Skip to content

Commit ada5af9

Browse files
committed
remove ideallyInert from hidden lockfile
1 parent 73820c6 commit ada5af9

File tree

16 files changed

+64
-1852
lines changed

16 files changed

+64
-1852
lines changed

workspaces/arborist/lib/arborist/build-ideal-tree.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
337337
})
338338

339339
.then(tree => {
340-
// search the virtual tree for invalid edges, if any are found add their source to
340+
// search the virtual tree for missing/invalid edges, if any are found add their source to
341341
// the depsQueue so that we'll fix it later
342342
depth({
343343
tree,
@@ -351,7 +351,7 @@ module.exports = cls => class IdealTreeBuilder extends cls {
351351
filter: node => node,
352352
visit: node => {
353353
for (const edge of node.edgesOut.values()) {
354-
if (!edge.valid) {
354+
if (!edge.to || !edge.valid) {
355355
this.#depsQueue.push(node)
356356
break // no need to continue the loop after the first hit
357357
}

workspaces/arborist/lib/arborist/load-virtual.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ To fix:
269269
integrity: sw.integrity,
270270
resolved: consistentResolve(sw.resolved, this.path, path),
271271
pkg: sw,
272-
ideallyInert: sw.ideallyInert,
273272
hasShrinkwrap: sw.hasShrinkwrap,
274273
dev,
275274
optional,

workspaces/arborist/lib/arborist/reify.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,17 @@ module.exports = cls => class Reifier extends cls {
135135
for (const node of this.#omitted) {
136136
node.parent = null
137137
}
138+
// clean inert
139+
for (const node of this.idealTree.inventory.values()) {
140+
if (node.ideallyInert) {
141+
node.parent = null
142+
}
143+
}
138144
// clean up any trash that is still in the tree
139145
for (const path of this[_trashList]) {
140146
const loc = relpath(this.idealTree.realpath, path)
141147
const node = this.idealTree.inventory.get(loc)
142-
if (node && node.root === this.idealTree && !node.ideallyInert) {
148+
if (node && node.root === this.idealTree) {
143149
node.parent = null
144150
}
145151
}

workspaces/arborist/lib/diff.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,6 @@ const diffNode = ({
258258
}
259259

260260
// Treat inert nodes as undefined for the purposes of diffing.
261-
if (actual?.ideallyInert) {
262-
actual = undefined
263-
}
264261
if (ideal?.ideallyInert) {
265262
ideal = undefined
266263
}

workspaces/arborist/lib/shrinkwrap.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ const nodeMetaKeys = [
109109
'inBundle',
110110
'hasShrinkwrap',
111111
'hasInstallScript',
112-
'ideallyInert',
113112
]
114113

115114
const metaFieldFromPkg = (pkg, key) => {
@@ -136,10 +135,6 @@ const assertNoNewer = async (path, data, lockTime, dir, seen) => {
136135

137136
const parent = isParent ? dir : resolve(dir, 'node_modules')
138137
const rel = relpath(path, dir)
139-
const inert = data.packages[rel]?.ideallyInert
140-
if (inert) {
141-
return
142-
}
143138
seen.add(rel)
144139
let entries
145140
if (dir === path) {
@@ -178,7 +173,7 @@ const assertNoNewer = async (path, data, lockTime, dir, seen) => {
178173

179174
// assert that all the entries in the lockfile were seen
180175
for (const loc in data.packages) {
181-
if (!seen.has(loc) && !data.packages[loc].ideallyInert) {
176+
if (!seen.has(loc)) {
182177
throw new Error(`missing from node_modules: ${loc}`)
183178
}
184179
}
@@ -788,10 +783,6 @@ class Shrinkwrap {
788783
// ok, I did my best! good luck!
789784
}
790785

791-
if (lock.ideallyInert) {
792-
meta.ideallyInert = true
793-
}
794-
795786
if (lock.bundled) {
796787
meta.inBundle = true
797788
}
@@ -962,12 +953,6 @@ class Shrinkwrap {
962953
this.#buildLegacyLockfile(this.tree, this.data)
963954
}
964955

965-
if (!this.hiddenLockfile) {
966-
for (const node of Object.values(this.data.packages)) {
967-
delete node.ideallyInert
968-
}
969-
}
970-
971956
// lf version 1 = dependencies only
972957
// lf version 2 = dependencies and packages
973958
// lf version 3 = packages only

workspaces/arborist/tap-snapshots/test/arborist/load-actual.js.test.cjs

Lines changed: 0 additions & 231 deletions
Original file line numberDiff line numberDiff line change
@@ -6166,237 +6166,6 @@ ArboristNode {
61666166
}
61676167
`
61686168

6169-
exports[`test/arborist/load-actual.js TAP selflink > loaded tree 1`] = `
6170-
ArboristNode {
6171-
"children": Map {
6172-
"@scope/y" => ArboristNode {
6173-
"edgesIn": Set {
6174-
EdgeIn {
6175-
"from": "",
6176-
"name": "@scope/y",
6177-
"spec": "*",
6178-
"type": "prod",
6179-
},
6180-
},
6181-
"edgesOut": Map {
6182-
"foo" => EdgeOut {
6183-
"name": "foo",
6184-
"spec": "*",
6185-
"to": "node_modules/foo",
6186-
"type": "prod",
6187-
},
6188-
},
6189-
"location": "node_modules/@scope/y",
6190-
"name": "@scope/y",
6191-
"path": "selflink/node_modules/@scope/y",
6192-
"version": "1.2.3",
6193-
},
6194-
"@scope/z" => ArboristNode {
6195-
"children": Map {
6196-
"glob" => ArboristLink {
6197-
"dev": true,
6198-
"edgesIn": Set {
6199-
EdgeIn {
6200-
"from": "node_modules/@scope/z",
6201-
"name": "glob",
6202-
"spec": "4",
6203-
"type": "prod",
6204-
},
6205-
},
6206-
"extraneous": true,
6207-
"location": "node_modules/@scope/z/node_modules/glob",
6208-
"name": "glob",
6209-
"optional": true,
6210-
"path": "selflink/node_modules/@scope/z/node_modules/glob",
6211-
"peer": true,
6212-
"realpath": "selflink/node_modules/foo/node_modules/glob",
6213-
"resolved": "file:../../../foo/node_modules/glob",
6214-
"target": ArboristNode {
6215-
"children": Map {
6216-
"graceful-fs" => ArboristNode {
6217-
"dev": true,
6218-
"extraneous": true,
6219-
"location": "node_modules/foo/node_modules/glob/node_modules/graceful-fs",
6220-
"name": "graceful-fs",
6221-
"optional": true,
6222-
"path": "selflink/node_modules/foo/node_modules/glob/node_modules/graceful-fs",
6223-
"peer": true,
6224-
"version": "3.0.2",
6225-
},
6226-
"inherits" => ArboristNode {
6227-
"dev": true,
6228-
"extraneous": true,
6229-
"location": "node_modules/foo/node_modules/glob/node_modules/inherits",
6230-
"name": "inherits",
6231-
"optional": true,
6232-
"path": "selflink/node_modules/foo/node_modules/glob/node_modules/inherits",
6233-
"peer": true,
6234-
"version": "2.0.1",
6235-
},
6236-
"minimatch" => ArboristNode {
6237-
"children": Map {
6238-
"lru-cache" => ArboristNode {
6239-
"dev": true,
6240-
"extraneous": true,
6241-
"location": "node_modules/foo/node_modules/glob/node_modules/minimatch/node_modules/lru-cache",
6242-
"name": "lru-cache",
6243-
"optional": true,
6244-
"path": "selflink/node_modules/foo/node_modules/glob/node_modules/minimatch/node_modules/lru-cache",
6245-
"peer": true,
6246-
"version": "2.5.0",
6247-
},
6248-
"sigmund" => ArboristNode {
6249-
"dev": true,
6250-
"extraneous": true,
6251-
"location": "node_modules/foo/node_modules/glob/node_modules/minimatch/node_modules/sigmund",
6252-
"name": "sigmund",
6253-
"optional": true,
6254-
"path": "selflink/node_modules/foo/node_modules/glob/node_modules/minimatch/node_modules/sigmund",
6255-
"peer": true,
6256-
"version": "1.0.0",
6257-
},
6258-
},
6259-
"dev": true,
6260-
"extraneous": true,
6261-
"location": "node_modules/foo/node_modules/glob/node_modules/minimatch",
6262-
"name": "minimatch",
6263-
"optional": true,
6264-
"path": "selflink/node_modules/foo/node_modules/glob/node_modules/minimatch",
6265-
"peer": true,
6266-
"version": "1.0.0",
6267-
},
6268-
"once" => ArboristNode {
6269-
"dev": true,
6270-
"extraneous": true,
6271-
"location": "node_modules/foo/node_modules/glob/node_modules/once",
6272-
"name": "once",
6273-
"optional": true,
6274-
"path": "selflink/node_modules/foo/node_modules/glob/node_modules/once",
6275-
"peer": true,
6276-
"version": "1.3.0",
6277-
},
6278-
},
6279-
"edgesIn": Set {
6280-
EdgeIn {
6281-
"from": "node_modules/foo",
6282-
"name": "glob",
6283-
"spec": "4",
6284-
"type": "prod",
6285-
},
6286-
},
6287-
"location": "node_modules/foo/node_modules/glob",
6288-
"name": "glob",
6289-
"path": "selflink/node_modules/foo/node_modules/glob",
6290-
"version": "4.0.5",
6291-
},
6292-
"version": "4.0.5",
6293-
},
6294-
},
6295-
"dev": true,
6296-
"edgesOut": Map {
6297-
"glob" => EdgeOut {
6298-
"name": "glob",
6299-
"spec": "4",
6300-
"to": "node_modules/@scope/z/node_modules/glob",
6301-
"type": "prod",
6302-
},
6303-
},
6304-
"extraneous": true,
6305-
"location": "node_modules/@scope/z",
6306-
"name": "@scope/z",
6307-
"optional": true,
6308-
"path": "selflink/node_modules/@scope/z",
6309-
"peer": true,
6310-
"version": "1.2.3",
6311-
},
6312-
"foo" => ArboristNode {
6313-
"children": Map {
6314-
"glob" => ArboristNode {
6315-
"location": "node_modules/foo/node_modules/glob",
6316-
},
6317-
"selflink" => ArboristLink {
6318-
"edgesIn": Set {
6319-
EdgeIn {
6320-
"from": "node_modules/foo",
6321-
"name": "selflink",
6322-
"spec": "*",
6323-
"type": "prod",
6324-
},
6325-
},
6326-
"location": "node_modules/foo/node_modules/selflink",
6327-
"name": "selflink",
6328-
"path": "selflink/node_modules/foo/node_modules/selflink",
6329-
"realpath": "selflink",
6330-
"resolved": "file:../../..",
6331-
"target": ArboristNode {
6332-
"location": "",
6333-
},
6334-
"version": "1.2.3",
6335-
},
6336-
},
6337-
"edgesIn": Set {
6338-
EdgeIn {
6339-
"from": "",
6340-
"name": "foo",
6341-
"spec": "*",
6342-
"type": "prod",
6343-
},
6344-
EdgeIn {
6345-
"from": "node_modules/@scope/y",
6346-
"name": "foo",
6347-
"spec": "*",
6348-
"type": "prod",
6349-
},
6350-
},
6351-
"edgesOut": Map {
6352-
"glob" => EdgeOut {
6353-
"name": "glob",
6354-
"spec": "4",
6355-
"to": "node_modules/foo/node_modules/glob",
6356-
"type": "prod",
6357-
},
6358-
"selflink" => EdgeOut {
6359-
"name": "selflink",
6360-
"spec": "*",
6361-
"to": "node_modules/foo/node_modules/selflink",
6362-
"type": "prod",
6363-
},
6364-
},
6365-
"location": "node_modules/foo",
6366-
"name": "foo",
6367-
"path": "selflink/node_modules/foo",
6368-
"version": "1.2.3",
6369-
},
6370-
},
6371-
"edgesOut": Map {
6372-
"@scope/x" => EdgeOut {
6373-
"error": "MISSING",
6374-
"name": "@scope/x",
6375-
"spec": "*",
6376-
"to": null,
6377-
"type": "prod",
6378-
},
6379-
"@scope/y" => EdgeOut {
6380-
"name": "@scope/y",
6381-
"spec": "*",
6382-
"to": "node_modules/@scope/y",
6383-
"type": "prod",
6384-
},
6385-
"foo" => EdgeOut {
6386-
"name": "foo",
6387-
"spec": "*",
6388-
"to": "node_modules/foo",
6389-
"type": "prod",
6390-
},
6391-
},
6392-
"isProjectRoot": true,
6393-
"location": "",
6394-
"name": "selflink",
6395-
"path": "selflink",
6396-
"version": "1.2.3",
6397-
}
6398-
`
6399-
64006169
exports[`test/arborist/load-actual.js TAP shake out Link target timing issue > loaded tree 1`] = `
64016170
ArboristNode {
64026171
"children": Map {

workspaces/arborist/tap-snapshots/test/arborist/load-virtual.js.test.cjs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13344,12 +13344,6 @@ ArboristNode {
1334413344
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
1334513345
"version": "1.1.1",
1334613346
},
13347-
"acorn-jsx" => ArboristNode {
13348-
"location": "node_modules/acorn-jsx",
13349-
"name": "acorn-jsx",
13350-
"path": "{CWD}/test/fixtures/install-types/node_modules/acorn-jsx",
13351-
"version": "5.3.1",
13352-
},
1335313347
"balanced-match" => ArboristNode {
1335413348
"edgesIn": Set {
1335513349
EdgeIn {
@@ -14039,12 +14033,6 @@ ArboristNode {
1403914033
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
1404014034
"version": "1.1.1",
1404114035
},
14042-
"acorn-jsx" => ArboristNode {
14043-
"location": "node_modules/acorn-jsx",
14044-
"name": "acorn-jsx",
14045-
"path": "{CWD}/test/fixtures/install-types/node_modules/acorn-jsx",
14046-
"version": "5.3.1",
14047-
},
1404814036
"balanced-match" => ArboristNode {
1404914037
"edgesIn": Set {
1405014038
EdgeIn {
@@ -14734,12 +14722,6 @@ ArboristNode {
1473414722
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
1473514723
"version": "1.1.1",
1473614724
},
14737-
"acorn-jsx" => ArboristNode {
14738-
"location": "node_modules/acorn-jsx",
14739-
"name": "acorn-jsx",
14740-
"path": "{CWD}/test/arborist/tap-testdir-load-virtual-load-from-npm-shrinkwrap.json/node_modules/acorn-jsx",
14741-
"version": "5.3.1",
14742-
},
1474314725
"balanced-match" => ArboristNode {
1474414726
"edgesIn": Set {
1474514727
EdgeIn {

0 commit comments

Comments
 (0)