sfpm
Concepts

Deploy vs install

What sfpm deploy, sfpm deploy artifact, and sfpm install each send to a target org, and when to use each one.

Three commands put packages into an org. They differ in where the package content comes from and in what they send. Pick the command by the source you want to deploy.

CommandContent comes fromUnlocked packagesSource packagesData packagesManaged dependenciesAlready-installed check
sfpm deploy <packages> -o <org>Local project sourceSource deploy.Source deploy.SFDMU import.Not included.Off by default (--force). --no-force checks.
sfpm deploy artifact <packages> -o <org>Built artifacts in node_modulesSource deploy, even when the artifact has a package version.Source deploy.SFDMU import.Installed.Off by default (--force). --no-force checks.
sfpm install <packages> -o <org>Built artifacts in node_modulesPackage version install (04t) when the artifact has one. Otherwise source deploy.Source deploy.SFDMU import.Installed.On by default. --force reinstalls.

sfpm deploy

sfpm deploy sends the current local source for each named package to the org. Use it while you iterate, or for source packages you want to push from your working tree.

  • Dependencies deploy first, unless you pass --no-dependencies.
  • --force is on by default, so the package deploys even when the org already has the same version. Pass --no-force to skip packages that match the org.
  • Lifecycle hooks run in the deploy stage. Pass --no-hooks to skip them.
  • --test-level (-l) sets the Apex test level for the source deploy.

sfpm deploy artifact

sfpm deploy artifact deploys what a build already produced, not the working tree. Before the deploy, it fetches the named artifacts into node_modules with npm install --no-save. It then source-deploys each one from its artifact folder.

Unlocked packages are source-deployed here, even when their artifact carries a package version ID. To install the version instead, use sfpm install.

Use this command in a pipeline that builds and publishes once, then deploys the published output.

sfpm install

sfpm install installs the artifacts that node_modules provides, and it chooses the method for each package:

  • An unlocked artifact with a package version ID (04t) is installed as that version. Installation keys go in with --installation-key (-k).
  • An unlocked artifact without a package version ID is source-deployed.
  • A source package is source-deployed.
  • A data package runs an SFDMU import.
  • A managed dependency is installed as its subscriber package version.

Before each package, sfpm install checks the org. A package is skipped when the org already has the same source hash or the same package version. --force (-f) turns the check off. The check details are on the caching page.

Like deploy artifact, install fetches the artifacts with npm install --no-save, so the workspace package.json does not change. --target-org (-o) is required. Lifecycle hooks run in the install stage.

Which one to use

  • Working on a package in a sandbox: sfpm deploy.
  • A pipeline deploys the output of a build: sfpm deploy artifact.
  • Installing a released package version, or installing into an org that should skip what it already has: sfpm install.

Test levels

sfpm deploy and sfpm install take --test-level (-l) for source deploys. The options are NoTestRun, RunSpecifiedTests, RunLocalTests, and RunAllTestsInOrg. Without the flag, source deploys run with NoTestRun.

Next

On this page