Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Install extends ArboristWorkspaceCmd {
'audit',
'before',
'min-release-age',
'min-release-age-exclude',
'bin-links',
'fund',
'dry-run',
Expand Down
12 changes: 10 additions & 2 deletions lib/commands/outdated.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const pacote = require('pacote')
const table = require('text-table')
const npa = require('npm-package-arg')
const pickManifest = require('npm-pick-manifest')
const { isReleaseAgeExcluded } = require('@npmcli/arborist/lib/release-age-exclude.js')
const { output } = require('proc-log')
const localeCompare = require('@isaacs/string-locale-compare')('en')
const ArboristWorkspaceCmd = require('../arborist-cmd.js')
Expand Down Expand Up @@ -32,6 +33,7 @@ class Outdated extends ArboristWorkspaceCmd {
'workspace',
'before',
'min-release-age',
'min-release-age-exclude',
]

#tree
Expand Down Expand Up @@ -183,8 +185,14 @@ class Outdated extends ArboristWorkspaceCmd {
try {
const packument = await this.#getPackument(spec)
const expected = alias ? alias.fetchSpec : edge.spec
const wanted = pickManifest(packument, expected, this.npm.flatOptions)
const latest = pickManifest(packument, '*', this.npm.flatOptions)
const { minReleaseAgeExclude } = this.npm.flatOptions
// Packages matching `min-release-age-exclude` resolve to their newest
// version, so drop the `before` constraint for them.
const pickOpts = isReleaseAgeExcluded(packument.name, minReleaseAgeExclude)
? { ...this.npm.flatOptions, before: null }
: this.npm.flatOptions
const wanted = pickManifest(packument, expected, pickOpts)
const latest = pickManifest(packument, '*', pickOpts)
if (!current || current !== wanted.version || wanted.version !== latest.version) {
this.#list.push({
name: alias ? edge.spec.replace('npm', edge.name) : edge.name,
Expand Down
3 changes: 3 additions & 0 deletions lib/commands/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class Query extends BaseCommand {
'include-workspace-root',
'package-lock-only',
'expect-results',
'before',
'min-release-age',
'min-release-age-exclude',
]

constructor (...args) {
Expand Down
1 change: 1 addition & 0 deletions lib/commands/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Update extends ArboristWorkspaceCmd {
'audit',
'before',
'min-release-age',
'min-release-age-exclude',
'bin-links',
'fund',
'dry-run',
Expand Down
26 changes: 26 additions & 0 deletions lib/utils/allow-scripts-cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class AllowScriptsCmd extends BaseCommand {
}

runPending (unreviewed) {
if (this.npm.flatOptions.json) {
output.buffer({ allowScripts: this.pendingSummary(unreviewed) })
return
}
if (unreviewed.length === 0) {
output.standard('No packages with unreviewed install scripts.')
return
Expand All @@ -105,8 +109,30 @@ class AllowScriptsCmd extends BaseCommand {
)
}

// Build the same `{ name, changes }` shape printSummary uses for writes,
// but tag every entry as `pending` since nothing is written. Names and
// versions are derived exactly like the text listing above.
pendingSummary (unreviewed) {
const groups = new Map()
for (const { node } of unreviewed) {
const { name, version } = trustedDisplay(node)
/* istanbul ignore next: every test node has a name */
const display = name || '<unknown>'
const key = version ? `${display}@${version}` : display
if (!groups.has(display)) {
groups.set(display, [])
}
groups.get(display).push({ key, change: 'pending' })
}
return [...groups].map(([name, changes]) => ({ name, changes }))
}

async runAll (unreviewed) {
if (unreviewed.length === 0) {
if (this.npm.flatOptions.json) {
output.buffer({ allowScripts: [] })
return
}
output.standard('No packages with unreviewed install scripts.')
return
}
Expand Down
2 changes: 1 addition & 1 deletion smoke-tests/tap-snapshots/test/index.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ npm error --allow-scripts
npm error Comma-separated list of packages whose install-time lifecycle scripts
npm error
npm error --strict-allow-scripts
npm error If \`true\`, turn the install-script policy from a silent skip into a
npm error If \`true\`, turn the install-script policy from a warning into a hard
npm error
npm error --dangerously-allow-all-scripts
npm error If \`true\`, bypass the \`allowScripts\` policy entirely and run every
Expand Down
2 changes: 2 additions & 0 deletions tap-snapshots/test/lib/commands/config.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"maxsockets": 15,
"message": "%s",
"min-release-age": null,
"min-release-age-exclude": [],
"node-gyp": "{CWD}/node_modules/node-gyp/bin/node-gyp.js",
"node-options": null,
"noproxy": [
Expand Down Expand Up @@ -299,6 +300,7 @@ logs-max = 10
maxsockets = 15
message = "%s"
min-release-age = null
min-release-age-exclude = []
name = null
node-gyp = "{CWD}/node_modules/node-gyp/bin/node-gyp.js"
node-options = null
Expand Down
Loading
Loading