1.0.8 • Published 6 years ago

sfdx-ez v1.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

sfdx-ez

sfdx-ez is a node module used to interact with Salesforce DX commands, hopefully in a more intuitive way than with the DX CLI itself. sfdx-ez is meant to take some of the nuances of using Salesforce DX and make common operations easier.

Installation

npm i sfdx-ez --save

Examples

(Sample project here.)

Here is a function that one might use to spin up an org and push code into it:

const dxez = require('sfdx-ez')

// options - all options to use for the relevant commands
//   (see sfdx-ez config documentation)
function spinup(options) {
  // Create a new scratch org
  dxez.create(options)
  // Push local code into the newly-created scratch org
  dxez.push(options)
  // Open the newly-created scratch org in a browser window
  dxez.open(options)
}

As another example, here is a function that pulls code from a scratch org, converts the local Salesforce DX code into Metadata API format, and deploys the converted code into a production (i.e. non-scratch) org.

const dxez = require('sfdx-ez')

// options - all options to use for the relevant commands
//   (see sfdx-ez config documentation)
function toproduction(options) {
  // Pull code from the scratch org
  dxez.pull(options)
  // Convert local Salesforce DX code into Metadata API format
  dxez.convert(options)
  // Deploy the formatted code into a non-scratch org
  //   'deployto' specifies to deploy to the org named 'MySandbox'
  dxez.deploy({
    deployto: 'MySandbox'
  })
}

To import all commands to be used in a CLI

All of the commands have a relevant terminal command (including shortcuts!), thanks to yargs. To import all of them, simply use the .yargs property of each to create the relevant command.

For example, to import all of the commands, do the following (ensure you have yargs installed):

#!/usr/bin/env node

const dxez = require('sfdx-ez')
const yargs = require('yargs')

// Import all commands
for (command of Object.keys(dxez)) {
  yargs.command(dxez[command].yargs)
}

// Add help option
yargs
  .help()
  .alias('h', 'help').argv

Then, if you save that file as "cli.js" and you add something like the following to your package.json and then run "npm link", the command "dx l" will list all connected orgs (for example)!

...
"bin": {
    "dx": "cli.js"
  },
...

Help / Documentation

** For help with the terminal commands, which includes seeing a command's shortcuts, use --help (or -h) on any command. To see help for ALL commands, use --help (or -h) on the root command (for example dx -h)!

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago