Clone the project and cd
into it:
$ git clone [email protected]:forcedotcom/salesforcedx-apex.git
$ cd salesforcedx-apex
Ensure you have Yarn installed, then run:
$ yarn install
$ yarn build
- We work in
develop
- Our released (production) branch is
main
- Our work happens in topic branches (feature and/or bug fix)
- These branches are based on
develop
and can live in forks for external contributors or within this repository for authors - Be sure to prefix branches in this repository with
<developer-name>/
- Be sure to keep branches up-to-date using
rebase
- These branches are based on
Link the plugin from the top-level project directory and then run your command:
$ yarn plugin:link
$ sfdx force:apex:log:list -u [email protected]
Install the library locally by adding this information to your project's package.json
:
"@salesforce/apex-node": "file://path/to/salesforcedx-apex/packages/apex-node"
Using the library directly requires access to a Salesforce Connection. Create an instance of the specific Apex service to get access to the required methods. For example, to get a list of logs:
$ const authInfo = await AuthInfo.create({ username: myAdminUsername });
$ const connection = await Connection.create({ authInfo });
$ const logService = new LogService(connection);
$ const logList = await logService.getLogRecords();
You can use the same pattern for the Test Service
and Execute Service
as well.
$ yarn test
When running tests, code changes don't need to be built with
yarn build
first because the test suite uses ts-node as its runtime environment. Otherwise, runyarn build
before manually testing changes.
We recommend using the Visual Studio Code (VS Code) IDE for your plugin development. Included in the .vscode
directory of this plugin is a launch.json
config file, which allows you to attach a debugger to the node process when running your commands. To debug a command:
- If you linked your plugin to the Salesforce CLI using
yarn plugin:link
, call your command with thedev-suspend
switch:
$ sfdx force:apex:log:list -u [email protected] --dev-suspend
Alternatively, replace sfdx
with NODE_OPTIONS=--inspect-brk bin/run
and run your command:
$ NODE_OPTIONS=--inspect-brk bin/run force:apex:log:list -u [email protected]
- Set some breakpoints in your code.
- Click on the Debug icon in the Activity Bar to open up the Debugger view.
- In the upper left hand corner, set the launch configuration to
Attach to Remote
. - Click the green play button on the left of the debugger view. The debugger should now by suspended on the first line of the program.
- Click the green play button in the mini toolbar to continue running the program.
Happy debugging!