Salesforce CLI plugins are based on the oclif plugin framework. Read the plugin developer guide to learn about Salesforce CLI plugin development.
This repository contains a lot of additional scripts and tools to help with general Salesforce node development and enforce coding standards. You should familiarize yourself with some of the node developer packages used by Salesforce. There is also a default circleci config using the release management orb standards.
Additionally, there are some additional tests that the Salesforce CLI will enforce if this plugin is ever bundled with the CLI. These test are included by default under the posttest
script and it is recommended to keep these tests active in your plugin, regardless if you plan to have it bundled.
Everything past here is only a suggestion as to what should be in your specific plugin's description
This plugin is bundled with the Salesforce CLI. For more information on the CLI, read the getting started guide.
We always recommend using the latest version of these commands bundled with the CLI, however, you can install a specific version or tag if needed.
sfdx plugins:install [email protected]
Please report any issues at https://github.com/forcedotcom/cli/issues
- Please read our Code of Conduct
- Create a new issue before starting your project so that we can keep track of what you are trying to add/fix. That way, we can also offer suggestions or let you know if there is already an effort in progress.
- Fork this repository.
- Build the plugin locally
- Create a topic branch in your fork. Note, this step is recommended but technically not required if contributing using a fork.
- Edit the code in your fork.
- Write appropriate tests for your changes. Try to achieve at least 95% code coverage on any new code. No pull request will be accepted without unit tests.
- Sign CLA (see CLA below).
- Send us a pull request when you are done. We'll review your code, suggest any needed changes, and merge it in.
External contributors will be required to sign a Contributor's License Agreement. You can do so by going to https://cla.salesforce.com/sign-cla.
To build the plugin locally, make sure to have yarn installed and run the following commands:
# Clone the repository
git clone [email protected]:salesforcecli/plugin-signups
# Install the dependencies and compile
yarn install
yarn build
To use your plugin, run using the local ./bin/dev
or ./bin/dev.cmd
file.
# Run using local run file.
./bin/dev force:org:shape
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 sfdx cli
sfdx plugins:link .
# To verify
sfdx plugins
sf org create shape
sf org create snapshot
sf org delete shape
sf org delete snapshot
sf org get snapshot
sf org list shape
sf org list snapshot
Create a scratch org configuration (shape) based on the specified source org.
USAGE
$ sf org create shape -o <value> [--json] [--flags-dir <value>] [--api-version <value>]
FLAGS
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Create a scratch org configuration (shape) based on the specified source org.
Scratch org shapes mimic the baseline setup (features, limits, edition, and Metadata API settings) of a source org
without the extraneous data and metadata.
Run "sf org list shape" to view the available org shapes and their IDs.
To create a scratch org from an org shape, include the "sourceOrg" property in the scratch org definition file and set
it to the org ID of the source org. Then create a scratch org with the "sf org create scratch" command.
ALIASES
$ sf force org shape create
EXAMPLES
Create an org shape for the source org with alias SourceOrg:
$ sf org create shape --target-org SourceOrg
See code: src/commands/org/create/shape.ts
Create a snapshot of a scratch org.
USAGE
$ sf org create snapshot -v <value> -o <value> -n <value> [--json] [--flags-dir <value>] [--api-version <value>] [-d
<value>]
FLAGS
-d, --description=<value> Description of snapshot.
-n, --name=<value> (required) Unique name of snapshot.
-o, --source-org=<value> (required) ID or locally authenticated username or alias of scratch org to snapshot.
-v, --target-dev-hub=<value> (required) Username or alias of the Dev Hub org. Not required if the `target-dev-hub`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Create a snapshot of a scratch org.
A snapshot is a point-in-time copy of a scratch org. The copy is referenced by its unique name in a scratch org
definition file.
Use "sf org get snapshot" to get details, including status, about a snapshot creation request.
To create a scratch org from a snapshot, include the "snapshot" option (instead of "edition") in the scratch org
definition file and set it to the name of the snapshot. Then use "sf org create scratch" to create the scratch org.
ALIASES
$ sf force org snapshot create
EXAMPLES
Create a snapshot called "Dependencies" using the source scratch org ID and your default Dev Hub org:
$ sf org create snapshot --source-org 00Dxx0000000000 --name Dependencies --description 'Contains PackageA \
v1.1.0'
Create a snapshot called "NightlyBranch" using the source scratch org username and a Dev Hub org with alias
NightlyDevHub:
$ sf org create snapshot --source-org myuser@myorg --name NightlyBranch --description 'Contains PkgA v2.1.0 and \
PkgB 3.3.0' --target-dev-hub NightlyDevHub
FLAG DESCRIPTIONS
-d, --description=<value> Description of snapshot.
Use this description to document the contents of the snapshot. We suggest that you include a reference point, such
as a version control system tag or commit ID.
See code: src/commands/org/create/snapshot.ts
Delete all org shapes for a target org.
USAGE
$ sf org delete shape -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [-p]
FLAGS
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
-p, --no-prompt Don't prompt for confirmation.
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Delete all org shapes for a target org.
A source org can have only one active org shape. If you try to create an org shape for a source org that already has
one, the previous shape is marked inactive and replaced by a new active shape. If you don’t want to create scratch
orgs based on this shape, you can delete the org shape.
ALIASES
$ sf force org shape delete
EXAMPLES
Delete all org shapes for the source org with alias SourceOrg:
$ sf org delete shape --target-org SourceOrg
Delete all org shapes without prompting:
$ sf org delete shape --target-org SourceOrg --no-prompt
See code: src/commands/org/delete/shape.ts
Delete a scratch org snapshot.
USAGE
$ sf org delete snapshot -v <value> -s <value> [--json] [--flags-dir <value>] [--api-version <value>] [-p]
FLAGS
-p, --no-prompt Don't prompt the user to confirm the deletion.
-s, --snapshot=<value> (required) Name or ID of snapshot to delete.
-v, --target-dev-hub=<value> (required) Username or alias of the Dev Hub org. Not required if the `target-dev-hub`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Delete a scratch org snapshot.
Dev Hub admins can delete any snapshot. Users can delete only their own snapshots, unless a Dev Hub admin gives the
user Modify All permission, which works only with the Salesforce license.
ALIASES
$ sf force org snapshot delete
EXAMPLES
Delete a snapshot from the default Dev Hub using the snapshot ID:
$ sf org delete snapshot --snapshot 0Oo...
Delete a snapshot from the specified Dev Hub using the snapshot name:
$ sf org delete snapshot --snapshot BaseSnapshot --target-dev-hub SnapshotDevHub
FLAG DESCRIPTIONS
-s, --snapshot=<value> Name or ID of snapshot to delete.
The IDs of scratch org snapshots start with 0Oo.
See code: src/commands/org/delete/snapshot.ts
Get details about a scratch org snapshot.
USAGE
$ sf org get snapshot -v <value> -s <value> [--json] [--flags-dir <value>] [--api-version <value>]
FLAGS
-s, --snapshot=<value> (required) Name or ID of snapshot to retrieve.
-v, --target-dev-hub=<value> (required) Username or alias of the Dev Hub org. Not required if the `target-dev-hub`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Get details about a scratch org snapshot.
Snapshot creation can take a while. Use this command with the snapshot name or ID to check its creation status. After
the status changes to Active, you can use the snapshot to create scratch orgs.
To create a snapshot, use the "sf org create snapshot" command. To retrieve a list of all snapshots, use "sf org list
snapshot".
ALIASES
$ sf force org snapshot get
EXAMPLES
Get snapshot details using its ID and the default Dev Hub org:
$ sf org get snapshot --snapshot 0Oo...
Get snapshot details using its name from a Dev Hub org with alias SnapshotDevHub:
$ sf org get snapshot --snapshot Dependencies --target-dev-hub SnapshotDevHub
FLAG DESCRIPTIONS
-s, --snapshot=<value> Name or ID of snapshot to retrieve.
The IDs of scratch org snapshots start with 0Oo.
See code: src/commands/org/get/snapshot.ts
List all org shapes you’ve created.
USAGE
$ sf org list shape [--json] [--flags-dir <value>]
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
List all org shapes you’ve created.
The output includes the alias, username, and ID of the source org, the status of the org shape creation, and more. Use
the org ID to update your scratch org configuration file so you can create a scratch org based on this org shape.
ALIASES
$ sf force org shape list
EXAMPLES
List all org shapes you've created:
$ sf org list shape
List all org shapes in JSON format and write the output to a file:
$ sf org list shape --json > tmp/MyOrgShapeList.json
See code: src/commands/org/list/shape.ts
List scratch org snapshots.
USAGE
$ sf org list snapshot -v <value> [--json] [--flags-dir <value>] [--api-version <value>]
FLAGS
-v, --target-dev-hub=<value> (required) Username or alias of the Dev Hub org. Not required if the `target-dev-hub`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
List scratch org snapshots.
You can view all the snapshots in a Dev Hub that you have access to. If you’re an admin, you can see all snapshots
associated with the Dev Hub org. If you’re a user, you can see only your snapshots unless a Dev Hub admin gives you
View All permissions.
To create a snapshot, use the "sf org create snapshot" command. To get details about a snapshot request, use "sf org
get snapshot".
ALIASES
$ sf force org snapshot list
EXAMPLES
List snapshots in the default Dev Hub:
$ sf org list snapshot
List snapshots in the Dev Hub with alias SnapshotDevHub:
$ sf org list snapshot --target-dev-hub SnapshotDevHub
See code: src/commands/org/list/snapshot.ts