This repository provides a simple example of a Salesforce CLI plugin that does three things.
- Creates a "hello world" CLI command:
sf hello world
. - Creates a CLI hook that runs before any
sf
command is executed. - Creates a CLI hook that listens for a "pre deploy" event and takes action based on the contents of the deployment.
TODO: Update the rest of this doc.
curl https://raw.githubusercontent.com/ImJohnMDaniel/sed24-hot-create-cli-plugin/main/setup-training-lab | bash
sf plugins install [email protected]
To build the plugin locally, make sure to have yarn installed and run the following commands:
# Clone the repository
git clone [email protected]:salesforcecli/deployment-validator
# Install the dependencies and compile
yarn && yarn build
To use your plugin, run using the local ./bin/dev
or ./bin/dev.cmd
file.
# Run using local run file.
./bin/dev hello world
There should be no differences when running via the Salesforce CLI or using the local run file. However, it can be useful to link the plugin to do some additional testing or run your commands from anywhere on your machine.
# Link your plugin to the sf cli
sf plugins link .
# To verify
sf plugins
Say hello either to the world or someone you know.
USAGE
$ sf hello world [--json] [-n <value>]
FLAGS
-n, --name=<value> [default: World] The name of the person you'd like to say hello to.
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
Say hello either to the world or someone you know.
Say hello either to the world or someone you know.
EXAMPLES
Say hello to the world:
$ sf hello world
Say hello to someone you know:
$ sf hello world --name Astro