Skip to main content

Update Your Unlocked Package

Your company is going to grow and change over time, and your apps are likely to do the same. Unlocked packages provide a robust and easy way to test, package, and deploy changes to your apps.

It doesn’t really matter what you change. That’s not the point of this quick start.

Here are the basic steps to test your change before you create the updated package version.
sf org create scratch --definition-file config/project-scratch-def.json
sf project deploy start
sf org assign permset --name GIFter
sf org open --path lightning/n/GIFter


Does it look good? Excellent!

  1. To prepare for creating the package version, open the sfdx-project.json file again, this time to update the versionNumber to reflect the new version of the package. To reflect that it’s a minor version change, increment the versionNumber to 1.1.0.
    {
       "packageDirectories": [
          {
             "path": "force-app",
             "default": true,
             "package": "GIFter",
             "versionName": "Summer '22",
             "versionNumber": "1.1.0.NEXT"
          }
       ],
       "namespace": "",
       "sfdcLoginUrl": "https://login.salesforce.com",
       "sourceApiVersion": "55.0",
       "packageAliases": {
          "GIFter": "0Hoxxx",
          "GIFter@1.0.0-1": "04txxx"
       }
    }
  2. Now, let’s create a package version containing your app with the updated source.
    sf package version create --package GIFter --path force-app --installation-key test1234 --wait 10 --target-dev-hub DevHub
    Successfully created the package version [08cxxx]. Subscriber Package Version Id: 04txxx.
    Package Installation URL: https://login.salesforce.com/packaging/installPackage.apexp?p0=04txxx
    As an alternative, you can use the "sf package install" command.
  3. Install and test the package version in a fresh scratch org.
    sf org create scratch --definition-file config/project-scratch-def.json
    sf package install --wait 10 --publish-wait 10 --package GIFter@1.1.0-1 --installation-key test1234 --no-prompt
    sf org assign permset --name GIFter
    sf org open --path lightning/n/GIFter

You’re getting the idea, right?

OK, testing is successful. Let’s install it to our TP.

Install New Package Version in Your TP

Your work is mostly done at this point. Since you’ve done such a great job of testing along the way, we can feel confident about this last step.

  1. Install the package version in your TP.
    sf package install --target-org MyTP --wait 10 --package GIFter@1.1.0-1 --installation-key test1234 --no-prompt
    You don’t have to assign the perm set again because it’s already in the org from your install of the previous package version.

  2. And finally, one last time, open your TP and run the app.
    sf org open --path lightning/n/GIFter --target-org MyTP
Bingo! You’ve updated your app and deployed those changes using your unlocked package. If you look at the Installed Package Detail info, notice that the version name is appropriately updated.
  1. From Setup, enter Installed Packages in the Quick Find box, and select Installed Packages.

  2. Select GIFter.
The Installed Package Details dialog lists information for GIFter, such as version name, version number, and package type. You can view its components or dependencies by clicking the appropriate button.

More Info

We hope this quick start got you excited about the next evolution in packaging technology and helped you see the promise of unlocked packages. For more details about the power of unlocked packages, earn another badge by completing the Unlocked Packages for Customers module.

Keep learning for
free!
Sign up for an account to continue.
What’s in it for you?
  • Get personalized recommendations for your career goals
  • Practice your skills with hands-on challenges and quizzes
  • Track and share your progress with employers
  • Connect to mentorship and career opportunities