Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/commands')
-rw-r--r--deps/npm/lib/commands/access.js16
-rw-r--r--deps/npm/lib/commands/audit.js5
-rw-r--r--deps/npm/lib/commands/edit.js9
-rw-r--r--deps/npm/lib/commands/org.js135
-rw-r--r--deps/npm/lib/commands/outdated.js1
-rw-r--r--deps/npm/lib/commands/token.js45
6 files changed, 110 insertions, 101 deletions
diff --git a/deps/npm/lib/commands/access.js b/deps/npm/lib/commands/access.js
index 0a80da8ddd0..36218615371 100644
--- a/deps/npm/lib/commands/access.js
+++ b/deps/npm/lib/commands/access.js
@@ -5,6 +5,7 @@ const readPackageJson = require('read-package-json-fast')
const otplease = require('../utils/otplease.js')
const getIdentity = require('../utils/get-identity.js')
+const log = require('../utils/log-shim.js')
const BaseCommand = require('../base-command.js')
const subcommands = [
@@ -19,6 +20,15 @@ const subcommands = [
'2fa-not-required',
]
+const deprecated = [
+ '2fa-not-required',
+ '2fa-required',
+ 'ls-collaborators',
+ 'ls-packages',
+ 'public',
+ 'restricted',
+]
+
class Access extends BaseCommand {
static description = 'Set access level on published packages'
static name = 'access'
@@ -78,6 +88,10 @@ class Access extends BaseCommand {
throw this.usageError(`${cmd} is not a recognized subcommand.`)
}
+ if (deprecated.includes(cmd)) {
+ log.warn('access', `${cmd} subcommand will be removed in the next version of npm`)
+ }
+
return this[cmd](args, {
...this.npm.flatOptions,
})
@@ -175,7 +189,7 @@ class Access extends BaseCommand {
}
async edit () {
- throw new Error('edit subcommand is not implemented yet')
+ throw new Error('edit subcommand is not implemented')
}
modifyPackage (pkg, opts, fn, requireScope = true) {
diff --git a/deps/npm/lib/commands/audit.js b/deps/npm/lib/commands/audit.js
index 779bc22fc6a..6ec870f03a8 100644
--- a/deps/npm/lib/commands/audit.js
+++ b/deps/npm/lib/commands/audit.js
@@ -178,11 +178,12 @@ class VerifySignatures {
let name = edge.name
try {
name = npa(edge.spec).subSpec.name
- } catch (_) {
+ } catch {
+ // leave it as edge.name
}
try {
return npa(`${name}@${edge.spec}`)
- } catch (_) {
+ } catch {
// Skip packages with invalid spec
}
}
diff --git a/deps/npm/lib/commands/edit.js b/deps/npm/lib/commands/edit.js
index 0256f4f3a6f..67ac32e0171 100644
--- a/deps/npm/lib/commands/edit.js
+++ b/deps/npm/lib/commands/edit.js
@@ -58,11 +58,16 @@ class Edit extends BaseCommand {
}
const [bin, ...args] = this.npm.config.get('editor').split(/\s+/)
const editor = cp.spawn(bin, [...args, dir], { stdio: 'inherit' })
- editor.on('exit', (code) => {
+ editor.on('exit', async (code) => {
if (code) {
return reject(new Error(`editor process exited with code: ${code}`))
}
- this.npm.exec('rebuild', [dir]).catch(reject).then(resolve)
+ try {
+ await this.npm.exec('rebuild', [dir])
+ } catch (err) {
+ reject(err)
+ }
+ resolve()
})
})
})
diff --git a/deps/npm/lib/commands/org.js b/deps/npm/lib/commands/org.js
index 599b4b9c875..f49556c8d6a 100644
--- a/deps/npm/lib/commands/org.js
+++ b/deps/npm/lib/commands/org.js
@@ -50,7 +50,7 @@ class Org extends BaseCommand {
})
}
- set (org, user, role, opts) {
+ async set (org, user, role, opts) {
role = role || 'developer'
if (!org) {
throw new Error('First argument `orgname` is required.')
@@ -67,27 +67,26 @@ class Org extends BaseCommand {
)
}
- return liborg.set(org, user, role, opts).then(memDeets => {
- if (opts.json) {
- this.npm.output(JSON.stringify(memDeets, null, 2))
- } else if (opts.parseable) {
- this.npm.output(['org', 'orgsize', 'user', 'role'].join('\t'))
- this.npm.output(
- [memDeets.org.name, memDeets.org.size, memDeets.user, memDeets.role].join('\t')
- )
- } else if (!this.npm.silent) {
- this.npm.output(
- `Added ${memDeets.user} as ${memDeets.role} to ${memDeets.org.name}. You now have ${
+ const memDeets = await liborg.set(org, user, role, opts)
+ if (opts.json) {
+ this.npm.output(JSON.stringify(memDeets, null, 2))
+ } else if (opts.parseable) {
+ this.npm.output(['org', 'orgsize', 'user', 'role'].join('\t'))
+ this.npm.output(
+ [memDeets.org.name, memDeets.org.size, memDeets.user, memDeets.role].join('\t')
+ )
+ } else if (!this.npm.silent) {
+ this.npm.output(
+ `Added ${memDeets.user} as ${memDeets.role} to ${memDeets.org.name}. You now have ${
memDeets.org.size
} member${memDeets.org.size === 1 ? '' : 's'} in this org.`
- )
- }
+ )
+ }
- return memDeets
- })
+ return memDeets
}
- rm (org, user, opts) {
+ async rm (org, user, opts) {
if (!org) {
throw new Error('First argument `orgname` is required.')
}
@@ -96,68 +95,62 @@ class Org extends BaseCommand {
throw new Error('Second argument `username` is required.')
}
- return liborg
- .rm(org, user, opts)
- .then(() => {
- return liborg.ls(org, opts)
- })
- .then(roster => {
- user = user.replace(/^[~@]?/, '')
- org = org.replace(/^[~@]?/, '')
- const userCount = Object.keys(roster).length
- if (opts.json) {
- this.npm.output(
- JSON.stringify({
- user,
- org,
- userCount,
- deleted: true,
- })
- )
- } else if (opts.parseable) {
- this.npm.output(['user', 'org', 'userCount', 'deleted'].join('\t'))
- this.npm.output([user, org, userCount, true].join('\t'))
- } else if (!this.npm.silent) {
- this.npm.output(
- `Successfully removed ${user} from ${org}. You now have ${userCount} member${
- userCount === 1 ? '' : 's'
- } in this org.`
- )
- }
- })
+ await liborg.rm(org, user, opts)
+ const roster = await liborg.ls(org, opts)
+ user = user.replace(/^[~@]?/, '')
+ org = org.replace(/^[~@]?/, '')
+ const userCount = Object.keys(roster).length
+ if (opts.json) {
+ this.npm.output(
+ JSON.stringify({
+ user,
+ org,
+ userCount,
+ deleted: true,
+ })
+ )
+ } else if (opts.parseable) {
+ this.npm.output(['user', 'org', 'userCount', 'deleted'].join('\t'))
+ this.npm.output([user, org, userCount, true].join('\t'))
+ } else if (!this.npm.silent) {
+ this.npm.output(
+ `Successfully removed ${user} from ${org}. You now have ${userCount} member${
+ userCount === 1 ? '' : 's'
+ } in this org.`
+ )
+ }
}
- ls (org, user, opts) {
+ async ls (org, user, opts) {
if (!org) {
throw new Error('First argument `orgname` is required.')
}
- return liborg.ls(org, opts).then(roster => {
- if (user) {
- const newRoster = {}
- if (roster[user]) {
- newRoster[user] = roster[user]
- }
-
- roster = newRoster
+ let roster = await liborg.ls(org, opts)
+ if (user) {
+ const newRoster = {}
+ if (roster[user]) {
+ newRoster[user] = roster[user]
}
- if (opts.json) {
- this.npm.output(JSON.stringify(roster, null, 2))
- } else if (opts.parseable) {
- this.npm.output(['user', 'role'].join('\t'))
- Object.keys(roster).forEach(user => {
- this.npm.output([user, roster[user]].join('\t'))
+
+ roster = newRoster
+ }
+ if (opts.json) {
+ this.npm.output(JSON.stringify(roster, null, 2))
+ } else if (opts.parseable) {
+ this.npm.output(['user', 'role'].join('\t'))
+ Object.keys(roster).forEach(user => {
+ this.npm.output([user, roster[user]].join('\t'))
+ })
+ } else if (!this.npm.silent) {
+ const table = new Table({ head: ['user', 'role'] })
+ Object.keys(roster)
+ .sort()
+ .forEach(user => {
+ table.push([user, roster[user]])
})
- } else if (!this.npm.silent) {
- const table = new Table({ head: ['user', 'role'] })
- Object.keys(roster)
- .sort()
- .forEach(user => {
- table.push([user, roster[user]])
- })
- this.npm.output(table.toString())
- }
- })
+ this.npm.output(table.toString())
+ }
}
}
module.exports = Org
diff --git a/deps/npm/lib/commands/outdated.js b/deps/npm/lib/commands/outdated.js
index 042b776f71e..9e2060658ed 100644
--- a/deps/npm/lib/commands/outdated.js
+++ b/deps/npm/lib/commands/outdated.js
@@ -196,6 +196,7 @@ class Outdated extends ArboristWorkspaceCmd {
try {
alias = npa(edge.spec).subSpec
} catch (err) {
+ // ignore errors, no alias
}
const spec = npa(alias ? alias.name : edge.name)
const node = edge.to || edge
diff --git a/deps/npm/lib/commands/token.js b/deps/npm/lib/commands/token.js
index cf3b8cbee53..de8e61101d8 100644
--- a/deps/npm/lib/commands/token.js
+++ b/deps/npm/lib/commands/token.js
@@ -140,32 +140,27 @@ class Token extends BaseCommand {
const cidr = conf.cidr
const readonly = conf.readOnly
- return readUserInfo
- .password()
- .then(password => {
- const validCIDR = this.validateCIDRList(cidr)
- log.info('token', 'creating')
- return pulseTillDone.withPromise(
- otplease(this.npm, conf, conf => {
- return profile.createToken(password, readonly, validCIDR, conf)
- })
- )
- })
- .then(result => {
- delete result.key
- delete result.updated
- if (conf.json) {
- this.npm.output(JSON.stringify(result))
- } else if (conf.parseable) {
- Object.keys(result).forEach(k => this.npm.output(k + '\t' + result[k]))
- } else {
- const table = new Table()
- for (const k of Object.keys(result)) {
- table.push({ [chalk.bold(k)]: String(result[k]) })
- }
- this.npm.output(table.toString())
- }
+ const password = await readUserInfo.password()
+ const validCIDR = this.validateCIDRList(cidr)
+ log.info('token', 'creating')
+ const result = await pulseTillDone.withPromise(
+ otplease(this.npm, conf, conf => {
+ return profile.createToken(password, readonly, validCIDR, conf)
})
+ )
+ delete result.key
+ delete result.updated
+ if (conf.json) {
+ this.npm.output(JSON.stringify(result))
+ } else if (conf.parseable) {
+ Object.keys(result).forEach(k => this.npm.output(k + '\t' + result[k]))
+ } else {
+ const table = new Table()
+ for (const k of Object.keys(result)) {
+ table.push({ [chalk.bold(k)]: String(result[k]) })
+ }
+ this.npm.output(table.toString())
+ }
}
config () {