Skip to content

Latest commit

 

History

History
97 lines (66 loc) · 3.05 KB

developing.md

File metadata and controls

97 lines (66 loc) · 3.05 KB

Developing

Getting Started

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

Branches

  • 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

Development

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.


Testing

Running the Test Suite

$ 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, run yarn build before manually testing changes.


Debugging the Plugin

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:

  1. If you linked your plugin to the Salesforce CLI using yarn plugin:link, call your command with the dev-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]
  1. Set some breakpoints in your code.
  2. Click on the Debug icon in the Activity Bar to open up the Debugger view.
  3. In the upper left hand corner, set the launch configuration to Attach to Remote.
  4. 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.
  5. Click the green play button in the mini toolbar to continue running the program.


Happy debugging!