package2 Commands (Beta)

Use the package2 commands to create, install, and manage second-generation packages.

This release contains a beta version of the commands in the package2 topic, which means it’s a high-quality feature with known limitations. The commands in the package2 topic aren’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features. You can provide feedback and suggestions for the package2 commands in the Salesforce DX Beta group in the Success Community.

Note

package2:create (Beta)

Creates a second-generation package.

Command Syntax

sfdx force:package2:create
-n NAME
[-o CONTAINEROPTIONS]
[-d DESCRIPTION]
[-e]
[-v TARGETDEVHUBUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-n | --name NAME
Required

Name of the second-generation package to create.

Type: string
-o | --containeroptions CONTAINEROPTIONS
Optional

Container options for the package2.

Managed is default. Other options include Unlocked and Locked. (Managed=DeveloperManagedSubscriberManaged, Unlocked=DeveloperControlledSubscriberEditable, Locked=DeveloperControlledSubscriberLocked).

These options determine the upgrade and editability rules.

Type: string
-d | --description DESCRIPTION
Optional

Description of the second-generation package.

Type: string
-e | --nonamespace
Optional

Creates the package with no namespace. Available only for unlocked or locked packages. Useful when migrating an existing org to packages, but new metadata should use a namespaced package.

Type: flag
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for package2:create

This command must be run in a project.

First, use this command to create a second-generation package. Then create a package version.

To create a package with spaces in its name or description, enclose those values in single quotes.

Examples:

1$ sfdx force:package2:create -n PackageName -d 'My New Package' -o Unlocked

Run 'sfdx force:package2:list' to list all second-generation packages in the Dev Hub org.

package2:list (Beta)

Lists all second-generation packages in the Dev Hub org.

Command Syntax

sfdx force:package2:list
[-v TARGETDEVHUBUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for package2:list

You can view the namespace, IDs, and other details for each package.

package2:update (Beta)

Updates a second-generation package.

Command Syntax

sfdx force:package2:update
-i PACKAGE2ID
[-n NAME]
[-d DESCRIPTION]
[-v TARGETDEVHUBUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-i | --package2id PACKAGE2ID
Required

ID of package (starts with 0Ho).

Type: id
-n | --name NAME
Optional

Name of the package to update.

Type: string
-d | --description DESCRIPTION
Optional

Description of the package.

Type: string
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for package2:update

This command must be run in a project.

Specify a new value for each option you want to update.

Examples:

1$ sfdx force:package2:update --package2id 0Ho... --name 'AAnalytics'
1$ sfdx force:package2:update -i 0Ho... -d 'Advanced Analytics'

Run 'sfdx force:package2:list' to list all second-generation packages in the Dev Hub org.

package2:version:create (Beta)

Creates a second-generation package (package2) version in the Dev Hub org.

Command Syntax

sfdx force:package2:version:create
[-i PACKAGE2ID]
[-d DIRECTORY]
[-b BRANCH]
[-t TAG]
[-k INSTALLATIONKEY]
[-w WAIT]
[-v TARGETDEVHUBUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-i | --package2id PACKAGE2ID
Optional

ID of parent package (starts with 0Ho).

Type: id
-d | --directory DIRECTORY
Optional

The path to the directory that contains the contents of the package version.

Type: directory
-b | --branch BRANCH
Optional

The package version’s branch.

Type: string
-t | --tag TAG
Optional

The package version’s tag.

Type: string
-k | --installationkey INSTALLATIONKEY
Optional

Installation key for creating the key-protected package. The default is null.

Type: string
-w | --wait WAIT
Optional

The number of minutes to wait for the package version to be created.

Type: minutes
Default value: 0
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for package2:version:create

This command must be run in a project.

The package version is based on the package contents in the specified directory.

To retrieve details about a package version create request, including status and package2 version ID (05i), run "sfdx force:package2:version:create:get -i 08c...".

To list package version creation requests in the org, run "sfdx force:package2:version:create:list".

Examples:

1$ sfdx force:package2:version:create -d common
1$ sfdx force:package2:version:create -i 0Ho... -d common

package2:version:create:get (Beta)

Retrieves a second-generation package version creation request in the Dev Hub org.

Command Syntax

sfdx force:package2:version:create:get
-i PACKAGE2CREATEREQUESTID
[-v TARGETDEVHUBUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-i | --package2createrequestid PACKAGE2CREATEREQUESTID
Required

The ID of the package2 version creation request you want to display.

Type: id
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for package2:version:create:get

Specify the request ID for which you want to view details. If applicable, the command displays errors related to the request.

Examples:

1$ sfdx force:package2:version:create:get --package2createrequestid 08c...

To show all requests in the org, run "sfdx force:package2:version:create:list".

package2:version:create:list (Beta)

Lists all requests to create second-generation package (package2) versions in the Dev Hub org.

Command Syntax

sfdx force:package2:version:create:list
[-c CREATEDLASTDAYS]
[-s STATUS]
[-v TARGETDEVHUBUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-c | --createdlastdays CREATEDLASTDAYS
Optional

Filters the list based on the specified maximum number of days since the request was created (starting at 00:00:00 of first day to now; 0 for today).

Type: number
-s | --status STATUS
Optional

Filters the list based on the status of version creation requests.

Type: string
Permissible values are: Queued, InProgress, Success, Error
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for package2:version:create:list

Shows the details of each request to create a package2 version that's run in the Dev Hub org.

All filter parameters are applied using the AND logical operator (not OR).

To get information about a specific request, run "sfdx force:package2:version:create:get" and supply the request ID.

Examples:

1$ sfdx force:package2:version:create:list
1$ sfdx force:package2:version:create:list --createdlastdays 3
1$ sfdx force:package2:version:create:list --status Error
1$ sfdx force:package2:version:create:list -s InProgress
1$ sfdx force:package2:version:create:list -c 3 -s Success

package2:version:get (Beta)

Retrieves a package version in the Dev Hub org.

Command Syntax

sfdx force:package2:version:get
-i PACKAGE2VERSIONID
[-v TARGETDEVHUBUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-i | --package2versionid PACKAGE2VERSIONID
Required

The package version ID (starts with 05i).

Type: id
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for package2:version:get

This command must be run in a project.

Examples:

1$ sfdx force:package2:version:get --package2versionid 05i...

To update package version values, run "sfdx force:package2:version:update".

package2:version:list (Beta)

Lists all package2 versions in the Dev Hub org.

Command Syntax

sfdx force:package2:version:list
[-c CREATEDLASTDAYS]
[-m MODIFIEDLASTDAYS]
[-i PACKAGE2IDS]
[-r]
[-o ORDERBY]
[-v TARGETDEVHUBUSERNAME]
[--concise]
[--json]
[--loglevel LOGLEVEL]
[--verbose]

Parameters

-c | --createdlastdays CREATEDLASTDAYS
Optional

Filters the list based on the specified maximum number of days since the request was created (starting at 00:00:00 of first day to now; 0 for today).

Type: number
-m | --modifiedlastdays MODIFIEDLASTDAYS
Optional

Lists the items modified in the specified last number of days, starting at 00:00:00 of first day to now. Use 0 for today.

Type: number
-i | --package2ids PACKAGE2IDS
Optional

Filters results on the specified comma-delimited package2 IDs (start with 0Ho).

Type: string
-r | --released
Optional

Displays released versions only (IsBeta=false).

Type: flag
-o | --orderby ORDERBY
Optional

Orders the list by the specified package2 version fields.

Type: string
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--concise
Optional

Displays limited package2 version details.

Type: flag
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error
--verbose
Optional

Display extended package2 versions detail.

Type: flag

Help for package2:version:list

Displays details of each package2 version in the org.

Use --concise or --verbose to display limited or additional details, respectively.

All filter parameters are applied using the AND logical operator (not OR).

Examples:

1$ sfdx force:package2:version:list --verbose --createdlastdays 3 --released --orderby PatchVersion
1$ sfdx force:package2:version:list --package2ids 0Ho000000000000,0Ho000000000001 --released --modifiedlastdays 0
1$ sfdx force:package2:version:list --released
1$ sfdx force:package2:version:list --concise --modifiedlastdays 0
1$ sfdx force:package2:version:list --concise -c 3 -r

package2:version:update (Beta)

Updates a second-generation package version in the Dev Hub org.

Command Syntax

sfdx force:package2:version:update
-i PACKAGE2VERSIONID
[-n NAME]
[-d DESCRIPTION]
[-b BRANCH]
[-t TAG]
[-k INSTALLATIONKEY]
[-s]
[-p]
[-v TARGETDEVHUBUSERNAME]
[--json]
[--loglevel LOGLEVEL]

Parameters

-i | --package2versionid PACKAGE2VERSIONID
Required

The package version ID (starts with 05i).

Type: id
-n | --name NAME
Optional

The package version name.

Type: string
-d | --description DESCRIPTION
Optional

The second-generation package version description.

Type: string
-b | --branch BRANCH
Optional

The second-generation package version branch.

Type: string
-t | --tag TAG
Optional

The second-generation package version tag.

Type: string
-k | --installationkey INSTALLATIONKEY
Optional

Installation key for creating the key-protected package. The default is null.

Type: string
-s | --setasreleased
Optional

Sets the second-generation package version as released. Second-generation packages can’t be changed to beta after they’ve been released.

Type: flag
-p | --noprompt
Optional

No prompt to confirm setting the package version as released.

Type: flag
-v | --targetdevhubusername TARGETDEVHUBUSERNAME
Optional

A username or alias for the target Dev Hub org. Overrides the default Dev Hub org.

Type: string
--json
Optional

Format output as JSON.

Type: flag
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sfdx/sfdx.log.

Type: string
Permissible values are: trace, debug, info, warn, error, fatal
Default value: error

Help for package2:version:update

This command must be run in a project.

Specify a new value for each option you want to update.

Examples:

1$ sfdx force:package2:version:update --package2versionid 05i... --setasreleased
1$ sfdx force:package2:version:update -i 05i... -b master -t 'Release 1.0.7'

To display details about a package2 version, run "sfdx force:package2:version:get".