@npmcli/arborist 4.0.2 → 4.1.0
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 +3 -3
- 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 +12 -6
- package/lib/arborist/index.js +34 -22
- package/lib/arborist/load-actual.js +25 -7
- package/lib/arborist/load-virtual.js +5 -4
- package/lib/arborist/rebuild.js +7 -7
- package/lib/arborist/reify.js +15 -11
- 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/edge.js +38 -3
- package/lib/from-path.js +1 -1
- package/lib/link.js +1 -1
- package/lib/node.js +51 -6
- package/lib/override-set.js +123 -0
- package/lib/place-dep.js +5 -3
- package/lib/printable.js +13 -4
- package/lib/relpath.js +1 -1
- package/lib/retire-path.js +1 -1
- package/lib/shrinkwrap.js +27 -16
- package/lib/version-from-tgz.js +2 -2
- package/lib/vuln.js +1 -1
- package/lib/yarn-lock.js +2 -2
- package/package.json +23 -17
- 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,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Inspect and manage `node_modules` trees.
|
|
4
4
|
|
|
5
|
-

|
|
5
|
+

|
|
6
6
|
|
|
7
|
-
There's more documentation [in the
|
|
8
|
-
folder](https://github.com/npm/arborist/tree/main/
|
|
7
|
+
There's more documentation [in the docs
|
|
8
|
+
folder](https://github.com/npm/arborist/tree/main/docs).
|
|
9
9
|
|
|
10
10
|
## USAGE
|
|
11
11
|
|
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
|
|
@@ -379,6 +379,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
|
|
|
379
379
|
optional: false,
|
|
380
380
|
global: this[_global],
|
|
381
381
|
legacyPeerDeps: this.legacyPeerDeps,
|
|
382
|
+
loadOverrides: true,
|
|
382
383
|
})
|
|
383
384
|
if (root.isLink) {
|
|
384
385
|
root.target = new Node({
|
|
@@ -492,7 +493,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
|
|
|
492
493
|
|
|
493
494
|
// This returns a promise because we might not have the name yet,
|
|
494
495
|
// and need to call pacote.manifest to find the name.
|
|
495
|
-
[_add] (tree, {add, saveType = null, saveBundle = false}) {
|
|
496
|
+
[_add] (tree, { add, saveType = null, saveBundle = false }) {
|
|
496
497
|
// get the name for each of the specs in the list.
|
|
497
498
|
// ie, doing `foo@bar` we just return foo
|
|
498
499
|
// but if it's a url or git, we don't know the name until we
|
|
@@ -676,6 +677,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
|
|
|
676
677
|
// calls rather than walking over everything in the tree.
|
|
677
678
|
const set = this.idealTree.inventory
|
|
678
679
|
.filter(n => this[_shouldUpdateNode](n))
|
|
680
|
+
// XXX add any invalid edgesOut to the queue
|
|
679
681
|
for (const node of set) {
|
|
680
682
|
for (const edge of node.edgesIn) {
|
|
681
683
|
this.addTracker('idealTree', edge.from.name, edge.from.location)
|
|
@@ -772,7 +774,10 @@ This is a one-time fix-up, please be patient...
|
|
|
772
774
|
[_buildDeps] () {
|
|
773
775
|
process.emit('time', 'idealTree:buildDeps')
|
|
774
776
|
const tree = this.idealTree.target
|
|
777
|
+
tree.assertRootOverrides()
|
|
775
778
|
this[_depsQueue].push(tree)
|
|
779
|
+
// XXX also push anything that depends on a node with a name
|
|
780
|
+
// in the override list
|
|
776
781
|
this.log.silly('idealTree', 'buildDeps')
|
|
777
782
|
this.addTracker('idealTree', tree.name, '')
|
|
778
783
|
return this[_buildDepStep]()
|
|
@@ -936,7 +941,7 @@ This is a one-time fix-up, please be patient...
|
|
|
936
941
|
}
|
|
937
942
|
})
|
|
938
943
|
|
|
939
|
-
tasks.push({edge, dep})
|
|
944
|
+
tasks.push({ edge, dep })
|
|
940
945
|
}
|
|
941
946
|
|
|
942
947
|
const placeDeps = tasks
|
|
@@ -1112,6 +1117,7 @@ This is a one-time fix-up, please be patient...
|
|
|
1112
1117
|
path: node.realpath,
|
|
1113
1118
|
sourceReference: node,
|
|
1114
1119
|
legacyPeerDeps: this.legacyPeerDeps,
|
|
1120
|
+
overrides: node.overrides,
|
|
1115
1121
|
})
|
|
1116
1122
|
|
|
1117
1123
|
// also need to set up any targets from any link deps, so that
|
|
@@ -1271,7 +1277,7 @@ This is a one-time fix-up, please be patient...
|
|
|
1271
1277
|
// we typically only install non-optional peers, but we have to
|
|
1272
1278
|
// factor them into the peerSet so that we can avoid conflicts
|
|
1273
1279
|
.filter(e => e.peer && !(e.valid && e.to))
|
|
1274
|
-
.sort(({name: a}, {name: b}) => localeCompare(a, b))
|
|
1280
|
+
.sort(({ name: a }, { name: b }) => localeCompare(a, b))
|
|
1275
1281
|
|
|
1276
1282
|
for (const edge of peerEdges) {
|
|
1277
1283
|
// already placed this one, and we're happy with it.
|
|
@@ -1280,7 +1286,7 @@ This is a one-time fix-up, please be patient...
|
|
|
1280
1286
|
}
|
|
1281
1287
|
|
|
1282
1288
|
const parentEdge = node.parent.edgesOut.get(edge.name)
|
|
1283
|
-
const {isProjectRoot, isWorkspace} = node.parent.sourceReference
|
|
1289
|
+
const { isProjectRoot, isWorkspace } = node.parent.sourceReference
|
|
1284
1290
|
const isMine = isProjectRoot || isWorkspace
|
|
1285
1291
|
const conflictOK = this[_force] || !isMine && !this[_strictPeerDeps]
|
|
1286
1292
|
|
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')
|
|
@@ -127,16 +127,20 @@ module.exports = cls => class ActualLoader extends cls {
|
|
|
127
127
|
realpath: real,
|
|
128
128
|
pkg: {},
|
|
129
129
|
global,
|
|
130
|
+
loadOverrides: true,
|
|
130
131
|
})
|
|
131
|
-
return this[_loadActualActually]({root, ignoreMissing, global})
|
|
132
|
+
return this[_loadActualActually]({ root, ignoreMissing, global })
|
|
132
133
|
}
|
|
133
134
|
|
|
134
135
|
// not in global mode, hidden lockfile is allowed, load root pkg too
|
|
135
136
|
this[_actualTree] = await this[_loadFSNode]({
|
|
136
137
|
path: this.path,
|
|
137
138
|
real: await realpath(this.path, this[_rpcache], this[_stcache]),
|
|
139
|
+
loadOverrides: true,
|
|
138
140
|
})
|
|
139
141
|
|
|
142
|
+
this[_actualTree].assertRootOverrides()
|
|
143
|
+
|
|
140
144
|
// Note: hidden lockfile will be rejected if it's not the latest thing
|
|
141
145
|
// in the folder, or if any of the entries in the hidden lockfile are
|
|
142
146
|
// missing.
|
|
@@ -163,7 +167,7 @@ module.exports = cls => class ActualLoader extends cls {
|
|
|
163
167
|
// we can't easily get a ref to Arborist in this module, without
|
|
164
168
|
// creating a circular reference, since this class is a mixin used
|
|
165
169
|
// to build up the Arborist class itself.
|
|
166
|
-
await new this.constructor({...this.options}).loadVirtual({
|
|
170
|
+
await new this.constructor({ ...this.options }).loadVirtual({
|
|
167
171
|
root: this[_actualTree],
|
|
168
172
|
})
|
|
169
173
|
await this[_loadWorkspaces](this[_actualTree])
|
|
@@ -236,13 +240,26 @@ module.exports = cls => class ActualLoader extends cls {
|
|
|
236
240
|
this[_actualTree] = root
|
|
237
241
|
}
|
|
238
242
|
|
|
239
|
-
[_loadFSNode] ({ path, parent, real, root }) {
|
|
243
|
+
[_loadFSNode] ({ path, parent, real, root, loadOverrides }) {
|
|
240
244
|
if (!real) {
|
|
241
245
|
return realpath(path, this[_rpcache], this[_stcache])
|
|
242
246
|
.then(
|
|
243
|
-
real => this[_loadFSNode]({
|
|
247
|
+
real => this[_loadFSNode]({
|
|
248
|
+
path,
|
|
249
|
+
parent,
|
|
250
|
+
real,
|
|
251
|
+
root,
|
|
252
|
+
loadOverrides,
|
|
253
|
+
}),
|
|
244
254
|
// if realpath fails, just provide a dummy error node
|
|
245
|
-
error => new Node({
|
|
255
|
+
error => new Node({
|
|
256
|
+
error,
|
|
257
|
+
path,
|
|
258
|
+
realpath: path,
|
|
259
|
+
parent,
|
|
260
|
+
root,
|
|
261
|
+
loadOverrides,
|
|
262
|
+
})
|
|
246
263
|
)
|
|
247
264
|
}
|
|
248
265
|
|
|
@@ -271,6 +288,7 @@ module.exports = cls => class ActualLoader extends cls {
|
|
|
271
288
|
error,
|
|
272
289
|
parent,
|
|
273
290
|
root,
|
|
291
|
+
loadOverrides,
|
|
274
292
|
})
|
|
275
293
|
})
|
|
276
294
|
.then(node => {
|
|
@@ -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')
|
|
@@ -72,6 +72,7 @@ module.exports = cls => class VirtualLoader extends cls {
|
|
|
72
72
|
this[rootOptionProvided] = options.root
|
|
73
73
|
|
|
74
74
|
await this[loadFromShrinkwrap](s, root)
|
|
75
|
+
root.assertRootOverrides()
|
|
75
76
|
return treeCheck(this.virtualTree)
|
|
76
77
|
}
|
|
77
78
|
|
|
@@ -97,7 +98,7 @@ module.exports = cls => class VirtualLoader extends cls {
|
|
|
97
98
|
this[checkRootEdges](s, root)
|
|
98
99
|
root.meta = s
|
|
99
100
|
this.virtualTree = root
|
|
100
|
-
const {links, nodes} = this[resolveNodes](s, root)
|
|
101
|
+
const { links, nodes } = this[resolveNodes](s, root)
|
|
101
102
|
await this[resolveLinks](links, nodes)
|
|
102
103
|
if (!(s.originalLockfileVersion >= 2)) {
|
|
103
104
|
this[assignBundles](nodes)
|
|
@@ -208,7 +209,7 @@ module.exports = cls => class VirtualLoader extends cls {
|
|
|
208
209
|
nodes.set(location, this[loadNode](location, meta))
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
|
-
return {links, nodes}
|
|
212
|
+
return { links, nodes }
|
|
212
213
|
}
|
|
213
214
|
|
|
214
215
|
// links is the set of metadata, and nodes is the map of non-Link nodes
|
|
@@ -240,7 +241,7 @@ module.exports = cls => class VirtualLoader extends cls {
|
|
|
240
241
|
if (!location || node.isLink && !node.target.location) {
|
|
241
242
|
continue
|
|
242
243
|
}
|
|
243
|
-
const { name, parent, package: { inBundle }} = node
|
|
244
|
+
const { name, parent, package: { inBundle } } = node
|
|
244
245
|
|
|
245
246
|
if (!parent) {
|
|
246
247
|
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
|
|
@@ -1173,6 +1173,10 @@ module.exports = cls => class Reifier extends cls {
|
|
|
1173
1173
|
}
|
|
1174
1174
|
|
|
1175
1175
|
let newSpec
|
|
1176
|
+
// True if the dependency is getting installed from a local file path
|
|
1177
|
+
// In this case it is not possible to do the normal version comparisons
|
|
1178
|
+
// as the new version will be a file path
|
|
1179
|
+
const isLocalDep = req.type === 'directory' || req.type === 'file'
|
|
1176
1180
|
if (req.registry) {
|
|
1177
1181
|
const version = child.version
|
|
1178
1182
|
const prefixRange = version ? this[_savePrefix] + version : '*'
|
|
@@ -1204,7 +1208,7 @@ module.exports = cls => class Reifier extends cls {
|
|
|
1204
1208
|
} else {
|
|
1205
1209
|
newSpec = h.shortcut(opt)
|
|
1206
1210
|
}
|
|
1207
|
-
} else if (
|
|
1211
|
+
} else if (isLocalDep) {
|
|
1208
1212
|
// save the relative path in package.json
|
|
1209
1213
|
// Normally saveSpec is updated with the proper relative
|
|
1210
1214
|
// path already, but it's possible to specify a full absolute
|
|
@@ -1233,11 +1237,11 @@ module.exports = cls => class Reifier extends cls {
|
|
|
1233
1237
|
if (hasSubKey(pkg, 'devDependencies', name)) {
|
|
1234
1238
|
pkg.devDependencies[name] = newSpec
|
|
1235
1239
|
// don't update peer or optional if we don't have to
|
|
1236
|
-
if (hasSubKey(pkg, 'peerDependencies', name) && !intersects(newSpec, pkg.peerDependencies[name])) {
|
|
1240
|
+
if (hasSubKey(pkg, 'peerDependencies', name) && (isLocalDep || !intersects(newSpec, pkg.peerDependencies[name]))) {
|
|
1237
1241
|
pkg.peerDependencies[name] = newSpec
|
|
1238
1242
|
}
|
|
1239
1243
|
|
|
1240
|
-
if (hasSubKey(pkg, 'optionalDependencies', name) && !intersects(newSpec, pkg.optionalDependencies[name])) {
|
|
1244
|
+
if (hasSubKey(pkg, 'optionalDependencies', name) && (isLocalDep || !intersects(newSpec, pkg.optionalDependencies[name]))) {
|
|
1241
1245
|
pkg.optionalDependencies[name] = newSpec
|
|
1242
1246
|
}
|
|
1243
1247
|
} else {
|
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 !*!
|