fix: treat the linked dependency which version type is tag as update-to-date (#6791)

* fix(core): treat the linked dependency which version type is tag as update-to-date

* docs: add changeset

* chore: code style
This commit is contained in:
await-ovo
2023-07-12 08:58:54 +08:00
committed by GitHub
parent 35871080bd
commit b8cb91cf48
3 changed files with 60 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/core": patch
"pnpm": patch
---
Treat the linked dependency which version type is tag as update-to-date [#6592](https://github.com/pnpm/pnpm/issues/6592)

View File

@@ -18,6 +18,7 @@ import {
import pEvery from 'p-every'
import any from 'ramda/src/any'
import semver from 'semver'
import getVersionSelectorType from 'version-selector-type'
export async function allProjectsAreUpToDate (
projects: Array<ProjectOptions & { id: string }>,
@@ -111,6 +112,11 @@ async function linkedPackagesAreUpToDate (
) {
return true
}
// https://github.com/pnpm/pnpm/issues/6592
// if the dependency is linked and the specified version type is tag, we consider it to be up-to-date to skip full resolution.
if (isLinked && getVersionSelectorType(currentSpec)?.type === 'tag') {
return true
}
const linkedDir = isLinked
? path.join(project.dir, lockfileRef.slice(5))
: workspacePackages?.[depName]?.[lockfileRef]?.dir

View File

@@ -497,3 +497,51 @@ describe('local file dependency', () => {
})).toBeFalsy()
})
})
test('allProjectsAreUpToDate(): returns true if workspace dependency\'s version type is tag', async () => {
const projects = [
{
buildIndex: 0,
id: 'bar',
manifest: {
dependencies: {
foo: 'unpublished-tag',
},
},
rootDir: 'bar',
},
{
buildIndex: 0,
id: 'foo',
manifest: fooManifest,
rootDir: 'foo',
},
]
const options = {
autoInstallPeers: false,
excludeLinksFromLockfile: false,
linkWorkspacePackages: true,
wantedLockfile: {
importers: {
bar: {
dependencies: {
foo: 'link:../foo',
},
specifiers: {
foo: 'unpublished-tag',
},
},
foo: {
specifiers: {},
},
},
lockfileVersion: 5,
} as Lockfile,
workspacePackages,
lockfileDir: process.cwd(),
}
expect(await allProjectsAreUpToDate(projects, {
...options,
lockfileDir: process.cwd(),
})).toBeTruthy()
})