Skip to content

findPackageVersions

findPackageVersions(project, packageName, options?): PackageVersionMatch[]

Defined in: simply-package-core/src/packageVersionLookup.ts:84

Find every place packageName is declared in a project, and the version declared with it.

A package can be declared four ways, all of which are searched:

  1. A dependency whose package is a versioned alias — test-package@0.1.0+2.
  2. A dependency whose package is a bare name plus a sibling versionNumber.
  3. A dependency whose package is a raw ID, where packageAliases maps a versioned alias for packageName onto that same ID.
  4. A package directory that builds packageName, i.e. the project’s own package version.

Matches are returned rather than resolved to a single answer because “the same package declared at two different versions in two directories” is a real project state, and only the caller knows whether that’s an error or a list to display.

SfdxProject

The parsed sfdx-project.json contents.

string

The package name or alias to look up.

FindPackageVersionsOptions = {}

Narrows which package directories are searched.

PackageVersionMatch[]

Every match, in package-directory order, dependencies before the directory’s own package. A match with no version means the package is declared but its version isn’t knowable from the project file alone.