@npmcli/arborist 7.4.2 → 7.5.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.
@@ -13,7 +13,7 @@ const _fixAvailable = Symbol('fixAvailable')
13
13
  const _checkTopNode = Symbol('checkTopNode')
14
14
  const _init = Symbol('init')
15
15
  const _omit = Symbol('omit')
16
- const log = require('proc-log')
16
+ const { log, time } = require('proc-log')
17
17
 
18
18
  const fetch = require('npm-registry-fetch')
19
19
 
@@ -117,7 +117,7 @@ class AuditReport extends Map {
117
117
  }
118
118
 
119
119
  async [_init] () {
120
- process.emit('time', 'auditReport:init')
120
+ const timeEnd = time.start('auditReport:init')
121
121
 
122
122
  const promises = []
123
123
  for (const [name, advisories] of Object.entries(this.report)) {
@@ -210,7 +210,8 @@ class AuditReport extends Map {
210
210
  }
211
211
  }
212
212
  }
213
- process.emit('timeEnd', 'auditReport:init')
213
+
214
+ timeEnd()
214
215
  }
215
216
 
216
217
  [_checkTopNode] (topNode, vuln, spec) {
@@ -306,7 +307,7 @@ class AuditReport extends Map {
306
307
  return null
307
308
  }
308
309
 
309
- process.emit('time', 'auditReport:getReport')
310
+ const timeEnd = time.start('auditReport:getReport')
310
311
  try {
311
312
  try {
312
313
  // first try the super fast bulk advisory listing
@@ -347,7 +348,7 @@ class AuditReport extends Map {
347
348
  this.error = er
348
349
  return null
349
350
  } finally {
350
- process.emit('timeEnd', 'auditReport:getReport')
351
+ timeEnd()
351
352
  }
352
353
  }
353
354
  }
package/lib/dep-valid.js CHANGED
@@ -124,7 +124,7 @@ const linkValid = (child, requested, requestor) => {
124
124
  return isLink && relative(child.realpath, requested.fetchSpec) === ''
125
125
  }
126
126
 
127
- const tarballValid = (child, requested, requestor) => {
127
+ const tarballValid = (child, requested) => {
128
128
  if (child.isLink) {
129
129
  return false
130
130
  }
package/lib/inventory.js CHANGED
@@ -130,7 +130,7 @@ class Inventory extends Map {
130
130
  return super.get(node.location) === node
131
131
  }
132
132
 
133
- set (k, v) {
133
+ set () {
134
134
  throw new Error('direct set() not supported, use inventory.add(node)')
135
135
  }
136
136
  }
package/lib/place-dep.js CHANGED
@@ -8,7 +8,7 @@
8
8
  // a result.
9
9
 
10
10
  const localeCompare = require('@isaacs/string-locale-compare')('en')
11
- const log = require('proc-log')
11
+ const { log } = require('proc-log')
12
12
  const { redact } = require('@npmcli/redact')
13
13
  const deepestNestingTarget = require('./deepest-nesting-target.js')
14
14
  const CanPlaceDep = require('./can-place-dep.js')
@@ -3,7 +3,7 @@
3
3
  const { resolve } = require('path')
4
4
  const { parser, arrayDelimiter } = require('@npmcli/query')
5
5
  const localeCompare = require('@isaacs/string-locale-compare')('en')
6
- const log = require('proc-log')
6
+ const { log } = require('proc-log')
7
7
  const { minimatch } = require('minimatch')
8
8
  const npa = require('npm-package-arg')
9
9
  const pacote = require('pacote')
@@ -650,27 +650,27 @@ class Results {
650
650
  // operators for attribute selectors
651
651
  const attributeOperators = {
652
652
  // attribute value is equivalent
653
- '=' ({ attr, value, insensitive }) {
653
+ '=' ({ attr, value }) {
654
654
  return attr === value
655
655
  },
656
656
  // attribute value contains word
657
- '~=' ({ attr, value, insensitive }) {
657
+ '~=' ({ attr, value }) {
658
658
  return (attr.match(/\w+/g) || []).includes(value)
659
659
  },
660
660
  // attribute value contains string
661
- '*=' ({ attr, value, insensitive }) {
661
+ '*=' ({ attr, value }) {
662
662
  return attr.includes(value)
663
663
  },
664
664
  // attribute value is equal or starts with
665
- '|=' ({ attr, value, insensitive }) {
665
+ '|=' ({ attr, value }) {
666
666
  return attr.startsWith(`${value}-`)
667
667
  },
668
668
  // attribute value starts with
669
- '^=' ({ attr, value, insensitive }) {
669
+ '^=' ({ attr, value }) {
670
670
  return attr.startsWith(value)
671
671
  },
672
672
  // attribute value ends with
673
- '$=' ({ attr, value, insensitive }) {
673
+ '$=' ({ attr, value }) {
674
674
  return attr.endsWith(value)
675
675
  },
676
676
  }
package/lib/shrinkwrap.js CHANGED
@@ -33,7 +33,7 @@ const mismatch = (a, b) => a && b && a !== b
33
33
  // After calling this.commit(), any nodes not present in the tree will have
34
34
  // been removed from the shrinkwrap data as well.
35
35
 
36
- const log = require('proc-log')
36
+ const { log } = require('proc-log')
37
37
  const YarnLock = require('./yarn-lock.js')
38
38
  const {
39
39
  readFile,
@@ -1145,6 +1145,7 @@ class Shrinkwrap {
1145
1145
  throw new Error('run load() before saving data')
1146
1146
  }
1147
1147
 
1148
+ // This must be called before the lockfile conversion check below since it sets properties as part of `commit()`
1148
1149
  const json = this.toString(options)
1149
1150
  if (
1150
1151
  !this.hiddenLockfile
@@ -1155,6 +1156,7 @@ class Shrinkwrap {
1155
1156
  `Converting lock file (${relative(process.cwd(), this.filename)}) from v${this.originalLockfileVersion} -> v${this.lockfileVersion}`
1156
1157
  )
1157
1158
  }
1159
+
1158
1160
  return Promise.all([
1159
1161
  writeFile(this.filename, json).catch(er => {
1160
1162
  if (this.hiddenLockfile) {
package/lib/tracker.js CHANGED
@@ -1,12 +1,12 @@
1
- const npmlog = require('npmlog')
1
+ const proggy = require('proggy')
2
2
 
3
3
  module.exports = cls => class Tracker extends cls {
4
4
  #progress = new Map()
5
- #setProgress
6
5
 
7
- constructor (options = {}) {
8
- super(options)
9
- this.#setProgress = !!options.progress
6
+ #createTracker (key, name) {
7
+ const tracker = new proggy.Tracker(name ?? key)
8
+ tracker.on('done', () => this.#progress.delete(key))
9
+ this.#progress.set(key, tracker)
10
10
  }
11
11
 
12
12
  addTracker (section, subsection = null, key = null) {
@@ -26,22 +26,17 @@ module.exports = cls => class Tracker extends cls {
26
26
  this.#onError(`Tracker "${section}" already exists`)
27
27
  } else if (!hasTracker && subsection === null) {
28
28
  // 1. no existing tracker, no subsection
29
- // Create a new tracker from npmlog
30
- // starts progress bar
31
- if (this.#setProgress && this.#progress.size === 0) {
32
- npmlog.enableProgress()
33
- }
34
-
35
- this.#progress.set(section, npmlog.newGroup(section))
29
+ // Create a new progress tracker
30
+ this.#createTracker(section)
36
31
  } else if (!hasTracker && subsection !== null) {
37
32
  // 2. no parent tracker and subsection
38
33
  this.#onError(`Parent tracker "${section}" does not exist`)
39
34
  } else if (!hasTracker || !hasSubtracker) {
40
35
  // 3. existing parent tracker, no subsection tracker
41
- // Create a new subtracker in this.#progress from parent tracker
42
- this.#progress.set(`${section}:${key}`,
43
- this.#progress.get(section).newGroup(`${section}:${subsection}`)
44
- )
36
+ // Create a new subtracker and update parents
37
+ const parentTracker = this.#progress.get(section)
38
+ parentTracker.update(parentTracker.value, parentTracker.total + 1)
39
+ this.#createTracker(`${section}:${key}`, `${section}:${subsection}`)
45
40
  }
46
41
  // 4. existing parent tracker, existing subsection tracker
47
42
  // skip it
@@ -70,32 +65,22 @@ module.exports = cls => class Tracker extends cls {
70
65
  this.finishTracker(section, key)
71
66
  }
72
67
  }
73
-
74
68
  // remove parent tracker
75
69
  this.#progress.get(section).finish()
76
- this.#progress.delete(section)
77
-
78
- // remove progress bar if all
79
- // trackers are finished
80
- if (this.#setProgress && this.#progress.size === 0) {
81
- npmlog.disableProgress()
82
- }
83
70
  } else if (!hasTracker && subsection === null) {
84
71
  // 1. no existing parent tracker, no subsection
85
72
  this.#onError(`Tracker "${section}" does not exist`)
86
73
  } else if (!hasTracker || hasSubtracker) {
87
74
  // 2. subtracker exists
88
75
  // Finish subtracker and remove from this.#progress
76
+ const parentTracker = this.#progress.get(section)
77
+ parentTracker.update(parentTracker.value + 1)
89
78
  this.#progress.get(`${section}:${key}`).finish()
90
- this.#progress.delete(`${section}:${key}`)
91
79
  }
92
80
  // 3. existing parent tracker, no subsection
93
81
  }
94
82
 
95
83
  #onError (msg) {
96
- if (this.#setProgress) {
97
- npmlog.disableProgress()
98
- }
99
84
  throw new Error(msg)
100
85
  }
101
86
  }
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@npmcli/arborist",
3
- "version": "7.4.2",
3
+ "version": "7.5.1",
4
4
  "description": "Manage node_modules trees",
5
5
  "dependencies": {
6
6
  "@isaacs/string-locale-compare": "^1.1.0",
7
7
  "@npmcli/fs": "^3.1.0",
8
- "@npmcli/installed-package-contents": "^2.0.2",
8
+ "@npmcli/installed-package-contents": "^2.1.0",
9
9
  "@npmcli/map-workspaces": "^3.0.2",
10
- "@npmcli/metavuln-calculator": "^7.0.0",
10
+ "@npmcli/metavuln-calculator": "^7.1.0",
11
11
  "@npmcli/name-from-folder": "^2.0.0",
12
12
  "@npmcli/node-gyp": "^3.0.0",
13
- "@npmcli/package-json": "^5.0.0",
13
+ "@npmcli/package-json": "^5.1.0",
14
14
  "@npmcli/query": "^3.1.0",
15
- "@npmcli/redact": "^1.1.0",
16
- "@npmcli/run-script": "^7.0.2",
15
+ "@npmcli/redact": "^2.0.0",
16
+ "@npmcli/run-script": "^8.1.0",
17
17
  "bin-links": "^4.0.1",
18
18
  "cacache": "^18.0.0",
19
19
  "common-ancestor-path": "^1.0.1",
@@ -23,13 +23,13 @@
23
23
  "minimatch": "^9.0.4",
24
24
  "nopt": "^7.0.0",
25
25
  "npm-install-checks": "^6.2.0",
26
- "npm-package-arg": "^11.0.1",
26
+ "npm-package-arg": "^11.0.2",
27
27
  "npm-pick-manifest": "^9.0.0",
28
- "npm-registry-fetch": "^16.2.0",
29
- "npmlog": "^7.0.1",
30
- "pacote": "^17.0.4",
28
+ "npm-registry-fetch": "^17.0.0",
29
+ "pacote": "^18.0.1",
31
30
  "parse-conflict-json": "^3.0.0",
32
- "proc-log": "^3.0.0",
31
+ "proc-log": "^4.2.0",
32
+ "proggy": "^2.0.0",
33
33
  "promise-all-reject-late": "^1.0.0",
34
34
  "promise-call-limit": "^3.0.1",
35
35
  "read-package-json-fast": "^3.0.2",
@@ -62,7 +62,7 @@
62
62
  },
63
63
  "repository": {
64
64
  "type": "git",
65
- "url": "https://github.com/npm/cli.git",
65
+ "url": "git+https://github.com/npm/cli.git",
66
66
  "directory": "workspaces/arborist"
67
67
  },
68
68
  "author": "GitHub Inc.",