Skip to main content

Monorepo Updating

Helper functions for updating dependencies within a monorepo.

Functions

lintMonorepoPackageJSONs()

function lintMonorepoPackageJSONs(monorepoRoot?): Promise<void>

Helper function to:

  • Check if all of the dependencies in the monorepo "package.json" files are up to date.
  • Check if any dependencies in the monorepo root "package.json" are unused.

This is intended to be called in a monorepo lint script. It will exit the program with an error code of 1 if discrepancies are found.

This function attempts to find the monorepo root directory automatically based on searching backwards from the file of the calling function.

Parameters

ParameterTypeDescription
monorepoRoot?stringOptional. If specified, automatic monorepo root detection will be skipped.

Returns

Promise<void>

Defined in

packages/complete-node/src/functions/monorepoUpdate.ts:47


updatePackageJSONDependenciesMonorepo()

function updatePackageJSONDependenciesMonorepo(monorepoRoot?): Promise<boolean>

Helper function to update the dependencies in all of the monorepo "package.json" files. If there are any updates, the package manager used in the project will be automatically invoked to install them.

This function attempts to find the monorepo root directory automatically based on searching backwards from the file of the calling function.

Under the hood, this function calls the updatePackageJSONDependencies and updatePackageJSONDependenciesMonorepoChildren helper functions.

If you need to check to see if the monorepo dependencies are up to date in a lint script, then use the lintMonorepoPackageJSONs function instead.

Parameters

ParameterTypeDescription
monorepoRoot?stringOptional. If specified, automatic monorepo root detection will be skipped.

Returns

Promise<boolean>

Whether any "package.json" files were changed.

Defined in

packages/complete-node/src/functions/monorepoUpdate.ts:82


updatePackageJSONDependenciesMonorepoChildren()

function updatePackageJSONDependenciesMonorepoChildren(monorepoRoot, dryRun): Promise<boolean>

Helper function to only update the dependencies in the "package.json" files of the sub-packages of a monorepo.

This will update both the normal dependencies (to match what is in the monorepo root "package.json") and the monorepo dependencies (to be what is listed in the "version" field of the respective "package.json" file).

This function is called by the updatePackageJSONDependenciesMonorepo script.

If you need to check to see if the monorepo dependencies are up to date in a lint script, then use the lintMonorepoPackageJSONs function instead.

Parameters

ParameterTypeDefault valueDescription
monorepoRootstringundefinedThe full path to the monorepo root directory.
dryRunbooleanfalseOptional. If true, will not modify the "package.json" files. Defaults to false.

Returns

Promise<boolean>

Whether all of the "package.json" files were valid.

Defined in

packages/complete-node/src/functions/monorepoUpdate.ts:118