Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-09-30 22:42:46 +0300
committerGar <gar+gh@danger.computer>2021-09-30 22:49:18 +0300
commit8349c3c1557ac52973ad08c10db492e3a5a30204 (patch)
treea9f30844846e3dc4748bc5e222a7fa4a4ad2220b
parentbb0b2da6c0275dd8c9eda894452ce45b2e8c4c51 (diff)
deps: arborist@2.10.0
* includeWorkspaceRoot support * workspacesEnabled=false support PR-URL: https://github.com/npm/cli/pull/3815 Credit: @wraithgar Close: #3815 Reviewed-by: @isaacs
-rw-r--r--node_modules/@npmcli/arborist/lib/arborist/audit.js11
-rw-r--r--node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js20
-rw-r--r--node_modules/@npmcli/arborist/lib/arborist/index.js29
-rw-r--r--node_modules/@npmcli/arborist/lib/arborist/rebuild.js7
-rw-r--r--node_modules/@npmcli/arborist/lib/arborist/reify.js16
-rw-r--r--node_modules/@npmcli/arborist/package.json2
-rw-r--r--package-lock.json14
-rw-r--r--package.json2
8 files changed, 83 insertions, 18 deletions
diff --git a/node_modules/@npmcli/arborist/lib/arborist/audit.js b/node_modules/@npmcli/arborist/lib/arborist/audit.js
index c0cd79bb1..eb4a35655 100644
--- a/node_modules/@npmcli/arborist/lib/arborist/audit.js
+++ b/node_modules/@npmcli/arborist/lib/arborist/audit.js
@@ -5,6 +5,7 @@ const AuditReport = require('../audit-report.js')
// shared with reify
const _global = Symbol.for('global')
const _workspaces = Symbol.for('workspaces')
+const _includeWorkspaceRoot = Symbol.for('includeWorkspaceRoot')
module.exports = cls => class Auditor extends cls {
async audit (options = {}) {
@@ -23,7 +24,15 @@ module.exports = cls => class Auditor extends cls {
process.emit('time', 'audit')
const tree = await this.loadVirtual()
if (this[_workspaces] && this[_workspaces].length) {
- options.filterSet = this.workspaceDependencySet(tree, this[_workspaces])
+ options.filterSet = this.workspaceDependencySet(
+ tree,
+ this[_workspaces],
+ this[_includeWorkspaceRoot]
+ )
+ }
+ if (!options.workspacesEnabled) {
+ options.filterSet =
+ this.excludeWorkspacesDependencySet(tree)
}
this.auditReport = await AuditReport.load(tree, options)
const ret = options.fix ? this.reify(options) : this.auditReport
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 b7876b114..3e6a9838f 100644
--- a/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js
+++ b/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js
@@ -93,6 +93,7 @@ const _checkEngine = Symbol('checkEngine')
const _checkPlatform = Symbol('checkPlatform')
const _virtualRoots = Symbol('virtualRoots')
const _virtualRoot = Symbol('virtualRoot')
+const _includeWorkspaceRoot = Symbol.for('includeWorkspaceRoot')
const _failPeerConflict = Symbol('failPeerConflict')
const _explainPeerConflict = Symbol('explainPeerConflict')
@@ -115,12 +116,13 @@ module.exports = cls => class IdealTreeBuilder extends cls {
options.registry = this.registry = registry.replace(/\/+$/, '') + '/'
const {
- idealTree = null,
- global = false,
follow = false,
+ force = false,
+ global = false,
globalStyle = false,
+ idealTree = null,
+ includeWorkspaceRoot = false,
legacyPeerDeps = false,
- force = false,
packageLock = true,
strictPeerDeps = false,
workspaces = [],
@@ -162,6 +164,8 @@ module.exports = cls => class IdealTreeBuilder extends cls {
// don't hold onto references for nodes that are garbage collected.
this[_peerSetSource] = new WeakMap()
this[_virtualRoots] = new Map()
+
+ this[_includeWorkspaceRoot] = includeWorkspaceRoot
}
get explicitRequests () {
@@ -394,8 +398,14 @@ module.exports = cls => class IdealTreeBuilder extends cls {
if (!this[_workspaces].length) {
await this[_applyUserRequestsToNode](tree, options)
} else {
- await Promise.all(this.workspaceNodes(tree, this[_workspaces])
- .map(node => this[_applyUserRequestsToNode](node, options)))
+ const nodes = this.workspaceNodes(tree, this[_workspaces])
+ if (this[_includeWorkspaceRoot]) {
+ nodes.push(tree)
+ }
+ const appliedRequests = nodes.map(
+ node => this[_applyUserRequestsToNode](node, options)
+ )
+ await Promise.all(appliedRequests)
}
process.emit('timeEnd', 'idealTree:userRequests')
diff --git a/node_modules/@npmcli/arborist/lib/arborist/index.js b/node_modules/@npmcli/arborist/lib/arborist/index.js
index d8ca67faa..ccfa7cad9 100644
--- a/node_modules/@npmcli/arborist/lib/arborist/index.js
+++ b/node_modules/@npmcli/arborist/lib/arborist/index.js
@@ -58,6 +58,7 @@ class Arborist extends Base {
cache: options.cache || `${homedir()}/.npm/_cacache`,
packumentCache: options.packumentCache || new Map(),
log: options.log || procLog,
+ workspacesEnabled: options.workspacesEnabled !== false,
}
if (options.saveType && !saveTypeMap.get(options.saveType)) {
throw new Error(`Invalid saveType ${options.saveType}`)
@@ -73,8 +74,15 @@ class Arborist extends Base {
}
// returns a set of workspace nodes and all their deps
- workspaceDependencySet (tree, workspaces) {
+ workspaceDependencySet (tree, workspaces, includeWorkspaceRoot) {
const wsNodes = this.workspaceNodes(tree, workspaces)
+ if (includeWorkspaceRoot) {
+ for (const edge of tree.edgesOut.values()) {
+ if (edge.type !== 'workspace' && edge.to) {
+ wsNodes.push(edge.to)
+ }
+ }
+ }
const set = new Set(wsNodes)
const extraneous = new Set()
for (const node of set) {
@@ -96,6 +104,25 @@ class Arborist extends Base {
for (const extra of extraneous) {
set.add(extra)
}
+
+ return set
+ }
+
+ excludeWorkspacesDependencySet (tree) {
+ const set = new Set()
+ for (const edge of tree.edgesOut.values()) {
+ if (edge.type !== 'workspace' && edge.to) {
+ set.add(edge.to)
+ }
+ }
+ for (const node of set) {
+ for (const edge of node.edgesOut.values()) {
+ if (edge.to) {
+ set.add(edge.to)
+ }
+ }
+ }
+
return set
}
}
diff --git a/node_modules/@npmcli/arborist/lib/arborist/rebuild.js b/node_modules/@npmcli/arborist/lib/arborist/rebuild.js
index e48bdd76b..6fa5c0011 100644
--- a/node_modules/@npmcli/arborist/lib/arborist/rebuild.js
+++ b/node_modules/@npmcli/arborist/lib/arborist/rebuild.js
@@ -34,6 +34,7 @@ const _addToBuildSet = Symbol('addToBuildSet')
const _checkBins = Symbol.for('checkBins')
const _queues = Symbol('queues')
const _scriptShell = Symbol('scriptShell')
+const _includeWorkspaceRoot = Symbol.for('includeWorkspaceRoot')
const _force = Symbol.for('force')
@@ -77,7 +78,11 @@ module.exports = cls => class Builder extends cls {
if (!nodes) {
const tree = await this.loadActual()
if (this[_workspaces] && this[_workspaces].length) {
- const filterSet = this.workspaceDependencySet(tree, this[_workspaces])
+ const filterSet = this.workspaceDependencySet(
+ tree,
+ this[_workspaces],
+ this[_includeWorkspaceRoot]
+ )
nodes = tree.inventory.filter(node => filterSet.has(node))
} else {
nodes = tree.inventory.values()
diff --git a/node_modules/@npmcli/arborist/lib/arborist/reify.js b/node_modules/@npmcli/arborist/lib/arborist/reify.js
index 3a9c47974..a279d8956 100644
--- a/node_modules/@npmcli/arborist/lib/arborist/reify.js
+++ b/node_modules/@npmcli/arborist/lib/arborist/reify.js
@@ -83,6 +83,7 @@ const _validateNodeModules = Symbol('validateNodeModules')
const _nmValidated = Symbol('nmValidated')
const _validatePath = Symbol('validatePath')
const _reifyPackages = Symbol.for('reifyPackages')
+const _includeWorkspaceRoot = Symbol.for('includeWorkspaceRoot')
const _omitDev = Symbol('omitDev')
const _omitOptional = Symbol('omitOptional')
@@ -340,6 +341,15 @@ module.exports = cls => class Reifier extends cls {
filterNodes.push(actual)
}
}
+ if (this[_includeWorkspaceRoot] && (this[_workspaces].length > 0)) {
+ for (const tree of [this.idealTree, this.actualTree]) {
+ for (const {type, to} of tree.edgesOut.values()) {
+ if (type !== 'workspace' && to) {
+ filterNodes.push(to)
+ }
+ }
+ }
+ }
}
// find all the nodes that need to change between the actual
@@ -901,7 +911,11 @@ module.exports = cls => class Reifier extends cls {
// if we're operating on a workspace, only audit the workspace deps
if (this[_workspaces] && this[_workspaces].length) {
- options.filterSet = this.workspaceDependencySet(tree, this[_workspaces])
+ options.filterSet = this.workspaceDependencySet(
+ tree,
+ this[_workspaces],
+ this[_includeWorkspaceRoot]
+ )
}
this.auditReport = AuditReport.load(tree, options)
diff --git a/node_modules/@npmcli/arborist/package.json b/node_modules/@npmcli/arborist/package.json
index b39818d48..f912d2af1 100644
--- a/node_modules/@npmcli/arborist/package.json
+++ b/node_modules/@npmcli/arborist/package.json
@@ -1,6 +1,6 @@
{
"name": "@npmcli/arborist",
- "version": "2.9.0",
+ "version": "2.10.0",
"description": "Manage node_modules trees",
"dependencies": {
"@isaacs/string-locale-compare": "^1.0.1",
diff --git a/package-lock.json b/package-lock.json
index e8cc960ec..b8decbc1a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -85,7 +85,7 @@
],
"dependencies": {
"@isaacs/string-locale-compare": "^1.1.0",
- "@npmcli/arborist": "^2.9.0",
+ "@npmcli/arborist": "^2.10.0",
"@npmcli/ci-detect": "^1.2.0",
"@npmcli/config": "^2.3.0",
"@npmcli/map-workspaces": "^1.0.4",
@@ -771,9 +771,9 @@
}
},
"node_modules/@npmcli/arborist": {
- "version": "2.9.0",
- "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-2.9.0.tgz",
- "integrity": "sha512-21DTow2xC0GlkowlE4zOu99UY21nSymW14fHZmB0yeAqhagmttJPmCUZXU+ngJmJ/Dwe5YP9QJUTgEVRLqnwcg==",
+ "version": "2.10.0",
+ "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-2.10.0.tgz",
+ "integrity": "sha512-CLnD+zXG9oijEEzViimz8fbOoFVb7hoypiaf7p6giJhvYtrxLAyY3cZAMPIFQvsG731+02eMDp3LqVBNo7BaZA==",
"inBundle": true,
"dependencies": {
"@isaacs/string-locale-compare": "^1.0.1",
@@ -11023,9 +11023,9 @@
"dev": true
},
"@npmcli/arborist": {
- "version": "2.9.0",
- "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-2.9.0.tgz",
- "integrity": "sha512-21DTow2xC0GlkowlE4zOu99UY21nSymW14fHZmB0yeAqhagmttJPmCUZXU+ngJmJ/Dwe5YP9QJUTgEVRLqnwcg==",
+ "version": "2.10.0",
+ "resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-2.10.0.tgz",
+ "integrity": "sha512-CLnD+zXG9oijEEzViimz8fbOoFVb7hoypiaf7p6giJhvYtrxLAyY3cZAMPIFQvsG731+02eMDp3LqVBNo7BaZA==",
"requires": {
"@isaacs/string-locale-compare": "^1.0.1",
"@npmcli/installed-package-contents": "^1.0.7",
diff --git a/package.json b/package.json
index 705fb779e..31083ff0b 100644
--- a/package.json
+++ b/package.json
@@ -54,7 +54,7 @@
},
"dependencies": {
"@isaacs/string-locale-compare": "^1.1.0",
- "@npmcli/arborist": "^2.9.0",
+ "@npmcli/arborist": "^2.10.0",
"@npmcli/ci-detect": "^1.2.0",
"@npmcli/config": "^2.3.0",
"@npmcli/map-workspaces": "^1.0.4",