-
Notifications
You must be signed in to change notification settings - Fork 675
Add 'rush-pnpm up' support for catalogs #5585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
benkeen
wants to merge
26
commits into
microsoft:main
Choose a base branch
from
benkeen:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ea6ee3d
Add 'rush-pnpm up' support for catalogs
8323e43
Update common/changes/@microsoft/rush/main_2026-01-31-22-28.json
benkeen f715b55
Apply code review feedback
ad97f17
Update libraries/rush-lib/src/logic/pnpm/PnpmWorkspaceFile.ts
benkeen a6e3c54
Update libraries/rush-lib/src/logic/pnpm/PnpmOptionsConfiguration.ts
benkeen 46f7359
Update libraries/rush-lib/src/logic/pnpm/PnpmOptionsConfiguration.ts
benkeen 19f5af2
Update libraries/rush-lib/src/logic/pnpm/PnpmOptionsConfiguration.ts
benkeen 89041c9
Update libraries/rush-lib/src/cli/test/RushPnpmCommandLineParser.test.ts
benkeen 9507313
Update libraries/rush-lib/src/logic/pnpm/PnpmOptionsConfiguration.ts
benkeen cb3c760
Update libraries/rush-lib/src/logic/pnpm/PnpmOptionsConfiguration.ts
benkeen 073c2b6
Update libraries/rush-lib/src/logic/pnpm/PnpmOptionsConfiguration.ts
benkeen 88b3000
Update libraries/rush-lib/src/logic/pnpm/test/PnpmOptionsConfiguratio…
benkeen c59d56f
Update libraries/rush-lib/src/logic/pnpm/test/PnpmOptionsConfiguratio…
benkeen d89bc91
Update libraries/rush-lib/src/logic/pnpm/test/PnpmOptionsConfiguratio…
benkeen 27445b9
Update libraries/rush-lib/src/logic/pnpm/test/PnpmOptionsConfiguratio…
benkeen 20f3cf8
Update libraries/rush-lib/src/logic/pnpm/test/PnpmOptionsConfiguratio…
benkeen 30a60dd
Update libraries/rush-lib/src/logic/pnpm/test/PnpmOptionsConfiguratio…
benkeen fe4d784
Update libraries/rush-lib/src/logic/pnpm/test/PnpmOptionsConfiguratio…
benkeen fa9b039
Update libraries/rush-lib/src/logic/pnpm/test/PnpmOptionsConfiguratio…
benkeen 8d44296
Update libraries/rush-lib/src/logic/pnpm/test/PnpmOptionsConfiguratio…
benkeen 3842170
Update libraries/rush-lib/src/logic/pnpm/test/PnpmOptionsConfiguratio…
benkeen 93d85a5
Update libraries/rush-lib/src/logic/pnpm/test/PnpmOptionsConfiguratio…
benkeen 1ffabcd
Update libraries/rush-lib/src/logic/pnpm/test/PnpmOptionsConfiguratio…
benkeen 30064fe
Update libraries/rush-lib/src/logic/pnpm/PnpmWorkspaceFile.ts
benkeen 3ee9066
Code review feedback - test and code cleanup
167f583
Code review feedback
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@microsoft/rush", | ||
| "comment": "Add catalog support to `rush-pnpm update`.", | ||
| "type": "none" | ||
| } | ||
| ], | ||
| "packageName": "@microsoft/rush" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
libraries/rush-lib/src/cli/test/RushPnpmCommandLineParser.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
| // See LICENSE in the project root for license information. | ||
|
|
||
| import * as path from 'node:path'; | ||
| import { FileSystem, JsonFile } from '@rushstack/node-core-library'; | ||
| import { TestUtilities } from '@rushstack/heft-config-file'; | ||
| import { RushConfiguration } from '../../api/RushConfiguration'; | ||
| import { PnpmWorkspaceFile } from '../../logic/pnpm/PnpmWorkspaceFile'; | ||
|
|
||
| const PACKAGE_ROOT: string = path.resolve(__dirname, '../../..'); | ||
| const CATALOG_SYNC_REPO_PATH: string = `${__dirname}/catalogSyncTestRepo`; | ||
|
|
||
| describe('RushPnpmCommandLineParser', () => { | ||
| describe('catalog syncing', () => { | ||
| const testRepoPath: string = `${PACKAGE_ROOT}/temp/catalog-sync-test-repo`; | ||
| const pnpmConfigPath: string = `${testRepoPath}/common/config/rush/pnpm-config.json`; | ||
| const pnpmWorkspacePath: string = `${testRepoPath}/common/temp/pnpm-workspace.yaml`; | ||
|
|
||
| beforeEach(async () => { | ||
| await FileSystem.copyFilesAsync({ sourcePath: CATALOG_SYNC_REPO_PATH, destinationPath: testRepoPath }); | ||
| }); | ||
|
|
||
| afterEach(async () => { | ||
| await FileSystem.deleteFolderAsync(testRepoPath); | ||
| }); | ||
|
|
||
| it('syncs updated catalogs from pnpm-workspace.yaml to pnpm-config.json', async () => { | ||
| const updatedWorkspaceYaml = `packages: | ||
| - '../../apps/*' | ||
| catalogs: | ||
| default: | ||
| react: ^18.2.0 | ||
| react-dom: ^18.2.0 | ||
| typescript: ~5.3.0 | ||
| frontend: | ||
| vue: ^3.4.0 | ||
| `; | ||
| await FileSystem.writeFileAsync(pnpmWorkspacePath, updatedWorkspaceYaml); | ||
|
|
||
| const rushConfiguration: RushConfiguration = RushConfiguration.loadFromConfigurationFile( | ||
| `${testRepoPath}/rush.json` | ||
| ); | ||
|
|
||
| const subspace = rushConfiguration.getSubspace('default'); | ||
| const pnpmOptions = subspace.getPnpmOptions(); | ||
|
|
||
| expect(TestUtilities.stripAnnotations(pnpmOptions?.globalCatalogs)).toEqual({ | ||
| default: { | ||
| react: '^18.0.0', | ||
| 'react-dom': '^18.0.0' | ||
| } | ||
| }); | ||
|
|
||
| const newCatalogs = await PnpmWorkspaceFile.loadCatalogsFromFileAsync(pnpmWorkspacePath); | ||
|
|
||
| await pnpmOptions?.updateGlobalCatalogsAsync(newCatalogs); | ||
|
|
||
| const updatedRushConfiguration: RushConfiguration = RushConfiguration.loadFromConfigurationFile( | ||
| `${testRepoPath}/rush.json` | ||
| ); | ||
| const updatedSubspace = updatedRushConfiguration.getSubspace('default'); | ||
| const updatedPnpmOptions = updatedSubspace.getPnpmOptions(); | ||
|
|
||
| expect(TestUtilities.stripAnnotations(updatedPnpmOptions?.globalCatalogs)).toEqual({ | ||
| default: { | ||
| react: '^18.2.0', | ||
| 'react-dom': '^18.2.0', | ||
| typescript: '~5.3.0' | ||
| }, | ||
| frontend: { | ||
| vue: '^3.4.0' | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| it('does not update pnpm-config.json when catalogs are unchanged', async () => { | ||
| const newCatalogs = await PnpmWorkspaceFile.loadCatalogsFromFileAsync(pnpmWorkspacePath); | ||
|
|
||
| const rushConfiguration: RushConfiguration = RushConfiguration.loadFromConfigurationFile( | ||
| `${testRepoPath}/rush.json` | ||
| ); | ||
| const subspace = rushConfiguration.getSubspace('default'); | ||
| const pnpmOptions = subspace.getPnpmOptions(); | ||
|
|
||
| await pnpmOptions?.updateGlobalCatalogsAsync(newCatalogs); | ||
|
|
||
| const savedConfig = JsonFile.load(pnpmConfigPath); | ||
| expect(savedConfig.globalCatalogs).toEqual({ | ||
| default: { | ||
| react: '^18.0.0', | ||
| 'react-dom': '^18.0.0' | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| it('removes catalogs when pnpm-workspace.yaml has no catalogs', async () => { | ||
| const workspaceWithoutCatalogs = `packages: | ||
| - '../../apps/*' | ||
| `; | ||
| await FileSystem.writeFileAsync(pnpmWorkspacePath, workspaceWithoutCatalogs); | ||
|
|
||
| const newCatalogs = await PnpmWorkspaceFile.loadCatalogsFromFileAsync(pnpmWorkspacePath); | ||
|
|
||
| expect(newCatalogs).toBeUndefined(); | ||
|
|
||
| const rushConfiguration: RushConfiguration = RushConfiguration.loadFromConfigurationFile( | ||
| `${testRepoPath}/rush.json` | ||
| ); | ||
| const subspace = rushConfiguration.getSubspace('default'); | ||
| const pnpmOptions = subspace.getPnpmOptions(); | ||
|
|
||
| await pnpmOptions?.updateGlobalCatalogsAsync(newCatalogs); | ||
|
|
||
| const updatedRushConfiguration: RushConfiguration = RushConfiguration.loadFromConfigurationFile( | ||
| `${testRepoPath}/rush.json` | ||
| ); | ||
| const updatedSubspace = updatedRushConfiguration.getSubspace('default'); | ||
| const updatedPnpmOptions = updatedSubspace.getPnpmOptions(); | ||
|
|
||
| expect(updatedPnpmOptions?.globalCatalogs).toBeUndefined(); | ||
| }); | ||
| }); | ||
| }); |
1 change: 1 addition & 0 deletions
1
libraries/rush-lib/src/cli/test/catalogSyncTestRepo/common/.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| !temp |
8 changes: 8 additions & 0 deletions
8
libraries/rush-lib/src/cli/test/catalogSyncTestRepo/common/config/rush/pnpm-config.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "globalCatalogs": { | ||
| "default": { | ||
| "react": "^18.0.0", | ||
| "react-dom": "^18.0.0" | ||
| } | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
libraries/rush-lib/src/cli/test/catalogSyncTestRepo/common/temp/pnpm-workspace.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| packages: | ||
| - '../../apps/*' | ||
| catalogs: | ||
| default: | ||
| react: ^18.0.0 | ||
| react-dom: ^18.0.0 |
7 changes: 7 additions & 0 deletions
7
libraries/rush-lib/src/cli/test/catalogSyncTestRepo/rush.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json", | ||
| "rushVersion": "5.166.0", | ||
| "pnpmVersion": "10.28.1", | ||
| "nodeSupportedVersionRange": ">=18.0.0", | ||
| "projects": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will throw if
jsonFilenameis undefined. Is the property type wrong?