mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-28 02:53:15 -04:00
fix(update): preserve the range prefix in aliased deps
This commit is contained in:
6
.changeset/curvy-tips-doubt.md
Normal file
6
.changeset/curvy-tips-doubt.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/which-version-is-pinned": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
When updating dependencies, preserve the range prefix in aliased dependencies. So `npm:foo@1.0.0` becomes `npm:foo@1.1.0`.
|
||||
@@ -4,6 +4,10 @@ export function whichVersionIsPinned (spec: string) {
|
||||
const isWorkspaceProtocol = spec.startsWith('workspace:')
|
||||
if (isWorkspaceProtocol) spec = spec.slice('workspace:'.length)
|
||||
if (spec === '*') return isWorkspaceProtocol ? 'patch' : 'none'
|
||||
if (spec.startsWith('npm:')) {
|
||||
const index = spec.lastIndexOf('@')
|
||||
spec = spec.slice(index + 1)
|
||||
}
|
||||
const parsedRange = parseRange(spec)
|
||||
if (parsedRange.length !== 1) return undefined
|
||||
const versionObject = parsedRange[0]
|
||||
|
||||
@@ -6,6 +6,11 @@ test.each([
|
||||
['1.0.0', 'patch'],
|
||||
['*', 'none'],
|
||||
['workspace:^1.0.0', 'major'],
|
||||
['npm:foo@1.0.0', 'patch'],
|
||||
['npm:@foo/foo@1.0.0', 'patch'],
|
||||
['npm:foo@^1.0.0', 'major'],
|
||||
['npm:@foo/foo@^1.0.0', 'major'],
|
||||
['npm:@pnpm.e2e/qar@100.0.0', 'patch'],
|
||||
])('whichVersionIsPinned()', (spec, expectedResult) => {
|
||||
expect(whichVersionIsPinned(spec)).toEqual(expectedResult)
|
||||
})
|
||||
|
||||
@@ -399,7 +399,7 @@ test('recursive update --latest specific dependency on projects that do not shar
|
||||
|
||||
const manifest1 = await readPackageJsonFromDir(path.resolve('project-1'))
|
||||
expect(manifest1.dependencies).toStrictEqual({
|
||||
alias: 'npm:@pnpm.e2e/qar@^100.1.0', // this might be not correct
|
||||
alias: 'npm:@pnpm.e2e/qar@100.1.0',
|
||||
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
|
||||
'@pnpm.e2e/foo': '^100.1.0',
|
||||
})
|
||||
@@ -574,7 +574,7 @@ test('recursive update --latest specific dependency on projects with a shared a
|
||||
|
||||
const manifest1 = await readPackageJsonFromDir(path.resolve('project-1'))
|
||||
expect(manifest1.dependencies).toStrictEqual({
|
||||
alias: 'npm:@pnpm.e2e/qar@^100.1.0', // this might be incorrect
|
||||
alias: 'npm:@pnpm.e2e/qar@100.1.0',
|
||||
'@pnpm.e2e/dep-of-pkg-with-1-dep': '100.0.0',
|
||||
'@pnpm.e2e/foo': '100.1.0',
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user