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 2fce837a58ce9..2b9b4595b512b 100644 --- a/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js +++ b/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js @@ -4,7 +4,6 @@ const npa = require('npm-package-arg') const pacote = require('pacote') const cacache = require('cacache') const semver = require('semver') -const mapWorkspaces = require('@npmcli/map-workspaces') const promiseCallLimit = require('promise-call-limit') const getPeerSet = require('../peer-set.js') const realpath = require('../../lib/realpath.js') @@ -54,7 +53,7 @@ const _nodeFromSpec = Symbol('nodeFromSpec') const _fetchManifest = Symbol('fetchManifest') const _problemEdges = Symbol('problemEdges') const _manifests = Symbol('manifests') -const _mapWorkspaces = Symbol('mapWorkspaces') +const _loadWorkspaces = Symbol.for('loadWorkspaces') const _linkFromSpec = Symbol('linkFromSpec') const _loadPeerSet = Symbol('loadPeerSet') const _updateNames = Symbol.for('updateNames') @@ -268,6 +267,7 @@ module.exports = cls => class IdealTreeBuilder extends cls { pkg => this[_rootNodeFromPackage](pkg), er => this[_rootNodeFromPackage]({}) )) + .then(root => this[_loadWorkspaces](root)) // ok to not have a virtual tree. probably initial install. // When updating all, we load the shrinkwrap, but don't bother // to build out the full virtual tree from it, since we'll be @@ -288,11 +288,8 @@ module.exports = cls => class IdealTreeBuilder extends cls { .then(async root => { if (!this[_updateAll] && !this[_global] && !root.meta.loadedFromDisk) await new this.constructor(this.options).loadActual({ root }) - else if (!this[_global] && (!this[_usePackageLock] || this[_updateAll])) - await this[_mapWorkspaces](root) return root }) - .then(tree => { // null the virtual tree, because we're about to hack away at it // if you want another one, load another copy. @@ -327,15 +324,6 @@ module.exports = cls => class IdealTreeBuilder extends cls { }) } - [_mapWorkspaces] (node) { - return mapWorkspaces({ cwd: node.path, pkg: node.package }) - .then(workspaces => { - if (workspaces.size) - node.workspaces = workspaces - return node - }) - } - // process the add/rm requests by modifying the root node, and the // update.names request by queueing nodes dependent on those named. async [_applyUserRequests] (options) { diff --git a/node_modules/@npmcli/arborist/lib/arborist/index.js b/node_modules/@npmcli/arborist/lib/arborist/index.js index 067aed1120f51..4c7e96da4ecf3 100644 --- a/node_modules/@npmcli/arborist/lib/arborist/index.js +++ b/node_modules/@npmcli/arborist/lib/arborist/index.js @@ -35,6 +35,7 @@ const mixins = [ require('./deduper.js'), require('./audit.js'), require('./build-ideal-tree.js'), + require('./load-workspaces.js'), require('./load-actual.js'), require('./load-virtual.js'), require('./rebuild.js'), diff --git a/node_modules/@npmcli/arborist/lib/arborist/load-actual.js b/node_modules/@npmcli/arborist/lib/arborist/load-actual.js index 6aab202aa2720..5c440cfc7ce23 100644 --- a/node_modules/@npmcli/arborist/lib/arborist/load-actual.js +++ b/node_modules/@npmcli/arborist/lib/arborist/load-actual.js @@ -7,7 +7,6 @@ const {promisify} = require('util') const readdir = promisify(require('readdir-scoped-modules')) const walkUp = require('walk-up-path') const ancestorPath = require('common-ancestor-path') -const mapWorkspaces = require('@npmcli/map-workspaces') const Shrinkwrap = require('../shrinkwrap.js') const calcDepFlags = require('../calc-dep-flags.js') @@ -31,7 +30,7 @@ const _cache = Symbol('nodeLoadingCache') const _loadActual = Symbol('loadActual') const _loadActualVirtually = Symbol('loadActualVirtually') const _loadActualActually = Symbol('loadActualActually') -const _mapWorkspaces = Symbol('mapWorkspaces') +const _loadWorkspaces = Symbol.for('loadWorkspaces') const _actualTreePromise = Symbol('actualTreePromise') const _actualTree = Symbol('actualTree') const _transplant = Symbol('transplant') @@ -162,7 +161,7 @@ module.exports = cls => class ActualLoader extends cls { this[_findFSParents]() this[_transplant](root) - await this[_mapWorkspaces](this[_actualTree]) + await this[_loadWorkspaces](this[_actualTree]) // only reset root flags if we're not re-rooting, otherwise leave as-is calcDepFlags(this[_actualTree], !root) return this[_actualTree] @@ -309,18 +308,6 @@ module.exports = cls => class ActualLoader extends cls { () => {}) } - async [_mapWorkspaces] (node) { - const workspaces = await mapWorkspaces({ - cwd: node.path, - pkg: node.package, - }) - - if (workspaces.size) - node.workspaces = workspaces - - return node - } - async [_findMissingEdges] () { // try to resolve any missing edges by walking up the directory tree, // checking for the package in each node_modules folder. stop at the diff --git a/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js b/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js index 6453088f74bd5..7d0572826fc80 100644 --- a/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js +++ b/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js @@ -1,7 +1,6 @@ // mixin providing the loadVirtual method const {dirname, resolve} = require('path') -const mapWorkspaces = require('@npmcli/map-workspaces') const walkUp = require('walk-up-path') const nameFromFolder = require('@npmcli/name-from-folder') @@ -20,7 +19,8 @@ const assignParentage = Symbol('assignParentage') const loadRoot = Symbol('loadRoot') const loadNode = Symbol('loadVirtualNode') const loadLink = Symbol('loadVirtualLink') -const loadWorkspaces = Symbol('loadWorkspaces') +const loadWorkspaces = Symbol.for('loadWorkspaces') +const loadWorkspacesVirtual = Symbol.for('loadWorkspacesVirtual') const flagsSuspect = Symbol.for('flagsSuspect') const reCalcDepFlags = Symbol('reCalcDepFlags') const checkRootEdges = Symbol('checkRootEdges') @@ -131,7 +131,7 @@ module.exports = cls => class VirtualLoader extends cls { delete prod[name] const lockWS = [] - const workspaces = mapWorkspaces.virtual({ + const workspaces = this[loadWorkspacesVirtual]({ cwd: this.path, lockfile: s.data, }) @@ -270,16 +270,6 @@ module.exports = cls => class VirtualLoader extends cls { return node } - async [loadWorkspaces] (node) { - const workspaces = await mapWorkspaces({ - cwd: node.path, - pkg: node.package, - }) - if (workspaces.size) - node.workspaces = workspaces - return node - } - [loadLink] (location, targetLoc, target, meta) { const path = resolve(this.path, location) const link = new Link({ diff --git a/node_modules/@npmcli/arborist/lib/arborist/load-workspaces.js b/node_modules/@npmcli/arborist/lib/arborist/load-workspaces.js new file mode 100644 index 0000000000000..93d078415f585 --- /dev/null +++ b/node_modules/@npmcli/arborist/lib/arborist/load-workspaces.js @@ -0,0 +1,31 @@ +const mapWorkspaces = require('@npmcli/map-workspaces') + +const _appendWorkspaces = Symbol('appendWorkspaces') +// shared ref used by other mixins/Arborist +const _loadWorkspaces = Symbol.for('loadWorkspaces') +const _loadWorkspacesVirtual = Symbol.for('loadWorkspacesVirtual') + +module.exports = cls => class MapWorkspaces extends cls { + [_appendWorkspaces] (node, workspaces) { + if (node && workspaces.size) + node.workspaces = workspaces + + return node + } + + async [_loadWorkspaces] (node) { + if (node.workspaces) + return node + + const workspaces = await mapWorkspaces({ + cwd: node.path, + pkg: node.package, + }) + + return this[_appendWorkspaces](node, workspaces) + } + + [_loadWorkspacesVirtual] (opts) { + return mapWorkspaces.virtual(opts) + } +} diff --git a/node_modules/@npmcli/arborist/package.json b/node_modules/@npmcli/arborist/package.json index e9ff371f65b03..d8c63159af36c 100644 --- a/node_modules/@npmcli/arborist/package.json +++ b/node_modules/@npmcli/arborist/package.json @@ -1,6 +1,6 @@ { "name": "@npmcli/arborist", - "version": "0.0.31", + "version": "0.0.32", "description": "Manage node_modules trees", "dependencies": { "@npmcli/installed-package-contents": "^1.0.5", diff --git a/package-lock.json b/package-lock.json index a2675a97e505a..c701f1e3032ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -76,7 +76,7 @@ ], "license": "Artistic-2.0", "dependencies": { - "@npmcli/arborist": "^0.0.31", + "@npmcli/arborist": "^0.0.32", "@npmcli/ci-detect": "^1.2.0", "@npmcli/config": "^1.1.8", "@npmcli/run-script": "^1.7.0", @@ -379,9 +379,9 @@ } }, "node_modules/@npmcli/arborist": { - "version": "0.0.31", - "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-0.0.31.tgz", - "integrity": "sha512-BO5mCagGFv2szVhdAoZj2RcyjgOFxf1B+KpBTJvJYnYWwj/v4dDpzh5BixNrvDRcrCVZUq+kOOL/l53d5MHPjA==", + "version": "0.0.32", + "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-0.0.32.tgz", + "integrity": "sha512-FZgrZVFaBqSPRsfr7DYAdrqFBT6ShxXpkMUBBIFZ6mm7Bgt3h5exM050s9ROD2DBOsxXJGOJj8BfdAuU0ZABXg==", "inBundle": true, "dependencies": { "@npmcli/installed-package-contents": "^1.0.5", @@ -8511,9 +8511,9 @@ } }, "@npmcli/arborist": { - "version": "0.0.31", - "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-0.0.31.tgz", - "integrity": "sha512-BO5mCagGFv2szVhdAoZj2RcyjgOFxf1B+KpBTJvJYnYWwj/v4dDpzh5BixNrvDRcrCVZUq+kOOL/l53d5MHPjA==", + "version": "0.0.32", + "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-0.0.32.tgz", + "integrity": "sha512-FZgrZVFaBqSPRsfr7DYAdrqFBT6ShxXpkMUBBIFZ6mm7Bgt3h5exM050s9ROD2DBOsxXJGOJj8BfdAuU0ZABXg==", "requires": { "@npmcli/installed-package-contents": "^1.0.5", "@npmcli/map-workspaces": "^1.0.1", diff --git a/package.json b/package.json index 891cf52a3e5a3..2b3b5a3bf273a 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "./package.json": "./package.json" }, "dependencies": { - "@npmcli/arborist": "^0.0.31", + "@npmcli/arborist": "^0.0.32", "@npmcli/ci-detect": "^1.2.0", "@npmcli/config": "^1.1.8", "@npmcli/run-script": "^1.7.0",