📢 Attention Salesforce Certified Trailblazers! Maintain your credentials and link your Trailhead and Webassessor accounts by April 19th. Learn more.
close

Update Your Unlocked Package

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.

  1. sfdx force:org:create -s -f config/project-scratch-def.json
  2. sfdx force:source:push
  3. sfdx force:user:permset:assign -n GIFter
  4. sfdx force:org:open -p lightning/n/GIFter

    Does it look good? Excellent!

  5. To prepare for creating the package version, open the sfdx-project.json file again, this time to update the versionName 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 '18 (new color)",
             "versionNumber": "1.1.0.NEXT"
          }
       ],
       "namespace": "",
       "sfdcLoginUrl": "https://login.salesforce.com",
       "sourceApiVersion": "43.0",
       "packageAliases": {
          "GIFter": "0Hoxxx",
          "GIFter@1.0.0-1": "04txxx"
       }
    }
  6. Now, let’s create a package version containing your app with the updated source.
    sfdx force:package:version:create -p GIFter -d force-app -k test1234 \
    --wait 10 -v 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 "sfdx force:package:install" command.
  7. Install and test the package version in a fresh scratch org.
    sfdx force:org:create -s -f config/project-scratch-def.json
    sfdx force:package:install --wait 10 --publishwait 10 --package GIFter@1.1.0-1 \ 
    -k test1234 --noprompt
    sfdx force:user:permset:assign -n GIFter
    sfdx force:org:open -p 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.
    sfdx force:package:install -u MyTP --wait 10 --package GIFter@1.1.0-1 \ 
    -k test1234 --noprompt

    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.
    sfdx force:org:open -p lightning/n/GIFter -u 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.

retargeting