+1939
-39
lines changedFilter options
+1939
-39
lines changed Original file line number Diff line number Diff line change
@@ -809,7 +809,8 @@ This is a one-time fix-up, please be patient...
809
809
const crackOpen = this.#complete &&
810
810
node !== this.idealTree &&
811
811
node.resolved &&
812
-
(hasBundle || hasShrinkwrap)
812
+
(hasBundle || hasShrinkwrap) &&
813
+
!node.ideallyInert
813
814
if (crackOpen) {
814
815
const Arborist = this.constructor
815
816
const opt = { ...this.options }
@@ -1527,7 +1528,7 @@ This is a one-time fix-up, please be patient...
1527
1528
1528
1529
const set = optionalSet(node)
1529
1530
for (const node of set) {
1530
-
node.parent = null
1531
+
node.ideallyInert = true
1531
1532
}
1532
1533
}
1533
1534
}
@@ -1548,6 +1549,7 @@ This is a one-time fix-up, please be patient...
1548
1549
node.parent !== null
1549
1550
&& !node.isProjectRoot
1550
1551
&& !excludeNodes.has(node)
1552
+
&& !node.ideallyInert
1551
1553
) {
1552
1554
this[_addNodeToTrashList](node)
1553
1555
}
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ module.exports = cls => class IsolatedReifier extends cls {
81
81
}
82
82
queue.push(e.to)
83
83
})
84
-
if (!next.isProjectRoot && !next.isWorkspace) {
84
+
if (!next.isProjectRoot && !next.isWorkspace && !next.ideallyInert) {
85
85
root.external.push(await this.externalProxyMemo(next))
86
86
}
87
87
}
@@ -147,8 +147,8 @@ module.exports = cls => class IsolatedReifier extends cls {
147
147
const nonOptionalDeps = edges.filter(e => !e.optional).map(e => e.to.target)
148
148
149
149
result.localDependencies = await Promise.all(nonOptionalDeps.filter(n => n.isWorkspace).map(this.workspaceProxyMemo))
150
-
result.externalDependencies = await Promise.all(nonOptionalDeps.filter(n => !n.isWorkspace).map(this.externalProxyMemo))
151
-
result.externalOptionalDependencies = await Promise.all(optionalDeps.map(this.externalProxyMemo))
150
+
result.externalDependencies = await Promise.all(nonOptionalDeps.filter(n => !n.isWorkspace && !n.ideallyInert).map(this.externalProxyMemo))
151
+
result.externalOptionalDependencies = await Promise.all(optionalDeps.filter(n => !n.ideallyInert).map(this.externalProxyMemo))
152
152
result.dependencies = [
153
153
...result.externalDependencies,
154
154
...result.localDependencies,
Original file line number Diff line number Diff line change
@@ -267,6 +267,7 @@ module.exports = cls => class VirtualLoader extends cls {
267
267
integrity: sw.integrity,
268
268
resolved: consistentResolve(sw.resolved, this.path, path),
269
269
pkg: sw,
270
+
ideallyInert: sw.ideallyInert,
270
271
hasShrinkwrap: sw.hasShrinkwrap,
271
272
dev,
272
273
optional,
Original file line number Diff line number Diff line change
@@ -149,7 +149,7 @@ module.exports = cls => class Reifier extends cls {
149
149
for (const path of this[_trashList]) {
150
150
const loc = relpath(this.idealTree.realpath, path)
151
151
const node = this.idealTree.inventory.get(loc)
152
-
if (node && node.root === this.idealTree) {
152
+
if (node && node.root === this.idealTree && !node.ideallyInert) {
153
153
node.parent = null
154
154
}
155
155
}
@@ -237,6 +237,18 @@ module.exports = cls => class Reifier extends cls {
237
237
this.idealTree.meta.hiddenLockfile = true
238
238
this.idealTree.meta.lockfileVersion = defaultLockfileVersion
239
239
240
+
// Preserve inertness for failed stuff.
241
+
if (this.actualTree) {
242
+
for (const [loc, actual] of this.actualTree.inventory.entries()) {
243
+
if (actual.ideallyInert) {
244
+
const ideal = this.idealTree.inventory.get(loc)
245
+
if (ideal) {
246
+
ideal.ideallyInert = true
247
+
}
248
+
}
249
+
}
250
+
}
251
+
240
252
this.actualTree = this.idealTree
241
253
this.idealTree = null
242
254
@@ -599,6 +611,9 @@ module.exports = cls => class Reifier extends cls {
599
611
// retire the same path at the same time.
600
612
const dirsChecked = new Set()
601
613
return promiseAllRejectLate(leaves.map(async node => {
614
+
if (node.ideallyInert) {
615
+
return
616
+
}
602
617
for (const d of walkUp(node.path)) {
603
618
if (d === node.top.path) {
604
619
break
@@ -743,6 +758,10 @@ module.exports = cls => class Reifier extends cls {
743
758
}
744
759
745
760
async #extractOrLink (node) {
761
+
if (node.ideallyInert) {
762
+
return
763
+
}
764
+
746
765
const nm = resolve(node.parent.path, 'node_modules')
747
766
await this.#validateNodeModules(nm)
748
767
@@ -818,6 +837,7 @@ module.exports = cls => class Reifier extends cls {
818
837
const set = optionalSet(node)
819
838
for (node of set) {
820
839
log.verbose('reify', 'failed optional dependency', node.path)
840
+
node.ideallyInert = true
821
841
this[_addNodeToTrashList](node)
822
842
}
823
843
}) : p).then(() => node)
@@ -1152,6 +1172,9 @@ module.exports = cls => class Reifier extends cls {
1152
1172
1153
1173
this.#retiredUnchanged[retireFolder] = []
1154
1174
return promiseAllRejectLate(diff.unchanged.map(node => {
1175
+
if (node.ideallyInert) {
1176
+
return
1177
+
}
1155
1178
// no need to roll back links, since we'll just delete them anyway
1156
1179
if (node.isLink) {
1157
1180
return mkdir(dirname(node.path), { recursive: true, force: true })
@@ -1231,7 +1254,7 @@ module.exports = cls => class Reifier extends cls {
1231
1254
// skip links that only live within node_modules as they are most
1232
1255
// likely managed by packages we installed, we only want to rebuild
1233
1256
// unchanged links we directly manage
1234
-
const linkedFromRoot = node.parent === tree || node.target.fsTop === tree
1257
+
const linkedFromRoot = (node.parent === tree && !node.ideallyInert) || node.target.fsTop === tree
1235
1258
if (node.isLink && linkedFromRoot) {
1236
1259
nodes.push(node)
1237
1260
}
Original file line number Diff line number Diff line change
@@ -103,6 +103,7 @@ class Node {
103
103
global = false,
104
104
dummy = false,
105
105
sourceReference = null,
106
+
ideallyInert = false,
106
107
} = options
107
108
// this object gives querySelectorAll somewhere to stash context about a node
108
109
// while processing a query
@@ -197,6 +198,8 @@ class Node {
197
198
this.extraneous = false
198
199
}
199
200
201
+
this.ideallyInert = ideallyInert
202
+
200
203
this.edgesIn = new Set()
201
204
this.edgesOut = new CaseInsensitiveMap()
202
205
Original file line number Diff line number Diff line change
@@ -109,6 +109,7 @@ const nodeMetaKeys = [
109
109
'inBundle',
110
110
'hasShrinkwrap',
111
111
'hasInstallScript',
112
+
'ideallyInert',
112
113
]
113
114
114
115
const metaFieldFromPkg = (pkg, key) => {
@@ -135,6 +136,10 @@ const assertNoNewer = async (path, data, lockTime, dir, seen) => {
135
136
136
137
const parent = isParent ? dir : resolve(dir, 'node_modules')
137
138
const rel = relpath(path, dir)
139
+
const inert = data.packages[rel]?.ideallyInert
140
+
if (inert) {
141
+
return
142
+
}
138
143
seen.add(rel)
139
144
let entries
140
145
if (dir === path) {
@@ -173,7 +178,7 @@ const assertNoNewer = async (path, data, lockTime, dir, seen) => {
173
178
174
179
// assert that all the entries in the lockfile were seen
175
180
for (const loc in data.packages) {
176
-
if (!seen.has(loc)) {
181
+
if (!seen.has(loc) && !data.packages[loc].ideallyInert) {
177
182
throw new Error(`missing from node_modules: ${loc}`)
178
183
}
179
184
}
@@ -783,6 +788,10 @@ class Shrinkwrap {
783
788
// ok, I did my best! good luck!
784
789
}
785
790
791
+
if (lock.ideallyInert) {
792
+
meta.ideallyInert = true
793
+
}
794
+
786
795
if (lock.bundled) {
787
796
meta.inBundle = true
788
797
}
@@ -953,6 +962,12 @@ class Shrinkwrap {
953
962
this.#buildLegacyLockfile(this.tree, this.data)
954
963
}
955
964
965
+
if (!this.hiddenLockfile) {
966
+
for (const node of Object.values(this.data.packages)) {
967
+
delete node.ideallyInert
968
+
}
969
+
}
970
+
956
971
// lf version 1 = dependencies only
957
972
// lf version 2 = dependencies and packages
958
973
// lf version 3 = packages only
Original file line number Diff line number Diff line change
@@ -77868,11 +77868,34 @@ ArboristNode {
77868
77868
77869
77869
exports[`test/arborist/build-ideal-tree.js TAP optional dependency failures > optional-dep-enotarget 1`] = `
77870
77870
ArboristNode {
77871
+
"children": Map {
77872
+
"tap" => ArboristNode {
77873
+
"edgesIn": Set {
77874
+
EdgeIn {
77875
+
"error": "INVALID",
77876
+
"from": "",
77877
+
"name": "tap",
77878
+
"spec": "9999.0000.9999",
77879
+
"type": "optional",
77880
+
},
77881
+
},
77882
+
"errors": Array [
77883
+
Object {
77884
+
"code": "ETARGET",
77885
+
},
77886
+
],
77887
+
"location": "node_modules/tap",
77888
+
"name": "tap",
77889
+
"optional": true,
77890
+
"path": "{CWD}/test/fixtures/optional-dep-enotarget/node_modules/tap",
77891
+
},
77892
+
},
77871
77893
"edgesOut": Map {
77872
77894
"tap" => EdgeOut {
77895
+
"error": "INVALID",
77873
77896
"name": "tap",
77874
77897
"spec": "9999.0000.9999",
77875
-
"to": null,
77898
+
"to": "node_modules/tap",
77876
77899
"type": "optional",
77877
77900
},
77878
77901
},
@@ -77887,11 +77910,32 @@ ArboristNode {
77887
77910
77888
77911
exports[`test/arborist/build-ideal-tree.js TAP optional dependency failures > optional-dep-missing 1`] = `
77889
77912
ArboristNode {
77913
+
"children": Map {
77914
+
"@isaacs/this-does-not-exist-at-all" => ArboristNode {
77915
+
"edgesIn": Set {
77916
+
EdgeIn {
77917
+
"from": "",
77918
+
"name": "@isaacs/this-does-not-exist-at-all",
77919
+
"spec": "*",
77920
+
"type": "optional",
77921
+
},
77922
+
},
77923
+
"errors": Array [
77924
+
Object {
77925
+
"code": "E404",
77926
+
},
77927
+
],
77928
+
"location": "node_modules/@isaacs/this-does-not-exist-at-all",
77929
+
"name": "@isaacs/this-does-not-exist-at-all",
77930
+
"optional": true,
77931
+
"path": "{CWD}/test/fixtures/optional-dep-missing/node_modules/@isaacs/this-does-not-exist-at-all",
77932
+
},
77933
+
},
77890
77934
"edgesOut": Map {
77891
77935
"@isaacs/this-does-not-exist-at-all" => EdgeOut {
77892
77936
"name": "@isaacs/this-does-not-exist-at-all",
77893
77937
"spec": "*",
77894
-
"to": null,
77938
+
"to": "node_modules/@isaacs/this-does-not-exist-at-all",
77895
77939
"type": "optional",
77896
77940
},
77897
77941
},
@@ -77906,11 +77950,60 @@ ArboristNode {
77906
77950
77907
77951
exports[`test/arborist/build-ideal-tree.js TAP optional dependency failures > optional-metadep-enotarget 1`] = `
77908
77952
ArboristNode {
77953
+
"children": Map {
77954
+
"@isaacs/prod-dep-enotarget" => ArboristNode {
77955
+
"children": Map {
77956
+
"tap" => ArboristNode {
77957
+
"edgesIn": Set {
77958
+
EdgeIn {
77959
+
"error": "INVALID",
77960
+
"from": "node_modules/@isaacs/prod-dep-enotarget",
77961
+
"name": "tap",
77962
+
"spec": "9999.0000.9999",
77963
+
"type": "prod",
77964
+
},
77965
+
},
77966
+
"errors": Array [
77967
+
Object {
77968
+
"code": "ETARGET",
77969
+
},
77970
+
],
77971
+
"location": "node_modules/@isaacs/prod-dep-enotarget/node_modules/tap",
77972
+
"name": "tap",
77973
+
"optional": true,
77974
+
"path": "{CWD}/test/fixtures/optional-metadep-enotarget/node_modules/@isaacs/prod-dep-enotarget/node_modules/tap",
77975
+
},
77976
+
},
77977
+
"edgesIn": Set {
77978
+
EdgeIn {
77979
+
"from": "",
77980
+
"name": "@isaacs/prod-dep-enotarget",
77981
+
"spec": "*",
77982
+
"type": "optional",
77983
+
},
77984
+
},
77985
+
"edgesOut": Map {
77986
+
"tap" => EdgeOut {
77987
+
"error": "INVALID",
77988
+
"name": "tap",
77989
+
"spec": "9999.0000.9999",
77990
+
"to": "node_modules/@isaacs/prod-dep-enotarget/node_modules/tap",
77991
+
"type": "prod",
77992
+
},
77993
+
},
77994
+
"location": "node_modules/@isaacs/prod-dep-enotarget",
77995
+
"name": "@isaacs/prod-dep-enotarget",
77996
+
"optional": true,
77997
+
"path": "{CWD}/test/fixtures/optional-metadep-enotarget/node_modules/@isaacs/prod-dep-enotarget",
77998
+
"resolved": "https://registry.npmjs.org/@isaacs/prod-dep-enotarget/-/prod-dep-enotarget-1.0.0.tgz",
77999
+
"version": "1.0.0",
78000
+
},
78001
+
},
77909
78002
"edgesOut": Map {
77910
78003
"@isaacs/prod-dep-enotarget" => EdgeOut {
77911
78004
"name": "@isaacs/prod-dep-enotarget",
77912
78005
"spec": "*",
77913
-
"to": null,
78006
+
"to": "node_modules/@isaacs/prod-dep-enotarget",
77914
78007
"type": "optional",
77915
78008
},
77916
78009
},
@@ -77924,11 +78017,58 @@ ArboristNode {
77924
78017
77925
78018
exports[`test/arborist/build-ideal-tree.js TAP optional dependency failures > optional-metadep-missing 1`] = `
77926
78019
ArboristNode {
78020
+
"children": Map {
78021
+
"@isaacs/testing-prod-dep-metadata-missing" => ArboristNode {
78022
+
"children": Map {
78023
+
"@isaacs/this-does-not-exist-at-all" => ArboristNode {
78024
+
"edgesIn": Set {
78025
+
EdgeIn {
78026
+
"from": "node_modules/@isaacs/testing-prod-dep-metadata-missing",
78027
+
"name": "@isaacs/this-does-not-exist-at-all",
78028
+
"spec": "*",
78029
+
"type": "prod",
78030
+
},
78031
+
},
78032
+
"errors": Array [
78033
+
Object {
78034
+
"code": "E404",
78035
+
},
78036
+
],
78037
+
"location": "node_modules/@isaacs/testing-prod-dep-metadata-missing/node_modules/@isaacs/this-does-not-exist-at-all",
78038
+
"name": "@isaacs/this-does-not-exist-at-all",
78039
+
"optional": true,
78040
+
"path": "{CWD}/test/fixtures/optional-metadep-missing/node_modules/@isaacs/testing-prod-dep-metadata-missing/node_modules/@isaacs/this-does-not-exist-at-all",
78041
+
},
78042
+
},
78043
+
"edgesIn": Set {
78044
+
EdgeIn {
78045
+
"from": "",
78046
+
"name": "@isaacs/testing-prod-dep-metadata-missing",
78047
+
"spec": "*",
78048
+
"type": "optional",
78049
+
},
78050
+
},
78051
+
"edgesOut": Map {
78052
+
"@isaacs/this-does-not-exist-at-all" => EdgeOut {
78053
+
"name": "@isaacs/this-does-not-exist-at-all",
78054
+
"spec": "*",
78055
+
"to": "node_modules/@isaacs/testing-prod-dep-metadata-missing/node_modules/@isaacs/this-does-not-exist-at-all",
78056
+
"type": "prod",
78057
+
},
78058
+
},
78059
+
"location": "node_modules/@isaacs/testing-prod-dep-metadata-missing",
78060
+
"name": "@isaacs/testing-prod-dep-metadata-missing",
78061
+
"optional": true,
78062
+
"path": "{CWD}/test/fixtures/optional-metadep-missing/node_modules/@isaacs/testing-prod-dep-metadata-missing",
78063
+
"resolved": "https://registry.npmjs.org/@isaacs/testing-prod-dep-metadata-missing/-/testing-prod-dep-metadata-missing-1.0.0.tgz",
78064
+
"version": "1.0.0",
78065
+
},
78066
+
},
77927
78067
"edgesOut": Map {
77928
78068
"@isaacs/testing-prod-dep-metadata-missing" => EdgeOut {
77929
78069
"name": "@isaacs/testing-prod-dep-metadata-missing",
77930
78070
"spec": "*",
77931
-
"to": null,
78071
+
"to": "node_modules/@isaacs/testing-prod-dep-metadata-missing",
77932
78072
"type": "optional",
77933
78073
},
77934
78074
},
Original file line number Diff line number Diff line change
@@ -7784,4 +7784,4 @@ ArboristNode {
7784
7784
"name": "yarn-lock-mkdirp-file-dep",
7785
7785
"path": "yarn-lock-mkdirp-file-dep",
7786
7786
}
7787
-
`
7787
+
`
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4