The Salesforce CLI is built using oclif, which is an open source CLI framework owned and maintained by Salesforce. The primary benefit of using oclif is that it allows us to develop CLI plugins for specific feature areas. Some plugins are bundled with every CLI installation, while others can be installed if and when a user chooses.
This architecture allows us to empower internal teams and external contributors (aka plugin providers) to own and maintain their CLI commands, without having to create an entirely new CLI. It also allows plugin providers to keep their changes isolated from other plugins and it allows customers to preview features and fixes by manually installing a plugin before it's shipped in the CLI.
We write most of our business logic inside of NPM libraries that plugins can consume. This allows the commands in a plugin to be a light wrapper around the library and also enables other consumers to use the exact same functionality - for example, both @salesforce/plugin-deploy-retrieve and the Salesforce Extension pack for VsCode use the source-deploy-retrieve library to interact with Salesforce metadata.
Plugins are npm packages written in Typescript and are hosted in the public npm registry. These are the dependencies that are typical amongst all Salesforce plugins:
- plugin-deploy-retrieve
- plugin-env
- plugin-functions
- plugin-generate
- plugin-login
- plugin-settings
- plugin-telemetry
- plugin-info
- plugin-sobject
- plugin-autocomplete
- plugin-commands
- plugin-help
- plugin-not-found
- plugin-plugins
- plugin-update
- plugin-warn-if-update-available
- plugin-which
- plugin-version
- @oclif/core
- @salesforce/kit
- @salesforce/core
- @salesforce/ts-types
- @salesforce/sf-plugins-core
- @salesforce/source-deploy-retrieve
- @salesforce/source-tracking
- @salesforce/cli-plugins-testkit
- @salesforce/dev-config
- @salesforce/dev-scripts
- @salesforce/prettier-config
- @salesforce/ts-sinon
- eslint-config-salesforce
- eslint-config-salesforce-license
- eslint-config-salesforce-typescript
Below is a diagram that outlines at a high level the process that occurs every time a user executes a CLI command.