Skip to content

Add argument to specify "ancestor" with force:package:version:create #178

@douglascayers

Description

@douglascayers

Is your feature request related to a problem? Please describe.

In a CI/CD setup, I automate the creation of package versions. No developers maintain the sfdx-project.json file. We are creating 2GP managed packages and one of the requirements for a new managed package version to be upgradeable in the subscriber org is if the new package version specified an ancestor id.

Currently, the ancestor package version id can only be specified in the sfdx-project.json file. Which means someone or something must manage this file before running the force:package:version:create command.

What are you trying to do

Specify the ancestor package version id as an argument to force:package:version:create command like I can specify versionnumber so that it is easier to script package version creation with no maintenance of sfdx-project.json.

Describe the solution you'd like

A new flag added to the force:package:version:create command to specify the ancestor.

--ancestor  -c  -- ID (starts with 05i) or alias of the immediate parent package version of the version to be created

Example Usage

sfdx force:package:version:create --ancestor 05iB00000004CIeIAM --versionnumber 1.2.0.5 --package MyPackage

sfdx force:package:version:create -c 05iB00000004CIeIAM -n 1.2.0.5 -p MyPackage

Describe alternatives you've considered

In our CI/CD service, I use a custom bash script to update the sfdx-project.json with the ancestorId value, create the package version, then discard the file changes.

https://gist.github.com/douglascayers/e3a9525729a1b512618adf720e3fbe94

With that script, then our project's sfdx-project.json can be as simple as the following and never be updated or maintained as the script handles determining the correct next major.minor.patch.build version number, ancestor id, and promoting versions.

{
    "packageDirectories": [
        {
            "path": "force-app",
            "default": true,
            "package": "MyPackage",
            "versionNumber": "1.0.0.NEXT"
        }
    ],
    "namespace": "my_namespace",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "46.0",
    "packageAliases": {
        "MyPackage": "0Hoxxx"
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:packagingfeatureIssue or pull request for a new featureowned by another teamThe Salesforce CLI team does not own this work but will pass on the information to the correct team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions