@npmcli/arborist 2.2.7 → 2.2.8
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/arborist/build-ideal-tree.js +15 -1
- package/lib/printable.js +14 -3
- package/lib/shrinkwrap.js +14 -4
- package/package.json +1 -1
|
@@ -883,6 +883,8 @@ This is a one-time fix-up, please be patient...
|
|
|
883
883
|
// create a virtual root node with the same deps as the node that
|
|
884
884
|
// is requesting this one, so that we can get all the peer deps in
|
|
885
885
|
// a context where they're likely to be resolvable.
|
|
886
|
+
// Note that the virtual root will also have virtual copies of the
|
|
887
|
+
// targets of any child Links, so that they resolve appropriately.
|
|
886
888
|
const parent = parent_ || this[_virtualRoot](edge.from)
|
|
887
889
|
const realParent = edge.peer ? edge.from.resolveParent : edge.from
|
|
888
890
|
|
|
@@ -936,11 +938,23 @@ This is a one-time fix-up, please be patient...
|
|
|
936
938
|
return this[_virtualRoots].get(node)
|
|
937
939
|
|
|
938
940
|
const vr = new Node({
|
|
939
|
-
path:
|
|
941
|
+
path: node.realpath,
|
|
940
942
|
sourceReference: node,
|
|
941
943
|
legacyPeerDeps: this.legacyPeerDeps,
|
|
942
944
|
})
|
|
943
945
|
|
|
946
|
+
// also need to set up any targets from any link deps, so that
|
|
947
|
+
// they are properly reflected in the virtual environment
|
|
948
|
+
for (const child of node.children.values()) {
|
|
949
|
+
if (child.isLink) {
|
|
950
|
+
new Node({
|
|
951
|
+
path: child.realpath,
|
|
952
|
+
sourceReference: child.target,
|
|
953
|
+
root: vr,
|
|
954
|
+
})
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
|
|
944
958
|
this[_virtualRoots].set(node, vr)
|
|
945
959
|
return vr
|
|
946
960
|
}
|
package/lib/printable.js
CHANGED
|
@@ -63,6 +63,13 @@ class ArboristNode {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
class ArboristVirtualNode extends ArboristNode {
|
|
67
|
+
constructor (tree, path) {
|
|
68
|
+
super(tree, path)
|
|
69
|
+
this.sourceReference = printableTree(tree.sourceReference, path)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
66
73
|
class ArboristLink extends ArboristNode {
|
|
67
74
|
constructor (tree, path) {
|
|
68
75
|
super(tree, path)
|
|
@@ -119,10 +126,14 @@ class EdgeIn extends Edge {
|
|
|
119
126
|
}
|
|
120
127
|
|
|
121
128
|
const printableTree = (tree, path = []) => {
|
|
122
|
-
|
|
123
|
-
|
|
129
|
+
const Cls = tree.isLink ? ArboristLink
|
|
130
|
+
: tree.sourceReference ? ArboristVirtualNode
|
|
131
|
+
: ArboristNode
|
|
132
|
+
if (path.includes(tree)) {
|
|
133
|
+
const obj = Object.create(Cls.prototype)
|
|
134
|
+
return Object.assign(obj, { location: tree.location })
|
|
135
|
+
}
|
|
124
136
|
path.push(tree)
|
|
125
|
-
const Cls = tree.isLink ? ArboristLink : ArboristNode
|
|
126
137
|
return new Cls(tree, path)
|
|
127
138
|
}
|
|
128
139
|
|
package/lib/shrinkwrap.js
CHANGED
|
@@ -41,6 +41,7 @@ const readFile = promisify(fs.readFile)
|
|
|
41
41
|
const writeFile = promisify(fs.writeFile)
|
|
42
42
|
const stat = promisify(fs.stat)
|
|
43
43
|
const readdir_ = promisify(fs.readdir)
|
|
44
|
+
const readlink = promisify(fs.readlink)
|
|
44
45
|
|
|
45
46
|
// XXX remove when drop support for node v10
|
|
46
47
|
const lstat = promisify(fs.lstat)
|
|
@@ -176,10 +177,19 @@ const assertNoNewer = async (path, data, lockTime, dir = path, seen = null) => {
|
|
|
176
177
|
: readdir(parent, { withFileTypes: true })
|
|
177
178
|
|
|
178
179
|
return children.catch(() => [])
|
|
179
|
-
.then(ents => Promise.all(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
.then(ents => Promise.all(ents.map(async ent => {
|
|
181
|
+
const child = resolve(parent, ent.name)
|
|
182
|
+
if (ent.isDirectory() && !/^\./.test(ent.name))
|
|
183
|
+
await assertNoNewer(path, data, lockTime, child, seen)
|
|
184
|
+
else if (ent.isSymbolicLink()) {
|
|
185
|
+
const target = resolve(parent, await readlink(child))
|
|
186
|
+
const tstat = await stat(target).catch(() => null)
|
|
187
|
+
seen.add(relpath(path, child))
|
|
188
|
+
if (tstat && tstat.isDirectory() && !seen.has(relpath(path, target)))
|
|
189
|
+
await assertNoNewer(path, data, lockTime, target, seen)
|
|
190
|
+
}
|
|
191
|
+
})))
|
|
192
|
+
.then(() => {
|
|
183
193
|
if (dir !== path)
|
|
184
194
|
return
|
|
185
195
|
|