RoadmapShopEvents
Skip to main content

Home > @microsoft/rush-lib > CommonVersionsConfiguration

CommonVersionsConfiguration class

Use this class to load and save the "common/config/rush/common-versions.json" config file. This config file stores dependency version information that affects all projects in the repo.

Signature:
export declare class CommonVersionsConfiguration

Properties

PropertyModifiersTypeDescription
allowedAlternativeVersionsMap<string, ReadonlyArray<string>>A table that stores, for a given dependency, a list of SemVer ranges that will be accepted by "rush check" in addition to the normal version range.
filePathstringGet the absolute file path of the common-versions.json file.
implicitlyPreferredVersionsboolean | undefinedWhen set to true, for all projects in the repo, all dependencies will be automatically added as preferredVersions, except in cases where different projects specify different version ranges for a given dependency. For older package managers, this tended to reduce duplication of indirect dependencies. However, it can sometimes cause trouble for indirect dependencies with incompatible peerDependencies ranges. If the value is undefined, then the default value is true.
preferredVersionsMap<string, string>A table that specifies a "preferred version" for a given NPM package. This feature is typically used to hold back an indirect dependency to a specific older version, or to reduce duplication of indirect dependencies.
xstitchPreferredVersionsMap<string, string>A table of specifies preferred versions maintained by the XStitch tool.

Methods

MethodModifiersDescription
getAllPreferredVersions()Returns the union of preferredVersions and xstitchPreferredVersions.
getPreferredVersionsHash()Get a sha1 hash of the preferred versions.
loadFromFile(jsonFilename)staticLoads the common-versions.json data from the specified file path. If the file has not been created yet, then an empty object is returned.
save()Writes the "common-versions.json" file to disk, using the filename that was passed to loadFromFile().