[rush-lib] Add pnpm global catalog detection to rush change#5627
Conversation
|
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Pull request overview
Adds PNPM global catalog (globalCatalogs) change detection to rush change so that projects using the catalog: protocol are marked as changed when catalog entries are edited, including across subspaces (addresses #5624).
Changes:
- Extend
ProjectChangeAnalyzer.getChangedProjectsAsync()to detect diffs in per-subspacepnpm-config.jsoncatalog entries and mark impacted projects as changed. - Add unit tests covering catalog changes (default/named catalogs) and subspace scenarios.
- Add new test fixture repos (
repoWithCatalogs,repoWithSubspacesCatalogs) and a Rush change file.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| libraries/rush-lib/src/logic/ProjectChangeAnalyzer.ts | Implements subspace-aware catalog diffing and project impact detection. |
| libraries/rush-lib/src/logic/test/ProjectChangeAnalyzer.test.ts | Adds unit tests for catalog change detection (including subspaces). |
| libraries/rush-lib/src/logic/test/repoWithCatalogs/rush.json | Test fixture Rush repo definition for catalog tests. |
| libraries/rush-lib/src/logic/test/repoWithCatalogs/a/package.json | Fixture project using default catalog dependencies. |
| libraries/rush-lib/src/logic/test/repoWithCatalogs/b/package.json | Fixture project using tools catalog (and workspace dep). |
| libraries/rush-lib/src/logic/test/repoWithCatalogs/c/package.json | Fixture project with no catalog dependencies. |
| libraries/rush-lib/src/logic/test/repoWithCatalogs/d/package.json | Fixture project using default catalog (single package). |
| libraries/rush-lib/src/logic/test/repoWithCatalogs/e/package.json | Fixture project using tools catalog in devDependencies. |
| libraries/rush-lib/src/logic/test/repoWithCatalogs/common/config/rush/pnpm-config.json | Fixture defining globalCatalogs for non-subspace repo. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/rush.json | Test fixture Rush repo definition with subspaces enabled. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/a/package.json | Fixture default-subspace project using default catalog. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/b/package.json | Fixture default-subspace project with non-catalog dependency. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/c/package.json | Fixture default-subspace project consuming a workspace dep. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/d/package.json | Fixture named-subspace project using default catalog. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/e/package.json | Fixture named-subspace project using tools catalog. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/f/package.json | Fixture named-subspace project with no catalog deps. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/g/package.json | Fixture named-subspace project using default catalog. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/h/package.json | Fixture named-subspace project using tools catalog. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/common/config/subspaces/default/pnpm-config.json | Fixture default subspace globalCatalogs definition. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/common/config/subspaces/default/common-versions.json | Fixture default subspace common-versions config. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/common/config/subspaces/default/.pnpmfile.cjs | Fixture default subspace pnpmfile. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/common/config/subspaces/project-change-analyzer-test-subspace/pnpm-config.json | Fixture named subspace globalCatalogs definition. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/common/config/subspaces/project-change-analyzer-test-subspace/common-versions.json | Fixture named subspace common-versions config. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/common/config/subspaces/project-change-analyzer-test-subspace/.pnpmfile.cjs | Fixture named subspace pnpmfile. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/common/config/rush/version-policies.json | Fixture Rush config required by test repo. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/common/config/rush/subspaces.json | Fixture enabling subspaces in test repo. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/common/config/rush/pnpm-config.json | Fixture root pnpm config enabling workspaces for subspaces. |
| libraries/rush-lib/src/logic/test/repoWithSubspacesCatalogs/common/config/rush/experiments.json | Fixture enabling cross-subspace decoupled dependency exemption for tests. |
| common/changes/@microsoft/rush/rush-change-catalog-entries_2026-02-17-18-48.json | Change file documenting the Rush CLI behavior update. |
…6-02-17-18-48.json Co-authored-by: Ian Clanton-Thuon <iclanton@users.noreply.github.com>
dmichon-msft
left a comment
There was a problem hiding this comment.
Few readability suggestions.
Head branch was pushed to by a user without write access
bartvandenende-wm
left a comment
There was a problem hiding this comment.
Looks like this change is causing some regression @iclanton
| blobSpec: `${mergeCommit}:${pnpmConfigRelativePath}`, | ||
| repositoryRoot: repoRoot | ||
| }); | ||
| const oldPnpmConfig: IPnpmOptionsJson = JSON.parse(oldPnpmConfigText); |
There was a problem hiding this comment.
@CarltonHowell I think this path is currently parsing pnpm-config.json with JSON.parse, which does not allow comments. In many Rush repos this file is JSONC-style (with comments), so this branch may incorrectly fall into the “created or unparseable” path and report all projects as affected.
Also, should this message use writeWarningLine instead of writeLine? Right now it goes to stdout, which can break consumers expecting pure JSON output from list --json.
Summary
rush changedoes not detect change to catalog version of dependency #5624rush changedoes not consider changes to pnpm global catalog changes. Runningrush changenow considers any chances to catalog entries, be it additions of version changes.Details
getChangedProjectsAsync()between the per-project file change detection and the includeExternalDependencies block. The new logic:a. Guards on
rushConfiguration.isPnpmandglobalCatalogsexistingb. Computes the relative path to
pnpm-config.jsonand checks if it's in changedFilesc. Loads the old
pnpm-config.jsonto find which catalog names changedd. If the old file doesn't exist (new creation), treats all current catalogs as changed
e. Builds a map of catalogName → Set by scanning each project's dependencies, devDependencies, and optionalDependencies for
catalog: protocolentriesf. Marks affected projects as changed
How it was tested
Impacted documentation