@pony-ci/sfdx-node
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

sfdx-node

CircleCI npm License

Execute sfdx commands in node.
The sfdx-cli itself doesn't have to be installed.

Usage

All commands are asynchronous.

// run tests
await sfdx.force.apex.test.run({targetusername: 'username'});

// set default username
await sfdx.force.config.set({}, 'defaultusername=username');

// set global default username
await sfdx.force.config.set({global: true}, 'defaultusername=username');

// suppress stdout and stderr
await sfdx.force.config.set({quiet: true}, 'defaultusername=username');

SFDX Plugins

This module includes the force plugin by default. You can override this plugin with a different version or even add support for other plugins. To add or override plugin, add node module containing the commands into dependencies in your package.json file. Then register the commands using registerNamespace function.

// override force plugin
const FORCE_PATH = path.dirname(require.resolve('salesforce-alm'));
registerNamespace({
    commandsDir: path.join(FORCE_PATH, 'commands'),
    namespace: 'force'
});

// add custom plugin
const PLUGIN_PATH = path.dirname(require.resolve('my-plugin-module'));
registerNamespace({
    commandsDir: path.join(PLUGIN_PATH, 'commands'),
    namespace: 'namespace'
});

Requirements for plugins.

  • Commands must be in the <commandsDir>/<namespace>/ directory.
  • Each command file must contain one of the following:
    • default export of a class extending SfdxCommand
    • export of a class extending the ToolbeltCommand and its name must be in camel case, without namespace name and with Command suffix, e.g. OrgCreateCommand for force/org/create.js file where force is a namespace.

Even some first versions of force commands don't fulfil these requirements.

License

This software is released under the MIT License.

Package Sidebar

Install

npm i @pony-ci/sfdx-node

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

27.5 kB

Total Files

28

Last publish

Collaborators

  • ponyci