aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib')
-rw-r--r--deps/npm/lib/access.js2
-rw-r--r--deps/npm/lib/config/defaults.js3
-rw-r--r--deps/npm/lib/fetch-package-metadata.md2
-rw-r--r--deps/npm/lib/install.js45
-rw-r--r--deps/npm/lib/install/action/extract.js3
-rw-r--r--deps/npm/lib/install/action/global-install.js3
-rw-r--r--deps/npm/lib/install/action/global-link.js3
-rw-r--r--deps/npm/lib/install/and-add-parent-to-errors.js3
-rw-r--r--deps/npm/lib/install/deps.js32
-rw-r--r--deps/npm/lib/install/inflate-shrinkwrap.js2
-rw-r--r--deps/npm/lib/install/is-only-optional.js3
-rw-r--r--deps/npm/lib/install/save.js2
-rw-r--r--deps/npm/lib/ls.js14
-rw-r--r--deps/npm/lib/outdated.js94
-rw-r--r--deps/npm/lib/run-script.js2
-rw-r--r--deps/npm/lib/shrinkwrap.js9
-rw-r--r--deps/npm/lib/stars.js2
-rw-r--r--deps/npm/lib/token.js46
-rw-r--r--deps/npm/lib/update.js2
-rw-r--r--deps/npm/lib/utils/error-message.js4
-rw-r--r--deps/npm/lib/utils/module-name.js1
-rw-r--r--deps/npm/lib/view.js2
22 files changed, 196 insertions, 83 deletions
diff --git a/deps/npm/lib/access.js b/deps/npm/lib/access.js
index 4bb93fda1d..6657f4b071 100644
--- a/deps/npm/lib/access.js
+++ b/deps/npm/lib/access.js
@@ -154,7 +154,7 @@ access['ls-packages'] = access.lsPackages = ([owner], opts) => {
}
access['ls-collaborators'] = access.lsCollaborators = ([pkg, usr], opts) => {
- return getPackage(pkg).then(pkgName =>
+ return getPackage(pkg, false).then(pkgName =>
libaccess.lsCollaborators(pkgName, usr, opts)
).then(collabs => {
// TODO - print these out nicely (breaking change)
diff --git a/deps/npm/lib/config/defaults.js b/deps/npm/lib/config/defaults.js
index 2592659539..f563357d4c 100644
--- a/deps/npm/lib/config/defaults.js
+++ b/deps/npm/lib/config/defaults.js
@@ -113,6 +113,7 @@ Object.defineProperty(exports, 'defaults', {get: function () {
'audit-level': 'low',
'auth-type': 'legacy',
+ 'before': null,
'bin-links': true,
browser: null,
@@ -260,6 +261,7 @@ exports.types = {
audit: Boolean,
'audit-level': ['low', 'moderate', 'high', 'critical'],
'auth-type': ['legacy', 'sso', 'saml', 'oauth'],
+ 'before': [null, Date],
'bin-links': Boolean,
browser: [null, String],
ca: [null, String, Array],
@@ -394,6 +396,7 @@ function getLocalAddresses () {
}
exports.shorthands = {
+ before: ['--enjoy-by'],
s: ['--loglevel', 'silent'],
d: ['--loglevel', 'info'],
dd: ['--loglevel', 'verbose'],
diff --git a/deps/npm/lib/fetch-package-metadata.md b/deps/npm/lib/fetch-package-metadata.md
index 6fe4beac6e..7b4562341b 100644
--- a/deps/npm/lib/fetch-package-metadata.md
+++ b/deps/npm/lib/fetch-package-metadata.md
@@ -1,7 +1,7 @@
fetch-package-metadata
----------------------
- var fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
+ const fetchPackageMetadata = require("npm/lib/fetch-package-metadata")
fetchPackageMetadata(spec, contextdir, callback)
This will get package metadata (and if possible, ONLY package metadata) for
diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js
index e15bc47919..d2f705e1d1 100644
--- a/deps/npm/lib/install.js
+++ b/deps/npm/lib/install.js
@@ -401,7 +401,7 @@ Installer.prototype.normalizeCurrentTree = function (cb) {
if (this.currentTree.error) {
for (let child of this.currentTree.children) {
if (!child.fakeChild && isExtraneous(child)) {
- this.currentTree.package.dependencies[child.package.name] = computeVersionSpec(this.currentTree, child)
+ this.currentTree.package.dependencies[moduleName(child)] = computeVersionSpec(this.currentTree, child)
}
}
}
@@ -703,8 +703,25 @@ Installer.prototype.cloneCurrentTreeToIdealTree = function (cb) {
validate('F', arguments)
log.silly('install', 'cloneCurrentTreeToIdealTree')
- this.idealTree = copyTree(this.currentTree)
- this.idealTree.warnings = []
+ if (npm.config.get('before')) {
+ this.idealTree = {
+ package: this.currentTree.package,
+ path: this.currentTree.path,
+ realpath: this.currentTree.realpath,
+ children: [],
+ requires: [],
+ missingDeps: {},
+ missingDevDeps: {},
+ requiredBy: [],
+ error: this.currentTree.error,
+ warnings: [],
+ isTop: true
+ }
+ } else {
+ this.idealTree = copyTree(this.currentTree)
+ this.idealTree.warnings = []
+ }
+
cb()
}
@@ -825,7 +842,11 @@ Installer.prototype.printInstalledForHuman = function (diffs, auditResult) {
var report = ''
if (this.args.length && (added || updated)) {
report += this.args.map((p) => {
- return `+ ${p.name}@${p.version}`
+ return `+ ${p.name}@${p.version}${
+ !p._requested.name || p._requested.name === p.name
+ ? ''
+ : ` (as ${p._requested.name})`
+ }`
}).join('\n') + '\n'
}
var actions = []
@@ -922,10 +943,14 @@ Installer.prototype.printInstalledForJSON = function (diffs, auditResult) {
function recordAction (action) {
var mutation = action[0]
var child = action[1]
+ const isAlias = child.package && child.package._requested && child.package._requested.type === 'alias'
+ const name = isAlias
+ ? child.package._requested.name
+ : child.package && child.package.name
var result = {
action: mutation,
- name: moduleName(child),
- version: child.package && child.package.version,
+ name,
+ version: child.package && `${isAlias ? `npm:${child.package.name}@` : ''}${child.package.version}`,
path: child.path
}
if (mutation === 'move') {
@@ -947,10 +972,16 @@ Installer.prototype.printInstalledForParseable = function (diffs) {
} else if (mutation === 'update') {
var previousVersion = child.oldPkg.package && child.oldPkg.package.version
}
+ const isAlias = child.package._requested && child.package._requested.type === 'alias'
+ const version = child.package && isAlias
+ ? `npm:${child.package.name}@${child.package.version}`
+ : child.package
+ ? child.package.version
+ : ''
output(
mutation + '\t' +
moduleName(child) + '\t' +
- (child.package ? child.package.version : '') + '\t' +
+ version + '\t' +
(child.path ? path.relative(self.where, child.path) : '') + '\t' +
(previousVersion || '') + '\t' +
(previousPath || ''))
diff --git a/deps/npm/lib/install/action/extract.js b/deps/npm/lib/install/action/extract.js
index c1c17cdf6c..32a4f4e004 100644
--- a/deps/npm/lib/install/action/extract.js
+++ b/deps/npm/lib/install/action/extract.js
@@ -6,6 +6,7 @@ const figgyPudding = require('figgy-pudding')
const stat = BB.promisify(require('graceful-fs').stat)
const gentlyRm = BB.promisify(require('../../utils/gently-rm.js'))
const mkdirp = BB.promisify(require('mkdirp'))
+const moduleName = require('../../utils/module-name.js')
const moduleStagingPath = require('../module-staging-path.js')
const move = require('../../utils/move.js')
const npa = require('npm-package-arg')
@@ -113,7 +114,7 @@ function readBundled (pkg, staging, extractTo) {
}
function stageBundledModule (bundler, child, staging, parentPath) {
- const stageFrom = path.join(parentPath, 'node_modules', child.package.name)
+ const stageFrom = path.join(parentPath, 'node_modules', moduleName(child))
const stageTo = moduleStagingPath(staging, child)
return BB.map(child.children, (child) => {
diff --git a/deps/npm/lib/install/action/global-install.js b/deps/npm/lib/install/action/global-install.js
index bdc121b693..44d2f628f2 100644
--- a/deps/npm/lib/install/action/global-install.js
+++ b/deps/npm/lib/install/action/global-install.js
@@ -3,12 +3,13 @@ var path = require('path')
var npm = require('../../npm.js')
var Installer = require('../../install.js').Installer
var packageId = require('../../utils/package-id.js')
+var moduleName = require('../../utils/module-name.js')
module.exports = function (staging, pkg, log, next) {
log.silly('global-install', packageId(pkg))
var globalRoot = path.resolve(npm.globalDir, '..')
npm.config.set('global', true)
- var install = new Installer(globalRoot, false, [pkg.package.name + '@' + pkg.package._requested.fetchSpec])
+ var install = new Installer(globalRoot, false, [moduleName(pkg) + '@' + pkg.package._requested.rawSpec])
install.link = false
install.run(function () {
npm.config.set('global', false)
diff --git a/deps/npm/lib/install/action/global-link.js b/deps/npm/lib/install/action/global-link.js
index f109e5b88a..c9d9a8feb2 100644
--- a/deps/npm/lib/install/action/global-link.js
+++ b/deps/npm/lib/install/action/global-link.js
@@ -1,8 +1,9 @@
'use strict'
+var moduleName = require('../../utils/module-name.js')
var npm = require('../../npm.js')
var packageId = require('../../utils/package-id.js')
module.exports = function (staging, pkg, log, next) {
log.silly('global-link', packageId(pkg))
- npm.link(pkg.package.name, next)
+ npm.link(moduleName(pkg), next)
}
diff --git a/deps/npm/lib/install/and-add-parent-to-errors.js b/deps/npm/lib/install/and-add-parent-to-errors.js
index 62a86bd4a6..fe4128230b 100644
--- a/deps/npm/lib/install/and-add-parent-to-errors.js
+++ b/deps/npm/lib/install/and-add-parent-to-errors.js
@@ -1,4 +1,5 @@
'use strict'
+var moduleName = require('../utils/module-name.js')
var validate = require('aproba')
module.exports = function (parent, cb) {
@@ -6,7 +7,7 @@ module.exports = function (parent, cb) {
return function (er) {
if (!er) return cb.apply(null, arguments)
if (er instanceof Error && parent && parent.package && parent.package.name) {
- er.parent = parent.package.name
+ er.parent = moduleName(parent)
}
cb(er)
}
diff --git a/deps/npm/lib/install/deps.js b/deps/npm/lib/install/deps.js
index c36265093b..3fe370140a 100644
--- a/deps/npm/lib/install/deps.js
+++ b/deps/npm/lib/install/deps.js
@@ -57,6 +57,19 @@ function doesChildVersionMatch (child, requested, requestor) {
if (fromSw.toString() === requested.toString()) return true
}
+ if (requested.type === 'git' && requested.gitRange) {
+ const sameRepo = npa(child.package._from).fetchSpec === requested.fetchSpec
+ try {
+ return sameRepo && semver.satisfies(child.package.version, requested.gitRange, true)
+ } catch (e) {
+ return false
+ }
+ }
+
+ if (requested.type === 'alias') {
+ return doesChildVersionMatch(child, requested.subSpec, requestor)
+ }
+
if (!registryTypes[requested.type]) {
var childReq = child.package._requested
if (childReq) {
@@ -72,7 +85,7 @@ function doesChildVersionMatch (child, requested, requestor) {
// You'll see this scenario happen with at least tags and git dependencies.
// Some buggy clients will write spaces into the module name part of a _from.
if (child.package._from) {
- var fromReq = npa.resolve(moduleName(child), child.package._from.replace(new RegExp('^\\s*' + moduleName(child) + '\\s*@'), ''))
+ var fromReq = npa(child.package._from)
if (fromReq.rawSpec === requested.rawSpec) return true
if (fromReq.type === requested.type && fromReq.saveSpec && fromReq.saveSpec === requested.saveSpec) return true
}
@@ -289,11 +302,13 @@ function computeVersionSpec (tree, child) {
var requested
var childReq = child.package._requested
if (child.isLink) {
- requested = npa.resolve(child.package.name, 'file:' + child.realpath, getTop(tree).path)
+ requested = npa.resolve(moduleName(child), 'file:' + child.realpath, getTop(tree).path)
} else if (childReq && (isNotEmpty(childReq.saveSpec) || (isNotEmpty(childReq.rawSpec) && isNotEmpty(childReq.fetchSpec)))) {
requested = child.package._requested
} else if (child.package._from) {
requested = npa(child.package._from, tree.path)
+ } else if (child.name && child.name !== child.package.name) {
+ requested = npa.resolve(child.name, `npm:${child.package.name}@${child.package.version})`)
} else {
requested = npa.resolve(child.package.name, child.package.version)
}
@@ -305,6 +320,9 @@ function computeVersionSpec (tree, child) {
!npm.config.get('save-exact')) {
rangeDescriptor = npm.config.get('save-prefix')
}
+ if (requested.type === 'alias') {
+ rangeDescriptor = `npm:${requested.subSpec.name}@${rangeDescriptor}`
+ }
return rangeDescriptor + version
} else if (requested.type === 'directory' || requested.type === 'file') {
return 'file:' + unixFormatPath(path.relative(getTop(tree).path, requested.fetchSpec))
@@ -324,7 +342,7 @@ exports.removeDeps = function (args, tree, saveToDependencies, next) {
for (let pkg of args) {
var pkgName = moduleName(pkg)
var toRemove = tree.children.filter(moduleNameMatches(pkgName))
- var pkgToRemove = toRemove[0] || createChild({package: {name: pkgName}})
+ var pkgToRemove = toRemove[0] || createChild({name: pkgName})
var saveType = getSaveType(tree, pkg) || 'dependencies'
if (tree.isTop && saveToDependencies) {
pkgToRemove.save = saveType
@@ -652,11 +670,13 @@ function resolveWithNewModule (pkg, tree, log, next) {
addBundled(pkg, (bundleErr) => {
var parent = earliestInstallable(tree, tree, pkg, log) || tree
var isLink = pkg._requested.type === 'directory'
+ var name = pkg._requested.name || pkg.name
var child = createChild({
+ name,
package: pkg,
parent: parent,
- path: path.join(parent.isLink ? parent.realpath : parent.path, 'node_modules', pkg.name),
- realpath: isLink ? pkg._requested.fetchSpec : path.join(parent.realpath, 'node_modules', pkg.name),
+ path: path.join(parent.isLink ? parent.realpath : parent.path, 'node_modules', name),
+ realpath: isLink ? pkg._requested.fetchSpec : path.join(parent.realpath, 'node_modules', name),
children: pkg._bundled || [],
isLink: isLink,
isInLink: parent.isLink,
@@ -759,7 +779,7 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr
validate('OOOO', arguments)
function undeletedModuleMatches (child) {
- return !child.removed && moduleName(child) === pkg.name
+ return !child.removed && moduleName(child) === ((pkg._requested && pkg._requested.name) || pkg.name)
}
const undeletedMatches = tree.children.filter(undeletedModuleMatches)
if (undeletedMatches.length) {
diff --git a/deps/npm/lib/install/inflate-shrinkwrap.js b/deps/npm/lib/install/inflate-shrinkwrap.js
index bf1ab70657..395cc11191 100644
--- a/deps/npm/lib/install/inflate-shrinkwrap.js
+++ b/deps/npm/lib/install/inflate-shrinkwrap.js
@@ -177,7 +177,7 @@ function makeFakeChild (name, topPath, tree, sw, requested) {
realpath: requested.type === 'directory' ? requested.fetchSpec : childPath(tree.realpath, pkg),
location: (tree.location === '/' ? '' : tree.location + '/') + pkg.name,
isLink: requested.type === 'directory',
- isInLink: tree.isLink,
+ isInLink: tree.isLink || tree.isInLink,
swRequires: sw.requires
})
tree.children.push(child)
diff --git a/deps/npm/lib/install/is-only-optional.js b/deps/npm/lib/install/is-only-optional.js
index f1b731578d..81e227bae7 100644
--- a/deps/npm/lib/install/is-only-optional.js
+++ b/deps/npm/lib/install/is-only-optional.js
@@ -2,6 +2,7 @@
module.exports = isOptional
const isOptDep = require('./is-opt-dep.js')
+const moduleName = require('../utils/module-name.js')
function isOptional (node, seen) {
if (!seen) seen = new Set()
@@ -15,6 +16,6 @@ function isOptional (node, seen) {
const swOptional = node.fromShrinkwrap && node.package._optional
return node.requiredBy.every(function (req) {
if (req.fakeChild && swOptional) return true
- return isOptDep(req, node.package.name) || isOptional(req, seen)
+ return isOptDep(req, moduleName(node)) || isOptional(req, seen)
})
}
diff --git a/deps/npm/lib/install/save.js b/deps/npm/lib/install/save.js
index 7227e78852..92b44a1080 100644
--- a/deps/npm/lib/install/save.js
+++ b/deps/npm/lib/install/save.js
@@ -44,7 +44,7 @@ exports.saveShrinkwrap = saveShrinkwrap
function saveShrinkwrap (tree, next) {
validate('OF', arguments)
- if (!npm.config.get('shrinkwrap') || !npm.config.get('package-lock')) {
+ if (!npm.config.get('package-lock-only') && (!npm.config.get('shrinkwrap') || !npm.config.get('package-lock'))) {
return next()
}
require('../shrinkwrap.js').createShrinkwrap(tree, {silent: false}, next)
diff --git a/deps/npm/lib/ls.js b/deps/npm/lib/ls.js
index bb5e433f78..78a2b1d791 100644
--- a/deps/npm/lib/ls.js
+++ b/deps/npm/lib/ls.js
@@ -12,6 +12,7 @@ var readPackageTree = require('read-package-tree')
var archy = require('archy')
var semver = require('semver')
var color = require('ansicolors')
+var moduleName = require('./utils/module-name.js')
var npa = require('npm-package-arg')
var sortedObject = require('sorted-object')
var npm = require('./npm.js')
@@ -59,7 +60,9 @@ var lsFromTree = ls.fromTree = function (dir, physicalTree, args, silent, cb) {
args = []
} else {
args = args.map(function (a) {
- if (typeof a === 'object') {
+ if (typeof a === 'object' && a.package._requested.type === 'alias') {
+ return [moduleName(a), `npm:${a.package.name}@${a.package.version}`, a]
+ } else if (typeof a === 'object') {
return [a.package.name, a.package.version, a]
} else {
var p = npa(a)
@@ -305,7 +308,7 @@ function filterFound (root, args) {
if (!markDeps) continue
Object.keys(markDeps).forEach(function (depName) {
var dep = markDeps[depName]
- if (dep.peerMissing) return
+ if (dep.peerMissing && !dep._from) return
dep._parent = markPkg
for (var ii = 0; ii < args.length; ii++) {
var argName = args[ii][0]
@@ -392,8 +395,11 @@ function makeArchy_ (data, long, dir, depth, parent, d) {
}
var out = {}
- // the top level is a bit special.
- out.label = data._id || ''
+ if (data._requested && data._requested.type === 'alias') {
+ out.label = `${d}@npm:${data._id}`
+ } else {
+ out.label = data._id || ''
+ }
if (data._found === 'explicit' && data._id) {
if (npm.color) {
out.label = color.bgBlack(color.yellow(out.label.trim())) + ' '
diff --git a/deps/npm/lib/outdated.js b/deps/npm/lib/outdated.js
index ebd67fb6b3..197b719625 100644
--- a/deps/npm/lib/outdated.js
+++ b/deps/npm/lib/outdated.js
@@ -20,30 +20,30 @@ outdated.usage = 'npm outdated [[<@scope>/]<pkg> ...]'
outdated.completion = require('./utils/completion/installed-deep.js')
-var os = require('os')
-var url = require('url')
-var path = require('path')
-var readPackageTree = require('read-package-tree')
-var asyncMap = require('slide').asyncMap
-var color = require('ansicolors')
-var styles = require('ansistyles')
-var table = require('text-table')
-var semver = require('semver')
-var npa = require('libnpm/parse-arg')
-var pickManifest = require('npm-pick-manifest')
-var fetchPackageMetadata = require('./fetch-package-metadata.js')
-var mutateIntoLogicalTree = require('./install/mutate-into-logical-tree.js')
-var npm = require('./npm.js')
+const os = require('os')
+const url = require('url')
+const path = require('path')
+const readPackageTree = require('read-package-tree')
+const asyncMap = require('slide').asyncMap
+const color = require('ansicolors')
+const styles = require('ansistyles')
+const table = require('text-table')
+const semver = require('semver')
+const npa = require('libnpm/parse-arg')
+const pickManifest = require('npm-pick-manifest')
+const fetchPackageMetadata = require('./fetch-package-metadata.js')
+const mutateIntoLogicalTree = require('./install/mutate-into-logical-tree.js')
+const npm = require('./npm.js')
const npmConfig = require('./config/figgy-config.js')
const figgyPudding = require('figgy-pudding')
const packument = require('libnpm/packument')
-var long = npm.config.get('long')
-var isExtraneous = require('./install/is-extraneous.js')
-var computeMetadata = require('./install/deps.js').computeMetadata
-var computeVersionSpec = require('./install/deps.js').computeVersionSpec
-var moduleName = require('./utils/module-name.js')
-var output = require('./utils/output.js')
-var ansiTrim = require('./utils/ansi-trim')
+const long = npm.config.get('long')
+const isExtraneous = require('./install/is-extraneous.js')
+const computeMetadata = require('./install/deps.js').computeMetadata
+const computeVersionSpec = require('./install/deps.js').computeVersionSpec
+const moduleName = require('./utils/module-name.js')
+const output = require('./utils/output.js')
+const ansiTrim = require('./utils/ansi-trim')
const OutdatedConfig = figgyPudding({
also: {},
@@ -157,7 +157,7 @@ function makePretty (p, opts) {
}
if (opts.color) {
- columns[0] = color[has === want || want === 'linked' ? 'yellow' : 'red'](columns[0]) // dep
+ columns[0] = color[has === want ? 'yellow' : 'red'](columns[0]) // dep
columns[2] = color.green(columns[2]) // want
columns[3] = color.magenta(columns[3]) // latest
}
@@ -215,8 +215,8 @@ function makeJSON (list, opts) {
function outdated_ (args, path, tree, parentHas, depth, opts, cb) {
if (!tree.package) tree.package = {}
- if (path && tree.package.name) path += ' > ' + tree.package.name
- if (!path && tree.package.name) path = tree.package.name
+ if (path && moduleName(tree)) path += ' > ' + tree.package.name
+ if (!path && moduleName(tree)) path = tree.package.name
if (depth > opts.depth) {
return cb(null, [])
}
@@ -298,10 +298,10 @@ function outdated_ (args, path, tree, parentHas, depth, opts, cb) {
var has = Object.create(parentHas)
tree.children.forEach(function (child) {
- if (child.package.name && child.package.private) {
+ if (moduleName(child) && child.package.private) {
deps = deps.filter(function (dep) { return dep !== child })
}
- has[child.package.name] = {
+ has[moduleName(child)] = {
version: child.isLink ? 'linked' : child.package.version,
from: child.isLink ? 'file:' + child.path : child.package._from
}
@@ -349,13 +349,6 @@ function shouldUpdate (args, tree, dep, has, req, depth, pkgpath, opts, cb, type
cb)
}
- function doIt (wanted, latest) {
- if (!long) {
- return cb(null, [[tree, dep, curr && curr.version, wanted, latest, req, null, pkgpath]])
- }
- cb(null, [[tree, dep, curr && curr.version, wanted, latest, req, type, pkgpath]])
- }
-
if (args.length && args.indexOf(dep) === -1) return skip()
if (tree.isLink && req == null) return skip()
@@ -374,11 +367,22 @@ function shouldUpdate (args, tree, dep, has, req, depth, pkgpath, opts, cb, type
} else if (parsed.type === 'file') {
return updateLocalDeps()
} else {
- return packument(dep, opts.concat({
+ return packument(parsed, opts.concat({
'prefer-online': true
})).nodeify(updateDeps)
}
+ function doIt (wanted, latest) {
+ let c = curr && curr.version
+ if (parsed.type === 'alias') {
+ c = `npm:${parsed.subSpec.name}@${c}`
+ }
+ if (!long) {
+ return cb(null, [[tree, dep, c, wanted, latest, req, null, pkgpath]])
+ }
+ cb(null, [[tree, dep, c, wanted, latest, req, type, pkgpath]])
+ }
+
function updateLocalDeps (latestRegistryVersion) {
fetchPackageMetadata('file:' + parsed.fetchSpec, '.', (er, localDependency) => {
if (er) return cb()
@@ -405,6 +409,9 @@ function shouldUpdate (args, tree, dep, has, req, depth, pkgpath, opts, cb, type
function updateDeps (er, d) {
if (er) return cb(er)
+ if (parsed.type === 'alias') {
+ req = parsed.subSpec.rawSpec
+ }
try {
var l = pickManifest(d, 'latest')
var m = pickManifest(d, req)
@@ -421,11 +428,20 @@ function shouldUpdate (args, tree, dep, has, req, depth, pkgpath, opts, cb, type
var dFromUrl = m._from && url.parse(m._from).protocol
var cFromUrl = curr && curr.from && url.parse(curr.from).protocol
- if (!curr ||
- (dFromUrl && cFromUrl && m._from !== curr.from) ||
- m.version !== curr.version ||
- m.version !== l.version) {
- doIt(m.version, l.version)
+ if (
+ !curr ||
+ (dFromUrl && cFromUrl && m._from !== curr.from) ||
+ m.version !== curr.version ||
+ m.version !== l.version
+ ) {
+ if (parsed.type === 'alias') {
+ doIt(
+ `npm:${parsed.subSpec.name}@${m.version}`,
+ `npm:${parsed.subSpec.name}@${l.version}`
+ )
+ } else {
+ doIt(m.version, l.version)
+ }
} else {
skip()
}
diff --git a/deps/npm/lib/run-script.js b/deps/npm/lib/run-script.js
index 3302576311..476591c051 100644
--- a/deps/npm/lib/run-script.js
+++ b/deps/npm/lib/run-script.js
@@ -136,7 +136,7 @@ function run (pkg, wd, cmd, args, cb) {
'prestart', 'start', 'poststart'
]
} else {
- if (!pkg.scripts[cmd]) {
+ if (pkg.scripts[cmd] == null) {
if (cmd === 'test') {
pkg.scripts.test = 'echo \'Error: no test specified\''
} else if (cmd === 'env') {
diff --git a/deps/npm/lib/shrinkwrap.js b/deps/npm/lib/shrinkwrap.js
index dbb12b5bd4..75d58bf8e4 100644
--- a/deps/npm/lib/shrinkwrap.js
+++ b/deps/npm/lib/shrinkwrap.js
@@ -110,11 +110,13 @@ function shrinkwrapDeps (deps, top, tree, seen) {
var childIsOnlyDev = isOnlyDev(child)
var pkginfo = deps[moduleName(child)] = {}
var requested = getRequested(child) || child.package._requested || {}
+ var linked = child.isLink || child.isInLink
+ var linkedFromHere = linked && path.relative(top.realpath, child.realpath)[0] !== '.'
pkginfo.version = childVersion(top, child, requested)
if (requested.type === 'git' && child.package._from) {
pkginfo.from = child.package._from
}
- if (child.fromBundle || child.isInLink) {
+ if (child.fromBundle && !linked) {
pkginfo.bundled = true
} else {
if (isRegistry(requested)) {
@@ -139,7 +141,8 @@ function shrinkwrapDeps (deps, top, tree, seen) {
pkginfo.requires[moduleName(required)] = childRequested(top, required, requested)
})
}
- if (child.children.length) {
+ // iterate into children on non-links and links contained within the top level package
+ if (child.children.length && (!child.isLink || linkedFromHere)) {
pkginfo.dependencies = {}
shrinkwrapDeps(pkginfo.dependencies, top, child, seen)
}
@@ -159,6 +162,8 @@ function childVersion (top, child, req) {
return 'file:' + unixFormatPath(path.relative(top.path, child.package._resolved || req.fetchSpec))
} else if (!isRegistry(req) && !child.fromBundle) {
return child.package._resolved || req.saveSpec || req.rawSpec
+ } else if (req.type === 'alias') {
+ return `npm:${child.package.name}@${child.package.version}`
} else {
return child.package.version
}
diff --git a/deps/npm/lib/stars.js b/deps/npm/lib/stars.js
index ea3581f1d4..8b28baffd8 100644
--- a/deps/npm/lib/stars.js
+++ b/deps/npm/lib/stars.js
@@ -27,7 +27,7 @@ function stars ([user], cb) {
})
}).catch(err => {
if (err.code === 'ENEEDAUTH') {
- throw Object.assign(new Error("'npm starts' on your own user account requires auth"), {
+ throw Object.assign(new Error("'npm stars' on your own user account requires auth"), {
code: 'ENEEDAUTH'
})
} else {
diff --git a/deps/npm/lib/token.js b/deps/npm/lib/token.js
index cccbba2f9a..326f98ec7e 100644
--- a/deps/npm/lib/token.js
+++ b/deps/npm/lib/token.js
@@ -1,6 +1,9 @@
'use strict'
+
const profile = require('libnpm/profile')
const npm = require('./npm.js')
+const figgyPudding = require('figgy-pudding')
+const npmConfig = require('./config/figgy-config.js')
const output = require('./utils/output.js')
const Table = require('cli-table3')
const Bluebird = require('bluebird')
@@ -76,22 +79,43 @@ function generateTokenIds (tokens, minLength) {
return byId
}
+const TokenConfig = figgyPudding({
+ registry: {},
+ otp: {},
+ cidr: {},
+ 'read-only': {},
+ json: {},
+ parseable: {}
+})
+
function config () {
- const conf = {
- json: npm.config.get('json'),
- parseable: npm.config.get('parseable'),
- registry: npm.config.get('registry'),
- otp: npm.config.get('otp')
- }
+ let conf = TokenConfig(npmConfig())
const creds = npm.config.getCredentialsByURI(conf.registry)
if (creds.token) {
- conf.auth = {token: creds.token}
+ conf = conf.concat({
+ auth: { token: creds.token }
+ })
} else if (creds.username) {
- conf.auth = {basic: {username: creds.username, password: creds.password}}
+ conf = conf.concat({
+ auth: {
+ basic: {
+ username: creds.username,
+ password: creds.password
+ }
+ }
+ })
} else if (creds.auth) {
const auth = Buffer.from(creds.auth, 'base64').toString().split(':', 2)
- conf.auth = {basic: {username: auth[0], password: auth[1]}}
+ conf = conf.concat({
+ auth: {
+ basic: {
+ username: auth[0],
+ password: auth[1]
+ }
+ }
+ })
} else {
+ conf = conf.concat({ auth: {} })
conf.auth = {}
}
if (conf.otp) conf.auth.otp = conf.otp
@@ -183,8 +207,8 @@ function rm (args) {
function create (args) {
const conf = config()
- const cidr = npm.config.get('cidr')
- const readonly = npm.config.get('read-only')
+ const cidr = conf.cidr
+ const readonly = conf['read-only']
const validCIDR = validateCIDRList(cidr)
return readUserInfo.password().then((password) => {
diff --git a/deps/npm/lib/update.js b/deps/npm/lib/update.js
index 9b1345f9df..fdb934fac6 100644
--- a/deps/npm/lib/update.js
+++ b/deps/npm/lib/update.js
@@ -46,7 +46,7 @@ function update_ (args) {
"because it's currently at the maximum version that matches its specified semver range"
)
}
- return ww.current !== ww.wanted && ww.latest !== 'linked'
+ return ww.current !== ww.wanted
})
if (wanted.length === 0) return
diff --git a/deps/npm/lib/utils/error-message.js b/deps/npm/lib/utils/error-message.js
index 55c5463454..bf5d65c0df 100644
--- a/deps/npm/lib/utils/error-message.js
+++ b/deps/npm/lib/utils/error-message.js
@@ -154,10 +154,12 @@ function errorMessage (er) {
var msg = er.message.replace(/^404\s+/, '')
short.push(['404', msg])
if (er.pkgid && er.pkgid !== '-') {
+ var pkg = er.pkgid.replace(/(?!^)@.*$/, '')
+
detail.push(['404', ''])
detail.push(['404', '', "'" + er.pkgid + "' is not in the npm registry."])
- var valResult = nameValidator(er.pkgid)
+ var valResult = nameValidator(pkg)
if (valResult.validForNewPackages) {
detail.push(['404', 'You should bug the author to publish it (or use the name yourself!)'])
diff --git a/deps/npm/lib/utils/module-name.js b/deps/npm/lib/utils/module-name.js
index 89957b181f..18f54e4118 100644
--- a/deps/npm/lib/utils/module-name.js
+++ b/deps/npm/lib/utils/module-name.js
@@ -21,6 +21,7 @@ function isNotEmpty (str) {
var unknown = 0
function moduleName (tree) {
+ if (tree.name) { return tree.name }
var pkg = tree.package || tree
if (isNotEmpty(pkg.name) && typeof pkg.name === 'string') return pkg.name.trim()
var pkgName = pathToPackageName(tree.path)
diff --git a/deps/npm/lib/view.js b/deps/npm/lib/view.js
index 5dd605029b..fc10a2f4ac 100644
--- a/deps/npm/lib/view.js
+++ b/deps/npm/lib/view.js
@@ -243,7 +243,7 @@ function prettyView (packument, manifest, opts) {
name: color.yellow(manifest._npmUser.name),
email: color.cyan(manifest._npmUser.email)
}),
- modified: color.yellow(relativeDate(packument.time[packument.version])),
+ modified: packument.time ? color.yellow(relativeDate(packument.time[packument.version])) : undefined,
maintainers: (packument.maintainers || []).map((u) => unparsePerson({
name: color.yellow(u.name),
email: color.cyan(u.email)