-
Notifications
You must be signed in to change notification settings - Fork 667
[rush] Fix(#5602): allPreferredVersions and allowedAlternativeVersions missing in subspace pnpmfileSettings.json #5611
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
LPegasus
wants to merge
2
commits into
microsoft:main
Choose a base branch
from
LPegasus:fix-5602
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.
+180
−3
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
10 changes: 10 additions & 0 deletions
10
common/changes/@microsoft/rush/fix-5602_2026-02-07-17-45.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,10 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "packageName": "@microsoft/rush", | ||
| "comment": "Fix allPreferredVersions and allowedAlternativeVersions missing in subspace pnpmfileSettings.json", | ||
| "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
41 changes: 41 additions & 0 deletions
41
libraries/rush-lib/src/logic/pnpm/test/SubspacePnpmfileConfiguration.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,41 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
| // See LICENSE in the project root for license information. | ||
|
|
||
| import { RushConfiguration } from '../../../api/RushConfiguration'; | ||
| import { SubspacePnpmfileConfiguration } from '../SubspacePnpmfileConfiguration'; | ||
| import { JsonFile, type JsonObject } from '@rushstack/node-core-library'; | ||
|
|
||
| describe(SubspacePnpmfileConfiguration.name, () => { | ||
| const repoPath: string = `${__dirname}/repo-with-subspace`; | ||
| const rushFilename: string = `${repoPath}/rush.json`; | ||
| const rushConfiguration: RushConfiguration = RushConfiguration.loadFromConfigurationFile(rushFilename); | ||
| const shimPath: string = `${rushConfiguration.defaultSubspace.getSubspaceTempFolderPath()}/pnpmfileSettings.json`; | ||
|
|
||
| beforeAll(async () => { | ||
| const subspace = rushConfiguration.defaultSubspace; | ||
| await SubspacePnpmfileConfiguration.writeCommonTempSubspaceGlobalPnpmfileAsync( | ||
| rushConfiguration, | ||
| subspace, | ||
| undefined | ||
| ); | ||
| }); | ||
|
|
||
| it('should use the smallest-available SemVer range (preferredVersions)', async () => { | ||
| const shimJson: JsonObject = await JsonFile.loadAsync(shimPath); | ||
| expect(shimJson.allPreferredVersions).toHaveProperty('@rushstack/terminal', '0.19.2'); | ||
| }); | ||
|
|
||
| it('should record allPreferredVersions in pnpmfileSettings.json', async () => { | ||
| const shimJson: JsonObject = await JsonFile.loadAsync(shimPath); | ||
| expect(shimJson.allPreferredVersions).toHaveProperty('@rushstack/terminal', '0.19.2'); | ||
| }); | ||
|
|
||
| it('should record allowedAlternativeVersions in pnpmfileSettings.json', async () => { | ||
| const shimJson: JsonObject = await JsonFile.loadAsync(shimPath); | ||
| const allowedAlternativeVersions = shimJson.allowedAlternativeVersions as | ||
| | Record<string, readonly string[]> | ||
| | undefined; | ||
| expect(allowedAlternativeVersions).toBeDefined(); | ||
| expect(allowedAlternativeVersions).toHaveProperty('foo', ['1.0.0']); | ||
| }); | ||
| }); |
8 changes: 8 additions & 0 deletions
8
libraries/rush-lib/src/logic/pnpm/test/repo-with-subspace/a/package.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 @@ | ||
| { | ||
| "name": "a", | ||
| "version": "1.0.0", | ||
| "description": "Test package a to test subspace pnpmfile shim with preferred versions", | ||
| "dependencies": { | ||
| "@rushstack/terminal": "~0.19.0" | ||
| } | ||
| } |
3 changes: 3 additions & 0 deletions
3
...aries/rush-lib/src/logic/pnpm/test/repo-with-subspace/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,3 @@ | ||
| { | ||
| "useWorkspaces": true | ||
| } |
10 changes: 10 additions & 0 deletions
10
libraries/rush-lib/src/logic/pnpm/test/repo-with-subspace/common/config/rush/subspaces.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,10 @@ | ||
| /** | ||
| * This configuration file manages the experimental "subspaces" feature for Rush, | ||
| * which allows multiple PNPM lockfiles to be used in a single Rush workspace. | ||
| * For full documentation, please see https://rushjs.io | ||
| */ | ||
| { | ||
| "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/subspaces.schema.json", | ||
| "subspacesEnabled": true, | ||
| "subspaceNames": ["default"] | ||
| } |
2 changes: 2 additions & 0 deletions
2
...es/rush-lib/src/logic/pnpm/test/repo-with-subspace/common/config/subspaces/default/.npmrc
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,2 @@ | ||
| registry=https://registry.npmjs.org/ | ||
| always-auth=false |
23 changes: 23 additions & 0 deletions
23
...-lib/src/logic/pnpm/test/repo-with-subspace/common/config/subspaces/default/.pnpmfile.cjs
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,23 @@ | ||
| 'use strict'; | ||
|
|
||
| /** | ||
| * When using the PNPM package manager, you can use pnpmfile.js to workaround | ||
| * dependencies that have mistakes in their package.json file. (This feature is | ||
| * functionally similar to Yarn's "resolutions".) | ||
| * | ||
| * For details, see the PNPM documentation: | ||
| * https://pnpm.io/pnpmfile#hooks | ||
| * | ||
| * IMPORTANT: SINCE THIS FILE CONTAINS EXECUTABLE CODE, MODIFYING IT IS LIKELY TO INVALIDATE | ||
| * ANY CACHED DEPENDENCY ANALYSIS. After any modification to pnpmfile.js, it's recommended to run | ||
| * "rush update --full" so that PNPM will recalculate all version selections. | ||
| */ | ||
| module.exports = { | ||
| hooks: { | ||
| readPackage | ||
| } | ||
| }; | ||
|
|
||
| function readPackage(packageJson, _context) { | ||
| return packageJson; | ||
| } |
28 changes: 28 additions & 0 deletions
28
...c/logic/pnpm/test/repo-with-subspace/common/config/subspaces/default/common-versions.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,28 @@ | ||
| /** | ||
| * This configuration file specifies NPM dependency version selections that affect all projects | ||
| * in a Rush repo. More documentation is available on the Rush website: https://rushjs.io | ||
| */ | ||
| { | ||
| "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/common-versions.schema.json", | ||
|
|
||
| /** | ||
| * 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. | ||
| * | ||
| * The "preferredVersions" value can be any SemVer range specifier (e.g. "~1.2.3"). Rush injects these values into | ||
| * the "dependencies" field of the top-level common/temp/package.json, which influences how the package manager | ||
| * will calculate versions. The specific effect depends on your package manager. Generally it will have no | ||
| * effect on an incompatible or already constrained SemVer range. If you are using PNPM, similar effects can be | ||
| * achieved using the pnpmfile.js hook. See the Rush documentation for more details. | ||
| * | ||
| * After modifying this field, it's recommended to run "rush update --full" so that the package manager | ||
| * will recalculate all version selections. | ||
| */ | ||
| "preferredVersions": { | ||
| "@rushstack/terminal": "0.19.2" | ||
| }, | ||
| "ensureConsistentVersions": false, | ||
| "allowedAlternativeVersions": { | ||
| "foo": ["1.0.0"] | ||
| } | ||
| } |
18 changes: 18 additions & 0 deletions
18
libraries/rush-lib/src/logic/pnpm/test/repo-with-subspace/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,18 @@ | ||
| /** | ||
| * This is the main configuration file for Rush. | ||
| * For full documentation, please see https://rushjs.io | ||
| */ | ||
| { | ||
| "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json", | ||
| "rushVersion": "5.166.0", | ||
| "pnpmVersion": "10.27.0", | ||
| "nodeSupportedVersionRange": "*", | ||
| // "projectFolderMinDepth": 1, | ||
| // "projectFolderMaxDepth": 2, | ||
| "projects": [ | ||
| { | ||
| "packageName": "a", | ||
| "projectFolder": "a" | ||
| } | ||
| ] | ||
| } |
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.
Why is
SubspacePnpmfileConfigurationdistinct from https://github.com/microsoft/rushstack/blob/main/libraries/rush-lib/src/logic/pnpm/PnpmfileConfiguration.ts? Looks like a lot of this is already in there. Can these two be largely deduplicated?