https://github.com/pony-ci/sfdx-node
Execute SFDX commands in node.
https://github.com/pony-ci/sfdx-node
cli node nodejs salesforce salesforcedx sfdx sfdx-cli
Last synced: 2 days ago
JSON representation
Execute SFDX commands in node.
- Host: GitHub
- URL: https://github.com/pony-ci/sfdx-node
- Owner: pony-ci
- License: mit
- Created: 2020-04-09T14:06:09.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-09T16:54:23.000Z (over 2 years ago)
- Last Synced: 2025-04-28T13:04:36.448Z (2 days ago)
- Topics: cli, node, nodejs, salesforce, salesforcedx, sfdx, sfdx-cli
- Language: TypeScript
- Homepage:
- Size: 401 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sfdx-node
[](https://circleci.com/gh/pony-ci/sfdx-node)
[](https://badge.fury.io/js/%40pony-ci%2Fsfdx-node)
[](https://github.com/pony-ci/sfdx-node/blob/master/LICENSE)Execute sfdx commands in node.
The sfdx-cli itself doesn't have to be installed.## Usage
All commands are asynchronous.
```javascript
// 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.
```javascript
// 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 `//` 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](https://github.com/pony-ci/sfdx-node/blob/master/LICENSE).