summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/@npmcli/arborist
diff options
context:
space:
mode:
authornpm-robot <ops+robot@npmjs.com>2021-06-17 18:59:38 +0000
committerRuy Adorno <ruyadorno@hotmail.com>2021-06-18 11:51:54 -0400
commit98139dfef1858b3879570d7edbd5afd3259c7de3 (patch)
treeebe98ec69881970289aec5902348b50f78683fbd /deps/npm/node_modules/@npmcli/arborist
parent0536be2ad81fbee1a2c31022c3b624dc49742d62 (diff)
downloadnode-new-98139dfef1858b3879570d7edbd5afd3259c7de3.tar.gz
deps: upgrade npm to 7.18.1
PR-URL: https://github.com/nodejs/node/pull/39065 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruy Adorno <ruyadorno@github.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/@npmcli/arborist')
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js14
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js2
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-actual.js20
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js35
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js2
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js16
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/inventory.js18
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/node.js18
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/proc-log.js21
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js2
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/tracker.js2
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/package.json3
12 files changed, 77 insertions, 76 deletions
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js
index 73a6f667e3..5db11eb383 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js
@@ -7,7 +7,7 @@ const semver = require('semver')
const promiseCallLimit = require('promise-call-limit')
const getPeerSet = require('../peer-set.js')
const realpath = require('../../lib/realpath.js')
-const { resolve } = require('path')
+const { resolve, dirname } = require('path')
const { promisify } = require('util')
const treeCheck = require('../tree-check.js')
const readdir = promisify(require('readdir-scoped-modules'))
@@ -661,7 +661,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
const ancient = meta.ancientLockfile
const old = meta.loadedFromDisk && !(meta.originalLockfileVersion >= 2)
- if (inventory.size === 0 || !ancient && !(old && this[_complete]))
+ if (inventory.size === 0 || !ancient && !old)
return
// if the lockfile is from node v5 or earlier, then we'll have to reload
@@ -688,10 +688,12 @@ This is a one-time fix-up, please be patient...
this.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 = !version ||
- resolved && resolved.startsWith('file:')
- const id = useResolved ? resolved : version
- const spec = npa.resolve(name, id, path)
+ const useResolved = resolved && (
+ !version || resolved.startsWith('file:')
+ )
+ 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}`
this.addTracker(t)
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js
index b119d3117b..94501cae12 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/index.js
@@ -28,7 +28,7 @@
const {resolve} = require('path')
const {homedir} = require('os')
-const procLog = require('../proc-log.js')
+const procLog = require('proc-log')
const { saveTypeMap } = require('../add-rm-pkg-deps.js')
const mixins = [
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-actual.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-actual.js
index d9e7fb46d6..9fca7d6425 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-actual.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/load-actual.js
@@ -22,6 +22,7 @@ const _loadFSTree = Symbol('loadFSTree')
const _loadFSChildren = Symbol('loadFSChildren')
const _findMissingEdges = Symbol('findMissingEdges')
const _findFSParents = Symbol('findFSParents')
+const _resetDepFlags = Symbol('resetDepFlags')
const _actualTreeLoaded = Symbol('actualTreeLoaded')
const _rpcache = Symbol.for('realpathCache')
@@ -74,6 +75,19 @@ module.exports = cls => class ActualLoader extends cls {
this[_topNodes] = new Set()
}
+ [_resetDepFlags] (tree, root) {
+ // reset all deps to extraneous prior to recalc
+ if (!root) {
+ for (const node of tree.inventory.values())
+ node.extraneous = true
+ }
+
+ // only reset root flags if we're not re-rooting,
+ // otherwise leave as-is
+ calcDepFlags(tree, !root)
+ return tree
+ }
+
// public method
async loadActual (options = {}) {
// allow the user to set options on the ctor as well.
@@ -88,6 +102,7 @@ module.exports = cls => class ActualLoader extends cls {
return this.actualTree ? this.actualTree
: this[_actualTreePromise] ? this[_actualTreePromise]
: this[_actualTreePromise] = this[_loadActual](options)
+ .then(tree => this[_resetDepFlags](tree, options.root))
.then(tree => this.actualTree = treeCheck(tree))
}
@@ -152,8 +167,7 @@ module.exports = cls => class ActualLoader extends cls {
root: this[_actualTree],
})
await this[_loadWorkspaces](this[_actualTree])
- if (this[_actualTree].workspaces && this[_actualTree].workspaces.size)
- calcDepFlags(this[_actualTree], !root)
+
this[_transplant](root)
return this[_actualTree]
}
@@ -178,8 +192,6 @@ module.exports = cls => class ActualLoader extends cls {
dependencies[name] = dependencies[name] || '*'
actualRoot.package = { ...actualRoot.package, dependencies }
}
- // only reset root flags if we're not re-rooting, otherwise leave as-is
- calcDepFlags(this[_actualTree], !root)
return this[_actualTree]
}
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js
index 58dc7c68a4..55360538b9 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js
@@ -2,7 +2,6 @@
const onExit = require('../signal-handling.js')
const pacote = require('pacote')
-const rpj = require('read-package-json-fast')
const AuditReport = require('../audit-report.js')
const {subset, intersects} = require('semver')
const npa = require('npm-package-arg')
@@ -57,7 +56,6 @@ const _extractOrLink = Symbol('extractOrLink')
const _checkBins = Symbol.for('checkBins')
const _symlink = Symbol('symlink')
const _warnDeprecated = Symbol('warnDeprecated')
-const _loadAncientPackageDetails = Symbol('loadAncientPackageDetails')
const _loadBundlesAndUpdateTrees = Symbol.for('loadBundlesAndUpdateTrees')
const _submitQuickAudit = Symbol('submitQuickAudit')
const _awaitQuickAudit = Symbol('awaitQuickAudit')
@@ -522,7 +520,6 @@ module.exports = cls => class Reifier extends cls {
await this[_checkBins](node)
await this[_extractOrLink](node)
await this[_warnDeprecated](node)
- await this[_loadAncientPackageDetails](node)
})
return this[_handleOptionalFailure](node, p)
@@ -583,32 +580,6 @@ module.exports = cls => class Reifier extends cls {
this.log.warn('deprecated', `${_id}: ${deprecated}`)
}
- async [_loadAncientPackageDetails] (node, forceReload = false) {
- // If we're loading from a v1 lockfile, load details from the package.json
- // that weren't recorded in the old format.
- const {meta} = this.idealTree
- const ancient = meta.ancientLockfile
- const old = meta.loadedFromDisk && !(meta.originalLockfileVersion >= 2)
-
- // already replaced with the manifest if it's truly ancient
- if (node.path && (forceReload || (old && !ancient))) {
- // XXX should have a shared location where package.json is read,
- // so we don't ever read the same pj more than necessary.
- let pkg
- try {
- pkg = await rpj(node.path + '/package.json')
- } catch (err) {}
-
- if (pkg) {
- node.package.bin = pkg.bin
- node.package.os = pkg.os
- node.package.cpu = pkg.cpu
- node.package.engines = pkg.engines
- meta.add(node)
- }
- }
- }
-
// if the node is optional, then the failure of the promise is nonfatal
// just add it and its optional set to the trash list.
[_handleOptionalFailure] (node, p) {
@@ -1079,12 +1050,6 @@ module.exports = cls => class Reifier extends cls {
const { meta } = this.idealTree
- // might have to update metadata for bins and stuff that gets lost
- if (meta.loadedFromDisk && !(meta.originalLockfileVersion >= 2)) {
- for (const node of this.idealTree.inventory.values())
- await this[_loadAncientPackageDetails](node, true)
- }
-
return meta.save(saveOpt)
}
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js b/deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js
index 139a7aefd2..8f7d6546d6 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/audit-report.js
@@ -12,7 +12,7 @@ const _fixAvailable = Symbol('fixAvailable')
const _checkTopNode = Symbol('checkTopNode')
const _init = Symbol('init')
const _omit = Symbol('omit')
-const procLog = require('./proc-log.js')
+const procLog = require('proc-log')
const fetch = require('npm-registry-fetch')
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js b/deps/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js
index d6ae266db3..21d8ddcf7b 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/calc-dep-flags.js
@@ -22,6 +22,11 @@ const calcDepFlagsStep = (node) => {
// Since we're only walking through deps that are not already flagged
// as non-dev/non-optional, it's typically a very shallow traversal
node.extraneous = false
+ resetParents(node, 'extraneous')
+ resetParents(node, 'dev')
+ resetParents(node, 'peer')
+ resetParents(node, 'devOptional')
+ resetParents(node, 'optional')
// for links, map their hierarchy appropriately
if (node.target) {
@@ -29,8 +34,7 @@ const calcDepFlagsStep = (node) => {
node.target.optional = node.optional
node.target.devOptional = node.devOptional
node.target.peer = node.peer
- node.target.extraneous = false
- node = node.target
+ return calcDepFlagsStep(node.target)
}
node.edgesOut.forEach(({peer, optional, dev, to}) => {
@@ -71,6 +75,14 @@ const calcDepFlagsStep = (node) => {
return node
}
+const resetParents = (node, flag) => {
+ if (node[flag])
+ return
+
+ for (let p = node; p && (p === node || p[flag]); p = p.resolveParent)
+ p[flag] = false
+}
+
// typically a short walk, since it only traverses deps that
// have the flag set.
const unsetFlag = (node, flag) => {
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/inventory.js b/deps/npm/node_modules/@npmcli/arborist/lib/inventory.js
index 7578291885..a4ae11c2ab 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/inventory.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/inventory.js
@@ -7,6 +7,20 @@ const _index = Symbol('_index')
const defaultKeys = ['name', 'license', 'funding', 'realpath', 'packageName']
const { hasOwnProperty } = Object.prototype
const debug = require('./debug.js')
+
+// handling for the outdated "licenses" array, just pick the first one
+// also support the alternative spelling "licence"
+const getLicense = pkg => {
+ if (pkg) {
+ const lic = pkg.license || pkg.licence
+ if (lic)
+ return lic
+ const lics = pkg.licenses || pkg.licences
+ if (Array.isArray(lics))
+ return lics[0]
+ }
+}
+
class Inventory extends Map {
constructor (opt = {}) {
const { primary, keys } = opt
@@ -56,7 +70,9 @@ class Inventory extends Map {
for (const [key, map] of this[_index].entries()) {
// if the node has the value, but it's false, then use that
const val_ = hasOwnProperty.call(node, key) ? node[key]
- : node[key] || (node.package && node.package[key])
+ : key === 'license' ? getLicense(node.package)
+ : node[key] ? node[key]
+ : node.package && node.package[key]
const val = typeof val_ === 'string' ? val_
: !val_ || typeof val_ !== 'object' ? val_
: key === 'license' ? val_.type
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/node.js b/deps/npm/node_modules/@npmcli/arborist/lib/node.js
index 1683c70495..c21bc46cfb 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/node.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/node.js
@@ -547,6 +547,8 @@ class Node {
// try to find our parent/fsParent in the new root inventory
for (const p of walkUp(dirname(this.path))) {
+ if (p === this.path)
+ continue
const ploc = relpath(root.realpath, p)
const parent = root.inventory.get(ploc)
if (parent) {
@@ -783,7 +785,13 @@ class Node {
}
get fsParent () {
- return this[_fsParent]
+ const parent = this[_fsParent]
+ /* istanbul ignore next - should be impossible */
+ debug(() => {
+ if (parent === this)
+ throw new Error('node set to its own fsParent')
+ })
+ return parent
}
set fsParent (fsParent) {
@@ -1009,7 +1017,13 @@ class Node {
}
get parent () {
- return this[_parent]
+ const parent = this[_parent]
+ /* istanbul ignore next - should be impossible */
+ debug(() => {
+ if (parent === this)
+ throw new Error('node set to its own parent')
+ })
+ return parent
}
// This setter keeps everything in order when we move a node from
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/proc-log.js b/deps/npm/node_modules/@npmcli/arborist/lib/proc-log.js
deleted file mode 100644
index 52e0e46679..0000000000
--- a/deps/npm/node_modules/@npmcli/arborist/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/deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js b/deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js
index 0a19ef9300..9fb0528db4 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/shrinkwrap.js
@@ -32,7 +32,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.js')
+const procLog = require('proc-log')
const YarnLock = require('./yarn-lock.js')
const {promisify} = require('util')
const rimraf = promisify(require('rimraf'))
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/tracker.js b/deps/npm/node_modules/@npmcli/arborist/lib/tracker.js
index 47267872ce..aefd5fe1bb 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/tracker.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/tracker.js
@@ -1,6 +1,6 @@
const _progress = Symbol('_progress')
const _onError = Symbol('_onError')
-const procLog = require('./proc-log.js')
+const procLog = require('proc-log')
module.exports = cls => class Tracker extends cls {
constructor (options = {}) {
diff --git a/deps/npm/node_modules/@npmcli/arborist/package.json b/deps/npm/node_modules/@npmcli/arborist/package.json
index 7c2622f49e..bd27e4bbff 100644
--- a/deps/npm/node_modules/@npmcli/arborist/package.json
+++ b/deps/npm/node_modules/@npmcli/arborist/package.json
@@ -1,6 +1,6 @@
{
"name": "@npmcli/arborist",
- "version": "2.6.2",
+ "version": "2.6.3",
"description": "Manage node_modules trees",
"dependencies": {
"@npmcli/installed-package-contents": "^1.0.7",
@@ -22,6 +22,7 @@
"npm-registry-fetch": "^11.0.0",
"pacote": "^11.2.6",
"parse-conflict-json": "^1.1.1",
+ "proc-log": "^1.0.0",
"promise-all-reject-late": "^1.0.0",
"promise-call-limit": "^1.0.1",
"read-package-json-fast": "^2.0.2",