From c4a37300693453b6f3f9d95363c2613186310822 Mon Sep 17 00:00:00 2001 From: Shinyaigeek Date: Sat, 1 Oct 2022 03:38:41 +0900 Subject: [PATCH] feat: ignore packages listed in pnpm.update.ignore field on update command --- .../plugin-commands-installation/src/installDeps.ts | 5 +++++ .../plugin-commands-installation/src/recursive.ts | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/plugin-commands-installation/src/installDeps.ts b/packages/plugin-commands-installation/src/installDeps.ts index 21b751d532d..060d7f94e62 100644 --- a/packages/plugin-commands-installation/src/installDeps.ts +++ b/packages/plugin-commands-installation/src/installDeps.ts @@ -201,6 +201,11 @@ when running add/update with the --workspace option') let currentInput = [...params] + if (opts.update) { + const ignoredPackages = (manifest.pnpm?.updateConfig?.ignoreDependencies ?? []) + currentInput = [...ignoredPackages.map(pkg => `!${pkg}`), ...currentInput] + } + const updateMatch = opts.update && (currentInput.length > 0) ? createMatcher(currentInput) : null if (updateMatch != null) { currentInput = matchDependencies(updateMatch, manifest, includeDirect) diff --git a/packages/plugin-commands-installation/src/recursive.ts b/packages/plugin-commands-installation/src/recursive.ts index b854d4a03cc..11d3a8e8811 100755 --- a/packages/plugin-commands-installation/src/recursive.ts +++ b/packages/plugin-commands-installation/src/recursive.ts @@ -173,8 +173,6 @@ export default async function recursive ( optionalDependencies: true, } - const updateMatch = cmdFullName === 'update' && (params.length > 0) ? createMatcher(params) : null - // For a workspace with shared lockfile if (opts.lockfileDir && ['add', 'install', 'remove', 'update', 'import'].includes(cmdFullName)) { let importers = await getImporters() @@ -201,6 +199,11 @@ export default async function recursive ( const modulesDir = localConfig.modulesDir ?? opts.modulesDir const { manifest, writeProjectManifest } = manifestsByPath[rootDir] let currentInput = [...params] + if (opts.update) { + const ignoredPackages = (manifest.pnpm?.updateConfig?.ignoreDependencies ?? []) + currentInput = [...ignoredPackages.map(pkg => `!${pkg}`), ...currentInput] + } + const updateMatch = cmdFullName === 'update' && (currentInput.length > 0) ? createMatcher(currentInput) : null if (updateMatch != null) { currentInput = matchDependencies(updateMatch, manifest, includeDirect) if ((currentInput.length === 0) && (typeof opts.depth === 'undefined' || opts.depth <= 0)) { @@ -308,6 +311,11 @@ export default async function recursive ( const { manifest, writeProjectManifest } = manifestsByPath[rootDir] let currentInput = [...params] + if (opts.update) { + const ignoredPackages = (manifest.pnpm?.updateConfig?.ignoreDependencies ?? []) + currentInput = [...ignoredPackages.map(pkg => `!${pkg}`), ...currentInput] + } + const updateMatch = cmdFullName === 'update' && (currentInput.length > 0) ? createMatcher(currentInput) : null if (updateMatch != null) { currentInput = matchDependencies(updateMatch, manifest, includeDirect) if (currentInput.length === 0) return