Newer Version Available

This content describes an older version of this product. View Latest

Extract Dependency Information from Unlocked Packages

For an installed unlocked package, you can now run a simple SOQL query to extract its dependency information. You can also create a script to automate the installation of unlocked packages with dependencies.

The SubscriberPackageVersion Tooling API object now provides dependency information. Using a SOQL query on SubscriberPackageVersion, you can identify the packages on which your unlocked package has a dependency. You can get the (04t) IDs and the correct install order for those packages.

Example

Package B has a dependency on package A. Package D depends on packages B and C. Here’s a sample sfdx-project.json that you would have specified while creating a package version. Package D dependencies are noted as packages A, B, and C.
Before installing pkgD (with ID=04txx000000082hAAA), use this SOQL query to determine its dependencies. The username is typically the target subscriber org where the unlocked package is to be installed.
You see this output when you run the query, with the (04t) IDs for pkgA, pkgB, and pkgC in that order.