@npmcli/arborist 9.1.3 → 9.1.4
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.
|
@@ -1238,15 +1238,19 @@ This is a one-time fix-up, please be patient...
|
|
|
1238
1238
|
// Check if the target is within the project root
|
|
1239
1239
|
isProjectInternalFileSpec = targetPath.startsWith(resolvedProjectRoot + sep) || targetPath === resolvedProjectRoot
|
|
1240
1240
|
}
|
|
1241
|
+
|
|
1242
|
+
// When using --install-links, we need to handle transitive file dependencies specially
|
|
1243
|
+
// If the parent was installed (not linked) due to --install-links, and this is a file: dep, we should also install it rather than link it
|
|
1244
|
+
const parentWasInstalled = parent && !parent.isLink && parent.resolved?.startsWith('file:')
|
|
1245
|
+
const isTransitiveFileDep = spec.type === 'directory' && parentWasInstalled && installLinks
|
|
1246
|
+
|
|
1241
1247
|
// Decide whether to link or copy the dependency
|
|
1242
|
-
const shouldLink = isWorkspace || isProjectInternalFileSpec || !installLinks
|
|
1248
|
+
const shouldLink = (isWorkspace || isProjectInternalFileSpec || !installLinks) && !isTransitiveFileDep
|
|
1243
1249
|
if (spec.type === 'directory' && shouldLink) {
|
|
1244
1250
|
return this.#linkFromSpec(name, spec, parent, edge)
|
|
1245
1251
|
}
|
|
1246
1252
|
|
|
1247
|
-
// if the spec matches a workspace name, then see if the workspace node will
|
|
1248
|
-
// satisfy the edge. if it does, we return the workspace node to make sure it
|
|
1249
|
-
// takes priority.
|
|
1253
|
+
// if the spec matches a workspace name, then see if the workspace node will satisfy the edge. if it does, we return the workspace node to make sure it takes priority.
|
|
1250
1254
|
if (isWorkspace) {
|
|
1251
1255
|
const existingNode = this.idealTree.edgesOut.get(spec.name).to
|
|
1252
1256
|
if (existingNode && existingNode.isWorkspace && existingNode.satisfies(edge)) {
|
|
@@ -1254,6 +1258,15 @@ This is a one-time fix-up, please be patient...
|
|
|
1254
1258
|
}
|
|
1255
1259
|
}
|
|
1256
1260
|
|
|
1261
|
+
// For file: dependencies that we're installing (not linking), ensure proper resolution
|
|
1262
|
+
if (isTransitiveFileDep && edge) {
|
|
1263
|
+
// For transitive file deps, resolve relative to the parent's original source location
|
|
1264
|
+
const parentOriginalPath = parent.resolved.slice(5) // Remove 'file:' prefix
|
|
1265
|
+
const relativePath = edge.rawSpec.slice(5) // Remove 'file:' prefix
|
|
1266
|
+
const absolutePath = resolve(parentOriginalPath, relativePath)
|
|
1267
|
+
spec = npa.resolve(name, `file:${absolutePath}`)
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1257
1270
|
// spec isn't a directory, and either isn't a workspace or the workspace we have
|
|
1258
1271
|
// doesn't satisfy the edge. try to fetch a manifest and build a node from that.
|
|
1259
1272
|
return this.#fetchManifest(spec)
|
|
@@ -1306,6 +1319,12 @@ This is a one-time fix-up, please be patient...
|
|
|
1306
1319
|
.sort(({ name: a }, { name: b }) => localeCompare(a, b))
|
|
1307
1320
|
|
|
1308
1321
|
for (const edge of peerEdges) {
|
|
1322
|
+
// node.parent gets mutated during loop execution due to recursive #nodeFromEdge calls.
|
|
1323
|
+
// When a compatible peer is found (e.g. a@1.1.0 replaces a@1.2.0), the original node loses its parent.
|
|
1324
|
+
// if node is detached/removed from the tree, or has no parent, so no need to check remaining edgesOut for that node.
|
|
1325
|
+
if (!node.parent) {
|
|
1326
|
+
break
|
|
1327
|
+
}
|
|
1309
1328
|
// already placed this one, and we're happy with it.
|
|
1310
1329
|
if (edge.valid && edge.to) {
|
|
1311
1330
|
continue
|
package/lib/arborist/reify.js
CHANGED
|
@@ -885,6 +885,7 @@ module.exports = cls => class Reifier extends cls {
|
|
|
885
885
|
// Replace the host with the registry host while keeping the path intact
|
|
886
886
|
resolvedURL.hostname = registryURL.hostname
|
|
887
887
|
resolvedURL.port = registryURL.port
|
|
888
|
+
resolvedURL.protocol = registryURL.protocol
|
|
888
889
|
|
|
889
890
|
// Make sure we don't double-include the path if it's already there
|
|
890
891
|
const registryPath = registryURL.pathname.replace(/\/$/, '')
|