@vltpkg/graph 1.0.0-rc.4 → 1.0.0-rc.6
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/dist/esm/actual/load.d.ts.map +1 -1
- package/dist/esm/actual/load.js +25 -8
- package/dist/esm/actual/load.js.map +1 -1
- package/dist/esm/diff.d.ts +2 -0
- package/dist/esm/diff.d.ts.map +1 -1
- package/dist/esm/edge.d.ts +1 -0
- package/dist/esm/edge.d.ts.map +1 -1
- package/dist/esm/edge.js +4 -0
- package/dist/esm/edge.js.map +1 -1
- package/dist/esm/graph.d.ts +18 -4
- package/dist/esm/graph.d.ts.map +1 -1
- package/dist/esm/graph.js +50 -39
- package/dist/esm/graph.js.map +1 -1
- package/dist/esm/ideal/append-nodes.d.ts +1 -1
- package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/append-nodes.js +146 -64
- package/dist/esm/ideal/append-nodes.js.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts +2 -5
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.js +23 -12
- package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -1
- package/dist/esm/ideal/build.d.ts.map +1 -1
- package/dist/esm/ideal/build.js +0 -2
- package/dist/esm/ideal/build.js.map +1 -1
- package/dist/esm/ideal/get-ordered-dependencies.d.ts +10 -0
- package/dist/esm/ideal/get-ordered-dependencies.d.ts.map +1 -0
- package/dist/esm/ideal/get-ordered-dependencies.js +42 -0
- package/dist/esm/ideal/get-ordered-dependencies.js.map +1 -0
- package/dist/esm/ideal/peers.d.ts +71 -0
- package/dist/esm/ideal/peers.d.ts.map +1 -0
- package/dist/esm/ideal/peers.js +318 -0
- package/dist/esm/ideal/peers.js.map +1 -0
- package/dist/esm/ideal/{add-nodes.d.ts → refresh-ideal-graph.d.ts} +9 -5
- package/dist/esm/ideal/refresh-ideal-graph.d.ts.map +1 -0
- package/dist/esm/ideal/refresh-ideal-graph.js +79 -0
- package/dist/esm/ideal/refresh-ideal-graph.js.map +1 -0
- package/dist/esm/ideal/types.d.ts +65 -1
- package/dist/esm/ideal/types.d.ts.map +1 -1
- package/dist/esm/ideal/types.js.map +1 -1
- package/dist/esm/install.d.ts +3 -2
- package/dist/esm/install.d.ts.map +1 -1
- package/dist/esm/install.js +21 -5
- package/dist/esm/install.js.map +1 -1
- package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
- package/dist/esm/lockfile/load-nodes.js +8 -2
- package/dist/esm/lockfile/load-nodes.js.map +1 -1
- package/dist/esm/lockfile/load.d.ts +0 -4
- package/dist/esm/lockfile/load.d.ts.map +1 -1
- package/dist/esm/lockfile/load.js +4 -29
- package/dist/esm/lockfile/load.js.map +1 -1
- package/dist/esm/node.d.ts +14 -0
- package/dist/esm/node.d.ts.map +1 -1
- package/dist/esm/node.js +16 -0
- package/dist/esm/node.js.map +1 -1
- package/dist/esm/visualization/json-output.d.ts +2 -1
- package/dist/esm/visualization/json-output.d.ts.map +1 -1
- package/dist/esm/visualization/json-output.js +2 -2
- package/dist/esm/visualization/json-output.js.map +1 -1
- package/package.json +21 -21
- package/dist/esm/ideal/add-nodes.d.ts.map +0 -1
- package/dist/esm/ideal/add-nodes.js +0 -39
- package/dist/esm/ideal/add-nodes.js.map +0 -1
- package/dist/esm/ideal/remove-nodes.d.ts +0 -7
- package/dist/esm/ideal/remove-nodes.d.ts.map +0 -1
- package/dist/esm/ideal/remove-nodes.js +0 -19
- package/dist/esm/ideal/remove-nodes.js.map +0 -1
package/dist/esm/install.js
CHANGED
|
@@ -42,6 +42,7 @@ export const install = async (options, add) => {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
if (options.frozenLockfile) {
|
|
45
|
+
// validates no add/remove operations are requested
|
|
45
46
|
if (add?.modifiedDependencies) {
|
|
46
47
|
const dependencies = [];
|
|
47
48
|
for (const [, deps] of add) {
|
|
@@ -54,7 +55,6 @@ export const install = async (options, add) => {
|
|
|
54
55
|
const lockfileGraph = loadVirtual({
|
|
55
56
|
...options,
|
|
56
57
|
mainManifest,
|
|
57
|
-
skipLoadingNodesOnModifiersChange: false,
|
|
58
58
|
});
|
|
59
59
|
const emptyAdd = Object.assign(new Map(), { modifiedDependencies: false });
|
|
60
60
|
const emptyRemove = Object.assign(new Map(), {
|
|
@@ -94,7 +94,8 @@ export const install = async (options, add) => {
|
|
|
94
94
|
const node = lockfileGraph.nodes.get(importerId);
|
|
95
95
|
const location = node?.location || importerId;
|
|
96
96
|
const depNames = Array.from(deps.keys());
|
|
97
|
-
|
|
97
|
+
const depLabelAdd = deps.size === 1 ? 'dependency' : 'dependencies';
|
|
98
|
+
details.push(` ${location}: ${deps.size} ${depLabelAdd} to add (${depNames.join(', ')})`);
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
for (const [importerId, deps] of importerSpecs.remove) {
|
|
@@ -102,7 +103,10 @@ export const install = async (options, add) => {
|
|
|
102
103
|
const node = lockfileGraph.nodes.get(importerId);
|
|
103
104
|
const location = node?.location || importerId;
|
|
104
105
|
const depNames = Array.from(deps);
|
|
105
|
-
|
|
106
|
+
const depLabelRemove = deps.size === 1 ?
|
|
107
|
+
'dependency'
|
|
108
|
+
: /* c8 ignore next */ 'dependencies';
|
|
109
|
+
details.push(` ${location}: ${deps.size} ${depLabelRemove} to remove (${depNames.join(', ')})`);
|
|
106
110
|
}
|
|
107
111
|
}
|
|
108
112
|
const lockfilePath = resolve(options.projectRoot, 'vlt-lock.json');
|
|
@@ -121,13 +125,22 @@ export const install = async (options, add) => {
|
|
|
121
125
|
}
|
|
122
126
|
}
|
|
123
127
|
try {
|
|
128
|
+
const remove = Object.assign(new Map(), {
|
|
129
|
+
modifiedDependencies: false,
|
|
130
|
+
});
|
|
124
131
|
const modifiers = GraphModifier.maybeLoad(options);
|
|
125
|
-
|
|
132
|
+
let act = actualLoad({
|
|
126
133
|
...options,
|
|
127
134
|
mainManifest,
|
|
128
135
|
loadManifests: true,
|
|
129
136
|
modifiers: undefined, // modifiers should not be used here
|
|
130
137
|
});
|
|
138
|
+
// if the actual graph has no dependencies, it's simpler to ignore it
|
|
139
|
+
// this allows us to check for its availability later on for properly
|
|
140
|
+
// handling situations like resetting edges for refreshing the ideal graph
|
|
141
|
+
if (act.importers.size === act.nodes.size) {
|
|
142
|
+
act = undefined;
|
|
143
|
+
}
|
|
131
144
|
const graph = await idealBuild({
|
|
132
145
|
...options,
|
|
133
146
|
actual: act,
|
|
@@ -135,6 +148,7 @@ export const install = async (options, add) => {
|
|
|
135
148
|
mainManifest,
|
|
136
149
|
loadManifests: true,
|
|
137
150
|
modifiers,
|
|
151
|
+
remove,
|
|
138
152
|
remover,
|
|
139
153
|
});
|
|
140
154
|
// If lockfileOnly is enabled, skip reify and only save the lockfile
|
|
@@ -143,11 +157,12 @@ export const install = async (options, add) => {
|
|
|
143
157
|
lockfile.save({ graph, modifiers });
|
|
144
158
|
const saveImportersPackageJson =
|
|
145
159
|
/* c8 ignore next */
|
|
146
|
-
add?.modifiedDependencies ?
|
|
160
|
+
add?.modifiedDependencies || remove.modifiedDependencies ?
|
|
147
161
|
updatePackageJson({
|
|
148
162
|
...options,
|
|
149
163
|
add,
|
|
150
164
|
graph,
|
|
165
|
+
remove,
|
|
151
166
|
})
|
|
152
167
|
: undefined;
|
|
153
168
|
saveImportersPackageJson?.();
|
|
@@ -160,6 +175,7 @@ export const install = async (options, add) => {
|
|
|
160
175
|
graph,
|
|
161
176
|
loadManifests: true,
|
|
162
177
|
modifiers,
|
|
178
|
+
remove,
|
|
163
179
|
remover,
|
|
164
180
|
});
|
|
165
181
|
return { buildQueue, graph, diff };
|
package/dist/esm/install.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,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;YACb,wBAAwB,EAAE,EAAE,CAAA;YAC5B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;QACnC,CAAC;QAED,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,MAAM,KAAK,CAAC;YACvC,GAAG,OAAO;YACV,GAAG;YACH,MAAM,EAAE,GAAG;YACX,KAAK;YACL,aAAa,EAAE,IAAI;YACnB,SAAS;YACT,OAAO;SACR,CAAC,CAAA;QAEF,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;IACpC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,oBAAoB;QACpB,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QACxC,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { load as actualLoad } from './actual/load.ts'\nimport { build as idealBuild } from './ideal/build.ts'\nimport { reify } from './reify/index.ts'\nimport { GraphModifier } from './modifiers.ts'\nimport { init } from '@vltpkg/init'\nimport { error } from '@vltpkg/error-cause'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport { asError } from '@vltpkg/types'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { LoadOptions } from './actual/load.ts'\nimport { getDependencies } from './dependencies.ts'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n} from './dependencies.ts'\nimport { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { load as loadVirtual } from './lockfile/load.ts'\nimport { getImporterSpecs } from './ideal/get-importer-specs.ts'\nimport { lockfile } from './index.ts'\nimport { updatePackageJson } from './reify/update-importers-package-json.ts'\n\nexport type InstallOptions = LoadOptions & {\n packageInfo: PackageInfoClient\n cleanInstall?: boolean // Only set by ci command for clean install\n allowScripts: string\n}\n\nexport const install = async (\n options: InstallOptions,\n add?: AddImportersDependenciesMap,\n) => {\n // Validate incompatible options\n if (options.lockfileOnly && options.cleanInstall) {\n throw error(\n 'Cannot use --lockfile-only with --clean-install (ci command). Clean install requires filesystem operations.',\n )\n }\n\n if (options.expectLockfile || options.frozenLockfile) {\n const lockfilePath = resolve(options.projectRoot, 'vlt-lock.json')\n if (!existsSync(lockfilePath)) {\n throw error(\n 'vlt-lock.json file is required when using --expect-lockfile, --frozen-lockfile, or ci command',\n {\n path: lockfilePath,\n },\n )\n }\n }\n\n let mainManifest: NormalizedManifest | undefined = undefined\n try {\n mainManifest = options.packageJson.read(options.projectRoot)\n } catch (err) {\n if (asError(err).message === 'Could not read package.json file') {\n await init({ cwd: options.projectRoot })\n mainManifest = options.packageJson.read(options.projectRoot, {\n reload: true,\n })\n } else {\n throw err\n }\n }\n\n if (options.frozenLockfile) {\n if (add?.modifiedDependencies) {\n const dependencies: string[] = []\n for (const [, deps] of add) {\n for (const [name] of deps) {\n dependencies.push(name)\n }\n }\n throw error(\n 'Cannot add dependencies when using --frozen-lockfile',\n { found: dependencies.join(', ') },\n )\n }\n\n const lockfileGraph = loadVirtual({\n ...options,\n mainManifest,\n skipLoadingNodesOnModifiersChange: false,\n })\n\n const emptyAdd = Object.assign(\n new Map<DepID, Map<string, Dependency>>(),\n { modifiedDependencies: false },\n )\n const emptyRemove = Object.assign(new Map<DepID, Set<string>>(), {\n modifiedDependencies: false,\n })\n const importerSpecs = getImporterSpecs({\n graph: lockfileGraph,\n add: emptyAdd,\n remove: emptyRemove,\n ...options,\n })\n\n // Check for spec changes by comparing package.json specs with lockfile edges\n const specChanges: string[] = []\n for (const importer of lockfileGraph.importers) {\n const deps = getDependencies(importer, options)\n for (const [depName, dep] of deps) {\n const edge = importer.edgesOut.get(depName)\n if (edge?.spec) {\n if (edge.spec.toString() !== dep.spec.toString()) {\n const node = lockfileGraph.nodes.get(importer.id)\n /* c8 ignore next */\n const location = node?.location || importer.id\n specChanges.push(\n ` ${location}: ${depName} spec changed from \"${edge.spec}\" to \"${dep.spec}\"`,\n )\n }\n }\n }\n }\n\n if (\n importerSpecs.add.modifiedDependencies ||\n importerSpecs.remove.modifiedDependencies ||\n specChanges.length > 0\n ) {\n const details: string[] = []\n\n if (specChanges.length > 0) {\n details.push(...specChanges)\n }\n\n for (const [importerId, deps] of importerSpecs.add) {\n if (deps.size > 0) {\n const node = lockfileGraph.nodes.get(importerId)\n const location = node?.location || importerId\n const depNames = Array.from(deps.keys())\n details.push(\n ` ${location}: ${deps.size} dependencies to add (${depNames.join(', ')})`,\n )\n }\n }\n\n for (const [importerId, deps] of importerSpecs.remove) {\n if (deps.size > 0) {\n const node = lockfileGraph.nodes.get(importerId)\n const location = node?.location || importerId\n const depNames = Array.from(deps)\n details.push(\n ` ${location}: ${deps.size} dependencies to remove (${depNames.join(', ')})`,\n )\n }\n }\n\n const lockfilePath = resolve(\n options.projectRoot,\n 'vlt-lock.json',\n )\n throw error(\n 'Lockfile is out of sync with package.json. Run \"vlt install\" to update.\\n' +\n details.join('\\n'),\n {\n path: lockfilePath,\n },\n )\n }\n }\n\n const remover = new RollbackRemove()\n if (options.cleanInstall) {\n const nodeModulesPath = resolve(\n options.projectRoot,\n 'node_modules',\n )\n if (existsSync(nodeModulesPath)) {\n await remover.rm(nodeModulesPath)\n remover.confirm()\n }\n }\n\n try {\n const modifiers = GraphModifier.maybeLoad(options)\n\n const act = actualLoad({\n ...options,\n mainManifest,\n loadManifests: true,\n modifiers: undefined, // modifiers should not be used here\n })\n const graph = await idealBuild({\n ...options,\n actual: act,\n add,\n mainManifest,\n loadManifests: true,\n modifiers,\n remover,\n })\n\n // If lockfileOnly is enabled, skip reify and only save the lockfile\n if (options.lockfileOnly) {\n // Save only the main lockfile, skip all filesystem operations\n lockfile.save({ graph, modifiers })\n const saveImportersPackageJson =\n /* c8 ignore next */\n add?.modifiedDependencies ?\n updatePackageJson({\n ...options,\n add,\n graph,\n })\n : undefined\n saveImportersPackageJson?.()\n return { graph, diff: undefined }\n }\n\n const { diff, buildQueue } = await reify({\n ...options,\n add,\n actual: act,\n graph,\n loadManifests: true,\n modifiers,\n remover,\n })\n\n return { buildQueue, graph, diff }\n } catch (err) {\n /* c8 ignore next */\n await remover.rollback().catch(() => {})\n throw err\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAMnD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AAQ5E,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC1B,OAAuB,EACvB,GAAiC,EACjC,EAAE;IACF,gCAAgC;IAChC,IAAI,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QACjD,MAAM,KAAK,C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,EAAE,IAAI,EAAE,CAAA;IACpC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,oBAAoB;QACpB,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QACxC,MAAM,GAAG,CAAA;IACX,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { load as actualLoad } from './actual/load.ts'\nimport { build as idealBuild } from './ideal/build.ts'\nimport { reify } from './reify/index.ts'\nimport { GraphModifier } from './modifiers.ts'\nimport { init } from '@vltpkg/init'\nimport { error } from '@vltpkg/error-cause'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport { asError } from '@vltpkg/types'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { LoadOptions } from './actual/load.ts'\nimport { getDependencies } from './dependencies.ts'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n} from './dependencies.ts'\nimport { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { load as loadVirtual } from './lockfile/load.ts'\nimport { getImporterSpecs } from './ideal/get-importer-specs.ts'\nimport { lockfile } from './index.ts'\nimport type { Graph } from './index.ts'\nimport { updatePackageJson } from './reify/update-importers-package-json.ts'\n\nexport type InstallOptions = LoadOptions & {\n packageInfo: PackageInfoClient\n cleanInstall?: boolean // Only set by ci command for clean install\n allowScripts: string\n}\n\nexport const install = async (\n options: InstallOptions,\n add?: AddImportersDependenciesMap,\n) => {\n // Validate incompatible options\n if (options.lockfileOnly && options.cleanInstall) {\n throw error(\n 'Cannot use --lockfile-only with --clean-install (ci command). Clean install requires filesystem operations.',\n )\n }\n\n if (options.expectLockfile || options.frozenLockfile) {\n const lockfilePath = resolve(options.projectRoot, 'vlt-lock.json')\n if (!existsSync(lockfilePath)) {\n throw error(\n 'vlt-lock.json file is required when using --expect-lockfile, --frozen-lockfile, or ci command',\n {\n path: lockfilePath,\n },\n )\n }\n }\n\n let mainManifest: NormalizedManifest | undefined = undefined\n try {\n mainManifest = options.packageJson.read(options.projectRoot)\n } catch (err) {\n if (asError(err).message === 'Could not read package.json file') {\n await init({ cwd: options.projectRoot })\n mainManifest = options.packageJson.read(options.projectRoot, {\n reload: true,\n })\n } else {\n throw err\n }\n }\n\n if (options.frozenLockfile) {\n // validates no add/remove operations are requested\n if (add?.modifiedDependencies) {\n const dependencies: string[] = []\n for (const [, deps] of add) {\n for (const [name] of deps) {\n dependencies.push(name)\n }\n }\n throw error(\n 'Cannot add dependencies when using --frozen-lockfile',\n { found: dependencies.join(', ') },\n )\n }\n\n const lockfileGraph = loadVirtual({\n ...options,\n mainManifest,\n })\n\n const emptyAdd = Object.assign(\n new Map<DepID, Map<string, Dependency>>(),\n { modifiedDependencies: false },\n )\n const emptyRemove = Object.assign(new Map<DepID, Set<string>>(), {\n modifiedDependencies: false,\n })\n const importerSpecs = getImporterSpecs({\n graph: lockfileGraph,\n add: emptyAdd,\n remove: emptyRemove,\n ...options,\n })\n\n // Check for spec changes by comparing package.json specs with lockfile edges\n const specChanges: string[] = []\n for (const importer of lockfileGraph.importers) {\n const deps = getDependencies(importer, options)\n for (const [depName, dep] of deps) {\n const edge = importer.edgesOut.get(depName)\n if (edge?.spec) {\n if (edge.spec.toString() !== dep.spec.toString()) {\n const node = lockfileGraph.nodes.get(importer.id)\n /* c8 ignore next */\n const location = node?.location || importer.id\n specChanges.push(\n ` ${location}: ${depName} spec changed from \"${edge.spec}\" to \"${dep.spec}\"`,\n )\n }\n }\n }\n }\n\n if (\n importerSpecs.add.modifiedDependencies ||\n importerSpecs.remove.modifiedDependencies ||\n specChanges.length > 0\n ) {\n const details: string[] = []\n\n if (specChanges.length > 0) {\n details.push(...specChanges)\n }\n\n for (const [importerId, deps] of importerSpecs.add) {\n if (deps.size > 0) {\n const node = lockfileGraph.nodes.get(importerId)\n const location = node?.location || importerId\n const depNames = Array.from(deps.keys())\n const depLabelAdd =\n deps.size === 1 ? 'dependency' : 'dependencies'\n details.push(\n ` ${location}: ${deps.size} ${depLabelAdd} to add (${depNames.join(', ')})`,\n )\n }\n }\n\n for (const [importerId, deps] of importerSpecs.remove) {\n if (deps.size > 0) {\n const node = lockfileGraph.nodes.get(importerId)\n const location = node?.location || importerId\n const depNames = Array.from(deps)\n const depLabelRemove =\n deps.size === 1 ?\n 'dependency'\n : /* c8 ignore next */ 'dependencies'\n details.push(\n ` ${location}: ${deps.size} ${depLabelRemove} to remove (${depNames.join(', ')})`,\n )\n }\n }\n\n const lockfilePath = resolve(\n options.projectRoot,\n 'vlt-lock.json',\n )\n throw error(\n 'Lockfile is out of sync with package.json. Run \"vlt install\" to update.\\n' +\n details.join('\\n'),\n {\n path: lockfilePath,\n },\n )\n }\n }\n\n const remover = new RollbackRemove()\n if (options.cleanInstall) {\n const nodeModulesPath = resolve(\n options.projectRoot,\n 'node_modules',\n )\n if (existsSync(nodeModulesPath)) {\n await remover.rm(nodeModulesPath)\n remover.confirm()\n }\n }\n\n try {\n const remove = Object.assign(new Map<DepID, Set<string>>(), {\n modifiedDependencies: false,\n }) as RemoveImportersDependenciesMap\n const modifiers = GraphModifier.maybeLoad(options)\n\n let act: Graph | undefined = actualLoad({\n ...options,\n mainManifest,\n loadManifests: true,\n modifiers: undefined, // modifiers should not be used here\n })\n // if the actual graph has no dependencies, it's simpler to ignore it\n // this allows us to check for its availability later on for properly\n // handling situations like resetting edges for refreshing the ideal graph\n if (act.importers.size === act.nodes.size) {\n act = undefined\n }\n const graph = await idealBuild({\n ...options,\n actual: act,\n add,\n mainManifest,\n loadManifests: true,\n modifiers,\n remove,\n remover,\n })\n\n // If lockfileOnly is enabled, skip reify and only save the lockfile\n if (options.lockfileOnly) {\n // Save only the main lockfile, skip all filesystem operations\n lockfile.save({ graph, modifiers })\n const saveImportersPackageJson =\n /* c8 ignore next */\n add?.modifiedDependencies || remove.modifiedDependencies ?\n updatePackageJson({\n ...options,\n add,\n graph,\n remove,\n })\n : undefined\n saveImportersPackageJson?.()\n return { graph, diff: undefined }\n }\n\n const { diff, buildQueue } = await reify({\n ...options,\n add,\n actual: act,\n graph,\n loadManifests: true,\n modifiers,\n remove,\n remover,\n })\n\n return { buildQueue, graph, diff }\n } catch (err) {\n /* c8 ignore next */\n await remover.rollback().catch(() => {})\n throw err\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-nodes.d.ts","sourceRoot":"","sources":["../../../src/lockfile/load-nodes.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,YAAY,CAAA;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD,eAAO,MAAM,SAAS,UACb,SAAS,SACT,YAAY,CAAC,OAAO,CAAC,WACnB,WAAW,WACX,SAAS,2BACO,OAAO,
|
|
1
|
+
{"version":3,"file":"load-nodes.d.ts","sourceRoot":"","sources":["../../../src/lockfile/load-nodes.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,YAAY,CAAA;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD,eAAO,MAAM,SAAS,UACb,SAAS,SACT,YAAY,CAAC,OAAO,CAAC,WACnB,WAAW,WACX,SAAS,2BACO,OAAO,SAgIjC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import { splitDepID } from '@vltpkg/dep-id/browser';
|
|
2
|
+
import { splitDepID, splitExtra } from '@vltpkg/dep-id/browser';
|
|
3
3
|
import { getBooleanFlagsFromNum, getBuildStateFromNum, } from "./types.js";
|
|
4
4
|
export const loadNodes = (graph, nodes, options, actual, throwOnMissingManifest) => {
|
|
5
5
|
const entries = Object.entries(nodes);
|
|
@@ -55,7 +55,13 @@ export const loadNodes = (graph, nodes, options, actual, throwOnMissingManifest)
|
|
|
55
55
|
graph.addNode(id, mani)
|
|
56
56
|
: graph.addNode(id, undefined, undefined, name ?? undefined, version);
|
|
57
57
|
if (extra) {
|
|
58
|
-
|
|
58
|
+
const { modifier, peerSetHash } = splitExtra(extra);
|
|
59
|
+
if (modifier) {
|
|
60
|
+
node.modifier = modifier;
|
|
61
|
+
}
|
|
62
|
+
if (peerSetHash) {
|
|
63
|
+
node.peerSetHash = peerSetHash;
|
|
64
|
+
}
|
|
59
65
|
}
|
|
60
66
|
const { dev, optional } = getBooleanFlagsFromNum(flags);
|
|
61
67
|
node.options = options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-nodes.js","sourceRoot":"","sources":["../../../src/lockfile/load-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"load-nodes.js","sourceRoot":"","sources":["../../../src/lockfile/load-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,YAAY,CAAA;AAMnB,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAgB,EAChB,KAA4B,EAC5B,OAAoB,EACpB,MAAkB,EAClB,sBAAgC,EAChC,EAAE;IACF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAA4B,CAAA;IAChE,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAA;IAEhC,8DAA8D;IAC9D,mCAAmC;I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AAG,OAAO,CAAA;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,aAAa,EAAE,SAAS,CAAA;QACtD,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,aAAa,EAAE,QAAQ,CAAA;QACnD,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAA;QACpC,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,IAAI,CAAC,WAAW,EAAE,CAAA;QACtC,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAC1B,CAAC;aAAM,CAAC;YACN,8DAA8D;YAC9D,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;gBACpB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;YAC1B,CAAC;QACH,CAAC;QACD,IAAI,IAAI,IAAI,WAAW,EAAE,CAAC;YACxB,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;QAC7C,CAAC;QAED,gCAAgC;QAChC,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAC1B,CAAC;QAED,sCAAsC;QACtC,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAClB,CAAC;QAED,8BAA8B;QAC9B,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACpD,IAAI,CAAC,UAAU,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAA;QACpD,CAAC;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { splitDepID, splitExtra } from '@vltpkg/dep-id/browser'\nimport {\n getBooleanFlagsFromNum,\n getBuildStateFromNum,\n} from './types.ts'\nimport type { LockfileData, LockfileNode } from './types.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { GraphLike } from '@vltpkg/types'\nimport type { SpecOptions } from '@vltpkg/spec/browser'\n\nexport const loadNodes = (\n graph: GraphLike,\n nodes: LockfileData['nodes'],\n options: SpecOptions,\n actual?: GraphLike,\n throwOnMissingManifest?: boolean,\n) => {\n const entries = Object.entries(nodes) as [DepID, LockfileNode][]\n const nodeCount = entries.length\n\n // Batch process registry spec parsing (only for large graphs)\n // Only used for non-trivial graphs\n const registryVersionCache =\n nodeCount > 50 ? new Map<string, string>() : null\n\n for (const [id, lockfileNode] of entries) {\n const [\n flags,\n name,\n integrity,\n resolved,\n location,\n manifest,\n rawManifest,\n platform,\n bins,\n buildState,\n ] = lockfileNode\n // workspace nodes and the project root node are already part of the\n // graph and it should not create new nodes if an existing one is there\n if (graph.nodes.has(id)) continue\n\n const [type, filepath, maybeExtra, lastExtra] = splitDepID(id)\n const extra =\n type === 'registry' || type === 'git' ? lastExtra : maybeExtra\n const registrySpec = maybeExtra\n\n // The reference node is a node that matches the same id from the\n // current iterating node in the provided `actual` graph, this allows\n // for hydrating missing manifest, integrity, and resolved values\n // that may be missing from the lockfile\n const referenceNode = actual?.nodes.get(id)\n const mani = manifest ?? referenceNode?.manifest\n\n // Throw if manifest is missing and the option is enabled\n if (!mani && throwOnMissingManifest) {\n throw error(\n `Missing manifest for node ${id} and no reference node found.`,\n )\n }\n\n // Optimize registry version extraction with caching for large graphs\n let version: string | undefined\n if (\n type === 'registry' &&\n registrySpec &&\n registrySpec.indexOf('@') > 0\n ) {\n if (registryVersionCache) {\n const seenVersion = registryVersionCache.get(registrySpec)\n /* c8 ignore start */\n if (seenVersion) {\n version = seenVersion\n } else {\n version = registrySpec.split('@').slice(-1)[0] || undefined\n /* c8 ignore stop */\n if (version) {\n registryVersionCache.set(registrySpec, version)\n }\n }\n } else {\n version = registrySpec.split('@').slice(-1)[0] || undefined\n }\n }\n\n // if the lockfile has manifest data then it should just use that\n // otherwise tries to infer name / version value from the lockfile node\n const node =\n mani ?\n graph.addNode(id, mani)\n : graph.addNode(\n id,\n undefined,\n undefined,\n name ?? undefined,\n version,\n )\n\n if (extra) {\n const { modifier, peerSetHash } = splitExtra(extra)\n if (modifier) {\n node.modifier = modifier\n }\n if (peerSetHash) {\n node.peerSetHash = peerSetHash\n }\n }\n\n const { dev, optional } = getBooleanFlagsFromNum(flags)\n node.options = options\n node.dev = dev\n node.optional = optional\n node.integrity = integrity ?? referenceNode?.integrity\n node.resolved = resolved ?? referenceNode?.resolved\n node.projectRoot = graph.projectRoot\n if (!node.resolved) node.setResolved()\n if (location) {\n node.location = location\n } else {\n // set the location to file dependencies based on the id value\n if (type === 'file') {\n node.location = filepath\n }\n }\n if (mani && rawManifest) {\n node.setConfusedManifest(mani, rawManifest)\n }\n\n // Set platform data if provided\n if (platform) {\n node.platform = platform\n }\n\n // optionally set bin data if provided\n if (bins) {\n node.bins = bins\n }\n\n // Set build state if provided\n if (buildState !== undefined && buildState !== null) {\n node.buildState = getBuildStateFromNum(buildState)\n }\n }\n}\n"]}
|
|
@@ -35,10 +35,6 @@ export type LoadOptions = SpecOptions & {
|
|
|
35
35
|
* A {@link PathScurry} object, for use in globs
|
|
36
36
|
*/
|
|
37
37
|
scurry?: PathScurry;
|
|
38
|
-
/**
|
|
39
|
-
* Load only importers into the graph if the modifiers have changed.
|
|
40
|
-
*/
|
|
41
|
-
skipLoadingNodesOnModifiersChange?: boolean;
|
|
42
38
|
/**
|
|
43
39
|
* Whether to throw an error if a manifest is missing when loading nodes.
|
|
44
40
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/lockfile/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAK7C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC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;IACH,MAAM,CAAC,EAAE,KAAK,CAAA;IACd;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,YAAY,EAAE,kBAAkB,CAAA;IAChC;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACjC,CAAA;AASD,eAAO,MAAM,IAAI,YAAa,WAAW,KAAG,KAM3C,CAAA;AAED,eAAO,MAAM,UAAU,YAAa,WAAW,KAAG,KAQjD,CAAA;AAED,eAAO,MAAM,UAAU,YACZ,WAAW,gBACN,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,iBAAiB,CAAC,GAC7D,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,iBAAiB,CAAC,CAAC,UAgE7D,CAAA"}
|
|
@@ -19,11 +19,11 @@ export const loadHidden = (options) => {
|
|
|
19
19
|
return loadObject(options, loadLockfile(projectRoot, 'node_modules/.vlt-lock.json'));
|
|
20
20
|
};
|
|
21
21
|
export const loadObject = (options, lockfileData) => {
|
|
22
|
-
const { mainManifest,
|
|
22
|
+
const { mainManifest, scurry } = options;
|
|
23
23
|
const packageJson = options.packageJson ?? new PackageJson();
|
|
24
24
|
const monorepo = options.monorepo ??
|
|
25
25
|
Monorepo.maybeLoad(options.projectRoot, { packageJson, scurry });
|
|
26
|
-
const { catalog = {}, catalogs = {},
|
|
26
|
+
const { catalog = {}, catalogs = {}, 'scope-registries': scopeRegistries, registry, registries, 'git-hosts': gitHosts, 'git-host-archives': gitHostArchives,
|
|
27
27
|
/* c8 ignore next */
|
|
28
28
|
} = lockfileData.options ?? {};
|
|
29
29
|
// Optimize options merging - only create new objects when needed
|
|
@@ -50,33 +50,8 @@ export const loadObject = (options, lockfileData) => {
|
|
|
50
50
|
mainManifest,
|
|
51
51
|
monorepo,
|
|
52
52
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// recalculate the graph - useful for refreshing an ideal graph when
|
|
56
|
-
// modifiers are swapped.
|
|
57
|
-
// Optimize modifier comparison - avoid JSON.stringify for simple cases
|
|
58
|
-
let modifiersChanged = false;
|
|
59
|
-
if (skipLoadingNodesOnModifiersChange) {
|
|
60
|
-
const lockfileConfig = modifiersLockfileConfig ?? {};
|
|
61
|
-
const optionsConfig = modifiers?.config ?? {};
|
|
62
|
-
// Quick check for obvious differences
|
|
63
|
-
const lockfileKeys = Object.keys(lockfileConfig);
|
|
64
|
-
const optionsKeys = Object.keys(optionsConfig);
|
|
65
|
-
if (lockfileKeys.length !== optionsKeys.length) {
|
|
66
|
-
modifiersChanged = true;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
// Only use JSON.stringify if we need deep comparison
|
|
70
|
-
const lockfileModifiers = JSON.stringify(lockfileConfig);
|
|
71
|
-
const optionsModifiers = JSON.stringify(optionsConfig);
|
|
72
|
-
modifiersChanged = lockfileModifiers !== optionsModifiers;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const shouldLoadDependencies = !(skipLoadingNodesOnModifiersChange && modifiersChanged);
|
|
76
|
-
if (shouldLoadDependencies) {
|
|
77
|
-
loadNodes(graph, lockfileData.nodes, mergedOptions, options.actual, options.throwOnMissingManifest);
|
|
78
|
-
loadEdges(graph, lockfileData.edges, mergedOptions);
|
|
79
|
-
}
|
|
53
|
+
loadNodes(graph, lockfileData.nodes, mergedOptions, options.actual, options.throwOnMissingManifest);
|
|
54
|
+
loadEdges(graph, lockfileData.edges, mergedOptions);
|
|
80
55
|
// hydrate missing node-level registry data
|
|
81
56
|
for (const node of graph.nodes.values()) {
|
|
82
57
|
const [firstEdge] = node.edgesIn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/lockfile/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/lockfile/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AA0CnC,MAAM,YAAY,GAAG,CAAC,WAAmB,EAAE,YAAoB,EAAE,EAAE,CACjE,IAAI,CAAC,KAAK,CACR,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,YAAY,CAAC,EAAE;IAC/C,QAAQ,EAAE,MAAM;CACjB,CAAC,CACa,CAAA;AAEnB,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,OAAoB,EAAS,EAAE;IAClD,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAA;IAC/B,OAAO,UAAU,CACf,OAAO,EACP,YAAY,CAAC,WAAW,EAAE,eAAe,CAAC,CAC3C,CAAA;AACH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;YAC1C,CAAC,CAAC,OAAO,CAAC,UAAU;QACtB,WAAW,EACT,QAAQ,CAAC,CAAC;YACR,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,EAAE,GAAG,QAAQ,EAAE;YAC1C,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;QACxB,mBAAmB,EACjB,eAAe,CAAC,CAAC;YACf,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,EAAE,GAAG,eAAe,EAAE;YACzD,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC;KACjC,CAAA;IACD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC;QACtB,GAAG,aAAa;QAChB,YAAY;QACZ,QAAQ;KACT,CAAC,CAAA;IACF,SAAS,CACP,KAAK,EACL,YAAY,CAAC,KAAK,EAClB,aAAa,EACb,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,sBAAsB,CAC/B,CAAA;IACD,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,aAAa,CAAC,CAAA;IAEnD,2CAA2C;IAC3C,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QACxC,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,OAAO,CAAA;QAChC,IAAI,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAA;QACzC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { PackageJson } from '@vltpkg/package-json'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { loadEdges } from './load-edges.ts'\nimport { loadNodes } from './load-nodes.ts'\nimport { Graph } from '../graph.ts'\nimport type { PathScurry } from 'path-scurry'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { LockfileData } from './types.ts'\nimport type { GraphModifier } from '../modifiers.ts'\n\nexport type LoadOptions = SpecOptions & {\n /**\n * An optional {@link Graph} object to hydrate extra data from.\n */\n actual?: Graph\n /**\n * The project root dirname.\n */\n projectRoot: string\n /**\n * The project root manifest.\n */\n mainManifest: NormalizedManifest\n /**\n * The graph modifiers helper object.\n */\n modifiers?: GraphModifier\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * A {@link PackageJson} object, for sharing manifest caches\n */\n packageJson?: PackageJson\n /**\n * A {@link PathScurry} object, for use in globs\n */\n scurry?: PathScurry\n /**\n * Whether to throw an error if a manifest is missing when loading nodes.\n */\n throwOnMissingManifest?: boolean\n}\n\nconst loadLockfile = (projectRoot: string, lockfilePath: string) =>\n JSON.parse(\n readFileSync(resolve(projectRoot, lockfilePath), {\n encoding: 'utf8',\n }),\n ) as LockfileData\n\nexport const load = (options: LoadOptions): Graph => {\n const { projectRoot } = options\n return loadObject(\n options,\n loadLockfile(projectRoot, 'vlt-lock.json'),\n )\n}\n\nexport const loadHidden = (options: LoadOptions): Graph => {\n const { projectRoot } = options\n // Ensure that missing manifests throw an error when loading hidden lockfiles\n options.throwOnMissingManifest = true\n return loadObject(\n options,\n loadLockfile(projectRoot, 'node_modules/.vlt-lock.json'),\n )\n}\n\nexport const loadObject = (\n options: LoadOptions,\n lockfileData: Omit<LockfileData, 'options' | 'lockfileVersion'> &\n Partial<Pick<LockfileData, 'options' | 'lockfileVersion'>>,\n) => {\n const { mainManifest, scurry } = options\n const packageJson = options.packageJson ?? new PackageJson()\n const monorepo =\n options.monorepo ??\n Monorepo.maybeLoad(options.projectRoot, { packageJson, scurry })\n const {\n catalog = {},\n catalogs = {},\n 'scope-registries': scopeRegistries,\n registry,\n registries,\n 'git-hosts': gitHosts,\n 'git-host-archives': gitHostArchives,\n /* c8 ignore next */\n } = lockfileData.options ?? {}\n\n // Optimize options merging - only create new objects when needed\n const mergedOptions = {\n ...options,\n catalog,\n catalogs,\n 'scope-registries':\n scopeRegistries ?\n { ...options['scope-registries'], ...scopeRegistries }\n : options['scope-registries'],\n registry: registry ?? options.registry,\n registries:\n registries ?\n { ...options.registries, ...registries }\n : options.registries,\n 'git-hosts':\n gitHosts ?\n { ...options['git-hosts'], ...gitHosts }\n : options['git-hosts'],\n 'git-host-archives':\n gitHostArchives ?\n { ...options['git-host-archives'], ...gitHostArchives }\n : options['git-host-archives'],\n }\n const graph = new Graph({\n ...mergedOptions,\n mainManifest,\n monorepo,\n })\n loadNodes(\n graph,\n lockfileData.nodes,\n mergedOptions,\n options.actual,\n options.throwOnMissingManifest,\n )\n loadEdges(graph, lockfileData.edges, mergedOptions)\n\n // hydrate missing node-level registry data\n for (const node of graph.nodes.values()) {\n const [firstEdge] = node.edgesIn\n if (firstEdge?.spec.registry) {\n node.registry = firstEdge.spec.registry\n }\n }\n\n return graph\n}\n"]}
|
package/dist/esm/node.d.ts
CHANGED
|
@@ -134,6 +134,19 @@ export declare class Node implements NodeLike {
|
|
|
134
134
|
* - 'failed': Node build has failed
|
|
135
135
|
*/
|
|
136
136
|
buildState: 'none' | 'needed' | 'built' | 'failed';
|
|
137
|
+
/**
|
|
138
|
+
* Deterministic unique string used to identify (and ultimately duplicate)
|
|
139
|
+
* nodes that are affected by a peer context set modified resolution.
|
|
140
|
+
* These are appended to the node {@link DepID} as the `extra` suffix.
|
|
141
|
+
*/
|
|
142
|
+
peerSetHash?: string;
|
|
143
|
+
/**
|
|
144
|
+
* True if this node is detached from the graph.
|
|
145
|
+
* This is used to indicate that the node is not part of the graph
|
|
146
|
+
* although the node is still available as part of the resolution process.
|
|
147
|
+
* Allows for skipping fetching manifests for detached nodes.
|
|
148
|
+
*/
|
|
149
|
+
detached: boolean;
|
|
137
150
|
/**
|
|
138
151
|
* The file system location for this node.
|
|
139
152
|
*/
|
|
@@ -192,6 +205,7 @@ export declare class Node implements NodeLike {
|
|
|
192
205
|
maybeSetConfusedManifest(spec: Spec, confused?: NormalizedManifest): void;
|
|
193
206
|
toJSON(): {
|
|
194
207
|
rawManifest?: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
|
|
208
|
+
peerSetHash?: string | undefined;
|
|
195
209
|
id: DepID;
|
|
196
210
|
name: string;
|
|
197
211
|
version: string | undefined;
|
package/dist/esm/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAO7C,OAAO,KAAK,EAAE,KAAK,EAAc,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAErD,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,QAAQ,EACT,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAKvC,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,SAAS,CAAA;CACjB,CAAA;AAED,qBAAa,IAAK,YAAW,QAAQ;;IACnC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;IAOD;;;;;;OAMG;IACH,IAAI,QAAQ,IAGW,OAAO,CAD7B;IACD,IAAI,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAS7B;IAED,UAAU,IAAI,IAAI,IAAI,IAAI,GAAG;QAAE,QAAQ,EAAE,IAAI,CAAA;KAAE;IAK/C;;;;;OAKG;IACH,IAAI,GAAG,IAGM,OAAO,CADnB;IACD,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,EASnB;IAED,KAAK,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ACb,OAAO,CAAC,EAAE,MAAM;IAwBlB;;;;OAIG;IACH,UAAU,IAAI,OAAO;IAkBrB,IAAI,OAAO,IAKQ,WAAW,CAH7B;IAGD,IAAI,OAAO,CAAC,KAAK,EAAE,WAAW,EAAI;IAElC,MAAM,CAAC,KAAK,EAAE,IAAI;IAIlB;;OAEG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM;IAKpC;;;;OAIG;IACH,WAAW;IAgBX,kBAAkB;IAclB;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI;IAO7D;;;OAGG;IACH,IAAI,WAAW,IAAI,kBAAkB,GAAG,SAAS,CAEhD;IAED;;OAEG;IACH,mBAAmB,CACjB,KAAK,EAAE,kBAAkB,EACzB,QAAQ,CAAC,EAAE,kBAAkB;IAQ/B;;OAEG;IACH,wBAAwB,CACtB,IAAI,EAAE,IAAI,EACV,QAAQ,CAAC,EAAE,kBAAkB;IAa/B,MAAM;;;;;;;;;;;;;;;;;sBA9OM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;iBAC3B,MAAM,EAAE,GAAG,MAAM;kBAChB,MAAM,EAAE,GAAG,MAAM;;;;IAwQzB,QAAQ;CAGT;AAED,eAAO,MAAM,MAAM,UAAW,OAAO,KAAG,KAAK,IAAI,IAQhD,CAAA;AAED,eAAO,MAAM,MAAM,UAAW,OAAO,KAAG,IAKvC,CAAA"}
|
package/dist/esm/node.js
CHANGED
|
@@ -167,6 +167,19 @@ export class Node {
|
|
|
167
167
|
* - 'failed': Node build has failed
|
|
168
168
|
*/
|
|
169
169
|
buildState = 'none';
|
|
170
|
+
/**
|
|
171
|
+
* Deterministic unique string used to identify (and ultimately duplicate)
|
|
172
|
+
* nodes that are affected by a peer context set modified resolution.
|
|
173
|
+
* These are appended to the node {@link DepID} as the `extra` suffix.
|
|
174
|
+
*/
|
|
175
|
+
peerSetHash;
|
|
176
|
+
/**
|
|
177
|
+
* True if this node is detached from the graph.
|
|
178
|
+
* This is used to indicate that the node is not part of the graph
|
|
179
|
+
* although the node is still available as part of the resolution process.
|
|
180
|
+
* Allows for skipping fetching manifests for detached nodes.
|
|
181
|
+
*/
|
|
182
|
+
detached = false;
|
|
170
183
|
/**
|
|
171
184
|
* The file system location for this node.
|
|
172
185
|
*/
|
|
@@ -343,6 +356,9 @@ export class Node {
|
|
|
343
356
|
modifier: this.modifier,
|
|
344
357
|
platform: this.platform,
|
|
345
358
|
buildState: this.buildState,
|
|
359
|
+
...(this.peerSetHash ?
|
|
360
|
+
{ peerSetHash: this.peerSetHash }
|
|
361
|
+
: undefined),
|
|
346
362
|
...(this.confused ?
|
|
347
363
|
{ rawManifest: this.#rawManifest }
|
|
348
364
|
: undefined),
|
package/dist/esm/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,YAAY,EACZ,UAAU,GACX,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAA;AAQ/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AASnD,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,QAAQ,CAAa;IACrB,SAAS,CAAS;IAClB,YAAY,CAAqB;IAEjC,SAAS,GAAG,KAAK,CAAA;IACjB;;;;;;OAMG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IACD,IAAI,QAAQ,CAAC,QAAiB;QAC5B,MAAM,MAAM,GAAG,IAA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AC,SAAS,CAAC;SACb,CAAA;IACH,CAAC;IAED,QAAQ;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE;IACtD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,IAAI,IAAI;QACb,IAAI,IAAI,KAAK;QACb,UAAU,IAAI,KAAK;QAClB,KAAc,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,oBAAoB,CAC7D,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAQ,EAAE;IAC7C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,MAAM,SAAS,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IACtD,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { PathScurry } from 'path-scurry'\nimport {\n isPackageNameConfused,\n getId,\n hydrateTuple,\n splitDepID,\n} from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { typeError } from '@vltpkg/error-cause'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport { expandNormalizedManifestSymbols } from '@vltpkg/types'\nimport type {\n Integrity,\n NormalizedManifest,\n DependencyTypeShort,\n GraphLike,\n NodeLike,\n} from '@vltpkg/types'\nimport { Edge } from './edge.ts'\nimport type { Graph } from './graph.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { GraphModifier } from './modifiers.ts'\n\nexport type NodeOptions = SpecOptions & {\n projectRoot: string\n graph: GraphLike\n}\n\nexport class Node implements NodeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Node'\n }\n\n #options: SpecOptions\n #location?: string\n #rawManifest?: NormalizedManifest\n\n #optional = false\n /**\n * True if a node is only reachable via optional or peerOptional edges from\n * any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any optional-flagged non-optional dependencies.\n */\n get optional() {\n return this.#optional\n }\n set optional(optional: boolean) {\n const before = this.#optional\n this.#optional = optional\n if (before && !optional) {\n // unset for all deps, as well\n for (const { to, optional } of this.edgesOut.values()) {\n if (!optional && to?.optional) to.optional = false\n }\n }\n }\n\n isOptional(): this is Node & { optional: true } {\n return this.#optional\n }\n\n #dev = false\n /**\n * True if a node is only reachable via dev edges from any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any dev-flagged non-dev dependencies.\n */\n get dev() {\n return this.#dev\n }\n set dev(dev: boolean) {\n const before = this.#dev\n this.#dev = dev\n if (before && !dev) {\n // unset for all deps, as well\n for (const { to, dev } of this.edgesOut.values()) {\n if (!dev && to?.dev) to.dev = false\n }\n }\n }\n\n isDev(): this is Node & { dev: true } {\n return this.#dev\n }\n\n /**\n * True if there's a manifest-confused package name.\n */\n confused = false\n\n /**\n * True if this node has been extracted to the file system.\n */\n extracted = false\n\n /**\n * List of edges coming into this node.\n */\n edgesIn = new Set<Edge>()\n\n /**\n * List of edges from this node into other nodes. This usually represents\n * that the connected node is a direct dependency of this node.\n */\n edgesOut = new Map<string, Edge>()\n\n /**\n * A `mainImporter` node may have workspace connected to it,\n * equivalent to its `edgesOut` linked deps.\n */\n workspaces: Map<string, Edge> | undefined\n\n /**\n * A reference to the {@link DepID} this node represents in the graph.\n */\n id: DepID\n\n /**\n * True if this node is an importer node.\n */\n importer = false\n\n /**\n * True if this node is the project root node.\n */\n mainImporter = false\n\n /**\n * A reference to the graph this node is a part of.\n */\n graph: Graph\n\n /**\n * The manifest integrity value.\n */\n integrity?: Integrity\n\n /**\n * The manifest this node represents in the graph.\n */\n manifest?: NormalizedManifest\n\n /**\n * Project where this node resides\n */\n projectRoot: string\n\n /**\n * For registry nodes, this is the registry we fetched them from.\n * Needed because their un-prefixed dependencies need to come from\n * the same registry, if it's not the default.\n */\n registry?: string\n\n /**\n * If this node has been modified as part of applying a {@link GraphModifier}\n * then this field will contain the modifier query that was applied.\n * Otherwise, it will be `undefined`.\n */\n modifier: string | undefined\n\n /**\n * The name of the package represented by this node, this is usually\n * equivalent to `manifest.name` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package names instead.\n */\n #name?: string\n get name() {\n if (this.#name) return this.#name\n this.#name = this.id\n return this.#name\n }\n\n /**\n * The version of the package represented by this node, this is usually\n * equivalent to `manifest.version` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package versions instead.\n */\n version?: string\n\n /**\n * An address {@link PackageInfoClient} may use to extract this package.\n */\n resolved?: string\n\n /**\n * Platform requirements (engines, os, cpu) extracted from manifest.\n * Stored separately for optional dependencies to enable platform checks\n * when manifest is not loaded.\n */\n platform?: {\n engines?: Record<string, string>\n os?: string[] | string\n cpu?: string[] | string\n }\n\n /**\n * Record of binary names to their paths in the package, if any.\n */\n bins?: Record<string, string>\n\n /**\n * True if this node has been built as part of the reify step.\n */\n built = false\n\n /**\n * Build state of this node - tracks whether it needs building, has been built, or failed.\n * - 'none': No build state (default)\n * - 'needed': Node needs to be built\n * - 'built': Node has been successfully built\n * - 'failed': Node build has failed\n */\n buildState: 'none' | 'needed' | 'built' | 'failed' = 'none'\n\n /**\n * The file system location for this node.\n */\n get location(): string {\n if (this.#location) {\n return this.#location\n }\n this.#location = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n // if using the default location, it is in the store\n this.inVltStore = () => true\n return this.#location\n }\n\n set location(location: string) {\n this.#location = location\n // reset memoization, since it might be elsewhere now\n if (this.inVltStore !== Node.prototype.inVltStore) {\n this.inVltStore = Node.prototype.inVltStore\n }\n }\n\n /**\n * The resolved location of the node in the file system.\n */\n resolvedLocation(scurry: PathScurry): string {\n return scurry.cwd.resolve(this.location).fullpath()\n }\n\n /**\n * The location of the node_modules folder where this node's edgesOut\n * should be linked into. For nodes in the store, this is the parent\n * directory, since they're extracted into a node_modules folder\n * side by side with links to their deps. For nodes outside of the store\n * (ie, importers and arbitrary link deps) this is the node_modules folder\n * directly inside the node's directory.\n */\n nodeModules(scurry: PathScurry): string {\n const loc = this.resolvedLocation(scurry)\n return this.inVltStore() ?\n loc.substring(0, loc.length - this.name.length - 1)\n : scurry.resolve(loc, 'node_modules')\n }\n\n constructor(\n options: NodeOptions,\n id?: DepID,\n manifest?: NormalizedManifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n this.#options = options\n this.projectRoot = options.projectRoot\n if (id) {\n this.id = id\n } else {\n if (!manifest || !spec) {\n throw typeError(\n 'A new Node needs either a manifest & spec or an id parameter',\n {\n manifest,\n },\n )\n }\n this.id = getId(spec, manifest)\n }\n this.graph = options.graph as Graph\n this.manifest = manifest\n\n this.#name = name || this.manifest?.name\n this.version = version || this.manifest?.version\n }\n\n /**\n * return true if this node is located in the vlt store\n * memoized the first time it's called, since the store location\n * doesn't change within the context of a single operation.\n */\n inVltStore(): boolean {\n // technically this just means it's in *a* vlt store, but we can safely\n // assume that a user won't construct a path like this by accident,\n // and there's only ever one store in any given project.\n const inStore = this.location.endsWith(\n `.vlt/${this.id}/node_modules/${this.name}`,\n )\n this.inVltStore = () => inStore\n return inStore\n }\n\n #registryNodeResolved(tuple: DepIDTuple) {\n const spec = hydrateTuple(tuple, this.#name, this.#options)\n this.resolved =\n this.manifest?.dist?.tarball || spec.conventionalRegistryTarball\n this.integrity ??= this.manifest?.dist?.integrity\n }\n\n get options() {\n return this.#options\n }\n\n /* c8 ignore next */\n set options(_opts: SpecOptions) {}\n\n equals(other: Node) {\n return this.id === other.id && this.location === other.location\n }\n\n /**\n * Sets the node as an importer along with its location.\n */\n setImporterLocation(location: string) {\n this.#location = location\n this.importer = true\n }\n\n /**\n * Sets the appropriate resolve / integrity value for this node.\n * Note that other places might also set these values, like for\n * example the lockfile that might have already have this info.\n */\n setResolved() {\n // file | remote | workspace type of ids all points to a URI that\n // can be used as the `resolved` value, so we split the dep id\n // for these cases.\n const tuple = splitDepID(this.id)\n const [type, resolved] = tuple\n switch (type) {\n case 'registry':\n this.#registryNodeResolved(tuple)\n break\n default:\n this.resolved = resolved\n break\n }\n }\n\n setDefaultLocation() {\n const def = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n\n // only relocate if the location is in node_modules already\n if (\n !this.importer &&\n (!this.#location ||\n (this.#location !== def &&\n /^(?:\\.\\/)?node_modules\\//.test(this.#location)))\n ) {\n this.#location = def\n }\n }\n\n /**\n * Add an edge from this node connecting it to a direct dependency.\n */\n addEdgesTo(type: DependencyTypeShort, spec: Spec, node?: Node) {\n const edge = new Edge(type, spec, this, node)\n node?.edgesIn.add(edge)\n this.edgesOut.set(spec.name, edge)\n return edge\n }\n\n /**\n * The raw manifest before any modifications.\n * If not set, falls back to the current manifest.\n */\n get rawManifest(): NormalizedManifest | undefined {\n return this.#rawManifest ?? this.manifest\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n setConfusedManifest(\n fixed: NormalizedManifest,\n confused?: NormalizedManifest,\n ) {\n this.manifest = fixed\n this.#rawManifest = confused\n this.confused = true\n this.#name = this.manifest.name\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n maybeSetConfusedManifest(\n spec: Spec,\n confused?: NormalizedManifest,\n ) {\n if (isPackageNameConfused(spec, this.manifest?.name)) {\n this.setConfusedManifest(\n {\n ...this.manifest,\n name: spec.name,\n },\n confused,\n )\n }\n }\n\n toJSON() {\n return {\n id: this.id,\n name: this.name,\n version: this.version,\n location: this.location,\n importer: this.importer,\n manifest:\n this.manifest &&\n expandNormalizedManifestSymbols(this.manifest),\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n confused: this.confused,\n modifier: this.modifier,\n platform: this.platform,\n buildState: this.buildState,\n ...(this.confused ?\n { rawManifest: this.#rawManifest }\n : undefined),\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n\nexport const isNode = (value: unknown): value is Node => {\n return (\n typeof value === 'object' &&\n value != null &&\n 'id' in value &&\n 'manifest' in value &&\n (value as Node)[Symbol.toStringTag] === '@vltpkg/graph.Node'\n )\n}\n\nexport const asNode = (value: unknown): Node => {\n if (!isNode(value)) {\n throw typeError('Expected a node', { found: value })\n }\n return value\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,YAAY,EACZ,UAAU,GACX,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAA;AAQ/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AASnD,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,QAAQ,CAAa;IACrB,SAAS,CAAS;IAClB,YAAY,CAAqB;IAEjC,SAAS,GAAG,KAAK,CAAA;IACjB;;;;;;OAMG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IACD,IAAI,QAAQ,CAAC,QAAiB;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACxB,8BAA8B;YAC9B,KAAK,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC,QAAQ,IAAI,EAAE,E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a,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE;IACtD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,IAAI,IAAI;QACb,IAAI,IAAI,KAAK;QACb,UAAU,IAAI,KAAK;QAClB,KAAc,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,oBAAoB,CAC7D,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAQ,EAAE;IAC7C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,MAAM,SAAS,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IACtD,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { PathScurry } from 'path-scurry'\nimport {\n isPackageNameConfused,\n getId,\n hydrateTuple,\n splitDepID,\n} from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { typeError } from '@vltpkg/error-cause'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport { expandNormalizedManifestSymbols } from '@vltpkg/types'\nimport type {\n Integrity,\n NormalizedManifest,\n DependencyTypeShort,\n GraphLike,\n NodeLike,\n} from '@vltpkg/types'\nimport { Edge } from './edge.ts'\nimport type { Graph } from './graph.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { GraphModifier } from './modifiers.ts'\n\nexport type NodeOptions = SpecOptions & {\n projectRoot: string\n graph: GraphLike\n}\n\nexport class Node implements NodeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Node'\n }\n\n #options: SpecOptions\n #location?: string\n #rawManifest?: NormalizedManifest\n\n #optional = false\n /**\n * True if a node is only reachable via optional or peerOptional edges from\n * any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any optional-flagged non-optional dependencies.\n */\n get optional() {\n return this.#optional\n }\n set optional(optional: boolean) {\n const before = this.#optional\n this.#optional = optional\n if (before && !optional) {\n // unset for all deps, as well\n for (const { to, optional } of this.edgesOut.values()) {\n if (!optional && to?.optional) to.optional = false\n }\n }\n }\n\n isOptional(): this is Node & { optional: true } {\n return this.#optional\n }\n\n #dev = false\n /**\n * True if a node is only reachable via dev edges from any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any dev-flagged non-dev dependencies.\n */\n get dev() {\n return this.#dev\n }\n set dev(dev: boolean) {\n const before = this.#dev\n this.#dev = dev\n if (before && !dev) {\n // unset for all deps, as well\n for (const { to, dev } of this.edgesOut.values()) {\n if (!dev && to?.dev) to.dev = false\n }\n }\n }\n\n isDev(): this is Node & { dev: true } {\n return this.#dev\n }\n\n /**\n * True if there's a manifest-confused package name.\n */\n confused = false\n\n /**\n * True if this node has been extracted to the file system.\n */\n extracted = false\n\n /**\n * List of edges coming into this node.\n */\n edgesIn = new Set<Edge>()\n\n /**\n * List of edges from this node into other nodes. This usually represents\n * that the connected node is a direct dependency of this node.\n */\n edgesOut = new Map<string, Edge>()\n\n /**\n * A `mainImporter` node may have workspace connected to it,\n * equivalent to its `edgesOut` linked deps.\n */\n workspaces: Map<string, Edge> | undefined\n\n /**\n * A reference to the {@link DepID} this node represents in the graph.\n */\n id: DepID\n\n /**\n * True if this node is an importer node.\n */\n importer = false\n\n /**\n * True if this node is the project root node.\n */\n mainImporter = false\n\n /**\n * A reference to the graph this node is a part of.\n */\n graph: Graph\n\n /**\n * The manifest integrity value.\n */\n integrity?: Integrity\n\n /**\n * The manifest this node represents in the graph.\n */\n manifest?: NormalizedManifest\n\n /**\n * Project where this node resides\n */\n projectRoot: string\n\n /**\n * For registry nodes, this is the registry we fetched them from.\n * Needed because their un-prefixed dependencies need to come from\n * the same registry, if it's not the default.\n */\n registry?: string\n\n /**\n * If this node has been modified as part of applying a {@link GraphModifier}\n * then this field will contain the modifier query that was applied.\n * Otherwise, it will be `undefined`.\n */\n modifier: string | undefined\n\n /**\n * The name of the package represented by this node, this is usually\n * equivalent to `manifest.name` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package names instead.\n */\n #name?: string\n get name() {\n if (this.#name) return this.#name\n this.#name = this.id\n return this.#name\n }\n\n /**\n * The version of the package represented by this node, this is usually\n * equivalent to `manifest.version` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package versions instead.\n */\n version?: string\n\n /**\n * An address {@link PackageInfoClient} may use to extract this package.\n */\n resolved?: string\n\n /**\n * Platform requirements (engines, os, cpu) extracted from manifest.\n * Stored separately for optional dependencies to enable platform checks\n * when manifest is not loaded.\n */\n platform?: {\n engines?: Record<string, string>\n os?: string[] | string\n cpu?: string[] | string\n }\n\n /**\n * Record of binary names to their paths in the package, if any.\n */\n bins?: Record<string, string>\n\n /**\n * True if this node has been built as part of the reify step.\n */\n built = false\n\n /**\n * Build state of this node - tracks whether it needs building, has been built, or failed.\n * - 'none': No build state (default)\n * - 'needed': Node needs to be built\n * - 'built': Node has been successfully built\n * - 'failed': Node build has failed\n */\n buildState: 'none' | 'needed' | 'built' | 'failed' = 'none'\n\n /**\n * Deterministic unique string used to identify (and ultimately duplicate)\n * nodes that are affected by a peer context set modified resolution.\n * These are appended to the node {@link DepID} as the `extra` suffix.\n */\n peerSetHash?: string\n\n /**\n * True if this node is detached from the graph.\n * This is used to indicate that the node is not part of the graph\n * although the node is still available as part of the resolution process.\n * Allows for skipping fetching manifests for detached nodes.\n */\n detached = false\n\n /**\n * The file system location for this node.\n */\n get location(): string {\n if (this.#location) {\n return this.#location\n }\n this.#location = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n // if using the default location, it is in the store\n this.inVltStore = () => true\n return this.#location\n }\n\n set location(location: string) {\n this.#location = location\n // reset memoization, since it might be elsewhere now\n if (this.inVltStore !== Node.prototype.inVltStore) {\n this.inVltStore = Node.prototype.inVltStore\n }\n }\n\n /**\n * The resolved location of the node in the file system.\n */\n resolvedLocation(scurry: PathScurry): string {\n return scurry.cwd.resolve(this.location).fullpath()\n }\n\n /**\n * The location of the node_modules folder where this node's edgesOut\n * should be linked into. For nodes in the store, this is the parent\n * directory, since they're extracted into a node_modules folder\n * side by side with links to their deps. For nodes outside of the store\n * (ie, importers and arbitrary link deps) this is the node_modules folder\n * directly inside the node's directory.\n */\n nodeModules(scurry: PathScurry): string {\n const loc = this.resolvedLocation(scurry)\n return this.inVltStore() ?\n loc.substring(0, loc.length - this.name.length - 1)\n : scurry.resolve(loc, 'node_modules')\n }\n\n constructor(\n options: NodeOptions,\n id?: DepID,\n manifest?: NormalizedManifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n this.#options = options\n this.projectRoot = options.projectRoot\n if (id) {\n this.id = id\n } else {\n if (!manifest || !spec) {\n throw typeError(\n 'A new Node needs either a manifest & spec or an id parameter',\n {\n manifest,\n },\n )\n }\n this.id = getId(spec, manifest)\n }\n this.graph = options.graph as Graph\n this.manifest = manifest\n\n this.#name = name || this.manifest?.name\n this.version = version || this.manifest?.version\n }\n\n /**\n * return true if this node is located in the vlt store\n * memoized the first time it's called, since the store location\n * doesn't change within the context of a single operation.\n */\n inVltStore(): boolean {\n // technically this just means it's in *a* vlt store, but we can safely\n // assume that a user won't construct a path like this by accident,\n // and there's only ever one store in any given project.\n const inStore = this.location.endsWith(\n `.vlt/${this.id}/node_modules/${this.name}`,\n )\n this.inVltStore = () => inStore\n return inStore\n }\n\n #registryNodeResolved(tuple: DepIDTuple) {\n const spec = hydrateTuple(tuple, this.#name, this.#options)\n this.resolved =\n this.manifest?.dist?.tarball || spec.conventionalRegistryTarball\n this.integrity ??= this.manifest?.dist?.integrity\n }\n\n get options() {\n return this.#options\n }\n\n /* c8 ignore next */\n set options(_opts: SpecOptions) {}\n\n equals(other: Node) {\n return this.id === other.id && this.location === other.location\n }\n\n /**\n * Sets the node as an importer along with its location.\n */\n setImporterLocation(location: string) {\n this.#location = location\n this.importer = true\n }\n\n /**\n * Sets the appropriate resolve / integrity value for this node.\n * Note that other places might also set these values, like for\n * example the lockfile that might have already have this info.\n */\n setResolved() {\n // file | remote | workspace type of ids all points to a URI that\n // can be used as the `resolved` value, so we split the dep id\n // for these cases.\n const tuple = splitDepID(this.id)\n const [type, resolved] = tuple\n switch (type) {\n case 'registry':\n this.#registryNodeResolved(tuple)\n break\n default:\n this.resolved = resolved\n break\n }\n }\n\n setDefaultLocation() {\n const def = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n\n // only relocate if the location is in node_modules already\n if (\n !this.importer &&\n (!this.#location ||\n (this.#location !== def &&\n /^(?:\\.\\/)?node_modules\\//.test(this.#location)))\n ) {\n this.#location = def\n }\n }\n\n /**\n * Add an edge from this node connecting it to a direct dependency.\n */\n addEdgesTo(type: DependencyTypeShort, spec: Spec, node?: Node) {\n const edge = new Edge(type, spec, this, node)\n node?.edgesIn.add(edge)\n this.edgesOut.set(spec.name, edge)\n return edge\n }\n\n /**\n * The raw manifest before any modifications.\n * If not set, falls back to the current manifest.\n */\n get rawManifest(): NormalizedManifest | undefined {\n return this.#rawManifest ?? this.manifest\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n setConfusedManifest(\n fixed: NormalizedManifest,\n confused?: NormalizedManifest,\n ) {\n this.manifest = fixed\n this.#rawManifest = confused\n this.confused = true\n this.#name = this.manifest.name\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n maybeSetConfusedManifest(\n spec: Spec,\n confused?: NormalizedManifest,\n ) {\n if (isPackageNameConfused(spec, this.manifest?.name)) {\n this.setConfusedManifest(\n {\n ...this.manifest,\n name: spec.name,\n },\n confused,\n )\n }\n }\n\n toJSON() {\n return {\n id: this.id,\n name: this.name,\n version: this.version,\n location: this.location,\n importer: this.importer,\n manifest:\n this.manifest &&\n expandNormalizedManifestSymbols(this.manifest),\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n confused: this.confused,\n modifier: this.modifier,\n platform: this.platform,\n buildState: this.buildState,\n ...(this.peerSetHash ?\n { peerSetHash: this.peerSetHash }\n : undefined),\n ...(this.confused ?\n { rawManifest: this.#rawManifest }\n : undefined),\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n\nexport const isNode = (value: unknown): value is Node => {\n return (\n typeof value === 'object' &&\n value != null &&\n 'id' in value &&\n 'manifest' in value &&\n (value as Node)[Symbol.toStringTag] === '@vltpkg/graph.Node'\n )\n}\n\nexport const asNode = (value: unknown): Node => {\n if (!isNode(value)) {\n throw typeError('Expected a node', { found: value })\n }\n return value\n}\n"]}
|
|
@@ -32,10 +32,11 @@ export type JSONOutputItem = {
|
|
|
32
32
|
};
|
|
33
33
|
export type JSONOutputGraph = {
|
|
34
34
|
edges: EdgeLike[];
|
|
35
|
+
nodes: NodeLike[];
|
|
35
36
|
importers: Set<NodeLike>;
|
|
36
37
|
};
|
|
37
38
|
/**
|
|
38
39
|
* Returns a JSON string representation of the graph.
|
|
39
40
|
*/
|
|
40
|
-
export declare function jsonOutput({ edges, importers }: JSONOutputGraph): JSONOutputItem[];
|
|
41
|
+
export declare function jsonOutput({ edges, nodes, importers, }: JSONOutputGraph): JSONOutputItem[];
|
|
41
42
|
//# sourceMappingURL=json-output.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-output.d.ts","sourceRoot":"","sources":["../../../src/visualization/json-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAEvD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,MAAM,CAAC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|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns a JSON string representation of the graph.
|
|
3
3
|
*/
|
|
4
|
-
export function jsonOutput({ edges, importers }) {
|
|
4
|
+
export function jsonOutput({ edges, nodes, importers, }) {
|
|
5
5
|
const res = [];
|
|
6
6
|
const seenIds = new Set();
|
|
7
7
|
// Collects edge & it's linked nodes as json output items
|
|
@@ -37,7 +37,7 @@ export function jsonOutput({ edges, importers }) {
|
|
|
37
37
|
return a.name.localeCompare(b.name);
|
|
38
38
|
});
|
|
39
39
|
for (const node of orderedImporters) {
|
|
40
|
-
if (seenIds.has(node.id))
|
|
40
|
+
if (!nodes.includes(node) || seenIds.has(node.id))
|
|
41
41
|
continue;
|
|
42
42
|
res.unshift({
|
|
43
43
|
/* c8 ignore next - name can't be missing but ts won't know */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-output.js","sourceRoot":"","sources":["../../../src/visualization/json-output.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json-output.js","sourceRoot":"","sources":["../../../src/visualization/json-output.ts"],"names":[],"mappings":"AAwCA;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,KAAK,EACL,KAAK,EACL,SAAS,GACO;IAChB,MAAM,GAAG,GAAqB,EAAE,CAAA;IAChC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAS,CAAA;IAEhC,yDAAyD;IACzD,MAAM,YAAY,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAC5C,MAAM,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,CAAA;QAChD,MAAM,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW,CAAA;QAChD,IAAI,YAAY,IAAI,CAAC,YAAY;YAAE,OAAO,CAAC,CAAC,CAAA;QAC5C,oBAAoB;QACpB,IAAI,CAAC,Y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;YACR,UAAU,EAAE,KAAK;SAClB,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport type { EdgeLike, NodeLike } from '@vltpkg/types'\n\n/**\n * A JSON output item describes a package that is present in the install\n * graph. It represents an edge plus it's linking Node.\n */\nexport type JSONOutputItem = {\n /**\n * The name of the package.\n */\n name: string\n /**\n * A reference to the id of the Node that this package is linked from.\n */\n fromID?: DepID\n /**\n * The dependency spec definition for this package.\n */\n spec?: string\n /**\n * The package type.\n */\n type?: EdgeLike['type']\n /**\n * A representation of the package object that fulfills this dependency.\n */\n to?: NodeLike\n /**\n * Whether this edge was overridden by a graph modifier.\n */\n overridden: boolean\n}\n\nexport type JSONOutputGraph = {\n edges: EdgeLike[]\n nodes: NodeLike[]\n importers: Set<NodeLike>\n}\n\n/**\n * Returns a JSON string representation of the graph.\n */\nexport function jsonOutput({\n edges,\n nodes,\n importers,\n}: JSONOutputGraph) {\n const res: JSONOutputItem[] = []\n const seenIds = new Set<DepID>()\n\n // Collects edge & it's linked nodes as json output items\n const orderedEdges = [...edges].sort((a, b) => {\n const aIsWorkspace = a.spec.type === 'workspace'\n const bIsWorkspace = b.spec.type === 'workspace'\n if (aIsWorkspace && !bIsWorkspace) return -1\n /* c8 ignore next */\n if (!aIsWorkspace && bIsWorkspace) return 1\n return 0 // preserve original order otherwise\n })\n for (const edge of orderedEdges) {\n if (edge.to) seenIds.add(edge.to.id)\n res.push({\n name: edge.name,\n fromID: edge.from.id,\n spec: String(edge.spec),\n type: edge.type,\n to: edge.to,\n overridden: edge.spec.overridden,\n })\n }\n\n // Collects included importer nodes json output items\n /* c8 ignore next 3 */\n const orderedImporters = [...importers].sort((a, b) => {\n if (!a.name) return 1\n if (!b.name) return -1\n return a.name.localeCompare(b.name)\n })\n for (const node of orderedImporters) {\n if (!nodes.includes(node) || seenIds.has(node.id)) continue\n res.unshift({\n /* c8 ignore next - name can't be missing but ts won't know */\n name: node.name || node.id,\n to: node,\n overridden: false,\n })\n }\n\n return res\n}\n"]}
|