@npmcli/arborist 2.7.1 → 2.8.3

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.
Files changed (50) hide show
  1. package/bin/actual.js +4 -2
  2. package/bin/audit.js +12 -6
  3. package/bin/dedupe.js +49 -0
  4. package/bin/funding.js +4 -2
  5. package/bin/ideal.js +2 -1
  6. package/bin/lib/logging.js +4 -3
  7. package/bin/lib/options.js +14 -12
  8. package/bin/lib/timers.js +6 -3
  9. package/bin/license.js +9 -5
  10. package/bin/prune.js +6 -3
  11. package/bin/reify.js +6 -3
  12. package/bin/virtual.js +4 -2
  13. package/lib/add-rm-pkg-deps.js +25 -14
  14. package/lib/arborist/audit.js +2 -1
  15. package/lib/arborist/build-ideal-tree.js +246 -757
  16. package/lib/arborist/deduper.js +2 -1
  17. package/lib/arborist/index.js +8 -4
  18. package/lib/arborist/load-actual.js +32 -15
  19. package/lib/arborist/load-virtual.js +34 -18
  20. package/lib/arborist/load-workspaces.js +4 -2
  21. package/lib/arborist/rebuild.js +31 -16
  22. package/lib/arborist/reify.js +332 -119
  23. package/lib/audit-report.js +42 -22
  24. package/lib/calc-dep-flags.js +18 -9
  25. package/lib/can-place-dep.js +430 -0
  26. package/lib/case-insensitive-map.js +50 -0
  27. package/lib/consistent-resolve.js +2 -1
  28. package/lib/deepest-nesting-target.js +18 -0
  29. package/lib/dep-valid.js +8 -4
  30. package/lib/diff.js +74 -22
  31. package/lib/edge.js +29 -14
  32. package/lib/gather-dep-set.js +2 -1
  33. package/lib/inventory.js +12 -6
  34. package/lib/link.js +14 -9
  35. package/lib/node.js +269 -118
  36. package/lib/optional-set.js +4 -2
  37. package/lib/peer-entry-sets.js +77 -0
  38. package/lib/place-dep.js +578 -0
  39. package/lib/printable.js +48 -18
  40. package/lib/realpath.js +12 -6
  41. package/lib/shrinkwrap.js +168 -91
  42. package/lib/signal-handling.js +6 -3
  43. package/lib/spec-from-lock.js +7 -4
  44. package/lib/tracker.js +24 -18
  45. package/lib/tree-check.js +12 -6
  46. package/lib/version-from-tgz.js +4 -2
  47. package/lib/vuln.js +28 -16
  48. package/lib/yarn-lock.js +27 -15
  49. package/package.json +9 -13
  50. package/lib/peer-set.js +0 -25
package/lib/printable.js CHANGED
@@ -7,41 +7,62 @@ const relpath = require('./relpath.js')
7
7
  class ArboristNode {
8
8
  constructor (tree, path) {
9
9
  this.name = tree.name
10
- if (tree.packageName && tree.packageName !== this.name)
10
+ if (tree.packageName && tree.packageName !== this.name) {
11
11
  this.packageName = tree.packageName
12
- if (tree.version)
12
+ }
13
+ if (tree.version) {
13
14
  this.version = tree.version
15
+ }
14
16
  this.location = tree.location
15
17
  this.path = tree.path
16
- if (tree.realpath !== this.path)
18
+ if (tree.realpath !== this.path) {
17
19
  this.realpath = tree.realpath
18
- if (tree.resolved !== null)
20
+ }
21
+ if (tree.resolved !== null) {
19
22
  this.resolved = tree.resolved
20
- if (tree.extraneous)
23
+ }
24
+ if (tree.extraneous) {
21
25
  this.extraneous = true
22
- if (tree.dev)
26
+ }
27
+ if (tree.dev) {
23
28
  this.dev = true
24
- if (tree.optional)
29
+ }
30
+ if (tree.optional) {
25
31
  this.optional = true
26
- if (tree.devOptional && !tree.dev && !tree.optional)
32
+ }
33
+ if (tree.devOptional && !tree.dev && !tree.optional) {
27
34
  this.devOptional = true
28
- if (tree.peer)
35
+ }
36
+ if (tree.peer) {
29
37
  this.peer = true
30
- if (tree.inBundle)
38
+ }
39
+ if (tree.inBundle) {
31
40
  this.bundled = true
32
- if (tree.inDepBundle)
41
+ }
42
+ if (tree.inDepBundle) {
33
43
  this.bundler = tree.getBundler().location
44
+ }
45
+ if (tree.isProjectRoot) {
46
+ this.isProjectRoot = true
47
+ }
48
+ if (tree.isWorkspace) {
49
+ this.isWorkspace = true
50
+ }
34
51
  const bd = tree.package && tree.package.bundleDependencies
35
- if (bd && bd.length)
52
+ if (bd && bd.length) {
36
53
  this.bundleDependencies = bd
37
- if (tree.inShrinkwrap)
54
+ }
55
+ if (tree.inShrinkwrap) {
38
56
  this.inShrinkwrap = true
39
- else if (tree.hasShrinkwrap)
57
+ } else if (tree.hasShrinkwrap) {
40
58
  this.hasShrinkwrap = true
41
- if (tree.error)
59
+ }
60
+ if (tree.error) {
42
61
  this.error = treeError(tree.error)
43
- if (tree.errors && tree.errors.length)
62
+ }
63
+ if (tree.errors && tree.errors.length) {
44
64
  this.errors = tree.errors.map(treeError)
65
+ }
45
66
 
46
67
  // edgesOut sorted by name
47
68
  if (tree.edgesOut.size) {
@@ -105,8 +126,12 @@ class Edge {
105
126
  this.type = edge.type
106
127
  this.name = edge.name
107
128
  this.spec = edge.spec || '*'
108
- if (edge.error)
129
+ if (edge.error) {
109
130
  this.error = edge.error
131
+ }
132
+ if (edge.overridden) {
133
+ this.overridden = edge.overridden
134
+ }
110
135
  }
111
136
  }
112
137
 
@@ -122,6 +147,8 @@ class EdgeOut extends Edge {
122
147
  this.to ? ' -> ' + this.to : ''
123
148
  }${
124
149
  this.error ? ' ' + this.error : ''
150
+ }${
151
+ this.overridden ? ' overridden' : ''
125
152
  } }`
126
153
  }
127
154
  }
@@ -136,13 +163,16 @@ class EdgeIn extends Edge {
136
163
  [util.inspect.custom] () {
137
164
  return `{ ${this.from || '""'} ${this.type} ${this.name}@${this.spec}${
138
165
  this.error ? ' ' + this.error : ''
166
+ }${
167
+ this.overridden ? ' overridden' : ''
139
168
  } }`
140
169
  }
141
170
  }
142
171
 
143
172
  const printableTree = (tree, path = []) => {
144
- if (!tree)
173
+ if (!tree) {
145
174
  return tree
175
+ }
146
176
 
147
177
  const Cls = tree.isLink ? ArboristLink
148
178
  : tree.sourceReference ? ArboristVirtualNode
package/lib/realpath.js CHANGED
@@ -14,18 +14,21 @@ const { resolve, basename, dirname } = require('path')
14
14
  const realpathCached = (path, rpcache, stcache, depth) => {
15
15
  // just a safety against extremely deep eloops
16
16
  /* istanbul ignore next */
17
- if (depth > 2000)
17
+ if (depth > 2000) {
18
18
  throw eloop(path)
19
+ }
19
20
 
20
21
  path = resolve(path)
21
- if (rpcache.has(path))
22
+ if (rpcache.has(path)) {
22
23
  return Promise.resolve(rpcache.get(path))
24
+ }
23
25
 
24
26
  const dir = dirname(path)
25
27
  const base = basename(path)
26
28
 
27
- if (base && rpcache.has(dir))
29
+ if (base && rpcache.has(dir)) {
28
30
  return realpathChild(dir, base, rpcache, stcache, depth)
31
+ }
29
32
 
30
33
  // if it's the root, then we know it's real
31
34
  if (!base) {
@@ -40,8 +43,9 @@ const realpathCached = (path, rpcache, stcache, depth) => {
40
43
  }
41
44
 
42
45
  const lstatCached = (path, stcache) => {
43
- if (stcache.has(path))
46
+ if (stcache.has(path)) {
44
47
  return Promise.resolve(stcache.get(path))
48
+ }
45
49
 
46
50
  const p = lstat(path).then(st => {
47
51
  stcache.set(path, st)
@@ -66,8 +70,9 @@ const realpathChild = (dir, base, rpcache, stcache, depth) => {
66
70
  const realdir = rpcache.get(dir)
67
71
  // that unpossible
68
72
  /* istanbul ignore next */
69
- if (typeof realdir === 'undefined')
73
+ if (typeof realdir === 'undefined') {
70
74
  throw new Error('in realpathChild without parent being in realpath cache')
75
+ }
71
76
 
72
77
  const realish = resolve(realdir, base)
73
78
  return lstatCached(realish, stcache).then(st => {
@@ -78,8 +83,9 @@ const realpathChild = (dir, base, rpcache, stcache, depth) => {
78
83
 
79
84
  return readlink(realish).then(target => {
80
85
  const resolved = resolve(realdir, target)
81
- if (realish === resolved)
86
+ if (realish === resolved) {
82
87
  throw eloop(realish)
88
+ }
83
89
 
84
90
  return realpathCached(resolved, rpcache, stcache, depth + 1)
85
91
  }).then(real => {