Skip to content

Commit 44bfa37

Browse files
committed
dep: @npmcli/arborist 4.0.5
PR-URL: #4065 Credit: @fritzy Close: #4065 Reviewed-by: @lukekarrys
1 parent 088c116 commit 44bfa37

30 files changed

+166
-146
lines changed

node_modules/@npmcli/arborist/LICENSE

-22
This file was deleted.
+20
Original file line numberDiff line numberDiff line change
@@ -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.

node_modules/@npmcli/arborist/bin/prune.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require('./lib/logging.js')
66
require('./lib/timers.js')
77

88
const printDiff = diff => {
9-
const {depth} = require('treeverse')
9+
const { depth } = require('treeverse')
1010
depth({
1111
tree: diff,
1212
visit: d => {

node_modules/@npmcli/arborist/bin/reify.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require('./lib/logging.js')
66
require('./lib/timers.js')
77

88
const printDiff = diff => {
9-
const {depth} = require('treeverse')
9+
const { depth } = require('treeverse')
1010
depth({
1111
tree: diff,
1212
visit: d => {

node_modules/@npmcli/arborist/lib/add-rm-pkg-deps.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
const localeCompare = require('@isaacs/string-locale-compare')('en')
44

5-
const add = ({pkg, add, saveBundle, saveType, log}) => {
5+
const add = ({ pkg, add, saveBundle, saveType, log }) => {
66
for (const spec of add) {
7-
addSingle({pkg, spec, saveBundle, saveType, log})
7+
addSingle({ pkg, spec, saveBundle, saveType, log })
88
}
99

1010
return pkg
@@ -20,7 +20,7 @@ const saveTypeMap = new Map([
2020
['peer', 'peerDependencies'],
2121
])
2222

23-
const addSingle = ({pkg, spec, saveBundle, saveType, log}) => {
23+
const addSingle = ({ pkg, spec, saveBundle, saveType, log }) => {
2424
const { name, rawSpec } = spec
2525

2626
// if the user does not give us a type, we infer which type(s)

node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const Node = require('../node.js')
3131
const Link = require('../link.js')
3232
const addRmPkgDeps = require('../add-rm-pkg-deps.js')
3333
const optionalSet = require('../optional-set.js')
34-
const {checkEngine, checkPlatform} = require('npm-install-checks')
34+
const { checkEngine, checkPlatform } = require('npm-install-checks')
3535

3636
const relpath = require('../relpath.js')
3737

@@ -311,7 +311,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
311311
? Shrinkwrap.reset({
312312
path: this.path,
313313
lockfileVersion: this.options.lockfileVersion,
314-
}).then(meta => Object.assign(root, {meta}))
314+
}).then(meta => Object.assign(root, { meta }))
315315
: this.loadVirtual({ root }))
316316

317317
// 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 {
492492

493493
// This returns a promise because we might not have the name yet,
494494
// 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 }) {
496496
// get the name for each of the specs in the list.
497497
// ie, doing `foo@bar` we just return foo
498498
// 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...
936936
}
937937
})
938938

939-
tasks.push({edge, dep})
939+
tasks.push({ edge, dep })
940940
}
941941

942942
const placeDeps = tasks
@@ -1271,7 +1271,7 @@ This is a one-time fix-up, please be patient...
12711271
// we typically only install non-optional peers, but we have to
12721272
// factor them into the peerSet so that we can avoid conflicts
12731273
.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))
12751275

12761276
for (const edge of peerEdges) {
12771277
// already placed this one, and we're happy with it.
@@ -1280,7 +1280,7 @@ This is a one-time fix-up, please be patient...
12801280
}
12811281

12821282
const parentEdge = node.parent.edgesOut.get(edge.name)
1283-
const {isProjectRoot, isWorkspace} = node.parent.sourceReference
1283+
const { isProjectRoot, isWorkspace } = node.parent.sourceReference
12841284
const isMine = isProjectRoot || isWorkspace
12851285
const conflictOK = this[_force] || !isMine && !this[_strictPeerDeps]
12861286

node_modules/@npmcli/arborist/lib/arborist/index.js

+34-22
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
// the base class, so that the overall voltron class is easier to test and
2727
// cover, and separation of concerns can be maintained.
2828

29-
const {resolve} = require('path')
30-
const {homedir} = require('os')
29+
const { resolve } = require('path')
30+
const { homedir } = require('os')
3131
const procLog = require('proc-log')
32+
const { depth } = require('treeverse')
3233
const { saveTypeMap } = require('../add-rm-pkg-deps.js')
3334

3435
const mixins = [
@@ -88,6 +89,9 @@ class Arborist extends Base {
8889
process.emit('timeEnd', 'arborist:ctor')
8990
}
9091

92+
// TODO: We should change these to static functions instead
93+
// of methods for the next major version
94+
9195
// returns an array of the actual nodes for all the workspaces
9296
workspaceNodes (tree, workspaces) {
9397
return getWorkspaceNodes(tree, workspaces, this.log)
@@ -103,15 +107,15 @@ class Arborist extends Base {
103107
}
104108
}
105109
}
106-
const set = new Set(wsNodes)
110+
const wsDepSet = new Set(wsNodes)
107111
const extraneous = new Set()
108-
for (const node of set) {
112+
for (const node of wsDepSet) {
109113
for (const edge of node.edgesOut.values()) {
110114
const dep = edge.to
111115
if (dep) {
112-
set.add(dep)
116+
wsDepSet.add(dep)
113117
if (dep.isLink) {
114-
set.add(dep.target)
118+
wsDepSet.add(dep.target)
115119
}
116120
}
117121
}
@@ -122,28 +126,36 @@ class Arborist extends Base {
122126
}
123127
}
124128
for (const extra of extraneous) {
125-
set.add(extra)
129+
wsDepSet.add(extra)
126130
}
127131

128-
return set
132+
return wsDepSet
129133
}
130134

135+
// returns a set of root dependencies, excluding depdencies that are
136+
// exclusively workspace dependencies
131137
excludeWorkspacesDependencySet (tree) {
132-
const set = new Set()
133-
for (const edge of tree.edgesOut.values()) {
134-
if (edge.type !== 'workspace' && edge.to) {
135-
set.add(edge.to)
136-
}
137-
}
138-
for (const node of set) {
139-
for (const edge of node.edgesOut.values()) {
140-
if (edge.to) {
141-
set.add(edge.to)
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+
}
142151
}
143-
}
144-
}
145-
146-
return set
152+
return node
153+
},
154+
filter: node => node,
155+
getChildren: (node, tree) =>
156+
[...tree.edgesOut.values()].map(edge => edge.to),
157+
})
158+
return rootDepSet
147159
}
148160
}
149161

node_modules/@npmcli/arborist/lib/arborist/load-actual.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// mix-in implementing the loadActual method
22

3-
const {relative, dirname, resolve, join, normalize} = require('path')
3+
const { relative, dirname, resolve, join, normalize } = require('path')
44

55
const rpj = require('read-package-json-fast')
6-
const {promisify} = require('util')
6+
const { promisify } = require('util')
77
const readdir = promisify(require('readdir-scoped-modules'))
88
const walkUp = require('walk-up-path')
99
const ancestorPath = require('common-ancestor-path')
@@ -128,7 +128,7 @@ module.exports = cls => class ActualLoader extends cls {
128128
pkg: {},
129129
global,
130130
})
131-
return this[_loadActualActually]({root, ignoreMissing, global})
131+
return this[_loadActualActually]({ root, ignoreMissing, global })
132132
}
133133

134134
// not in global mode, hidden lockfile is allowed, load root pkg too
@@ -163,7 +163,7 @@ module.exports = cls => class ActualLoader extends cls {
163163
// we can't easily get a ref to Arborist in this module, without
164164
// creating a circular reference, since this class is a mixin used
165165
// to build up the Arborist class itself.
166-
await new this.constructor({...this.options}).loadVirtual({
166+
await new this.constructor({ ...this.options }).loadVirtual({
167167
root: this[_actualTree],
168168
})
169169
await this[_loadWorkspaces](this[_actualTree])

node_modules/@npmcli/arborist/lib/arborist/load-virtual.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// mixin providing the loadVirtual method
22
const localeCompare = require('@isaacs/string-locale-compare')('en')
33

4-
const {resolve} = require('path')
4+
const { resolve } = require('path')
55

66
const nameFromFolder = require('@npmcli/name-from-folder')
77
const consistentResolve = require('../consistent-resolve.js')
@@ -97,7 +97,7 @@ module.exports = cls => class VirtualLoader extends cls {
9797
this[checkRootEdges](s, root)
9898
root.meta = s
9999
this.virtualTree = root
100-
const {links, nodes} = this[resolveNodes](s, root)
100+
const { links, nodes } = this[resolveNodes](s, root)
101101
await this[resolveLinks](links, nodes)
102102
if (!(s.originalLockfileVersion >= 2)) {
103103
this[assignBundles](nodes)
@@ -208,7 +208,7 @@ module.exports = cls => class VirtualLoader extends cls {
208208
nodes.set(location, this[loadNode](location, meta))
209209
}
210210
}
211-
return {links, nodes}
211+
return { links, nodes }
212212
}
213213

214214
// 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 {
240240
if (!location || node.isLink && !node.target.location) {
241241
continue
242242
}
243-
const { name, parent, package: { inBundle }} = node
243+
const { name, parent, package: { inBundle } } = node
244244

245245
if (!parent) {
246246
continue

node_modules/@npmcli/arborist/lib/arborist/rebuild.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// bundle building needed. Called by reify, and by `npm rebuild`.
33

44
const localeCompare = require('@isaacs/string-locale-compare')('en')
5-
const {depth: dfwalk} = require('treeverse')
5+
const { depth: dfwalk } = require('treeverse')
66
const promiseAllRejectLate = require('promise-all-reject-late')
77
const rpj = require('read-package-json-fast')
88
const binLinks = require('bin-links')
99
const runScript = require('@npmcli/run-script')
1010
const promiseCallLimit = require('promise-call-limit')
11-
const {resolve} = require('path')
11+
const { resolve } = require('path')
1212
const {
1313
isNodeGypPackage,
1414
defaultGypInstallScript,
@@ -220,7 +220,7 @@ module.exports = cls => class Builder extends cls {
220220
}
221221

222222
if (this[_oldMeta] === null) {
223-
const {root: {meta}} = node
223+
const { root: { meta } } = node
224224
this[_oldMeta] = meta && meta.loadedFromDisk &&
225225
!(meta.originalLockfileVersion >= 2)
226226
}
@@ -242,7 +242,7 @@ module.exports = cls => class Builder extends cls {
242242
const pkg = await rpj(node.path + '/package.json').catch(() => ({}))
243243
set.delete(node)
244244

245-
const {scripts = {}} = pkg
245+
const { scripts = {} } = pkg
246246
node.package.scripts = scripts
247247
return this[_addToBuildSet](node, set, true)
248248
}
@@ -319,9 +319,9 @@ module.exports = cls => class Builder extends cls {
319319
}
320320
const p = runScript(runOpts).catch(er => {
321321
const { code, signal } = er
322-
this.log.info('run', pkg._id, event, {code, signal})
322+
this.log.info('run', pkg._id, event, { code, signal })
323323
throw er
324-
}).then(({args, code, signal, stdout, stderr}) => {
324+
}).then(({ args, code, signal, stdout, stderr }) => {
325325
this.scriptsRun.add({
326326
pkg,
327327
path,
@@ -333,7 +333,7 @@ module.exports = cls => class Builder extends cls {
333333
stdout,
334334
stderr,
335335
})
336-
this.log.info('run', pkg._id, event, {code, signal})
336+
this.log.info('run', pkg._id, event, { code, signal })
337337
})
338338

339339
await (this[_doHandleOptionalFailure]

0 commit comments

Comments
 (0)