-
Notifications
You must be signed in to change notification settings - Fork 631
[rush-lib] Fix PreferredVersions
being ignored when projects have overlapping dependencies
#4835
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0a381c5
Prioritize explicit preferredVersions over implicit ones
ace-n-msft 0d89644
Add tests
ace-n-msft d0a1837
Add changelog
ace-n-msft 92b7365
Address feedback: foreach() function -> for...of loop
ace-n-msft 071ebb4
Merge branch 'main' of https://github.com/microsoft/rushstack into fi…
ace-n-msft eb356ae
Fix CI failures
ace-n-msft 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-3205_2024-07-17-01-52.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 an issue where PreferredVersions are ignored when a project contains an overlapping dependency entry (https://github.com/microsoft/rushstack/issues/3205)", | ||
"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
40 changes: 40 additions & 0 deletions
40
libraries/rush-lib/src/logic/pnpm/test/PnpmfileConfiguration.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,40 @@ | ||
// 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 type { Subspace } from '../../../api/Subspace'; | ||
import { PnpmfileConfiguration } from '../PnpmfileConfiguration'; | ||
import { JsonFile, JsonObject } from '@rushstack/node-core-library'; | ||
import { RushConstants } from '../../RushConstants'; | ||
import { before } from 'node:test'; | ||
|
||
describe(PnpmfileConfiguration.name, () => { | ||
const repoPath: string = `${__dirname}/repo`; | ||
const rushFilename: string = `${repoPath}/rush3.json`; | ||
const rushConfiguration: RushConfiguration = RushConfiguration.loadFromConfigurationFile(rushFilename); | ||
const shimPath: string = `${rushConfiguration.defaultSubspace.getSubspaceTempFolder()}/pnpmfileSettings.json`; | ||
|
||
beforeAll(async () => { | ||
const subspace = rushConfiguration.defaultSubspace; | ||
await PnpmfileConfiguration.writeCommonTempPnpmfileShimAsync( | ||
rushConfiguration, | ||
subspace.getSubspaceTempFolder(), | ||
subspace | ||
); | ||
}); | ||
|
||
it('should use the smallest-available SemVer range (preferredVersions)', async () => { | ||
const shimJson: JsonObject = await JsonFile.loadAsync(shimPath); | ||
expect(shimJson.allPreferredVersions).toHaveProperty('core-js', '3.6.5'); | ||
}); | ||
|
||
it('should use the smallest-available SemVer range (per-project)', async () => { | ||
const shimJson: JsonObject = await JsonFile.loadAsync(shimPath); | ||
expect(shimJson.allPreferredVersions).toHaveProperty('delay', '5.0.0'); | ||
}); | ||
|
||
it('should override preferredVersions when per-project versions conflict', async () => { | ||
const shimJson: JsonObject = await JsonFile.loadAsync(shimPath); | ||
expect(shimJson.allPreferredVersions).toHaveProperty('find-up', '5.0.0'); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
libraries/rush-lib/src/logic/pnpm/test/repo/apps/baz/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,9 @@ | ||
{ | ||
"name": "baz", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"core-js": "^3.0.0", | ||
"delay": "5.0.0", | ||
"find-up": "*" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
libraries/rush-lib/src/logic/pnpm/test/repo/common/config/rush/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,8 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/common-versions.schema.json", | ||
"preferredVersions": { | ||
"core-js": "3.6.5", | ||
"delay": "4.0.0", | ||
"find-up": "5.0.0" | ||
} | ||
} |
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,14 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush.schema.json", | ||
"pnpmVersion": "7.0.0", | ||
"rushVersion": "5.46.1", | ||
"projects": [ | ||
{ | ||
"packageName": "baz", | ||
"projectFolder": "apps/baz" | ||
} | ||
], | ||
"pnpmOptions": { | ||
"useWorkspaces": true | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.