@npmcli/arborist 7.2.2 → 7.3.1

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.
@@ -4,7 +4,7 @@ const rpj = require('read-package-json-fast')
4
4
  const npa = require('npm-package-arg')
5
5
  const pacote = require('pacote')
6
6
  const cacache = require('cacache')
7
- const promiseCallLimit = require('promise-call-limit')
7
+ const { callLimit: promiseCallLimit } = require('promise-call-limit')
8
8
  const realpath = require('../../lib/realpath.js')
9
9
  const { resolve, dirname } = require('path')
10
10
  const treeCheck = require('../tree-check.js')
@@ -56,30 +56,52 @@ const _global = Symbol.for('global')
56
56
  const _idealTreePrune = Symbol.for('idealTreePrune')
57
57
 
58
58
  // Push items in, pop them sorted by depth and then path
59
+ // Sorts physically shallower deps up to the front of the queue, because
60
+ // they'll affect things deeper in, then alphabetical for consistency between
61
+ // installs
59
62
  class DepsQueue {
63
+ // [{ sorted, items }] indexed by depth
60
64
  #deps = []
61
65
  #sorted = true
66
+ #minDepth = 0
67
+ #length = 0
62
68
 
63
69
  get length () {
64
- return this.#deps.length
70
+ return this.#length
65
71
  }
66
72
 
67
73
  push (item) {
68
- if (!this.#deps.includes(item)) {
69
- this.#sorted = false
70
- this.#deps.push(item)
74
+ if (!this.#deps[item.depth]) {
75
+ this.#length++
76
+ this.#deps[item.depth] = { sorted: true, items: [item] }
77
+ // no minDepth check needed, this branch is only reached when we are in
78
+ // the middle of a shallower depth and creating a new one
79
+ return
80
+ }
81
+ if (!this.#deps[item.depth].items.includes(item)) {
82
+ this.#length++
83
+ this.#deps[item.depth].sorted = false
84
+ this.#deps[item.depth].items.push(item)
85
+ if (item.depth < this.#minDepth) {
86
+ this.#minDepth = item.depth
87
+ }
71
88
  }
72
89
  }
73
90
 
74
91
  pop () {
75
- if (!this.#sorted) {
76
- // sort physically shallower deps up to the front of the queue, because
77
- // they'll affect things deeper in, then alphabetical
78
- this.#deps.sort((a, b) =>
79
- (a.depth - b.depth) || localeCompare(a.path, b.path))
80
- this.#sorted = true
92
+ let depth
93
+ while (!depth?.items.length) {
94
+ depth = this.#deps[this.#minDepth]
95
+ if (!depth?.items.length) {
96
+ this.#minDepth++
97
+ }
98
+ }
99
+ if (!depth.sorted) {
100
+ depth.items.sort((a, b) => localeCompare(a.path, b.path))
101
+ depth.sorted = true
81
102
  }
82
- return this.#deps.shift()
103
+ this.#length--
104
+ return depth.items.shift()
83
105
  }
84
106
  }
85
107
 
@@ -1016,7 +1038,7 @@ This is a one-time fix-up, please be patient...
1016
1038
  // may well be an optional dep that has gone missing. it'll
1017
1039
  // fail later anyway.
1018
1040
  for (const e of this.#problemEdges(placed)) {
1019
- promises.push(
1041
+ promises.push(() =>
1020
1042
  this.#fetchManifest(npa.resolve(e.name, e.spec, fromPath(placed, e)))
1021
1043
  .catch(er => null)
1022
1044
  )
@@ -1031,7 +1053,7 @@ This is a one-time fix-up, please be patient...
1031
1053
  }
1032
1054
  }
1033
1055
 
1034
- await Promise.all(promises)
1056
+ await promiseCallLimit(promises)
1035
1057
  return this.#buildDepStep()
1036
1058
  }
1037
1059
 
@@ -1208,8 +1230,12 @@ This is a one-time fix-up, please be patient...
1208
1230
  } else {
1209
1231
  const cleanRawSpec = cleanUrl(spec.rawSpec)
1210
1232
  log.silly('fetch manifest', spec.raw.replace(spec.rawSpec, cleanRawSpec))
1211
- const p = pacote.manifest(spec, options)
1212
- .then(mani => {
1233
+ const o = {
1234
+ ...options,
1235
+ fullMetadata: true,
1236
+ }
1237
+ const p = pacote.manifest(spec, o)
1238
+ .then(({ license, ...mani }) => {
1213
1239
  this.#manifests.set(spec.raw, mani)
1214
1240
  return mani
1215
1241
  })
@@ -7,7 +7,7 @@ const promiseAllRejectLate = require('promise-all-reject-late')
7
7
  const rpj = require('read-package-json-fast')
8
8
  const binLinks = require('bin-links')
9
9
  const runScript = require('@npmcli/run-script')
10
- const promiseCallLimit = require('promise-call-limit')
10
+ const { callLimit: promiseCallLimit } = require('promise-call-limit')
11
11
  const { resolve } = require('path')
12
12
  const {
13
13
  isNodeGypPackage,
@@ -387,7 +387,7 @@ module.exports = cls => class Builder extends cls {
387
387
  : p)
388
388
 
389
389
  process.emit('timeEnd', timer)
390
- }), limit)
390
+ }), { limit })
391
391
  process.emit('timeEnd', `build:run:${event}`)
392
392
  }
393
393
 
@@ -31,6 +31,7 @@ const relpath = require('../relpath.js')
31
31
  const Diff = require('../diff.js')
32
32
  const retirePath = require('../retire-path.js')
33
33
  const promiseAllRejectLate = require('promise-all-reject-late')
34
+ const { callLimit: promiseCallLimit } = require('promise-call-limit')
34
35
  const optionalSet = require('../optional-set.js')
35
36
  const calcDepFlags = require('../calc-dep-flags.js')
36
37
  const { saveTypeMap, hasSubKey } = require('../add-rm-pkg-deps.js')
@@ -628,7 +629,7 @@ module.exports = cls => class Reifier extends cls {
628
629
  process.emit('time', timer)
629
630
  this.addTracker('reify', node.name, node.location)
630
631
 
631
- const { npmVersion, nodeVersion, cpu, os } = this.options
632
+ const { npmVersion, nodeVersion, cpu, os, libc } = this.options
632
633
  const p = Promise.resolve().then(async () => {
633
634
  // when we reify an optional node, check the engine and platform
634
635
  // first. be sure to ignore the --force and --engine-strict flags,
@@ -638,7 +639,7 @@ module.exports = cls => class Reifier extends cls {
638
639
  // eslint-disable-next-line promise/always-return
639
640
  if (node.optional) {
640
641
  checkEngine(node.package, npmVersion, nodeVersion, false)
641
- checkPlatform(node.package, false, { cpu, os })
642
+ checkPlatform(node.package, false, { cpu, os, libc })
642
643
  }
643
644
  await this[_checkBins](node)
644
645
  await this[_extractOrLink](node)
@@ -817,10 +818,12 @@ module.exports = cls => class Reifier extends cls {
817
818
  }
818
819
 
819
820
  // extract all the nodes with bundles
820
- return promiseAllRejectLate(set.map(node => {
821
- this[_bundleUnpacked].add(node)
822
- return this[_reifyNode](node)
823
- }))
821
+ return promiseCallLimit(set.map(node => {
822
+ return () => {
823
+ this[_bundleUnpacked].add(node)
824
+ return this[_reifyNode](node)
825
+ }
826
+ }), { rejectLate: true })
824
827
  // then load their unpacked children and move into the ideal tree
825
828
  .then(nodes =>
826
829
  promiseAllRejectLate(nodes.map(async node => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npmcli/arborist",
3
- "version": "7.2.2",
3
+ "version": "7.3.1",
4
4
  "description": "Manage node_modules trees",
5
5
  "dependencies": {
6
6
  "@isaacs/string-locale-compare": "^1.1.0",
@@ -30,7 +30,7 @@
30
30
  "parse-conflict-json": "^3.0.0",
31
31
  "proc-log": "^3.0.0",
32
32
  "promise-all-reject-late": "^1.0.0",
33
- "promise-call-limit": "^1.0.2",
33
+ "promise-call-limit": "^3.0.1",
34
34
  "read-package-json-fast": "^3.0.2",
35
35
  "semver": "^7.3.7",
36
36
  "ssri": "^10.0.5",