@npmcli/arborist 8.0.0 → 9.0.0-pre.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.
@@ -154,7 +154,9 @@ module.exports = cls => class Builder extends cls {
154
154
 
155
155
  // links should run prepare scripts and only link bins after that
156
156
  if (type === 'links') {
157
- await this.#runScripts('prepare')
157
+ if (!this.options.ignoreScripts) {
158
+ await this.#runScripts('prepare')
159
+ }
158
160
  }
159
161
  if (this.options.binLinks) {
160
162
  await this.#linkAllBins()
@@ -15,7 +15,7 @@ const _init = Symbol('init')
15
15
  const _omit = Symbol('omit')
16
16
  const { log, time } = require('proc-log')
17
17
 
18
- const fetch = require('npm-registry-fetch')
18
+ const npmFetch = require('npm-registry-fetch')
19
19
 
20
20
  class AuditReport extends Map {
21
21
  static load (tree, opts) {
@@ -274,33 +274,6 @@ class AuditReport extends Map {
274
274
  throw new Error('do not call AuditReport.set() directly')
275
275
  }
276
276
 
277
- // convert a quick-audit into a bulk advisory listing
278
- static auditToBulk (report) {
279
- if (!report.advisories) {
280
- // tack on the report json where the response body would go
281
- throw Object.assign(new Error('Invalid advisory report'), {
282
- body: JSON.stringify(report),
283
- })
284
- }
285
-
286
- const bulk = {}
287
- const { advisories } = report
288
- for (const advisory of Object.values(advisories)) {
289
- const {
290
- id,
291
- url,
292
- title,
293
- severity = 'high',
294
- vulnerable_versions = '*',
295
- module_name: name,
296
- } = advisory
297
- bulk[name] = bulk[name] || []
298
- bulk[name].push({ id, url, title, severity, vulnerable_versions })
299
- }
300
-
301
- return bulk
302
- }
303
-
304
277
  async [_getReport] () {
305
278
  // if we're not auditing, just return false
306
279
  if (this.options.audit === false || this.options.offline === true || this.tree.inventory.size === 1) {
@@ -309,39 +282,24 @@ class AuditReport extends Map {
309
282
 
310
283
  const timeEnd = time.start('auditReport:getReport')
311
284
  try {
312
- try {
313
- // first try the super fast bulk advisory listing
314
- const body = prepareBulkData(this.tree, this[_omit], this.filterSet)
315
- log.silly('audit', 'bulk request', body)
316
-
317
- // no sense asking if we don't have anything to audit,
318
- // we know it'll be empty
319
- if (!Object.keys(body).length) {
320
- return null
321
- }
285
+ const body = prepareBulkData(this.tree, this[_omit], this.filterSet)
286
+ log.silly('audit', 'bulk request', body)
322
287
 
323
- const res = await fetch('/-/npm/v1/security/advisories/bulk', {
324
- ...this.options,
325
- registry: this.options.auditRegistry || this.options.registry,
326
- method: 'POST',
327
- gzip: true,
328
- body,
329
- })
330
-
331
- return await res.json()
332
- } catch (er) {
333
- log.silly('audit', 'bulk request failed', String(er.body))
334
- // that failed, try the quick audit endpoint
335
- const body = prepareData(this.tree, this.options)
336
- const res = await fetch('/-/npm/v1/security/audits/quick', {
337
- ...this.options,
338
- registry: this.options.auditRegistry || this.options.registry,
339
- method: 'POST',
340
- gzip: true,
341
- body,
342
- })
343
- return AuditReport.auditToBulk(await res.json())
288
+ // no sense asking if we don't have anything to audit,
289
+ // we know it'll be empty
290
+ if (!Object.keys(body).length) {
291
+ return null
344
292
  }
293
+
294
+ const res = await npmFetch('/-/npm/v1/security/advisories/bulk', {
295
+ ...this.options,
296
+ registry: this.options.auditRegistry || this.options.registry,
297
+ method: 'POST',
298
+ gzip: true,
299
+ body,
300
+ })
301
+
302
+ return await res.json()
345
303
  } catch (er) {
346
304
  log.verbose('audit error', er)
347
305
  log.silly('audit error', String(er.body))
@@ -384,32 +342,4 @@ const prepareBulkData = (tree, omit, filterSet) => {
384
342
  return payload
385
343
  }
386
344
 
387
- const prepareData = (tree, opts) => {
388
- const { npmVersion: npm_version } = opts
389
- const node_version = process.version
390
- const { platform, arch } = process
391
- const { NODE_ENV: node_env } = process.env
392
- const data = tree.meta.commit()
393
- // the legacy audit endpoint doesn't support any kind of pre-filtering
394
- // we just have to get the advisories and skip over them in the report
395
- return {
396
- name: data.name,
397
- version: data.version,
398
- requires: {
399
- ...(tree.package.devDependencies || {}),
400
- ...(tree.package.peerDependencies || {}),
401
- ...(tree.package.optionalDependencies || {}),
402
- ...(tree.package.dependencies || {}),
403
- },
404
- dependencies: data.dependencies,
405
- metadata: {
406
- node_version,
407
- npm_version,
408
- platform,
409
- arch,
410
- node_env,
411
- },
412
- }
413
- }
414
-
415
345
  module.exports = AuditReport
@@ -8,7 +8,7 @@ const { minimatch } = require('minimatch')
8
8
  const npa = require('npm-package-arg')
9
9
  const pacote = require('pacote')
10
10
  const semver = require('semver')
11
- const fetch = require('npm-registry-fetch')
11
+ const npmFetch = require('npm-registry-fetch')
12
12
 
13
13
  // handle results for parsed query asts, results are stored in a map that has a
14
14
  // key that points to each ast selector node and stores the resulting array of
@@ -461,7 +461,7 @@ class Results {
461
461
  packages[node.name].push(node.version)
462
462
  }
463
463
  })
464
- const res = await fetch('/-/npm/v1/security/advisories/bulk', {
464
+ const res = await npmFetch('/-/npm/v1/security/advisories/bulk', {
465
465
  ...this.flatOptions,
466
466
  registry: this.flatOptions.auditRegistry || this.flatOptions.registry,
467
467
  method: 'POST',
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@npmcli/arborist",
3
- "version": "8.0.0",
3
+ "version": "9.0.0-pre.1",
4
4
  "description": "Manage node_modules trees",
5
5
  "dependencies": {
6
6
  "@isaacs/string-locale-compare": "^1.1.0",
7
7
  "@npmcli/fs": "^4.0.0",
8
8
  "@npmcli/installed-package-contents": "^3.0.0",
9
9
  "@npmcli/map-workspaces": "^4.0.1",
10
- "@npmcli/metavuln-calculator": "^8.0.0",
10
+ "@npmcli/metavuln-calculator": "^9.0.0",
11
11
  "@npmcli/name-from-folder": "^3.0.0",
12
12
  "@npmcli/node-gyp": "^4.0.0",
13
13
  "@npmcli/package-json": "^6.0.1",
@@ -18,7 +18,6 @@
18
18
  "cacache": "^19.0.1",
19
19
  "common-ancestor-path": "^1.0.1",
20
20
  "hosted-git-info": "^8.0.0",
21
- "json-parse-even-better-errors": "^4.0.0",
22
21
  "json-stringify-nice": "^1.1.4",
23
22
  "lru-cache": "^10.2.2",
24
23
  "minimatch": "^9.0.4",
@@ -27,7 +26,7 @@
27
26
  "npm-package-arg": "^12.0.0",
28
27
  "npm-pick-manifest": "^10.0.0",
29
28
  "npm-registry-fetch": "^18.0.1",
30
- "pacote": "^19.0.0",
29
+ "pacote": "^21.0.0",
31
30
  "parse-conflict-json": "^4.0.0",
32
31
  "proc-log": "^5.0.0",
33
32
  "proggy": "^3.0.0",
@@ -37,11 +36,12 @@
37
36
  "semver": "^7.3.7",
38
37
  "ssri": "^12.0.0",
39
38
  "treeverse": "^3.0.0",
40
- "walk-up-path": "^3.0.1"
39
+ "walk-up-path": "^4.0.0"
41
40
  },
42
41
  "devDependencies": {
43
42
  "@npmcli/eslint-config": "^5.0.1",
44
- "@npmcli/template-oss": "4.23.3",
43
+ "@npmcli/mock-registry": "^1.0.0",
44
+ "@npmcli/template-oss": "4.23.5",
45
45
  "benchmark": "^2.1.4",
46
46
  "minify-registry-metadata": "^4.0.0",
47
47
  "nock": "^13.3.3",
@@ -82,18 +82,18 @@
82
82
  "test-env": [
83
83
  "LC_ALL=sk"
84
84
  ],
85
- "timeout": "360",
85
+ "timeout": "720",
86
86
  "nyc-arg": [
87
87
  "--exclude",
88
88
  "tap-snapshots/**"
89
89
  ]
90
90
  },
91
91
  "engines": {
92
- "node": "^18.17.0 || >=20.5.0"
92
+ "node": "^20.17.0 || >=22.9.0"
93
93
  },
94
94
  "templateOSS": {
95
95
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
96
- "version": "4.23.3",
96
+ "version": "4.23.5",
97
97
  "content": "../../scripts/template-oss/index.js"
98
98
  }
99
99
  }