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:
authorMichael Perrotte <mike@npmjs.com>2020-02-20 01:52:44 +0300
committerisaacs <i@izs.me>2020-05-08 04:11:51 +0300
commita2c3820fe9a54c3e3b4f7c7ffdd9143a796e2f5e (patch)
tree5c06a7516e8aef07809d176c79d898224830e89e /node_modules
parent09dac89c1bc20eb2c1f1f272c9e07fc1a579d75a (diff)
@npmcli/arborist@0.0.0-pre.8
Diffstat (limited to 'node_modules')
-rw-r--r--node_modules/@npmcli/arborist/README.md8
-rw-r--r--node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js87
-rw-r--r--node_modules/@npmcli/arborist/lib/arborist/reify.js5
-rw-r--r--node_modules/@npmcli/arborist/package.json32
4 files changed, 84 insertions, 48 deletions
diff --git a/node_modules/@npmcli/arborist/README.md b/node_modules/@npmcli/arborist/README.md
index 8dc50f44f..a16b298ff 100644
--- a/node_modules/@npmcli/arborist/README.md
+++ b/node_modules/@npmcli/arborist/README.md
@@ -9,7 +9,7 @@ folder](https://github.com/npm/arborist/tree/master/notes).
## USAGE
-```javascript
+```js
const Arborist = require('@npmcli/arborist')
const arb = new Arborist({
@@ -82,9 +82,9 @@ arb.buildIdealTree(options).then(() => {
// - optionalDependencies
// - devDependencies
// - peerDependenciesMeta
- // Each matches what you'd find in a package.json file, but only
- // specifies additions/changes to the current set. They're added
- // to the root node's requirements, and then the tree is built.
+ // Each is an array of package specifiers, which would be passed to
+ // `npm install`. They're added to the root node's requirements, and
+ // then the tree is built.
// update: Either `true` to just go ahead and update everything, or an
// object with any or all of the following fields:
// - all: boolean. set to true to just update everything
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 c8e315e47..069e234f0 100644
--- a/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js
+++ b/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js
@@ -56,7 +56,7 @@ const _pruneForReplacement = Symbol('pruneForReplacement')
const _fixDepFlags = Symbol('fixDepFlags')
const _resolveLinks = Symbol('resolveLinks')
const _rootNodeFromPackage = Symbol('rootNodeFromPackage')
-const _addRm = Symbol('addRm')
+const _add = Symbol('add')
const _explicitRequests = Symbol('explicitRequests')
const _queueNamedUpdates = Symbol('queueNamedUpdates')
const _shouldUpdateNode = Symbol('shouldUpdateNode')
@@ -68,6 +68,7 @@ const _follow = Symbol('follow')
// used by Reify mixin
const _idealTreePrune = Symbol.for('idealTreePrune')
+const _resolvedAdd = Symbol.for('resolvedAdd')
const Virtual = require('./load-virtual.js')
const Actual = require('./load-actual.js')
@@ -191,40 +192,72 @@ module.exports = cls => class IdealTreeBuilder extends Tracker(Virtual(Actual(cl
// process the add/rm requests by modifying the root node, and the
// update.names request by queueing nodes dependent on those named.
[_applyUserRequests] (options) {
+ // If we have a list of package names to update, and we know it's
+ // going to update them wherever they are, add any paths into those
+ // named nodes to the buildIdealTree queue.
+ if (this[_updateNames].length)
+ this[_queueNamedUpdates]()
+
+ if (options.rm && options.rm.length)
+ addRmPkgDeps.rm(this.idealTree.package, options.rm)
+
+ // triggers a refresh of all edgesOut
+ const after = () => this.idealTree.package = this.idealTree.package
+
// these just add and remove to/from the root node
- // but both mean we have to do a full walk, not just fixing problems
- // and stopping when we no longer see any problems.
- if (options.add || options.rm)
- this[_addRm](options)
-
- // get the list of deps that we're explicitly requesting, so that
- // 'npm install foo' will reinstall, even if we already have it.
- if (options.add) {
- for (const [type, specs] of Object.entries(options.add)) {
+ return (options.add)
+ ? this[_add](options.add).then(after)
+ : after()
+ }
+
+
+ // add => might return promise
+ // might not have name, call pacote.manifest (find name)
+ [_add] (add) {
+ const promises = []
+ this[_resolvedAdd] = {}
+
+ // not going to work for:
+ // peerDepsMeta
+ // bundledDeps
+ for (const [type, specs] of Object.entries(add)) {
+ const p = Promise.all(specs.map(s => {
+ const spec = npa(s, this.path)
+ if (spec.name) {
+ return spec
+ } else {
+ return pacote.manifest(spec).then(mani => {
+ spec.name = mani.name
+ return spec
+ })
+ }
+ })).then(specs => {
+ for (const spec of specs) {
+ if (type === 'bundleDependencies') {
+ this[_resolvedAdd][type] = this[_resolvedAdd][type] || []
+ this[_resolvedAdd][type].push(spec.name)
+ } else {
+ this[_resolvedAdd][type] = this[_resolvedAdd][type] || {}
+ this[_resolvedAdd][type][spec.name] = spec.rawSpec
+ }
+ }
+ })
+ promises.push(p)
+ }
+ return Promise.all(promises).then(() => {
+ // get the list of deps that we're explicitly requesting, so that
+ // 'npm install foo' will reinstall, even if we already have it.
+ for (const [type, specs] of Object.entries(this[_resolvedAdd])) {
if (type === 'dependencies' || type === 'devDependencies' ||
type === 'optionalDependencies' || type === 'peerDependencies') {
- for (const name of Object.keys(options.add[type])) {
+ for (const name of Object.keys(this[_resolvedAdd][type])) {
this[_explicitRequests].add(name)
}
}
}
- }
-
- // If we have a list of package names to update, and we know it's
- // going to update them wherever they are, add any paths into those
- // named nodes to the buildIdealTree queue.
- if (this[_updateNames].length)
- this[_queueNamedUpdates]()
- }
- [_addRm] ({ add, rm }) {
- const pkg = this.idealTree.package
- if (rm && rm.length)
- addRmPkgDeps.rm(pkg, rm)
- if (add)
- addRmPkgDeps.add(pkg, add)
- // triggers a refresh of all edgesOut
- this.idealTree.package = pkg
+ addRmPkgDeps.add(this.idealTree.package, this[_resolvedAdd])
+ })
}
[_queueNamedUpdates] () {
diff --git a/node_modules/@npmcli/arborist/lib/arborist/reify.js b/node_modules/@npmcli/arborist/lib/arborist/reify.js
index 758d42e75..3d71f6614 100644
--- a/node_modules/@npmcli/arborist/lib/arborist/reify.js
+++ b/node_modules/@npmcli/arborist/lib/arborist/reify.js
@@ -85,6 +85,7 @@ const _force = Symbol('force')
// defined by Ideal mixin
const _idealTreePrune = Symbol.for('idealTreePrune')
const _explicitRootInstalls = Symbol.for('explicitRootInstalls')
+const _resolvedAdd = Symbol.for('resolvedAdd')
module.exports = cls => class Reifier extends Ideal(cls) {
constructor (options) {
@@ -711,10 +712,10 @@ module.exports = cls => class Reifier extends Ideal(cls) {
if (options.save === false)
return
- if (options.add) {
+ if (this[_resolvedAdd]) {
const pkg = this.idealTree.package
// need to save these more nicely, now that we know what they are
- for (const [type, specs] of Object.entries(options.add)) {
+ for (const [type, specs] of Object.entries(this[_resolvedAdd])) {
if (!specs || typeof specs !== 'object' || Array.isArray(specs))
continue
diff --git a/node_modules/@npmcli/arborist/package.json b/node_modules/@npmcli/arborist/package.json
index 69b0287bf..445b3971a 100644
--- a/node_modules/@npmcli/arborist/package.json
+++ b/node_modules/@npmcli/arborist/package.json
@@ -1,8 +1,14 @@
{
- "_from": "@npmcli/arborist",
- "_id": "@npmcli/arborist@0.0.0-pre.7",
+ "_args": [
+ [
+ "@npmcli/arborist@0.0.0-pre.8",
+ "/Users/isaacs/dev/npm/cli"
+ ]
+ ],
+ "_from": "@npmcli/arborist@0.0.0-pre.8",
+ "_id": "@npmcli/arborist@0.0.0-pre.8",
"_inBundle": false,
- "_integrity": "sha512-xUtElnU5cn7TapgQ4viCCXPz1L7VXlQKhbwDKvvCHVyftRLIGd5osvNkdH08SPC8cIXNrVf7LKINZs2kpMkPBA==",
+ "_integrity": "sha512-l1qCEvdxX3NR69ifgVPX3bG7GbvhsrEv63G7nKvRNMYedQzBtQx8H3ECukVblk00KbqVoJh/3hfzMPUJVRP17g==",
"_location": "/@npmcli/arborist",
"_phantomChildren": {
"glob": "7.1.4",
@@ -12,24 +18,22 @@
"write-file-atomic": "2.4.3"
},
"_requested": {
- "type": "tag",
+ "type": "version",
"registry": true,
- "raw": "@npmcli/arborist",
+ "raw": "@npmcli/arborist@0.0.0-pre.8",
"name": "@npmcli/arborist",
"escapedName": "@npmcli%2farborist",
"scope": "@npmcli",
- "rawSpec": "",
+ "rawSpec": "0.0.0-pre.8",
"saveSpec": null,
- "fetchSpec": "latest"
+ "fetchSpec": "0.0.0-pre.8"
},
"_requiredBy": [
- "#USER",
"/"
],
- "_resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-0.0.0-pre.7.tgz",
- "_shasum": "77e31962e33a4a7a9f604e772f2e2b2dd7ec8c84",
- "_spec": "@npmcli/arborist",
- "_where": "/Users/claudiahdz/npm/cli",
+ "_resolved": "https://registry.npmjs.org/@npmcli/arborist/-/arborist-0.0.0-pre.8.tgz",
+ "_spec": "0.0.0-pre.8",
+ "_where": "/Users/isaacs/dev/npm/cli",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
@@ -38,7 +42,6 @@
"bugs": {
"url": "https://github.com/npm/arborist/issues"
},
- "bundleDependencies": false,
"dependencies": {
"@npmcli/installed-package-contents": "^1.0.5",
"@npmcli/run-script": "^1.2.1",
@@ -56,7 +59,6 @@
"semver": "^7.1.2",
"treeverse": "^1.0.1"
},
- "deprecated": false,
"description": "Manage node_modules trees",
"devDependencies": {
"minify-registry-metadata": "^2.1.0",
@@ -90,5 +92,5 @@
"esm": false,
"timeout": "60"
},
- "version": "0.0.0-pre.7"
+ "version": "0.0.0-pre.8"
}