summaryrefslogtreecommitdiff
path: root/deps/npm/lib
diff options
context:
space:
mode:
authorKat Marchán <kzm@sykosomatic.org>2015-09-04 14:47:14 -0700
committerRod Vagg <rod@vagg.org>2015-09-06 21:38:09 +1000
commitd15ba80d6f7a473a70081768500260429ecb6218 (patch)
treed83559d4277c56eab5fffb986dd1e4ec8db94a4b /deps/npm/lib
parentb4f1711a629251f6aab7615907fe7358881e0648 (diff)
downloadandroid-node-v8-d15ba80d6f7a473a70081768500260429ecb6218.tar.gz
android-node-v8-d15ba80d6f7a473a70081768500260429ecb6218.tar.bz2
android-node-v8-d15ba80d6f7a473a70081768500260429ecb6218.zip
deps: upgrade to npm 2.14.2
PR-URL: https://github.com/nodejs/node/pull/2696 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
Diffstat (limited to 'deps/npm/lib')
-rw-r--r--deps/npm/lib/access.js179
-rw-r--r--deps/npm/lib/build.js6
-rw-r--r--deps/npm/lib/link.js7
-rw-r--r--deps/npm/lib/npm.js1
-rw-r--r--deps/npm/lib/run-script.js2
-rw-r--r--deps/npm/lib/team.js54
-rwxr-xr-xdeps/npm/lib/utils/completion.sh16
-rw-r--r--deps/npm/lib/utils/error-handler.js8
-rw-r--r--deps/npm/lib/utils/lifecycle.js14
-rw-r--r--deps/npm/lib/version.js2
-rw-r--r--deps/npm/lib/whoami.js2
11 files changed, 173 insertions, 118 deletions
diff --git a/deps/npm/lib/access.js b/deps/npm/lib/access.js
index cf960a67d8..790a760cb7 100644
--- a/deps/npm/lib/access.js
+++ b/deps/npm/lib/access.js
@@ -1,123 +1,110 @@
-var assert = require("assert")
-var resolve = require("path").resolve
-var url = require("url")
+'use strict'
-var log = require("npmlog")
-var readPackageJson = require("read-package-json")
+var resolve = require('path').resolve
-var mapToRegistry = require("./utils/map-to-registry.js")
-var npa = require("npm-package-arg")
-var npm = require("./npm.js")
+var readPackageJson = require('read-package-json')
+var mapToRegistry = require('./utils/map-to-registry.js')
+var npm = require('./npm.js')
+
+var whoami = require('./whoami')
module.exports = access
-access.usage = "npm access public [<package>]"
- + "\nnpm access restricted [<package>]"
- + "\nnpm access add <read-only|read-write> <entity> [<package>]"
- + "\nnpm access rm <entity> [<package>]"
- + "\nnpm access ls [<package>]"
- + "\nnpm access edit [<package>]"
+access.usage =
+ 'npm access public [<package>]\n' +
+ 'npm access restricted [<package>]\n' +
+ 'npm access grant <read-only|read-write> <scope:team> [<package>]\n' +
+ 'npm access revoke <scope:team> [<package>]\n' +
+ 'npm access ls-packages [<user>|<scope>|<scope:team>]\n' +
+ 'npm access ls-collaborators [<package> [<user>]]\n' +
+ 'npm access edit [<package>]'
+
+access.subcommands = ['public', 'restricted', 'grant', 'revoke',
+ 'ls-packages', 'ls-collaborators', 'edit']
access.completion = function (opts, cb) {
var argv = opts.conf.argv.remain
if (argv.length === 2) {
- return cb(null, ["public", "restricted", "add", "rm", "ls", "edit"])
+ return cb(null, access.subcommands)
}
switch (argv[2]) {
- case "public":
- case "restricted":
- case "ls":
- case "edit":
- return cb(new Error("unimplemented: packages you can change"))
- case "add":
- if (argv.length === 3) return cb(null, ["read-only", "read-write"])
-
- return cb(new Error("unimplemented: entities and packages"))
- case "rm":
- return cb(new Error("unimplemented: entities and packages"))
+ case 'grant':
+ if (argv.length === 3) {
+ return cb(null, ['read-only', 'read-write'])
+ } else {
+ return cb(null, [])
+ }
+ case 'public':
+ case 'restricted':
+ case 'ls-packages':
+ case 'ls-collaborators':
+ case 'edit':
+ return cb(null, [])
+ case 'revoke':
+ return cb(null, [])
default:
- return cb(new Error(argv[2]+" not recognized"))
+ return cb(new Error(argv[2] + ' not recognized'))
}
}
function access (args, cb) {
var cmd = args.shift()
- switch (cmd) {
- case "public": case "restricted": return changeAccess(args, cmd, cb)
- case "add": case "set": return add(args, cb)
- case "rm": case "del": case "clear": return rm(args, cb)
- case "list": case "sl": case "ls": return ls(args, cb)
- case "edit": case "ed": return edit(args, cb)
- default: return cb("Usage:\n"+access.usage)
- }
-}
-
-function changeAccess (args, level, cb) {
- assert(Array.isArray(args), "changeAccess requires args be an array")
- assert(
- ["public", "restricted"].indexOf(level) !== -1,
- "access level must be either 'public' or 'restricted'"
- )
- assert(typeof cb === "function", "changeAccess requires a callback")
-
- var p = (args.shift() || "").trim()
- if (!p) return getCurrentPackage(level, cb)
- changeAccess_(p, level, cb)
-}
-
-function getCurrentPackage (level, cb) {
- var here = resolve(npm.prefix, "package.json")
- log.verbose("setPackageLevel", "here", here)
-
- readPackageJson(here, function (er, data) {
- if (er) return cb(er)
-
- if (!data.name) {
- return cb(new Error("Package must be named"))
- }
-
- changeAccess_(data.name, level, cb)
+ var params
+ return parseParams(cmd, args, function (err, p) {
+ if (err) { return cb(err) }
+ params = p
+ return mapToRegistry(params.package, npm.config, invokeCmd)
})
-}
-function changeAccess_ (name, level, cb) {
- log.verbose("changeAccess", "name", name, "level", level)
- mapToRegistry(name, npm.config, function (er, uri, auth, base) {
- if (er) return cb(er)
-
- var data = npa(name)
- if (!data.scope) {
- var msg = "Sorry, you can't change the access level of unscoped packages."
- log.error("access", msg)
- return cb(new Error(msg))
+ function invokeCmd (err, uri, auth, base) {
+ if (err) { return cb(err) }
+ params.auth = auth
+ try {
+ return npm.registry.access(cmd, uri, params, function (err, data) {
+ !err && data && console.log(JSON.stringify(data, undefined, 2))
+ cb(err, data)
+ })
+ } catch (e) {
+ cb(e.message + '\n\nUsage:\n' + access.usage)
}
+ }
+}
- // name must be scoped, so escape separator
- name = name.replace("/", "%2f")
- // FIXME: mapToRegistry still isn't generic enough SIGH
- uri = url.resolve(base, "-/package/"+name+"/access")
- var params = {
- level : level,
- auth : auth
+function parseParams (cmd, args, cb) {
+ var params = {}
+ if (cmd === 'grant') {
+ params.permissions = args.shift()
+ }
+ if (['grant', 'revoke', 'ls-packages'].indexOf(cmd) !== -1) {
+ var entity = (args.shift() || '').split(':')
+ params.scope = entity[0]
+ params.team = entity[1]
+ }
+ getPackage(args.shift(), function (err, pkg) {
+ if (err) { return cb(err) }
+ params.package = pkg
+
+ if (!params.scope && cmd === 'ls-packages') {
+ whoami([], true, function (err, scope) {
+ params.scope = scope
+ cb(err, params)
+ })
+ } else {
+ if (cmd === 'ls-collaborators') {
+ params.user = args.shift()
+ }
+ cb(null, params)
}
-
- npm.registry.access(uri, params, cb)
})
}
-function add (args, cb) {
- return cb(new Error("npm access add isn't implemented yet!"))
-}
-
-function rm (args, cb) {
- return cb(new Error("npm access rm isn't implemented yet!"))
-}
-
-function ls (args, cb) {
- return cb(new Error("npm access ls isn't implemented yet!"))
-}
-
-function edit (args, cb) {
- return cb(new Error("npm access edit isn't implemented yet!"))
+function getPackage (name, cb) {
+ if (name && name.trim()) {
+ cb(null, name.trim())
+ } else {
+ readPackageJson(
+ resolve(npm.prefix, 'package.json'),
+ function (err, data) { cb(err, data.name) })
+ }
}
diff --git a/deps/npm/lib/build.js b/deps/npm/lib/build.js
index c5ee76e5c8..1f2d2efceb 100644
--- a/deps/npm/lib/build.js
+++ b/deps/npm/lib/build.js
@@ -122,10 +122,10 @@ function shouldWarn(pkg, folder, global, cb) {
// current searched package is the linked package on first call
if (linkedPkg !== currentPkg) {
- if (!topPkg.dependencies) return cb()
-
// don't generate a warning if it's listed in dependencies
- if (Object.keys(topPkg.dependencies).indexOf(currentPkg) === -1) {
+ if (Object.keys(topPkg.dependencies || {})
+ .concat(Object.keys(topPkg.devDependencies || {}))
+ .indexOf(currentPkg) === -1) {
if (top && pkg.preferGlobal && !global) {
log.warn("prefer global", pkg._id + " should be installed with -g")
diff --git a/deps/npm/lib/link.js b/deps/npm/lib/link.js
index 916ebd6afe..1b3558030b 100644
--- a/deps/npm/lib/link.js
+++ b/deps/npm/lib/link.js
@@ -97,14 +97,13 @@ function linkInstall (pkgs, cb) {
function next () {
chain
- ( [ [npm.commands, "unbuild", [target]]
- , [function (cb) {
+ ( [ [function (cb) {
log.verbose("link", "symlinking %s to %s", pp, target)
cb()
}]
, [symlink, pp, target]
- // do run lifecycle scripts - full build here.
- , rp && [build, [target]]
+ // do not run any scripts
+ , rp && [build, [target], npm.config.get("global"), build._noLC, true]
, [ resultPrinter, pkg, pp, target, rp ] ]
, cb )
}
diff --git a/deps/npm/lib/npm.js b/deps/npm/lib/npm.js
index 97cdad4de2..c049d95ba6 100644
--- a/deps/npm/lib/npm.js
+++ b/deps/npm/lib/npm.js
@@ -113,6 +113,7 @@ var commandCache = {}
, "unpublish"
, "owner"
, "access"
+ , "team"
, "deprecate"
, "shrinkwrap"
diff --git a/deps/npm/lib/run-script.js b/deps/npm/lib/run-script.js
index 057af2bc69..2c805615a4 100644
--- a/deps/npm/lib/run-script.js
+++ b/deps/npm/lib/run-script.js
@@ -62,7 +62,7 @@ function runScript (args, cb) {
function list(cb) {
var json = path.join(npm.localPrefix, "package.json")
var cmdList = [ "publish", "install", "uninstall"
- , "test", "stop", "start", "restart"
+ , "test", "stop", "start", "restart", "version"
].reduce(function (l, p) {
return l.concat(["pre" + p, p, "post" + p])
}, [])
diff --git a/deps/npm/lib/team.js b/deps/npm/lib/team.js
new file mode 100644
index 0000000000..324d8df5e2
--- /dev/null
+++ b/deps/npm/lib/team.js
@@ -0,0 +1,54 @@
+var mapToRegistry = require('./utils/map-to-registry.js')
+var npm = require('./npm')
+
+module.exports = team
+
+team.subcommands = ['create', 'destroy', 'add', 'rm', 'ls', 'edit']
+
+team.usage =
+ 'npm team create <scope:team>\n' +
+ 'npm team destroy <scope:team>\n' +
+ 'npm team add <scope:team> <user>\n' +
+ 'npm team rm <scope:team> <user>\n' +
+ 'npm team ls <scope>|<scope:team>\n' +
+ 'npm team edit <scope:team>'
+
+team.completion = function (opts, cb) {
+ var argv = opts.conf.argv.remain
+ if (argv.length === 2) {
+ return cb(null, team.subcommands)
+ }
+ switch (argv[2]) {
+ case 'ls':
+ case 'create':
+ case 'destroy':
+ case 'add':
+ case 'rm':
+ case 'edit':
+ return cb(null, [])
+ default:
+ return cb(new Error(argv[2] + ' not recognized'))
+ }
+}
+
+function team (args, cb) {
+ // Entities are in the format <scope>:<team>
+ var cmd = args.shift()
+ var entity = (args.shift() || '').split(':')
+ return mapToRegistry('/', npm.config, function (err, uri, auth) {
+ if (err) { return cb(err) }
+ try {
+ return npm.registry.team(cmd, uri, {
+ auth: auth,
+ scope: entity[0],
+ team: entity[1],
+ user: args.shift()
+ }, function (err, data) {
+ !err && data && console.log(JSON.stringify(data, undefined, 2))
+ cb(err, data)
+ })
+ } catch (e) {
+ cb(e.message + '\n\nUsage:\n' + team.usage)
+ }
+ })
+}
diff --git a/deps/npm/lib/utils/completion.sh b/deps/npm/lib/utils/completion.sh
index 3c7a3590d8..25bef2c17b 100755
--- a/deps/npm/lib/utils/completion.sh
+++ b/deps/npm/lib/utils/completion.sh
@@ -7,17 +7,21 @@
# Or, maybe: npm completion > /usr/local/etc/bash_completion.d/npm
#
-COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
-COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
-export COMP_WORDBREAKS
-
if type complete &>/dev/null; then
_npm_completion () {
+ local words cword
+ if type _get_comp_words_by_ref &>/dev/null; then
+ _get_comp_words_by_ref -n = -n @ -w words -i cword
+ else
+ cword="$COMP_CWORD"
+ words=("${COMP_WORDS[@]}")
+ fi
+
local si="$IFS"
- IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
+ IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
- npm completion -- "${COMP_WORDS[@]}" \
+ npm completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
diff --git a/deps/npm/lib/utils/error-handler.js b/deps/npm/lib/utils/error-handler.js
index 6ffb2867e2..dac6a17f25 100644
--- a/deps/npm/lib/utils/error-handler.js
+++ b/deps/npm/lib/utils/error-handler.js
@@ -366,6 +366,14 @@ function errorHandler (er) {
].join("\n"))
break
+ case "EISDIR":
+ log.error("eisdir", [er.message
+ ,"This is most likely not a problem with npm itself"
+ ,"and is related to npm not being able to find a package.json in"
+ ,"a package you are trying to install."
+ ].join("\n"))
+ break
+
default:
log.error("", er.message || er)
log.error("", ["", "If you need help, you may report this error at:"
diff --git a/deps/npm/lib/utils/lifecycle.js b/deps/npm/lib/utils/lifecycle.js
index a6f2b98e88..9805a1c0c1 100644
--- a/deps/npm/lib/utils/lifecycle.js
+++ b/deps/npm/lib/utils/lifecycle.js
@@ -196,12 +196,12 @@ function runCmd_ (cmd, pkg, env, wd, stage, unsafe, uid, gid, cb_) {
conf.gid = gid ^ 0
}
- var sh = "sh"
- var shFlag = "-c"
+ var sh = 'sh'
+ var shFlag = '-c'
- if (process.platform === "win32") {
- sh = process.env.comspec || "cmd"
- shFlag = "/c"
+ if (process.platform === 'win32') {
+ sh = process.env.comspec || 'cmd'
+ shFlag = '/d /s /c'
conf.windowsVerbatimArguments = true
}
@@ -313,7 +313,9 @@ function makeEnv (data, prefix, env) {
, verPref = data.name + "@" + data.version + ":"
keys.forEach(function (i) {
- if (i.charAt(0) === "_" && i.indexOf("_"+namePref) !== 0) {
+ // in some rare cases (e.g. working with nerf darts), there are segmented
+ // "private" (underscore-prefixed) config names -- don't export
+ if (i.charAt(0) === '_' && i.indexOf('_' + namePref) !== 0 || i.match(/:_/)) {
return
}
var value = npm.config.get(i)
diff --git a/deps/npm/lib/version.js b/deps/npm/lib/version.js
index b33392488f..dbd48a0145 100644
--- a/deps/npm/lib/version.js
+++ b/deps/npm/lib/version.js
@@ -141,7 +141,7 @@ function dump (data, cb) {
function checkGit (localData, cb) {
fs.stat(path.join(npm.localPrefix, '.git'), function (er, s) {
- var doGit = !er && s.isDirectory() && npm.config.get('git-tag-version')
+ var doGit = !er && npm.config.get('git-tag-version')
if (!doGit) {
if (er) log.verbose('version', 'error checking for .git', er)
log.verbose('version', 'not tagging in git')
diff --git a/deps/npm/lib/whoami.js b/deps/npm/lib/whoami.js
index d92a6574a1..bef0184a00 100644
--- a/deps/npm/lib/whoami.js
+++ b/deps/npm/lib/whoami.js
@@ -40,7 +40,7 @@ function whoami (args, silent, cb) {
// At this point, if they have a credentials object, it doesn't have a token
// or auth in it. Probably just the default registry.
var needAuth = new Error(
- "'npm whoami' requires you to be logged in."
+ "this command requires you to be logged in."
)
needAuth.code = 'ENEEDAUTH'
process.nextTick(cb.bind(this, needAuth))