diff --git a/lib/commands/access.js b/lib/commands/access.js index 7d3930dacbce9..206d6de9c22c4 100644 --- a/lib/commands/access.js +++ b/lib/commands/access.js @@ -3,7 +3,6 @@ const path = require('path') const libaccess = require('libnpmaccess') const readPackageJson = require('read-package-json-fast') -const log = require('../utils/log-shim.js') const otplease = require('../utils/otplease.js') const getIdentity = require('../utils/get-identity.js') const BaseCommand = require('../base-command.js') @@ -79,7 +78,6 @@ class Access extends BaseCommand { return this[cmd](args, { ...this.npm.flatOptions, - log, }) } diff --git a/lib/commands/adduser.js b/lib/commands/adduser.js index 1cf70fffbf541..cbeaaaf0f28be 100644 --- a/lib/commands/adduser.js +++ b/lib/commands/adduser.js @@ -31,7 +31,6 @@ class AddUser extends BaseCommand { creds, registry, scope, - log, }) await this.updateConfig({ diff --git a/lib/commands/ci.js b/lib/commands/ci.js index 5e862a473a70f..e054bee51679c 100644 --- a/lib/commands/ci.js +++ b/lib/commands/ci.js @@ -40,7 +40,6 @@ class CI extends ArboristWorkspaceCmd { ...this.npm.flatOptions, packageLock: true, // npm ci should never skip lock files path: where, - log, save: false, // npm ci should never modify the lockfile or package.json workspaces: this.workspaceNames, } @@ -101,7 +100,7 @@ class CI extends ArboristWorkspaceCmd { scriptShell, stdio: 'inherit', stdioString: true, - banner: log.level !== 'silent', + banner: !this.npm.silent, event, }) } diff --git a/lib/commands/dedupe.js b/lib/commands/dedupe.js index 1c270249adb3f..4662ce3241b24 100644 --- a/lib/commands/dedupe.js +++ b/lib/commands/dedupe.js @@ -1,7 +1,6 @@ // dedupe duplicated packages, or find them in the tree const Arborist = require('@npmcli/arborist') const reifyFinish = require('../utils/reify-finish.js') -const log = require('../utils/log-shim.js') const ArboristWorkspaceCmd = require('../arborist-cmd.js') @@ -40,7 +39,6 @@ class Dedupe extends ArboristWorkspaceCmd { const where = this.npm.prefix const opts = { ...this.npm.flatOptions, - log, path: where, dryRun, save, diff --git a/lib/commands/deprecate.js b/lib/commands/deprecate.js index 5505b9bf77cf7..839e974caf09b 100644 --- a/lib/commands/deprecate.js +++ b/lib/commands/deprecate.js @@ -1,5 +1,4 @@ const fetch = require('npm-registry-fetch') -const log = require('../utils/log-shim.js') const otplease = require('../utils/otplease.js') const npa = require('npm-package-arg') const semver = require('semver') @@ -51,7 +50,6 @@ class Deprecate extends BaseCommand { ...this.npm.flatOptions, spec: p, query: { write: true }, - log, }) Object.keys(packument.versions) @@ -66,7 +64,6 @@ class Deprecate extends BaseCommand { method: 'PUT', body: packument, ignoreBody: true, - log, })) } } diff --git a/lib/commands/diff.js b/lib/commands/diff.js index b3855aa08f3f1..d737a58dc43d8 100644 --- a/lib/commands/diff.js +++ b/lib/commands/diff.js @@ -61,7 +61,6 @@ class Diff extends BaseCommand { ...this.npm.flatOptions, diffFiles: args, where: this.top, - log, }) return this.npm.output(res) } @@ -194,7 +193,6 @@ class Diff extends BaseCommand { const packument = await pacote.packument(spec, { ...this.npm.flatOptions, preferOnline: true, - log, }) bSpec = pickManifest( packument, diff --git a/lib/commands/dist-tag.js b/lib/commands/dist-tag.js index e2b013206d3aa..bb36f3f72bfb2 100644 --- a/lib/commands/dist-tag.js +++ b/lib/commands/dist-tag.js @@ -31,7 +31,6 @@ class DistTag extends BaseCommand { async exec ([cmdName, pkg, tag]) { const opts = { ...this.npm.flatOptions, - log, } if (['add', 'a', 'set', 's'].includes(cmdName)) { diff --git a/lib/commands/doctor.js b/lib/commands/doctor.js index 47a522eb676d0..508faa57aa5e9 100644 --- a/lib/commands/doctor.js +++ b/lib/commands/doctor.js @@ -125,8 +125,7 @@ class Doctor extends BaseCommand { stringLength: s => ansiTrim(s).length, } - const silent = log.levels[log.level] > log.levels.error - if (!silent) { + if (!this.npm.silent) { this.npm.output(table(outTable, tableOpts)) if (!allOk) { console.error('') diff --git a/lib/commands/exec.js b/lib/commands/exec.js index 61a6d965954aa..52fb1f8eb7229 100644 --- a/lib/commands/exec.js +++ b/lib/commands/exec.js @@ -1,7 +1,6 @@ const libexec = require('libnpmexec') const BaseCommand = require('../base-command.js') const getLocationMsg = require('../exec/get-workspace-location-msg.js') -const log = require('../utils/log-shim') // it's like this: // @@ -77,7 +76,6 @@ class Exec extends BaseCommand { call, localBin, locationMsg, - log, globalBin, output, packages, diff --git a/lib/commands/fund.js b/lib/commands/fund.js index 47a51c33a6841..787a5193f0155 100644 --- a/lib/commands/fund.js +++ b/lib/commands/fund.js @@ -5,7 +5,6 @@ const pacote = require('pacote') const semver = require('semver') const npa = require('npm-package-arg') const { depth } = require('treeverse') -const log = require('../utils/log-shim.js') const { readTree: getFundingInfo, normalizeFunding, isValidFunding } = require('libnpmfund') const completion = require('../utils/completion/installed-deep.js') @@ -69,7 +68,6 @@ class Fund extends ArboristWorkspaceCmd { // TODO: add !workspacesEnabled option handling to libnpmfund const fundingInfo = getFundingInfo(tree, { ...this.flatOptions, - log, workspaces: this.workspaceNames, }) diff --git a/lib/commands/hook.js b/lib/commands/hook.js index c99a99585897a..2ff6ac01ce527 100644 --- a/lib/commands/hook.js +++ b/lib/commands/hook.js @@ -2,7 +2,6 @@ const hookApi = require('libnpmhook') const otplease = require('../utils/otplease.js') const relativeDate = require('tiny-relative-date') const Table = require('cli-table3') -const log = require('../utils/log-shim.js') const BaseCommand = require('../base-command.js') class Hook extends BaseCommand { @@ -23,7 +22,6 @@ class Hook extends BaseCommand { async exec (args) { return otplease({ ...this.npm.flatOptions, - log, }, (opts) => { switch (args[0]) { case 'add': @@ -48,7 +46,7 @@ class Hook extends BaseCommand { } else if (opts.parseable) { this.npm.output(Object.keys(hook).join('\t')) this.npm.output(Object.keys(hook).map(k => hook[k]).join('\t')) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`+ ${this.hookName(hook)} ${ opts.unicode ? ' ➜ ' : ' -> ' } ${hook.endpoint}`) @@ -66,7 +64,7 @@ class Hook extends BaseCommand { }) } else if (!hooks.length) { this.npm.output("You don't have any hooks configured yet.") - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { if (hooks.length === 1) { this.npm.output('You have one hook configured.') } else { @@ -103,7 +101,7 @@ class Hook extends BaseCommand { } else if (opts.parseable) { this.npm.output(Object.keys(hook).join('\t')) this.npm.output(Object.keys(hook).map(k => hook[k]).join('\t')) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`- ${this.hookName(hook)} ${ opts.unicode ? ' ✘ ' : ' X ' } ${hook.endpoint}`) @@ -117,7 +115,7 @@ class Hook extends BaseCommand { } else if (opts.parseable) { this.npm.output(Object.keys(hook).join('\t')) this.npm.output(Object.keys(hook).map(k => hook[k]).join('\t')) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`+ ${this.hookName(hook)} ${ opts.unicode ? ' ➜ ' : ' -> ' } ${hook.endpoint}`) diff --git a/lib/commands/init.js b/lib/commands/init.js index 7e8a8f7a5c8ab..367533f8259f5 100644 --- a/lib/commands/init.js +++ b/lib/commands/init.js @@ -114,7 +114,6 @@ class Init extends BaseCommand { color, localBin, locationMsg, - log, globalBin, output, path, diff --git a/lib/commands/install.js b/lib/commands/install.js index a92a5edc5ebb7..61526abb7879b 100644 --- a/lib/commands/install.js +++ b/lib/commands/install.js @@ -147,7 +147,6 @@ class Install extends ArboristWorkspaceCmd { const opts = { ...this.npm.flatOptions, - log, auditLevel: null, path: where, add: args, @@ -173,7 +172,7 @@ class Install extends ArboristWorkspaceCmd { scriptShell, stdio: 'inherit', stdioString: true, - banner: log.level !== 'silent', + banner: !this.npm.silent, event, }) } diff --git a/lib/commands/link.js b/lib/commands/link.js index e8e2c6b349aa9..d656791469a64 100644 --- a/lib/commands/link.js +++ b/lib/commands/link.js @@ -7,7 +7,6 @@ const Arborist = require('@npmcli/arborist') const npa = require('npm-package-arg') const rpj = require('read-package-json-fast') const semver = require('semver') -const log = require('../utils/log-shim.js') const reifyFinish = require('../utils/reify-finish.js') @@ -69,7 +68,6 @@ class Link extends ArboristWorkspaceCmd { const globalOpts = { ...this.npm.flatOptions, path: globalTop, - log, global: true, prune: false, } @@ -118,7 +116,6 @@ class Link extends ArboristWorkspaceCmd { const localArb = new Arborist({ ...this.npm.flatOptions, prune: false, - log, path: this.npm.prefix, save, }) @@ -126,7 +123,6 @@ class Link extends ArboristWorkspaceCmd { ...this.npm.flatOptions, prune: false, path: this.npm.prefix, - log, add: names.map(l => `file:${resolve(globalTop, 'node_modules', l)}`), save, workspaces: this.workspaceNames, @@ -143,12 +139,10 @@ class Link extends ArboristWorkspaceCmd { const arb = new Arborist({ ...this.npm.flatOptions, path: globalTop, - log, global: true, }) await arb.reify({ add, - log, }) await reifyFinish(this.npm, arb) } diff --git a/lib/commands/logout.js b/lib/commands/logout.js index 34fbace583562..aea5e93652b0e 100644 --- a/lib/commands/logout.js +++ b/lib/commands/logout.js @@ -25,7 +25,6 @@ class Logout extends BaseCommand { ...this.npm.flatOptions, method: 'DELETE', ignoreBody: true, - log, }) } else if (auth.isBasicAuth) { log.verbose('logout', `clearing user credentials for ${reg}`) diff --git a/lib/commands/org.js b/lib/commands/org.js index 89859200fed6b..f3d344ca33e3d 100644 --- a/lib/commands/org.js +++ b/lib/commands/org.js @@ -2,7 +2,6 @@ const liborg = require('libnpmorg') const otplease = require('../utils/otplease.js') const Table = require('cli-table3') const BaseCommand = require('../base-command.js') -const log = require('../utils/log-shim.js') class Org extends BaseCommand { static description = 'Manage orgs' @@ -35,7 +34,6 @@ class Org extends BaseCommand { async exec ([cmd, orgname, username, role], cb) { return otplease({ ...this.npm.flatOptions, - log, }, opts => { switch (cmd) { case 'add': @@ -76,7 +74,7 @@ class Org extends BaseCommand { this.npm.output( [memDeets.org.name, memDeets.org.size, memDeets.user, memDeets.role].join('\t') ) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output( `Added ${memDeets.user} as ${memDeets.role} to ${memDeets.org.name}. You now have ${ memDeets.org.size @@ -118,7 +116,7 @@ class Org extends BaseCommand { } else if (opts.parseable) { this.npm.output(['user', 'org', 'userCount', 'deleted'].join('\t')) this.npm.output([user, org, userCount, true].join('\t')) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output( `Successfully removed ${user} from ${org}. You now have ${userCount} member${ userCount === 1 ? '' : 's' @@ -149,7 +147,7 @@ class Org extends BaseCommand { Object.keys(roster).forEach(user => { this.npm.output([user, roster[user]].join('\t')) }) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { const table = new Table({ head: ['user', 'role'] }) Object.keys(roster) .sort() diff --git a/lib/commands/owner.js b/lib/commands/owner.js index 7b76b7be42ec6..effaaa6a53d3a 100644 --- a/lib/commands/owner.js +++ b/lib/commands/owner.js @@ -59,7 +59,6 @@ class Owner extends BaseCommand { async exec ([action, ...args]) { const opts = { ...this.npm.flatOptions, - log, } switch (action) { case 'ls': @@ -198,7 +197,6 @@ class Owner extends BaseCommand { method: 'PUT', body, spec, - log, }) }) diff --git a/lib/commands/ping.js b/lib/commands/ping.js index 27089be4e1714..5a651c4a6ab09 100644 --- a/lib/commands/ping.js +++ b/lib/commands/ping.js @@ -10,7 +10,7 @@ class Ping extends BaseCommand { async exec (args) { log.notice('PING', this.npm.config.get('registry')) const start = Date.now() - const details = await pingUtil({ ...this.npm.flatOptions, log }) + const details = await pingUtil({ ...this.npm.flatOptions }) const time = Date.now() - start log.notice('PONG', `${time}ms`) if (this.npm.config.get('json')) { diff --git a/lib/commands/profile.js b/lib/commands/profile.js index 9786e9ba4d4cf..6b4d1407f7919 100644 --- a/lib/commands/profile.js +++ b/lib/commands/profile.js @@ -108,7 +108,7 @@ class Profile extends BaseCommand { async get (args) { const tfa = 'two-factor auth' const info = await pulseTillDone.withPromise( - npmProfile.get({ ...this.npm.flatOptions, log }) + npmProfile.get({ ...this.npm.flatOptions }) ) if (!info.cidr_whitelist) { @@ -170,7 +170,7 @@ class Profile extends BaseCommand { } async set (args) { - const conf = { ...this.npm.flatOptions, log } + const conf = { ...this.npm.flatOptions } const prop = (args[0] || '').toLowerCase().trim() let value = args.length > 1 ? args.slice(1).join(' ') : null @@ -285,7 +285,7 @@ class Profile extends BaseCommand { if (auth.basic) { log.info('profile', 'Updating authentication to bearer token') const result = await npmProfile.createToken( - auth.basic.password, false, [], { ...this.npm.flatOptions, log } + auth.basic.password, false, [], { ...this.npm.flatOptions } ) if (!result.token) { @@ -309,7 +309,7 @@ class Profile extends BaseCommand { log.info('profile', 'Determine if tfa is pending') const userInfo = await pulseTillDone.withPromise( - npmProfile.get({ ...this.npm.flatOptions, log }) + npmProfile.get({ ...this.npm.flatOptions }) ) const conf = { ...this.npm.flatOptions } diff --git a/lib/commands/prune.js b/lib/commands/prune.js index 5831df62859c2..16c8b6d4329ac 100644 --- a/lib/commands/prune.js +++ b/lib/commands/prune.js @@ -1,6 +1,5 @@ // prune extraneous packages const Arborist = require('@npmcli/arborist') -const log = require('../utils/log-shim.js') const reifyFinish = require('../utils/reify-finish.js') const ArboristWorkspaceCmd = require('../arborist-cmd.js') @@ -15,7 +14,6 @@ class Prune extends ArboristWorkspaceCmd { const opts = { ...this.npm.flatOptions, path: where, - log, workspaces: this.workspaceNames, } const arb = new Arborist(opts) diff --git a/lib/commands/publish.js b/lib/commands/publish.js index 63106c520bd58..d1f0ee743cfcc 100644 --- a/lib/commands/publish.js +++ b/lib/commands/publish.js @@ -55,13 +55,13 @@ class Publish extends BaseCommand { const json = this.npm.config.get('json') const defaultTag = this.npm.config.get('tag') const ignoreScripts = this.npm.config.get('ignore-scripts') - const silent = log.level === 'silent' + const { silent } = this.npm if (semver.validRange(defaultTag)) { throw new Error('Tag name must not be a valid SemVer range: ' + defaultTag.trim()) } - const opts = { ...this.npm.flatOptions, log } + const opts = { ...this.npm.flatOptions } // you can publish name@version, ./foo.tgz, etc. // even though the default is the 'file:.' cwd. @@ -152,7 +152,7 @@ class Publish extends BaseCommand { const results = {} const json = this.npm.config.get('json') - const silent = log.level === 'silent' + const { silent } = this.npm const noop = a => a const color = this.npm.color ? chalk : { green: noop, bold: noop } await this.setWorkspaces(filters) diff --git a/lib/commands/run-script.js b/lib/commands/run-script.js index cd877e0b3dfa4..edba95821b44c 100644 --- a/lib/commands/run-script.js +++ b/lib/commands/run-script.js @@ -116,7 +116,7 @@ class RunScript extends BaseCommand { stdio: 'inherit', stdioString: true, pkg, - banner: log.level !== 'silent', + banner: !this.npm.silent, } for (const [event, args] of events) { @@ -139,7 +139,7 @@ class RunScript extends BaseCommand { } const allScripts = Object.keys(scripts) - if (log.level === 'silent') { + if (this.npm.silent) { return allScripts } @@ -233,7 +233,7 @@ class RunScript extends BaseCommand { async listWorkspaces (args, filters) { await this.setWorkspaces(filters) - if (log.level === 'silent') { + if (this.npm.silent) { return } diff --git a/lib/commands/star.js b/lib/commands/star.js index 4974c39883e43..2d08747aa7719 100644 --- a/lib/commands/star.js +++ b/lib/commands/star.js @@ -29,13 +29,12 @@ class Star extends BaseCommand { const pkgs = args.map(npa) for (const pkg of pkgs) { const [username, fullData] = await Promise.all([ - getIdentity(this.npm, { ...this.npm.flatOptions, log }), + getIdentity(this.npm, { ...this.npm.flatOptions }), fetch.json(pkg.escapedName, { ...this.npm.flatOptions, spec: pkg, query: { write: true }, preferOnline: true, - log, }), ]) @@ -64,7 +63,6 @@ class Star extends BaseCommand { spec: pkg, method: 'PUT', body, - log, }) this.npm.output(show + ' ' + pkg.name) diff --git a/lib/commands/team.js b/lib/commands/team.js index e3fb9b83c5a27..1e13a83f52b09 100644 --- a/lib/commands/team.js +++ b/lib/commands/team.js @@ -1,7 +1,6 @@ const columns = require('cli-columns') const libteam = require('libnpmteam') -const log = require('../utils/log-shim.js') const otplease = require('../utils/otplease.js') const BaseCommand = require('../base-command.js') @@ -43,7 +42,7 @@ class Team extends BaseCommand { // XXX: "description" option to libnpmteam is used as a description of the // team, but in npm's options, this is a boolean meaning "show the // description in npm search output". Hence its being set to null here. - await otplease({ ...this.npm.flatOptions, log }, opts => { + await otplease({ ...this.npm.flatOptions }, opts => { entity = entity.replace(/^@/, '') switch (cmd) { case 'create': return this.create(entity, opts) @@ -73,7 +72,7 @@ class Team extends BaseCommand { })) } else if (opts.parseable) { this.npm.output(`${entity}\tcreated`) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`+@${entity}`) } } @@ -87,7 +86,7 @@ class Team extends BaseCommand { })) } else if (opts.parseable) { this.npm.output(`${entity}\tdeleted`) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`-@${entity}`) } } @@ -102,7 +101,7 @@ class Team extends BaseCommand { })) } else if (opts.parseable) { this.npm.output(`${user}\t${entity}\tadded`) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`${user} added to @${entity}`) } } @@ -117,7 +116,7 @@ class Team extends BaseCommand { })) } else if (opts.parseable) { this.npm.output(`${user}\t${entity}\tremoved`) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { this.npm.output(`${user} removed from @${entity}`) } } @@ -128,7 +127,7 @@ class Team extends BaseCommand { this.npm.output(JSON.stringify(users, null, 2)) } else if (opts.parseable) { this.npm.output(users.join('\n')) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { const plural = users.length === 1 ? '' : 's' const more = users.length === 0 ? '' : ':\n' this.npm.output(`\n@${entity} has ${users.length} user${plural}${more}`) @@ -142,7 +141,7 @@ class Team extends BaseCommand { this.npm.output(JSON.stringify(teams, null, 2)) } else if (opts.parseable) { this.npm.output(teams.join('\n')) - } else if (!opts.silent && opts.loglevel !== 'silent') { + } else if (!this.npm.silent) { const plural = teams.length === 1 ? '' : 's' const more = teams.length === 0 ? '' : ':\n' this.npm.output(`\n@${entity} has ${teams.length} team${plural}${more}`) diff --git a/lib/commands/token.js b/lib/commands/token.js index cfb5ab666565a..df80f1afec44e 100644 --- a/lib/commands/token.js +++ b/lib/commands/token.js @@ -168,7 +168,7 @@ class Token extends BaseCommand { } config () { - const conf = { ...this.npm.flatOptions, log } + const conf = { ...this.npm.flatOptions } const creds = this.npm.config.getCredentialsByURI(conf.registry) if (creds.token) { conf.auth = { token: creds.token } diff --git a/lib/commands/uninstall.js b/lib/commands/uninstall.js index b40c59bda4419..587968e3bbba9 100644 --- a/lib/commands/uninstall.js +++ b/lib/commands/uninstall.js @@ -1,5 +1,4 @@ const { resolve } = require('path') -const log = require('../utils/log-shim.js') const Arborist = require('@npmcli/arborist') const rpj = require('read-package-json-fast') @@ -49,7 +48,6 @@ class Uninstall extends ArboristWorkspaceCmd { const opts = { ...this.npm.flatOptions, path, - log, rm: args, workspaces: this.workspaceNames, } diff --git a/lib/commands/unpublish.js b/lib/commands/unpublish.js index d8410cc13481b..c848b6389d1b8 100644 --- a/lib/commands/unpublish.js +++ b/lib/commands/unpublish.js @@ -32,7 +32,7 @@ class Unpublish extends BaseCommand { return [] } - const opts = { ...this.npm.flatOptions, log } + const opts = { ...this.npm.flatOptions } const username = await getIdentity(this.npm, { ...opts }).catch(() => null) if (!username) { return [] @@ -68,8 +68,7 @@ class Unpublish extends BaseCommand { const spec = args.length && npa(args[0]) const force = this.npm.config.get('force') - const loglevel = this.npm.config.get('loglevel') - const silent = loglevel === 'silent' + const { silent } = this.npm const dryRun = this.npm.config.get('dry-run') let pkgName let pkgVersion @@ -84,7 +83,7 @@ class Unpublish extends BaseCommand { ) } - const opts = { ...this.npm.flatOptions, log } + const opts = { ...this.npm.flatOptions } if (!spec || path.resolve(spec.name) === this.npm.localPrefix) { // if there's a package.json in the current folder, then // read the package name and version out of that. diff --git a/lib/commands/update.js b/lib/commands/update.js index c55d7cf575d88..025ebbaf815f0 100644 --- a/lib/commands/update.js +++ b/lib/commands/update.js @@ -54,7 +54,6 @@ class Update extends ArboristWorkspaceCmd { const opts = { ...this.npm.flatOptions, - log, path: where, save, workspaces: this.workspaceNames, diff --git a/lib/commands/whoami.js b/lib/commands/whoami.js index 07ebe2e244753..154cc870391ba 100644 --- a/lib/commands/whoami.js +++ b/lib/commands/whoami.js @@ -1,5 +1,4 @@ const getIdentity = require('../utils/get-identity.js') -const log = require('../utils/log-shim.js') const BaseCommand = require('../base-command.js') class Whoami extends BaseCommand { @@ -8,7 +7,7 @@ class Whoami extends BaseCommand { static params = ['registry'] async exec (args) { - const username = await getIdentity(this.npm, { ...this.npm.flatOptions, log }) + const username = await getIdentity(this.npm, { ...this.npm.flatOptions }) this.npm.output( this.npm.config.get('json') ? JSON.stringify(username) : username ) diff --git a/lib/npm.js b/lib/npm.js index 4d22b531a4662..ce8f6aee8f575 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -52,7 +52,6 @@ class Npm extends EventEmitter { definitions, flatten, shorthands, - log, }) this[_title] = process.title this.updateNotification = null @@ -251,6 +250,7 @@ class Npm extends EventEmitter { // Use logColor since that is based on stderr color: this.logColor, progress: this.flatOptions.progress, + silent: this.silent, timing: this.config.get('timing'), loglevel: this.config.get('loglevel'), unicode: this.config.get('unicode'), @@ -300,6 +300,10 @@ class Npm extends EventEmitter { return this.flatOptions.logColor } + get silent () { + return this.flatOptions.silent + } + get lockfileVersion () { return 2 } diff --git a/lib/utils/config/definitions.js b/lib/utils/config/definitions.js index 79e686ca75134..c5c129eb3d495 100644 --- a/lib/utils/config/definitions.js +++ b/lib/utils/config/definitions.js @@ -1222,6 +1222,9 @@ define('loglevel', { See also the \`foreground-scripts\` config. `, + flatten (key, obj, flatOptions) { + flatOptions.silent = obj[key] === 'silent' + }, }) define('logs-max', { diff --git a/lib/utils/display.js b/lib/utils/display.js index aae51e8806f8a..a19f72297e838 100644 --- a/lib/utils/display.js +++ b/lib/utils/display.js @@ -35,6 +35,7 @@ class Display { loglevel, unicode, progress, + silent, heading = 'npm', } = config @@ -59,8 +60,7 @@ class Display { log.disableUnicode() } - // if it's more than error, don't show progress - const silent = log.levels[log.level] > log.levels.error + // if it's silent, don't show progress if (progress && !silent) { log.enableProgress() } else { diff --git a/lib/utils/exit-handler.js b/lib/utils/exit-handler.js index 22c774101751b..6186ea81dcc02 100644 --- a/lib/utils/exit-handler.js +++ b/lib/utils/exit-handler.js @@ -49,8 +49,8 @@ process.on('exit', code => { // npm must be loaded to know where the log file was written if (showLogFileMessage && hasLoadedNpm) { - // just a line break - if (log.levels[log.level] <= log.levels.error) { + // just a line break if not in silent mode + if (!npm.silent) { console.error('') } @@ -175,7 +175,7 @@ const exitHandler = err => { log.verbose('exit', exitCode || 0) - showLogFileMessage = log.level === 'silent' || noLogMessage + showLogFileMessage = (hasLoadedNpm && npm.silent) || noLogMessage ? false : !!exitCode diff --git a/lib/utils/reify-output.js b/lib/utils/reify-output.js index b4114c1b2fe04..b5c3a593b8db0 100644 --- a/lib/utils/reify-output.js +++ b/lib/utils/reify-output.js @@ -27,7 +27,7 @@ const reifyOutput = (npm, arb) => { // don't print any info in --silent mode, but we still need to // set the exitCode properly from the audit report, if we have one. - if (log.levels[log.level] > log.levels.error) { + if (npm.silent) { getAuditReport(npm, auditReport) return } @@ -88,7 +88,7 @@ const reifyOutput = (npm, arb) => { // at the end if there's still stuff, because it's silly for `npm audit` // to tell you to run `npm audit` for details. otherwise, use the summary // report. if we get here, we know it's not quiet or json. -// If the loglevel is set higher than 'error', then we just run the report +// If the loglevel is silent, then we just run the report // to get the exitCode set appropriately. const printAuditReport = (npm, report) => { const res = getAuditReport(npm, report) @@ -105,7 +105,7 @@ const getAuditReport = (npm, report) => { // when in silent mode, we print nothing. the JSON output is // going to just JSON.stringify() the report object. - const reporter = log.levels[log.level] > log.levels.error ? 'quiet' + const reporter = npm.silent ? 'quiet' : npm.flatOptions.json ? 'quiet' : npm.command !== 'audit' ? 'install' : 'detail' diff --git a/lib/utils/update-notifier.js b/lib/utils/update-notifier.js index 44b6a5433c09a..875c3a99a2579 100644 --- a/lib/utils/update-notifier.js +++ b/lib/utils/update-notifier.js @@ -10,7 +10,6 @@ const { promisify } = require('util') const stat = promisify(require('fs').stat) const writeFile = promisify(require('fs').writeFile) const { resolve } = require('path') -const log = require('./log-shim.js') const isGlobalNpmUpdate = npm => { return npm.flatOptions.global && @@ -62,7 +61,7 @@ const updateNotifier = async (npm, spec = 'latest') => { // if they're currently using a prerelease, nudge to the next prerelease // otherwise, nudge to latest. - const useColor = log.useColor() + const useColor = npm.logColor const mani = await pacote.manifest(`npm@${spec}`, { // always prefer latest, even if doing --tag=whatever on the cmd diff --git a/node_modules/@npmcli/config/lib/env-replace.js b/node_modules/@npmcli/config/lib/env-replace.js index a6e4b2968d04e..e0f7276b1ec2b 100644 --- a/node_modules/@npmcli/config/lib/env-replace.js +++ b/node_modules/@npmcli/config/lib/env-replace.js @@ -1,6 +1,6 @@ // replace any ${ENV} values with the appropriate environ. -const envExpr = /(\\*)\$\{([^}]+)\}/g +const envExpr = /(? f.replace(envExpr, (orig, esc, name) => { const val = env[name] !== undefined ? env[name] : `$\{${name}}` diff --git a/node_modules/@npmcli/config/lib/index.js b/node_modules/@npmcli/config/lib/index.js index dc839a5389c3a..82e369938db9c 100644 --- a/node_modules/@npmcli/config/lib/index.js +++ b/node_modules/@npmcli/config/lib/index.js @@ -5,6 +5,7 @@ const nopt = require('nopt') const mkdirp = require('mkdirp-infer-owner') const mapWorkspaces = require('@npmcli/map-workspaces') const rpj = require('read-package-json-fast') +const log = require('proc-log') /* istanbul ignore next */ const myUid = process.getuid && process.getuid() @@ -88,7 +89,6 @@ class Config { // options just to override in tests, mostly env = process.env, argv = process.argv, - log = require('./proc-log.js'), platform = process.platform, execPath = process.execPath, cwd = process.cwd(), @@ -114,7 +114,6 @@ class Config { this.defaults = defaults this.npmPath = npmPath - this.log = log this.argv = argv this.env = env this.execPath = execPath @@ -436,7 +435,7 @@ class Config { } invalidHandler (k, val, type, source, where) { - this.log.warn( + log.warn( 'invalid config', k + '=' + JSON.stringify(val), `set in ${source}` @@ -469,7 +468,7 @@ class Config { : mustBe.filter(m => m !== Array) .map(n => typeof n === 'string' ? n : JSON.stringify(n)) .join(', ') - this.log.warn('invalid config', msg, desc) + log.warn('invalid config', msg, desc) } [_loadObject] (obj, where, source, er = null) { @@ -491,7 +490,7 @@ class Config { if (er) { conf.loadError = er if (er.code !== 'ENOENT') { - this.log.verbose('config', `error loading ${where} config`, er) + log.verbose('config', `error loading ${where} config`, er) } } else { conf.raw = obj @@ -510,7 +509,7 @@ class Config { // XXX a future npm version will make this a warning. // An even more future npm version will make this an error. if (this.deprecated[key]) { - this.log.verbose('config', key, this.deprecated[key]) + log.verbose('config', key, this.deprecated[key]) } } @@ -607,14 +606,14 @@ class Config { .catch(() => false) if (hasNpmrc) { - this.log.warn(`ignoring workspace config at ${this.localPrefix}/.npmrc`) + log.warn(`ignoring workspace config at ${this.localPrefix}/.npmrc`) } // set the workspace in the default layer, which allows it to be overridden easily const { data } = this.data.get('default') data.workspace = [this.localPrefix] this.localPrefix = p - this.log.info(`found workspace root at ${this.localPrefix}`) + log.info(`found workspace root at ${this.localPrefix}`) // we found a root, so we return now return } diff --git a/node_modules/@npmcli/config/lib/proc-log.js b/node_modules/@npmcli/config/lib/proc-log.js deleted file mode 100644 index 0492a26180756..0000000000000 --- a/node_modules/@npmcli/config/lib/proc-log.js +++ /dev/null @@ -1,4 +0,0 @@ -const log = (level) => (...args) => process.emit('log', level, ...args) -for (const level of ['silly', 'verbose', 'warn', 'error']) { - exports[level] = log(level) -} diff --git a/node_modules/@npmcli/config/package.json b/node_modules/@npmcli/config/package.json index b0722db413e5b..ea03f957f83c5 100644 --- a/node_modules/@npmcli/config/package.json +++ b/node_modules/@npmcli/config/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/config", - "version": "3.0.0", + "version": "4.0.0", "files": [ "bin", "lib" @@ -30,22 +30,23 @@ "coverage-map": "map.js" }, "devDependencies": { - "@npmcli/template-oss": "^2.5.1", - "tap": "^15.0.4" + "@npmcli/template-oss": "^2.7.1", + "tap": "^15.1.6" }, "dependencies": { "@npmcli/map-workspaces": "^2.0.0", "ini": "^2.0.0", "mkdirp-infer-owner": "^2.0.0", "nopt": "^5.0.0", + "proc-log": "^2.0.0", "read-package-json-fast": "^2.0.3", - "semver": "^7.3.4", + "semver": "^7.3.5", "walk-up-path": "^1.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" }, "templateOSS": { - "version": "2.6.0" + "version": "2.7.1" } } diff --git a/node_modules/@npmcli/git/lib/clone.js b/node_modules/@npmcli/git/lib/clone.js index 6754fd7606009..ac5f86b14494c 100644 --- a/node_modules/@npmcli/git/lib/clone.js +++ b/node_modules/@npmcli/git/lib/clone.js @@ -15,7 +15,7 @@ const shallowHosts = new Set([ 'gist.github.com', 'gitlab.com', 'bitbucket.com', - 'bitbucket.org' + 'bitbucket.org', ]) // we have to use url.parse until we add the same shim that hosted-git-info has // to handle scp:// urls @@ -113,10 +113,14 @@ const branch = (repo, revDoc, target, opts) => { revDoc.ref, repo, target, - '--recurse-submodules' + '--recurse-submodules', ] - if (maybeShallow(repo, opts)) { args.push('--depth=1') } - if (isWindows(opts)) { args.push('--config', 'core.longpaths=true') } + if (maybeShallow(repo, opts)) { + args.push('--depth=1') + } + if (isWindows(opts)) { + args.push('--config', 'core.longpaths=true') + } return spawn(args, opts).then(() => revDoc.sha) } @@ -126,10 +130,14 @@ const plain = (repo, revDoc, target, opts) => { 'clone', repo, target, - '--recurse-submodules' + '--recurse-submodules', ] - if (maybeShallow(repo, opts)) { args.push('--depth=1') } - if (isWindows(opts)) { args.push('--config', 'core.longpaths=true') } + if (maybeShallow(repo, opts)) { + args.push('--depth=1') + } + if (isWindows(opts)) { + args.push('--config', 'core.longpaths=true') + } return spawn(args, opts).then(() => revDoc.sha) } @@ -143,7 +151,7 @@ const updateSubmodules = (target, opts) => new Promise(resolve => 'update', '-q', '--init', - '--recursive' + '--recursive', ], { ...opts, cwd: target })) })) diff --git a/node_modules/@npmcli/git/lib/errors.js b/node_modules/@npmcli/git/lib/errors.js index 25b2b9f9fd6a6..7aeac4762866f 100644 --- a/node_modules/@npmcli/git/lib/errors.js +++ b/node_modules/@npmcli/git/lib/errors.js @@ -32,5 +32,5 @@ class GitUnknownError extends GitError { module.exports = { GitConnectionError, GitPathspecError, - GitUnknownError + GitUnknownError, } diff --git a/node_modules/@npmcli/git/lib/index.js b/node_modules/@npmcli/git/lib/index.js index 20d7cfd01cfd1..10a65f782e6da 100644 --- a/node_modules/@npmcli/git/lib/index.js +++ b/node_modules/@npmcli/git/lib/index.js @@ -5,5 +5,5 @@ module.exports = { is: require('./is.js'), find: require('./find.js'), isClean: require('./is-clean.js'), - errors: require('./errors.js') + errors: require('./errors.js'), } diff --git a/node_modules/@npmcli/git/lib/lines-to-revs.js b/node_modules/@npmcli/git/lib/lines-to-revs.js index 9f879ca2475f5..3cf3778fe9178 100644 --- a/node_modules/@npmcli/git/lib/lines-to-revs.js +++ b/node_modules/@npmcli/git/lib/lines-to-revs.js @@ -7,7 +7,7 @@ module.exports = lines => finish(lines.reduce(linesToRevsReducer, { versions: {}, 'dist-tags': {}, refs: {}, - shas: {} + shas: {}, })) const finish = revs => distTags(shaList(peelTags(revs))) @@ -52,7 +52,9 @@ const distTags = revs => { revs['dist-tags'].latest = v } else if (ver.sha === HEAD.sha) { revs['dist-tags'].HEAD = v - if (!revs.refs.latest) { revs['dist-tags'].latest = v } + if (!revs.refs.latest) { + revs['dist-tags'].latest = v + } } }) return revs @@ -79,7 +81,9 @@ const refType = ref => { // return the doc, or null if we should ignore it. const lineToRevDoc = line => { const split = line.trim().split(/\s+/, 2) - if (split.length < 2) { return null } + if (split.length < 2) { + return null + } const sha = split[0].trim() const rawRef = split[1].trim() @@ -122,7 +126,9 @@ const lineToRevDoc = line => { const linesToRevsReducer = (revs, line) => { const doc = lineToRevDoc(line) - if (!doc) { return revs } + if (!doc) { + return revs + } revs.refs[doc.ref] = doc revs.refs[doc.rawRef] = doc diff --git a/node_modules/@npmcli/git/lib/make-error.js b/node_modules/@npmcli/git/lib/make-error.js index 043a8e6e95181..7540ec7c8b9f7 100644 --- a/node_modules/@npmcli/git/lib/make-error.js +++ b/node_modules/@npmcli/git/lib/make-error.js @@ -1,7 +1,7 @@ const { GitConnectionError, GitPathspecError, - GitUnknownError + GitUnknownError, } = require('./errors.js') const connectionErrorRe = new RegExp([ @@ -12,7 +12,7 @@ const connectionErrorRe = new RegExp([ 'Failed to connect to .* Timed out', 'Connection reset by peer', 'SSL_ERROR_SYSCALL', - 'The requested URL returned error: 503' + 'The requested URL returned error: 503', ].join('|')) const missingPathspecRe = /pathspec .* did not match any file\(s\) known to git/ diff --git a/node_modules/@npmcli/git/lib/opts.js b/node_modules/@npmcli/git/lib/opts.js index 144e0a3aaf03f..3119af16e0cf1 100644 --- a/node_modules/@npmcli/git/lib/opts.js +++ b/node_modules/@npmcli/git/lib/opts.js @@ -2,11 +2,11 @@ // This defaults to accepting new ssh host key fingerprints const gitEnv = { GIT_ASKPASS: 'echo', - GIT_SSH_COMMAND: 'ssh -oStrictHostKeyChecking=accept-new' + GIT_SSH_COMMAND: 'ssh -oStrictHostKeyChecking=accept-new', } module.exports = (opts = {}) => ({ stdioString: true, ...opts, shell: false, - env: opts.env || { ...gitEnv, ...process.env } + env: opts.env || { ...gitEnv, ...process.env }, }) diff --git a/node_modules/@npmcli/git/lib/proc-log.js b/node_modules/@npmcli/git/lib/proc-log.js deleted file mode 100644 index b2bdd9dc90205..0000000000000 --- a/node_modules/@npmcli/git/lib/proc-log.js +++ /dev/null @@ -1,21 +0,0 @@ -// default logger. -// emits 'log' events on the process -const LEVELS = [ - 'notice', - 'error', - 'warn', - 'info', - 'verbose', - 'http', - 'silly', - 'pause', - 'resume' -] - -const log = level => (...args) => process.emit('log', level, ...args) - -const logger = {} -for (const level of LEVELS) { - logger[level] = log(level) -} -module.exports = logger diff --git a/node_modules/@npmcli/git/lib/revs.js b/node_modules/@npmcli/git/lib/revs.js index 81059594f7aee..ee72370d5b7ec 100644 --- a/node_modules/@npmcli/git/lib/revs.js +++ b/node_modules/@npmcli/git/lib/revs.js @@ -4,7 +4,7 @@ const LRU = require('lru-cache') const revsCache = new LRU({ max: 100, - maxAge: 5 * 60 * 1000 + ttl: 5 * 60 * 1000, }) const linesToRevs = require('./lines-to-revs.js') diff --git a/node_modules/@npmcli/git/lib/spawn.js b/node_modules/@npmcli/git/lib/spawn.js index 1c89a4c53cf86..40972a509caa5 100644 --- a/node_modules/@npmcli/git/lib/spawn.js +++ b/node_modules/@npmcli/git/lib/spawn.js @@ -1,28 +1,29 @@ const spawn = require('@npmcli/promise-spawn') const promiseRetry = require('promise-retry') +const log = require('proc-log') const makeError = require('./make-error.js') const whichGit = require('./which.js') const makeOpts = require('./opts.js') -const procLog = require('./proc-log.js') module.exports = (gitArgs, opts = {}) => { const gitPath = whichGit(opts) - if (gitPath instanceof Error) { return Promise.reject(gitPath) } + if (gitPath instanceof Error) { + return Promise.reject(gitPath) + } // undocumented option, mostly only here for tests const args = opts.allowReplace || gitArgs[0] === '--no-replace-objects' ? gitArgs : ['--no-replace-objects', ...gitArgs] - const log = opts.log || procLog let retry = opts.retry if (retry === null || retry === undefined) { retry = { retries: opts.fetchRetries || 2, factor: opts.fetchRetryFactor || 10, maxTimeout: opts.fetchRetryMaxtimeout || 60000, - minTimeout: opts.fetchRetryMintimeout || 1000 + minTimeout: opts.fetchRetryMintimeout || 1000, } } return promiseRetry((retry, number) => { diff --git a/node_modules/@npmcli/git/node_modules/lru-cache/LICENSE b/node_modules/@npmcli/git/node_modules/lru-cache/LICENSE new file mode 100644 index 0000000000000..9b58a3e03d1df --- /dev/null +++ b/node_modules/@npmcli/git/node_modules/lru-cache/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) 2010-2022 Isaac Z. Schlueter and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/node_modules/@npmcli/git/node_modules/lru-cache/index.js b/node_modules/@npmcli/git/node_modules/lru-cache/index.js new file mode 100644 index 0000000000000..ede2f30cc4b23 --- /dev/null +++ b/node_modules/@npmcli/git/node_modules/lru-cache/index.js @@ -0,0 +1,581 @@ +const perf = typeof performance === 'object' && performance && + typeof performance.now === 'function' ? performance : Date + +const warned = new Set() +const deprecatedOption = (opt, msg) => { + const code = `LRU_CACHE_OPTION_${opt}` + if (shouldWarn(code)) { + warn(code, `The ${opt} option is deprecated. ${msg}`, LRUCache) + } +} +const deprecatedMethod = (method, msg) => { + const code = `LRU_CACHE_METHOD_${method}` + if (shouldWarn(code)) { + const { prototype } = LRUCache + const { get } = Object.getOwnPropertyDescriptor(prototype, method) + warn(code, `The ${method} method is deprecated. ${msg}`, get) + } +} +const deprecatedProperty = (field, msg) => { + const code = `LRU_CACHE_PROPERTY_${field}` + if (shouldWarn(code)) { + const { prototype } = LRUCache + const { get } = Object.getOwnPropertyDescriptor(prototype, field) + warn(code, `The ${field} property is deprecated. ${msg}`, get) + } +} +const shouldWarn = (code) => !(process.noDeprecation || warned.has(code)) +const warn = (code, msg, fn) => { + warned.add(code) + process.emitWarning(msg, 'DeprecationWarning', code, fn) +} + +const isPosInt = n => n && n === Math.floor(n) && n > 0 && isFinite(n) + +/* istanbul ignore next - This is a little bit ridiculous, tbh. + * The maximum array length is 2^32-1 or thereabouts on most JS impls. + * And well before that point, you're caching the entire world, I mean, + * that's ~32GB of just integers for the next/prev links, plus whatever + * else to hold that many keys and values. Just filling the memory with + * zeroes at init time is brutal when you get that big. + * But why not be complete? + * Maybe in the future, these limits will have expanded. */ +const getUintArray = max => !isPosInt(max) ? null +: max <= Math.pow(2, 8) ? Uint8Array +: max <= Math.pow(2, 16) ? Uint16Array +: max <= Math.pow(2, 32) ? Uint32Array +: max <= Number.MAX_SAFE_INTEGER ? ZeroArray +: null + +class ZeroArray extends Array { + constructor (size) { + super(size) + this.fill(0) + } +} + +class Stack { + constructor (max) { + const UintArray = getUintArray(max) + this.heap = new UintArray(max) + this.length = 0 + } + push (n) { + this.heap[this.length++] = n + } + pop () { + return this.heap[--this.length] + } +} + +class LRUCache { + constructor (options = {}) { + const { + max, + ttl, + ttlResolution = 1, + ttlAutopurge, + updateAgeOnGet, + allowStale, + dispose, + disposeAfter, + noDisposeOnSet, + maxSize, + sizeCalculation, + } = options + + // deprecated options, don't trigger a warning for getting them if + // the thing being passed in is another LRUCache we're copying. + const { + length, + maxAge, + stale, + } = options instanceof LRUCache ? {} : options + + if (!isPosInt(max)) { + throw new TypeError('max option must be an integer') + } + + const UintArray = getUintArray(max) + if (!UintArray) { + throw new Error('invalid max value: ' + max) + } + + this.max = max + this.maxSize = maxSize || 0 + this.sizeCalculation = sizeCalculation || length + if (this.sizeCalculation) { + if (!this.maxSize) { + throw new TypeError('cannot set sizeCalculation without setting maxSize') + } + if (typeof this.sizeCalculation !== 'function') { + throw new TypeError('sizeCalculating set to non-function') + } + } + this.keyMap = new Map() + this.keyList = new Array(max).fill(null) + this.valList = new Array(max).fill(null) + this.next = new UintArray(max) + this.prev = new UintArray(max) + this.head = 0 + this.tail = 0 + this.free = new Stack(max) + this.initialFill = 1 + this.size = 0 + + if (typeof dispose === 'function') { + this.dispose = dispose + } + if (typeof disposeAfter === 'function') { + this.disposeAfter = disposeAfter + this.disposed = [] + } else { + this.disposeAfter = null + this.disposed = null + } + this.noDisposeOnSet = !!noDisposeOnSet + + if (this.maxSize) { + if (!isPosInt(this.maxSize)) { + throw new TypeError('maxSize must be a positive integer if specified') + } + this.initializeSizeTracking() + } + + this.allowStale = !!allowStale || !!stale + this.updateAgeOnGet = !!updateAgeOnGet + this.ttlResolution = isPosInt(ttlResolution) || ttlResolution === 0 + ? ttlResolution : 1 + this.ttlAutopurge = !!ttlAutopurge + this.ttl = ttl || maxAge || 0 + if (this.ttl) { + if (!isPosInt(this.ttl)) { + throw new TypeError('ttl must be a positive integer if specified') + } + this.initializeTTLTracking() + } + + if (stale) { + deprecatedOption('stale', 'please use options.allowStale instead') + } + if (maxAge) { + deprecatedOption('maxAge', 'please use options.ttl instead') + } + if (length) { + deprecatedOption('length', 'please use options.sizeCalculation instead') + } + } + + initializeTTLTracking () { + this.ttls = new ZeroArray(this.max) + this.starts = new ZeroArray(this.max) + this.setItemTTL = (index, ttl) => { + this.starts[index] = ttl !== 0 ? perf.now() : 0 + this.ttls[index] = ttl + if (ttl !== 0 && this.ttlAutopurge) { + const t = setTimeout(() => { + if (this.isStale(index)) { + this.delete(this.keyList[index]) + } + }, ttl + 1) + /* istanbul ignore else - unref() not supported on all platforms */ + if (t.unref) { + t.unref() + } + } + } + this.updateItemAge = (index) => { + this.starts[index] = this.ttls[index] !== 0 ? perf.now() : 0 + } + // debounce calls to perf.now() to 1s so we're not hitting + // that costly call repeatedly. + let cachedNow = 0 + const getNow = () => { + const n = perf.now() + if (this.ttlResolution > 0) { + cachedNow = n + const t = setTimeout(() => cachedNow = 0, this.ttlResolution) + /* istanbul ignore else - not available on all platforms */ + if (t.unref) { + t.unref() + } + } + return n + } + this.isStale = (index) => { + return this.ttls[index] !== 0 && this.starts[index] !== 0 && + ((cachedNow || getNow()) - this.starts[index] > this.ttls[index]) + } + } + updateItemAge (index) {} + setItemTTL (index, ttl) {} + isStale (index) { return false } + + initializeSizeTracking () { + this.calculatedSize = 0 + this.sizes = new ZeroArray(this.max) + this.removeItemSize = index => this.calculatedSize -= this.sizes[index] + this.addItemSize = (index, v, k, size, sizeCalculation) => { + const s = size || (sizeCalculation ? sizeCalculation(v, k) : 0) + this.sizes[index] = isPosInt(s) ? s : 0 + const maxSize = this.maxSize - this.sizes[index] + while (this.calculatedSize > maxSize) { + this.evict() + } + this.calculatedSize += this.sizes[index] + } + this.delete = k => { + if (this.size !== 0) { + const index = this.keyMap.get(k) + if (index !== undefined) { + this.calculatedSize -= this.sizes[index] + } + } + return LRUCache.prototype.delete.call(this, k) + } + } + removeItemSize (index) {} + addItemSize (index, v, k, size, sizeCalculation) {} + + *indexes () { + if (this.size) { + for (let i = this.tail; true; i = this.prev[i]) { + if (!this.isStale(i)) { + yield i + } + if (i === this.head) { + break + } + } + } + } + *rindexes () { + if (this.size) { + for (let i = this.head; true; i = this.next[i]) { + if (!this.isStale(i)) { + yield i + } + if (i === this.tail) { + break + } + } + } + } + + *entries () { + for (const i of this.indexes()) { + yield [this.keyList[i], this.valList[i]] + } + } + + *keys () { + for (const i of this.indexes()) { + yield this.keyList[i] + } + } + + *values () { + for (const i of this.indexes()) { + yield this.valList[i] + } + } + + [Symbol.iterator] () { + return this.entries() + } + + find (fn, getOptions = {}) { + for (const i of this.indexes()) { + if (fn(this.valList[i], this.keyList[i], this)) { + return this.get(this.keyList[i], getOptions) + } + } + } + + forEach (fn, thisp = this) { + for (const i of this.indexes()) { + fn.call(thisp, this.valList[i], this.keyList[i], this) + } + } + + rforEach (fn, thisp = this) { + for (const i of this.rindexes()) { + fn.call(thisp, this.valList[i], this.keyList[i], this) + } + } + + get prune () { + deprecatedMethod('prune', 'Please use cache.purgeStale() instead.') + return this.purgeStale + } + + purgeStale () { + let deleted = false + if (this.size) { + for (let i = this.head; true; i = this.next[i]) { + const b = i === this.tail + if (this.isStale(i)) { + this.delete(this.keyList[i]) + deleted = true + } + if (b) { + break + } + } + } + return deleted + } + + dump () { + const arr = [] + for (const i of this.indexes()) { + const key = this.keyList[i] + const value = this.valList[i] + const entry = { value } + if (this.ttls) { + entry.ttl = this.ttls[i] + } + if (this.sizes) { + entry.size = this.sizes[i] + } + arr.unshift([key, entry]) + } + return arr + } + + load (arr) { + this.clear() + for (const [key, entry] of arr) { + this.set(key, entry.value, entry) + } + } + + dispose (v, k, reason) {} + + set (k, v, { + ttl = this.ttl, + noDisposeOnSet = this.noDisposeOnSet, + size = 0, + sizeCalculation = this.sizeCalculation, + } = {}) { + let index = this.size === 0 ? undefined : this.keyMap.get(k) + if (index === undefined) { + // addition + index = this.newIndex() + this.keyList[index] = k + this.valList[index] = v + this.keyMap.set(k, index) + this.next[this.tail] = index + this.prev[index] = this.tail + this.tail = index + this.size ++ + this.addItemSize(index, v, k, size, sizeCalculation) + } else { + // update + const oldVal = this.valList[index] + if (v !== oldVal) { + if (!noDisposeOnSet) { + this.dispose(oldVal, k, 'set') + if (this.disposeAfter) { + this.disposed.push([oldVal, k, 'set']) + } + } + this.removeItemSize(index) + this.valList[index] = v + this.addItemSize(index, v, k, size, sizeCalculation) + } + this.moveToTail(index) + } + if (ttl !== 0 && this.ttl === 0 && !this.ttls) { + this.initializeTTLTracking() + } + this.setItemTTL(index, ttl) + if (this.disposeAfter) { + while (this.disposed.length) { + this.disposeAfter(...this.disposed.shift()) + } + } + return this + } + + newIndex () { + if (this.size === 0) { + return this.tail + } + if (this.size === this.max) { + return this.evict() + } + if (this.free.length !== 0) { + return this.free.pop() + } + // initial fill, just keep writing down the list + return this.initialFill++ + } + + pop () { + if (this.size) { + const val = this.valList[this.head] + this.evict() + return val + } + } + + evict () { + const head = this.head + const k = this.keyList[head] + const v = this.valList[head] + this.dispose(v, k, 'evict') + if (this.disposeAfter) { + this.disposed.push([v, k, 'evict']) + } + this.removeItemSize(head) + this.head = this.next[head] + this.keyMap.delete(k) + this.size -- + return head + } + + has (k) { + return this.keyMap.has(k) && !this.isStale(this.keyMap.get(k)) + } + + // like get(), but without any LRU updating or TTL expiration + peek (k, { allowStale = this.allowStale } = {}) { + const index = this.keyMap.get(k) + if (index !== undefined && (allowStale || !this.isStale(index))) { + return this.valList[index] + } + } + + get (k, { + allowStale = this.allowStale, + updateAgeOnGet = this.updateAgeOnGet, + } = {}) { + const index = this.keyMap.get(k) + if (index !== undefined) { + if (this.isStale(index)) { + const value = allowStale ? this.valList[index] : undefined + this.delete(k) + return value + } else { + this.moveToTail(index) + if (updateAgeOnGet) { + this.updateItemAge(index) + } + return this.valList[index] + } + } + } + + connect (p, n) { + this.prev[n] = p + this.next[p] = n + } + + moveToTail (index) { + // if tail already, nothing to do + // if head, move head to next[index] + // else + // move next[prev[index]] to next[index] (head has no prev) + // move prev[next[index]] to prev[index] + // prev[index] = tail + // next[tail] = index + // tail = index + if (index !== this.tail) { + if (index === this.head) { + this.head = this.next[index] + } else { + this.connect(this.prev[index], this.next[index]) + } + this.connect(this.tail, index) + this.tail = index + } + } + + get del () { + deprecatedMethod('del', 'Please use cache.delete() instead.') + return this.delete + } + delete (k) { + let deleted = false + if (this.size !== 0) { + const index = this.keyMap.get(k) + if (index !== undefined) { + deleted = true + if (this.size === 1) { + this.clear() + } else { + this.removeItemSize(index) + this.dispose(this.valList[index], k, 'delete') + if (this.disposeAfter) { + this.disposed.push([this.valList[index], k, 'delete']) + } + this.keyMap.delete(k) + this.keyList[index] = null + this.valList[index] = null + if (index === this.tail) { + this.tail = this.prev[index] + } else if (index === this.head) { + this.head = this.next[index] + } else { + this.next[this.prev[index]] = this.next[index] + this.prev[this.next[index]] = this.prev[index] + } + this.size -- + this.free.push(index) + } + } + } + if (this.disposed) { + while (this.disposed.length) { + this.disposeAfter(...this.disposed.shift()) + } + } + return deleted + } + + clear () { + if (this.dispose !== LRUCache.prototype.dispose) { + for (const index of this.rindexes()) { + this.dispose(this.valList[index], this.keyList[index], 'delete') + } + } + if (this.disposeAfter) { + for (const index of this.rindexes()) { + this.disposed.push([this.valList[index], this.keyList[index], 'delete']) + } + } + this.keyMap.clear() + this.valList.fill(null) + this.keyList.fill(null) + if (this.ttls) { + this.ttls.fill(0) + this.starts.fill(0) + } + if (this.sizes) { + this.sizes.fill(0) + } + this.head = 0 + this.tail = 0 + this.initialFill = 1 + this.free.length = 0 + this.calculatedSize = 0 + this.size = 0 + if (this.disposed) { + while (this.disposed.length) { + this.disposeAfter(...this.disposed.shift()) + } + } + } + get reset () { + deprecatedMethod('reset', 'Please use cache.clear() instead.') + return this.clear + } + + get length () { + deprecatedProperty('length', 'Please use cache.size instead.') + return this.size + } +} + +module.exports = LRUCache diff --git a/node_modules/@npmcli/git/node_modules/lru-cache/package.json b/node_modules/@npmcli/git/node_modules/lru-cache/package.json new file mode 100644 index 0000000000000..66dbbd9c11503 --- /dev/null +++ b/node_modules/@npmcli/git/node_modules/lru-cache/package.json @@ -0,0 +1,34 @@ +{ + "name": "lru-cache", + "description": "A cache object that deletes the least-recently-used items.", + "version": "7.3.1", + "author": "Isaac Z. Schlueter ", + "keywords": [ + "mru", + "lru", + "cache" + ], + "scripts": { + "test": "tap", + "snap": "tap", + "preversion": "npm test", + "postversion": "npm publish", + "prepublishOnly": "git push origin --follow-tags" + }, + "main": "index.js", + "repository": "git://github.com/isaacs/node-lru-cache.git", + "devDependencies": { + "benchmark": "^2.1.4", + "tap": "^15.1.6" + }, + "license": "ISC", + "files": [ + "index.js" + ], + "engines": { + "node": ">=12" + }, + "tap": { + "coverage-map": "map.js" + } +} diff --git a/node_modules/@npmcli/git/package.json b/node_modules/@npmcli/git/package.json index 9475da5007a7d..02cd37fa225ad 100644 --- a/node_modules/@npmcli/git/package.json +++ b/node_modules/@npmcli/git/package.json @@ -1,44 +1,57 @@ { "name": "@npmcli/git", - "version": "2.1.0", + "version": "3.0.0", "main": "lib/index.js", "files": [ - "lib/*.js" + "bin", + "lib" ], "description": "a util for spawning git from npm CLI contexts", "repository": { "type": "git", "url": "git+https://github.com/npm/git" }, - "author": "Isaac Z. Schlueter (https://izs.me)", + "author": "GitHub Inc.", "license": "ISC", "scripts": { - "lint": "standard", + "lint": "eslint '**/*.js'", "lint:fix": "standard --fix", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", "preversion": "npm test", "snap": "tap", "test": "tap", - "posttest": "npm run lint" + "posttest": "npm run lint", + "postlint": "npm-template-check", + "template-copy": "npm-template-copy --force", + "lintfix": "npm run lint -- --fix" }, "tap": { "check-coverage": true, "coverage-map": "map.js" }, "devDependencies": { + "@npmcli/template-oss": "^2.7.1", "slash": "^3.0.0", "standard": "^16.0.3", - "tap": "^15.0.6" + "tap": "^15.1.6" }, "dependencies": { "@npmcli/promise-spawn": "^1.3.2", - "lru-cache": "^6.0.0", + "lru-cache": "^7.3.1", "mkdirp": "^1.0.4", - "npm-pick-manifest": "^6.1.1", + "npm-pick-manifest": "^7.0.0", + "proc-log": "^2.0.0", "promise-inflight": "^1.0.1", "promise-retry": "^2.0.1", "semver": "^7.3.5", "which": "^2.0.2" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" + }, + "templateOSS": { + "windowsCI": false, + "version": "2.7.1" } } diff --git a/node_modules/@npmcli/metavuln-calculator/lib/advisory.js b/node_modules/@npmcli/metavuln-calculator/lib/advisory.js index d0900e3732846..5b58ef6370724 100644 --- a/node_modules/@npmcli/metavuln-calculator/lib/advisory.js +++ b/node_modules/@npmcli/metavuln-calculator/lib/advisory.js @@ -22,8 +22,9 @@ class Advisory { this[_source] = source this[_options] = options this.name = name - if (!source.name) + if (!source.name) { source.name = name + } this.dependency = source.name @@ -70,11 +71,13 @@ class Advisory { // load up the data from a cache entry and a fetched packument load (cached, packument) { // basic data integrity gutcheck - if (!cached || typeof cached !== 'object') + if (!cached || typeof cached !== 'object') { throw new TypeError('invalid cached data, expected object') + } - if (!packument || typeof packument !== 'object') + if (!packument || typeof packument !== 'object') { throw new TypeError('invalid packument data, expected object') + } if (cached.id && cached.id !== this.id) { throw Object.assign(new Error('loading from incorrect cache entry'), { @@ -88,14 +91,16 @@ class Advisory { actual: packument.name, }) } - if (this[_packument]) + if (this[_packument]) { throw new Error('advisory object already loaded') + } // if we have a range from the initialization, and the cached // data has a *different* range, then we know we have to recalc. // just don't use the cached data, so we will definitely not match later - if (!this.range || cached.range && cached.range === this.range) + if (!this.range || cached.range && cached.range === this.range) { Object.assign(this, cached) + } this[_packument] = packument @@ -107,8 +112,9 @@ class Advisory { if (!this.versions.includes(v)) { versionsAdded.push(v) this.versions.push(v) - } else if (!pakuVersions.includes(v)) + } else if (!pakuVersions.includes(v)) { versionsRemoved.push(v) + } } // strip out any removed versions from our lists, and sort by semver @@ -138,14 +144,16 @@ class Advisory { this[_updated] = true // test any versions newly added - if (!unchanged || versionsAdded.length) + if (!unchanged || versionsAdded.length) { this[_testVersions](unchanged ? versionsAdded : this.versions) + } this.vulnerableVersions = semver.sort(this.vulnerableVersions, semverOpt) // metavulns have to calculate their range, since cache is invalidated // advisories just get their range from the advisory above - if (this.type === 'metavuln') + if (this.type === 'metavuln') { this[_calculateRange]() + } return this } @@ -170,10 +178,11 @@ class Advisory { } break } - if (vr.length > 1) + if (vr.length > 1) { vr[1] = this.versions[v] - else + } else { vr.push(this.versions[v]) + } v++ vulnVer++ } @@ -198,26 +207,30 @@ class Advisory { // we use the dependency version from the manifest. testVersion (version, spec = null) { const sv = String(version) - if (this[_versionVulnMemo].has(sv)) + if (this[_versionVulnMemo].has(sv)) { return this[_versionVulnMemo].get(sv) + } const result = this[_testVersion](version, spec) - if (result) + if (result) { this[_markVulnerable](version) + } this[_versionVulnMemo].set(sv, !!result) return result } [_markVulnerable] (version) { const sv = String(version) - if (!this.vulnerableVersions.includes(sv)) + if (!this.vulnerableVersions.includes(sv)) { this.vulnerableVersions.push(sv) + } } [_testVersion] (version, spec) { const sv = String(version) - if (this.vulnerableVersions.includes(sv)) + if (this.vulnerableVersions.includes(sv)) { return true + } if (this.type === 'advisory') { // advisory, just test range @@ -233,12 +246,14 @@ class Advisory { }, } - if (!spec) + if (!spec) { spec = getDepSpec(mani, this.dependency) + } // no dep, no vuln - if (spec === null) + if (spec === null) { return false + } if (!semver.validRange(spec, semverOpt)) { // not a semver range, nothing we can hope to do about it @@ -252,8 +267,9 @@ class Advisory { // try to pick a version of the dep that isn't vulnerable const avoid = this[_source].range - if (bundled) + if (bundled) { return semver.intersects(spec, avoid, semverOpt) + } return this[_source].testSpec(spec) } @@ -263,8 +279,9 @@ class Advisory { // consistent across multiple versions, so memoize this as well, in case // we're testing lots of versions. const memo = this[_specVulnMemo] - if (memo.has(spec)) + if (memo.has(spec)) { return memo.get(spec) + } const res = this[_testSpec](spec) memo.set(spec, res) @@ -274,10 +291,12 @@ class Advisory { [_testSpec] (spec) { for (const v of this.versions) { const satisfies = semver.satisfies(v, spec) - if (!satisfies) + if (!satisfies) { continue - if (!this.testVersion(v)) + } + if (!this.testVersion(v)) { return false + } } // either vulnerable, or not installable because nothing satisfied // either way, best avoided. @@ -285,8 +304,9 @@ class Advisory { } [_testVersions] (versions) { - if (!versions.length) + if (!versions.length) { return + } // set of lists of versions const versionSets = new Set() @@ -328,30 +348,34 @@ class Advisory { // version in the list, then start there instead. let h = 0 const origHeadVuln = this.testVersion(list[h]) - while (h < list.length && /-/.test(String(list[h]))) + while (h < list.length && /-/.test(String(list[h]))) { h++ + } // don't filter out the whole list! they might all be pr's - if (h === list.length) + if (h === list.length) { h = 0 - else if (origHeadVuln) { + } else if (origHeadVuln) { // if the original was vulnerable, assume so are all of these - for (let hh = 0; hh < h; hh++) + for (let hh = 0; hh < h; hh++) { this[_markVulnerable](list[hh]) + } } let t = list.length - 1 const origTailVuln = this.testVersion(list[t]) - while (t > h && /-/.test(String(list[t]))) + while (t > h && /-/.test(String(list[t]))) { t-- + } // don't filter out the whole list! might all be pr's - if (t === h) + if (t === h) { t = list.length - 1 - else if (origTailVuln) { + } else if (origTailVuln) { // if original tail was vulnerable, assume these are as well - for (let tt = list.length - 1; tt > t; tt--) + for (let tt = list.length - 1; tt > t; tt--) { this[_markVulnerable](list[tt]) + } } const headVuln = h === 0 ? origHeadVuln @@ -362,14 +386,16 @@ class Advisory { // if head and tail both vulnerable, whole list is thrown out if (headVuln && tailVuln) { - for (let v = h; v < t; v++) + for (let v = h; v < t; v++) { this[_markVulnerable](list[v]) + } continue } // if length is 2 or 1, then we marked them all already - if (t < h + 2) + if (t < h + 2) { continue + } const mid = Math.floor(list.length / 2) const pre = list.slice(0, mid) @@ -382,8 +408,9 @@ class Advisory { const midVuln = this.testVersion(pre[pre.length - 1]) while (/-/.test(String(pre[pre.length - 1]))) { const v = pre.pop() - if (midVuln) + if (midVuln) { this[_markVulnerable](v) + } } } @@ -391,8 +418,9 @@ class Advisory { const midVuln = this.testVersion(post[0]) while (/-/.test(String(post[0]))) { const v = post.shift() - if (midVuln) + if (midVuln) { this[_markVulnerable](v) + } } } diff --git a/node_modules/@npmcli/metavuln-calculator/lib/hash.js b/node_modules/@npmcli/metavuln-calculator/lib/hash.js index 79c0678c7581a..634bf99de0494 100644 --- a/node_modules/@npmcli/metavuln-calculator/lib/hash.js +++ b/node_modules/@npmcli/metavuln-calculator/lib/hash.js @@ -1,5 +1,5 @@ -const {createHash} = require('crypto') +const { createHash } = require('crypto') -module.exports = ({name, source}) => createHash('sha512') +module.exports = ({ name, source }) => createHash('sha512') .update(JSON.stringify([name, source])) .digest('base64') diff --git a/node_modules/@npmcli/metavuln-calculator/lib/index.js b/node_modules/@npmcli/metavuln-calculator/lib/index.js index 02c1ed018b8b5..668f55942c506 100644 --- a/node_modules/@npmcli/metavuln-calculator/lib/index.js +++ b/node_modules/@npmcli/metavuln-calculator/lib/index.js @@ -4,7 +4,7 @@ const pacote = require('pacote') const cacache = require('cacache') const Advisory = require('./advisory.js') -const {homedir} = require('os') +const { homedir } = require('os') const jsonParse = require('json-parse-even-better-errors') const _packument = Symbol('packument') @@ -37,8 +37,9 @@ class Calculator { async calculate (name, source) { const k = `security-advisory:${name}:${source.id}` - if (this[_advisories].has(k)) + if (this[_advisories].has(k)) { return this[_advisories].get(k) + } const p = this[_calculate](name, source) this[_advisories].set(k, p) @@ -58,8 +59,9 @@ class Calculator { process.emit('time', `metavuln:load:${k}`) advisory.load(cached, packument) process.emit('timeEnd', `metavuln:load:${k}`) - if (advisory.updated) + if (advisory.updated) { await this[_cachePut](advisory) + } this[_advisories].set(k, advisory) process.emit('timeEnd', t) return advisory @@ -81,8 +83,9 @@ class Calculator { const key = `security-advisory:${name}:${id}` /* istanbul ignore if - should be impossible, since we memoize the * advisory object itself using the same key, just being cautious */ - if (this[_cacheData].has(key)) + if (this[_cacheData].has(key)) { return this[_cacheData].get(key) + } process.emit('time', `metavuln:cache:get:${key}`) const p = cacache.get(this[_cache], key, { ...this[_options] }) @@ -98,8 +101,9 @@ class Calculator { } async [_packument] (name) { - if (this[_packuments].has(name)) + if (this[_packuments].has(name)) { return this[_packuments].get(name) + } process.emit('time', `metavuln:packument:${name}`) const p = pacote.packument(name, { ...this[_options] }) diff --git a/node_modules/@npmcli/metavuln-calculator/package.json b/node_modules/@npmcli/metavuln-calculator/package.json index 131cff672332d..385a34b85af27 100644 --- a/node_modules/@npmcli/metavuln-calculator/package.json +++ b/node_modules/@npmcli/metavuln-calculator/package.json @@ -1,13 +1,14 @@ { "name": "@npmcli/metavuln-calculator", - "version": "2.0.0", + "version": "3.0.0", "main": "lib/index.js", "files": [ + "bin", "lib" ], "description": "Calculate meta-vulnerabilities from package security advisories", "repository": "https://github.com/npm/metavuln-calculator", - "author": "Isaac Z. Schlueter (https://izs.me)", + "author": "GitHub Inc.", "license": "ISC", "scripts": { "test": "tap", @@ -18,29 +19,30 @@ "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags", "eslint": "eslint", - "lint": "npm run eslint -- \"lib/**/*.js\" \"test/**/*.js\"", - "lintfix": "npm run lint -- --fix" + "lint": "eslint '**/*.js'", + "lintfix": "npm run lint -- --fix", + "postlint": "npm-template-check", + "template-copy": "npm-template-copy --force" }, "tap": { "check-coverage": true, "coverage-map": "map.js" }, "devDependencies": { - "eslint": "^7.20.0", - "eslint-plugin-import": "^2.22.1", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.3.1", - "eslint-plugin-standard": "^4.1.0", + "@npmcli/template-oss": "^2.7.1", "require-inject": "^1.4.4", - "tap": "^14.10.8" + "tap": "^15.1.6" }, "dependencies": { - "cacache": "^15.0.5", + "cacache": "^15.3.0", "json-parse-even-better-errors": "^2.3.1", - "pacote": "^12.0.0", - "semver": "^7.3.2" + "pacote": "^13.0.1", + "semver": "^7.3.5" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" + }, + "templateOSS": { + "version": "2.7.1" } } diff --git a/node_modules/init-package-json/lib/init-package-json.js b/node_modules/init-package-json/lib/init-package-json.js index bee79351caab3..f13a34ce6ff4e 100644 --- a/node_modules/init-package-json/lib/init-package-json.js +++ b/node_modules/init-package-json/lib/init-package-json.js @@ -127,7 +127,7 @@ function init (dir, input, config, cb) { return write(true) } console.log('About to write to %s:\n\n%s\n', packageFile, d) - read({prompt: 'Is this OK? ', default: 'yes'}, function (er, ok) { + read({ prompt: 'Is this OK? ', default: 'yes' }, function (er, ok) { if (er) { return cb(er) } diff --git a/node_modules/init-package-json/package.json b/node_modules/init-package-json/package.json index 6d642f6cf6879..7649c503de815 100644 --- a/node_modules/init-package-json/package.json +++ b/node_modules/init-package-json/package.json @@ -1,6 +1,6 @@ { "name": "init-package-json", - "version": "2.0.5", + "version": "3.0.0", "main": "lib/init-package-json.js", "scripts": { "test": "tap", @@ -11,7 +11,8 @@ "postlint": "npm-template-check", "lintfix": "npm run lint -- --fix", "snap": "tap", - "posttest": "npm run lint" + "posttest": "npm run lint", + "template-copy": "npm-template-copy --force" }, "repository": { "type": "git", @@ -21,21 +22,21 @@ "license": "ISC", "description": "A node module to get your node module started", "dependencies": { - "npm-package-arg": "^8.1.5", + "npm-package-arg": "^9.0.0", "promzard": "^0.3.0", - "read": "~1.0.1", + "read": "^1.0.7", "read-package-json": "^4.1.1", "semver": "^7.3.5", "validate-npm-package-license": "^3.0.4", "validate-npm-package-name": "^3.0.0" }, "devDependencies": { - "@npmcli/config": "^2.1.0", - "@npmcli/template-oss": "^1.0.3", - "tap": "^15.0.9" + "@npmcli/config": "^4.0.0", + "@npmcli/template-oss": "^2.7.1", + "tap": "^15.1.6" }, "engines": { - "node": ">=10" + "node": "^12.13.0 || ^14.15.0 || >=16" }, "tap": { "statements": "94", @@ -56,5 +57,7 @@ "bin", "lib" ], - "templateVersion": "1.0.3" + "templateOSS": { + "version": "2.7.1" + } } diff --git a/node_modules/npm-package-arg/npa.js b/node_modules/npm-package-arg/lib/npa.js similarity index 86% rename from node_modules/npm-package-arg/npa.js rename to node_modules/npm-package-arg/lib/npa.js index 191befeb5e69d..cc1eddaec74b4 100644 --- a/node_modules/npm-package-arg/npa.js +++ b/node_modules/npm-package-arg/lib/npa.js @@ -20,30 +20,32 @@ function npa (arg, where) { let name let spec if (typeof arg === 'object') { - if (arg instanceof Result && (!where || where === arg.where)) + if (arg instanceof Result && (!where || where === arg.where)) { return arg - else if (arg.name && arg.rawSpec) + } else if (arg.name && arg.rawSpec) { return npa.resolve(arg.name, arg.rawSpec, where || arg.where) - else + } else { return npa(arg.raw, where || arg.where) + } } const nameEndsAt = arg[0] === '@' ? arg.slice(1).indexOf('@') + 1 : arg.indexOf('@') const namePart = nameEndsAt > 0 ? arg.slice(0, nameEndsAt) : arg - if (isURL.test(arg)) + if (isURL.test(arg)) { spec = arg - else if (isGit.test(arg)) + } else if (isGit.test(arg)) { spec = `git+ssh://${arg}` - else if (namePart[0] !== '@' && (hasSlashes.test(namePart) || isFilename.test(namePart))) + } else if (namePart[0] !== '@' && (hasSlashes.test(namePart) || isFilename.test(namePart))) { spec = arg - else if (nameEndsAt > 0) { + } else if (nameEndsAt > 0) { name = namePart spec = arg.slice(nameEndsAt + 1) } else { const valid = validatePackageName(arg) - if (valid.validForOldPackages) + if (valid.validForOldPackages) { name = arg - else + } else { spec = arg + } } return resolve(name, spec, where, arg) } @@ -58,35 +60,41 @@ function resolve (name, spec, where, arg) { fromArgument: arg != null, }) - if (name) + if (name) { res.setName(name) + } - if (spec && (isFilespec.test(spec) || /^file:/i.test(spec))) + if (spec && (isFilespec.test(spec) || /^file:/i.test(spec))) { return fromFile(res, where) - else if (spec && /^npm:/i.test(spec)) + } else if (spec && /^npm:/i.test(spec)) { return fromAlias(res, where) + } const hosted = HostedGit.fromUrl(spec, { noGitPlus: true, noCommittish: true, }) - if (hosted) + if (hosted) { return fromHostedGit(res, hosted) - else if (spec && isURL.test(spec)) + } else if (spec && isURL.test(spec)) { return fromURL(res) - else if (spec && (hasSlashes.test(spec) || isFilename.test(spec))) + } else if (spec && (hasSlashes.test(spec) || isFilename.test(spec))) { return fromFile(res, where) - else + } else { return fromRegistry(res) + } } -function invalidPackageName (name, valid) { - const err = new Error(`Invalid package name "${name}": ${valid.errors.join('; ')}`) +function invalidPackageName (name, valid, raw) { + // eslint-disable-next-line max-len + const err = new Error(`Invalid package name "${name}" of package "${raw}": ${valid.errors.join('; ')}.`) err.code = 'EINVALIDPACKAGENAME' return err } -function invalidTagName (name) { - const err = new Error(`Invalid tag name "${name}": Tags may not have any characters that encodeURIComponent encodes.`) + +function invalidTagName (name, raw) { + // eslint-disable-next-line max-len + const err = new Error(`Invalid tag name "${name}" of package "${raw}": Tags may not have any characters that encodeURIComponent encodes.`) err.code = 'EINVALIDTAGNAME' return err } @@ -95,10 +103,11 @@ function Result (opts) { this.type = opts.type this.registry = opts.registry this.where = opts.where - if (opts.raw == null) + if (opts.raw == null) { this.raw = opts.name ? opts.name + '@' + opts.rawSpec : opts.rawSpec - else + } else { this.raw = opts.raw + } this.name = undefined this.escapedName = undefined @@ -106,8 +115,9 @@ function Result (opts) { this.rawSpec = opts.rawSpec == null ? '' : opts.rawSpec this.saveSpec = opts.saveSpec this.fetchSpec = opts.fetchSpec - if (opts.name) + if (opts.name) { this.setName(opts.name) + } this.gitRange = opts.gitRange this.gitCommittish = opts.gitCommittish this.hosted = opts.hosted @@ -115,8 +125,9 @@ function Result (opts) { Result.prototype.setName = function (name) { const valid = validatePackageName(name) - if (!valid.validForOldPackages) - throw invalidPackageName(name, valid) + if (!valid.validForOldPackages) { + throw invalidPackageName(name, valid, this.raw) + } this.name = name this.scope = name[0] === '@' ? name.slice(0, name.indexOf('/')) : undefined @@ -127,11 +138,13 @@ Result.prototype.setName = function (name) { Result.prototype.toString = function () { const full = [] - if (this.name != null && this.name !== '') + if (this.name != null && this.name !== '') { full.push(this.name) + } const spec = this.saveSpec || this.fetchSpec || this.rawSpec - if (spec != null && spec !== '') + if (spec != null && spec !== '') { full.push(spec) + } return full.length ? full.join('@') : this.raw } @@ -145,21 +158,23 @@ function setGitCommittish (res, committish) { if (committish != null && committish.length >= 7 && committish.slice(0, 7) === 'semver:') { res.gitRange = decodeURIComponent(committish.slice(7)) res.gitCommittish = null - } else + } else { res.gitCommittish = committish === '' ? null : committish + } return res } function fromFile (res, where) { - if (!where) + if (!where) { where = process.cwd() + } res.type = isFilename.test(res.rawSpec) ? 'file' : 'directory' res.where = where // always put the '/' on where when resolving urls, or else // file:foo from /path/to/bar goes to /path/to/foo, when we want - // it to be /path/to/foo/bar + // it to be /path/to/bar/foo let specUrl let resolvedUrl @@ -225,10 +240,11 @@ function fromFile (res, where) { if (/^\/~(\/|$)/.test(specPath)) { res.saveSpec = `file:${specPath.substr(1)}` resolvedPath = path.resolve(homedir(), specPath.substr(3)) - } else if (!path.isAbsolute(rawNoPrefix)) + } else if (!path.isAbsolute(rawNoPrefix)) { res.saveSpec = `file:${path.relative(where, resolvedPath)}` - else + } else { res.saveSpec = `file:${path.resolve(resolvedPath)}` + } res.fetchSpec = path.resolve(where, resolvedPath) return res @@ -311,11 +327,13 @@ function fromURL (res) { function fromAlias (res, where) { const subSpec = npa(res.rawSpec.substr(4), where) - if (subSpec.type === 'alias') + if (subSpec.type === 'alias') { throw new Error('nested aliases not supported') + } - if (!subSpec.registry) + if (!subSpec.registry) { throw new Error('aliases only work for registry deps') + } res.subSpec = subSpec res.registry = true @@ -334,14 +352,14 @@ function fromRegistry (res) { res.fetchSpec = spec const version = semver.valid(spec, true) const range = semver.validRange(spec, true) - if (version) + if (version) { res.type = 'version' - else if (range) + } else if (range) { res.type = 'range' - else { - if (encodeURIComponent(spec) !== spec) - throw invalidTagName(spec) - + } else { + if (encodeURIComponent(spec) !== spec) { + throw invalidTagName(spec, res.raw) + } res.type = 'tag' } return res diff --git a/node_modules/npm-package-arg/package.json b/node_modules/npm-package-arg/package.json index bf5f597e6d8df..b0821312a7f0d 100644 --- a/node_modules/npm-package-arg/package.json +++ b/node_modules/npm-package-arg/package.json @@ -1,22 +1,23 @@ { "name": "npm-package-arg", - "version": "8.1.5", + "version": "9.0.0", "description": "Parse the things that can be arguments to `npm install`", - "main": "npa.js", + "main": "./lib/npa.js", "directories": { "test": "test" }, "files": [ - "npa.js" + "bin", + "lib" ], "dependencies": { - "hosted-git-info": "^4.0.1", - "semver": "^7.3.4", + "hosted-git-info": "^4.1.0", + "semver": "^7.3.5", "validate-npm-package-name": "^3.0.0" }, "devDependencies": { - "@npmcli/lint": "^1.0.1", - "tap": "^15.0.9" + "@npmcli/template-oss": "^2.7.1", + "tap": "^15.1.6" }, "scripts": { "preversion": "npm test", @@ -25,22 +26,30 @@ "test": "tap", "snap": "tap", "npmclilint": "npmcli-lint", - "lint": "npm run npmclilint -- \"*.*js\" \"test/**/*.*js\"", + "lint": "eslint '**/*.js'", "lintfix": "npm run lint -- --fix", - "posttest": "npm run lint --", - "postsnap": "npm run lintfix --" + "posttest": "npm run lint", + "postsnap": "npm run lintfix --", + "postlint": "npm-template-check", + "template-copy": "npm-template-copy --force" }, "repository": { "type": "git", "url": "https://github.com/npm/npm-package-arg" }, - "author": "Isaac Z. Schlueter (http://blog.izs.me/)", + "author": "GitHub Inc.", "license": "ISC", "bugs": { "url": "https://github.com/npm/npm-package-arg/issues" }, "homepage": "https://github.com/npm/npm-package-arg", "engines": { - "node": ">=10" + "node": "^12.13.0 || ^14.15.0 || >=16" + }, + "tap": { + "branches": 97 + }, + "templateOSS": { + "version": "2.7.1" } } diff --git a/node_modules/npm-pick-manifest/index.js b/node_modules/npm-pick-manifest/lib/index.js similarity index 96% rename from node_modules/npm-pick-manifest/index.js rename to node_modules/npm-pick-manifest/lib/index.js index 695450524dc13..f2934e9ca1822 100644 --- a/node_modules/npm-pick-manifest/index.js +++ b/node_modules/npm-pick-manifest/lib/index.js @@ -34,7 +34,7 @@ const pickManifest = (packument, wanted, opts) => { npmVersion = null, includeStaged = false, avoid = null, - avoidStrict = false + avoidStrict = false, } = opts const { name, time: verTimes } = packument @@ -43,7 +43,7 @@ const pickManifest = (packument, wanted, opts) => { if (avoidStrict) { const looseOpts = { ...opts, - avoidStrict: false + avoidStrict: false, } const result = pickManifest(packument, wanted, looseOpts) @@ -56,7 +56,7 @@ const pickManifest = (packument, wanted, opts) => { return { ...caret, _outsideDependencyRange: true, - _isSemVerMajor: false + _isSemVerMajor: false, } } @@ -65,7 +65,7 @@ const pickManifest = (packument, wanted, opts) => { return { ...star, _outsideDependencyRange: true, - _isSemVerMajor: true + _isSemVerMajor: true, } } @@ -75,7 +75,7 @@ const pickManifest = (packument, wanted, opts) => { wanted, avoid, before, - versions: Object.keys(versions) + versions: Object.keys(versions), }) } @@ -143,7 +143,7 @@ const pickManifest = (packument, wanted, opts) => { type, wanted, before, - versions: Object.keys(versions) + versions: Object.keys(versions), }) } @@ -213,6 +213,6 @@ module.exports = (packument, wanted, opts = {}) => { versions: Object.keys(packument.versions), name, distTags: packument['dist-tags'], - defaultTag + defaultTag, }) } diff --git a/node_modules/npm-pick-manifest/package.json b/node_modules/npm-pick-manifest/package.json index 4b4866cbf8832..ece1d174dbc0c 100644 --- a/node_modules/npm-pick-manifest/package.json +++ b/node_modules/npm-pick-manifest/package.json @@ -1,19 +1,24 @@ { "name": "npm-pick-manifest", - "version": "6.1.1", + "version": "7.0.0", "description": "Resolves a matching manifest from a package metadata document according to standard npm semver resolution rules.", - "main": "index.js", + "main": "./lib", "files": [ - "*.js" + "bin", + "lib" ], "scripts": { "coverage": "tap", - "lint": "standard", + "lint": "eslint '**/*.js'", "test": "tap", "posttest": "npm run lint", "preversion": "npm test", "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags" + "prepublishOnly": "git push origin --follow-tags", + "postlint": "npm-template-check", + "template-copy": "npm-template-copy --force", + "lintfix": "npm run lint -- --fix", + "snap": "tap" }, "repository": "https://github.com/npm/npm-pick-manifest", "keywords": [ @@ -21,23 +26,25 @@ "semver", "package manager" ], - "author": { - "name": "Kat Marchán", - "email": "kzm@sykosomatic.org", - "twitter": "maybekatz" - }, + "author": "GitHub Inc.", "license": "ISC", "dependencies": { "npm-install-checks": "^4.0.0", "npm-normalize-package-bin": "^1.0.1", - "npm-package-arg": "^8.1.2", - "semver": "^7.3.4" + "npm-package-arg": "^9.0.0", + "semver": "^7.3.5" }, "devDependencies": { - "standard": "^14.3.1", - "tap": "^14.11.0" + "@npmcli/template-oss": "^2.7.1", + "tap": "^15.1.6" }, "tap": { "check-coverage": true + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" + }, + "templateOSS": { + "version": "2.7.1" } } diff --git a/node_modules/npm-profile/lib/index.js b/node_modules/npm-profile/lib/index.js index aa322e37f4824..74a8084292a6c 100644 --- a/node_modules/npm-profile/lib/index.js +++ b/node_modules/npm-profile/lib/index.js @@ -4,13 +4,14 @@ const fetch = require('npm-registry-fetch') const { HttpErrorBase } = require('npm-registry-fetch/lib/errors') const os = require('os') const { URL } = require('url') +const log = require('proc-log') // try loginWeb, catch the "not supported" message and fall back to couch const login = (opener, prompter, opts = {}) => { const { creds } = opts return loginWeb(opener, opts).catch(er => { if (er instanceof WebLoginNotSupported) { - process.emit('log', 'verbose', 'web login not supported, trying couch') + log.verbose('web login not supported, trying couch') return prompter(creds) .then(data => loginCouch(data.username, data.password, opts)) } else { @@ -23,7 +24,7 @@ const adduser = (opener, prompter, opts = {}) => { const { creds } = opts return adduserWeb(opener, opts).catch(er => { if (er instanceof WebLoginNotSupported) { - process.emit('log', 'verbose', 'web adduser not supported, trying couch') + log.verbose('web adduser not supported, trying couch') return prompter(creds) .then(data => adduserCouch(data.username, data.email, data.password, opts)) } else { @@ -33,12 +34,12 @@ const adduser = (opener, prompter, opts = {}) => { } const adduserWeb = (opener, opts = {}) => { - process.emit('log', 'verbose', 'web adduser', 'before first POST') + log.verbose('web adduser', 'before first POST') return webAuth(opener, opts, { create: true }) } const loginWeb = (opener, opts = {}) => { - process.emit('log', 'verbose', 'web login', 'before first POST') + log.verbose('web login', 'before first POST') return webAuth(opener, opts, {}) } @@ -62,13 +63,13 @@ const webAuth = (opener, opts, body) => { return Promise.all([res, res.json()]) }).then(([res, content]) => { const { doneUrl, loginUrl } = content - process.emit('log', 'verbose', 'web auth', 'got response', content) + log.verbose('web auth', 'got response', content) if (!isValidUrl(doneUrl) || !isValidUrl(loginUrl)) { throw new WebLoginInvalidResponse('POST', res, content) } return content }).then(({ doneUrl, loginUrl }) => { - process.emit('log', 'verbose', 'web auth', 'opening url pair') + log.verbose('web auth', 'opening url pair') return opener(loginUrl).then( () => webAuthCheckLogin(doneUrl, { ...opts, cache: false }) ) @@ -121,7 +122,7 @@ const adduserCouch = (username, email, password, opts = {}) => { ...body, password: 'XXXXX', } - process.emit('log', 'verbose', 'adduser', 'before first PUT', logObj) + log.verbose('adduser', 'before first PUT', logObj) const target = '/-/user/org.couchdb.user:' + encodeURIComponent(username) return fetch.json(target, { @@ -147,9 +148,9 @@ const loginCouch = (username, password, opts = {}) => { ...body, password: 'XXXXX', } - process.emit('log', 'verbose', 'login', 'before first PUT', logObj) + log.verbose('login', 'before first PUT', logObj) - const target = '-/user/org.couchdb.user:' + encodeURIComponent(username) + const target = '/-/user/org.couchdb.user:' + encodeURIComponent(username) return fetch.json(target, { ...opts, method: 'PUT', diff --git a/node_modules/npm-profile/package.json b/node_modules/npm-profile/package.json index 8745c2559f33f..68b04bba6d900 100644 --- a/node_modules/npm-profile/package.json +++ b/node_modules/npm-profile/package.json @@ -1,12 +1,13 @@ { "name": "npm-profile", - "version": "6.0.0", + "version": "6.0.2", "description": "Library for updating an npmjs.com profile", "keywords": [], "author": "GitHub Inc.", "license": "ISC", "dependencies": { - "npm-registry-fetch": "^12.0.0" + "npm-registry-fetch": "^13.0.0", + "proc-log": "^2.0.0" }, "main": "./lib/index.js", "repository": { @@ -18,9 +19,9 @@ "lib" ], "devDependencies": { - "@npmcli/template-oss": "^2.5.1", - "nock": "^13.2.1", - "tap": "^15.1.5" + "@npmcli/template-oss": "^2.7.1", + "nock": "^13.2.4", + "tap": "^15.1.6" }, "scripts": { "preversion": "npm test", @@ -31,7 +32,8 @@ "snap": "tap", "lint": "eslint '**/*.js'", "postlint": "npm-template-check", - "lintfix": "npm run lint -- --fix" + "lintfix": "npm run lint -- --fix", + "template-copy": "npm-template-copy --force" }, "tap": { "check-coverage": true @@ -40,6 +42,6 @@ "node": "^12.13.0 || ^14.15.0 || >=16" }, "templateOSS": { - "version": "2.5.1" + "version": "2.7.1" } } diff --git a/node_modules/npm-registry-fetch/lib/check-response.js b/node_modules/npm-registry-fetch/lib/check-response.js index 26043a96de854..872ec8a888694 100644 --- a/node_modules/npm-registry-fetch/lib/check-response.js +++ b/node_modules/npm-registry-fetch/lib/check-response.js @@ -3,23 +3,24 @@ const errors = require('./errors.js') const { Response } = require('minipass-fetch') const defaultOpts = require('./default-opts.js') +const log = require('proc-log') /* eslint-disable-next-line max-len */ const moreInfoUrl = 'https://github.com/npm/cli/wiki/No-auth-for-URI,-but-auth-present-for-scoped-registry' const checkResponse = - async ({ method, uri, res, registry, startTime, auth, opts }) => { + async ({ method, uri, res, startTime, auth, opts }) => { opts = { ...defaultOpts, ...opts } if (res.headers.has('npm-notice') && !res.headers.has('x-local-cache')) { - opts.log.notice('', res.headers.get('npm-notice')) + log.notice('', res.headers.get('npm-notice')) } if (res.status >= 400) { - logRequest(method, res, startTime, opts) + logRequest(method, res, startTime) if (auth && auth.scopeAuthKey && !auth.token && !auth.auth) { // we didn't have auth for THIS request, but we do have auth for // requests to the registry indicated by the spec's scope value. // Warn the user. - opts.log.warn('registry', `No auth for URI, but auth present for scoped registry. + log.warn('registry', `No auth for URI, but auth present for scoped registry. URI: ${uri} Scoped Registry Key: ${auth.scopeAuthKey} @@ -38,7 +39,7 @@ More info here: ${moreInfoUrl}`) } module.exports = checkResponse -function logRequest (method, res, startTime, opts) { +function logRequest (method, res, startTime) { const elapsedTime = Date.now() - startTime const attempt = res.headers.get('x-fetch-attempts') const attemptStr = attempt && attempt > 1 ? ` attempt #${attempt}` : '' @@ -58,7 +59,7 @@ function logRequest (method, res, startTime, opts) { urlStr = res.url } - opts.log.http( + log.http( 'fetch', `${method.toUpperCase()} ${res.status} ${urlStr} ${elapsedTime}ms${attemptStr}${cacheStr}` ) diff --git a/node_modules/npm-registry-fetch/lib/default-opts.js b/node_modules/npm-registry-fetch/lib/default-opts.js index e8e8221da4a58..f0847f0b507e2 100644 --- a/node_modules/npm-registry-fetch/lib/default-opts.js +++ b/node_modules/npm-registry-fetch/lib/default-opts.js @@ -1,6 +1,5 @@ const pkg = require('../package.json') module.exports = { - log: require('./silentlog.js'), maxSockets: 12, method: 'GET', registry: 'https://registry.npmjs.org/', diff --git a/node_modules/npm-registry-fetch/package.json b/node_modules/npm-registry-fetch/package.json index f1aab5c7bb4a8..9349619e99e61 100644 --- a/node_modules/npm-registry-fetch/package.json +++ b/node_modules/npm-registry-fetch/package.json @@ -1,6 +1,6 @@ { "name": "npm-registry-fetch", - "version": "12.0.2", + "version": "13.0.0", "description": "Fetch-based http client for use with npm registry APIs", "main": "lib", "files": [ @@ -31,18 +31,18 @@ "author": "GitHub Inc.", "license": "ISC", "dependencies": { - "make-fetch-happen": "^10.0.1", + "make-fetch-happen": "^10.0.2", "minipass": "^3.1.6", "minipass-fetch": "^1.4.1", "minipass-json-stream": "^1.0.1", "minizlib": "^2.1.2", - "npm-package-arg": "^8.1.5" + "npm-package-arg": "^9.0.0", + "proc-log": "^2.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.7.1", "cacache": "^15.3.0", "nock": "^13.2.4", - "npmlog": "^6.0.0", "require-inject": "^1.4.4", "ssri": "^8.0.1", "tap": "^15.1.6" diff --git a/node_modules/pacote/lib/bin.js b/node_modules/pacote/lib/bin.js index c0409be1ff085..369304adaa879 100755 --- a/node_modules/pacote/lib/bin.js +++ b/node_modules/pacote/lib/bin.js @@ -4,26 +4,28 @@ const run = conf => { const pacote = require('../') switch (conf._[0]) { case 'resolve': - if (conf.long) + case 'manifest': + case 'packument': + if (conf._[0] === 'resolve' && conf.long) { return pacote.manifest(conf._[1], conf).then(mani => ({ resolved: mani._resolved, integrity: mani._integrity, from: mani._from, })) - case 'manifest': - case 'packument': + } return pacote[conf._[0]](conf._[1], conf) case 'tarball': if (!conf._[2] || conf._[2] === '-') { return pacote.tarball.stream(conf._[1], stream => { stream.pipe(conf.testStdout || - /* istanbul ignore next */ process.stdout) + /* istanbul ignore next */ process.stdout) // make sure it resolves something falsey return stream.promise().then(() => {}) }, conf) - } else + } else { return pacote.tarball.file(conf._[1], conf._[2], conf) + } case 'extract': return pacote.extract(conf._[1], conf._[2], conf) @@ -81,8 +83,9 @@ const pretty = (conf, result) => let addedLogListener = false const main = args => { const conf = parse(args) - if (conf.help || conf.h) + if (conf.help || conf.h) { return console.log(usage()) + } if (!addedLogListener) { process.on('log', console.error) @@ -121,14 +124,14 @@ const parse = args => { } let dashdash = false args.forEach(arg => { - if (dashdash) + if (dashdash) { conf._.push(arg) - else if (arg === '--') + } else if (arg === '--') { dashdash = true - else if (arg === '-h') + } else if (arg === '-h') { conf.help = true - else if (/^--/.test(arg)) { - const {key, value} = parseArg(arg) + } else if (/^--/.test(arg)) { + const { key, value } = parseArg(arg) conf[key] = value } else { conf._.push(arg) @@ -137,9 +140,9 @@ const parse = args => { return conf } -if (module === require.main) +if (module === require.main) { main(process.argv.slice(2)) -else +} else { module.exports = { main, run, @@ -147,3 +150,4 @@ else parseArg, parse, } +} diff --git a/node_modules/pacote/lib/dir.js b/node_modules/pacote/lib/dir.js index 0d3a00d95ae7c..598b029f7ad48 100644 --- a/node_modules/pacote/lib/dir.js +++ b/node_modules/pacote/lib/dir.js @@ -1,14 +1,12 @@ const Fetcher = require('./fetcher.js') const FileFetcher = require('./file.js') -const cacache = require('cacache') const Minipass = require('minipass') -const { promisify } = require('util') -const readPackageJson = require('read-package-json-fast') const tarCreateOptions = require('./util/tar-create-options.js') const packlist = require('npm-packlist') const tar = require('tar') const _prepareDir = Symbol('_prepareDir') const { resolve } = require('path') +const _readPackageJson = Symbol.for('package.Fetcher._readPackageJson') const runScript = require('@npmcli/run-script') @@ -31,18 +29,18 @@ class DirFetcher extends Fetcher { [_prepareDir] () { return this.manifest().then(mani => { - if (!mani.scripts || !mani.scripts.prepare) + if (!mani.scripts || !mani.scripts.prepare) { return + } // we *only* run prepare. // pre/post-pack is run by the npm CLI for publish and pack, // but this function is *also* run when installing git deps const stdio = this.opts.foregroundScripts ? 'inherit' : 'pipe' - // hide the banner if loglevel is silent, or if prepare running + // hide the banner if silent opt is passed in, or if prepare running // in the background. - const banner = this.opts.log && this.opts.log.level === 'silent' ? false - : stdio === 'inherit' + const banner = this.opts.silent ? false : stdio === 'inherit' return runScript({ pkg: mani, @@ -76,10 +74,11 @@ class DirFetcher extends Fetcher { } manifest () { - if (this.package) + if (this.package) { return Promise.resolve(this.package) + } - return readPackageJson(this.resolved + '/package.json') + return this[_readPackageJson](this.resolved + '/package.json') .then(mani => this.package = { ...mani, _integrity: this.integrity && String(this.integrity), diff --git a/node_modules/pacote/lib/fetcher.js b/node_modules/pacote/lib/fetcher.js index 69dd025b7bd98..78b13a9637c4f 100644 --- a/node_modules/pacote/lib/fetcher.js +++ b/node_modules/pacote/lib/fetcher.js @@ -9,12 +9,15 @@ const { promisify } = require('util') const { basename, dirname } = require('path') const rimraf = promisify(require('rimraf')) const tar = require('tar') -const procLog = require('./util/proc-log.js') +const log = require('proc-log') const retry = require('promise-retry') const fsm = require('fs-minipass') const cacache = require('cacache') const isPackageBin = require('./util/is-package-bin.js') +const removeTrailingSlashes = require('./util/trailing-slashes.js') const getContents = require('@npmcli/installed-package-contents') +const readPackageJsonFast = require('read-package-json-fast') +const readPackageJson = promisify(require('read-package-json')) // we only change ownership on unix platforms, and only if uid is 0 const selfOwner = process.getuid && process.getuid() === 0 ? { @@ -41,11 +44,13 @@ const _assertType = Symbol('_assertType') const _tarballFromCache = Symbol('_tarballFromCache') const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved') const _cacheFetches = Symbol.for('pacote.Fetcher._cacheFetches') +const _readPackageJson = Symbol.for('package.Fetcher._readPackageJson') class FetcherBase { constructor (spec, opts) { - if (!opts || typeof opts !== 'object') + if (!opts || typeof opts !== 'object') { throw new TypeError('options object is required') + } this.spec = npa(spec, opts.where) this.allowGitIgnore = !!opts.allowGitIgnore @@ -62,7 +67,7 @@ class FetcherBase { this[_assertType]() // clone the opts object so that others aren't upset when we mutate it // by adding/modifying the integrity value. - this.opts = {...opts} + this.opts = { ...opts } this.cache = opts.cache || cacheDir() this.resolved = opts.resolved || null @@ -72,8 +77,9 @@ class FetcherBase { // is no longer strong enough. this.defaultIntegrityAlgorithm = opts.defaultIntegrityAlgorithm || 'sha512' - if (typeof opts.integrity === 'string') + if (typeof opts.integrity === 'string') { this.opts.integrity = ssri.parse(opts.integrity) + } this.package = null this.type = this.constructor.name @@ -85,7 +91,6 @@ class FetcherBase { // the process's umask setting do its job. but if configured, we do // respect it. this.umask = opts.umask || 0 - this.log = opts.log || procLog this.preferOnline = !!opts.preferOnline this.preferOffline = !!opts.preferOffline @@ -93,10 +98,15 @@ class FetcherBase { this.before = opts.before this.fullMetadata = this.before ? true : !!opts.fullMetadata + this.fullReadJson = !!opts.fullReadJson + if (this.fullReadJson) { + this[_readPackageJson] = readPackageJson + } else { + this[_readPackageJson] = readPackageJsonFast + } this.defaultTag = opts.defaultTag || 'latest' - this.registry = (opts.registry || 'https://registry.npmjs.org') - .replace(/\/+$/, '') + this.registry = removeTrailingSlashes(opts.registry || 'https://registry.npmjs.org') // command to run 'prepare' scripts on directories and git dirs // To use pacote with yarn, for example, set npmBin to 'yarn' @@ -104,7 +114,7 @@ class FetcherBase { this.npmBin = opts.npmBin || 'npm' // command to install deps for preparing - this.npmInstallCmd = opts.npmInstallCmd || [ 'install', '--force' ] + this.npmInstallCmd = opts.npmInstallCmd || ['install', '--force'] // XXX fill more of this in based on what we know from this.opts // we explicitly DO NOT fill in --tag, though, since we are often @@ -132,19 +142,22 @@ class FetcherBase { get integrity () { return this.opts.integrity || null } + set integrity (i) { - if (!i) + if (!i) { return + } i = ssri.parse(i) const current = this.opts.integrity // do not ever update an existing hash value, but do // merge in NEW algos and hashes that we don't already have. - if (current) + if (current) { current.merge(i) - else + } else { this.opts.integrity = i + } } get notImplementedError () { @@ -212,8 +225,9 @@ class FetcherBase { stream.on('error', er => istream.emit('error', er)) // if not caching this, just pipe through to the istream and return it - if (!this.opts.cache || !this[_cacheFetches]) + if (!this.opts.cache || !this[_cacheFetches]) { return stream.pipe(istream) + } // we have to return a stream that gets ALL the data, and proxies errors, // but then pipe from the original tarball stream into the cache as well. @@ -288,39 +302,42 @@ class FetcherBase { this.integrity && this.resolved ) ? streamHandler(this[_tarballFromCache]()).catch(er => { - if (this.isDataCorruptionError(er)) { - this.log.warn('tarball', `cached data for ${ + if (this.isDataCorruptionError(er)) { + log.warn('tarball', `cached data for ${ this.spec } (${this.integrity}) seems to be corrupted. Refreshing cache.`) - return this.cleanupCached().then(() => { throw er }) - } else { - throw er - } - }) : null + return this.cleanupCached().then(() => { + throw er + }) + } else { + throw er + } + }) : null const fromResolved = er => { if (er) { - if (!this.isRetriableError(er)) + if (!this.isRetriableError(er)) { throw er - this.log.silly('tarball', `no local data for ${ + } + log.silly('tarball', `no local data for ${ this.spec }. Extracting by manifest.`) } return this.resolve().then(() => retry(tryAgain => streamHandler(this[_istream](this[_tarballFromResolved]())) - .catch(er => { + .catch(er => { // Most likely data integrity. A cache ENOENT error is unlikely // here, since we're definitely not reading from the cache, but it // IS possible that the fetch subsystem accessed the cache, and the // entry got blown away or something. Try one more time to be sure. - if (this.isRetriableError(er)) { - this.log.warn('tarball', `tarball data for ${ + if (this.isRetriableError(er)) { + log.warn('tarball', `tarball data for ${ this.spec } (${this.integrity}) seems to be corrupted. Trying again.`) - return this.cleanupCached().then(() => tryAgain(er)) - } - throw er - }), { retries: 1, minTimeout: 0, maxTimeout: 0 })) + return this.cleanupCached().then(() => tryAgain(er)) + } + throw er + }), { retries: 1, minTimeout: 0, maxTimeout: 0 })) } return fromCache ? fromCache.catch(fromResolved) : fromResolved() @@ -337,7 +354,7 @@ class FetcherBase { } [_empty] (path) { - return getContents({path, depth: 1}).then(contents => Promise.all( + return getContents({ path, depth: 1 }).then(contents => Promise.all( contents.map(entry => rimraf(entry)))) } @@ -350,7 +367,7 @@ class FetcherBase { // parent folder (rare, but probably happens sometimes). return !inferOwner ? this[_empty](dest).then(() => mkdirp(dest)).then(() => ({})) - : inferOwner(dest).then(({uid, gid}) => + : inferOwner(dest).then(({ uid, gid }) => this[_empty](dest) .then(() => mkdirp(dest)) .then(made => { @@ -360,13 +377,13 @@ class FetcherBase { const dir = made || /* istanbul ignore next */ dest return this[_chown](dir, uid, gid) }) - .then(() => ({uid, gid}))) + .then(() => ({ uid, gid }))) } // extraction is always the same. the only difference is where // the tarball comes from. extract (dest) { - return this[_mkdir](dest).then(({uid, gid}) => + return this[_mkdir](dest).then(({ uid, gid }) => this.tarballStream(tarball => this[_extract](dest, tarball, uid, gid))) } @@ -389,7 +406,7 @@ class FetcherBase { const dir = dirname(dest) return !inferOwner ? mkdirp(dir).then(() => this[_toFile](dest)) - : inferOwner(dest).then(({uid, gid}) => + : inferOwner(dest).then(({ uid, gid }) => mkdirp(dir).then(made => this[_toFile](dest) .then(res => this[_chown](made || dir, uid, gid) .then(() => res)))) @@ -407,8 +424,8 @@ class FetcherBase { }) extractor.on('error', er => { - this.log.warn('tar', er.message) - this.log.silly('tar', er) + log.warn('tar', er.message) + log.silly('tar', er) reject(er) }) @@ -439,21 +456,23 @@ class FetcherBase { noChmod: true, noMtime: true, filter: (name, entry) => { - if (/Link$/.test(entry.type)) + if (/Link$/.test(entry.type)) { return false + } entry.mode = this[_entryMode](entry.path, entry.mode, entry.type) // this replicates the npm pack behavior where .gitignore files // are treated like .npmignore files, but only if a .npmignore // file is not present. if (/File$/.test(entry.type)) { const base = basename(entry.path) - if (base === '.npmignore') + if (base === '.npmignore') { sawIgnores.add(entry.path) - else if (base === '.gitignore' && !this.allowGitIgnore) { + } else if (base === '.gitignore' && !this.allowGitIgnore) { // rename, but only if there's not already a .npmignore const ni = entry.path.replace(/\.gitignore$/, '.npmignore') - if (sawIgnores.has(ni)) + if (sawIgnores.has(ni)) { return false + } entry.path = ni } return true @@ -462,8 +481,8 @@ class FetcherBase { strip: 1, onwarn: /* istanbul ignore next - we can trust that tar logs */ (code, msg, data) => { - this.log.warn('tar', code, msg) - this.log.silly('tar', code, msg, data) + log.warn('tar', code, msg) + log.silly('tar', code, msg, data) }, uid, gid, diff --git a/node_modules/pacote/lib/file.js b/node_modules/pacote/lib/file.js index d5c601aabd873..bf99bb86e359e 100644 --- a/node_modules/pacote/lib/file.js +++ b/node_modules/pacote/lib/file.js @@ -1,12 +1,11 @@ const Fetcher = require('./fetcher.js') const fsm = require('fs-minipass') const cacache = require('cacache') -const { promisify } = require('util') -const readPackageJson = require('read-package-json-fast') const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved') const _exeBins = Symbol('_exeBins') const { resolve } = require('path') const fs = require('fs') +const _readPackageJson = Symbol.for('package.Fetcher._readPackageJson') class FileFetcher extends Fetcher { constructor (spec, opts) { @@ -20,24 +19,26 @@ class FileFetcher extends Fetcher { } manifest () { - if (this.package) + if (this.package) { return Promise.resolve(this.package) + } // have to unpack the tarball for this. return cacache.tmp.withTmp(this.cache, this.opts, dir => this.extract(dir) - .then(() => readPackageJson(dir + '/package.json')) - .then(mani => this.package = { - ...mani, - _integrity: this.integrity && String(this.integrity), - _resolved: this.resolved, - _from: this.from, - })) + .then(() => this[_readPackageJson](dir + '/package.json')) + .then(mani => this.package = { + ...mani, + _integrity: this.integrity && String(this.integrity), + _resolved: this.resolved, + _from: this.from, + })) } [_exeBins] (pkg, dest) { - if (!pkg.bin) + if (!pkg.bin) { return Promise.resolve() + } return Promise.all(Object.keys(pkg.bin).map(k => new Promise(res => { const script = resolve(dest, pkg.bin[k]) @@ -46,11 +47,13 @@ class FileFetcher extends Fetcher { // something, we just leave it for a later stage to trip over // when we can provide a more useful contextual error. fs.stat(script, (er, st) => { - if (er) + if (er) { return res() + } const mode = st.mode | 0o111 - if (mode === st.mode) + if (mode === st.mode) { return res() + } fs.chmod(script, mode, res) }) }))) @@ -61,8 +64,8 @@ class FileFetcher extends Fetcher { // but if not, read the unpacked manifest and chmod properly. return super.extract(dest) .then(result => this.package ? result - : readPackageJson(dest + '/package.json').then(pkg => - this[_exeBins](pkg, dest)).then(() => result)) + : this[_readPackageJson](dest + '/package.json').then(pkg => + this[_exeBins](pkg, dest)).then(() => result)) } [_tarballFromResolved] () { @@ -75,7 +78,7 @@ class FileFetcher extends Fetcher { return this.manifest().then(mani => ({ name: mani.name, 'dist-tags': { - [this.defaultTag]: mani.version + [this.defaultTag]: mani.version, }, versions: { [mani.version]: { @@ -83,9 +86,9 @@ class FileFetcher extends Fetcher { dist: { tarball: `file:${this.resolved}`, integrity: this.integrity && String(this.integrity), - } - } - } + }, + }, + }, })) } } diff --git a/node_modules/pacote/lib/git.js b/node_modules/pacote/lib/git.js index ab87d494ce4ba..cab389ff179c2 100644 --- a/node_modules/pacote/lib/git.js +++ b/node_modules/pacote/lib/git.js @@ -6,11 +6,9 @@ const hashre = /^[a-f0-9]{40}$/ const git = require('@npmcli/git') const pickManifest = require('npm-pick-manifest') const npa = require('npm-package-arg') -const url = require('url') const Minipass = require('minipass') const cacache = require('cacache') -const { promisify } = require('util') -const readPackageJson = require('read-package-json-fast') +const log = require('proc-log') const npm = require('./util/npm.js') const _resolvedFromRepo = Symbol('_resolvedFromRepo') @@ -24,6 +22,7 @@ const _cloneHosted = Symbol('_cloneHosted') const _cloneRepo = Symbol('_cloneRepo') const _setResolvedWithSha = Symbol('_setResolvedWithSha') const _prepareDir = Symbol('_prepareDir') +const _readPackageJson = Symbol.for('package.Fetcher._readPackageJson') // get the repository url. // prefer https if there's auth, since ssh will drop that. @@ -40,8 +39,9 @@ class GitFetcher extends Fetcher { constructor (spec, opts) { super(spec, opts) this.resolvedRef = null - if (this.spec.hosted) + if (this.spec.hosted) { this.from = this.spec.hosted.shortcut({ noCommittish: false }) + } // shortcut: avoid full clone when we can go straight to the tgz // if we have the full sha and it's a hosted git platform @@ -51,8 +51,9 @@ class GitFetcher extends Fetcher { this.resolved = this.spec.hosted ? repoUrl(this.spec.hosted, { noCommittish: false }) : this.spec.rawSpec - } else + } else { this.resolvedSha = '' + } } // just exposed to make it easier to test all the combinations @@ -67,8 +68,9 @@ class GitFetcher extends Fetcher { resolve () { // likely a hosted git repo with a sha, so get the tarball url // but in general, no reason to resolve() more than necessary! - if (this.resolved) + if (this.resolved) { return super.resolve() + } // fetch the git repo and then look at the current hash const h = this.spec.hosted @@ -86,37 +88,41 @@ class GitFetcher extends Fetcher { return this[_resolvedFromRepo](hosted.https && hosted.https()) .catch(er => { // Throw early since we know pathspec errors will fail again if retried - if (er instanceof git.errors.GitPathspecError) + if (er instanceof git.errors.GitPathspecError) { throw er + } const ssh = hosted.sshurl && hosted.sshurl() // no fallthrough if we can't fall through or have https auth - if (!ssh || hosted.auth) + if (!ssh || hosted.auth) { throw er + } return this[_resolvedFromRepo](ssh) }) } [_resolvedFromRepo] (gitRemote) { // XXX make this a custom error class - if (!gitRemote) + if (!gitRemote) { return Promise.reject(new Error(`No git url for ${this.spec}`)) + } const gitRange = this.spec.gitRange const name = this.spec.name return git.revs(gitRemote, this.opts).then(remoteRefs => { return gitRange ? pickManifest({ - versions: remoteRefs.versions, - 'dist-tags': remoteRefs['dist-tags'], - name, - }, gitRange, this.opts) + versions: remoteRefs.versions, + 'dist-tags': remoteRefs['dist-tags'], + name, + }, gitRange, this.opts) : this.spec.gitCommittish ? remoteRefs.refs[this.spec.gitCommittish] || remoteRefs.refs[remoteRefs.shas[this.spec.gitCommittish]] - : remoteRefs.refs.HEAD // no git committish, get default head + : remoteRefs.refs.HEAD // no git committish, get default head }).then(revDoc => { // the committish provided isn't in the rev list // things like HEAD~3 or @yesterday can land here. - if (!revDoc || !revDoc.sha) + if (!revDoc || !revDoc.sha) { return this[_resolvedFromClone]() + } this.resolvedRef = revDoc this.resolvedSha = revDoc.sha @@ -145,16 +151,18 @@ class GitFetcher extends Fetcher { } [_prepareDir] (dir) { - return readPackageJson(dir + '/package.json').then(mani => { + return this[_readPackageJson](dir + '/package.json').then(mani => { // no need if we aren't going to do any preparation. const scripts = mani.scripts - if (!scripts || !( - scripts.postinstall || + if (!mani.workspaces && (!scripts || !( + scripts.postinstall || scripts.build || scripts.preinstall || scripts.install || - scripts.prepare)) + scripts.prepack || + scripts.prepare))) { return + } // to avoid cases where we have an cycle of git deps that depend // on one another, we only ever do preparation for one instance @@ -166,7 +174,7 @@ class GitFetcher extends Fetcher { const noPrepare = !process.env._PACOTE_NO_PREPARE_ ? [] : process.env._PACOTE_NO_PREPARE_.split('\n') if (noPrepare.includes(this.resolved)) { - this.log.info('prepare', 'skip prepare, already seen', this.resolved) + log.info('prepare', 'skip prepare, already seen', this.resolved) return } noPrepare.push(this.resolved) @@ -202,9 +210,9 @@ class GitFetcher extends Fetcher { dirStream.on('end', res) dirStream.pipe(stream) }))).catch( - /* istanbul ignore next: very unlikely and hard to test */ - er => stream.emit('error', er) - ) + /* istanbul ignore next: very unlikely and hard to test */ + er => stream.emit('error', er) + ) return stream } @@ -237,10 +245,11 @@ class GitFetcher extends Fetcher { integrity: null, // it'll always be different, if we have one }).extract(tmp).then(() => handler(tmp), er => { // fall back to ssh download if tarball fails - if (er.constructor.name.match(/^Http/)) + if (er.constructor.name.match(/^Http/)) { return this[_clone](handler, false) - else + } else { throw er + } }) } @@ -249,10 +258,11 @@ class GitFetcher extends Fetcher { : this[_cloneRepo](this.spec.fetchSpec, ref, tmp) ).then(sha => { this.resolvedSha = sha - if (!this.resolved) + if (!this.resolved) { this[_addGitSha](sha) + } }) - .then(() => handler(tmp)) + .then(() => handler(tmp)) }) } @@ -266,12 +276,14 @@ class GitFetcher extends Fetcher { return this[_cloneRepo](hosted.https({ noCommittish: true }), ref, tmp) .catch(er => { // Throw early since we know pathspec errors will fail again if retried - if (er instanceof git.errors.GitPathspecError) + if (er instanceof git.errors.GitPathspecError) { throw er + } const ssh = hosted.sshurl && hosted.sshurl({ noCommittish: true }) // no fallthrough if we can't fall through or have https auth - if (!ssh || hosted.auth) + if (!ssh || hosted.auth) { throw er + } return this[_cloneRepo](ssh, ref, tmp) }) } @@ -282,19 +294,20 @@ class GitFetcher extends Fetcher { } manifest () { - if (this.package) + if (this.package) { return Promise.resolve(this.package) + } return this.spec.hosted && this.resolved ? FileFetcher.prototype.manifest.apply(this) : this[_clone](dir => - readPackageJson(dir + '/package.json') - .then(mani => this.package = { - ...mani, - _integrity: this.integrity && String(this.integrity), - _resolved: this.resolved, - _from: this.from, - })) + this[_readPackageJson](dir + '/package.json') + .then(mani => this.package = { + ...mani, + _integrity: this.integrity && String(this.integrity), + _resolved: this.resolved, + _from: this.from, + })) } packument () { diff --git a/node_modules/pacote/lib/registry.js b/node_modules/pacote/lib/registry.js index e0a310717420d..b4f890d310dfa 100644 --- a/node_modules/pacote/lib/registry.js +++ b/node_modules/pacote/lib/registry.js @@ -2,11 +2,11 @@ const Fetcher = require('./fetcher.js') const RemoteFetcher = require('./remote.js') const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved') const pacoteVersion = require('../package.json').version +const removeTrailingSlashes = require('./util/trailing-slashes.js') const npa = require('npm-package-arg') const rpj = require('read-package-json-fast') const pickManifest = require('npm-pick-manifest') const ssri = require('ssri') -const Minipass = require('minipass') // Corgis are cute. 🐕🐶 const corgiDoc = 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*' @@ -32,10 +32,11 @@ class RegistryFetcher extends Fetcher { // handle case when npm-package-arg guesses wrong. if (this.spec.type === 'tag' && this.spec.rawSpec === '' && - this.defaultTag !== 'latest') + this.defaultTag !== 'latest') { this.spec = npa(`${this.spec.name}@${this.defaultTag}`) + } this.registry = fetch.pickRegistry(spec, opts) - this.packumentUrl = this.registry.replace(/\/*$/, '/') + + this.packumentUrl = removeTrailingSlashes(this.registry) + '/' + this.spec.escapedName // XXX pacote <=9 has some logic to ignore opts.resolved if @@ -45,13 +46,15 @@ class RegistryFetcher extends Fetcher { } resolve () { - if (this.resolved) + if (this.resolved) { return Promise.resolve(this.resolved) + } // fetching the manifest sets resolved and (usually) integrity return this.manifest().then(() => { - if (this.resolved) + if (this.resolved) { return this.resolved + } throw Object.assign( new Error('Invalid package manifest: no `dist.tarball` field'), @@ -77,8 +80,9 @@ class RegistryFetcher extends Fetcher { // note this might be either an in-flight promise for a request, // or the actual packument, but we never want to make more than // one request at a time for the same thing regardless. - if (this.packumentCache && this.packumentCache.has(this.packumentUrl)) + if (this.packumentCache && this.packumentCache.has(this.packumentUrl)) { return this.packumentCache.get(this.packumentUrl) + } // npm-registry-fetch the packument // set the appropriate header for corgis if fullMetadata isn't set @@ -92,12 +96,14 @@ class RegistryFetcher extends Fetcher { }).then(res => res.json().then(packument => { packument._cached = res.headers.has('x-local-cache') packument._contentLength = +res.headers.get('content-length') - if (this.packumentCache) + if (this.packumentCache) { this.packumentCache.set(this.packumentUrl, packument) + } return packument })).catch(er => { - if (this.packumentCache) + if (this.packumentCache) { this.packumentCache.delete(this.packumentUrl) + } if (er.code === 'E404' && !this.fullMetadata) { // possible that corgis are not supported by this registry this.fullMetadata = true @@ -105,14 +111,16 @@ class RegistryFetcher extends Fetcher { } throw er }) - if (this.packumentCache) + if (this.packumentCache) { this.packumentCache.set(this.packumentUrl, p) + } return p } manifest () { - if (this.package) + if (this.package) { return Promise.resolve(this.package) + } return this.packument() .then(packument => pickManifest(packument, this.spec.fetchSpec, { @@ -127,12 +135,12 @@ class RegistryFetcher extends Fetcher { this.resolved = mani._resolved = dist.tarball mani._from = this.from const distIntegrity = dist.integrity ? ssri.parse(dist.integrity) - : dist.shasum ? ssri.fromHex(dist.shasum, 'sha1', {...this.opts}) + : dist.shasum ? ssri.fromHex(dist.shasum, 'sha1', { ...this.opts }) : null if (distIntegrity) { - if (!this.integrity) + if (!this.integrity) { this.integrity = distIntegrity - else if (!this.integrity.match(distIntegrity)) { + } else if (!this.integrity.match(distIntegrity)) { // only bork if they have algos in common. // otherwise we end up breaking if we have saved a sha512 // previously for the tarball, but the manifest only @@ -143,7 +151,7 @@ class RegistryFetcher extends Fetcher { for (const algo of Object.keys(this.integrity)) { if (distIntegrity[algo]) { throw Object.assign(new Error( - `Integrity checksum failed when using ${algo}: `+ + `Integrity checksum failed when using ${algo}: ` + `wanted ${this.integrity} but got ${distIntegrity}.` ), { code: 'EINTEGRITY' }) } @@ -155,8 +163,9 @@ class RegistryFetcher extends Fetcher { } } } - if (this.integrity) + if (this.integrity) { mani._integrity = String(this.integrity) + } this.package = rpj.normalize(mani) return this.package }) diff --git a/node_modules/pacote/lib/remote.js b/node_modules/pacote/lib/remote.js index 727a8bfc8e608..5cabfe4fcda44 100644 --- a/node_modules/pacote/lib/remote.js +++ b/node_modules/pacote/lib/remote.js @@ -3,7 +3,6 @@ const FileFetcher = require('./file.js') const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved') const pacoteVersion = require('../package.json').version const fetch = require('npm-registry-fetch') -const ssri = require('ssri') const Minipass = require('minipass') // The default registry URL is a string of great magic. const magic = /^https?:\/\/registry\.npmjs\.org\// @@ -14,8 +13,9 @@ class RemoteFetcher extends Fetcher { constructor (spec, opts) { super(spec, opts) this.resolved = this.spec.fetchSpec - if (magic.test(this.resolved) && !magic.test(this.registry + '/')) + if (magic.test(this.resolved) && !magic.test(this.registry + '/')) { this.resolved = this.resolved.replace(magic, this.registry + '/') + } // nam is a fermented pork sausage that is good to eat const nameat = this.spec.name ? `${this.spec.name}@` : '' @@ -35,7 +35,7 @@ class RemoteFetcher extends Fetcher { headers: this[_headers](), spec: this.spec, integrity: this.integrity, - algorithms: [ this.pickIntegrityAlgorithm() ], + algorithms: [this.pickIntegrityAlgorithm()], } fetch(this.resolved, fetchOpts).then(res => { const hash = res.headers.get('x-local-cache-hash') @@ -62,7 +62,7 @@ class RemoteFetcher extends Fetcher { 'pacote-req-type': 'tarball', 'pacote-pkg-id': this.pkgid, ...(this.integrity ? { 'pacote-integrity': String(this.integrity) } - : {}), + : {}), ...(this.opts.headers || {}), } } diff --git a/node_modules/pacote/lib/util/cache-dir.js b/node_modules/pacote/lib/util/cache-dir.js index abd2453232027..4236213edd409 100644 --- a/node_modules/pacote/lib/util/cache-dir.js +++ b/node_modules/pacote/lib/util/cache-dir.js @@ -1,5 +1,5 @@ const os = require('os') -const {resolve} = require('path') +const { resolve } = require('path') module.exports = (fakePlatform = false) => { const temp = os.tmpdir() diff --git a/node_modules/pacote/lib/util/is-package-bin.js b/node_modules/pacote/lib/util/is-package-bin.js index 35cf0642703c7..49a3f73f537ce 100644 --- a/node_modules/pacote/lib/util/is-package-bin.js +++ b/node_modules/pacote/lib/util/is-package-bin.js @@ -12,10 +12,11 @@ const binObj = (name, bin) => const hasBin = (pkg, path) => { const bin = binObj(pkg.name, pkg.bin) - const p = path.replace(/^[^\\\/]*\//, '') - for (const [k, v] of Object.entries(bin)) { - if (v === p) + const p = path.replace(/^[^\\/]*\//, '') + for (const kv of Object.entries(bin)) { + if (kv[1] === p) { return true + } } return false } diff --git a/node_modules/pacote/lib/util/npm.js b/node_modules/pacote/lib/util/npm.js index f2f29bd0acbd1..c444d788ad192 100644 --- a/node_modules/pacote/lib/util/npm.js +++ b/node_modules/pacote/lib/util/npm.js @@ -1,6 +1,5 @@ // run an npm command const spawn = require('@npmcli/promise-spawn') -const {dirname} = require('path') module.exports = (npmBin, npmCommand, cwd, env, extra) => { const isJS = npmBin.endsWith('.js') diff --git a/node_modules/pacote/lib/util/proc-log.js b/node_modules/pacote/lib/util/proc-log.js deleted file mode 100644 index b2bdd9dc90205..0000000000000 --- a/node_modules/pacote/lib/util/proc-log.js +++ /dev/null @@ -1,21 +0,0 @@ -// default logger. -// emits 'log' events on the process -const LEVELS = [ - 'notice', - 'error', - 'warn', - 'info', - 'verbose', - 'http', - 'silly', - 'pause', - 'resume' -] - -const log = level => (...args) => process.emit('log', level, ...args) - -const logger = {} -for (const level of LEVELS) { - logger[level] = log(level) -} -module.exports = logger diff --git a/node_modules/pacote/lib/util/tar-create-options.js b/node_modules/pacote/lib/util/tar-create-options.js index 31ab34c9d949f..d070f0f7ba2d4 100644 --- a/node_modules/pacote/lib/util/tar-create-options.js +++ b/node_modules/pacote/lib/util/tar-create-options.js @@ -9,7 +9,7 @@ const tarCreateOptions = manifest => ({ // platform specific optimizations that cause // integrity mismatch errors due to differing // end results after compression - level: 9 + level: 9, }, // ensure that package bins are always executable @@ -17,8 +17,9 @@ const tarCreateOptions = manifest => ({ // anything that is not a regular file, ignored by // .npmignore or package.json "files", etc. filter: (path, stat) => { - if (isPackageBin(manifest, path)) + if (isPackageBin(manifest, path)) { stat.mode |= 0o111 + } return true }, diff --git a/node_modules/pacote/lib/util/trailing-slashes.js b/node_modules/pacote/lib/util/trailing-slashes.js new file mode 100644 index 0000000000000..ff75dfd9c0fbc --- /dev/null +++ b/node_modules/pacote/lib/util/trailing-slashes.js @@ -0,0 +1,10 @@ +const removeTrailingSlashes = (input) => { + // in order to avoid regexp redos detection + let output = input + while (output.endsWith('/')) { + output = output.substr(0, output.length - 1) + } + return output +} + +module.exports = removeTrailingSlashes diff --git a/node_modules/pacote/package.json b/node_modules/pacote/package.json index ffbc067f68dee..7e1f07cafdcd3 100644 --- a/node_modules/pacote/package.json +++ b/node_modules/pacote/package.json @@ -1,8 +1,8 @@ { "name": "pacote", - "version": "12.0.3", + "version": "13.0.2", "description": "JavaScript package downloader", - "author": "Isaac Z. Schlueter (https://izs.me)", + "author": "GitHub Inc.", "bin": { "pacote": "lib/bin.js" }, @@ -13,19 +13,26 @@ "snap": "tap", "preversion": "npm test", "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags" + "prepublishOnly": "git push origin --follow-tags", + "lint": "eslint '**/*.js'", + "postlint": "npm-template-check", + "lintfix": "npm run lint -- --fix", + "posttest": "npm run lint", + "template-copy": "npm-template-copy --force" }, "tap": { "timeout": 300, "coverage-map": "map.js" }, "devDependencies": { + "@npmcli/template-oss": "^2.7.1", "mutate-fs": "^2.1.1", "npm-registry-mock": "^1.3.1", - "tap": "^15.0.4" + "tap": "^15.1.6" }, "files": [ - "lib/**/*.js" + "bin", + "lib" ], "keywords": [ "packages", @@ -33,28 +40,34 @@ "git" ], "dependencies": { - "@npmcli/git": "^2.1.0", - "@npmcli/installed-package-contents": "^1.0.6", + "@npmcli/git": "^3.0.0", + "@npmcli/installed-package-contents": "^1.0.7", "@npmcli/promise-spawn": "^1.2.0", "@npmcli/run-script": "^2.0.0", - "cacache": "^15.0.5", + "cacache": "^15.3.0", "chownr": "^2.0.0", "fs-minipass": "^2.1.0", "infer-owner": "^1.0.4", - "minipass": "^3.1.3", - "mkdirp": "^1.0.3", - "npm-package-arg": "^8.0.1", + "minipass": "^3.1.6", + "mkdirp": "^1.0.4", + "npm-package-arg": "^9.0.0", "npm-packlist": "^3.0.0", - "npm-pick-manifest": "^6.0.0", - "npm-registry-fetch": "^12.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-registry-fetch": "^13.0.0", + "proc-log": "^2.0.0", "promise-retry": "^2.0.1", - "read-package-json-fast": "^2.0.1", + "read-package-json": "^4.1.1", + "read-package-json-fast": "^2.0.3", "rimraf": "^3.0.2", "ssri": "^8.0.1", - "tar": "^6.1.0" + "tar": "^6.1.11" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" }, - "repository": "git@github.com:npm/pacote" + "repository": "git@github.com:npm/pacote", + "templateOSS": { + "version": "2.7.1", + "windowsCI": false + } } diff --git a/node_modules/proc-log/index.js b/node_modules/proc-log/index.js deleted file mode 100644 index 9b58713ff3f85..0000000000000 --- a/node_modules/proc-log/index.js +++ /dev/null @@ -1,22 +0,0 @@ -// emits 'log' events on the process -const LEVELS = [ - 'notice', - 'error', - 'warn', - 'info', - 'verbose', - 'http', - 'silly', - 'pause', - 'resume', -] - -const log = level => (...args) => process.emit('log', level, ...args) - -const logger = {} -for (const level of LEVELS) - logger[level] = log(level) - -logger.LEVELS = LEVELS - -module.exports = logger diff --git a/workspaces/libnpmversion/lib/proc-log.js b/node_modules/proc-log/lib/index.js similarity index 92% rename from workspaces/libnpmversion/lib/proc-log.js rename to node_modules/proc-log/lib/index.js index a7c683ba2fd11..7c5dfad3b7ba3 100644 --- a/workspaces/libnpmversion/lib/proc-log.js +++ b/node_modules/proc-log/lib/index.js @@ -1,4 +1,3 @@ -// default logger. // emits 'log' events on the process const LEVELS = [ 'notice', @@ -18,4 +17,7 @@ const logger = {} for (const level of LEVELS) { logger[level] = log(level) } + +logger.LEVELS = LEVELS + module.exports = logger diff --git a/node_modules/proc-log/package.json b/node_modules/proc-log/package.json index 178009f61b8d2..17e9249b7ca46 100644 --- a/node_modules/proc-log/package.json +++ b/node_modules/proc-log/package.json @@ -1,28 +1,36 @@ { "name": "proc-log", - "version": "1.0.0", + "version": "2.0.0", "files": [ - "index.js" + "bin", + "lib" ], + "main": "lib/index.js", "description": "just emit 'log' events on the process object", "repository": "https://github.com/npm/proc-log", - "author": "Isaac Z. Schlueter (https://izs.me)", + "author": "GitHub Inc.", "license": "ISC", "scripts": { "test": "tap", "snap": "tap", - "posttest": "eslint index.js test/*.js", + "posttest": "npm run lint", "postsnap": "eslint index.js test/*.js --fix", "preversion": "npm test", "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags" + "prepublishOnly": "git push origin --follow-tags", + "lint": "eslint '**/*.js'", + "postlint": "npm-template-check", + "template-copy": "npm-template-copy --force", + "lintfix": "npm run lint -- --fix" }, "devDependencies": { - "eslint": "^7.9.0", - "eslint-plugin-import": "^2.22.0", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.2.1", - "eslint-plugin-standard": "^4.0.1", - "tap": "^15.0.2" + "@npmcli/template-oss": "^2.7.1", + "tap": "^15.1.6" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" + }, + "templateOSS": { + "version": "2.7.1" } } diff --git a/package-lock.json b/package-lock.json index 20aaac14907bf..dfbbe22d331b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -89,7 +89,7 @@ "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/arborist": "^4.3.1", "@npmcli/ci-detect": "^2.0.0", - "@npmcli/config": "^3.0.0", + "@npmcli/config": "^4.0.0", "@npmcli/map-workspaces": "^2.0.0", "@npmcli/package-json": "^1.0.1", "@npmcli/run-script": "^2.0.0", @@ -108,7 +108,7 @@ "graceful-fs": "^4.2.9", "hosted-git-info": "^4.1.0", "ini": "^2.0.0", - "init-package-json": "^2.0.5", + "init-package-json": "^3.0.0", "is-cidr": "^4.0.2", "json-parse-even-better-errors": "^2.3.1", "libnpmaccess": "^5.0.1", @@ -132,16 +132,16 @@ "nopt": "^5.0.0", "npm-audit-report": "^2.1.5", "npm-install-checks": "^4.0.0", - "npm-package-arg": "^8.1.5", - "npm-pick-manifest": "^6.1.1", - "npm-profile": "^6.0.0", - "npm-registry-fetch": "^12.0.2", + "npm-package-arg": "^9.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-profile": "^6.0.2", + "npm-registry-fetch": "^13.0.0", "npm-user-validate": "^1.0.1", "npmlog": "^6.0.1", "opener": "^1.5.2", - "pacote": "^12.0.3", + "pacote": "^13.0.2", "parse-conflict-json": "^2.0.1", - "proc-log": "^1.0.0", + "proc-log": "^2.0.0", "qrcode-terminal": "^0.12.0", "read": "~1.0.7", "read-package-json": "^4.1.1", @@ -815,17 +815,18 @@ } }, "node_modules/@npmcli/config": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-3.0.0.tgz", - "integrity": "sha512-2cYe2MCGintq1s6izbLYO2gAHZwNFQ92lIb5QhtpRizwHwqrV9v4+xNpvx1EBaEaqTHFR4QuozgZLA1scao/5Q==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-4.0.0.tgz", + "integrity": "sha512-iywEsUhkA6GSgTS3vHLxHttU6lovSYt7wCGD0MOsjfd1YAUlz8243TXUKhcJiPfWvQYB4FnZkn30m3KmZS8GuA==", "inBundle": true, "dependencies": { "@npmcli/map-workspaces": "^2.0.0", "ini": "^2.0.0", "mkdirp-infer-owner": "^2.0.0", "nopt": "^5.0.0", + "proc-log": "^2.0.0", "read-package-json-fast": "^2.0.3", - "semver": "^7.3.4", + "semver": "^7.3.5", "walk-up-path": "^1.0.0" }, "engines": { @@ -876,19 +877,32 @@ } }, "node_modules/@npmcli/git": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-2.1.0.tgz", - "integrity": "sha512-/hBFX/QG1b+N7PZBFs0bi+evgRZcK9nWBxQKZkGoXUT5hJSwl5c4d7y8/hm+NQZRPhQ67RzFaj5UM9YeyKoryw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-3.0.0.tgz", + "integrity": "sha512-xfSBJ+KBMZWWqRHFbEgIaXG/LtELHrQZMJ72Gkb3yWdHysu/7+VGOs8ME0c3td7QNQX57Ggo3kYL6ylcd70/kA==", "inBundle": true, "dependencies": { "@npmcli/promise-spawn": "^1.3.2", - "lru-cache": "^6.0.0", + "lru-cache": "^7.3.1", "mkdirp": "^1.0.4", - "npm-pick-manifest": "^6.1.1", + "npm-pick-manifest": "^7.0.0", + "proc-log": "^2.0.0", "promise-inflight": "^1.0.1", "promise-retry": "^2.0.1", "semver": "^7.3.5", "which": "^2.0.2" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" + } + }, + "node_modules/@npmcli/git/node_modules/lru-cache": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.3.1.tgz", + "integrity": "sha512-nX1x4qUrKqwbIAhv4s9et4FIUVzNOpeY07bsjGUy8gwJrXH/wScImSQqXErmo/b2jZY2r0mohbLA9zVj7u1cNw==", + "inBundle": true, + "engines": { + "node": ">=12" } }, "node_modules/@npmcli/installed-package-contents": { @@ -923,14 +937,14 @@ } }, "node_modules/@npmcli/metavuln-calculator": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/metavuln-calculator/-/metavuln-calculator-2.0.0.tgz", - "integrity": "sha512-VVW+JhWCKRwCTE+0xvD6p3uV4WpqocNYYtzyvenqL/u1Q3Xx6fGTJ+6UoIoii07fbuEO9U3IIyuGY0CYHDv1sg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/metavuln-calculator/-/metavuln-calculator-3.0.0.tgz", + "integrity": "sha512-tIzAdW3DAvlyuQyYvy7WuDKaJs55LoXFAIyglZTrHsc9DGZWP1YVL7+8WFKqx+lHyHUEkfk02Dc8ie4JWtNO6w==", "dependencies": { - "cacache": "^15.0.5", + "cacache": "^15.3.0", "json-parse-even-better-errors": "^2.3.1", - "pacote": "^12.0.0", - "semver": "^7.3.2" + "pacote": "^13.0.1", + "semver": "^7.3.5" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" @@ -4036,21 +4050,21 @@ } }, "node_modules/init-package-json": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-2.0.5.tgz", - "integrity": "sha512-u1uGAtEFu3VA6HNl/yUWw57jmKEMx8SKOxHhxjGnOFUiIlFnohKDFg4ZrPpv9wWqk44nDxGJAtqjdQFm+9XXQA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-3.0.0.tgz", + "integrity": "sha512-b0PZaZ3lF0mKsk7QcP03LhxXttVR0kb4XIafD1HXV4JIvLhifdvFgNyXr3qSA/3DZmiskFveLP1eXfXGFybG6g==", "inBundle": true, "dependencies": { - "npm-package-arg": "^8.1.5", + "npm-package-arg": "^9.0.0", "promzard": "^0.3.0", - "read": "~1.0.1", + "read": "^1.0.7", "read-package-json": "^4.1.1", "semver": "^7.3.5", "validate-npm-package-license": "^3.0.4", "validate-npm-package-name": "^3.0.0" }, "engines": { - "node": ">=10" + "node": "^12.13.0 || ^14.15.0 || >=16" } }, "node_modules/inline-style-parser": { @@ -5594,17 +5608,17 @@ "inBundle": true }, "node_modules/npm-package-arg": { - "version": "8.1.5", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.5.tgz", - "integrity": "sha512-LhgZrg0n0VgvzVdSm1oiZworPbTxYHUJCgtsJW8mGvlDpxTM1vSJc3m5QZeUkhAHIzbz3VCHd/R4osi1L1Tg/Q==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-9.0.0.tgz", + "integrity": "sha512-yhzXxeor+Zfhe5MGwPdDumz6HtNlj2pMekWB95IX3CC6uDNgde0oPKHDCLDPoJqQfd0HqAWt+y4Hs5m7CK1+9Q==", "inBundle": true, "dependencies": { - "hosted-git-info": "^4.0.1", - "semver": "^7.3.4", + "hosted-git-info": "^4.1.0", + "semver": "^7.3.5", "validate-npm-package-name": "^3.0.0" }, "engines": { - "node": ">=10" + "node": "^12.13.0 || ^14.15.0 || >=16" } }, "node_modules/npm-packlist": { @@ -5626,41 +5640,46 @@ } }, "node_modules/npm-pick-manifest": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-6.1.1.tgz", - "integrity": "sha512-dBsdBtORT84S8V8UTad1WlUyKIY9iMsAmqxHbLdeEeBNMLQDlDWWra3wYUx9EBEIiG/YwAy0XyNHDd2goAsfuA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-7.0.0.tgz", + "integrity": "sha512-njM1AcdioFaKd0JSGtLO09YA1WRwctjGQJbnHGmKS+u+uwP8oFvtZtOQWPYdxrnY5eJud3wn8OpH4sEIx6+GEQ==", "inBundle": true, "dependencies": { "npm-install-checks": "^4.0.0", "npm-normalize-package-bin": "^1.0.1", - "npm-package-arg": "^8.1.2", - "semver": "^7.3.4" + "npm-package-arg": "^9.0.0", + "semver": "^7.3.5" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" } }, "node_modules/npm-profile": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/npm-profile/-/npm-profile-6.0.0.tgz", - "integrity": "sha512-ZiwXx3Fq3wNqJMz+d4AVZ9X4xAw/0TqsvdiyDF5Y+h9lQ7AjYDOxY06lj7AP5vUBqB/7k/0oNFQOx03Ay0iHPw==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/npm-profile/-/npm-profile-6.0.2.tgz", + "integrity": "sha512-0Fq8l+A10YXnnS63E3HThWjOb7+19Wsh1nOVutC2fKuowar8t/5PpINsbcm5xQ2dA28uAu+wjFfUyiEVSMz4Jw==", "inBundle": true, "dependencies": { - "npm-registry-fetch": "^12.0.0" + "npm-registry-fetch": "^13.0.0", + "proc-log": "^2.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" } }, "node_modules/npm-registry-fetch": { - "version": "12.0.2", - "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-12.0.2.tgz", - "integrity": "sha512-Df5QT3RaJnXYuOwtXBXS9BWs+tHH2olvkCLh6jcR/b/u3DvPMlp3J0TvvYwplPKxHMOwfg287PYih9QqaVFoKA==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-13.0.0.tgz", + "integrity": "sha512-MmiMuV9DU5gRuAU0jia952Qq+E4h7ZoUaeltCXivhClcqfOVKqNLZEQsRUOb6a8WQY+um8x97JcUuaWFoPoBBw==", "inBundle": true, "dependencies": { - "make-fetch-happen": "^10.0.1", + "make-fetch-happen": "^10.0.2", "minipass": "^3.1.6", "minipass-fetch": "^1.4.1", "minipass-json-stream": "^1.0.1", "minizlib": "^2.1.2", - "npm-package-arg": "^8.1.5" + "npm-package-arg": "^9.0.0", + "proc-log": "^2.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" @@ -6011,30 +6030,32 @@ } }, "node_modules/pacote": { - "version": "12.0.3", - "resolved": "https://registry.npmjs.org/pacote/-/pacote-12.0.3.tgz", - "integrity": "sha512-CdYEl03JDrRO3x18uHjBYA9TyoW8gy+ThVcypcDkxPtKlw76e4ejhYB6i9lJ+/cebbjpqPW/CijjqxwDTts8Ow==", + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/pacote/-/pacote-13.0.2.tgz", + "integrity": "sha512-3LyfvDk2BSJNFQZIcDqnLNa7IsYb6KwX3H9uZPwaHJFIX6Gv5N9QHU+s7mEs/RbN4/ta6KUT39LAi2l6EkBi5A==", "inBundle": true, "dependencies": { - "@npmcli/git": "^2.1.0", - "@npmcli/installed-package-contents": "^1.0.6", + "@npmcli/git": "^3.0.0", + "@npmcli/installed-package-contents": "^1.0.7", "@npmcli/promise-spawn": "^1.2.0", "@npmcli/run-script": "^2.0.0", - "cacache": "^15.0.5", + "cacache": "^15.3.0", "chownr": "^2.0.0", "fs-minipass": "^2.1.0", "infer-owner": "^1.0.4", - "minipass": "^3.1.3", - "mkdirp": "^1.0.3", - "npm-package-arg": "^8.0.1", + "minipass": "^3.1.6", + "mkdirp": "^1.0.4", + "npm-package-arg": "^9.0.0", "npm-packlist": "^3.0.0", - "npm-pick-manifest": "^6.0.0", - "npm-registry-fetch": "^12.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-registry-fetch": "^13.0.0", + "proc-log": "^2.0.0", "promise-retry": "^2.0.1", - "read-package-json-fast": "^2.0.1", + "read-package-json": "^4.1.1", + "read-package-json-fast": "^2.0.3", "rimraf": "^3.0.2", "ssri": "^8.0.1", - "tar": "^6.1.0" + "tar": "^6.1.11" }, "bin": { "pacote": "lib/bin.js" @@ -6302,10 +6323,13 @@ } }, "node_modules/proc-log": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-1.0.0.tgz", - "integrity": "sha512-aCk8AO51s+4JyuYGg3Q/a6gnrlDO09NpVWePtjp7xwphcoQ04x5WAfCyugcsbLooWcMJ87CLkD4+604IckEdhg==", - "inBundle": true + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-2.0.0.tgz", + "integrity": "sha512-I/35MfCX2H8jBUhKN8JB8nmqvQo/nKdrBodBY7L3RhDSPPyvOHwLYNmPuhwuJq7a7C3vgFKWGQM+ecPStcvOHA==", + "inBundle": true, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16" + } }, "node_modules/process-nextick-args": { "version": "2.0.1", @@ -10531,7 +10555,7 @@ "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/installed-package-contents": "^1.0.7", "@npmcli/map-workspaces": "^2.0.0", - "@npmcli/metavuln-calculator": "^2.0.0", + "@npmcli/metavuln-calculator": "^3.0.0", "@npmcli/move-file": "^1.1.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.3", @@ -10545,12 +10569,13 @@ "mkdirp": "^1.0.4", "mkdirp-infer-owner": "^2.0.0", "npm-install-checks": "^4.0.0", - "npm-package-arg": "^8.1.5", - "npm-pick-manifest": "^6.1.0", - "npm-registry-fetch": "^12.0.1", - "pacote": "^12.0.2", + "npm-package-arg": "^9.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-registry-fetch": "^13.0.0", + "npmlog": "^6.0.1", + "pacote": "^13.0.2", "parse-conflict-json": "^2.0.1", - "proc-log": "^1.0.0", + "proc-log": "^2.0.0", "promise-all-reject-late": "^1.0.0", "promise-call-limit": "^1.0.1", "read-package-json-fast": "^2.0.2", @@ -10598,8 +10623,8 @@ "dependencies": { "aproba": "^2.0.0", "minipass": "^3.1.1", - "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^12.0.1" + "npm-package-arg": "^9.0.0", + "npm-registry-fetch": "^13.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", @@ -10619,8 +10644,8 @@ "binary-extensions": "^2.2.0", "diff": "^5.0.0", "minimatch": "^3.0.4", - "npm-package-arg": "^8.1.4", - "pacote": "^12.0.0", + "npm-package-arg": "^9.0.0", + "pacote": "^13.0.2", "tar": "^6.1.0" }, "devDependencies": { @@ -10641,9 +10666,10 @@ "@npmcli/run-script": "^2.0.0", "chalk": "^4.1.0", "mkdirp-infer-owner": "^2.0.0", - "npm-package-arg": "^8.1.2", - "pacote": "^12.0.0", - "proc-log": "^1.0.0", + "npm-package-arg": "^9.0.0", + "npmlog": "^6.0.1", + "pacote": "^13.0.2", + "proc-log": "^2.0.0", "read": "^1.0.7", "read-package-json-fast": "^2.0.2", "walk-up-path": "^1.0.0" @@ -10676,7 +10702,7 @@ "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", @@ -10751,7 +10777,7 @@ "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", @@ -10768,8 +10794,8 @@ "license": "ISC", "dependencies": { "@npmcli/run-script": "^2.0.0", - "npm-package-arg": "^8.1.0", - "pacote": "^12.0.0" + "npm-package-arg": "^9.0.0", + "pacote": "^13.0.2" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", @@ -10800,8 +10826,8 @@ "license": "ISC", "dependencies": { "normalize-package-data": "^3.0.2", - "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^12.0.1", + "npm-package-arg": "^9.0.0", + "npm-registry-fetch": "^13.0.0", "semver": "^7.1.3", "ssri": "^8.0.1" }, @@ -10820,7 +10846,7 @@ "version": "4.0.1", "license": "ISC", "dependencies": { - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", @@ -10895,7 +10921,7 @@ "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", @@ -10910,9 +10936,10 @@ "version": "2.0.2", "license": "ISC", "dependencies": { - "@npmcli/git": "^2.0.7", + "@npmcli/git": "^3.0.0", "@npmcli/run-script": "^2.0.0", "json-parse-even-better-errors": "^2.3.1", + "proc-log": "^2.0.0", "semver": "^7.3.5", "stringify-package": "^1.0.1" }, @@ -11442,7 +11469,7 @@ "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/installed-package-contents": "^1.0.7", "@npmcli/map-workspaces": "^2.0.0", - "@npmcli/metavuln-calculator": "^2.0.0", + "@npmcli/metavuln-calculator": "^3.0.0", "@npmcli/move-file": "^1.1.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.3", @@ -11461,12 +11488,13 @@ "mkdirp-infer-owner": "^2.0.0", "nock": "^13.2.0", "npm-install-checks": "^4.0.0", - "npm-package-arg": "^8.1.5", - "npm-pick-manifest": "^6.1.0", - "npm-registry-fetch": "^12.0.1", - "pacote": "^12.0.2", + "npm-package-arg": "^9.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-registry-fetch": "^13.0.0", + "npmlog": "^6.0.1", + "pacote": "^13.0.2", "parse-conflict-json": "^2.0.1", - "proc-log": "^1.0.0", + "proc-log": "^2.0.0", "promise-all-reject-late": "^1.0.0", "promise-call-limit": "^1.0.1", "read-package-json-fast": "^2.0.2", @@ -11500,16 +11528,17 @@ "integrity": "sha512-8yQtQ9ArHh/TzdUDKQwEvwCgpDuhSWTDAbiKMl3854PcT+Dk4UmWaiawuFTLy9n5twzXOBXVflWe+90/ffXQrA==" }, "@npmcli/config": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-3.0.0.tgz", - "integrity": "sha512-2cYe2MCGintq1s6izbLYO2gAHZwNFQ92lIb5QhtpRizwHwqrV9v4+xNpvx1EBaEaqTHFR4QuozgZLA1scao/5Q==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/config/-/config-4.0.0.tgz", + "integrity": "sha512-iywEsUhkA6GSgTS3vHLxHttU6lovSYt7wCGD0MOsjfd1YAUlz8243TXUKhcJiPfWvQYB4FnZkn30m3KmZS8GuA==", "requires": { "@npmcli/map-workspaces": "^2.0.0", "ini": "^2.0.0", "mkdirp-infer-owner": "^2.0.0", "nopt": "^5.0.0", + "proc-log": "^2.0.0", "read-package-json-fast": "^2.0.3", - "semver": "^7.3.4", + "semver": "^7.3.5", "walk-up-path": "^1.0.0" } }, @@ -11540,18 +11569,26 @@ } }, "@npmcli/git": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-2.1.0.tgz", - "integrity": "sha512-/hBFX/QG1b+N7PZBFs0bi+evgRZcK9nWBxQKZkGoXUT5hJSwl5c4d7y8/hm+NQZRPhQ67RzFaj5UM9YeyKoryw==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/git/-/git-3.0.0.tgz", + "integrity": "sha512-xfSBJ+KBMZWWqRHFbEgIaXG/LtELHrQZMJ72Gkb3yWdHysu/7+VGOs8ME0c3td7QNQX57Ggo3kYL6ylcd70/kA==", "requires": { "@npmcli/promise-spawn": "^1.3.2", - "lru-cache": "^6.0.0", + "lru-cache": "^7.3.1", "mkdirp": "^1.0.4", - "npm-pick-manifest": "^6.1.1", + "npm-pick-manifest": "^7.0.0", + "proc-log": "^2.0.0", "promise-inflight": "^1.0.1", "promise-retry": "^2.0.1", "semver": "^7.3.5", "which": "^2.0.2" + }, + "dependencies": { + "lru-cache": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.3.1.tgz", + "integrity": "sha512-nX1x4qUrKqwbIAhv4s9et4FIUVzNOpeY07bsjGUy8gwJrXH/wScImSQqXErmo/b2jZY2r0mohbLA9zVj7u1cNw==" + } } }, "@npmcli/installed-package-contents": { @@ -11575,14 +11612,14 @@ } }, "@npmcli/metavuln-calculator": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@npmcli/metavuln-calculator/-/metavuln-calculator-2.0.0.tgz", - "integrity": "sha512-VVW+JhWCKRwCTE+0xvD6p3uV4WpqocNYYtzyvenqL/u1Q3Xx6fGTJ+6UoIoii07fbuEO9U3IIyuGY0CYHDv1sg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/metavuln-calculator/-/metavuln-calculator-3.0.0.tgz", + "integrity": "sha512-tIzAdW3DAvlyuQyYvy7WuDKaJs55LoXFAIyglZTrHsc9DGZWP1YVL7+8WFKqx+lHyHUEkfk02Dc8ie4JWtNO6w==", "requires": { - "cacache": "^15.0.5", + "cacache": "^15.3.0", "json-parse-even-better-errors": "^2.3.1", - "pacote": "^12.0.0", - "semver": "^7.3.2" + "pacote": "^13.0.1", + "semver": "^7.3.5" } }, "@npmcli/move-file": { @@ -13881,13 +13918,13 @@ "integrity": "sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA==" }, "init-package-json": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-2.0.5.tgz", - "integrity": "sha512-u1uGAtEFu3VA6HNl/yUWw57jmKEMx8SKOxHhxjGnOFUiIlFnohKDFg4ZrPpv9wWqk44nDxGJAtqjdQFm+9XXQA==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/init-package-json/-/init-package-json-3.0.0.tgz", + "integrity": "sha512-b0PZaZ3lF0mKsk7QcP03LhxXttVR0kb4XIafD1HXV4JIvLhifdvFgNyXr3qSA/3DZmiskFveLP1eXfXGFybG6g==", "requires": { - "npm-package-arg": "^8.1.5", + "npm-package-arg": "^9.0.0", "promzard": "^0.3.0", - "read": "~1.0.1", + "read": "^1.0.7", "read-package-json": "^4.1.1", "semver": "^7.3.5", "validate-npm-package-license": "^3.0.4", @@ -14441,8 +14478,8 @@ "aproba": "^2.0.0", "minipass": "^3.1.1", "nock": "^12.0.1", - "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^12.0.1", + "npm-package-arg": "^9.0.0", + "npm-registry-fetch": "^13.0.0", "tap": "^15.1.0" } }, @@ -14456,8 +14493,8 @@ "diff": "^5.0.0", "eslint": "^8.1.0", "minimatch": "^3.0.4", - "npm-package-arg": "^8.1.4", - "pacote": "^12.0.0", + "npm-package-arg": "^9.0.0", + "pacote": "^13.0.2", "tap": "^15.0.9", "tar": "^6.1.0" } @@ -14472,9 +14509,10 @@ "bin-links": "^3.0.0", "chalk": "^4.1.0", "mkdirp-infer-owner": "^2.0.0", - "npm-package-arg": "^8.1.2", - "pacote": "^12.0.0", - "proc-log": "^1.0.0", + "npm-package-arg": "^9.0.0", + "npmlog": "^6.0.1", + "pacote": "^13.0.2", + "proc-log": "^2.0.0", "read": "^1.0.7", "read-package-json-fast": "^2.0.2", "tap": "^15.0.6", @@ -14495,7 +14533,7 @@ "@npmcli/template-oss": "^2.4.2", "aproba": "^2.0.0", "nock": "^9.6.1", - "npm-registry-fetch": "^12.0.1", + "npm-registry-fetch": "^13.0.0", "tap": "^15.1.0" }, "dependencies": { @@ -14555,7 +14593,7 @@ "aproba": "^2.0.0", "minipass": "^3.1.1", "nock": "^12.0.1", - "npm-registry-fetch": "^12.0.1", + "npm-registry-fetch": "^13.0.0", "tap": "^15.0.0" } }, @@ -14565,8 +14603,8 @@ "@npmcli/run-script": "^2.0.0", "@npmcli/template-oss": "^2.4.2", "nock": "^13.0.7", - "npm-package-arg": "^8.1.0", - "pacote": "^12.0.0", + "npm-package-arg": "^9.0.0", + "pacote": "^13.0.2", "tap": "^15.0.0" }, "dependencies": { @@ -14592,8 +14630,8 @@ "lodash.clonedeep": "^4.5.0", "nock": "^12.0.2", "normalize-package-data": "^3.0.2", - "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^12.0.1", + "npm-package-arg": "^9.0.0", + "npm-registry-fetch": "^13.0.0", "semver": "^7.1.3", "ssri": "^8.0.1", "tap": "^15" @@ -14604,7 +14642,7 @@ "requires": { "@npmcli/template-oss": "^2.4.2", "nock": "^9.6.1", - "npm-registry-fetch": "^12.0.1", + "npm-registry-fetch": "^13.0.0", "tap": "^15" }, "dependencies": { @@ -14663,17 +14701,18 @@ "@npmcli/template-oss": "^2.4.2", "aproba": "^2.0.0", "nock": "^12.0.1", - "npm-registry-fetch": "^12.0.1", + "npm-registry-fetch": "^13.0.0", "tap": "^15" } }, "libnpmversion": { "version": "file:workspaces/libnpmversion", "requires": { - "@npmcli/git": "^2.0.7", + "@npmcli/git": "^3.0.0", "@npmcli/run-script": "^2.0.0", "@npmcli/template-oss": "^2.4.2", "json-parse-even-better-errors": "^2.3.1", + "proc-log": "^2.0.0", "require-inject": "^1.4.4", "semver": "^7.3.5", "stringify-package": "^1.0.1", @@ -15240,12 +15279,12 @@ "integrity": "sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==" }, "npm-package-arg": { - "version": "8.1.5", - "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-8.1.5.tgz", - "integrity": "sha512-LhgZrg0n0VgvzVdSm1oiZworPbTxYHUJCgtsJW8mGvlDpxTM1vSJc3m5QZeUkhAHIzbz3VCHd/R4osi1L1Tg/Q==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-9.0.0.tgz", + "integrity": "sha512-yhzXxeor+Zfhe5MGwPdDumz6HtNlj2pMekWB95IX3CC6uDNgde0oPKHDCLDPoJqQfd0HqAWt+y4Hs5m7CK1+9Q==", "requires": { - "hosted-git-info": "^4.0.1", - "semver": "^7.3.4", + "hosted-git-info": "^4.1.0", + "semver": "^7.3.5", "validate-npm-package-name": "^3.0.0" } }, @@ -15261,35 +15300,37 @@ } }, "npm-pick-manifest": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-6.1.1.tgz", - "integrity": "sha512-dBsdBtORT84S8V8UTad1WlUyKIY9iMsAmqxHbLdeEeBNMLQDlDWWra3wYUx9EBEIiG/YwAy0XyNHDd2goAsfuA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/npm-pick-manifest/-/npm-pick-manifest-7.0.0.tgz", + "integrity": "sha512-njM1AcdioFaKd0JSGtLO09YA1WRwctjGQJbnHGmKS+u+uwP8oFvtZtOQWPYdxrnY5eJud3wn8OpH4sEIx6+GEQ==", "requires": { "npm-install-checks": "^4.0.0", "npm-normalize-package-bin": "^1.0.1", - "npm-package-arg": "^8.1.2", - "semver": "^7.3.4" + "npm-package-arg": "^9.0.0", + "semver": "^7.3.5" } }, "npm-profile": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/npm-profile/-/npm-profile-6.0.0.tgz", - "integrity": "sha512-ZiwXx3Fq3wNqJMz+d4AVZ9X4xAw/0TqsvdiyDF5Y+h9lQ7AjYDOxY06lj7AP5vUBqB/7k/0oNFQOx03Ay0iHPw==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/npm-profile/-/npm-profile-6.0.2.tgz", + "integrity": "sha512-0Fq8l+A10YXnnS63E3HThWjOb7+19Wsh1nOVutC2fKuowar8t/5PpINsbcm5xQ2dA28uAu+wjFfUyiEVSMz4Jw==", "requires": { - "npm-registry-fetch": "^12.0.0" + "npm-registry-fetch": "^13.0.0", + "proc-log": "^2.0.0" } }, "npm-registry-fetch": { - "version": "12.0.2", - "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-12.0.2.tgz", - "integrity": "sha512-Df5QT3RaJnXYuOwtXBXS9BWs+tHH2olvkCLh6jcR/b/u3DvPMlp3J0TvvYwplPKxHMOwfg287PYih9QqaVFoKA==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/npm-registry-fetch/-/npm-registry-fetch-13.0.0.tgz", + "integrity": "sha512-MmiMuV9DU5gRuAU0jia952Qq+E4h7ZoUaeltCXivhClcqfOVKqNLZEQsRUOb6a8WQY+um8x97JcUuaWFoPoBBw==", "requires": { - "make-fetch-happen": "^10.0.1", + "make-fetch-happen": "^10.0.2", "minipass": "^3.1.6", "minipass-fetch": "^1.4.1", "minipass-json-stream": "^1.0.1", "minizlib": "^2.1.2", - "npm-package-arg": "^8.1.5" + "npm-package-arg": "^9.0.0", + "proc-log": "^2.0.0" } }, "npm-user-validate": { @@ -15547,29 +15588,31 @@ } }, "pacote": { - "version": "12.0.3", - "resolved": "https://registry.npmjs.org/pacote/-/pacote-12.0.3.tgz", - "integrity": "sha512-CdYEl03JDrRO3x18uHjBYA9TyoW8gy+ThVcypcDkxPtKlw76e4ejhYB6i9lJ+/cebbjpqPW/CijjqxwDTts8Ow==", + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/pacote/-/pacote-13.0.2.tgz", + "integrity": "sha512-3LyfvDk2BSJNFQZIcDqnLNa7IsYb6KwX3H9uZPwaHJFIX6Gv5N9QHU+s7mEs/RbN4/ta6KUT39LAi2l6EkBi5A==", "requires": { - "@npmcli/git": "^2.1.0", - "@npmcli/installed-package-contents": "^1.0.6", + "@npmcli/git": "^3.0.0", + "@npmcli/installed-package-contents": "^1.0.7", "@npmcli/promise-spawn": "^1.2.0", "@npmcli/run-script": "^2.0.0", - "cacache": "^15.0.5", + "cacache": "^15.3.0", "chownr": "^2.0.0", "fs-minipass": "^2.1.0", "infer-owner": "^1.0.4", - "minipass": "^3.1.3", - "mkdirp": "^1.0.3", - "npm-package-arg": "^8.0.1", + "minipass": "^3.1.6", + "mkdirp": "^1.0.4", + "npm-package-arg": "^9.0.0", "npm-packlist": "^3.0.0", - "npm-pick-manifest": "^6.0.0", - "npm-registry-fetch": "^12.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-registry-fetch": "^13.0.0", + "proc-log": "^2.0.0", "promise-retry": "^2.0.1", - "read-package-json-fast": "^2.0.1", + "read-package-json": "^4.1.1", + "read-package-json-fast": "^2.0.3", "rimraf": "^3.0.2", "ssri": "^8.0.1", - "tar": "^6.1.0" + "tar": "^6.1.11" } }, "parent-module": { @@ -15788,9 +15831,9 @@ "dev": true }, "proc-log": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-1.0.0.tgz", - "integrity": "sha512-aCk8AO51s+4JyuYGg3Q/a6gnrlDO09NpVWePtjp7xwphcoQ04x5WAfCyugcsbLooWcMJ87CLkD4+604IckEdhg==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-2.0.0.tgz", + "integrity": "sha512-I/35MfCX2H8jBUhKN8JB8nmqvQo/nKdrBodBY7L3RhDSPPyvOHwLYNmPuhwuJq7a7C3vgFKWGQM+ecPStcvOHA==" }, "process-nextick-args": { "version": "2.0.1", diff --git a/package.json b/package.json index c7885c2089c31..a01683769ce5d 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/arborist": "^4.3.1", "@npmcli/ci-detect": "^2.0.0", - "@npmcli/config": "^3.0.0", + "@npmcli/config": "^4.0.0", "@npmcli/map-workspaces": "^2.0.0", "@npmcli/package-json": "^1.0.1", "@npmcli/run-script": "^2.0.0", @@ -76,7 +76,7 @@ "graceful-fs": "^4.2.9", "hosted-git-info": "^4.1.0", "ini": "^2.0.0", - "init-package-json": "^2.0.5", + "init-package-json": "^3.0.0", "is-cidr": "^4.0.2", "json-parse-even-better-errors": "^2.3.1", "libnpmaccess": "^5.0.1", @@ -100,16 +100,16 @@ "nopt": "^5.0.0", "npm-audit-report": "^2.1.5", "npm-install-checks": "^4.0.0", - "npm-package-arg": "^8.1.5", - "npm-pick-manifest": "^6.1.1", - "npm-profile": "^6.0.0", - "npm-registry-fetch": "^12.0.2", + "npm-package-arg": "^9.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-profile": "^6.0.2", + "npm-registry-fetch": "^13.0.0", "npm-user-validate": "^1.0.1", "npmlog": "^6.0.1", "opener": "^1.5.2", - "pacote": "^12.0.3", + "pacote": "^13.0.2", "parse-conflict-json": "^2.0.1", - "proc-log": "^1.0.0", + "proc-log": "^2.0.0", "qrcode-terminal": "^0.12.0", "read": "~1.0.7", "read-package-json": "^4.1.1", diff --git a/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs b/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs index 523aabca29b50..0aaf235fd14b6 100644 --- a/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs +++ b/tap-snapshots/test/lib/utils/exit-handler.js.test.cjs @@ -26,10 +26,10 @@ exports[`test/lib/utils/exit-handler.js TAP handles unknown error with logs and 32 error ERR SUMMARY Unknown error 33 error ERR DETAIL Unknown error 34 verbose exit 1 -35 timing npm Completed in {TIME}ms -36 verbose code 1 -37 error A complete log of this run can be found in: -37 error {CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs/{DATE}-debug-0.log +36 timing npm Completed in {TIME}ms +37 verbose code 1 +38 error A complete log of this run can be found in: +38 error {CWD}/test/lib/utils/tap-testdir-exit-handler-handles-unknown-error-with-logs-and-debug-file/cache/_logs/{DATE}-debug-0.log ` exports[`test/lib/utils/exit-handler.js TAP handles unknown error with logs and debug file > logs 1`] = ` diff --git a/test/fixtures/mock-npm.js b/test/fixtures/mock-npm.js index c3dc47f5dde4f..4846d9a485841 100644 --- a/test/fixtures/mock-npm.js +++ b/test/fixtures/mock-npm.js @@ -31,6 +31,18 @@ const RealMockNpm = (t, otherMocks = {}) => { return mock } +const setLoglevel = (t, loglevel, reset = true) => { + if (t && reset) { + const _level = log.level + t.teardown(() => log.level = _level) + } + + if (loglevel) { + // Set log level on the npmlog singleton and shared across everything + log.level = loglevel + } +} + // Resolve some options to a function call with supplied args const result = (fn, ...args) => typeof fn === 'function' ? fn(...args) : fn @@ -62,14 +74,8 @@ const LoadMockNpm = async (t, { throw new Error('cant `load` without `init`') } - const _level = log.level - t.teardown(() => log.level = _level) - - if (config.loglevel) { - // Set log level as early as possible since it is set - // on the npmlog singleton and shared across everything - log.level = config.loglevel - } + // Set log level as early as possible since + setLoglevel(t, config.loglevel) const dir = t.testdir({ root: testdir, cache: {} }) const prefix = path.join(dir, 'root') @@ -93,11 +99,9 @@ const LoadMockNpm = async (t, { for (const [k, v] of Object.entries(result(config, { npm, prefix, cache }))) { npm.config.set(k, v) } - if (config.loglevel) { - // Set global loglevel *again* since it possibly got reset during load - // XXX: remove with npmlog - log.level = config.loglevel - } + // Set global loglevel *again* since it possibly got reset during load + // XXX: remove with npmlog + setLoglevel(t, config.loglevel, false) npm.prefix = prefix npm.cache = cache } @@ -129,7 +133,7 @@ const realConfig = require('../../lib/utils/config') // npm.config You still need a separate flatOptions. Tests should migrate to // using the real npm mock above class MockNpm { - constructor (base = {}) { + constructor (base = {}, t) { this._mockOutputs = [] this.isMockNpm = true this.base = base @@ -150,9 +154,24 @@ class MockNpm { // for now isDefault is going to just return false if a value was defined isDefault: (k) => !Object.prototype.hasOwnProperty.call(config, k), get: (k) => ({ ...realConfig.defaults, ...config })[k], - set: (k, v) => config[k] = v, + set: (k, v) => { + config[k] = v + // mock how real npm derives silent + if (k === 'loglevel') { + this.flatOptions.silent = v === 'silent' + this.silent = v === 'silent' + } + }, list: [{ ...realConfig.defaults, ...config }], } + + if (t && config.loglevel) { + setLoglevel(t, config.loglevel) + } + + if (config.loglevel) { + this.config.set('loglevel', config.loglevel) + } } output (...msg) { @@ -163,8 +182,8 @@ class MockNpm { } } -const FakeMockNpm = (base = {}) => { - return new MockNpm(base) +const FakeMockNpm = (base = {}, t) => { + return new MockNpm(base, t) } module.exports = { diff --git a/test/fixtures/sandbox.js b/test/fixtures/sandbox.js index 701d9cea72397..d51281d41d104 100644 --- a/test/fixtures/sandbox.js +++ b/test/fixtures/sandbox.js @@ -193,6 +193,8 @@ class Sandbox extends EventEmitter { // test.teardown hook teardown () { if (this[_parent]) { + const sandboxProcess = sandboxes.get(this[_parent]) + sandboxProcess.removeAllListeners('log') sandboxes.delete(this[_parent]) } if (this[_npm]) { @@ -211,20 +213,7 @@ class Sandbox extends EventEmitter { return Reflect.get(this, prop, this) } - const actual = Reflect.get(target, prop, receiver) - if (typeof actual === 'function') { - // in node 10.1 there's an interesting bug where if a function on process - // is called without explicitly forcing the 'this' arg to something, we - // get 'Illegal invocation' errors. wrapping function properties in their - // own proxy so that we can make sure the context is right fixes it - return new Proxy(actual, { - apply: (target, context, args) => { - return Reflect.apply(target, _process, args) - }, - }) - } - - return actual + return Reflect.get(target, prop, receiver) } // proxy set handler @@ -278,17 +267,15 @@ class Sandbox extends EventEmitter { ...this[_mocks], ...mockedLogs.logMocks, }) + this.process.on('log', (l, ...args) => { + if (l !== 'pause' && l !== 'resume') { + this[_logs].push([l, ...args]) + } + }) + this[_npm] = new Npm() this[_npm].output = (...args) => this[_output].push(args) await this[_npm].load() - // in some node versions (later 10.x) our executionAsyncId at this point - // will for some reason appear to have been triggered by a different parent - // so immediately after load, if we can see that we lost our ancestry, we - // fix it here with a hammer - if (chain.get(executionAsyncId()) !== this[_parent]) { - chain.set(executionAsyncId(), this[_parent]) - process = this[_proxy] - } const cmd = this[_npm].argv.shift() return this[_npm].exec(cmd, this[_npm].argv) @@ -330,17 +317,15 @@ class Sandbox extends EventEmitter { ...this[_mocks], ...mockedLogs.logMocks, }) + this.process.on('log', (l, ...args) => { + if (l !== 'pause' && l !== 'resume') { + this[_logs].push([l, ...args]) + } + }) + this[_npm] = new Npm() this[_npm].output = (...args) => this[_output].push(args) await this[_npm].load() - // in some node versions (later 10.x) our executionAsyncId at this point - // will for some reason appear to have been triggered by a different parent - // so immediately after load, if we can see that we lost our ancestry, we - // fix it here with a hammer - if (chain.get(executionAsyncId()) !== this[_parent]) { - chain.set(executionAsyncId(), this[_parent]) - process = this[_proxy] - } const impl = await this[_npm].cmd(command) return impl.completion({ diff --git a/test/lib/commands/access.js b/test/lib/commands/access.js index c4e6f3167aa01..298897e4f5ffc 100644 --- a/test/lib/commands/access.js +++ b/test/lib/commands/access.js @@ -75,13 +75,12 @@ t.test('access public on unscoped package', async t => { }) t.test('access public on scoped package', async t => { - t.plan(3) + t.plan(2) const name = '@scoped/npm-access-public-pkg' const { npm } = await loadMockNpm(t, { mocks: { libnpmaccess: { - public: (pkg, { registry, log }) => { - t.ok(log, 'should pass a logger') + public: (pkg, { registry }) => { t.equal(pkg, name, 'should use pkg name ref') t.equal( registry, diff --git a/test/lib/commands/adduser.js b/test/lib/commands/adduser.js index 8a9358f9ab21a..f88508d15a6fe 100644 --- a/test/lib/commands/adduser.js +++ b/test/lib/commands/adduser.js @@ -20,13 +20,6 @@ const authDummy = (npm, options) => { throw new Error('did not pass full flatOptions to auth function') } - if (!options.log) { - // A quick to test to make sure a log gets passed to auth - // XXX: should be refactored with change to real mock npm - // https://github.com/npm/statusboard/issues/411 - throw new Error('pass log to auth') - } - return Promise.resolve({ message: 'success', newCreds: { diff --git a/test/lib/commands/deprecate.js b/test/lib/commands/deprecate.js index aa158cca3a1a1..180629a7488f9 100644 --- a/test/lib/commands/deprecate.js +++ b/test/lib/commands/deprecate.js @@ -2,15 +2,12 @@ const t = require('tap') let getIdentityImpl = () => 'someperson' let npmFetchBody = null -let npmFetchLog = null const npmFetch = async (uri, opts) => { npmFetchBody = opts.body - npmFetchLog = opts.log } npmFetch.json = async (uri, opts) => { - npmFetchLog = opts.log return { versions: { '1.0.0': {}, @@ -87,10 +84,8 @@ t.test('invalid semver range', async t => { t.test('undeprecate', async t => { t.teardown(() => { npmFetchBody = null - npmFetchLog = null }) await deprecate.exec(['foo', '']) - t.ok(npmFetchLog, 'was passed a logger') t.match(npmFetchBody, { versions: { '1.0.0': { deprecated: '' }, @@ -103,11 +98,9 @@ t.test('undeprecate', async t => { t.test('deprecates given range', async t => { t.teardown(() => { npmFetchBody = null - npmFetchLog = null }) await deprecate.exec(['foo@1.0.0', 'this version is deprecated']) - t.ok(npmFetchLog, 'was passed a logger') t.match(npmFetchBody, { versions: { '1.0.0': { diff --git a/test/lib/commands/diff.js b/test/lib/commands/diff.js index f73a543cb4c51..ed0702e3784a6 100644 --- a/test/lib/commands/diff.js +++ b/test/lib/commands/diff.js @@ -61,10 +61,9 @@ const diff = new Diff(npm) t.test('no args', t => { t.test('in a project dir', async t => { - t.plan(4) + t.plan(3) libnpmdiff = async ([a, b], opts) => { - t.ok(opts.log, 'should be passed a logger') t.equal(a, 'foo@latest', 'should have default spec comparison') t.equal(b, `file:${fooPath}`, 'should compare to cwd') t.match(opts, npm.flatOptions, 'should forward flat options') diff --git a/test/lib/commands/dist-tag.js b/test/lib/commands/dist-tag.js index b83c30e9c64ea..eb13c7ff02fbe 100644 --- a/test/lib/commands/dist-tag.js +++ b/test/lib/commands/dist-tag.js @@ -43,7 +43,6 @@ const routeMap = { // XXX overriding this does not appear to do anything, adding t.plan to things // that use it fails the test let npmRegistryFetchMock = (url, opts) => { - npmRegistryFetchLog = opts.log if (url === '/-/package/foo/dist-tags') { throw new Error('no package found') } @@ -51,9 +50,7 @@ let npmRegistryFetchMock = (url, opts) => { return routeMap[url] } -let npmRegistryFetchLog npmRegistryFetchMock.json = async (url, opts) => { - npmRegistryFetchLog = opts.log return routeMap[url] } @@ -86,10 +83,6 @@ const npm = mockNpm({ }) const distTag = new DistTag(npm) -t.afterEach(() => { - npmRegistryFetchLog = null -}) - t.test('ls in current package', async t => { npm.prefix = t.testdir({ 'package.json': JSON.stringify({ @@ -97,7 +90,6 @@ t.test('ls in current package', async t => { }), }) await distTag.exec(['ls']) - t.ok(npmRegistryFetchLog, 'is passed a logger') t.matchSnapshot( result, 'should list available tags for current package' @@ -299,7 +291,6 @@ t.test('add new tag', async t => { }) npmRegistryFetchMock = async (url, opts) => { - t.ok(opts.log, 'is passed a logger') t.equal(opts.method, 'PUT', 'should trigger request to add new tag') t.equal(opts.body, '7.7.7', 'should point to expected version') } @@ -366,7 +357,6 @@ t.test('remove existing tag', async t => { } npm.prefix = t.testdir({}) await distTag.exec(['rm', '@scoped/another', 'c']) - t.ok(npmRegistryFetchLog, 'is passed a logger') t.matchSnapshot(log, 'should log remove info') t.matchSnapshot(result, 'should return success msg') }) diff --git a/test/lib/commands/doctor.js b/test/lib/commands/doctor.js index 51b6111a0ae70..dee2110ff3c89 100644 --- a/test/lib/commands/doctor.js +++ b/test/lib/commands/doctor.js @@ -4,6 +4,7 @@ const { join } = require('path') const fs = require('fs') const ansiTrim = require('../../../lib/utils/ansi-trim.js') const isWindows = require('../../../lib/utils/is-windows.js') +const { fake: mockNpm } = require('../../fixtures/mock-npm') // getuid and getgid do not exist in windows, so we shim them // to return 0, as that is the value that lstat will assign the @@ -61,15 +62,18 @@ const clearLogs = () => { } } -const npm = { +const npm = mockNpm({ flatOptions: { registry: 'https://registry.npmjs.org/', }, + config: { + loglevel: 'info', + }, version: '7.1.0', output: data => { output.push(data) }, -} +}) let latestNpm = npm.version const pacote = { @@ -211,7 +215,7 @@ t.test('node versions', t => { npm.globalDir = dir npm.localBin = dir npm.globalBin = dir - mocks.npmlog.level = 'info' + npm.config.set('loglevel', 'silent') st.teardown(() => { delete npm.cache @@ -220,7 +224,7 @@ t.test('node versions', t => { delete npm.globalDir delete npm.localBin delete npm.globalBin - mocks.npmlog.level = 'error' + npm.config.set('loglevel', 'info') clearLogs() }) diff --git a/test/lib/commands/hook.js b/test/lib/commands/hook.js index a4eee711fe8e0..60a59a3fe7a3b 100644 --- a/test/lib/commands/hook.js +++ b/test/lib/commands/hook.js @@ -1,18 +1,20 @@ const t = require('tap') +const { fake: mockNpm } = require('../../fixtures/mock-npm') const output = [] -const npm = { +const npm = mockNpm({ flatOptions: { json: false, parseable: false, - silent: false, - loglevel: 'info', unicode: false, }, + config: { + loglevel: 'info', + }, output: msg => { output.push(msg) }, -} +}) const pkgTypes = { semver: 'package', @@ -78,7 +80,6 @@ t.test('npm hook add', async t => { await hook.exec(['add', 'semver', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -102,7 +103,6 @@ t.test('npm hook add - unicode output', async t => { await hook.exec(['add', 'semver', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -126,7 +126,6 @@ t.test('npm hook add - json output', async t => { await hook.exec(['add', '@npmcli', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -159,7 +158,6 @@ t.test('npm hook add - parseable output', async t => { await hook.exec(['add', '@npmcli', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -183,16 +181,15 @@ t.test('npm hook add - parseable output', async t => { }) t.test('npm hook add - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') hookArgs = null output.length = 0 }) await hook.exec(['add', '@npmcli', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -214,7 +211,6 @@ t.test('npm hook ls', async t => { await hook.exec(['ls']) - t.ok(hookArgs.log, 'is passed a logger') t.match( hookArgs, { @@ -240,7 +236,6 @@ t.test('npm hook ls, no results', async t => { await hook.exec(['ls']) - t.ok(hookArgs.log, 'is passed a logger') t.match( hookArgs, { @@ -270,7 +265,6 @@ t.test('npm hook ls, single result', async t => { await hook.exec(['ls']) - t.ok(hookArgs.log, 'is passed a logger') t.match( hookArgs, { @@ -294,7 +288,6 @@ t.test('npm hook ls - json output', async t => { await hook.exec(['ls']) - t.ok(hookArgs.log, 'is passed a logger') t.match( hookArgs, { @@ -340,7 +333,6 @@ t.test('npm hook ls - parseable output', async t => { await hook.exec(['ls']) - t.ok(hookArgs.log, 'is passed a logger') t.match( hookArgs, { @@ -362,16 +354,15 @@ t.test('npm hook ls - parseable output', async t => { }) t.test('npm hook ls - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') hookArgs = null output.length = 0 }) await hook.exec(['ls']) - t.ok(hookArgs.log, 'is passed a logger') t.match( hookArgs, { @@ -391,7 +382,6 @@ t.test('npm hook rm', async t => { await hook.exec(['rm', '1']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -413,7 +403,6 @@ t.test('npm hook rm - unicode output', async t => { await hook.exec(['rm', '1']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -426,16 +415,15 @@ t.test('npm hook rm - unicode output', async t => { }) t.test('npm hook rm - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') hookArgs = null output.length = 0 }) await hook.exec(['rm', '1']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -457,7 +445,6 @@ t.test('npm hook rm - json output', async t => { await hook.exec(['rm', '1']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -488,7 +475,6 @@ t.test('npm hook rm - parseable output', async t => { await hook.exec(['rm', '1']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -515,7 +501,6 @@ t.test('npm hook update', async t => { await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -539,7 +524,6 @@ t.test('npm hook update - unicode', async t => { await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -563,7 +547,6 @@ t.test('npm hook update - json output', async t => { await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -596,7 +579,6 @@ t.test('npm hook update - parseable output', async t => { await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { @@ -618,16 +600,15 @@ t.test('npm hook update - parseable output', async t => { }) t.test('npm hook update - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') hookArgs = null output.length = 0 }) await hook.exec(['update', '1', 'https://google.com', 'some-secret']) - t.ok(hookArgs.opts.log, 'is passed a logger') t.match( hookArgs, { diff --git a/test/lib/commands/logout.js b/test/lib/commands/logout.js index 1a1fbb785c808..73fe8028c7853 100644 --- a/test/lib/commands/logout.js +++ b/test/lib/commands/logout.js @@ -31,7 +31,7 @@ t.afterEach(() => { }) t.test('token logout', async t => { - t.plan(6) + t.plan(5) flatOptions['//registry.npmjs.org/:_authToken'] = '@foo/' @@ -62,7 +62,6 @@ t.test('token logout', async t => { await logout.exec([]) - t.ok(result.opts.log, 'should pass a logger') t.match( result, { @@ -92,7 +91,7 @@ t.test('token scoped logout', async t => { config.save = null }) - t.plan(8) + t.plan(7) flatOptions['//diff-registry.npmjs.com/:_authToken'] = '@bar/' flatOptions['//registry.npmjs.org/:_authToken'] = '@foo/' @@ -133,7 +132,6 @@ t.test('token scoped logout', async t => { await logout.exec([]) - t.ok(result.opts.log, 'should pass a logger') t.match( result, { @@ -204,7 +202,7 @@ t.test('ignore invalid scoped registry config', async t => { config.delete = null config.save = null }) - t.plan(5) + t.plan(4) flatOptions['//registry.npmjs.org/:_authToken'] = '@foo/' config.scope = '@myscope' @@ -236,7 +234,6 @@ t.test('ignore invalid scoped registry config', async t => { await logout.exec([]) - t.ok(result.opts.log, 'should pass a logger') t.match( result, { diff --git a/test/lib/commands/org.js b/test/lib/commands/org.js index b716adc097523..3ae951dd5c453 100644 --- a/test/lib/commands/org.js +++ b/test/lib/commands/org.js @@ -1,18 +1,20 @@ const t = require('tap') const ansiTrim = require('../../../lib/utils/ansi-trim.js') +const { fake: mockNpm } = require('../../fixtures/mock-npm') const output = [] -const npm = { +const npm = mockNpm({ flatOptions: { json: false, parseable: false, - silent: false, + }, + config: { loglevel: 'info', }, output: msg => { output.push(msg) }, -} +}) let orgSize = 1 let orgSetArgs = null @@ -83,7 +85,6 @@ t.test('npm org add', async t => { await org.exec(['add', 'orgname', 'username']) - t.ok(orgSetArgs.opts.log, 'got passed a logger') t.match( orgSetArgs, { @@ -149,7 +150,6 @@ t.test('npm org add - more users', async t => { }) await org.exec(['add', 'orgname', 'username']) - t.ok(orgSetArgs.opts.log, 'got passed a logger') t.match( orgSetArgs, { @@ -177,7 +177,6 @@ t.test('npm org add - json output', async t => { await org.exec(['add', 'orgname', 'username']) - t.ok(orgSetArgs.opts.log, 'got passed a logger') t.match( orgSetArgs, { @@ -212,7 +211,6 @@ t.test('npm org add - parseable output', async t => { await org.exec(['add', 'orgname', 'username']) - t.ok(orgSetArgs.opts.log, 'got passed a logger') t.match( orgSetArgs, { @@ -234,16 +232,15 @@ t.test('npm org add - parseable output', async t => { }) t.test('npm org add - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') orgSetArgs = null output.length = 0 }) await org.exec(['add', 'orgname', 'username']) - t.ok(orgSetArgs.opts.log, 'got passed a logger') t.match( orgSetArgs, { @@ -266,7 +263,6 @@ t.test('npm org rm', async t => { await org.exec(['rm', 'orgname', 'username']) - t.ok(orgRmArgs.opts.log, 'got passed a logger') t.match( orgRmArgs, { @@ -276,7 +272,6 @@ t.test('npm org rm', async t => { }, 'libnpmorg.rm received the correct args' ) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -330,7 +325,6 @@ t.test('npm org rm - one user left', async t => { await org.exec(['rm', 'orgname', 'username']) - t.ok(orgRmArgs.opts.log, 'got passed a logger') t.match( orgRmArgs, { @@ -340,7 +334,6 @@ t.test('npm org rm - one user left', async t => { }, 'libnpmorg.rm received the correct args' ) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -367,7 +360,6 @@ t.test('npm org rm - json output', async t => { await org.exec(['rm', 'orgname', 'username']) - t.ok(orgRmArgs.opts.log, 'got passed a logger') t.match( orgRmArgs, { @@ -377,7 +369,6 @@ t.test('npm org rm - json output', async t => { }, 'libnpmorg.rm received the correct args' ) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -409,7 +400,6 @@ t.test('npm org rm - parseable output', async t => { await org.exec(['rm', 'orgname', 'username']) - t.ok(orgRmArgs.opts.log, 'got passed a logger') t.match( orgRmArgs, { @@ -419,7 +409,6 @@ t.test('npm org rm - parseable output', async t => { }, 'libnpmorg.rm received the correct args' ) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -439,9 +428,9 @@ t.test('npm org rm - parseable output', async t => { }) t.test('npm org rm - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') orgRmArgs = null orgLsArgs = null output.length = 0 @@ -449,7 +438,6 @@ t.test('npm org rm - silent output', async t => { await org.exec(['rm', 'orgname', 'username']) - t.ok(orgRmArgs.opts.log, 'got passed a logger') t.match( orgRmArgs, { @@ -459,7 +447,6 @@ t.test('npm org rm - silent output', async t => { }, 'libnpmorg.rm received the correct args' ) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -485,7 +472,6 @@ t.test('npm org ls', async t => { await org.exec(['ls', 'orgname']) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -513,7 +499,6 @@ t.test('npm org ls - user filter', async t => { await org.exec(['ls', 'orgname', 'username']) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -539,7 +524,6 @@ t.test('npm org ls - user filter, missing user', async t => { await org.exec(['ls', 'orgname', 'username']) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -578,7 +562,6 @@ t.test('npm org ls - json output', async t => { await org.exec(['ls', 'orgname']) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -606,7 +589,6 @@ t.test('npm org ls - parseable output', async t => { await org.exec(['ls', 'orgname']) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { @@ -628,14 +610,14 @@ t.test('npm org ls - parseable output', async t => { }) t.test('npm org ls - silent output', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') orgList = { one: 'developer', two: 'admin', three: 'owner', } t.teardown(() => { - npm.flatOptions.silent = false + npm.config.set('loglevel', 'info') orgList = {} orgLsArgs = null output.length = 0 @@ -643,7 +625,6 @@ t.test('npm org ls - silent output', async t => { await org.exec(['ls', 'orgname']) - t.ok(orgLsArgs.opts.log, 'got passed a logger') t.match( orgLsArgs, { diff --git a/test/lib/commands/owner.js b/test/lib/commands/owner.js index a32a3df9b7dde..b5d4d1584289d 100644 --- a/test/lib/commands/owner.js +++ b/test/lib/commands/owner.js @@ -51,14 +51,13 @@ t.test('owner no args', async t => { }) t.test('owner ls no args', async t => { - t.plan(5) + t.plan(4) result = '' readPackageNameResponse = '@npmcli/map-workspaces' pacote.packument = async (spec, opts) => { t.equal(spec.name, '@npmcli/map-workspaces', 'should use expect pkg name') - t.ok(opts.log, 'is passed a logger') t.match( opts, { @@ -173,11 +172,10 @@ t.test('owner ls no maintainers', async t => { }) t.test('owner add ', async t => { - t.plan(11) + t.plan(8) result = '' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { t.ok('should request user info') @@ -218,7 +216,6 @@ t.test('owner add ', async t => { } } pacote.packument = async (spec, opts) => { - t.ok(opts.log, 'is passed a logger') t.equal(spec.name, '@npmcli/map-workspaces', 'should use expect pkg name') t.match( opts, @@ -247,7 +244,6 @@ t.test('owner add cwd package', async t => { result = '' readPackageNameResponse = '@npmcli/map-workspaces' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { return { @@ -277,7 +273,7 @@ t.test('owner add cwd package', async t => { }) t.test('owner add already an owner', async t => { - t.plan(3) + t.plan(2) result = '' log.info = (title, msg) => { @@ -289,7 +285,6 @@ t.test('owner add already an owner', async t => { ) } npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:ruyadorno') { return { @@ -321,7 +316,6 @@ t.test('owner add fails to retrieve user', async t => { result = '' readPackageNameResponse = npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve borked user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { return { ok: false } @@ -352,7 +346,6 @@ t.test('owner add fails to retrieve user', async t => { t.test('owner add fails to PUT updates', async t => { result = '' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { return { @@ -389,7 +382,7 @@ t.test('owner add fails to PUT updates', async t => { }) t.test('owner add fails to retrieve user info', async t => { - t.plan(4) + t.plan(3) result = '' log.error = (title, msg) => { @@ -397,7 +390,6 @@ t.test('owner add fails to retrieve user info', async t => { t.equal(msg, 'Error getting user data for foo') } npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { throw Object.assign( @@ -429,7 +421,6 @@ t.test('owner add fails to retrieve user info', async t => { t.test('owner add no previous maintainers property from server', async t => { result = '' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { return { @@ -496,11 +487,10 @@ t.test('owner add no cwd package', async t => { }) t.test('owner rm ', async t => { - t.plan(11) + t.plan(8) result = '' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:ruyadorno') { t.ok('should request user info') @@ -534,7 +524,6 @@ t.test('owner rm ', async t => { } } pacote.packument = async (spec, opts) => { - t.ok(opts.log, 'is passed a logger') t.equal(spec.name, '@npmcli/map-workspaces', 'should use expect pkg name') t.match( opts, @@ -560,7 +549,7 @@ t.test('owner rm ', async t => { }) t.test('owner rm not a current owner', async t => { - t.plan(3) + t.plan(2) result = '' log.info = (title, msg) => { @@ -568,7 +557,6 @@ t.test('owner rm not a current owner', async t => { t.equal(msg, 'Not a package owner: foo', 'should log.info not a package owner msg') } npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:foo') { return { @@ -602,7 +590,6 @@ t.test('owner rm cwd package', async t => { result = '' readPackageNameResponse = '@npmcli/map-workspaces' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:ruyadorno') { return { @@ -635,7 +622,6 @@ t.test('owner rm only user', async t => { result = '' readPackageNameResponse = 'ipt' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') // retrieve user info from couchdb request if (uri === '/-/user/org.couchdb.user:ruyadorno') { return { diff --git a/test/lib/commands/ping.js b/test/lib/commands/ping.js index 19ba9d586b763..f808e0ac3ba2a 100644 --- a/test/lib/commands/ping.js +++ b/test/lib/commands/ping.js @@ -2,13 +2,12 @@ const t = require('tap') const { fake: mockNpm } = require('../../fixtures/mock-npm') t.test('pings', async t => { - t.plan(7) + t.plan(6) const registry = 'https://registry.npmjs.org' let noticeCalls = 0 const Ping = t.mock('../../../lib/commands/ping.js', { '../../../lib/utils/ping.js': function (spec) { - t.ok(spec.log, 'is passed a logger') t.equal(spec.registry, registry, 'passes flatOptions') return {} }, @@ -36,14 +35,13 @@ t.test('pings', async t => { }) t.test('pings and logs details', async t => { - t.plan(9) + t.plan(8) const registry = 'https://registry.npmjs.org' const details = { extra: 'data' } let noticeCalls = 0 const Ping = t.mock('../../../lib/commands/ping.js', { '../../../lib/utils/ping.js': function (spec) { - t.ok(spec.log, 'is passed a logger') t.equal(spec.registry, registry, 'passes flatOptions') return details }, @@ -75,14 +73,13 @@ t.test('pings and logs details', async t => { }) t.test('pings and returns json', async t => { - t.plan(10) + t.plan(9) const registry = 'https://registry.npmjs.org' const details = { extra: 'data' } let noticeCalls = 0 const Ping = t.mock('../../../lib/commands/ping.js', { '../../../lib/utils/ping.js': function (spec) { - t.ok(spec.log, 'is passed a logger') t.equal(spec.registry, registry, 'passes flatOptions') return details }, diff --git a/test/lib/commands/publish.js b/test/lib/commands/publish.js index 52d4c1b342908..0a7f961bfbdc9 100644 --- a/test/lib/commands/publish.js +++ b/test/lib/commands/publish.js @@ -1,15 +1,6 @@ const t = require('tap') const { fake: mockNpm } = require('../../fixtures/mock-npm') const fs = require('fs') -const log = require('../../../lib/utils/log-shim') - -// The way we set loglevel is kind of convoluted, and there is no way to affect -// it from these tests, which only interact with lib/publish.js, which assumes -// that the code that is requiring and calling lib/publish.js has already -// taken care of the loglevel -const _level = log.level -t.beforeEach(() => (log.level = 'silent')) -t.teardown(() => (log.level = _level)) t.cleanSnapshot = data => { return data.replace(/^ *"gitHead": .*$\n/gm, '') @@ -25,7 +16,7 @@ t.test( /* eslint-disable-next-line max-len */ 'should publish with libnpmpublish, passing through flatOptions and respecting publishConfig.registry', async t => { - t.plan(7) + t.plan(6) const registry = 'https://some.registry' const publishConfig = { registry } @@ -59,7 +50,6 @@ t.test( t.match(manifest, { name: 'my-cool-pkg', version: '1.0.0' }, 'gets manifest') t.type(tarData, Buffer, 'tarData is a buffer') t.ok(opts, 'gets opts object') - t.ok(opts.log, 'gets passed a logger') t.same(opts.customValue, true, 'flatOptions values are passed through') t.same(opts.registry, registry, 'publishConfig.registry is passed through') }, @@ -82,7 +72,7 @@ t.test( ) t.test('re-loads publishConfig.registry if added during script process', async t => { - t.plan(6) + t.plan(5) const registry = 'https://some.registry' const publishConfig = { registry } const testDir = t.testdir({ @@ -113,7 +103,6 @@ t.test('re-loads publishConfig.registry if added during script process', async t t.match(manifest, { name: 'my-cool-pkg', version: '1.0.0' }, 'gets manifest') t.type(tarData, Buffer, 'tarData is a buffer') t.ok(opts, 'gets opts object') - t.ok(opts.log, 'gets passed a logger') t.same(opts.registry, registry, 'publishConfig.registry is passed through') }, }, @@ -142,7 +131,6 @@ t.test('if loglevel=info and json, should not output package contents', async t ), }) - log.level = 'info' const Publish = t.mock('../../../lib/commands/publish.js', { '../../../lib/utils/tar.js': { getContents: () => ({ @@ -159,11 +147,11 @@ t.test('if loglevel=info and json, should not output package contents', async t }, }) const npm = mockNpm({ - config: { json: true }, + config: { json: true, loglevel: 'info' }, output: () => { t.pass('output is called') }, - }) + }, t) npm.config.getCredentialsByURI = uri => { t.same(uri, npm.config.get('registry'), 'gets credentials for expected registry') return { token: 'some.registry.token' } @@ -206,11 +194,11 @@ t.test( }, }) const npm = mockNpm({ - config: { 'dry-run': true }, + config: { 'dry-run': true, loglevel: 'silent' }, output: () => { throw new Error('should not output in dry run mode') }, - }) + }, t) npm.config.getCredentialsByURI = () => { throw new Error('should not call getCredentialsByURI in dry run') } @@ -238,7 +226,6 @@ t.test( ), }) - log.level = 'info' const Publish = t.mock('../../../lib/commands/publish.js', { '../../../lib/utils/tar.js': { getContents: () => ({ @@ -255,11 +242,11 @@ t.test( }, }) const npm = mockNpm({ - config: { 'dry-run': true }, + config: { 'dry-run': true, loglevel: 'info' }, output: () => { t.pass('output fn is called') }, - }) + }, t) npm.config.getCredentialsByURI = () => { throw new Error('should not call getCredentialsByURI in dry run') } @@ -294,7 +281,7 @@ t.test('throws when invalid tag', async t => { }) t.test('can publish a tarball', async t => { - t.plan(4) + t.plan(3) const testDir = t.testdir({ tarball: {}, @@ -319,7 +306,6 @@ t.test('can publish a tarball', async t => { const Publish = t.mock('../../../lib/commands/publish.js', { libnpmpublish: { publish: (manifest, tarData, opts) => { - t.ok(opts.log, 'gets passed a logger') t.match( manifest, { @@ -415,7 +401,7 @@ t.test('should check auth for scope specific registry', async t => { }) t.test('should use auth for scope specific registry', async t => { - t.plan(4) + t.plan(3) const registry = 'https://some.registry' const testDir = t.testdir({ 'package.json': JSON.stringify( @@ -432,7 +418,6 @@ t.test('should use auth for scope specific registry', async t => { libnpmpublish: { publish: (manifest, tarData, opts) => { t.ok(opts, 'gets opts object') - t.ok(opts.log, 'gets passed a logger') t.same(opts['@npm:registry'], registry, 'scope specific registry is passed through') }, }, @@ -450,7 +435,7 @@ t.test('should use auth for scope specific registry', async t => { }) t.test('read registry only from publishConfig', async t => { - t.plan(4) + t.plan(3) const registry = 'https://some.registry' const publishConfig = { registry } @@ -469,7 +454,6 @@ t.test('read registry only from publishConfig', async t => { const Publish = t.mock('../../../lib/commands/publish.js', { libnpmpublish: { publish: (manifest, tarData, opts) => { - t.ok(opts.log, 'gets passed a logger') t.match(manifest, { name: 'my-cool-pkg', version: '1.0.0' }, 'gets manifest') t.same(opts.registry, registry, 'publishConfig is passed through') }, @@ -486,7 +470,7 @@ t.test('read registry only from publishConfig', async t => { }) t.test('able to publish after if encountered multiple configs', async t => { - t.plan(3) + t.plan(2) const registry = 'https://some.registry' const tag = 'better-tag' @@ -515,7 +499,6 @@ t.test('able to publish after if encountered multiple configs', async t => { const Publish = t.mock('../../../lib/commands/publish.js', { libnpmpublish: { publish: (manifest, tarData, opts) => { - t.ok(opts.log, 'gets passed a logger') t.same(opts.defaultTag, tag, 'gets option for expected tag') }, }, @@ -526,6 +509,7 @@ t.test('able to publish after if encountered multiple configs', async t => { defaultTag: 'better-tag', registry: 'https://other.registry', }, + output () {}, config: { get: key => configList[0][key], list: configList, @@ -604,14 +588,12 @@ t.test('workspaces', t => { const publish = new Publish(npm) t.test('all workspaces', async t => { - log.level = 'info' await publish.execWorkspaces([], []) t.matchSnapshot(publishes, 'should publish all workspaces') t.matchSnapshot(outputs, 'should output all publishes') }) t.test('one workspace', async t => { - log.level = 'info' await publish.execWorkspaces([], ['workspace-a']) t.matchSnapshot(publishes, 'should publish given workspace') t.matchSnapshot(outputs, 'should output one publish') @@ -623,7 +605,6 @@ t.test('workspaces', t => { }) t.test('json', async t => { - log.level = 'info' npm.config.set('json', true) await publish.execWorkspaces([], []) t.matchSnapshot(publishes, 'should publish all workspaces') @@ -680,10 +661,11 @@ t.test('private workspaces', async t => { }, } const npm = mockNpm({ + config: { loglevel: 'info' }, output: o => { outputs.push(o) }, - }) + }, t) npm.localPrefix = testDir npm.config.getCredentialsByURI = uri => { return { token: 'some.registry.token' } @@ -692,7 +674,6 @@ t.test('private workspaces', async t => { t.test('with color', async t => { t.plan(4) - log.level = 'info' const Publish = t.mock('../../../lib/commands/publish.js', { ...mocks, 'proc-log': { @@ -721,7 +702,6 @@ t.test('private workspaces', async t => { t.test('colorless', async t => { t.plan(4) - log.level = 'info' const Publish = t.mock('../../../lib/commands/publish.js', { ...mocks, 'proc-log': { @@ -754,7 +734,6 @@ t.test('private workspaces', async t => { if (manifest.private) { throw new Error('ERR') } - t.ok(opts.log, 'gets passed a logger') publishes.push(manifest) }, }, @@ -794,7 +773,6 @@ t.test('runs correct lifecycle scripts', async t => { }) const scripts = [] - log.level = 'info' const Publish = t.mock('../../../lib/commands/publish.js', { '@npmcli/run-script': args => { scripts.push(args) @@ -814,10 +792,11 @@ t.test('runs correct lifecycle scripts', async t => { }, }) const npm = mockNpm({ + config: { loglevel: 'info' }, output: () => { t.pass('output is called') }, - }) + }, t) npm.config.getCredentialsByURI = uri => { t.same(uri, npm.config.get('registry'), 'gets credentials for expected registry') return { token: 'some.registry.token' } @@ -845,7 +824,6 @@ t.test('does not run scripts on --ignore-scripts', async t => { ), }) - log.level = 'info' const Publish = t.mock('../../../lib/commands/publish.js', { '@npmcli/run-script': () => { t.fail('should not call run-script') @@ -865,11 +843,11 @@ t.test('does not run scripts on --ignore-scripts', async t => { }, }) const npm = mockNpm({ - config: { 'ignore-scripts': true }, + config: { 'ignore-scripts': true, loglevel: 'info' }, output: () => { t.pass('output is called') }, - }) + }, t) npm.config.getCredentialsByURI = uri => { t.same(uri, npm.config.get('registry'), 'gets credentials for expected registry') return { token: 'some.registry.token' } diff --git a/test/lib/commands/run-script.js b/test/lib/commands/run-script.js index ea0227cda08ca..834b61e7474c4 100644 --- a/test/lib/commands/run-script.js +++ b/test/lib/commands/run-script.js @@ -10,10 +10,12 @@ const RUN_SCRIPTS = [] const flatOptions = { scriptShell: undefined, } +const defaultLoglevel = 'info' const config = { json: false, parseable: false, 'if-present': false, + loglevel: defaultLoglevel, } const npm = mockNpm({ @@ -26,20 +28,21 @@ const npm = mockNpm({ output: (...msg) => output.push(msg), }) -const output = [] - -const npmlog = { - disableProgress: () => null, - level: 'warn', +const setLoglevel = (t, level) => { + npm.config.set('loglevel', level) + t.teardown(() => { + npm.config.set('loglevel', defaultLoglevel) + }) } +const output = [] + const log = { error: () => null, } t.afterEach(() => { npm.color = false - npmlog.level = 'warn' log.error = () => null output.length = 0 RUN_SCRIPTS.length = 0 @@ -58,7 +61,6 @@ const getRS = windows => { isServerPackage: require('@npmcli/run-script').isServerPackage, } ), - npmlog, 'proc-log': log, '../../../lib/utils/is-windows-shell.js': windows, }) @@ -359,10 +361,7 @@ t.test('skip pre/post hooks when using ignoreScripts', async t => { }) t.test('run silent', async t => { - npmlog.level = 'silent' - t.teardown(() => { - npmlog.level = 'warn' - }) + setLoglevel(t, 'silent') npm.localPrefix = t.testdir({ 'package.json': JSON.stringify({ @@ -440,12 +439,11 @@ t.test('list scripts', t => { }) t.test('silent', async t => { - npmlog.level = 'silent' + setLoglevel(t, 'silent') await runScript.exec([]) t.strictSame(output, []) }) t.test('warn json', async t => { - npmlog.level = 'warn' config.json = true await runScript.exec([]) t.strictSame(output, [[JSON.stringify(scripts, 0, 2)]], 'json report') @@ -723,7 +721,7 @@ t.test('workspaces', t => { }) t.test('list no scripts --loglevel=silent', async t => { - npmlog.level = 'silent' + setLoglevel(t, 'silent') await runScript.execWorkspaces([], []) t.strictSame(output, []) }) @@ -860,7 +858,6 @@ t.test('workspaces', t => { '@npmcli/run-script': () => { throw new Error('err') }, - npmlog, 'proc-log': log, '../../../lib/utils/is-windows-shell.js': false, }) @@ -879,7 +876,6 @@ t.test('workspaces', t => { RUN_SCRIPTS.push(opts) }, - npmlog, 'proc-log': log, '../../../lib/utils/is-windows-shell.js': false, }) diff --git a/test/lib/commands/star.js b/test/lib/commands/star.js index 2f4ddc9dc6439..4d19b32e1d258 100644 --- a/test/lib/commands/star.js +++ b/test/lib/commands/star.js @@ -42,10 +42,9 @@ t.test('no args', async t => { }) t.test('star a package', async t => { - t.plan(6) + t.plan(4) const pkgName = '@npmcli/arborist' npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') return { _id: pkgName, _rev: 'hash', @@ -70,11 +69,10 @@ t.test('star a package', async t => { }) t.test('unstar a package', async t => { - t.plan(6) + t.plan(4) const pkgName = '@npmcli/arborist' config['star.unstar'] = true npmFetch.json = async (uri, opts) => { - t.ok(opts.log, 'is passed a logger') return { _id: pkgName, _rev: 'hash', diff --git a/test/lib/commands/team.js b/test/lib/commands/team.js index 96260835fa2b6..0d5378b530647 100644 --- a/test/lib/commands/team.js +++ b/test/lib/commands/team.js @@ -1,4 +1,5 @@ const t = require('tap') +const { fake: mockNpm } = require('../../fixtures/mock-npm') let result = '' const libnpmteam = { @@ -9,12 +10,15 @@ const libnpmteam = { async lsUsers () {}, async rm () {}, } -const npm = { +const npm = mockNpm({ flatOptions: {}, + config: { + loglevel: 'info', + }, output: (...msg) => { result += msg.join('\n') }, -} +}) const mocks = { libnpmteam, 'cli-columns': a => a.join(' '), @@ -25,6 +29,7 @@ const mocks = { t.afterEach(() => { result = '' npm.flatOptions = {} + npm.config.set('loglevel', 'info') }) const Team = t.mock('../../../lib/commands/team.js', mocks) @@ -73,7 +78,7 @@ t.test('team add ', async t => { }) t.test('--silent', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') await team.exec(['add', '@npmcli:developers', 'foo']) @@ -115,7 +120,7 @@ t.test('team create ', async t => { }) t.test('--silent', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') await team.exec(['create', '@npmcli:newteam']) @@ -149,7 +154,7 @@ t.test('team destroy ', async t => { }) t.test('--silent', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') await team.exec(['destroy', '@npmcli:newteam']) t.same(result, '', 'should not output destroy if silent') }) @@ -198,7 +203,7 @@ t.test('team ls ', async t => { }) t.test('--silent', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') await team.exec(['ls', '@npmcli']) t.same(result, '', 'should not list teams if silent') }) @@ -278,7 +283,7 @@ t.test('team ls ', async t => { }) t.test('--silent', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') await team.exec(['ls', '@npmcli:developers']) t.same(result, '', 'should not output users if silent') }) @@ -345,7 +350,7 @@ t.test('team rm ', async t => { }) t.test('--silent', async t => { - npm.flatOptions.silent = true + npm.config.set('loglevel', 'silent') await team.exec(['rm', '@npmcli:newteam', 'foo']) t.same(result, '', 'should not output rm result if silent') }) diff --git a/test/lib/commands/unpublish.js b/test/lib/commands/unpublish.js index 99d55294fbacf..b9c94e5d5265f 100644 --- a/test/lib/commands/unpublish.js +++ b/test/lib/commands/unpublish.js @@ -22,7 +22,6 @@ const singleVersion = async () => { const config = { force: false, - loglevel: 'silly', } const testDir = t.testdir({ @@ -54,7 +53,7 @@ t.afterEach(() => { result = '' config['dry-run'] = false config.force = false - config.loglevel = 'silly' + npm.config.set('loglevel', 'info') }) t.test('no args --force', async t => { @@ -76,7 +75,6 @@ t.test('no args --force', async t => { const libnpmpublish = { unpublish (spec, opts) { - t.ok(opts.log, 'gets passed a logger') t.equal(spec.raw, 'pkg@1.0.0', 'should unpublish expected spec') t.match( opts, @@ -178,7 +176,6 @@ t.test('unpublish @version', async t => { const libnpmpublish = { unpublish (spec, opts) { - t.ok(opts.log, 'gets passed a logger') t.equal(spec.raw, 'pkg@1.0.0', 'should unpublish expected parsed spec') }, } @@ -240,7 +237,7 @@ t.test('unpublish --force no version set', async t => { }) t.test('silent', async t => { - config.loglevel = 'silent' + npm.config.set('loglevel', 'silent') const Unpublish = t.mock('../../../lib/commands/unpublish.js', { ...mocks, diff --git a/test/lib/commands/update.js b/test/lib/commands/update.js index 2b464bfabbfcd..ae9376466128a 100644 --- a/test/lib/commands/update.js +++ b/test/lib/commands/update.js @@ -27,7 +27,7 @@ t.afterEach(() => { }) t.test('no args', async t => { - t.plan(5) + t.plan(4) npm.prefix = '/project/a' @@ -44,7 +44,6 @@ t.test('no args', async t => { }, 'should call arborist contructor with expected args' ) - t.match(log, {}, 'log is passed in') } reify ({ save, update }) { @@ -66,7 +65,7 @@ t.test('no args', async t => { }) t.test('with args', async t => { - t.plan(5) + t.plan(4) npm.prefix = '/project/a' config.save = true @@ -84,7 +83,6 @@ t.test('with args', async t => { }, 'should call arborist contructor with expected args' ) - t.match(log, {}, 'log is passed in') } reify ({ save, update }) { @@ -130,7 +128,7 @@ t.test('update --depth=', async t => { }) t.test('update --global', async t => { - t.plan(3) + t.plan(2) const normalizePath = p => p.replace(/\\+/g, '/') const redactCwd = (path) => normalizePath(path) @@ -149,8 +147,6 @@ t.test('update --global', async t => { 'should call arborist contructor with expected options' ) - t.match(log, {}, 'log is passed in') - t.equal( redactCwd(path), '{CWD}/global/lib', diff --git a/test/lib/utils/config/definitions.js b/test/lib/utils/config/definitions.js index bf4b48709ae7b..a5b34a7499fbe 100644 --- a/test/lib/utils/config/definitions.js +++ b/test/lib/utils/config/definitions.js @@ -929,3 +929,12 @@ t.test('lockfile version', t => { t.match(flat.lockfileVersion, 3, 'flattens to a number') t.end() }) + +t.test('loglevel silent', t => { + const flat = {} + definitions.loglevel.flatten('loglevel', { + loglevel: 'silent', + }, flat) + t.match(flat.silent, true, 'flattens to assign silent') + t.end() +}) diff --git a/test/lib/utils/exit-handler.js b/test/lib/utils/exit-handler.js index 54bf48f89b0dd..6a96d92ddb250 100644 --- a/test/lib/utils/exit-handler.js +++ b/test/lib/utils/exit-handler.js @@ -89,9 +89,9 @@ const mockExitHandler = async (t, { init, load, testdir, config } = {}) => { ...rest, errors, npm, - // // Make it async to make testing ergonomics a little - // // easier so we dont need to t.plan() every test to - // // make sure we get process.exit called + // Make it async to make testing ergonomics a little + // easier so we dont need to t.plan() every test to + // make sure we get process.exit called exitHandler: (...args) => new Promise(resolve => { process.once('exit', resolve) exitHandler(...args) diff --git a/test/lib/utils/reify-output.js b/test/lib/utils/reify-output.js index 4e9ed7133c18c..b38a14de33909 100644 --- a/test/lib/utils/reify-output.js +++ b/test/lib/utils/reify-output.js @@ -1,9 +1,4 @@ const t = require('tap') -const log = require('../../../lib/utils/log-shim') - -const _level = log.level -t.beforeEach(() => log.level = 'warn') -t.teardown(() => log.level = _level) t.cleanSnapshot = str => str.replace(/in [0-9]+m?s/g, 'in {TIME}') @@ -13,6 +8,7 @@ const settings = { const npm = { started: Date.now(), flatOptions: settings, + silent: false, } const reifyOutput = require('../../../lib/utils/reify-output.js') t.test('missing info', (t) => { @@ -236,10 +232,13 @@ t.test('showing and not showing audit report', async t => { } t.test('no output when silent', t => { + t.teardown(() => { + delete npm.silent + }) + npm.silent = true npm.output = out => { t.fail('should not get output when silent', { actual: out }) } - log.level = 'silent' reifyOutput(npm, { actualTree: { inventory: { size: 999 }, children: [] }, auditReport, diff --git a/test/lib/utils/update-notifier.js b/test/lib/utils/update-notifier.js index a7a800c602fd6..fa4af29476f12 100644 --- a/test/lib/utils/update-notifier.js +++ b/test/lib/utils/update-notifier.js @@ -84,12 +84,11 @@ t.afterEach(() => { }) const runUpdateNotifier = async ({ color = true, ...npmOptions } = {}) => { - const _npm = { ...defaultNpm, ...npmOptions } + const _npm = { ...defaultNpm, ...npmOptions, logColor: color } await t.mock('../../../lib/utils/update-notifier.js', { '@npmcli/ci-detect': () => ciMock, pacote, fs, - npmlog: { useColor: () => color }, })(_npm) return _npm.updateNotification } diff --git a/workspaces/arborist/lib/add-rm-pkg-deps.js b/workspaces/arborist/lib/add-rm-pkg-deps.js index ae813186fb712..f59df359e9456 100644 --- a/workspaces/arborist/lib/add-rm-pkg-deps.js +++ b/workspaces/arborist/lib/add-rm-pkg-deps.js @@ -1,10 +1,11 @@ // add and remove dependency specs to/from pkg manifest +const log = require('proc-log') const localeCompare = require('@isaacs/string-locale-compare')('en') -const add = ({ pkg, add, saveBundle, saveType, log }) => { +const add = ({ pkg, add, saveBundle, saveType }) => { for (const spec of add) { - addSingle({ pkg, spec, saveBundle, saveType, log }) + addSingle({ pkg, spec, saveBundle, saveType }) } return pkg @@ -20,7 +21,7 @@ const saveTypeMap = new Map([ ['peer', 'peerDependencies'], ]) -const addSingle = ({ pkg, spec, saveBundle, saveType, log }) => { +const addSingle = ({ pkg, spec, saveBundle, saveType }) => { const { name, rawSpec } = spec // if the user does not give us a type, we infer which type(s) @@ -34,19 +35,19 @@ const addSingle = ({ pkg, spec, saveBundle, saveType, log }) => { if (saveType === 'prod') { // a production dependency can only exist as production (rpj ensures it // doesn't coexist w/ optional) - deleteSubKey(pkg, 'devDependencies', name, 'dependencies', log) - deleteSubKey(pkg, 'peerDependencies', name, 'dependencies', log) + deleteSubKey(pkg, 'devDependencies', name, 'dependencies') + deleteSubKey(pkg, 'peerDependencies', name, 'dependencies') } else if (saveType === 'dev') { // a dev dependency may co-exist as peer, or optional, but not production - deleteSubKey(pkg, 'dependencies', name, 'devDependencies', log) + deleteSubKey(pkg, 'dependencies', name, 'devDependencies') } else if (saveType === 'optional') { // an optional dependency may co-exist as dev (rpj ensures it doesn't // coexist w/ prod) - deleteSubKey(pkg, 'peerDependencies', name, 'optionalDependencies', log) + deleteSubKey(pkg, 'peerDependencies', name, 'optionalDependencies') } else { // peer or peerOptional is all that's left // a peer dependency may coexist as dev - deleteSubKey(pkg, 'dependencies', name, 'peerDependencies', log) - deleteSubKey(pkg, 'optionalDependencies', name, 'peerDependencies', log) + deleteSubKey(pkg, 'dependencies', name, 'peerDependencies') + deleteSubKey(pkg, 'optionalDependencies', name, 'peerDependencies') } const depType = saveTypeMap.get(saveType) @@ -108,9 +109,9 @@ const hasSubKey = (pkg, depType, name) => { } // Removes a subkey and warns about it if it's being replaced -const deleteSubKey = (pkg, depType, name, replacedBy, log) => { +const deleteSubKey = (pkg, depType, name, replacedBy) => { if (hasSubKey(pkg, depType, name)) { - if (replacedBy && log) { + if (replacedBy) { log.warn('idealTree', `Removing ${depType}.${name} in favor of ${replacedBy}.${name}`) } delete pkg[depType][name] diff --git a/workspaces/arborist/lib/arborist/build-ideal-tree.js b/workspaces/arborist/lib/arborist/build-ideal-tree.js index b7bc56f3e9797..3f001f9e9eb10 100644 --- a/workspaces/arborist/lib/arborist/build-ideal-tree.js +++ b/workspaces/arborist/lib/arborist/build-ideal-tree.js @@ -14,6 +14,7 @@ const fs = require('fs') const lstat = promisify(fs.lstat) const readlink = promisify(fs.readlink) const { depth } = require('treeverse') +const log = require('proc-log') const { OK, @@ -248,7 +249,7 @@ module.exports = cls => class IdealTreeBuilder extends cls { try { c() } catch (er) { - this.log.warn(er.code, er.message, { + log.warn(er.code, er.message, { package: er.pkgid, required: er.required, current: er.current, @@ -532,7 +533,6 @@ Try using the package name instead, e.g: saveBundle, saveType, path: this.path, - log: this.log, }) }) } @@ -602,7 +602,7 @@ Try using the package name instead, e.g: // be printed by npm-audit-report as if they can be fixed, because // they can't. if (bundler) { - this.log.warn(`audit fix ${node.name}@${node.version}`, + log.warn(`audit fix ${node.name}@${node.version}`, `${node.location}\nis a bundled dependency of\n${ bundler.name}@${bundler.version} at ${bundler.location}\n` + 'It cannot be fixed automatically.\n' + @@ -637,14 +637,14 @@ Try using the package name instead, e.g: if (!node.isProjectRoot && !node.isWorkspace) { // not something we're going to fix, sorry. have to cd into // that directory and fix it yourself. - this.log.warn('audit', 'Manual fix required in linked project ' + + log.warn('audit', 'Manual fix required in linked project ' + `at ./${node.location} for ${name}@${simpleRange}.\n` + `'cd ./${node.location}' and run 'npm audit' for details.`) continue } if (!fixAvailable) { - this.log.warn('audit', `No fix available for ${name}@${simpleRange}`) + log.warn('audit', `No fix available for ${name}@${simpleRange}`) continue } @@ -652,7 +652,7 @@ Try using the package name instead, e.g: const breakingMessage = isSemVerMajor ? 'a SemVer major change' : 'outside your stated dependency range' - this.log.warn('audit', `Updating ${name} to ${version},` + + log.warn('audit', `Updating ${name} to ${version},` + `which is ${breakingMessage}.`) await this[_add](node, { add: [`${name}@${version}`] }) @@ -727,7 +727,7 @@ Try using the package name instead, e.g: const heading = ancient ? 'ancient lockfile' : 'old lockfile' if (ancient || !this.options.lockfileVersion || this.options.lockfileVersion >= defaultLockfileVersion) { - this.log.warn(heading, + log.warn(heading, ` The ${meta.type} file was created with an old version of npm, so supplemental metadata must be fetched from the registry. @@ -744,7 +744,7 @@ This is a one-time fix-up, please be patient... } queue.push(async () => { - this.log.silly('inflate', node.location) + log.silly('inflate', node.location) const { resolved, version, path, name, location, integrity } = node // don't try to hit the registry for linked deps const useResolved = resolved && ( @@ -753,8 +753,7 @@ This is a one-time fix-up, please be patient... const id = useResolved ? resolved : version || `file:${node.path}` const spec = npa.resolve(name, id, dirname(path)) - const sloc = location.substr('node_modules/'.length) - const t = `idealTree:inflate:${sloc}` + const t = `idealTree:inflate:${location}` this.addTracker(t) await pacote.manifest(spec, { ...this.options, @@ -765,7 +764,7 @@ This is a one-time fix-up, please be patient... node.package = { ...mani, _id: `${mani.name}@${mani.version}` } }).catch((er) => { const warning = `Could not fetch metadata for ${name}@${id}` - this.log.warn(heading, warning, er) + log.warn(heading, warning, er) }) this.finishTracker(t) }) @@ -794,7 +793,7 @@ This is a one-time fix-up, please be patient... this[_depsQueue].push(tree) // XXX also push anything that depends on a node with a name // in the override list - this.log.silly('idealTree', 'buildDeps') + log.silly('idealTree', 'buildDeps') this.addTracker('idealTree', tree.name, '') return this[_buildDepStep]() .then(() => process.emit('timeEnd', 'idealTree:buildDeps')) @@ -1233,7 +1232,7 @@ This is a one-time fix-up, please be patient... if (this[_manifests].has(spec.raw)) { return this[_manifests].get(spec.raw) } else { - this.log.silly('fetch manifest', spec.raw) + log.silly('fetch manifest', spec.raw) const p = pacote.manifest(spec, options) .then(mani => { this[_manifests].set(spec.raw, mani) diff --git a/workspaces/arborist/lib/arborist/index.js b/workspaces/arborist/lib/arborist/index.js index de625e9b7684f..cb6ef1e0c2ccb 100644 --- a/workspaces/arborist/lib/arborist/index.js +++ b/workspaces/arborist/lib/arborist/index.js @@ -28,7 +28,6 @@ const { resolve } = require('path') const { homedir } = require('os') -const procLog = require('proc-log') const { depth } = require('treeverse') const { saveTypeMap } = require('../add-rm-pkg-deps.js') @@ -74,7 +73,6 @@ class Arborist extends Base { path: options.path || '.', cache: options.cache || `${homedir()}/.npm/_cacache`, packumentCache: options.packumentCache || new Map(), - log: options.log || procLog, workspacesEnabled: options.workspacesEnabled !== false, lockfileVersion: lockfileVersion(options.lockfileVersion), } @@ -94,7 +92,7 @@ class Arborist extends Base { // returns an array of the actual nodes for all the workspaces workspaceNodes (tree, workspaces) { - return getWorkspaceNodes(tree, workspaces, this.log) + return getWorkspaceNodes(tree, workspaces) } // returns a set of workspace nodes and all their deps diff --git a/workspaces/arborist/lib/arborist/rebuild.js b/workspaces/arborist/lib/arborist/rebuild.js index 1a05e52735376..09b4419f5b5dc 100644 --- a/workspaces/arborist/lib/arborist/rebuild.js +++ b/workspaces/arborist/lib/arborist/rebuild.js @@ -13,6 +13,7 @@ const { isNodeGypPackage, defaultGypInstallScript, } = require('@npmcli/node-gyp') +const log = require('proc-log') const boolEnv = b => b ? '1' : '' const sortNodes = (a, b) => @@ -297,7 +298,7 @@ module.exports = cls => class Builder extends cls { const timer = `build:run:${event}:${location}` process.emit('time', timer) - this.log.info('run', pkg._id, event, location, pkg.scripts[event]) + log.info('run', pkg._id, event, location, pkg.scripts[event]) const env = { npm_package_resolved: resolved, npm_package_integrity: integrity, @@ -319,7 +320,7 @@ module.exports = cls => class Builder extends cls { } const p = runScript(runOpts).catch(er => { const { code, signal } = er - this.log.info('run', pkg._id, event, { code, signal }) + log.info('run', pkg._id, event, { code, signal }) throw er }).then(({ args, code, signal, stdout, stderr }) => { this.scriptsRun.add({ @@ -333,7 +334,7 @@ module.exports = cls => class Builder extends cls { stdout, stderr, }) - this.log.info('run', pkg._id, event, { code, signal }) + log.info('run', pkg._id, event, { code, signal }) }) await (this[_doHandleOptionalFailure] diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index 91507fd791871..50061e722661b 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -8,6 +8,7 @@ const npa = require('npm-package-arg') const semver = require('semver') const debug = require('../debug.js') const walkUp = require('walk-up-path') +const log = require('proc-log') const { dirname, resolve, relative } = require('path') const { depth: dfwalk } = require('treeverse') @@ -390,7 +391,7 @@ module.exports = cls => class Reifier extends cls { [_addNodeToTrashList] (node, retire = false) { const paths = [node.path, ...node.binPaths] const moves = this[_retiredPaths] - this.log.silly('reify', 'mark', retire ? 'retired' : 'deleted', paths) + log.silly('reify', 'mark', retire ? 'retired' : 'deleted', paths) for (const path of paths) { if (retire) { const retired = retirePath(path) @@ -413,7 +414,7 @@ module.exports = cls => class Reifier extends cls { this[_addNodeToTrashList](diff.actual, true) } } - this.log.silly('reify', 'moves', moves) + log.silly('reify', 'moves', moves) const movePromises = Object.entries(moves) .map(([from, to]) => this[_renamePath](from, to)) return promiseAllRejectLate(movePromises) @@ -532,7 +533,7 @@ module.exports = cls => class Reifier extends cls { return promiseAllRejectLate(unlinks) .then(() => { if (failures.length) { - this.log.warn('cleanup', 'Failed to remove some directories', failures) + log.warn('cleanup', 'Failed to remove some directories', failures) } }) .then(() => process.emit('timeEnd', 'reify:rollback:createSparse')) @@ -624,7 +625,7 @@ module.exports = cls => class Reifier extends cls { this[_nmValidated].add(nm) return } - this.log.warn('reify', 'Removing non-directory', nm) + log.warn('reify', 'Removing non-directory', nm) await rimraf(nm) } @@ -647,8 +648,8 @@ module.exports = cls => class Reifier extends cls { 'please re-try this operation once it completes\n' + 'so that the damage can be corrected, or perform\n' + 'a fresh install with no lockfile if the problem persists.' - this.log.warn('reify', warning) - this.log.verbose('reify', 'unrecognized node in tree', node.path) + log.warn('reify', warning) + log.verbose('reify', 'unrecognized node in tree', node.path) node.parent = null node.fsParent = null this[_addNodeToTrashList](node) @@ -691,7 +692,7 @@ module.exports = cls => class Reifier extends cls { [_warnDeprecated] (node) { const { _id, deprecated } = node.package if (deprecated) { - this.log.warn('deprecated', `${_id}: ${deprecated}`) + log.warn('deprecated', `${_id}: ${deprecated}`) } } @@ -701,7 +702,7 @@ module.exports = cls => class Reifier extends cls { return (node.optional ? p.catch(er => { const set = optionalSet(node) for (node of set) { - this.log.verbose('reify', 'failed optional dependency', node.path) + log.verbose('reify', 'failed optional dependency', node.path) this[_addNodeToTrashList](node) } }) : p).then(() => node) @@ -1129,7 +1130,7 @@ module.exports = cls => class Reifier extends cls { return promiseAllRejectLate(promises).then(() => { if (failures.length) { - this.log.warn('cleanup', 'Failed to remove some directories', failures) + log.warn('cleanup', 'Failed to remove some directories', failures) } }) .then(() => process.emit('timeEnd', 'reify:trash')) diff --git a/workspaces/arborist/lib/audit-report.js b/workspaces/arborist/lib/audit-report.js index b7d8249b12ddc..4dc6dd177c1e4 100644 --- a/workspaces/arborist/lib/audit-report.js +++ b/workspaces/arborist/lib/audit-report.js @@ -13,7 +13,7 @@ const _fixAvailable = Symbol('fixAvailable') const _checkTopNode = Symbol('checkTopNode') const _init = Symbol('init') const _omit = Symbol('omit') -const procLog = require('proc-log') +const log = require('proc-log') const fetch = require('npm-registry-fetch') @@ -98,14 +98,13 @@ class AuditReport extends Map { this.calculator = new Calculator(opts) this.error = null this.options = opts - this.log = opts.log || procLog this.tree = tree this.filterSet = opts.filterSet } async run () { this.report = await this[_getReport]() - this.log.silly('audit report', this.report) + log.silly('audit report', this.report) if (this.report) { await this[_init]() } @@ -313,7 +312,7 @@ class AuditReport extends Map { try { // first try the super fast bulk advisory listing const body = prepareBulkData(this.tree, this[_omit], this.filterSet) - this.log.silly('audit', 'bulk request', body) + log.silly('audit', 'bulk request', body) // no sense asking if we don't have anything to audit, // we know it'll be empty @@ -331,7 +330,7 @@ class AuditReport extends Map { return await res.json() } catch (er) { - this.log.silly('audit', 'bulk request failed', String(er.body)) + log.silly('audit', 'bulk request failed', String(er.body)) // that failed, try the quick audit endpoint const body = prepareData(this.tree, this.options) const res = await fetch('/-/npm/v1/security/audits/quick', { @@ -344,8 +343,8 @@ class AuditReport extends Map { return AuditReport.auditToBulk(await res.json()) } } catch (er) { - this.log.verbose('audit error', er) - this.log.silly('audit error', String(er.body)) + log.verbose('audit error', er) + log.silly('audit error', String(er.body)) this.error = er return null } finally { diff --git a/workspaces/arborist/lib/get-workspace-nodes.js b/workspaces/arborist/lib/get-workspace-nodes.js index 6db489f69c518..91002dab57085 100644 --- a/workspaces/arborist/lib/get-workspace-nodes.js +++ b/workspaces/arborist/lib/get-workspace-nodes.js @@ -1,7 +1,10 @@ // Get the actual nodes corresponding to a root node's child workspaces, // given a list of workspace names. + +const log = require('proc-log') const relpath = require('./relpath.js') -const getWorkspaceNodes = (tree, workspaces, log) => { + +const getWorkspaceNodes = (tree, workspaces) => { const wsMap = tree.workspaces if (!wsMap) { log.warn('workspaces', 'filter set, but no workspaces present') diff --git a/workspaces/arborist/lib/shrinkwrap.js b/workspaces/arborist/lib/shrinkwrap.js index bb6971f7ad57a..35300f75000bd 100644 --- a/workspaces/arborist/lib/shrinkwrap.js +++ b/workspaces/arborist/lib/shrinkwrap.js @@ -33,7 +33,7 @@ const mismatch = (a, b) => a && b && a !== b // After calling this.commit(), any nodes not present in the tree will have // been removed from the shrinkwrap data as well. -const procLog = require('proc-log') +const log = require('proc-log') const YarnLock = require('./yarn-lock.js') const { promisify } = require('util') const rimraf = promisify(require('rimraf')) @@ -329,14 +329,12 @@ class Shrinkwrap { newline = '\n', shrinkwrapOnly = false, hiddenLockfile = false, - log = procLog, lockfileVersion, } = options this.lockfileVersion = hiddenLockfile ? 3 : lockfileVersion ? parseInt(lockfileVersion, 10) : null - this.log = log this[_awaitingUpdate] = new Map() this.tree = null this.path = resolve(path || '.') @@ -479,9 +477,9 @@ class Shrinkwrap { /* istanbul ignore else */ if (typeof this.filename === 'string') { const rel = relpath(this.path, this.filename) - this.log.verbose('shrinkwrap', `failed to load ${rel}`, er) + log.verbose('shrinkwrap', `failed to load ${rel}`, er) } else { - this.log.verbose('shrinkwrap', `failed to load ${this.path}`, er) + log.verbose('shrinkwrap', `failed to load ${this.path}`, er) } this.loadingError = er this.loadedFromDisk = false diff --git a/workspaces/arborist/lib/tracker.js b/workspaces/arborist/lib/tracker.js index b50f06eaa5518..c2a456e4832cc 100644 --- a/workspaces/arborist/lib/tracker.js +++ b/workspaces/arborist/lib/tracker.js @@ -1,20 +1,14 @@ const _progress = Symbol('_progress') const _onError = Symbol('_onError') -const procLog = require('proc-log') +const npmlog = require('npmlog') module.exports = cls => class Tracker extends cls { constructor (options = {}) { super(options) - this.log = options.log || procLog this[_progress] = new Map() } addTracker (section, subsection = null, key = null) { - // TrackerGroup type object not found - if (!this.log.newGroup) { - return - } - if (section === null || section === undefined) { this[_onError](`Tracker can't be null or undefined`) } @@ -31,13 +25,13 @@ module.exports = cls => class Tracker extends cls { this[_onError](`Tracker "${section}" already exists`) } else if (!hasTracker && subsection === null) { // 1. no existing tracker, no subsection - // Create a new tracker from this.log + // Create a new tracker from npmlog // starts progress bar if (this[_progress].size === 0) { - this.log.enableProgress() + npmlog.enableProgress() } - this[_progress].set(section, this.log.newGroup(section)) + this[_progress].set(section, npmlog.newGroup(section)) } else if (!hasTracker && subsection !== null) { // 2. no parent tracker and subsection this[_onError](`Parent tracker "${section}" does not exist`) @@ -53,11 +47,6 @@ module.exports = cls => class Tracker extends cls { } finishTracker (section, subsection = null, key = null) { - // TrackerGroup type object not found - if (!this.log.newGroup) { - return - } - if (section === null || section === undefined) { this[_onError](`Tracker can't be null or undefined`) } @@ -88,7 +77,7 @@ module.exports = cls => class Tracker extends cls { // remove progress bar if all // trackers are finished if (this[_progress].size === 0) { - this.log.disableProgress() + npmlog.disableProgress() } } else if (!hasTracker && subsection === null) { // 1. no existing parent tracker, no subsection @@ -103,7 +92,7 @@ module.exports = cls => class Tracker extends cls { } [_onError] (msg) { - this.log.disableProgress() + npmlog.disableProgress() throw new Error(msg) } } diff --git a/workspaces/arborist/package.json b/workspaces/arborist/package.json index a915c9d8b1f6f..3864d55d94568 100644 --- a/workspaces/arborist/package.json +++ b/workspaces/arborist/package.json @@ -6,7 +6,7 @@ "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/installed-package-contents": "^1.0.7", "@npmcli/map-workspaces": "^2.0.0", - "@npmcli/metavuln-calculator": "^2.0.0", + "@npmcli/metavuln-calculator": "^3.0.0", "@npmcli/move-file": "^1.1.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.3", @@ -20,12 +20,13 @@ "mkdirp": "^1.0.4", "mkdirp-infer-owner": "^2.0.0", "npm-install-checks": "^4.0.0", - "npm-package-arg": "^8.1.5", - "npm-pick-manifest": "^6.1.0", - "npm-registry-fetch": "^12.0.1", - "pacote": "^12.0.2", + "npm-package-arg": "^9.0.0", + "npm-pick-manifest": "^7.0.0", + "npm-registry-fetch": "^13.0.0", + "npmlog": "^6.0.1", + "pacote": "^13.0.2", "parse-conflict-json": "^2.0.1", - "proc-log": "^1.0.0", + "proc-log": "^2.0.0", "promise-all-reject-late": "^1.0.0", "promise-call-limit": "^1.0.1", "read-package-json-fast": "^2.0.2", diff --git a/workspaces/arborist/test/add-rm-pkg-deps.js b/workspaces/arborist/test/add-rm-pkg-deps.js index 54485f7bc84d1..77ea2bd61e550 100644 --- a/workspaces/arborist/test/add-rm-pkg-deps.js +++ b/workspaces/arborist/test/add-rm-pkg-deps.js @@ -10,13 +10,14 @@ t.test('add', t => { const file = npa('file@file:/some/path/foo.tgz', '/') const logs = [] - const log = { - warn: function (...args) { + const log = (l, ...args) => { + if (l === 'warn') { logs.push(args) - }, + } } + process.on('log', log) + t.teardown(() => process.off('log', log)) t.strictSame(add({ - log, pkg: { dependencies: { bar: '1' }, devDependencies: { foo: '2' }, diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index 7fb1f1f2bfdf8..11d478a5421aa 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -1075,6 +1075,7 @@ t.test('scoped registries', async t => { registry, }) const kReify = Symbol.for('reifyNode') + a.addTracker('reify') a.idealTree = new Node({ path }) const node = new Node({ diff --git a/workspaces/arborist/test/get-workspace-nodes.js b/workspaces/arborist/test/get-workspace-nodes.js index fa259a8fea9fd..3de4d73da7b9f 100644 --- a/workspaces/arborist/test/get-workspace-nodes.js +++ b/workspaces/arborist/test/get-workspace-nodes.js @@ -4,8 +4,6 @@ const Arborist = require('../lib/arborist/index.js') const { resolve } = require('path') const path = resolve(__dirname, './fixtures/workspaces-shared-deps-virtual') -const log = require('proc-log') - const warningTracker = () => { const list = [] const onlog = (...msg) => msg[0] === 'warn' && list.push(msg) @@ -23,7 +21,7 @@ t.before(async () => { t.test('basic behavior', t => { const getLogs = warningTracker() - const wsNodes = getWorkspaceNodes(tree, ['a'], log) + const wsNodes = getWorkspaceNodes(tree, ['a']) t.equal(wsNodes.length, 1) t.equal(wsNodes[0], tree.children.get('a').target) t.same(getLogs(), []) @@ -32,7 +30,7 @@ t.test('basic behavior', t => { t.test('filter set, but no workspaces present', t => { const getLogs = warningTracker() - const wsNodes = getWorkspaceNodes(tree.children.get('b').target, ['xyz'], log) + const wsNodes = getWorkspaceNodes(tree.children.get('b').target, ['xyz']) t.same(wsNodes, []) t.same(getLogs(), [ ['warn', 'workspaces', 'filter set, but no workspaces present'], @@ -42,7 +40,7 @@ t.test('filter set, but no workspaces present', t => { t.test('name in filter set, but not in workspaces', t => { const getLogs = warningTracker() - const wsNodes = getWorkspaceNodes(tree, ['xyz'], log) + const wsNodes = getWorkspaceNodes(tree, ['xyz']) t.same(wsNodes, []) t.same(getLogs(), [ ['warn', 'workspaces', 'xyz in filter set, but not in workspaces'], @@ -57,7 +55,7 @@ t.test('name in filter set, but no workspace folder present', t => { // but if we start moving things around and make a mistake, it's // possible to get there. tree.children.get('c').target.root = null - const wsNodes = getWorkspaceNodes(tree, ['c'], log) + const wsNodes = getWorkspaceNodes(tree, ['c']) t.same(wsNodes, []) t.same(getLogs(), [ ['warn', 'workspaces', 'c in filter set, but no workspace folder present'], diff --git a/workspaces/arborist/test/tracker.js b/workspaces/arborist/test/tracker.js index 03ece91a3b0b8..0c2fbb729d45e 100644 --- a/workspaces/arborist/test/tracker.js +++ b/workspaces/arborist/test/tracker.js @@ -1,15 +1,6 @@ const Tracker = require('../lib/tracker.js')(class {}) const t = require('tap') -const npmlog = { - newGroup: () => ({ - newGroup: () => ({ finish: () => {} }), - finish: () => {}, - }), - enableProgress: () => {}, - disableProgress: () => {}, -} - t.test('no npmlog', t => { const tr = new Tracker() t.doesNotThrow(() => { @@ -24,27 +15,27 @@ t.test('no npmlog', t => { t.test('adds tracker', t => { t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') }) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.addTracker('testTracker', 'subTracker') }) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.addTracker('testTracker', 'subTracker') tr.addTracker('testTracker', 'subTracker') }) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.addTracker('testTracker', 'subTracker.name', 'subTracker.key') }) - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() t.throws(() => { tr.addTracker() }, Error, `Tracker can't be null or undefined`) @@ -70,19 +61,19 @@ t.test('adds tracker', t => { t.test('finishes tracker', t => { t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.finishTracker('testTracker') }) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.addTracker('testTracker', 'subTracker') tr.finishTracker('testTracker', 'subTracker') tr.finishTracker('testTracker') }) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.addTracker('testTracker', 'subTracker.name', 'subTracker.key') tr.finishTracker('testTracker', 'subTracker.name', 'subTracker.key') @@ -90,14 +81,14 @@ t.test('finishes tracker', t => { }) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('firstTracker') tr.addTracker('secondTracker') tr.finishTracker('firstTracker') tr.finishTracker('secondTracker') }) - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() t.throws(() => { tr.finishTracker() }, Error, `Tracker can't be null or undefined`) @@ -109,19 +100,19 @@ t.test('finishes tracker', t => { }, Error, `Tracker can't be null or undefined`) t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.addTracker('testTracker', 'testChild') tr.finishTracker('testTracker') }) t.throws(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.finishTracker('testTracker') }, Error, 'Tracker "testTracker" does not exist') t.doesNotThrow(() => { - const tr = new Tracker({ log: npmlog }) + const tr = new Tracker() tr.addTracker('testTracker') tr.finishTracker('testTracker', 'nonExistentSubTracker') }) diff --git a/workspaces/libnpmaccess/package.json b/workspaces/libnpmaccess/package.json index 760da6cc1be87..f32c1a3c8373e 100644 --- a/workspaces/libnpmaccess/package.json +++ b/workspaces/libnpmaccess/package.json @@ -31,8 +31,8 @@ "dependencies": { "aproba": "^2.0.0", "minipass": "^3.1.1", - "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^12.0.1" + "npm-package-arg": "^9.0.0", + "npm-registry-fetch": "^13.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" diff --git a/workspaces/libnpmdiff/package.json b/workspaces/libnpmdiff/package.json index 24846f39cf4fb..2d18763396f1e 100644 --- a/workspaces/libnpmdiff/package.json +++ b/workspaces/libnpmdiff/package.json @@ -53,8 +53,8 @@ "binary-extensions": "^2.2.0", "diff": "^5.0.0", "minimatch": "^3.0.4", - "npm-package-arg": "^8.1.4", - "pacote": "^12.0.0", + "npm-package-arg": "^9.0.0", + "pacote": "^13.0.2", "tar": "^6.1.0" }, "templateOSS": { diff --git a/workspaces/libnpmexec/README.md b/workspaces/libnpmexec/README.md index a48552714d5e6..74d6f5211e61d 100644 --- a/workspaces/libnpmexec/README.md +++ b/workspaces/libnpmexec/README.md @@ -35,7 +35,6 @@ await libexec({ - `color`: Output should use color? **Boolean**, defaults to `false` - `localBin`: Location to the `node_modules/.bin` folder of the local project to start scanning for bin files **String**, defaults to `./node_modules/.bin`. **libexec** will walk up the directory structure looking for `node_modules/.bin` folders in parent folders that might satisfy the current `arg` and will use that bin if found. - `locationMsg`: Overrides "at location" message when entering interactive mode **String** - - `log`: Sets an optional logger **Object**, defaults to `proc-log` module usage. - `globalBin`: Location to the global space bin folder, same as: `$(npm bin -g)` **String**, defaults to empty string. - `output`: A function to print output to **Function** - `packages`: A list of packages to be used (possibly fetch from the registry) **Array**, defaults to `[]` diff --git a/workspaces/libnpmexec/lib/index.js b/workspaces/libnpmexec/lib/index.js index facafb035d328..3c7be114913b5 100644 --- a/workspaces/libnpmexec/lib/index.js +++ b/workspaces/libnpmexec/lib/index.js @@ -4,7 +4,8 @@ const read = promisify(require('read')) const Arborist = require('@npmcli/arborist') const ciDetect = require('@npmcli/ci-detect') -const logger = require('proc-log') +const log = require('proc-log') +const npmlog = require('npmlog') const mkdirp = require('mkdirp-infer-owner') const npa = require('npm-package-arg') const pacote = require('pacote') @@ -39,7 +40,6 @@ const exec = async (opts) => { yes = undefined, ...flatOptions } = opts - const log = flatOptions.log || logger // dereferences values because we manipulate it later const packages = [..._packages] @@ -50,7 +50,6 @@ const exec = async (opts) => { color, flatOptions, locationMsg, - log, output, path, pathArr, @@ -169,9 +168,7 @@ const exec = async (opts) => { const prompt = `Need to install the following packages:\n${ addList }Ok to proceed? ` - if (typeof log.clearProgress === 'function') { - log.clearProgress() - } + npmlog.clearProgress() const confirm = await read({ prompt, default: 'y' }) if (confirm.trim().toLowerCase().charAt(0) !== 'y') { throw new Error('canceled') diff --git a/workspaces/libnpmexec/lib/run-script.js b/workspaces/libnpmexec/lib/run-script.js index 851f5c60bd0f1..97543e6ff0d08 100644 --- a/workspaces/libnpmexec/lib/run-script.js +++ b/workspaces/libnpmexec/lib/run-script.js @@ -4,6 +4,8 @@ const chalk = require('chalk') const ciDetect = require('@npmcli/ci-detect') const runScript = require('@npmcli/run-script') const readPackageJson = require('read-package-json-fast') +const npmlog = require('npmlog') +const log = require('proc-log') const noTTY = require('./no-tty.js') const nocolor = { @@ -18,7 +20,6 @@ const run = async ({ color, flatOptions, locationMsg, - log, output = () => {}, path, pathArr, @@ -41,9 +42,7 @@ const run = async ({ }, } - if (log && log.disableProgress) { - log.disableProgress() - } + npmlog.disableProgress() try { if (script === scriptShell) { @@ -80,9 +79,7 @@ const run = async ({ stdio: 'inherit', }) } finally { - if (log && log.enableProgress) { - log.enableProgress() - } + npmlog.enableProgress() } } diff --git a/workspaces/libnpmexec/package.json b/workspaces/libnpmexec/package.json index 4410f187ec66a..c88bfb16384df 100644 --- a/workspaces/libnpmexec/package.json +++ b/workspaces/libnpmexec/package.json @@ -55,9 +55,10 @@ "@npmcli/run-script": "^2.0.0", "chalk": "^4.1.0", "mkdirp-infer-owner": "^2.0.0", - "npm-package-arg": "^8.1.2", - "pacote": "^12.0.0", - "proc-log": "^1.0.0", + "npm-package-arg": "^9.0.0", + "npmlog": "^6.0.1", + "pacote": "^13.0.2", + "proc-log": "^2.0.0", "read": "^1.0.7", "read-package-json-fast": "^2.0.2", "walk-up-path": "^1.0.0" diff --git a/workspaces/libnpmexec/test/index.js b/workspaces/libnpmexec/test/index.js index cbd3eda727569..e44bc00c7a100 100644 --- a/workspaces/libnpmexec/test/index.js +++ b/workspaces/libnpmexec/test/index.js @@ -336,10 +336,12 @@ t.test('prompt, accepts', async t => { t.test('with clearProgress function', async t => { const libexec = t.mock('../lib/index.js', { '@npmcli/ci-detect': () => false, - 'proc-log': { + npmlog: { clearProgress () { t.ok(true, 'should call clearProgress function') }, + disableProgress () {}, + enableProgress () {}, }, read (opts, cb) { cb(null, 'y') @@ -365,7 +367,6 @@ t.test('prompt, accepts', async t => { t.test('without clearProgress function', async t => { const libexec = t.mock('../lib/index.js', { '@npmcli/ci-detect': () => false, - 'proc-log': {}, read (opts, cb) { cb(null, 'y') }, @@ -401,10 +402,11 @@ t.test('prompt, refuses', async t => { t.test('with clearProgress function', async t => { const libexec = t.mock('../lib/index.js', { '@npmcli/ci-detect': () => false, - 'proc-log': { + npmlog: { clearProgress () { t.ok(true, 'should call clearProgress function') }, + disableProgess () {}, }, read (opts, cb) { cb(null, 'n') @@ -439,7 +441,6 @@ t.test('prompt, refuses', async t => { t.test('without clearProgress function', async t => { const libexec = t.mock('../lib/index.js', { '@npmcli/ci-detect': () => false, - 'proc-log': {}, read (opts, cb) { cb(null, 'n') }, diff --git a/workspaces/libnpmexec/test/run-script.js b/workspaces/libnpmexec/test/run-script.js index c86e8e1514171..0b97a72ac04cb 100644 --- a/workspaces/libnpmexec/test/run-script.js +++ b/workspaces/libnpmexec/test/run-script.js @@ -4,9 +4,6 @@ const baseOpts = { args: [], call: '', color: false, - log: { - warn () {}, - }, path: '', pathArr: [''], runPath: '', @@ -29,20 +26,18 @@ t.test('disable, enable log progress', t => { t.ok('should call run-script') }, '../lib/no-tty.js': () => false, - }) - const log = { - ...baseOpts.log, - disableProgress () { - t.ok('should disable progress') - }, - enableProgress () { - t.ok('should enable progress') + npmlog: { + disableProgress () { + t.ok('should disable progress') + }, + enableProgress () { + t.ok('should enable progress') + }, }, - } + }) runScript({ ...baseOpts, - log, path, }) }) @@ -139,18 +134,17 @@ t.test('ci env', t => { throw new Error('should not call run-script') }, '../lib/no-tty.js': () => false, - }) - const log = { - ...baseOpts.log, - warn (title, msg) { - t.equal(title, 'exec', 'should have expected title') - t.equal( - msg, - 'Interactive mode disabled in CI environment', - 'should have expected ci environment message' - ) + 'proc-log': { + warn (title, msg) { + t.equal(title, 'exec', 'should have expected title') + t.equal( + msg, + 'Interactive mode disabled in CI environment', + 'should have expected ci environment message' + ) + }, }, - } + }) - runScript({ ...baseOpts, log }) + runScript({ ...baseOpts }) }) diff --git a/workspaces/libnpmhook/package.json b/workspaces/libnpmhook/package.json index 4f30555273205..86e3c9b684447 100644 --- a/workspaces/libnpmhook/package.json +++ b/workspaces/libnpmhook/package.json @@ -34,7 +34,7 @@ "license": "ISC", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "devDependencies": { "@npmcli/template-oss": "^2.4.2", diff --git a/workspaces/libnpmorg/package.json b/workspaces/libnpmorg/package.json index 5c4909b1c9505..781fa9b524695 100644 --- a/workspaces/libnpmorg/package.json +++ b/workspaces/libnpmorg/package.json @@ -45,7 +45,7 @@ "homepage": "https://npmjs.com/package/libnpmorg", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" diff --git a/workspaces/libnpmpack/lib/index.js b/workspaces/libnpmpack/lib/index.js index a2c95cf938dcf..dc9cfd2c4e781 100644 --- a/workspaces/libnpmpack/lib/index.js +++ b/workspaces/libnpmpack/lib/index.js @@ -16,7 +16,7 @@ async function pack (spec = 'file:.', opts = {}) { // Default to true if no log options passed, set to false if we're in silent // mode - const banner = !opts.log || (opts.log.level !== 'silent') + const banner = !opts.silent if (spec.type === 'directory') { // prepack diff --git a/workspaces/libnpmpack/package.json b/workspaces/libnpmpack/package.json index 7317c272f7e22..94507504080d5 100644 --- a/workspaces/libnpmpack/package.json +++ b/workspaces/libnpmpack/package.json @@ -39,8 +39,8 @@ "homepage": "https://npmjs.com/package/libnpmpack", "dependencies": { "@npmcli/run-script": "^2.0.0", - "npm-package-arg": "^8.1.0", - "pacote": "^12.0.0" + "npm-package-arg": "^9.0.0", + "pacote": "^13.0.2" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" diff --git a/workspaces/libnpmpack/test/index.js b/workspaces/libnpmpack/test/index.js index 5f25f416655fd..b8007efe0b69e 100644 --- a/workspaces/libnpmpack/test/index.js +++ b/workspaces/libnpmpack/test/index.js @@ -49,7 +49,7 @@ t.test('writes tarball to file when dryRun === false', async t => { const tarball = await pack('file:.', { dryRun: false, packDestination: testDir, - log: { level: 'silent' }, // so the test doesn't try to log + silent: true, }) t.ok(tarball) const expectedTarball = path.join(testDir, 'my-cool-pkg-1.0.0.tgz') @@ -68,7 +68,7 @@ t.test('writes tarball to file when dryRun === false', async t => { }) }) -t.test('packs from local directory with silent loglevel', async t => { +t.test('packs from local directory with silent', async t => { const testDir = t.testdir({ 'package.json': JSON.stringify({ name: 'my-cool-pkg', @@ -79,7 +79,7 @@ t.test('packs from local directory with silent loglevel', async t => { const cwd = process.cwd() process.chdir(testDir) - const tarball = await pack('file:', { log: { level: 'silent' } }) + const tarball = await pack('file:', { silent: true }) t.ok(tarball) t.teardown(async () => { diff --git a/workspaces/libnpmpublish/package.json b/workspaces/libnpmpublish/package.json index 3fd2d6d5a3961..cb73ee348e2fb 100644 --- a/workspaces/libnpmpublish/package.json +++ b/workspaces/libnpmpublish/package.json @@ -43,8 +43,8 @@ "homepage": "https://npmjs.com/package/libnpmpublish", "dependencies": { "normalize-package-data": "^3.0.2", - "npm-package-arg": "^8.1.2", - "npm-registry-fetch": "^12.0.1", + "npm-package-arg": "^9.0.0", + "npm-registry-fetch": "^13.0.0", "semver": "^7.1.3", "ssri": "^8.0.1" }, diff --git a/workspaces/libnpmsearch/package.json b/workspaces/libnpmsearch/package.json index f524426dc65f8..ba660269893e2 100644 --- a/workspaces/libnpmsearch/package.json +++ b/workspaces/libnpmsearch/package.json @@ -41,7 +41,7 @@ "bugs": "https://github.com/npm/libnpmsearch/issues", "homepage": "https://npmjs.com/package/libnpmsearch", "dependencies": { - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" diff --git a/workspaces/libnpmteam/package.json b/workspaces/libnpmteam/package.json index 23903551aa8c1..083fd6f088123 100644 --- a/workspaces/libnpmteam/package.json +++ b/workspaces/libnpmteam/package.json @@ -32,7 +32,7 @@ "homepage": "https://npmjs.com/package/libnpmteam", "dependencies": { "aproba": "^2.0.0", - "npm-registry-fetch": "^12.0.1" + "npm-registry-fetch": "^13.0.0" }, "engines": { "node": "^12.13.0 || ^14.15.0 || >=16" diff --git a/workspaces/libnpmversion/README.md b/workspaces/libnpmversion/README.md index e82e7cd6f8730..165d16a2b607c 100644 --- a/workspaces/libnpmversion/README.md +++ b/workspaces/libnpmversion/README.md @@ -27,6 +27,7 @@ npmVersion(arg, { ignoreScripts: false, // do not run pre/post/version lifecycle scripts scriptShell: '/bin/bash', // shell to run lifecycle scripts in message: 'v%s', // message for tag and commit, replace %s with the version + silent: false, // passed to @npmcli/run-script to control whether it logs }).then(newVersion => { console.error('version updated!', newVersion) }) diff --git a/workspaces/libnpmversion/lib/enforce-clean.js b/workspaces/libnpmversion/lib/enforce-clean.js index 6103da9bd96af..721f146221c15 100644 --- a/workspaces/libnpmversion/lib/enforce-clean.js +++ b/workspaces/libnpmversion/lib/enforce-clean.js @@ -1,9 +1,10 @@ const git = require('@npmcli/git') +const log = require('proc-log') // returns true if it's cool to do git stuff // throws if it's unclean, and not forced. module.exports = async opts => { - const { force, log } = opts + const { force } = opts let hadError = false const clean = await git.isClean(opts).catch(er => { if (er.code === 'ENOGIT') { diff --git a/workspaces/libnpmversion/lib/index.js b/workspaces/libnpmversion/lib/index.js index 683941cdea4f3..95acd11b5e433 100644 --- a/workspaces/libnpmversion/lib/index.js +++ b/workspaces/libnpmversion/lib/index.js @@ -1,6 +1,5 @@ const readJson = require('./read-json.js') const version = require('./version.js') -const proclog = require('./proc-log.js') module.exports = async (newversion, opts = {}) => { const { @@ -15,8 +14,8 @@ module.exports = async (newversion, opts = {}) => { ignoreScripts = false, scriptShell = undefined, preid = null, - log = proclog, message = 'v%s', + silent, } = opts const pkg = opts.pkg || await readJson(path + '/package.json') @@ -35,7 +34,7 @@ module.exports = async (newversion, opts = {}) => { scriptShell, preid, pkg, - log, message, + silent, }) } diff --git a/workspaces/libnpmversion/lib/version.js b/workspaces/libnpmversion/lib/version.js index 116a375553e9e..12be89b040df7 100644 --- a/workspaces/libnpmversion/lib/version.js +++ b/workspaces/libnpmversion/lib/version.js @@ -8,6 +8,7 @@ const readJson = require('./read-json.js') const git = require('@npmcli/git') const commit = require('./commit.js') const tag = require('./tag.js') +const log = require('proc-log') const runScript = require('@npmcli/run-script') @@ -19,7 +20,7 @@ module.exports = async (newversion, opts) => { ignoreScripts, preid, pkg, - log, + silent, } = opts const { valid, clean, inc } = semver @@ -64,7 +65,7 @@ module.exports = async (newversion, opts) => { pkg, stdio: 'inherit', event: 'preversion', - banner: log.level !== 'silent', + banner: !silent, env: { npm_old_version: current, npm_new_version: newV, @@ -98,7 +99,7 @@ module.exports = async (newversion, opts) => { pkg, stdio: 'inherit', event: 'version', - banner: log.level !== 'silent', + banner: !silent, env: { npm_old_version: current, npm_new_version: newV, @@ -125,7 +126,7 @@ module.exports = async (newversion, opts) => { pkg, stdio: 'inherit', event: 'postversion', - banner: log.level !== 'silent', + banner: !silent, env: { npm_old_version: current, npm_new_version: newV, diff --git a/workspaces/libnpmversion/package.json b/workspaces/libnpmversion/package.json index 6d7823f5d0a5b..11ab7d9ebba7c 100644 --- a/workspaces/libnpmversion/package.json +++ b/workspaces/libnpmversion/package.json @@ -34,9 +34,10 @@ "tap": "^15" }, "dependencies": { - "@npmcli/git": "^2.0.7", + "@npmcli/git": "^3.0.0", "@npmcli/run-script": "^2.0.0", "json-parse-even-better-errors": "^2.3.1", + "proc-log": "^2.0.0", "semver": "^7.3.5", "stringify-package": "^1.0.1" }, diff --git a/workspaces/libnpmversion/tap-snapshots/test/index.js.test.cjs b/workspaces/libnpmversion/tap-snapshots/test/index.js.test.cjs index 6b79d41ebd691..59224e13fae45 100644 --- a/workspaces/libnpmversion/tap-snapshots/test/index.js.test.cjs +++ b/workspaces/libnpmversion/tap-snapshots/test/index.js.test.cjs @@ -15,17 +15,6 @@ Array [ "force": false, "gitTagVersion": true, "ignoreScripts": false, - "log": Object { - "error": Function (...args), - "http": Function (...args), - "info": Function (...args), - "notice": Function (...args), - "pause": Function (...args), - "resume": Function (...args), - "silly": Function (...args), - "verbose": Function (...args), - "warn": Function (...args), - }, "message": "v%s", "path": "{CWD}", "pkg": Object { @@ -35,6 +24,7 @@ Array [ "scriptShell": undefined, "signGitCommit": false, "signGitTag": false, + "silent": undefined, "tagVersionPrefix": "v", }, ] @@ -50,7 +40,6 @@ Array [ "force": true, "gitTagVersion": false, "ignoreScripts": true, - "log": Object {}, "message": "hello, i have a message for you", "path": "/some/path", "pkg": Object { @@ -60,6 +49,7 @@ Array [ "scriptShell": "/bin/bash", "signGitCommit": true, "signGitTag": true, + "silent": undefined, "tagVersionPrefix": "=", }, ] diff --git a/workspaces/libnpmversion/test/enforce-clean.js b/workspaces/libnpmversion/test/enforce-clean.js index 9a489d6f5664d..d96fb09ffa594 100644 --- a/workspaces/libnpmversion/test/enforce-clean.js +++ b/workspaces/libnpmversion/test/enforce-clean.js @@ -16,27 +16,27 @@ const enforceClean = requireInject('../lib/enforce-clean.js', { } }, }, + 'proc-log': { warn: (...msg) => warnings.push(msg) }, }) const warnings = [] -const log = { warn: (...msg) => warnings.push(msg) } t.test('clean, ok', t => - t.resolveMatch(enforceClean({ log, cwd: 'clean' }), true) + t.resolveMatch(enforceClean({ cwd: 'clean' }), true) .then(() => t.strictSame(warnings, [])) .then(() => { warnings.length = 0 })) t.test('unclean, no force, throws', t => - t.rejects(enforceClean({ log, cwd: 'unclean' })) + t.rejects(enforceClean({ cwd: 'unclean' })) .then(() => t.strictSame(warnings, [])) .then(() => { warnings.length = 0 })) t.test('unclean, forced, no throw', t => - t.resolveMatch(enforceClean({ log, cwd: 'unclean', force: true }), true) + t.resolveMatch(enforceClean({ cwd: 'unclean', force: true }), true) .then(() => t.strictSame(warnings, [ [ 'version', @@ -48,7 +48,7 @@ t.test('unclean, forced, no throw', t => })) t.test('nogit, return false, no throw', t => - t.resolveMatch(enforceClean({ log, cwd: 'nogit' }), false) + t.resolveMatch(enforceClean({ cwd: 'nogit' }), false) .then(() => t.strictSame(warnings, [ [ 'version', @@ -61,7 +61,7 @@ t.test('nogit, return false, no throw', t => })) t.test('other error, throw it', t => - t.rejects(enforceClean({ log, cwd: 'error' }), new Error('poop')) + t.rejects(enforceClean({ cwd: 'error' }), new Error('poop')) .then(() => t.strictSame(warnings, [])) .then(() => { warnings.length = 0 diff --git a/workspaces/libnpmversion/test/index.js b/workspaces/libnpmversion/test/index.js index 8c853c679219b..9dcef7b4cfa86 100644 --- a/workspaces/libnpmversion/test/index.js +++ b/workspaces/libnpmversion/test/index.js @@ -33,7 +33,6 @@ t.test('set the package ahead of time', async t => ignoreScripts: true, scriptShell: '/bin/bash', preid: 'rc', - log: {}, message: 'hello, i have a message for you', someOtherRandomField: 'this should not show up', }))) diff --git a/workspaces/libnpmversion/test/proc-log.js b/workspaces/libnpmversion/test/proc-log.js deleted file mode 100644 index 54f7d0b57df70..0000000000000 --- a/workspaces/libnpmversion/test/proc-log.js +++ /dev/null @@ -1,11 +0,0 @@ -const procLog = require('../lib/proc-log.js') -const t = require('tap') -process.once('log', (...args) => t.same(args, ['warn', 1, 2, 3])) -procLog.warn(1, 2, 3) -t.same(Object.keys(procLog), [ - 'notice', 'error', - 'warn', 'info', - 'verbose', 'http', - 'silly', 'pause', - 'resume', -]) diff --git a/workspaces/libnpmversion/test/version.js b/workspaces/libnpmversion/test/version.js index dfaa95de3bd52..19cf7ea0ab912 100644 --- a/workspaces/libnpmversion/test/version.js +++ b/workspaces/libnpmversion/test/version.js @@ -3,10 +3,6 @@ const requireInject = require('require-inject') const actionLog = [] -const log = { - verbose: (...msg) => actionLog.push(['verbose', ...msg]), -} - const gitMock = { is: async opts => !/\bnot-git$/.test(opts.path), spawn: async (args, opts) => actionLog.push(['spawn', args, opts]), @@ -26,6 +22,9 @@ const version = requireInject('../lib/version.js', { }, '@npmcli/git': gitMock, '@npmcli/run-script': async opt => actionLog.push(['run-script', opt.event, opt.env, opt]), + 'proc-log': { + verbose: (...msg) => actionLog.push(['verbose', ...msg]), + }, }) t.test('test out bumping the version in all the ways', async t => { @@ -70,7 +69,7 @@ t.test('test out bumping the version in all the ways', async t => { } throw new Error('no addy the locky fiel please & thanky i ignoring it') } - t.equal(await version('major', { path, log, pkg, gitTagVersion: true }), '2.0.0') + t.equal(await version('major', { path, pkg, gitTagVersion: true }), '2.0.0') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '1.2.0', npm_new_version: '2.0.0' }], ['write-json', path + '/package.json', pkg], @@ -85,7 +84,7 @@ t.test('test out bumping the version in all the ways', async t => { }) await t.test('minor (ignore scripts)', async t => { t.equal(await version('minor', - { path, log, pkg, ignoreScripts: true, gitTagVersion: true }), '2.1.0') + { path, pkg, ignoreScripts: true, gitTagVersion: true }), '2.1.0') t.match(actionLog, [ ['write-json', path + '/package.json', pkg], ['write-json', path + '/package-lock.json', pkg], @@ -97,7 +96,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.0') }) await t.test('patch', async t => { - t.equal(await version('patch', { path, log, pkg, gitTagVersion: true }), '2.1.1') + t.equal(await version('patch', { path, pkg, gitTagVersion: true }), '2.1.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.0', npm_new_version: '2.1.1' }], ['write-json', path + '/package.json', pkg], @@ -112,7 +111,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.1') }) await t.test('pre', async t => { - t.equal(await version('pre', { path, log, pkg, gitTagVersion: true }), '2.1.1-0') + t.equal(await version('pre', { path, pkg, gitTagVersion: true }), '2.1.1-0') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.1', npm_new_version: '2.1.1-0' }], ['write-json', path + '/package.json', pkg], @@ -127,7 +126,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.1-0') }) await t.test('pre with preid', async t => { - t.equal(await version('pre', { path, log, preid: 'alpha', pkg, gitTagVersion: true }), + t.equal(await version('pre', { path, preid: 'alpha', pkg, gitTagVersion: true }), '2.1.1-alpha.0') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.1-0', @@ -145,7 +144,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.1-alpha.0') }) await t.test('skips git tag when gitTagVersion is false', async t => { - t.equal(await version('minor', { path, log, pkg, ignoreScripts: true, gitTagVersion: false }), + t.equal(await version('minor', { path, pkg, ignoreScripts: true, gitTagVersion: false }), '2.2.0') t.match(actionLog, [ ['write-json', path + '/package.json', pkg], @@ -155,7 +154,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.2.0') }) await t.test('explicit version', async t => { - t.equal(await version('=v3.2.1', { path, log, pkg, gitTagVersion: true }), '3.2.1') + t.equal(await version('=v3.2.1', { path, pkg, gitTagVersion: true }), '3.2.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.2.0', npm_new_version: '3.2.1' }], ['write-json', path + '/package.json', pkg], @@ -170,14 +169,14 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '3.2.1') }) await t.test('invalid version', async t => { - await t.rejects(version('invalid version', { path, log, pkg }), { + await t.rejects(version('invalid version', { path, pkg }), { message: 'Invalid version: invalid version', current: '3.2.1', requested: 'invalid version', }) }) await t.test('same version, not allowed', async t => { - await t.rejects(version('=v3.2.1', { path, log, pkg }), { + await t.rejects(version('=v3.2.1', { path, pkg }), { message: 'Version not changed', current: '3.2.1', requested: '=v3.2.1', @@ -186,7 +185,7 @@ t.test('test out bumping the version in all the ways', async t => { }) await t.test('same version, is allowed', async t => { t.equal(await version('=v3.2.1', - { path, log, pkg, allowSameVersion: true, gitTagVersion: true }), '3.2.1') + { path, pkg, allowSameVersion: true, gitTagVersion: true }), '3.2.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '3.2.1', npm_new_version: '3.2.1' }], ['write-json', path + '/package.json', pkg], @@ -201,7 +200,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '3.2.1') }) await t.test('from git', async t => { - t.equal(await version('from-git', { path, log, pkg, gitTagVersion: true }), '1.2.3') + t.equal(await version('from-git', { path, pkg, gitTagVersion: true }), '1.2.3') t.match(actionLog, [ ['retrieve-tag', { path, pkg }], ['run-script', 'preversion', { npm_old_version: '3.2.1', npm_new_version: '1.2.3' }], @@ -218,7 +217,7 @@ t.test('test out bumping the version in all the ways', async t => { }) await t.test('no current version', async t => { delete pkg.version - t.equal(await version('2.3.4', { path, log, pkg, gitTagVersion: true }), '2.3.4') + t.equal(await version('2.3.4', { path, pkg, gitTagVersion: true }), '2.3.4') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '0.0.0', npm_new_version: '2.3.4' }], ['write-json', path + '/package.json', pkg], @@ -241,7 +240,7 @@ t.test('test out bumping the version in all the ways', async t => { }) const path = `${dir}/not-git` await t.test('major', async t => { - t.equal(await version('major', { path, log, pkg }), '2.0.0') + t.equal(await version('major', { path, pkg }), '2.0.0') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '1.2.0', npm_new_version: '2.0.0' }], ['write-json', path + '/package.json', pkg], @@ -253,7 +252,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.0.0') }) await t.test('minor (ignore scripts)', async t => { - t.equal(await version('minor', { path, log, pkg, ignoreScripts: true }), '2.1.0') + t.equal(await version('minor', { path, pkg, ignoreScripts: true }), '2.1.0') t.match(actionLog, [ ['write-json', path + '/package.json', pkg], ['write-json', path + '/npm-shrinkwrap.json', pkg], @@ -262,7 +261,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.0') }) await t.test('patch', async t => { - t.equal(await version('patch', { path, log, pkg }), '2.1.1') + t.equal(await version('patch', { path, pkg }), '2.1.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.0', npm_new_version: '2.1.1' }], ['write-json', path + '/package.json', pkg], @@ -274,7 +273,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.1') }) await t.test('pre', async t => { - t.equal(await version('pre', { path, log, pkg }), '2.1.1-0') + t.equal(await version('pre', { path, pkg }), '2.1.1-0') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.1', npm_new_version: '2.1.1-0' }], ['write-json', path + '/package.json', pkg], @@ -286,7 +285,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.1-0') }) await t.test('pre with preid', async t => { - t.equal(await version('pre', { path, log, preid: 'alpha', pkg }), '2.1.1-alpha.0') + t.equal(await version('pre', { path, preid: 'alpha', pkg }), '2.1.1-alpha.0') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.1-0', npm_new_version: '2.1.1-alpha.0' }], @@ -300,7 +299,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '2.1.1-alpha.0') }) await t.test('explicit version', async t => { - t.equal(await version('=v3.2.1', { path, log, pkg }), '3.2.1') + t.equal(await version('=v3.2.1', { path, pkg }), '3.2.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '2.1.1-alpha.0', npm_new_version: '3.2.1' }], @@ -314,14 +313,14 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '3.2.1') }) await t.test('invalid version', async t => { - await t.rejects(version('invalid version', { path, log, pkg }), { + await t.rejects(version('invalid version', { path, pkg }), { message: 'Invalid version: invalid version', current: '3.2.1', requested: 'invalid version', }) }) await t.test('same version, not allowed', async t => { - await t.rejects(version('=v3.2.1', { path, log, pkg }), { + await t.rejects(version('=v3.2.1', { path, pkg }), { message: 'Version not changed', current: '3.2.1', requested: '=v3.2.1', @@ -329,7 +328,7 @@ t.test('test out bumping the version in all the ways', async t => { }) }) await t.test('same version, is allowed', async t => { - t.equal(await version('=v3.2.1', { path, log, pkg, allowSameVersion: true }), '3.2.1') + t.equal(await version('=v3.2.1', { path, pkg, allowSameVersion: true }), '3.2.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '3.2.1', npm_new_version: '3.2.1' }, { banner: true }], @@ -345,7 +344,7 @@ t.test('test out bumping the version in all the ways', async t => { }) await t.test('same version, is allowed (silent mode)', async t => { t.equal(await version('=v3.2.1', - { path, log: { ...log, level: 'silent' }, pkg, allowSameVersion: true }), '3.2.1') + { path, silent: true, pkg, allowSameVersion: true }), '3.2.1') t.match(actionLog, [ ['run-script', 'preversion', { npm_old_version: '3.2.1', npm_new_version: '3.2.1' }, { banner: false }], @@ -360,7 +359,7 @@ t.test('test out bumping the version in all the ways', async t => { t.equal(pkg.version, '3.2.1') }) await t.test('from git', async t => { - await t.rejects(version('from-git', { path, log, pkg }), { + await t.rejects(version('from-git', { path, pkg }), { message: 'not a git dir', }) })