Skip to content
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

fix: don't incorrectly consider a lockfile to be out-of-date #5121

Merged
merged 1 commit into from
Jul 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/gentle-mice-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pnpm/core": patch
"pnpm": patch
---

Don't incorrectly consider a lockfile out-of-date when `workspace:^` or `workspace:~` version specs are used in a workspace.
2 changes: 1 addition & 1 deletion packages/core/src/install/allProjectsAreUpToDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async function linkedPackagesAreUpToDate (
const linkedPkg = manifestsByDir[linkedDir] ?? await safeReadPkgFromDir(linkedDir)
const availableRange = getVersionRange(currentSpec)
// This should pass the same options to semver as @pnpm/npm-resolver
const localPackageSatisfiesRange = availableRange === '*' ||
const localPackageSatisfiesRange = availableRange === '*' || availableRange === '^' || availableRange === '~' ||
linkedPkg && semver.satisfies(linkedPkg.version, availableRange, { loose: true })
if (isLinked !== localPackageSatisfiesRange) return false
}
Expand Down
28 changes: 28 additions & 0 deletions packages/core/test/allProjectsAreUpToDate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ test('allProjectsAreUpToDate(): use link and registry version if linkWorkspacePa
manifest: {
dependencies: {
foo: 'workspace:*',
foo2: 'workspace:~',
foo3: 'workspace:^',
},
},
rootDir: 'bar',
Expand All @@ -196,6 +198,22 @@ test('allProjectsAreUpToDate(): use link and registry version if linkWorkspacePa
manifest: fooManifest,
rootDir: 'foo',
},
{
id: 'foo2',
manifest: {
name: 'foo2',
version: '1.0.0',
},
rootDir: 'foo2',
},
{
id: 'foo3',
manifest: {
name: 'foo3',
version: '1.0.0',
},
rootDir: 'foo3',
},
],
{
autoInstallPeers: false,
Expand All @@ -205,9 +223,13 @@ test('allProjectsAreUpToDate(): use link and registry version if linkWorkspacePa
bar: {
dependencies: {
foo: 'link:../foo',
foo2: 'link:../foo2',
foo3: 'link:../foo3',
},
specifiers: {
foo: 'workspace:*',
foo2: 'workspace:~',
foo3: 'workspace:^',
},
},
bar2: {
Expand All @@ -221,6 +243,12 @@ test('allProjectsAreUpToDate(): use link and registry version if linkWorkspacePa
foo: {
specifiers: {},
},
foo2: {
specifiers: {},
},
foo3: {
specifiers: {},
},
},
lockfileVersion: 5,
},
Expand Down