@npmcli/arborist 7.5.0 → 7.5.2

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.
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/node.js CHANGED
@@ -119,6 +119,8 @@ class Node {
119
119
  // package's dependencies in a virtual root.
120
120
  this.sourceReference = sourceReference
121
121
 
122
+ // TODO if this came from pacote.manifest we don't have to do this,
123
+ // we can be told to skip this step
122
124
  const pkg = sourceReference ? sourceReference.package
123
125
  : normalize(options.pkg || {})
124
126
 
@@ -0,0 +1,77 @@
1
+ const { LRUCache } = require('lru-cache')
2
+ const { getHeapStatistics } = require('node:v8')
3
+ const { log } = require('proc-log')
4
+
5
+ // This is an in-memory cache that Pacote uses for packuments.
6
+ // Packuments are usually cached on disk. This allows for rapid re-requests
7
+ // of the same packument to bypass disk reads. The tradeoff here is memory
8
+ // usage for disk reads.
9
+ class PackumentCache extends LRUCache {
10
+ static #heapLimit = Math.floor(getHeapStatistics().heap_size_limit)
11
+
12
+ #sizeKey
13
+ #disposed = new Set()
14
+
15
+ #log (...args) {
16
+ log.silly('packumentCache', ...args)
17
+ }
18
+
19
+ constructor ({
20
+ // How much of this.#heapLimit to take up
21
+ heapFactor = 0.25,
22
+ // How much of this.#maxSize we allow any one packument to take up
23
+ // Anything over this is not cached
24
+ maxEntryFactor = 0.5,
25
+ sizeKey = '_contentLength',
26
+ } = {}) {
27
+ const maxSize = Math.floor(PackumentCache.#heapLimit * heapFactor)
28
+ const maxEntrySize = Math.floor(maxSize * maxEntryFactor)
29
+ super({
30
+ maxSize,
31
+ maxEntrySize,
32
+ sizeCalculation: (p) => {
33
+ // Don't cache if we dont know the size
34
+ // Some versions of pacote set this to `0`, newer versions set it to `null`
35
+ if (!p[sizeKey]) {
36
+ return maxEntrySize + 1
37
+ }
38
+ if (p[sizeKey] < 10_000) {
39
+ return p[sizeKey] * 2
40
+ }
41
+ if (p[sizeKey] < 1_000_000) {
42
+ return Math.floor(p[sizeKey] * 1.5)
43
+ }
44
+ // It is less beneficial to store a small amount of super large things
45
+ // at the cost of all other packuments.
46
+ return maxEntrySize + 1
47
+ },
48
+ dispose: (v, k) => {
49
+ this.#disposed.add(k)
50
+ this.#log(k, 'dispose')
51
+ },
52
+ })
53
+ this.#sizeKey = sizeKey
54
+ this.#log(`heap:${PackumentCache.#heapLimit} maxSize:${maxSize} maxEntrySize:${maxEntrySize}`)
55
+ }
56
+
57
+ set (k, v, ...args) {
58
+ // we use disposed only for a logging signal if we are setting packuments that
59
+ // have already been evicted from the cache previously. logging here could help
60
+ // us tune this in the future.
61
+ const disposed = this.#disposed.has(k)
62
+ /* istanbul ignore next - this doesnt happen consistently so hard to test without resorting to unit tests */
63
+ if (disposed) {
64
+ this.#disposed.delete(k)
65
+ }
66
+ this.#log(k, 'set', `size:${v[this.#sizeKey]} disposed:${disposed}`)
67
+ return super.set(k, v, ...args)
68
+ }
69
+
70
+ has (k, ...args) {
71
+ const has = super.has(k, ...args)
72
+ this.#log(k, `cache-${has ? 'hit' : 'miss'}`)
73
+ return has
74
+ }
75
+ }
76
+
77
+ module.exports = PackumentCache
@@ -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
@@ -1153,7 +1153,8 @@ class Shrinkwrap {
1153
1153
  && this.originalLockfileVersion !== this.lockfileVersion
1154
1154
  ) {
1155
1155
  log.warn(
1156
- `Converting lock file (${relative(process.cwd(), this.filename)}) from v${this.originalLockfileVersion} -> v${this.lockfileVersion}`
1156
+ 'shrinkwrap',
1157
+ `Converting lock file (${relative(process.cwd(), this.filename)}) from v${this.originalLockfileVersion} -> v${this.lockfileVersion}`
1157
1158
  )
1158
1159
  }
1159
1160
 
package/package.json CHANGED
@@ -1,32 +1,33 @@
1
1
  {
2
2
  "name": "@npmcli/arborist",
3
- "version": "7.5.0",
3
+ "version": "7.5.2",
4
4
  "description": "Manage node_modules trees",
5
5
  "dependencies": {
6
6
  "@isaacs/string-locale-compare": "^1.1.0",
7
- "@npmcli/fs": "^3.1.0",
7
+ "@npmcli/fs": "^3.1.1",
8
8
  "@npmcli/installed-package-contents": "^2.1.0",
9
9
  "@npmcli/map-workspaces": "^3.0.2",
10
- "@npmcli/metavuln-calculator": "^7.1.0",
10
+ "@npmcli/metavuln-calculator": "^7.1.1",
11
11
  "@npmcli/name-from-folder": "^2.0.0",
12
12
  "@npmcli/node-gyp": "^3.0.0",
13
13
  "@npmcli/package-json": "^5.1.0",
14
14
  "@npmcli/query": "^3.1.0",
15
- "@npmcli/redact": "^1.1.0",
16
- "@npmcli/run-script": "^8.0.0",
17
- "bin-links": "^4.0.1",
18
- "cacache": "^18.0.0",
15
+ "@npmcli/redact": "^2.0.0",
16
+ "@npmcli/run-script": "^8.1.0",
17
+ "bin-links": "^4.0.4",
18
+ "cacache": "^18.0.3",
19
19
  "common-ancestor-path": "^1.0.1",
20
- "hosted-git-info": "^7.0.1",
21
- "json-parse-even-better-errors": "^3.0.0",
20
+ "hosted-git-info": "^7.0.2",
21
+ "json-parse-even-better-errors": "^3.0.2",
22
22
  "json-stringify-nice": "^1.1.4",
23
+ "lru-cache": "^10.2.2",
23
24
  "minimatch": "^9.0.4",
24
- "nopt": "^7.0.0",
25
+ "nopt": "^7.2.1",
25
26
  "npm-install-checks": "^6.2.0",
26
27
  "npm-package-arg": "^11.0.2",
27
- "npm-pick-manifest": "^9.0.0",
28
- "npm-registry-fetch": "^16.2.1",
29
- "pacote": "^18.0.1",
28
+ "npm-pick-manifest": "^9.0.1",
29
+ "npm-registry-fetch": "^17.0.1",
30
+ "pacote": "^18.0.6",
30
31
  "parse-conflict-json": "^3.0.0",
31
32
  "proc-log": "^4.2.0",
32
33
  "proggy": "^2.0.0",
@@ -34,13 +35,13 @@
34
35
  "promise-call-limit": "^3.0.1",
35
36
  "read-package-json-fast": "^3.0.2",
36
37
  "semver": "^7.3.7",
37
- "ssri": "^10.0.5",
38
+ "ssri": "^10.0.6",
38
39
  "treeverse": "^3.0.0",
39
40
  "walk-up-path": "^3.0.1"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@npmcli/eslint-config": "^4.0.0",
43
- "@npmcli/template-oss": "4.21.3",
44
+ "@npmcli/template-oss": "4.22.0",
44
45
  "benchmark": "^2.1.4",
45
46
  "minify-registry-metadata": "^3.0.0",
46
47
  "nock": "^13.3.3",
@@ -62,7 +63,7 @@
62
63
  },
63
64
  "repository": {
64
65
  "type": "git",
65
- "url": "https://github.com/npm/cli.git",
66
+ "url": "git+https://github.com/npm/cli.git",
66
67
  "directory": "workspaces/arborist"
67
68
  },
68
69
  "author": "GitHub Inc.",
@@ -91,7 +92,7 @@
91
92
  },
92
93
  "templateOSS": {
93
94
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
94
- "version": "4.21.3",
95
+ "version": "4.22.0",
95
96
  "content": "../../scripts/template-oss/index.js"
96
97
  }
97
98
  }