@npmcli/arborist 9.3.1 → 9.4.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.
|
@@ -105,7 +105,7 @@ module.exports = cls => class IsolatedReifier extends cls {
|
|
|
105
105
|
node.root.path,
|
|
106
106
|
'node_modules',
|
|
107
107
|
'.store',
|
|
108
|
-
`${node.
|
|
108
|
+
`${node.packageName}@${node.version}`
|
|
109
109
|
)
|
|
110
110
|
mkdirSync(dir, { recursive: true })
|
|
111
111
|
// TODO this approach feels wrong
|
|
@@ -145,6 +145,21 @@ module.exports = cls => class IsolatedReifier extends cls {
|
|
|
145
145
|
const optionalDeps = edges.filter(e => e.optional).map(e => e.to.target)
|
|
146
146
|
const nonOptionalDeps = edges.filter(e => !e.optional).map(e => e.to.target)
|
|
147
147
|
|
|
148
|
+
// When legacyPeerDeps is enabled, peer dep edges are not created on the
|
|
149
|
+
// node. Resolve them from the tree so they get symlinked in the store.
|
|
150
|
+
const peerDeps = node.package.peerDependencies
|
|
151
|
+
if (peerDeps && node.legacyPeerDeps) {
|
|
152
|
+
const edgeNames = new Set(edges.map(e => e.name))
|
|
153
|
+
for (const peerName of Object.keys(peerDeps)) {
|
|
154
|
+
if (!edgeNames.has(peerName)) {
|
|
155
|
+
const resolved = node.resolve(peerName)
|
|
156
|
+
if (resolved && resolved !== node && !resolved.inert) {
|
|
157
|
+
nonOptionalDeps.push(resolved)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
148
163
|
result.localDependencies = await Promise.all(nonOptionalDeps.filter(n => n.isWorkspace).map(this.workspaceProxyMemo))
|
|
149
164
|
result.externalDependencies = await Promise.all(nonOptionalDeps.filter(n => !n.isWorkspace && !n.inert).map(this.externalProxyMemo))
|
|
150
165
|
result.externalOptionalDependencies = await Promise.all(optionalDeps.filter(n => !n.inert).map(this.externalProxyMemo))
|
|
@@ -155,7 +170,9 @@ module.exports = cls => class IsolatedReifier extends cls {
|
|
|
155
170
|
]
|
|
156
171
|
result.root = this.rootNode
|
|
157
172
|
result.id = this.counter++
|
|
158
|
-
|
|
173
|
+
/* istanbul ignore next - packageName is always set for real packages */
|
|
174
|
+
result.name = result.isWorkspace ? (node.packageName || node.name) : node.name
|
|
175
|
+
result.packageName = node.packageName || node.name
|
|
159
176
|
result.package = { ...node.package }
|
|
160
177
|
result.package.bundleDependencies = undefined
|
|
161
178
|
result.hasInstallScript = node.hasInstallScript
|
|
@@ -228,7 +245,7 @@ module.exports = cls => class IsolatedReifier extends cls {
|
|
|
228
245
|
getChildren: node => node.dependencies,
|
|
229
246
|
filter: node => node,
|
|
230
247
|
visit: node => {
|
|
231
|
-
branch.push(`${node.
|
|
248
|
+
branch.push(`${node.packageName}@${node.version}`)
|
|
232
249
|
deps.push(`${branch.join('->')}::${node.resolved}`)
|
|
233
250
|
},
|
|
234
251
|
leave: () => {
|
|
@@ -246,7 +263,7 @@ module.exports = cls => class IsolatedReifier extends cls {
|
|
|
246
263
|
}
|
|
247
264
|
|
|
248
265
|
const getKey = (idealTreeNode) => {
|
|
249
|
-
return `${idealTreeNode.
|
|
266
|
+
return `${idealTreeNode.packageName}@${idealTreeNode.version}-${treeHash(idealTreeNode)}`
|
|
250
267
|
}
|
|
251
268
|
|
|
252
269
|
const root = {
|
|
@@ -301,7 +318,7 @@ module.exports = cls => class IsolatedReifier extends cls {
|
|
|
301
318
|
isProjectRoot: false,
|
|
302
319
|
isTop: false,
|
|
303
320
|
location,
|
|
304
|
-
name: node.name,
|
|
321
|
+
name: node.packageName || node.name,
|
|
305
322
|
optional: node.optional,
|
|
306
323
|
top: { path: proxiedIdealTree.root.localPath },
|
|
307
324
|
children: [],
|
|
@@ -335,7 +352,7 @@ module.exports = cls => class IsolatedReifier extends cls {
|
|
|
335
352
|
return
|
|
336
353
|
}
|
|
337
354
|
processed.add(key)
|
|
338
|
-
const location = join('node_modules', '.store', key, 'node_modules', c.
|
|
355
|
+
const location = join('node_modules', '.store', key, 'node_modules', c.packageName)
|
|
339
356
|
generateChild(c, location, c.package, true)
|
|
340
357
|
})
|
|
341
358
|
bundledTree.nodes.forEach(node => {
|
|
@@ -361,13 +378,17 @@ module.exports = cls => class IsolatedReifier extends cls {
|
|
|
361
378
|
|
|
362
379
|
let from, nmFolder
|
|
363
380
|
if (externalEdge) {
|
|
364
|
-
const fromLocation = join('node_modules', '.store', key, 'node_modules', node.
|
|
381
|
+
const fromLocation = join('node_modules', '.store', key, 'node_modules', node.packageName)
|
|
365
382
|
from = root.children.find(c => c.location === fromLocation)
|
|
366
383
|
nmFolder = join('node_modules', '.store', key, 'node_modules')
|
|
367
384
|
} else {
|
|
368
385
|
from = node.isProjectRoot ? root : root.fsChildren.find(c => c.location === node.localLocation)
|
|
369
386
|
nmFolder = join(node.localLocation, 'node_modules')
|
|
370
387
|
}
|
|
388
|
+
/* istanbul ignore next - strict-peer-deps can exclude nodes from the tree */
|
|
389
|
+
if (!from) {
|
|
390
|
+
return
|
|
391
|
+
}
|
|
371
392
|
|
|
372
393
|
const processDeps = (dep, optional, external) => {
|
|
373
394
|
optional = !!optional
|
|
@@ -379,12 +400,16 @@ module.exports = cls => class IsolatedReifier extends cls {
|
|
|
379
400
|
|
|
380
401
|
let target
|
|
381
402
|
if (external) {
|
|
382
|
-
const toLocation = join('node_modules', '.store', toKey, 'node_modules', dep.
|
|
403
|
+
const toLocation = join('node_modules', '.store', toKey, 'node_modules', dep.packageName)
|
|
383
404
|
target = root.children.find(c => c.location === toLocation)
|
|
384
405
|
} else {
|
|
385
406
|
target = root.fsChildren.find(c => c.location === dep.localLocation)
|
|
386
407
|
}
|
|
387
408
|
// TODO: we should no-op is an edge has already been created with the same fromKey and toKey
|
|
409
|
+
/* istanbul ignore next - strict-peer-deps can exclude nodes from the tree */
|
|
410
|
+
if (!target) {
|
|
411
|
+
return
|
|
412
|
+
}
|
|
388
413
|
|
|
389
414
|
binNames.forEach(bn => {
|
|
390
415
|
target.binPaths.push(join(from.realpath, 'node_modules', '.bin', bn))
|
package/lib/arborist/rebuild.js
CHANGED
|
@@ -295,12 +295,12 @@ module.exports = cls => class Builder extends cls {
|
|
|
295
295
|
devOptional,
|
|
296
296
|
package: pkg,
|
|
297
297
|
location,
|
|
298
|
-
isStoreLink,
|
|
299
298
|
} = node.target
|
|
300
299
|
|
|
301
300
|
// skip any that we know we'll be deleting
|
|
302
|
-
// or
|
|
303
|
-
|
|
301
|
+
// or links to store entries (their scripts run on the store
|
|
302
|
+
// entry itself, not through the link)
|
|
303
|
+
if (this[_trashList].has(path) || (node.isLink && node.target?.isInStore)) {
|
|
304
304
|
return
|
|
305
305
|
}
|
|
306
306
|
|
package/lib/arborist/reify.js
CHANGED
|
@@ -422,7 +422,7 @@ module.exports = cls => class Reifier extends cls {
|
|
|
422
422
|
if (includeWorkspaces) {
|
|
423
423
|
// add all ws nodes to filterNodes
|
|
424
424
|
for (const ws of this.options.workspaces) {
|
|
425
|
-
const ideal = this.idealTree.children.get(ws)
|
|
425
|
+
const ideal = this.idealTree.children.get && this.idealTree.children.get(ws)
|
|
426
426
|
if (ideal) {
|
|
427
427
|
filterNodes.push(ideal)
|
|
428
428
|
}
|
|
@@ -427,11 +427,19 @@ class Results {
|
|
|
427
427
|
if (!this.currentAstNode.typeValue) {
|
|
428
428
|
return this.initialItems
|
|
429
429
|
}
|
|
430
|
+
// TODO this differs subtly with `:type()` because it now iterates on edgesIn, which means extraneous deps won't show up
|
|
431
|
+
// note how "@npmcli/abbrev@2.0.0-beta.45" is in the `:type()` results in the test but not in any of the other results.
|
|
430
432
|
return this.initialItems
|
|
431
433
|
.flatMap(node => {
|
|
432
434
|
const found = []
|
|
435
|
+
const { typeValue } = this.currentAstNode
|
|
433
436
|
for (const edge of node.edgesIn) {
|
|
434
|
-
|
|
437
|
+
const parsedArg = npa(`${edge.name}@${edge.spec}`)
|
|
438
|
+
if (typeValue === 'registry') {
|
|
439
|
+
if (parsedArg.registry) {
|
|
440
|
+
found.push(edge.to)
|
|
441
|
+
}
|
|
442
|
+
} else if (parsedArg.type === typeValue) {
|
|
435
443
|
found.push(edge.to)
|
|
436
444
|
}
|
|
437
445
|
}
|
package/lib/shrinkwrap.js
CHANGED