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

This commit is contained in:
Zoltan Kochan
2022-07-30 12:22:29 +03:00
committed by GitHub
parent c83f40c106
commit c7d65fe7fb
3 changed files with 35 additions and 1 deletions

View File

@@ -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.

View File

@@ -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
}

View File

@@ -178,6 +178,8 @@ test('allProjectsAreUpToDate(): use link and registry version if linkWorkspacePa
manifest: {
dependencies: {
foo: 'workspace:*',
foo2: 'workspace:~',
foo3: 'workspace:^',
},
},
rootDir: 'bar',
@@ -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,
@@ -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: {
@@ -221,6 +243,12 @@ test('allProjectsAreUpToDate(): use link and registry version if linkWorkspacePa
foo: {
specifiers: {},
},
foo2: {
specifiers: {},
},
foo3: {
specifiers: {},
},
},
lockfileVersion: 5,
},