Deploy and install
Deploy from local source, deploy or install published artifacts, and publish built packages to npm.
Four commands move packages toward an org or a registry. They differ in where they read from and where they write to. Pick the one that matches what you have.
| Command | Reads from | Writes to | Use it when |
|---|---|---|---|
sfpm deploy | Local project source | Target org | You want to deploy the source in your working copy. |
sfpm deploy artifact | Published artifacts from npm | Target org | You want to deploy the source of published package versions. |
sfpm install | Published artifacts from npm | Target org | You want to install published packages, with installation keys where needed. |
sfpm publish | Built output in each dist/ directory | npm registry | You want to publish packages that sfpm build has built. |
For the concepts behind deploy and install, see deploy vs install.
The deploy GitHub Action runs the artifact-install flow, the same kind of
operation as sfpm deploy artifact, not sfpm deploy (which deploys from
local project source). The action and the CLI command are not identical:
check the action's action.yml for its own inputs and defaults rather than
assuming full parity.
sfpm deploy
Deploys the named packages from the source in your project to the target org.
Dependencies are included unless you pass --no-dependencies.
sfpm deploy <package> [<package>...] [flags]| Flag | Default | Description |
|---|---|---|
-o, --target-org <username> | target-org from sf config | Target org username or alias. Env: SF_TARGET_ORG. Required. Falls back to the sf config default when unset. |
-f, --force | on | Deploys even when the package is already installed. Turn it off with --no-force. |
--no-dependencies | off | Deploys only the named packages, without their transitive dependencies. |
--no-hooks | off | Skips lifecycle hooks for this run. |
-l, --test-level <level> | none | Deployment test level: NoTestRun, RunSpecifiedTests, RunLocalTests, or RunAllTestsInOrg. |
--regression-test | off | Accepted by the command, but currently has no effect: nothing passes it through to the step that would run dependent-package tests. |
--turbo | off | Single-package mode for external orchestrators. Requires exactly one package. Implies --no-dependencies and --force. |
The shared flags --json, --plain, and --log-level also apply. See the
CLI reference.
sfpm deploy artifact
Takes the same flags and arguments as sfpm deploy. The difference is the
source. Before deploying, the command runs npm install --no-save for the
named packages in the project root. That step fetches their published artifacts
and any sfpm packages they depend on. The command then deploys the source from
those artifacts to the target org.
Publish the packages first with sfpm publish, so the
artifacts exist in the registry.
sfpm deploy artifact my-package -o my-sandboxdeploy artifact accepts --test-level because it inherits every flag from
sfpm deploy, but the value is never passed through to the artifact install
path. Setting it currently has no effect on this command.
sfpm install
Fetches the named packages and their sfpm dependencies from npm, then installs
them into the target org. The fetch uses npm install --no-save, not pnpm. It
runs in the project root and does not change package.json.
An artifact with a package version ID installs as a package version;
installation keys apply to it. An unlocked package built at the default
local validation level has no package version ID (it was built as a plain
source package), so installing that artifact is a source deploy instead, the
same as installing a source-type package.
sfpm install <package> [<package>...] -o my-sandbox [flags]| Flag | Default | Description |
|---|---|---|
-o, --target-org <username> | none | Target org username or alias. Env: SF_TARGET_ORG. Required. Unlike deploy, there is no sf config fallback. |
-f, --force | off | Reinstalls even when the package is already installed. |
-k, --installation-key <key> | none | Installation key for unlocked packages. Repeatable. Pass <package>=<key> for one package, or a bare value as the default for all packages. |
--no-dependencies | off | Declared, but currently has no effect: install always resolves the named packages together with their transitive sfpm dependencies, regardless of this flag. |
-l, --test-level <level> | none | Test level for source deployments. Same values as sfpm deploy. |
--regression-test | off | Accepted by the command, but currently has no effect, same as on sfpm deploy. |
--turbo | off | Single-package mode for external orchestrators. Requires exactly one package. Implies --no-dependencies and --force. |
install runs the install lifecycle hooks. It has no --no-hooks flag.
sfpm publish
Publishes packages from their dist/ directories to npm. Run
sfpm build first. A package without a built dist/package.json
is skipped with a warning.
With no arguments, or with all, the command publishes every package in the
workspace. Each package is published by running pnpm publish --no-git-checks
inside its dist/ directory.
| Flag | Default | Description |
|---|---|---|
--tag <tag> | latest | npm dist-tag to publish under, such as next. |
--dry-run | off | Passes --dry-run to pnpm, so nothing is published. |
sfpm publish my-package --tag next --dry-run
sfpm publish allTypical flow
sfpm build my-package
sfpm publish my-package
sfpm install my-package -o my-sandboxUse sfpm deploy while you change source and want the working copy in an org.
Use sfpm publish and then sfpm install or sfpm deploy artifact when the
target should receive the published version.
This flow builds at the default local validation level, so the install step
above is a source deploy, not a package-version install (see the note on
sfpm install above). Add --validation org (or full) to sfpm build first
if you need an actual package version installed.