diff --git a/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js b/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js index 54a6ff33751a1..582575ebfad29 100644 --- a/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js +++ b/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js @@ -790,6 +790,11 @@ This is a one-time fix-up, please be patient... } await Promise.all(promises) + for (const { to } of node.edgesOut.values()) { + if (to && to.isLink) + this[_linkNodes].add(to) + } + return this[_buildDepStep]() } @@ -1539,9 +1544,14 @@ This is a one-time fix-up, please be patient... } } - // didn't find a parent for it, but we're filling in external - // link targets, so go ahead and process it. - if (this[_follow] && !link.target.parent && !link.target.fsParent) { + // didn't find a parent for it or it has not been seen yet + // so go ahead and process it. + const unseenLink = (link.target.parent || link.target.fsParent) + && !this[_depsSeen].has(link.target) + if (this[_follow] + && !link.target.parent + && !link.target.fsParent + || unseenLink) { this.addTracker('idealTree', link.target.name, link.target.location) this[_depsQueue].push(link.target) } diff --git a/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js b/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js index 14c96092753fc..924d720de752c 100644 --- a/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js +++ b/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js @@ -185,12 +185,6 @@ module.exports = cls => class VirtualLoader extends cls { // links is the set of metadata, and nodes is the map of non-Link nodes // Set the targets to nodes in the set, if we have them (we might not) async [resolveLinks] (links, nodes) { - // now we've loaded the root, and all real nodes - // link up the links - const {meta} = this.virtualTree - const {loadedFromDisk, originalLockfileVersion} = meta - const oldLockfile = loadedFromDisk && !(originalLockfileVersion >= 2) - for (const [location, meta] of links.entries()) { const targetPath = resolve(this.path, meta.resolved) const targetLoc = relpath(this.path, targetPath) @@ -198,16 +192,13 @@ module.exports = cls => class VirtualLoader extends cls { const link = this[loadLink](location, targetLoc, target, meta) nodes.set(location, link) nodes.set(targetLoc, link.target) - // legacy shrinkwraps do not store all the info we need for the target. - // if we're loading from disk, and have a link in place, we need to - // look in that actual folder (or at least try to) in order to get - // the dependencies of the link target and load it properly. - if (oldLockfile) { - const pj = link.realpath + '/package.json' - const pkg = await rpj(pj).catch(() => null) - if (pkg) - link.target.package = pkg - } + + // we always need to read the package.json for link targets + // because they can be changed by the local user + const pj = link.realpath + '/package.json' + const pkg = await rpj(pj).catch(() => null) + if (pkg) + link.target.package = pkg } } diff --git a/node_modules/@npmcli/arborist/lib/arborist/reify.js b/node_modules/@npmcli/arborist/lib/arborist/reify.js index 57ecf071fbaff..8711f8d298534 100644 --- a/node_modules/@npmcli/arborist/lib/arborist/reify.js +++ b/node_modules/@npmcli/arborist/lib/arborist/reify.js @@ -10,10 +10,10 @@ const {dirname, resolve, relative} = require('path') const {depth: dfwalk} = require('treeverse') const fs = require('fs') const {promisify} = require('util') -const rename = promisify(fs.rename) const symlink = promisify(fs.symlink) const writeFile = promisify(fs.writeFile) const mkdirp = require('mkdirp-infer-owner') +const moveFile = require('@npmcli/move-file') const rimraf = promisify(require('rimraf')) const packageContents = require('@npmcli/installed-package-contents') @@ -251,7 +251,7 @@ module.exports = cls => class Reifier extends cls { } [_renamePath] (from, to, didMkdirp = false) { - return rename(from, to) + return moveFile(from, to) .catch(er => { // Occasionally an expected bin file might not exist in the package, // or a shim/symlink might have been moved aside. If we've already @@ -261,7 +261,7 @@ module.exports = cls => class Reifier extends cls { return didMkdirp ? null : mkdirp(dirname(to)).then(() => this[_renamePath](from, to, true)) } else if (er.code === 'EEXIST') - return rimraf(to).then(() => rename(from, to)) + return rimraf(to).then(() => moveFile(from, to)) else throw er }) @@ -427,7 +427,7 @@ module.exports = cls => class Reifier extends cls { const dir = dirname(node.path) const target = node.realpath const rel = relative(dir, target) - return symlink(rel, node.path, 'dir') + return symlink(rel, node.path, 'junction') } [_warnDeprecated] (node) { diff --git a/node_modules/@npmcli/arborist/package.json b/node_modules/@npmcli/arborist/package.json index fe72f409c4a45..99522745cb303 100644 --- a/node_modules/@npmcli/arborist/package.json +++ b/node_modules/@npmcli/arborist/package.json @@ -1,11 +1,12 @@ { "name": "@npmcli/arborist", - "version": "1.0.8", + "version": "1.0.9", "description": "Manage node_modules trees", "dependencies": { "@npmcli/installed-package-contents": "^1.0.5", "@npmcli/map-workspaces": "^1.0.1", "@npmcli/metavuln-calculator": "^1.0.0", + "@npmcli/move-file": "^1.0.1", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.0", "@npmcli/run-script": "^1.7.2", diff --git a/package-lock.json b/package-lock.json index f0617ffe2b13a..2f997086f9438 100644 --- a/package-lock.json +++ b/package-lock.json @@ -78,7 +78,7 @@ ], "license": "Artistic-2.0", "dependencies": { - "@npmcli/arborist": "^1.0.8", + "@npmcli/arborist": "^1.0.9", "@npmcli/ci-detect": "^1.2.0", "@npmcli/config": "^1.2.1", "@npmcli/run-script": "^1.7.5", @@ -386,14 +386,15 @@ } }, "node_modules/@npmcli/arborist": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-1.0.8.tgz", - "integrity": "sha512-LAopKkhAnBr6/cbIpH9VeNS4yLWMFf6AFKC7x3XHvNFDMy8cmvEjWtjcpV8ACjPPm4UbjIzQ/n4qrxaA0ZyBDA==", + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-1.0.9.tgz", + "integrity": "sha512-bvaPKdlT4F0U2JT0eV1fprv9dWdjFxY+O7WbXMvABvyO81kUPTJTBe1HhsGTIqXTrt2cOqXtLJI31Xs7iugptg==", "inBundle": true, "dependencies": { "@npmcli/installed-package-contents": "^1.0.5", "@npmcli/map-workspaces": "^1.0.1", "@npmcli/metavuln-calculator": "^1.0.0", + "@npmcli/move-file": "^1.0.1", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.0", "@npmcli/run-script": "^1.7.2", @@ -9065,13 +9066,14 @@ } }, "@npmcli/arborist": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-1.0.8.tgz", - "integrity": "sha512-LAopKkhAnBr6/cbIpH9VeNS4yLWMFf6AFKC7x3XHvNFDMy8cmvEjWtjcpV8ACjPPm4UbjIzQ/n4qrxaA0ZyBDA==", + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-1.0.9.tgz", + "integrity": "sha512-bvaPKdlT4F0U2JT0eV1fprv9dWdjFxY+O7WbXMvABvyO81kUPTJTBe1HhsGTIqXTrt2cOqXtLJI31Xs7iugptg==", "requires": { "@npmcli/installed-package-contents": "^1.0.5", "@npmcli/map-workspaces": "^1.0.1", "@npmcli/metavuln-calculator": "^1.0.0", + "@npmcli/move-file": "^1.0.1", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.0", "@npmcli/run-script": "^1.7.2", diff --git a/package.json b/package.json index 1c8461587b4c4..d1a1e191a080a 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "./package.json": "./package.json" }, "dependencies": { - "@npmcli/arborist": "^1.0.8", + "@npmcli/arborist": "^1.0.9", "@npmcli/ci-detect": "^1.2.0", "@npmcli/config": "^1.2.1", "@npmcli/run-script": "^1.7.5",