New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: ignore packages listed in package.json > pnpm.updateConfig.ignoreDependencies
on update/outdated commands
#5408
Changes from 12 commits
6b21dcd
6cbcb40
6440cc0
d8a0636
0573b75
b717a82
bc400b1
405733e
9c5a267
4123501
bc9321d
c4a3730
dfc8b5e
e939c47
62186c6
a2dbfaa
26918ac
bdd2f22
76b4073
a5f659b
d06f3e4
0237a40
1187055
2e4e8fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@pnpm/outdated": minor | ||
"@pnpm/plugin-commands-installation": minor | ||
"@pnpm/plugin-commands-outdated": minor | ||
"@pnpm/types": minor | ||
--- | ||
|
||
Ignore packages listed in package.json > pnpm.updateConfig.ignoreDependencies fields on update/outdated command [#5358](https://github.com/pnpm/pnpm/issues/5358) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "with-pnpm-update-ignore", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"is-positive": "1.0.0", | ||
"is-negative": "1.0.0" | ||
}, | ||
"pnpm": { | ||
"updateConfig": { | ||
"ignoreDependencies": [ | ||
"is-positive" | ||
] | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do append currentInput if it will be empty always? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as #5408 (comment) |
||
} | ||
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)) { | ||
|
@@ -226,6 +229,7 @@ export default async function recursive ( | |
currentInput = createWorkspaceSpecs(currentInput, workspacePackages) | ||
} | ||
} | ||
|
||
writeProjectManifests.push(writeProjectManifest) | ||
switch (mutation) { | ||
case 'uninstallSome': | ||
|
@@ -307,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] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do append currentInput if it will be empty always? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did so because I did not want to make if statement’s condition complex, but this is not strong will so I changed if statement’s condition in this line as you say. a2dbfaa |
||
} | ||
const updateMatch = cmdFullName === 'update' && (currentInput.length > 0) ? createMatcher(currentInput) : null | ||
if (updateMatch != null) { | ||
currentInput = matchDependencies(updateMatch, manifest, includeDirect) | ||
if (currentInput.length === 0) return | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we already discussed that the ignore list will only be active when pnpm update is called without args. So why do you append currentInput?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it would be ok to append the ignored packages to the beginning of currentInput with
!
because the successor params will override!
packages.However, I have rethought that it is not friendly to ignore packages even if they are explicitly specified
*
params, so I will append only if the params are empty 🙏 .There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in dfc8b5e