@npmcli/arborist 4.0.4 → 4.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +20 -0
- package/README.md +1 -1
- package/bin/prune.js +1 -1
- package/bin/reify.js +1 -1
- package/lib/add-rm-pkg-deps.js +3 -3
- package/lib/arborist/build-ideal-tree.js +6 -6
- package/lib/arborist/index.js +34 -22
- package/lib/arborist/load-actual.js +4 -4
- package/lib/arborist/load-virtual.js +4 -4
- package/lib/arborist/rebuild.js +7 -7
- package/lib/arborist/reify.js +8 -8
- package/lib/audit-report.js +3 -3
- package/lib/calc-dep-flags.js +1 -1
- package/lib/can-place-dep.js +2 -2
- package/lib/dep-valid.js +1 -1
- package/lib/diff.js +7 -7
- package/lib/from-path.js +1 -1
- package/lib/link.js +1 -1
- package/lib/node.js +6 -6
- package/lib/printable.js +2 -2
- package/lib/relpath.js +1 -1
- package/lib/retire-path.js +1 -1
- package/lib/shrinkwrap.js +4 -4
- package/lib/version-from-tgz.js +2 -2
- package/lib/vuln.js +1 -1
- package/lib/yarn-lock.js +2 -2
- package/package.json +18 -12
- package/LICENSE +0 -22
package/LICENSE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->
|
|
2
|
+
|
|
3
|
+
ISC License
|
|
4
|
+
|
|
5
|
+
Copyright npm, Inc.
|
|
6
|
+
|
|
7
|
+
Permission to use, copy, modify, and/or distribute this
|
|
8
|
+
software for any purpose with or without fee is hereby
|
|
9
|
+
granted, provided that the above copyright notice and this
|
|
10
|
+
permission notice appear in all copies.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL
|
|
13
|
+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
|
14
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
|
|
15
|
+
EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
17
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
18
|
+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
19
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Inspect and manage `node_modules` trees.
|
|
4
4
|
|
|
5
|
-

|
|
5
|
+

|
|
6
6
|
|
|
7
7
|
There's more documentation [in the notes
|
|
8
8
|
folder](https://github.com/npm/arborist/tree/main/notes).
|
package/bin/prune.js
CHANGED
package/bin/reify.js
CHANGED
package/lib/add-rm-pkg-deps.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const localeCompare = require('@isaacs/string-locale-compare')('en')
|
|
4
4
|
|
|
5
|
-
const add = ({pkg, add, saveBundle, saveType, log}) => {
|
|
5
|
+
const add = ({ pkg, add, saveBundle, saveType, log }) => {
|
|
6
6
|
for (const spec of add) {
|
|
7
|
-
addSingle({pkg, spec, saveBundle, saveType, log})
|
|
7
|
+
addSingle({ pkg, spec, saveBundle, saveType, log })
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
return pkg
|
|
@@ -20,7 +20,7 @@ const saveTypeMap = new Map([
|
|
|
20
20
|
['peer', 'peerDependencies'],
|
|
21
21
|
])
|
|
22
22
|
|
|
23
|
-
const addSingle = ({pkg, spec, saveBundle, saveType, log}) => {
|
|
23
|
+
const addSingle = ({ pkg, spec, saveBundle, saveType, log }) => {
|
|
24
24
|
const { name, rawSpec } = spec
|
|
25
25
|
|
|
26
26
|
// if the user does not give us a type, we infer which type(s)
|
|
@@ -31,7 +31,7 @@ const Node = require('../node.js')
|
|
|
31
31
|
const Link = require('../link.js')
|
|
32
32
|
const addRmPkgDeps = require('../add-rm-pkg-deps.js')
|
|
33
33
|
const optionalSet = require('../optional-set.js')
|
|
34
|
-
const {checkEngine, checkPlatform} = require('npm-install-checks')
|
|
34
|
+
const { checkEngine, checkPlatform } = require('npm-install-checks')
|
|
35
35
|
|
|
36
36
|
const relpath = require('../relpath.js')
|
|
37
37
|
|
|
@@ -311,7 +311,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
|
|
|
311
311
|
? Shrinkwrap.reset({
|
|
312
312
|
path: this.path,
|
|
313
313
|
lockfileVersion: this.options.lockfileVersion,
|
|
314
|
-
}).then(meta => Object.assign(root, {meta}))
|
|
314
|
+
}).then(meta => Object.assign(root, { meta }))
|
|
315
315
|
: this.loadVirtual({ root }))
|
|
316
316
|
|
|
317
317
|
// if we don't have a lockfile to go from, then start with the
|
|
@@ -492,7 +492,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
|
|
|
492
492
|
|
|
493
493
|
// This returns a promise because we might not have the name yet,
|
|
494
494
|
// and need to call pacote.manifest to find the name.
|
|
495
|
-
[_add] (tree, {add, saveType = null, saveBundle = false}) {
|
|
495
|
+
[_add] (tree, { add, saveType = null, saveBundle = false }) {
|
|
496
496
|
// get the name for each of the specs in the list.
|
|
497
497
|
// ie, doing `foo@bar` we just return foo
|
|
498
498
|
// but if it's a url or git, we don't know the name until we
|
|
@@ -936,7 +936,7 @@ This is a one-time fix-up, please be patient...
|
|
|
936
936
|
}
|
|
937
937
|
})
|
|
938
938
|
|
|
939
|
-
tasks.push({edge, dep})
|
|
939
|
+
tasks.push({ edge, dep })
|
|
940
940
|
}
|
|
941
941
|
|
|
942
942
|
const placeDeps = tasks
|
|
@@ -1271,7 +1271,7 @@ This is a one-time fix-up, please be patient...
|
|
|
1271
1271
|
// we typically only install non-optional peers, but we have to
|
|
1272
1272
|
// factor them into the peerSet so that we can avoid conflicts
|
|
1273
1273
|
.filter(e => e.peer && !(e.valid && e.to))
|
|
1274
|
-
.sort(({name: a}, {name: b}) => localeCompare(a, b))
|
|
1274
|
+
.sort(({ name: a }, { name: b }) => localeCompare(a, b))
|
|
1275
1275
|
|
|
1276
1276
|
for (const edge of peerEdges) {
|
|
1277
1277
|
// already placed this one, and we're happy with it.
|
|
@@ -1280,7 +1280,7 @@ This is a one-time fix-up, please be patient...
|
|
|
1280
1280
|
}
|
|
1281
1281
|
|
|
1282
1282
|
const parentEdge = node.parent.edgesOut.get(edge.name)
|
|
1283
|
-
const {isProjectRoot, isWorkspace} = node.parent.sourceReference
|
|
1283
|
+
const { isProjectRoot, isWorkspace } = node.parent.sourceReference
|
|
1284
1284
|
const isMine = isProjectRoot || isWorkspace
|
|
1285
1285
|
const conflictOK = this[_force] || !isMine && !this[_strictPeerDeps]
|
|
1286
1286
|
|
package/lib/arborist/index.js
CHANGED
|
@@ -26,9 +26,10 @@
|
|
|
26
26
|
// the base class, so that the overall voltron class is easier to test and
|
|
27
27
|
// cover, and separation of concerns can be maintained.
|
|
28
28
|
|
|
29
|
-
const {resolve} = require('path')
|
|
30
|
-
const {homedir} = require('os')
|
|
29
|
+
const { resolve } = require('path')
|
|
30
|
+
const { homedir } = require('os')
|
|
31
31
|
const procLog = require('proc-log')
|
|
32
|
+
const { depth } = require('treeverse')
|
|
32
33
|
const { saveTypeMap } = require('../add-rm-pkg-deps.js')
|
|
33
34
|
|
|
34
35
|
const mixins = [
|
|
@@ -88,6 +89,9 @@ class Arborist extends Base {
|
|
|
88
89
|
process.emit('timeEnd', 'arborist:ctor')
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
// TODO: We should change these to static functions instead
|
|
93
|
+
// of methods for the next major version
|
|
94
|
+
|
|
91
95
|
// returns an array of the actual nodes for all the workspaces
|
|
92
96
|
workspaceNodes (tree, workspaces) {
|
|
93
97
|
return getWorkspaceNodes(tree, workspaces, this.log)
|
|
@@ -103,15 +107,15 @@ class Arborist extends Base {
|
|
|
103
107
|
}
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
|
-
const
|
|
110
|
+
const wsDepSet = new Set(wsNodes)
|
|
107
111
|
const extraneous = new Set()
|
|
108
|
-
for (const node of
|
|
112
|
+
for (const node of wsDepSet) {
|
|
109
113
|
for (const edge of node.edgesOut.values()) {
|
|
110
114
|
const dep = edge.to
|
|
111
115
|
if (dep) {
|
|
112
|
-
|
|
116
|
+
wsDepSet.add(dep)
|
|
113
117
|
if (dep.isLink) {
|
|
114
|
-
|
|
118
|
+
wsDepSet.add(dep.target)
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
}
|
|
@@ -122,28 +126,36 @@ class Arborist extends Base {
|
|
|
122
126
|
}
|
|
123
127
|
}
|
|
124
128
|
for (const extra of extraneous) {
|
|
125
|
-
|
|
129
|
+
wsDepSet.add(extra)
|
|
126
130
|
}
|
|
127
131
|
|
|
128
|
-
return
|
|
132
|
+
return wsDepSet
|
|
129
133
|
}
|
|
130
134
|
|
|
135
|
+
// returns a set of root dependencies, excluding depdencies that are
|
|
136
|
+
// exclusively workspace dependencies
|
|
131
137
|
excludeWorkspacesDependencySet (tree) {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
const rootDepSet = new Set()
|
|
139
|
+
depth({
|
|
140
|
+
tree,
|
|
141
|
+
visit: node => {
|
|
142
|
+
for (const { to } of node.edgesOut.values()) {
|
|
143
|
+
if (!to || to.isWorkspace) {
|
|
144
|
+
continue
|
|
145
|
+
}
|
|
146
|
+
for (const edgeIn of to.edgesIn.values()) {
|
|
147
|
+
if (edgeIn.from.isRoot || rootDepSet.has(edgeIn.from)) {
|
|
148
|
+
rootDepSet.add(to)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
142
151
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
152
|
+
return node
|
|
153
|
+
},
|
|
154
|
+
filter: node => node,
|
|
155
|
+
getChildren: (node, tree) =>
|
|
156
|
+
[...tree.edgesOut.values()].map(edge => edge.to),
|
|
157
|
+
})
|
|
158
|
+
return rootDepSet
|
|
147
159
|
}
|
|
148
160
|
}
|
|
149
161
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// mix-in implementing the loadActual method
|
|
2
2
|
|
|
3
|
-
const {relative, dirname, resolve, join, normalize} = require('path')
|
|
3
|
+
const { relative, dirname, resolve, join, normalize } = require('path')
|
|
4
4
|
|
|
5
5
|
const rpj = require('read-package-json-fast')
|
|
6
|
-
const {promisify} = require('util')
|
|
6
|
+
const { promisify } = require('util')
|
|
7
7
|
const readdir = promisify(require('readdir-scoped-modules'))
|
|
8
8
|
const walkUp = require('walk-up-path')
|
|
9
9
|
const ancestorPath = require('common-ancestor-path')
|
|
@@ -128,7 +128,7 @@ module.exports = cls => class ActualLoader extends cls {
|
|
|
128
128
|
pkg: {},
|
|
129
129
|
global,
|
|
130
130
|
})
|
|
131
|
-
return this[_loadActualActually]({root, ignoreMissing, global})
|
|
131
|
+
return this[_loadActualActually]({ root, ignoreMissing, global })
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
// not in global mode, hidden lockfile is allowed, load root pkg too
|
|
@@ -163,7 +163,7 @@ module.exports = cls => class ActualLoader extends cls {
|
|
|
163
163
|
// we can't easily get a ref to Arborist in this module, without
|
|
164
164
|
// creating a circular reference, since this class is a mixin used
|
|
165
165
|
// to build up the Arborist class itself.
|
|
166
|
-
await new this.constructor({...this.options}).loadVirtual({
|
|
166
|
+
await new this.constructor({ ...this.options }).loadVirtual({
|
|
167
167
|
root: this[_actualTree],
|
|
168
168
|
})
|
|
169
169
|
await this[_loadWorkspaces](this[_actualTree])
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// mixin providing the loadVirtual method
|
|
2
2
|
const localeCompare = require('@isaacs/string-locale-compare')('en')
|
|
3
3
|
|
|
4
|
-
const {resolve} = require('path')
|
|
4
|
+
const { resolve } = require('path')
|
|
5
5
|
|
|
6
6
|
const nameFromFolder = require('@npmcli/name-from-folder')
|
|
7
7
|
const consistentResolve = require('../consistent-resolve.js')
|
|
@@ -97,7 +97,7 @@ module.exports = cls => class VirtualLoader extends cls {
|
|
|
97
97
|
this[checkRootEdges](s, root)
|
|
98
98
|
root.meta = s
|
|
99
99
|
this.virtualTree = root
|
|
100
|
-
const {links, nodes} = this[resolveNodes](s, root)
|
|
100
|
+
const { links, nodes } = this[resolveNodes](s, root)
|
|
101
101
|
await this[resolveLinks](links, nodes)
|
|
102
102
|
if (!(s.originalLockfileVersion >= 2)) {
|
|
103
103
|
this[assignBundles](nodes)
|
|
@@ -208,7 +208,7 @@ module.exports = cls => class VirtualLoader extends cls {
|
|
|
208
208
|
nodes.set(location, this[loadNode](location, meta))
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
return {links, nodes}
|
|
211
|
+
return { links, nodes }
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
// links is the set of metadata, and nodes is the map of non-Link nodes
|
|
@@ -240,7 +240,7 @@ module.exports = cls => class VirtualLoader extends cls {
|
|
|
240
240
|
if (!location || node.isLink && !node.target.location) {
|
|
241
241
|
continue
|
|
242
242
|
}
|
|
243
|
-
const { name, parent, package: { inBundle }} = node
|
|
243
|
+
const { name, parent, package: { inBundle } } = node
|
|
244
244
|
|
|
245
245
|
if (!parent) {
|
|
246
246
|
continue
|
package/lib/arborist/rebuild.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// bundle building needed. Called by reify, and by `npm rebuild`.
|
|
3
3
|
|
|
4
4
|
const localeCompare = require('@isaacs/string-locale-compare')('en')
|
|
5
|
-
const {depth: dfwalk} = require('treeverse')
|
|
5
|
+
const { depth: dfwalk } = require('treeverse')
|
|
6
6
|
const promiseAllRejectLate = require('promise-all-reject-late')
|
|
7
7
|
const rpj = require('read-package-json-fast')
|
|
8
8
|
const binLinks = require('bin-links')
|
|
9
9
|
const runScript = require('@npmcli/run-script')
|
|
10
10
|
const promiseCallLimit = require('promise-call-limit')
|
|
11
|
-
const {resolve} = require('path')
|
|
11
|
+
const { resolve } = require('path')
|
|
12
12
|
const {
|
|
13
13
|
isNodeGypPackage,
|
|
14
14
|
defaultGypInstallScript,
|
|
@@ -220,7 +220,7 @@ module.exports = cls => class Builder extends cls {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
if (this[_oldMeta] === null) {
|
|
223
|
-
const {root: {meta}} = node
|
|
223
|
+
const { root: { meta } } = node
|
|
224
224
|
this[_oldMeta] = meta && meta.loadedFromDisk &&
|
|
225
225
|
!(meta.originalLockfileVersion >= 2)
|
|
226
226
|
}
|
|
@@ -242,7 +242,7 @@ module.exports = cls => class Builder extends cls {
|
|
|
242
242
|
const pkg = await rpj(node.path + '/package.json').catch(() => ({}))
|
|
243
243
|
set.delete(node)
|
|
244
244
|
|
|
245
|
-
const {scripts = {}} = pkg
|
|
245
|
+
const { scripts = {} } = pkg
|
|
246
246
|
node.package.scripts = scripts
|
|
247
247
|
return this[_addToBuildSet](node, set, true)
|
|
248
248
|
}
|
|
@@ -319,9 +319,9 @@ module.exports = cls => class Builder extends cls {
|
|
|
319
319
|
}
|
|
320
320
|
const p = runScript(runOpts).catch(er => {
|
|
321
321
|
const { code, signal } = er
|
|
322
|
-
this.log.info('run', pkg._id, event, {code, signal})
|
|
322
|
+
this.log.info('run', pkg._id, event, { code, signal })
|
|
323
323
|
throw er
|
|
324
|
-
}).then(({args, code, signal, stdout, stderr}) => {
|
|
324
|
+
}).then(({ args, code, signal, stdout, stderr }) => {
|
|
325
325
|
this.scriptsRun.add({
|
|
326
326
|
pkg,
|
|
327
327
|
path,
|
|
@@ -333,7 +333,7 @@ module.exports = cls => class Builder extends cls {
|
|
|
333
333
|
stdout,
|
|
334
334
|
stderr,
|
|
335
335
|
})
|
|
336
|
-
this.log.info('run', pkg._id, event, {code, signal})
|
|
336
|
+
this.log.info('run', pkg._id, event, { code, signal })
|
|
337
337
|
})
|
|
338
338
|
|
|
339
339
|
await (this[_doHandleOptionalFailure]
|
package/lib/arborist/reify.js
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
const onExit = require('../signal-handling.js')
|
|
4
4
|
const pacote = require('pacote')
|
|
5
5
|
const AuditReport = require('../audit-report.js')
|
|
6
|
-
const {subset, intersects} = require('semver')
|
|
6
|
+
const { subset, intersects } = require('semver')
|
|
7
7
|
const npa = require('npm-package-arg')
|
|
8
8
|
const debug = require('../debug.js')
|
|
9
9
|
const walkUp = require('walk-up-path')
|
|
10
10
|
|
|
11
|
-
const {dirname, resolve, relative} = require('path')
|
|
12
|
-
const {depth: dfwalk} = require('treeverse')
|
|
11
|
+
const { dirname, resolve, relative } = require('path')
|
|
12
|
+
const { depth: dfwalk } = require('treeverse')
|
|
13
13
|
const fs = require('fs')
|
|
14
|
-
const {promisify} = require('util')
|
|
14
|
+
const { promisify } = require('util')
|
|
15
15
|
const lstat = promisify(fs.lstat)
|
|
16
16
|
const symlink = promisify(fs.symlink)
|
|
17
17
|
const mkdirp = require('mkdirp-infer-owner')
|
|
@@ -188,7 +188,7 @@ module.exports = cls => class Reifier extends cls {
|
|
|
188
188
|
// ok, we're about to start touching the fs. need to roll back
|
|
189
189
|
// if we get an early termination.
|
|
190
190
|
let reifyTerminated = null
|
|
191
|
-
const removeHandler = onExit(({signal}) => {
|
|
191
|
+
const removeHandler = onExit(({ signal }) => {
|
|
192
192
|
// only call once. if signal hits twice, we just terminate
|
|
193
193
|
removeHandler()
|
|
194
194
|
reifyTerminated = Object.assign(new Error('process terminated'), {
|
|
@@ -352,7 +352,7 @@ module.exports = cls => class Reifier extends cls {
|
|
|
352
352
|
if (includeRootDeps) {
|
|
353
353
|
// add all non-workspace nodes to filterNodes
|
|
354
354
|
for (const tree of [this.idealTree, this.actualTree]) {
|
|
355
|
-
for (const {type, to} of tree.edgesOut.values()) {
|
|
355
|
+
for (const { type, to } of tree.edgesOut.values()) {
|
|
356
356
|
if (type !== 'workspace' && to) {
|
|
357
357
|
filterNodes.push(to)
|
|
358
358
|
}
|
|
@@ -686,7 +686,7 @@ module.exports = cls => class Reifier extends cls {
|
|
|
686
686
|
}
|
|
687
687
|
|
|
688
688
|
[_warnDeprecated] (node) {
|
|
689
|
-
const {_id, deprecated} = node.package
|
|
689
|
+
const { _id, deprecated } = node.package
|
|
690
690
|
if (deprecated) {
|
|
691
691
|
this.log.warn('deprecated', `${_id}: ${deprecated}`)
|
|
692
692
|
}
|
|
@@ -1159,7 +1159,7 @@ module.exports = cls => class Reifier extends cls {
|
|
|
1159
1159
|
const edge = addTree.edgesOut.get(name)
|
|
1160
1160
|
const pkg = addTree.package
|
|
1161
1161
|
const req = npa.resolve(name, edge.spec, addTree.realpath)
|
|
1162
|
-
const {rawSpec, subSpec} = req
|
|
1162
|
+
const { rawSpec, subSpec } = req
|
|
1163
1163
|
|
|
1164
1164
|
const spec = subSpec ? subSpec.rawSpec : rawSpec
|
|
1165
1165
|
const child = edge.to
|
package/lib/audit-report.js
CHANGED
|
@@ -265,7 +265,7 @@ class AuditReport extends Map {
|
|
|
265
265
|
avoid: vuln.range,
|
|
266
266
|
avoidStrict: true,
|
|
267
267
|
})
|
|
268
|
-
return {name, version, isSemVerMajor}
|
|
268
|
+
return { name, version, isSemVerMajor }
|
|
269
269
|
} catch (er) {
|
|
270
270
|
return false
|
|
271
271
|
}
|
|
@@ -285,7 +285,7 @@ class AuditReport extends Map {
|
|
|
285
285
|
}
|
|
286
286
|
|
|
287
287
|
const bulk = {}
|
|
288
|
-
const {advisories} = report
|
|
288
|
+
const { advisories } = report
|
|
289
289
|
for (const advisory of Object.values(advisories)) {
|
|
290
290
|
const {
|
|
291
291
|
id,
|
|
@@ -296,7 +296,7 @@ class AuditReport extends Map {
|
|
|
296
296
|
module_name: name,
|
|
297
297
|
} = advisory
|
|
298
298
|
bulk[name] = bulk[name] || []
|
|
299
|
-
bulk[name].push({id, url, title, severity, vulnerable_versions})
|
|
299
|
+
bulk[name].push({ id, url, title, severity, vulnerable_versions })
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
return bulk
|
package/lib/calc-dep-flags.js
CHANGED
|
@@ -38,7 +38,7 @@ const calcDepFlagsStep = (node) => {
|
|
|
38
38
|
return calcDepFlagsStep(node.target)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
node.edgesOut.forEach(({peer, optional, dev, to}) => {
|
|
41
|
+
node.edgesOut.forEach(({ peer, optional, dev, to }) => {
|
|
42
42
|
// if the dep is missing, then its flags are already maximally unset
|
|
43
43
|
if (!to) {
|
|
44
44
|
return
|
package/lib/can-place-dep.js
CHANGED
|
@@ -78,7 +78,7 @@ class CanPlaceDep {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
this._treeSnapshot = JSON.stringify([...target.root.inventory.entries()]
|
|
81
|
-
.map(([loc, {packageName, version, resolved}]) => {
|
|
81
|
+
.map(([loc, { packageName, version, resolved }]) => {
|
|
82
82
|
return [loc, packageName, version, resolved]
|
|
83
83
|
}).sort(([a], [b]) => localeCompare(a, b)))
|
|
84
84
|
})
|
|
@@ -118,7 +118,7 @@ class CanPlaceDep {
|
|
|
118
118
|
|
|
119
119
|
debug(() => {
|
|
120
120
|
const treeSnapshot = JSON.stringify([...target.root.inventory.entries()]
|
|
121
|
-
.map(([loc, {packageName, version, resolved}]) => {
|
|
121
|
+
.map(([loc, { packageName, version, resolved }]) => {
|
|
122
122
|
return [loc, packageName, version, resolved]
|
|
123
123
|
}).sort(([a], [b]) => localeCompare(a, b)))
|
|
124
124
|
/* istanbul ignore if */
|
package/lib/dep-valid.js
CHANGED
package/lib/diff.js
CHANGED
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
// Thus, the root Diff node is the shallowest change required
|
|
6
6
|
// for a given branch of the tree being mutated.
|
|
7
7
|
|
|
8
|
-
const {depth} = require('treeverse')
|
|
9
|
-
const {existsSync} = require('fs')
|
|
8
|
+
const { depth } = require('treeverse')
|
|
9
|
+
const { existsSync } = require('fs')
|
|
10
10
|
|
|
11
11
|
const ssri = require('ssri')
|
|
12
12
|
|
|
13
13
|
class Diff {
|
|
14
|
-
constructor ({actual, ideal, filterSet, shrinkwrapInflated}) {
|
|
14
|
+
constructor ({ actual, ideal, filterSet, shrinkwrapInflated }) {
|
|
15
15
|
this.filterSet = filterSet
|
|
16
16
|
this.shrinkwrapInflated = shrinkwrapInflated
|
|
17
17
|
this.children = []
|
|
@@ -94,14 +94,14 @@ class Diff {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
return depth({
|
|
97
|
-
tree: new Diff({actual, ideal, filterSet, shrinkwrapInflated}),
|
|
97
|
+
tree: new Diff({ actual, ideal, filterSet, shrinkwrapInflated }),
|
|
98
98
|
getChildren,
|
|
99
99
|
leave,
|
|
100
100
|
})
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
const getAction = ({actual, ideal}) => {
|
|
104
|
+
const getAction = ({ actual, ideal }) => {
|
|
105
105
|
if (!ideal) {
|
|
106
106
|
return 'REMOVE'
|
|
107
107
|
}
|
|
@@ -237,7 +237,7 @@ const diffNode = ({
|
|
|
237
237
|
return
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
const action = getAction({actual, ideal})
|
|
240
|
+
const action = getAction({ actual, ideal })
|
|
241
241
|
|
|
242
242
|
// if it's a match, then get its children
|
|
243
243
|
// otherwise, this is the child diff node
|
|
@@ -245,7 +245,7 @@ const diffNode = ({
|
|
|
245
245
|
if (action === 'REMOVE') {
|
|
246
246
|
removed.push(actual)
|
|
247
247
|
}
|
|
248
|
-
children.push(new Diff({actual, ideal, filterSet, shrinkwrapInflated}))
|
|
248
|
+
children.push(new Diff({ actual, ideal, filterSet, shrinkwrapInflated }))
|
|
249
249
|
} else {
|
|
250
250
|
unchanged.push(ideal)
|
|
251
251
|
// !*! Weird dirty hack warning !*!
|
package/lib/from-path.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// end up getting installed. directory (ie, symlink) deps also need
|
|
4
4
|
// to be resolved based on their targets, but that's what realpath is
|
|
5
5
|
|
|
6
|
-
const {dirname} = require('path')
|
|
6
|
+
const { dirname } = require('path')
|
|
7
7
|
const npa = require('npm-package-arg')
|
|
8
8
|
|
|
9
9
|
const fromPath = (node, spec) =>
|
package/lib/link.js
CHANGED
|
@@ -3,7 +3,7 @@ const relpath = require('./relpath.js')
|
|
|
3
3
|
const Node = require('./node.js')
|
|
4
4
|
const _loadDeps = Symbol.for('Arborist.Node._loadDeps')
|
|
5
5
|
const _target = Symbol.for('_target')
|
|
6
|
-
const {dirname} = require('path')
|
|
6
|
+
const { dirname } = require('path')
|
|
7
7
|
// defined by Node class
|
|
8
8
|
const _delistFromMeta = Symbol.for('_delistFromMeta')
|
|
9
9
|
const _refreshLocation = Symbol.for('_refreshLocation')
|
package/lib/node.js
CHANGED
|
@@ -32,15 +32,15 @@ const semver = require('semver')
|
|
|
32
32
|
const nameFromFolder = require('@npmcli/name-from-folder')
|
|
33
33
|
const Edge = require('./edge.js')
|
|
34
34
|
const Inventory = require('./inventory.js')
|
|
35
|
-
const {normalize} = require('read-package-json-fast')
|
|
36
|
-
const {getPaths: getBinPaths} = require('bin-links')
|
|
35
|
+
const { normalize } = require('read-package-json-fast')
|
|
36
|
+
const { getPaths: getBinPaths } = require('bin-links')
|
|
37
37
|
const npa = require('npm-package-arg')
|
|
38
38
|
const debug = require('./debug.js')
|
|
39
39
|
const gatherDepSet = require('./gather-dep-set.js')
|
|
40
40
|
const treeCheck = require('./tree-check.js')
|
|
41
41
|
const walkUp = require('walk-up-path')
|
|
42
42
|
|
|
43
|
-
const {resolve, relative, dirname, basename} = require('path')
|
|
43
|
+
const { resolve, relative, dirname, basename } = require('path')
|
|
44
44
|
const util = require('util')
|
|
45
45
|
const _package = Symbol('_package')
|
|
46
46
|
const _parent = Symbol('_parent')
|
|
@@ -291,8 +291,8 @@ class Node {
|
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
get hasInstallScript () {
|
|
294
|
-
const {hasInstallScript, scripts} = this.package
|
|
295
|
-
const {install, preinstall, postinstall} = scripts || {}
|
|
294
|
+
const { hasInstallScript, scripts } = this.package
|
|
295
|
+
const { install, preinstall, postinstall } = scripts || {}
|
|
296
296
|
return !!(hasInstallScript || install || preinstall || postinstall)
|
|
297
297
|
}
|
|
298
298
|
|
|
@@ -376,7 +376,7 @@ class Node {
|
|
|
376
376
|
}
|
|
377
377
|
|
|
378
378
|
if (this.root.sourceReference) {
|
|
379
|
-
const {name, version} = this.root.package
|
|
379
|
+
const { name, version } = this.root.package
|
|
380
380
|
why.whileInstalling = {
|
|
381
381
|
name,
|
|
382
382
|
version,
|
package/lib/printable.js
CHANGED
|
@@ -87,7 +87,7 @@ class ArboristNode {
|
|
|
87
87
|
// fsChildren sorted by path
|
|
88
88
|
if (tree.fsChildren.size) {
|
|
89
89
|
this.fsChildren = new Set([...tree.fsChildren]
|
|
90
|
-
.sort(({path: a}, {path: b}) => localeCompare(a, b))
|
|
90
|
+
.sort(({ path: a }, { path: b }) => localeCompare(a, b))
|
|
91
91
|
.map(tree => printableTree(tree, path)))
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -114,7 +114,7 @@ class ArboristLink extends ArboristNode {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
const treeError = ({code, path}) => ({
|
|
117
|
+
const treeError = ({ code, path }) => ({
|
|
118
118
|
code,
|
|
119
119
|
...(path ? { path } : {}),
|
|
120
120
|
})
|
package/lib/relpath.js
CHANGED
package/lib/retire-path.js
CHANGED
package/lib/shrinkwrap.js
CHANGED
|
@@ -35,7 +35,7 @@ const mismatch = (a, b) => a && b && a !== b
|
|
|
35
35
|
|
|
36
36
|
const procLog = require('proc-log')
|
|
37
37
|
const YarnLock = require('./yarn-lock.js')
|
|
38
|
-
const {promisify} = require('util')
|
|
38
|
+
const { promisify } = require('util')
|
|
39
39
|
const rimraf = promisify(require('rimraf'))
|
|
40
40
|
const fs = require('fs')
|
|
41
41
|
const readFile = promisify(fs.readFile)
|
|
@@ -180,7 +180,7 @@ const assertNoNewer = async (path, data, lockTime, dir = path, seen = null) => {
|
|
|
180
180
|
|
|
181
181
|
const parent = isParent ? dir : resolve(dir, 'node_modules')
|
|
182
182
|
const children = dir === path
|
|
183
|
-
? Promise.resolve([{name: 'node_modules', isDirectory: () => true }])
|
|
183
|
+
? Promise.resolve([{ name: 'node_modules', isDirectory: () => true }])
|
|
184
184
|
: readdir(parent, { withFileTypes: true })
|
|
185
185
|
|
|
186
186
|
return children.catch(() => [])
|
|
@@ -366,7 +366,7 @@ class Shrinkwrap {
|
|
|
366
366
|
if (fromYarn && fromYarn.version) {
|
|
367
367
|
// if it's the yarn or npm default registry, use the version as
|
|
368
368
|
// our effective spec. if it's any other kind of thing, use that.
|
|
369
|
-
const {resolved, version, integrity} = fromYarn
|
|
369
|
+
const { resolved, version, integrity } = fromYarn
|
|
370
370
|
const isYarnReg = spec.registry && yarnRegRe.test(resolved)
|
|
371
371
|
const isnpmReg = spec.registry && !isYarnReg && npmRegRe.test(resolved)
|
|
372
372
|
const isReg = isnpmReg || isYarnReg
|
|
@@ -1062,7 +1062,7 @@ class Shrinkwrap {
|
|
|
1062
1062
|
}
|
|
1063
1063
|
|
|
1064
1064
|
// now we walk the children, putting them in the 'dependencies' object
|
|
1065
|
-
const {children} = node.target
|
|
1065
|
+
const { children } = node.target
|
|
1066
1066
|
if (!children.size) {
|
|
1067
1067
|
delete lock.dependencies
|
|
1068
1068
|
} else {
|
package/lib/version-from-tgz.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint node/no-deprecated-api: "off" */
|
|
2
2
|
const semver = require('semver')
|
|
3
|
-
const {basename} = require('path')
|
|
4
|
-
const {parse} = require('url')
|
|
3
|
+
const { basename } = require('path')
|
|
4
|
+
const { parse } = require('url')
|
|
5
5
|
module.exports = (name, tgz) => {
|
|
6
6
|
const base = basename(tgz)
|
|
7
7
|
if (!base.endsWith('.tgz')) {
|
package/lib/vuln.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// @npmcli/metavuln-calculator
|
|
12
12
|
// - via: dependency vulns which cause this one
|
|
13
13
|
|
|
14
|
-
const {satisfies, simplifyRange} = require('semver')
|
|
14
|
+
const { satisfies, simplifyRange } = require('semver')
|
|
15
15
|
const semverOpt = { loose: true, includePrerelease: true }
|
|
16
16
|
|
|
17
17
|
const localeCompare = require('@isaacs/string-locale-compare')('en')
|
package/lib/yarn-lock.js
CHANGED
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
|
|
31
31
|
const localeCompare = require('@isaacs/string-locale-compare')('en')
|
|
32
32
|
const consistentResolve = require('./consistent-resolve.js')
|
|
33
|
-
const {dirname} = require('path')
|
|
34
|
-
const {breadth} = require('treeverse')
|
|
33
|
+
const { dirname } = require('path')
|
|
34
|
+
const { breadth } = require('treeverse')
|
|
35
35
|
|
|
36
36
|
// sort a key/value object into a string of JSON stringified keys and vals
|
|
37
37
|
const sortKV = obj => Object.keys(obj)
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npmcli/arborist",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"description": "Manage node_modules trees",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@isaacs/string-locale-compare": "^1.0
|
|
6
|
+
"@isaacs/string-locale-compare": "^1.1.0",
|
|
7
7
|
"@npmcli/installed-package-contents": "^1.0.7",
|
|
8
8
|
"@npmcli/map-workspaces": "^2.0.0",
|
|
9
9
|
"@npmcli/metavuln-calculator": "^2.0.0",
|
|
10
10
|
"@npmcli/move-file": "^1.1.0",
|
|
11
11
|
"@npmcli/name-from-folder": "^1.0.1",
|
|
12
|
-
"@npmcli/node-gyp": "^1.0.
|
|
12
|
+
"@npmcli/node-gyp": "^1.0.3",
|
|
13
13
|
"@npmcli/package-json": "^1.0.1",
|
|
14
14
|
"@npmcli/run-script": "^2.0.0",
|
|
15
15
|
"bin-links": "^2.3.0",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"npm-package-arg": "^8.1.5",
|
|
24
24
|
"npm-pick-manifest": "^6.1.0",
|
|
25
25
|
"npm-registry-fetch": "^11.0.0",
|
|
26
|
-
"pacote": "^12.0.
|
|
26
|
+
"pacote": "^12.0.2",
|
|
27
27
|
"parse-conflict-json": "^1.1.1",
|
|
28
28
|
"proc-log": "^1.0.0",
|
|
29
29
|
"promise-all-reject-late": "^1.0.0",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"walk-up-path": "^1.0.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@npmcli/
|
|
40
|
+
"@npmcli/template-oss": "^2.3.0",
|
|
41
41
|
"benchmark": "^2.1.4",
|
|
42
42
|
"chalk": "^4.1.0",
|
|
43
43
|
"minify-registry-metadata": "^2.1.0",
|
|
44
|
-
"tap": "^15.
|
|
44
|
+
"tap": "^15.1.2",
|
|
45
45
|
"tcompare": "^5.0.6"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
@@ -54,21 +54,22 @@
|
|
|
54
54
|
"postversion": "npm publish",
|
|
55
55
|
"prepublishOnly": "git push origin --follow-tags",
|
|
56
56
|
"eslint": "eslint",
|
|
57
|
-
"lint": "
|
|
57
|
+
"lint": "eslint '**/*.js'",
|
|
58
58
|
"lintfix": "npm run lint -- --fix",
|
|
59
59
|
"benchmark": "node scripts/benchmark.js",
|
|
60
60
|
"benchclean": "rm -rf scripts/benchmark/*/",
|
|
61
|
-
"npmclilint": "npmcli-lint"
|
|
61
|
+
"npmclilint": "npmcli-lint",
|
|
62
|
+
"postlint": "npm-template-check"
|
|
62
63
|
},
|
|
63
64
|
"repository": {
|
|
64
65
|
"type": "git",
|
|
65
66
|
"url": "https://github.com/npm/arborist"
|
|
66
67
|
},
|
|
67
|
-
"author": "
|
|
68
|
+
"author": "GitHub Inc.",
|
|
68
69
|
"license": "ISC",
|
|
69
70
|
"files": [
|
|
70
|
-
"
|
|
71
|
-
"
|
|
71
|
+
"bin",
|
|
72
|
+
"lib"
|
|
72
73
|
],
|
|
73
74
|
"main": "lib/index.js",
|
|
74
75
|
"bin": {
|
|
@@ -91,5 +92,10 @@
|
|
|
91
92
|
},
|
|
92
93
|
"engines": {
|
|
93
94
|
"node": "^12.13.0 || ^14.15.0 || >=16"
|
|
94
|
-
}
|
|
95
|
+
},
|
|
96
|
+
"templateVersion": "2.3.0",
|
|
97
|
+
"eslintIgnore": [
|
|
98
|
+
"test/fixtures/",
|
|
99
|
+
"!test/fixtures/*.js"
|
|
100
|
+
]
|
|
95
101
|
}
|
package/LICENSE
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
The ISC License
|
|
2
|
-
|
|
3
|
-
Copyright npm, Inc.
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND NPM DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
-
AND FITNESS. IN NO EVENT SHALL NPM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
14
|
-
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
Files and metadata contained in `test/fixtures/registry-mocks/content` are
|
|
20
|
-
downloaded from the public npm registry. These are the property of their
|
|
21
|
-
respective owners. The use and distribution of said artifacts are covered by
|
|
22
|
-
their associated licenses.
|