From 4f4e0738cb5ecbab6b2f2274b8c10d0b6c6c84d1 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sun, 6 Oct 2024 12:07:57 +0200 Subject: [PATCH] fix(update): update latest should not update peer dependencies (#8615) close #6657 --- .changeset/afraid-wolves-obey.md | 6 +++ .../test/update/update.ts | 33 +++++++++++++ .../src/resolveDependencies.ts | 2 + pnpm-lock.yaml | 46 +++++++++---------- pnpm-workspace.yaml | 2 +- 5 files changed, 65 insertions(+), 24 deletions(-) create mode 100644 .changeset/afraid-wolves-obey.md diff --git a/.changeset/afraid-wolves-obey.md b/.changeset/afraid-wolves-obey.md new file mode 100644 index 0000000000..4d1355a60a --- /dev/null +++ b/.changeset/afraid-wolves-obey.md @@ -0,0 +1,6 @@ +--- +"@pnpm/resolve-dependencies": patch +"pnpm": patch +--- + +`pnpm update --latest` should not update the automatically installed peer dependencies [#6657](https://github.com/pnpm/pnpm/issues/6657). diff --git a/pkg-manager/plugin-commands-installation/test/update/update.ts b/pkg-manager/plugin-commands-installation/test/update/update.ts index 421b9646af..cd967a82bd 100644 --- a/pkg-manager/plugin-commands-installation/test/update/update.ts +++ b/pkg-manager/plugin-commands-installation/test/update/update.ts @@ -38,6 +38,39 @@ test('update with "*" pattern', async () => { expect(lockfile.packages['@pnpm.e2e/foo@1.0.0']).toBeTruthy() }) +test('update to latest should not touch the automatically installed peer dependencies', async () => { + await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.0', distTag: 'latest' }) + await addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.0', distTag: 'latest' }) + + const project = prepare({ + dependencies: { + '@pnpm.e2e/abc': '1.0.0', + }, + }) + + await install.handler({ + ...DEFAULT_OPTS, + dir: process.cwd(), + }) + + await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.1', distTag: 'latest' }) + await addDistTag({ package: '@pnpm.e2e/peer-c', version: '1.0.1', distTag: 'latest' }) + await addDistTag({ package: '@pnpm.e2e/abc', version: '2.0.0', distTag: 'latest' }) + + await update.handler({ + ...DEFAULT_OPTS, + dir: process.cwd(), + latest: true, + }, ['@pnpm.e2e/abc']) + + const lockfile = project.readLockfile() + + expect(lockfile.packages['@pnpm.e2e/peer-a@1.0.0']).toBeTruthy() + expect(lockfile.packages['@pnpm.e2e/peer-a@1.0.1']).toBeFalsy() + expect(lockfile.packages['@pnpm.e2e/peer-c@1.0.0']).toBeTruthy() + expect(lockfile.packages['@pnpm.e2e/peer-c@1.0.1']).toBeFalsy() +}) + test('update with negation pattern', async () => { await addDistTag({ package: '@pnpm.e2e/peer-a', version: '1.0.1', distTag: 'latest' }) await addDistTag({ package: '@pnpm.e2e/peer-c', version: '2.0.0', distTag: 'latest' }) diff --git a/pkg-manager/resolve-dependencies/src/resolveDependencies.ts b/pkg-manager/resolve-dependencies/src/resolveDependencies.ts index e4ff6a8eae..09fc58fc69 100644 --- a/pkg-manager/resolve-dependencies/src/resolveDependencies.ts +++ b/pkg-manager/resolve-dependencies/src/resolveDependencies.ts @@ -349,6 +349,7 @@ export async function resolveRootDependencies ( ...options, parentPkgAliases, publishedBy, + updateToLatest: false, }) importerResolutionResult.pkgAddresses.push(...resolveDependenciesResult.pkgAddresses) Object.assign(importerResolutionResult, @@ -369,6 +370,7 @@ export async function resolveRootDependencies ( ...options, parentPkgAliases, publishedBy, + updateToLatest: false, }) pkgAddressesByImportersWithoutPeers[index].pkgAddresses.push(...resolveDependenciesResult.pkgAddresses) Object.assign(pkgAddressesByImportersWithoutPeers[index], diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0ddef7ed80..2985ecd7a5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -55,8 +55,8 @@ catalogs: specifier: 0.0.0 version: 0.0.0 '@pnpm/registry-mock': - specifier: 3.41.0 - version: 3.41.0 + specifier: 3.42.0 + version: 3.42.0 '@pnpm/semver-diff': specifier: ^1.1.0 version: 1.1.0 @@ -722,7 +722,7 @@ importers: version: 2.0.3 '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/tsconfig': specifier: workspace:* version: link:__utils__/tsconfig @@ -846,7 +846,7 @@ importers: version: link:../../pkg-manager/modules-yaml '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/types': specifier: workspace:* version: link:../../packages/types @@ -880,7 +880,7 @@ importers: dependencies: '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/store.cafs': specifier: workspace:* version: link:../../store/cafs @@ -1104,7 +1104,7 @@ importers: version: link:../../__utils__/prepare '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@types/ramda': specifier: 'catalog:' version: 0.29.12 @@ -2178,7 +2178,7 @@ importers: version: link:../../__utils__/prepare '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -2308,7 +2308,7 @@ importers: version: link:../../__utils__/prepare '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/test-ipc-server': specifier: workspace:* version: link:../../__utils__/test-ipc-server @@ -3967,7 +3967,7 @@ importers: version: link:../../__utils__/prepare '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -4251,7 +4251,7 @@ importers: version: link:../../pkg-manifest/read-package-json '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/store-path': specifier: workspace:* version: link:../../store/store-path @@ -4539,7 +4539,7 @@ importers: version: link:../read-projects-context '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/store-path': specifier: workspace:* version: link:../../store/store-path @@ -4899,7 +4899,7 @@ importers: version: 'link:' '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -5095,7 +5095,7 @@ importers: version: link:../../__utils__/prepare '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -5703,7 +5703,7 @@ importers: version: link:../pkg-manifest/read-project-manifest '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/run-npm': specifier: workspace:* version: link:../exec/run-npm @@ -5981,7 +5981,7 @@ importers: version: link:../../__utils__/prepare '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/workspace.filter-packages-from-dir': specifier: workspace:* version: link:../../workspace/filter-packages-from-dir @@ -6090,7 +6090,7 @@ importers: version: link:../../__utils__/prepare '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/test-ipc-server': specifier: workspace:* version: link:../../__utils__/test-ipc-server @@ -6671,7 +6671,7 @@ importers: version: link:../../pkg-manifest/read-package-json '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -6738,7 +6738,7 @@ importers: version: link:../../__utils__/prepare '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/workspace.filter-packages-from-dir': specifier: workspace:* version: link:../../workspace/filter-packages-from-dir @@ -6829,7 +6829,7 @@ importers: version: link:../../__utils__/prepare '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@pnpm/test-fixtures': specifier: workspace:* version: link:../../__utils__/test-fixtures @@ -7167,7 +7167,7 @@ importers: version: link:../../__utils__/prepare '@pnpm/registry-mock': specifier: 'catalog:' - version: 3.41.0(encoding@0.1.13)(typanion@3.14.0) + version: 3.42.0(encoding@0.1.13)(typanion@3.14.0) '@types/archy': specifier: 'catalog:' version: 0.0.33 @@ -8844,8 +8844,8 @@ packages: resolution: {integrity: sha512-LFTWzfJbu6+l86bw/uUAsPU05n1oTqg6jzqyTXYDJPfVclqTfPnHiZoC1nvVvQlE7iVg3bhJ7SXg9IyzK7RWDQ==} engines: {node: '>=18.12'} - '@pnpm/registry-mock@3.41.0': - resolution: {integrity: sha512-AtnFxhDGrN8tKtXyZpAqFobOVYkb1HSUPlOk6v/+WzJq2iowNDrtKYs0MKuzGNizlQr+rBWcGEXaIUcS7oNZ0Q==} + '@pnpm/registry-mock@3.42.0': + resolution: {integrity: sha512-L2OuizGAxl16YKFg4iAqIVX+A6KQhqoXiEuhRM5izM/THnQZwcsN5OOUSxybQOdI6nU3Ka94+gm7LlbyTKGYqw==} engines: {node: '>=10.13'} hasBin: true @@ -15716,7 +15716,7 @@ snapshots: sort-keys: 4.2.0 strip-bom: 4.0.0 - '@pnpm/registry-mock@3.41.0(encoding@0.1.13)(typanion@3.14.0)': + '@pnpm/registry-mock@3.42.0(encoding@0.1.13)(typanion@3.14.0)': dependencies: anonymous-npm-registry-client: 0.2.0 execa: 5.1.1 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 08ab4f7954..7d5dcd1bff 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -54,7 +54,7 @@ catalog: "@pnpm/npm-package-arg": ^1.0.0 "@pnpm/os.env.path-extender": ^2.0.0 "@pnpm/patch-package": 0.0.0 - "@pnpm/registry-mock": 3.41.0 + "@pnpm/registry-mock": 3.42.0 "@pnpm/semver-diff": ^1.1.0 "@pnpm/tabtab": ^0.5.4 "@pnpm/util.lex-comparator": 3.0.0