plugin-org
Commands for working with Salesforce orgs. As the Salesforce CLI is transitioning commands owned by various teams to open source, it may not represent all of the org
commands.
About Salesforce CLI plugins
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.
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.
Install
sfdx plugins:install @salesforce/plugin-org
Issues
Please report any issues at https://github.com/forcedotcom/cli/issues
Contributing
- 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.
CLA
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.
Build
To build the plugin locally, make sure to have yarn installed and run the following commands:
git clone git@github.com:salesforcecli/plugin-org
yarn install
yarn build
To use your plugin, run using the local ./bin/run
or ./bin/run.cmd
file.
./bin/run force:org:list
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.
sfdx plugins:link .
sfdx plugins
Commands
sfdx force:org:beta:create [name=value...] [-t scratch|sandbox] [-f <filepath>] [-n] [-c] [-i <string>] [-s] [-a <string>] [-w <minutes>] [-d <integer>] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
create a scratch or sandbox org
USAGE
$ sfdx force:org:beta:create [name=value...] [-t scratch|sandbox] [-f <filepath>] [-n] [-c] [-i <string>] [-s] [-a
<string>] [-w <minutes>] [-d <integer>] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-a, --setalias=setalias alias for the created org
-c, --noancestors do not include second-generation
package ancestors in the scratch org
-d, --durationdays=durationdays duration of the scratch org (in
days) (default:7, min:1, max:30)
-f, --definitionfile=definitionfile path to an org definition file
-i, --clientid=clientid connected app consumer key; not
supported for sandbox org creation
-n, --nonamespace create the scratch org with no
namespace
-s, --setdefaultusername set the created org as the default
username
-t, --type=(scratch|sandbox) [default: scratch] type of org to
create
-u, --targetusername=targetusername username or alias for the target
org; overrides default target org
-v, --targetdevhubusername=targetdevhubusername username or alias for the dev hub
org; overrides default dev hub org
-w, --wait=wait [default: 6 minutes] the streaming
client socket timeout (in minutes)
--apiversion=apiversion override the api version used for
api requests made by this command
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation
DESCRIPTION
Creates a scratch org or a sandbox org using the values specified in a configuration file or key=value pairs that you
specify on the command line. Values specified on the command line override values in the configuration file. Specify a
configuration file or provide key=value pairs while creating a scratch org or a sandbox. When creating scratch orgs,
—targetdevhubusername (-v) must be a Dev Hub org. When creating sandboxes, the --targetusername (-u) must be a
production org with sandbox licenses. The —type (-t) is required if creating a sandbox.
EXAMPLES
$ sfdx force:org:create -f config/enterprise-scratch-def.json -a MyScratchOrg
$ sfdx force:org:create edition=Developer -a MyScratchOrg -s -v devHub
$ sfdx force:org:create -f config/enterprise-scratch-def.json -a ScratchOrgWithOverrides
username=testuser1@mycompany.org
$ sfdx force:org:create -t sandbox -f config/dev-sandbox-def.json -a MyDevSandbox -u prodOrg
See code: src/commands/force/org/beta/create.ts
sfdx force:org:delete [-p] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
mark a scratch or sandbox org for deletion
USAGE
$ sfdx force:org:delete [-p] [-v <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-p, --noprompt no prompt to confirm deletion
-u, --targetusername=targetusername username or alias for the target
org; overrides default target org
-v, --targetdevhubusername=targetdevhubusername username or alias for the dev hub
org; overrides default dev hub org
--apiversion=apiversion override the api version used for
api requests made by this command
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation
DESCRIPTION
To mark the org for deletion without being prompted to confirm, specify --noprompt.
EXAMPLES
$ sfdx force:org:delete -u me@my.org
$ sfdx force:org:delete -u MyOrgAlias -p
See code: src/commands/force/org/delete.ts
sfdx force:org:display [-u <string>] [--apiversion <string>] [--verbose] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
get the description for the current or target org
USAGE
$ sfdx force:org:display [-u <string>] [--apiversion <string>] [--verbose] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-u, --targetusername=targetusername username or alias for the target
org; overrides default target org
--apiversion=apiversion override the api version used for
api requests made by this command
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation
--verbose emit additional command output to
stdout
DESCRIPTION
Output includes your access token, client Id, connected status, org ID, instance URL, username, and alias, if
applicable.
Use --verbose to include the SFDX auth URL. WARNING: The SFDX auth URL contains sensitive information, such as a
refresh token that can be used to access an org. Don't share or distribute this URL or token.
Including --verbose displays the sfdxAuthUrl property only if you authenticated to the org using auth:web:login (not
auth:jwt:grant)
EXAMPLES
sfdx force:org:display
sfdx force:org:display -u me@my.org
sfdx force:org:display -u TestOrg1 --json
sfdx force:org:display -u TestOrg1 --json > tmp/MyOrgDesc.json
See code: src/commands/force/org/display.ts
sfdx force:org:list [--all] [-p --clean] [--skipconnectionstatus] [--verbose] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
list all orgs you’ve created or authenticated to
USAGE
$ sfdx force:org:list [--all] [-p --clean] [--skipconnectionstatus] [--verbose] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-p, --noprompt do not prompt for confirmation
--all include expired, deleted, and
unknown-status scratch orgs
--clean remove all local org authorizations
for non-active orgs
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation
--skipconnectionstatus skip retrieving the connection
status of non-scratch orgs
--verbose list more information about each org
EXAMPLES
sfdx force:org:list
sfdx force:org:list --verbose --json
sfdx force:org:list --verbose --json > tmp/MyOrgList.json
See code: src/commands/force/org/list.ts
sfdx force:org:open [-b <string> | -r] [-p <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
open your default scratch org, or another specified org
USAGE
$ sfdx force:org:open [-b <string> | -r] [-p <string>] [-u <string>] [--apiversion <string>] [--json] [--loglevel
trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL]
OPTIONS
-b, --browser=chrome|edge|firefox browser where the org opens
-p, --path=path navigation URL path
-r, --urlonly display navigation URL, but don’t
launch browser
-u, --targetusername=targetusername username or alias for the target
org; overrides default target org
--apiversion=apiversion override the api version used for
api requests made by this command
--json format output as json
--loglevel=(trace|debug|info|warn|error|fatal|TRACE|DEBUG|INFO|WARN|ERROR|FATAL) [default: warn] logging level for
this command invocation
DESCRIPTION
To open a specific page, specify the portion of the URL after "https://MyDomainName.my.salesforce.com/" as --path.
For example, specify "--path lightning" to open Lightning Experience, or specify "--path /apex/YourPage" to open a
Visualforce page.
To generate a URL but not launch it in your browser, specify --urlonly.
To open in a specific browser, use the --browser parameter. Supported browsers are "chrome", "edge", and "firefox". If
you don't specify --browser, the org opens in your default browser.
EXAMPLES
sfdx force:org:open
sfdx force:org:open -u me@my.org
sfdx force:org:open -u MyTestOrg1
sfdx force:org:open -r -p lightning
sfdx force:org:open -u me@my.org -b firefox
See code: src/commands/force/org/open.ts