@salesforce/plugin-apex

Apex commands

Usage no npm install needed!

<script type="module">
  import salesforcePluginApex from 'https://cdn.skypack.dev/@salesforce/plugin-apex';
</script>

README

Salesforce Apex Plugin

CircleCI npm (scoped) License Commitizen friendly

Introduction

This is an oclif plugin that supports the Salesforce Apex commands. The plugin is bundled with the salesforcedx plugin.

Note: This plugin is in beta and has been released early so we can collect feedback. It may contain bugs, undergo major changes, or be discontinued.

Building the Plugin

Clone the project and cd into it:

$ git clone git@github.com:forcedotcom/salesforcedx-apex.git
$ cd salesforcedx-apex

Ensure you have Yarn installed, then run:

$ yarn install
$ yarn build

Linking the Plugin

Link the plugin from the plugin-apex package directory and then run your command:

$ sfdx plugins:link .
$ sfdx force:apex:log:list -u myOrg@example.com

Alternatively, you can also run the command from the plugin-apex package directory without linking the plugin:

$ NODE_OPTIONS=--inspect-brk bin/run force:apex:log:list -u myOrg@example.com

### Running the Test Suite

Run the test suite locally by building the project first and then running the tests.

$ yarn build
$ yarn test

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 myOrg@example.com --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 myOrg@example.com
  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 be 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!