@vltpkg/graph 0.0.0-30 → 0.0.0-31
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 +5 -0
- package/dist/esm/actual/load.d.ts.map +1 -1
- package/dist/esm/actual/load.js +1 -0
- package/dist/esm/actual/load.js.map +1 -1
- package/dist/esm/build.d.ts +29 -0
- package/dist/esm/build.d.ts.map +1 -0
- package/dist/esm/build.js +79 -0
- package/dist/esm/build.js.map +1 -0
- package/dist/esm/diff.d.ts +62 -0
- package/dist/esm/diff.d.ts.map +1 -1
- package/dist/esm/diff.js +12 -0
- package/dist/esm/diff.js.map +1 -1
- package/dist/esm/edge.d.ts +6 -0
- package/dist/esm/edge.d.ts.map +1 -1
- package/dist/esm/edge.js +8 -0
- package/dist/esm/edge.js.map +1 -1
- package/dist/esm/ideal/add-nodes.d.ts +12 -2
- package/dist/esm/ideal/add-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/add-nodes.js +8 -2
- package/dist/esm/ideal/add-nodes.js.map +1 -1
- package/dist/esm/ideal/append-nodes.d.ts +3 -1
- package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/append-nodes.js +24 -3
- package/dist/esm/ideal/append-nodes.js.map +1 -1
- package/dist/esm/ideal/build.d.ts +5 -0
- package/dist/esm/ideal/build.d.ts.map +1 -1
- package/dist/esm/ideal/build.js +2 -1
- package/dist/esm/ideal/build.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/install.d.ts +7 -0
- package/dist/esm/install.d.ts.map +1 -1
- package/dist/esm/install.js +26 -2
- 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 +6 -2
- package/dist/esm/lockfile/load-nodes.js.map +1 -1
- package/dist/esm/lockfile/load.d.ts.map +1 -1
- package/dist/esm/lockfile/load.js +3 -1
- package/dist/esm/lockfile/load.js.map +1 -1
- package/dist/esm/lockfile/save.d.ts +6 -2
- package/dist/esm/lockfile/save.d.ts.map +1 -1
- package/dist/esm/lockfile/save.js +16 -5
- package/dist/esm/lockfile/save.js.map +1 -1
- package/dist/esm/lockfile/types.d.ts +17 -1
- package/dist/esm/lockfile/types.d.ts.map +1 -1
- package/dist/esm/lockfile/types.js +31 -0
- package/dist/esm/lockfile/types.js.map +1 -1
- package/dist/esm/node.d.ts +19 -1
- package/dist/esm/node.d.ts.map +1 -1
- package/dist/esm/node.js +17 -0
- package/dist/esm/node.js.map +1 -1
- package/dist/esm/reify/add-nodes.d.ts.map +1 -1
- package/dist/esm/reify/add-nodes.js +4 -29
- package/dist/esm/reify/add-nodes.js.map +1 -1
- package/dist/esm/reify/build.d.ts +10 -1
- package/dist/esm/reify/build.d.ts.map +1 -1
- package/dist/esm/reify/build.js +30 -4
- package/dist/esm/reify/build.js.map +1 -1
- package/dist/esm/reify/check-needed-build.d.ts +25 -0
- package/dist/esm/reify/check-needed-build.d.ts.map +1 -0
- package/dist/esm/reify/check-needed-build.js +50 -0
- package/dist/esm/reify/check-needed-build.js.map +1 -0
- package/dist/esm/reify/extract-node.d.ts +24 -0
- package/dist/esm/reify/extract-node.d.ts.map +1 -0
- package/dist/esm/reify/extract-node.js +76 -0
- package/dist/esm/reify/extract-node.js.map +1 -0
- package/dist/esm/reify/index.d.ts +16 -1
- package/dist/esm/reify/index.d.ts.map +1 -1
- package/dist/esm/reify/index.js +59 -12
- package/dist/esm/reify/index.js.map +1 -1
- package/dist/esm/transfer-data/load.d.ts.map +1 -1
- package/dist/esm/transfer-data/load.js.map +1 -1
- package/dist/esm/uninstall.d.ts +5 -1
- package/dist/esm/uninstall.d.ts.map +1 -1
- package/dist/esm/uninstall.js +51 -19
- package/dist/esm/uninstall.js.map +1 -1
- package/dist/esm/update.d.ts +2 -0
- package/dist/esm/update.d.ts.map +1 -1
- package/dist/esm/update.js +36 -22
- package/dist/esm/update.js.map +1 -1
- package/dist/esm/virtual-root.d.ts.map +1 -1
- package/dist/esm/virtual-root.js +1 -0
- package/dist/esm/virtual-root.js.map +1 -1
- package/package.json +21 -20
|
@@ -4,6 +4,7 @@ import { Spec } from '@vltpkg/spec';
|
|
|
4
4
|
import { longDependencyTypes, normalizeManifest } from '@vltpkg/types';
|
|
5
5
|
import { asDependency, shorten } from "../dependencies.js";
|
|
6
6
|
import { removeOptionalSubgraph } from "../remove-optional-subgraph.js";
|
|
7
|
+
import { extractNode } from "../reify/extract-node.js";
|
|
7
8
|
/**
|
|
8
9
|
* Only install devDeps for git dependencies and importers
|
|
9
10
|
* Everything else always gets installed
|
|
@@ -111,7 +112,7 @@ const fetchManifestsForDeps = async (packageInfo, graph, fromNode, deps, scurry,
|
|
|
111
112
|
/**
|
|
112
113
|
* Process placement tasks and collect child dependencies
|
|
113
114
|
*/
|
|
114
|
-
const processPlacementTasks = async (add, graph, options, placementTasks, modifiers) => {
|
|
115
|
+
const processPlacementTasks = async (add, graph, options, placementTasks, modifiers, scurry, packageInfo, extractPromises, actual, seenExtracted, remover) => {
|
|
115
116
|
const childDepsToProcess = [];
|
|
116
117
|
for (const placementTask of placementTasks) {
|
|
117
118
|
const { fetchTask, manifest } = placementTask;
|
|
@@ -178,6 +179,26 @@ const processPlacementTasks = async (add, graph, options, placementTasks, modifi
|
|
|
178
179
|
if (activeModifier) {
|
|
179
180
|
modifiers?.updateActiveEntry(node, activeModifier);
|
|
180
181
|
}
|
|
182
|
+
// Extract the node if it doesn't exist in the actual graph and we have the necessary parameters
|
|
183
|
+
if (remover &&
|
|
184
|
+
extractPromises &&
|
|
185
|
+
actual &&
|
|
186
|
+
scurry &&
|
|
187
|
+
packageInfo &&
|
|
188
|
+
node.inVltStore()) {
|
|
189
|
+
/* c8 ignore start */
|
|
190
|
+
if (seenExtracted?.has(node.id)) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
/* c8 ignore stop */
|
|
194
|
+
seenExtracted?.add(node.id);
|
|
195
|
+
const actualNode = actual.nodes.get(node.id);
|
|
196
|
+
if (!actualNode?.equals(node)) {
|
|
197
|
+
// Extract the node without awaiting - push the promise to the array
|
|
198
|
+
const extractPromise = extractNode(node, scurry, remover, options, packageInfo);
|
|
199
|
+
extractPromises.push(extractPromise);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
181
202
|
// updates graph node information
|
|
182
203
|
if (fileTypeInfo?.path && fileTypeInfo.isDirectory) {
|
|
183
204
|
node.location = fileTypeInfo.path;
|
|
@@ -225,7 +246,7 @@ const processPlacementTasks = async (add, graph, options, placementTasks, modifi
|
|
|
225
246
|
* It also applies any modifiers that applies to a given node as it processes
|
|
226
247
|
* and builds the graph.
|
|
227
248
|
*/
|
|
228
|
-
export const appendNodes = async (add, packageInfo, graph, fromNode, deps, scurry, options, seen, modifiers, modifierRefs) => {
|
|
249
|
+
export const appendNodes = async (add, packageInfo, graph, fromNode, deps, scurry, options, seen, modifiers, modifierRefs, extractPromises, actual, seenExtracted, remover) => {
|
|
229
250
|
/* c8 ignore next */
|
|
230
251
|
if (seen.has(fromNode.id))
|
|
231
252
|
return;
|
|
@@ -245,7 +266,7 @@ export const appendNodes = async (add, packageInfo, graph, fromNode, deps, scurr
|
|
|
245
266
|
// Sort dependencies by spec.name for deterministic ordering
|
|
246
267
|
nodeDeps.sort((a, b) => a.spec.name.localeCompare(b.spec.name, 'en')), scurry, nodeModifierRefs, depth);
|
|
247
268
|
// Process the placement tasks and get child dependencies
|
|
248
|
-
return await processPlacementTasks(add, graph, options, placementTasks, modifiers);
|
|
269
|
+
return await processPlacementTasks(add, graph, options, placementTasks, modifiers, scurry, packageInfo, extractPromises, actual, seenExtracted, remover);
|
|
249
270
|
}));
|
|
250
271
|
// Collect all child dependencies for the next level
|
|
251
272
|
for (const { childDepsToProcess } of levelResults) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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qBAAqB,CAChD,WAAW,EACX,KAAK,EACL,IAAI;YACJ,4DAA4D;YAC5D,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACrB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAC7C,EACD,MAAM,EACN,gBAAgB,EAChB,KAAK,CACN,CAAA;YAED,yDAAyD;YACzD,OAAO,MAAM,qBAAqB,CAChC,GAAG,EACH,KAAK,EACL,OAAO,EACP,cAAc,EACd,SAAS,CACV,CAAA;QACH,CAAC,CACF,CACF,CAAA;QAED,oDAAoD;QACpD,KAAK,MAAM,EAAE,kBAAkB,EAAE,IAAI,YAAY,EAAE,CAAC;YAClD,KAAK,MAAM,QAAQ,IAAI,kBAAkB,EAAE,CAAC;gBAC1C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;oBAChC,oBAAoB;oBACpB,MAAM,YAAY,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAA;oBACpD,aAAa,CAAC,IAAI,CAAC;wBACjB,GAAG,QAAQ;wBACX,KAAK,EAAE,YAAY,GAAG,CAAC;qBACxB,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,yBAAyB;QACzB,gBAAgB,GAAG,aAAa,CAAA;IAClC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { joinDepIDTuple } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport { longDependencyTypes, normalizeManifest } from '@vltpkg/types'\nimport type {\n DependencyTypeLong,\n DependencySaveType,\n Manifest,\n} from '@vltpkg/types'\nimport type { PathScurry } from 'path-scurry'\nimport { asDependency, shorten } from '../dependencies.ts'\nimport type { Dependency } from '../dependencies.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\nimport { removeOptionalSubgraph } from '../remove-optional-subgraph.ts'\nimport type {\n GraphModifier,\n ModifierActiveEntry,\n} from '../modifiers.ts'\n\ntype FileTypeInfo = {\n id: DepID\n path: string\n isDirectory: boolean\n}\n\n/**\n * Only install devDeps for git dependencies and importers\n * Everything else always gets installed\n */\nconst shouldInstallDepType = (\n node: Node,\n depType: DependencyTypeLong,\n) =>\n depType !== 'devDependencies' ||\n node.importer ||\n node.id.startsWith('git')\n\n/**\n * Retrieve the {@link DepID} and location for a `file:` type {@link Node}.\n */\nconst getFileTypeInfo = (\n spec: Spec,\n fromNode: Node,\n scurry: PathScurry,\n): FileTypeInfo | undefined => {\n const f = spec.final\n if (f.type !== 'file') return\n\n /* c8 ignore start - should be impossible */\n if (!f.file) {\n throw error('no path on file specifier', { spec })\n }\n /* c8 ignore stop */\n\n // Given that both linked folders and local tarballs (both defined with\n // usage of the `file:` spec prefix) location needs to be relative to their\n // parents, build the expected path and use it for both location and id\n const target = scurry.cwd.resolve(fromNode.location).resolve(f.file)\n const path = target.relativePosix()\n const id = joinDepIDTuple(['file', path])\n\n return {\n path,\n id,\n isDirectory: !!target.lstatSync()?.isDirectory(),\n }\n}\n\nconst isStringArray = (a: unknown): a is string[] =>\n Array.isArray(a) && !a.some(b => typeof b !== 'string')\n\n/**\n * Represents a manifest fetch operation with all the context needed.\n */\ntype ManifestFetchTask = {\n spec: Spec\n type: DependencySaveType\n fromNode: Node\n fileTypeInfo?: FileTypeInfo\n activeModifier?: ModifierActiveEntry\n queryModifier?: string\n edgeOptional: boolean\n manifestPromise: Promise<Manifest | undefined>\n depth: number\n}\n\n/**\n * Represents a node placement operation that depends on a resolved manifest.\n */\ntype NodePlacementTask = {\n fetchTask: ManifestFetchTask\n manifest: Manifest | undefined\n node?: Node\n childDeps?: Dependency[]\n childModifierRefs?: Map<string, ModifierActiveEntry>\n}\n\n/**\n * Represents an ongoing append operation for a node and its dependencies.\n */\ntype AppendNodeEntry = {\n node: Node\n deps: Dependency[]\n modifierRefs?: Map<string, ModifierActiveEntry>\n depth: number\n}\n\n/**\n * Fetch manifests for dependencies and create placement tasks.\n */\nconst fetchManifestsForDeps = async (\n packageInfo: PackageInfoClient,\n graph: Graph,\n fromNode: Node,\n deps: Dependency[],\n scurry: PathScurry,\n modifierRefs?: Map<string, ModifierActiveEntry>,\n depth = 0,\n): Promise<NodePlacementTask[]> => {\n // Create fetch tasks for all dependencies at this level\n const fetchTasks: ManifestFetchTask[] = []\n\n for (const { spec: originalSpec, type } of deps) {\n let spec = originalSpec\n const fileTypeInfo = getFileTypeInfo(spec, fromNode, scurry)\n const activeModifier = modifierRefs?.get(spec.name)\n\n // here is the place we swap specs if a edge modifier was defined\n const queryModifier = activeModifier?.modifier.query\n const completeModifier =\n activeModifier &&\n activeModifier.interactiveBreadcrumb.current ===\n activeModifier.modifier.breadcrumb.last\n if (\n queryModifier &&\n completeModifier &&\n 'spec' in activeModifier.modifier\n ) {\n spec = activeModifier.modifier.spec\n if (spec.bareSpec === '-') {\n continue\n }\n }\n\n const existingNode = graph.findResolution(\n spec,\n fromNode,\n queryModifier,\n )\n if (existingNode) {\n // For peerOptional dependencies, create a dangling edge instead of linking to existing node\n if (type === 'peerOptional') {\n /* c8 ignore next 3 */\n // This case happens when peerOptional dep already exists in graph\n graph.addEdge(type, spec, fromNode)\n } else {\n graph.addEdge(type, spec, fromNode, existingNode)\n }\n continue\n }\n\n const edgeOptional =\n type === 'optional' || type === 'peerOptional'\n\n // Start manifest fetch immediately for parallel processing\n const manifestPromise = packageInfo\n .manifest(spec, { from: scurry.resolve(fromNode.location) })\n .then(manifest => manifest as Manifest | undefined)\n .catch((er: unknown) => {\n // optional deps ignored if inaccessible\n if (edgeOptional || fromNode.optional) {\n return undefined\n }\n throw er\n })\n\n const fetchTask: ManifestFetchTask = {\n spec,\n type,\n fromNode,\n fileTypeInfo,\n activeModifier,\n queryModifier,\n edgeOptional,\n manifestPromise,\n depth,\n }\n\n fetchTasks.push(fetchTask)\n }\n\n // Create placement tasks\n const placementTasks: NodePlacementTask[] = []\n for (const fetchTask of fetchTasks) {\n const manifest = await fetchTask.manifestPromise\n\n placementTasks.push({\n fetchTask,\n manifest,\n })\n }\n\n return placementTasks\n}\n\n/**\n * Process placement tasks and collect child dependencies\n */\nconst processPlacementTasks = async (\n add: Map<string, Dependency>,\n graph: Graph,\n options: SpecOptions,\n placementTasks: NodePlacementTask[],\n modifiers?: GraphModifier,\n): Promise<{\n childDepsToProcess: Omit<AppendNodeEntry, 'depth'>[]\n}> => {\n const childDepsToProcess: Omit<AppendNodeEntry, 'depth'>[] = []\n\n for (const placementTask of placementTasks) {\n const { fetchTask, manifest } = placementTask\n let { spec } = fetchTask\n const type = fetchTask.type\n const fromNode = fetchTask.fromNode\n const fileTypeInfo = fetchTask.fileTypeInfo\n const activeModifier = fetchTask.activeModifier\n const queryModifier = fetchTask.queryModifier\n const edgeOptional = fetchTask.edgeOptional\n\n // Handle nameless dependencies\n if (manifest?.name && spec.name === '(unknown)') {\n const s = add.get(String(spec))\n if (s) {\n // removes the previous, placeholder entry key\n add.delete(String(spec))\n // replaces spec with a version with the correct name\n spec = Spec.parse(manifest.name, spec.bareSpec, options)\n // updates the add map with the fixed up spec\n const n = asDependency({\n ...s,\n spec,\n })\n add.set(manifest.name, n)\n }\n }\n\n // handles missing manifest resolution\n if (!manifest) {\n if (!edgeOptional && fromNode.isOptional()) {\n // failed resolution of a non-optional dep of an optional node\n // have to clean up the dependents\n removeOptionalSubgraph(graph, fromNode)\n continue\n } else if (edgeOptional) {\n // failed resolution of an optional dep, just ignore it,\n // nothing to prune because we never added it in the first place.\n continue\n } else {\n throw error('failed to resolve dependency', {\n spec,\n from: fromNode.location,\n })\n }\n }\n\n // Skip placing peerOptional dependencies, just create a dangling edge\n if (type === 'peerOptional') {\n /* c8 ignore next 3 */\n graph.addEdge(type, spec, fromNode)\n continue\n }\n\n // places a new node in the graph representing a newly seen dependency\n const node = graph.placePackage(\n fromNode,\n type,\n spec,\n normalizeManifest(manifest),\n fileTypeInfo?.id,\n queryModifier,\n )\n\n /* c8 ignore start - not possible, already ensured manifest */\n if (!node) {\n throw error('failed to place package', {\n from: fromNode.location,\n spec,\n })\n }\n /* c8 ignore stop */\n\n // update the node modifier tracker\n if (activeModifier) {\n modifiers?.updateActiveEntry(node, activeModifier)\n }\n\n // updates graph node information\n if (fileTypeInfo?.path && fileTypeInfo.isDirectory) {\n node.location = fileTypeInfo.path\n }\n node.setResolved()\n\n // Collect child dependencies for processing in the next level\n const bundleDeps = manifest.bundleDependencies\n const bundled = new Set<string>(\n (\n node.id.startsWith('git') ||\n node.importer ||\n !isStringArray(bundleDeps)\n ) ?\n []\n : bundleDeps,\n )\n\n // recursively process all child dependencies in the manifest\n const nextDeps: Dependency[] = []\n\n for (const depTypeName of longDependencyTypes) {\n const depRecord: Record<string, string> | undefined =\n manifest[depTypeName]\n\n if (depRecord && shouldInstallDepType(node, depTypeName)) {\n for (const [name, bareSpec] of Object.entries(depRecord)) {\n if (bundled.has(name)) continue\n nextDeps.push({\n type: shorten(depTypeName, name, manifest),\n spec: Spec.parse(name, bareSpec, {\n ...options,\n registry: spec.registry,\n }),\n })\n }\n }\n }\n\n if (nextDeps.length > 0) {\n childDepsToProcess.push({\n node,\n deps: nextDeps,\n modifierRefs: modifiers?.tryDependencies(node, nextDeps),\n })\n }\n }\n\n return { childDepsToProcess }\n}\n\n/**\n * Append new nodes in the given `graph` for dependencies specified at `add`\n * and missing dependencies from the `deps` parameter.\n *\n * It also applies any modifiers that applies to a given node as it processes\n * and builds the graph.\n */\nexport const appendNodes = async (\n add: Map<string, Dependency>,\n packageInfo: PackageInfoClient,\n graph: Graph,\n fromNode: Node,\n deps: Dependency[],\n scurry: PathScurry,\n options: SpecOptions,\n seen: Set<DepID>,\n modifiers?: GraphModifier,\n modifierRefs?: Map<string, ModifierActiveEntry>,\n) => {\n /* c8 ignore next */\n if (seen.has(fromNode.id)) return\n seen.add(fromNode.id)\n\n // Use a queue for breadth-first processing\n let currentLevelDeps: AppendNodeEntry[] = [\n { node: fromNode, deps, modifierRefs, depth: 0 },\n ]\n\n while (currentLevelDeps.length > 0) {\n const nextLevelDeps: AppendNodeEntry[] = []\n\n // Process all nodes at the current level in parallel\n const levelResults = await Promise.all(\n currentLevelDeps.map(\n async ({\n node,\n deps: nodeDeps,\n modifierRefs: nodeModifierRefs,\n depth,\n }: AppendNodeEntry) => {\n // Mark node as seen when we start processing its dependencies\n seen.add(node.id)\n\n // Fetch manifests for this node's dependencies\n const placementTasks = await fetchManifestsForDeps(\n packageInfo,\n graph,\n node,\n // Sort dependencies by spec.name for deterministic ordering\n nodeDeps.sort((a, b) =>\n a.spec.name.localeCompare(b.spec.name, 'en'),\n ),\n scurry,\n nodeModifierRefs,\n depth,\n )\n\n // Process the placement tasks and get child dependencies\n return await processPlacementTasks(\n add,\n graph,\n options,\n placementTasks,\n modifiers,\n )\n },\n ),\n )\n\n // Collect all child dependencies for the next level\n for (const { childDepsToProcess } of levelResults) {\n for (const childDep of childDepsToProcess) {\n if (!seen.has(childDep.node.id)) {\n /* c8 ignore next */\n const currentDepth = currentLevelDeps[0]?.depth ?? 0\n nextLevelDeps.push({\n ...childDep,\n depth: currentDepth + 1,\n })\n }\n }\n }\n\n // Move to the next level\n currentLevelDeps = nextLevelDeps\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"append-nodes.js","sourceRoot":"","sources":["../../../src/ideal/append-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MA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AE,CAAC,EAAE,CAAC;oBAChC,oBAAoB;oBACpB,MAAM,YAAY,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAA;oBACpD,aAAa,CAAC,IAAI,CAAC;wBACjB,GAAG,QAAQ;wBACX,KAAK,EAAE,YAAY,GAAG,CAAC;qBACxB,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,yBAAyB;QACzB,gBAAgB,GAAG,aAAa,CAAA;IAClC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { joinDepIDTuple } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport { longDependencyTypes, normalizeManifest } from '@vltpkg/types'\nimport type {\n DependencyTypeLong,\n DependencySaveType,\n Manifest,\n} from '@vltpkg/types'\nimport type { PathScurry } from 'path-scurry'\nimport { asDependency, shorten } from '../dependencies.ts'\nimport type { Dependency } from '../dependencies.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\nimport { removeOptionalSubgraph } from '../remove-optional-subgraph.ts'\nimport type {\n GraphModifier,\n ModifierActiveEntry,\n} from '../modifiers.ts'\nimport type { ExtractResult } from '../reify/extract-node.ts'\nimport { extractNode } from '../reify/extract-node.ts'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\n\ntype FileTypeInfo = {\n id: DepID\n path: string\n isDirectory: boolean\n}\n\n/**\n * Only install devDeps for git dependencies and importers\n * Everything else always gets installed\n */\nconst shouldInstallDepType = (\n node: Node,\n depType: DependencyTypeLong,\n) =>\n depType !== 'devDependencies' ||\n node.importer ||\n node.id.startsWith('git')\n\n/**\n * Retrieve the {@link DepID} and location for a `file:` type {@link Node}.\n */\nconst getFileTypeInfo = (\n spec: Spec,\n fromNode: Node,\n scurry: PathScurry,\n): FileTypeInfo | undefined => {\n const f = spec.final\n if (f.type !== 'file') return\n\n /* c8 ignore start - should be impossible */\n if (!f.file) {\n throw error('no path on file specifier', { spec })\n }\n /* c8 ignore stop */\n\n // Given that both linked folders and local tarballs (both defined with\n // usage of the `file:` spec prefix) location needs to be relative to their\n // parents, build the expected path and use it for both location and id\n const target = scurry.cwd.resolve(fromNode.location).resolve(f.file)\n const path = target.relativePosix()\n const id = joinDepIDTuple(['file', path])\n\n return {\n path,\n id,\n isDirectory: !!target.lstatSync()?.isDirectory(),\n }\n}\n\nconst isStringArray = (a: unknown): a is string[] =>\n Array.isArray(a) && !a.some(b => typeof b !== 'string')\n\n/**\n * Represents a manifest fetch operation with all the context needed.\n */\ntype ManifestFetchTask = {\n spec: Spec\n type: DependencySaveType\n fromNode: Node\n fileTypeInfo?: FileTypeInfo\n activeModifier?: ModifierActiveEntry\n queryModifier?: string\n edgeOptional: boolean\n manifestPromise: Promise<Manifest | undefined>\n depth: number\n}\n\n/**\n * Represents a node placement operation that depends on a resolved manifest.\n */\ntype NodePlacementTask = {\n fetchTask: ManifestFetchTask\n manifest: Manifest | undefined\n node?: Node\n childDeps?: Dependency[]\n childModifierRefs?: Map<string, ModifierActiveEntry>\n}\n\n/**\n * Represents an ongoing append operation for a node and its dependencies.\n */\ntype AppendNodeEntry = {\n node: Node\n deps: Dependency[]\n modifierRefs?: Map<string, ModifierActiveEntry>\n depth: number\n}\n\n/**\n * Fetch manifests for dependencies and create placement tasks.\n */\nconst fetchManifestsForDeps = async (\n packageInfo: PackageInfoClient,\n graph: Graph,\n fromNode: Node,\n deps: Dependency[],\n scurry: PathScurry,\n modifierRefs?: Map<string, ModifierActiveEntry>,\n depth = 0,\n): Promise<NodePlacementTask[]> => {\n // Create fetch tasks for all dependencies at this level\n const fetchTasks: ManifestFetchTask[] = []\n\n for (const { spec: originalSpec, type } of deps) {\n let spec = originalSpec\n const fileTypeInfo = getFileTypeInfo(spec, fromNode, scurry)\n const activeModifier = modifierRefs?.get(spec.name)\n\n // here is the place we swap specs if a edge modifier was defined\n const queryModifier = activeModifier?.modifier.query\n const completeModifier =\n activeModifier &&\n activeModifier.interactiveBreadcrumb.current ===\n activeModifier.modifier.breadcrumb.last\n if (\n queryModifier &&\n completeModifier &&\n 'spec' in activeModifier.modifier\n ) {\n spec = activeModifier.modifier.spec\n if (spec.bareSpec === '-') {\n continue\n }\n }\n\n const existingNode = graph.findResolution(\n spec,\n fromNode,\n queryModifier,\n )\n if (existingNode) {\n // For peerOptional dependencies, create a dangling edge instead of linking to existing node\n if (type === 'peerOptional') {\n /* c8 ignore next 3 */\n // This case happens when peerOptional dep already exists in graph\n graph.addEdge(type, spec, fromNode)\n } else {\n graph.addEdge(type, spec, fromNode, existingNode)\n }\n continue\n }\n\n const edgeOptional =\n type === 'optional' || type === 'peerOptional'\n\n // Start manifest fetch immediately for parallel processing\n const manifestPromise = packageInfo\n .manifest(spec, { from: scurry.resolve(fromNode.location) })\n .then(manifest => manifest as Manifest | undefined)\n .catch((er: unknown) => {\n // optional deps ignored if inaccessible\n if (edgeOptional || fromNode.optional) {\n return undefined\n }\n throw er\n })\n\n const fetchTask: ManifestFetchTask = {\n spec,\n type,\n fromNode,\n fileTypeInfo,\n activeModifier,\n queryModifier,\n edgeOptional,\n manifestPromise,\n depth,\n }\n\n fetchTasks.push(fetchTask)\n }\n\n // Create placement tasks\n const placementTasks: NodePlacementTask[] = []\n for (const fetchTask of fetchTasks) {\n const manifest = await fetchTask.manifestPromise\n\n placementTasks.push({\n fetchTask,\n manifest,\n })\n }\n\n return placementTasks\n}\n\n/**\n * Process placement tasks and collect child dependencies\n */\nconst processPlacementTasks = async (\n add: Map<string, Dependency>,\n graph: Graph,\n options: SpecOptions,\n placementTasks: NodePlacementTask[],\n modifiers?: GraphModifier,\n scurry?: PathScurry,\n packageInfo?: PackageInfoClient,\n extractPromises?: Promise<ExtractResult>[],\n actual?: Graph,\n seenExtracted?: Set<DepID>,\n remover?: RollbackRemove,\n): Promise<{\n childDepsToProcess: Omit<AppendNodeEntry, 'depth'>[]\n}> => {\n const childDepsToProcess: Omit<AppendNodeEntry, 'depth'>[] = []\n\n for (const placementTask of placementTasks) {\n const { fetchTask, manifest } = placementTask\n let { spec } = fetchTask\n const type = fetchTask.type\n const fromNode = fetchTask.fromNode\n const fileTypeInfo = fetchTask.fileTypeInfo\n const activeModifier = fetchTask.activeModifier\n const queryModifier = fetchTask.queryModifier\n const edgeOptional = fetchTask.edgeOptional\n\n // Handle nameless dependencies\n if (manifest?.name && spec.name === '(unknown)') {\n const s = add.get(String(spec))\n if (s) {\n // removes the previous, placeholder entry key\n add.delete(String(spec))\n // replaces spec with a version with the correct name\n spec = Spec.parse(manifest.name, spec.bareSpec, options)\n // updates the add map with the fixed up spec\n const n = asDependency({\n ...s,\n spec,\n })\n add.set(manifest.name, n)\n }\n }\n\n // handles missing manifest resolution\n if (!manifest) {\n if (!edgeOptional && fromNode.isOptional()) {\n // failed resolution of a non-optional dep of an optional node\n // have to clean up the dependents\n removeOptionalSubgraph(graph, fromNode)\n continue\n } else if (edgeOptional) {\n // failed resolution of an optional dep, just ignore it,\n // nothing to prune because we never added it in the first place.\n continue\n } else {\n throw error('failed to resolve dependency', {\n spec,\n from: fromNode.location,\n })\n }\n }\n\n // Skip placing peerOptional dependencies, just create a dangling edge\n if (type === 'peerOptional') {\n /* c8 ignore next 3 */\n graph.addEdge(type, spec, fromNode)\n continue\n }\n\n // places a new node in the graph representing a newly seen dependency\n const node = graph.placePackage(\n fromNode,\n type,\n spec,\n normalizeManifest(manifest),\n fileTypeInfo?.id,\n queryModifier,\n )\n\n /* c8 ignore start - not possible, already ensured manifest */\n if (!node) {\n throw error('failed to place package', {\n from: fromNode.location,\n spec,\n })\n }\n /* c8 ignore stop */\n\n // update the node modifier tracker\n if (activeModifier) {\n modifiers?.updateActiveEntry(node, activeModifier)\n }\n\n // Extract the node if it doesn't exist in the actual graph and we have the necessary parameters\n if (\n remover &&\n extractPromises &&\n actual &&\n scurry &&\n packageInfo &&\n node.inVltStore()\n ) {\n /* c8 ignore start */\n if (seenExtracted?.has(node.id)) {\n continue\n }\n /* c8 ignore stop */\n seenExtracted?.add(node.id)\n const actualNode = actual.nodes.get(node.id)\n if (!actualNode?.equals(node)) {\n // Extract the node without awaiting - push the promise to the array\n const extractPromise = extractNode(\n node,\n scurry,\n remover,\n options,\n packageInfo,\n )\n extractPromises.push(extractPromise)\n }\n }\n\n // updates graph node information\n if (fileTypeInfo?.path && fileTypeInfo.isDirectory) {\n node.location = fileTypeInfo.path\n }\n node.setResolved()\n\n // Collect child dependencies for processing in the next level\n const bundleDeps = manifest.bundleDependencies\n const bundled = new Set<string>(\n (\n node.id.startsWith('git') ||\n node.importer ||\n !isStringArray(bundleDeps)\n ) ?\n []\n : bundleDeps,\n )\n\n // recursively process all child dependencies in the manifest\n const nextDeps: Dependency[] = []\n\n for (const depTypeName of longDependencyTypes) {\n const depRecord: Record<string, string> | undefined =\n manifest[depTypeName]\n\n if (depRecord && shouldInstallDepType(node, depTypeName)) {\n for (const [name, bareSpec] of Object.entries(depRecord)) {\n if (bundled.has(name)) continue\n nextDeps.push({\n type: shorten(depTypeName, name, manifest),\n spec: Spec.parse(name, bareSpec, {\n ...options,\n registry: spec.registry,\n }),\n })\n }\n }\n }\n\n if (nextDeps.length > 0) {\n childDepsToProcess.push({\n node,\n deps: nextDeps,\n modifierRefs: modifiers?.tryDependencies(node, nextDeps),\n })\n }\n }\n\n return { childDepsToProcess }\n}\n\n/**\n * Append new nodes in the given `graph` for dependencies specified at `add`\n * and missing dependencies from the `deps` parameter.\n *\n * It also applies any modifiers that applies to a given node as it processes\n * and builds the graph.\n */\nexport const appendNodes = async (\n add: Map<string, Dependency>,\n packageInfo: PackageInfoClient,\n graph: Graph,\n fromNode: Node,\n deps: Dependency[],\n scurry: PathScurry,\n options: SpecOptions,\n seen: Set<DepID>,\n modifiers?: GraphModifier,\n modifierRefs?: Map<string, ModifierActiveEntry>,\n extractPromises?: Promise<ExtractResult>[],\n actual?: Graph,\n seenExtracted?: Set<DepID>,\n remover?: RollbackRemove,\n) => {\n /* c8 ignore next */\n if (seen.has(fromNode.id)) return\n seen.add(fromNode.id)\n\n // Use a queue for breadth-first processing\n let currentLevelDeps: AppendNodeEntry[] = [\n { node: fromNode, deps, modifierRefs, depth: 0 },\n ]\n\n while (currentLevelDeps.length > 0) {\n const nextLevelDeps: AppendNodeEntry[] = []\n\n // Process all nodes at the current level in parallel\n const levelResults = await Promise.all(\n currentLevelDeps.map(\n async ({\n node,\n deps: nodeDeps,\n modifierRefs: nodeModifierRefs,\n depth,\n }: AppendNodeEntry) => {\n // Mark node as seen when we start processing its dependencies\n seen.add(node.id)\n\n // Fetch manifests for this node's dependencies\n const placementTasks = await fetchManifestsForDeps(\n packageInfo,\n graph,\n node,\n // Sort dependencies by spec.name for deterministic ordering\n nodeDeps.sort((a, b) =>\n a.spec.name.localeCompare(b.spec.name, 'en'),\n ),\n scurry,\n nodeModifierRefs,\n depth,\n )\n\n // Process the placement tasks and get child dependencies\n return await processPlacementTasks(\n add,\n graph,\n options,\n placementTasks,\n modifiers,\n scurry,\n packageInfo,\n extractPromises,\n actual,\n seenExtracted,\n remover,\n )\n },\n ),\n )\n\n // Collect all child dependencies for the next level\n for (const { childDepsToProcess } of levelResults) {\n for (const childDep of childDepsToProcess) {\n if (!seen.has(childDep.node.id)) {\n /* c8 ignore next */\n const currentDepth = currentLevelDeps[0]?.depth ?? 0\n nextLevelDeps.push({\n ...childDep,\n depth: currentDepth + 1,\n })\n }\n }\n }\n\n // Move to the next level\n currentLevelDeps = nextLevelDeps\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import type { PackageInfoClient } from '@vltpkg/package-info';
|
|
|
2
2
|
import type { LoadOptions as LoadActualOptions } from '../actual/load.ts';
|
|
3
3
|
import type { AddImportersDependenciesMap, RemoveImportersDependenciesMap } from '../dependencies.ts';
|
|
4
4
|
import type { Graph } from '../graph.ts';
|
|
5
|
+
import type { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
5
6
|
export type BuildIdealOptions = LoadActualOptions & {
|
|
6
7
|
/**
|
|
7
8
|
* An actual graph
|
|
@@ -20,6 +21,10 @@ export type BuildIdealOptions = LoadActualOptions & {
|
|
|
20
21
|
* dependency names to be removed from its dependency list.
|
|
21
22
|
*/
|
|
22
23
|
remove?: RemoveImportersDependenciesMap;
|
|
24
|
+
/**
|
|
25
|
+
* A {@link RollbackRemove} instance to handle extraction rollbacks
|
|
26
|
+
*/
|
|
27
|
+
remover: RollbackRemove;
|
|
23
28
|
/**
|
|
24
29
|
* A {@link PackageInfoClient} instance to read manifest info from.
|
|
25
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,KAAK,EACV,2BAA2B,EAC3B,8BAA8B,EAE/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAK7D,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG;IAClD;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAA;IACd;;;;;OAKG;IACH,GAAG,CAAC,EAAE,2BAA2B,CAAA;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,8BAA8B,CAAA;IACvC;;OAEG;IACH,OAAO,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,YACP,iBAAiB,KACzB,OAAO,CAAC,KAAK,CAoCf,CAAA"}
|
package/dist/esm/ideal/build.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { graphStep } from '@vltpkg/output';
|
|
1
2
|
import { load as loadActual } from "../actual/load.js";
|
|
2
3
|
import { load as loadVirtual } from "../lockfile/load.js";
|
|
3
4
|
import { buildIdealFromStartingGraph } from "./build-ideal-from-starting-graph.js";
|
|
4
|
-
import { graphStep } from '@vltpkg/output';
|
|
5
5
|
const getMap = (m) => m ?? new Map();
|
|
6
6
|
/**
|
|
7
7
|
* Builds an ideal {@link Graph} representing the dependencies that
|
|
@@ -40,6 +40,7 @@ export const build = async (options) => {
|
|
|
40
40
|
graph,
|
|
41
41
|
packageInfo,
|
|
42
42
|
remove: getMap(options.remove),
|
|
43
|
+
actual: options.actual,
|
|
43
44
|
});
|
|
44
45
|
done();
|
|
45
46
|
return res;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAA;AAYlF,MAAM,MAAM,GAAG,CAA0B,CAAK,EAAE,EAAE,CAChD,CAAC,IAAK,IAAI,GAAG,EAAQ,CAAA;AA8BvB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EACxB,OAA0B,EACV,EAAE;IAClB,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAA;IAE/B,yDAAyD;IACzD,iDAAiD;IACjD,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAC9D,MAAM,YAAY,GAChB,OAAO,CAAC,YAAY,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAC/D,IAAI,KAAK,CAAA;IACT,IAAI,CAAC;QACH,KAAK,GAAG,WAAW,CAAC;YAClB,GAAG,OAAO;YACV,YAAY;YACZ,QAAQ;YACR,iCAAiC,EAAE,IAAI;SACxC,CAAC,CAAA;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,KAAK,GAAG,UAAU,CAAC;YACjB,GAAG,OAAO;YACV,YAAY;YACZ,QAAQ;YACR,iCAAiC,EAAE,IAAI;SACxC,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,2BAA2B,CAAC;QAC5C,GAAG,OAAO;QACV,MAAM;QACN,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;QACxB,KAAK;QACL,WAAW;QACX,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAA;IACF,IAAI,EAAE,CAAA;IACN,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import { graphStep } from '@vltpkg/output'\nimport { load as loadActual } from '../actual/load.ts'\nimport { load as loadVirtual } from '../lockfile/load.ts'\nimport { buildIdealFromStartingGraph } from './build-ideal-from-starting-graph.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { LoadOptions as LoadActualOptions } from '../actual/load.ts'\nimport type {\n AddImportersDependenciesMap,\n RemoveImportersDependenciesMap,\n Dependency,\n} from '../dependencies.ts'\nimport type { Graph } from '../graph.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\n\nconst getMap = <T extends Map<any, any>>(m?: T) =>\n m ?? (new Map() as T)\n\nexport type BuildIdealOptions = LoadActualOptions & {\n /**\n * An actual graph\n */\n actual?: Graph\n /**\n * A `Map` in which keys are {@link DepID} linking to another `Map` in which\n * keys are the dependency names and values are {@link Dependency}. This\n * structure represents dependencies that need to be added to the importer\n * represented by {@link DepID}.\n */\n add?: AddImportersDependenciesMap\n /**\n * A `Map` object representing nodes to be removed from the ideal graph.\n * Each {@link DepID} key represents an importer node and the `Set` of\n * dependency names to be removed from its dependency list.\n */\n remove?: RemoveImportersDependenciesMap\n /**\n * A {@link RollbackRemove} instance to handle extraction rollbacks\n */\n remover: RollbackRemove\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n}\n\n/**\n * Builds an ideal {@link Graph} representing the dependencies that\n * should be present in order to fulfill the requirements defined\n * by the `package.json` and `vlt-lock.json` files using either the\n * virtual or actual graph as a starting point. Also add / remove any\n * dependencies listed in the `add` and `remove` properties.\n */\nexport const build = async (\n options: BuildIdealOptions,\n): Promise<Graph> => {\n const done = graphStep('build')\n\n // Creates the shared instances that are going to be used\n // in both the loader methods and the build graph\n const { packageInfo, packageJson, scurry, monorepo } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(options.projectRoot)\n let graph\n try {\n graph = loadVirtual({\n ...options,\n mainManifest,\n monorepo,\n skipLoadingNodesOnModifiersChange: true,\n })\n } catch {\n graph = loadActual({\n ...options,\n mainManifest,\n monorepo,\n skipLoadingNodesOnModifiersChange: true,\n })\n }\n\n const res = await buildIdealFromStartingGraph({\n ...options,\n scurry,\n add: getMap(options.add),\n graph,\n packageInfo,\n remove: getMap(options.remove),\n actual: options.actual,\n })\n done()\n return res\n}\n"]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './build.ts';
|
|
1
2
|
export * from './edge.ts';
|
|
2
3
|
export * from './graph.ts';
|
|
3
4
|
export * from './node.ts';
|
|
@@ -33,4 +34,5 @@ export declare const ideal: {
|
|
|
33
34
|
};
|
|
34
35
|
export { reify } from './reify/index.ts';
|
|
35
36
|
export type { ReifyOptions } from './reify/index.ts';
|
|
37
|
+
export type { BuildResult } from './reify/build.ts';
|
|
36
38
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0CAA0C,CAAA;AACxD,cAAc,mCAAmC,CAAA;AACjD,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AAGjC,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACxE,eAAO,MAAM,MAAM;;CAAuB,CAAA;AAG1C,OAAO,KAAK,EAAE,WAAW,IAAI,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAI5E,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAA;AAED,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzD,YAAY,EAAE,iBAAiB,EAAE,CAAA;AACjC,eAAO,MAAM,KAAK;;CAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0CAA0C,CAAA;AACxD,cAAc,mCAAmC,CAAA;AACjD,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AAGjC,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACxE,eAAO,MAAM,MAAM;;CAAuB,CAAA;AAG1C,OAAO,KAAK,EAAE,WAAW,IAAI,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAI5E,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAA;AAED,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzD,YAAY,EAAE,iBAAiB,EAAE,CAAA;AACjC,eAAO,MAAM,KAAK;;CAAY,CAAA;AAE9B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAA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Ac,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AAEjC,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAErD,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;AAE1C,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzC,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,YAAY;IAClB,SAAS;IACT,SAAS;IACT,IAAI;CACL,CAAA;AAKD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAGxC,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,CAAA;AAE9B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA","sourcesContent":["export * from './build.ts'\nexport * from './edge.ts'\nexport * from './graph.ts'\nexport * from './node.ts'\nexport * from './dependencies.ts'\nexport * from './lockfile/types.ts'\nexport * from './visualization/json-output.ts'\nexport * from './visualization/human-readable-output.ts'\nexport * from './visualization/mermaid-output.ts'\nexport * from './stringify-node.ts'\nexport * from './install.ts'\nexport * from './uninstall.ts'\nexport * from './update.ts'\nexport * from './diff.ts'\nexport * from './modifiers.ts'\nexport * from './virtual-root.ts'\n\nimport { load as actualLoad } from './actual/load.ts'\nimport type { LoadOptions as ActualLoadOptions } from './actual/load.ts'\nexport const actual = { load: actualLoad }\n\nimport { load as lockfileLoad } from './lockfile/load.ts'\nimport type { LoadOptions as LockfileLoadOptions } from './lockfile/load.ts'\nimport { loadEdges } from './lockfile/load-edges.ts'\nimport { loadNodes } from './lockfile/load-nodes.ts'\nimport { save } from './lockfile/save.ts'\nexport const lockfile = {\n load: lockfileLoad,\n loadEdges,\n loadNodes,\n save,\n}\n\nexport type { ActualLoadOptions, LockfileLoadOptions }\nexport type { SaveOptions } from './lockfile/save.ts'\n\nimport { build } from './ideal/build.ts'\nimport type { BuildIdealOptions } from './ideal/build.ts'\nexport type { BuildIdealOptions }\nexport const ideal = { build }\n\nexport { reify } from './reify/index.ts'\nexport type { ReifyOptions } from './reify/index.ts'\nexport type { BuildResult } from './reify/build.ts'\n"]}
|
package/dist/esm/install.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import type { PackageInfoClient } from '@vltpkg/package-info';
|
|
2
2
|
import type { LoadOptions } from './actual/load.ts';
|
|
3
3
|
import type { AddImportersDependenciesMap } from './dependencies.ts';
|
|
4
|
+
import type { DepID } from '@vltpkg/dep-id';
|
|
4
5
|
export type InstallOptions = LoadOptions & {
|
|
5
6
|
packageInfo: PackageInfoClient;
|
|
6
7
|
cleanInstall?: boolean;
|
|
8
|
+
allowScripts: string;
|
|
7
9
|
};
|
|
8
10
|
export declare const install: (options: InstallOptions, add?: AddImportersDependenciesMap) => Promise<{
|
|
11
|
+
graph: import("./graph.ts").Graph;
|
|
12
|
+
diff: undefined;
|
|
13
|
+
buildQueue?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
buildQueue: DepID[] | undefined;
|
|
9
16
|
graph: import("./graph.ts").Graph;
|
|
10
17
|
diff: import("./diff.ts").Diff;
|
|
11
18
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/install.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,OAAO,KAAK,EACV,2BAA2B,EAE5B,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/install.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,OAAO,KAAK,EACV,2BAA2B,EAE5B,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAQ3C,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,WAAW,EAAE,iBAAiB,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,OAAO,YACT,cAAc,QACjB,2BAA2B;;;;;;;;EAuMlC,CAAA"}
|
package/dist/esm/install.js
CHANGED
|
@@ -11,7 +11,13 @@ import { existsSync } from 'node:fs';
|
|
|
11
11
|
import { resolve } from 'node:path';
|
|
12
12
|
import { load as loadVirtual } from "./lockfile/load.js";
|
|
13
13
|
import { getImporterSpecs } from "./ideal/get-importer-specs.js";
|
|
14
|
+
import { lockfile } from "./index.js";
|
|
15
|
+
import { updatePackageJson } from "./reify/update-importers-package-json.js";
|
|
14
16
|
export const install = async (options, add) => {
|
|
17
|
+
// Validate incompatible options
|
|
18
|
+
if (options.lockfileOnly && options.cleanInstall) {
|
|
19
|
+
throw error('Cannot use --lockfile-only with --clean-install (ci command). Clean install requires filesystem operations.');
|
|
20
|
+
}
|
|
15
21
|
if (options.expectLockfile || options.frozenLockfile) {
|
|
16
22
|
const lockfilePath = resolve(options.projectRoot, 'vlt-lock.json');
|
|
17
23
|
if (!existsSync(lockfilePath)) {
|
|
@@ -129,16 +135,34 @@ export const install = async (options, add) => {
|
|
|
129
135
|
mainManifest,
|
|
130
136
|
loadManifests: true,
|
|
131
137
|
modifiers,
|
|
138
|
+
remover,
|
|
132
139
|
});
|
|
133
|
-
|
|
140
|
+
// If lockfileOnly is enabled, skip reify and only save the lockfile
|
|
141
|
+
if (options.lockfileOnly) {
|
|
142
|
+
// Save only the main lockfile, skip all filesystem operations
|
|
143
|
+
lockfile.save({ graph, modifiers });
|
|
144
|
+
const saveImportersPackageJson =
|
|
145
|
+
/* c8 ignore next */
|
|
146
|
+
add?.modifiedDependencies ?
|
|
147
|
+
updatePackageJson({
|
|
148
|
+
...options,
|
|
149
|
+
add,
|
|
150
|
+
graph,
|
|
151
|
+
})
|
|
152
|
+
: undefined;
|
|
153
|
+
saveImportersPackageJson?.();
|
|
154
|
+
return { graph, diff: undefined };
|
|
155
|
+
}
|
|
156
|
+
const { diff, buildQueue } = await reify({
|
|
134
157
|
...options,
|
|
135
158
|
add,
|
|
136
159
|
actual: act,
|
|
137
160
|
graph,
|
|
138
161
|
loadManifests: true,
|
|
139
162
|
modifiers,
|
|
163
|
+
remover,
|
|
140
164
|
});
|
|
141
|
-
return { graph, diff };
|
|
165
|
+
return { buildQueue, graph, diff };
|
|
142
166
|
}
|
|
143
167
|
catch (err) {
|
|
144
168
|
/* c8 ignore next */
|
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,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,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GAAG,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QAElD,MAAM,GAAG,GAAG,UAAU,CAAC;YACrB,GAAG,OAAO;YACV,YAAY;YACZ,aAAa,EAAE,IAAI;YACnB,SAAS,EAAE,SAAS,EAAE,oCAAoC;SAC3D,CAAC,CAAA;QACF,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC;YAC7B,GAAG,OAAO;YACV,MAAM,EAAE,GAAG;YACX,GAAG;YACH,YAAY;YACZ,aAAa,EAAE,IAAI;YACnB,SAAS;SACV,CAAC,CAAA;QACF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC;YACvB,GAAG,OAAO;YACV,GAAG;YACH,MAAM,EAAE,GAAG;YACX,KAAK;YACL,aAAa,EAAE,IAAI;YACnB,SAAS;SACV,CAAC,CAAA;QAEF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;IACxB,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'\n\nexport type InstallOptions = LoadOptions & {\n packageInfo: PackageInfoClient\n cleanInstall?: boolean // Only set by ci command for clean install\n}\n\nexport const install = async (\n options: InstallOptions,\n add?: AddImportersDependenciesMap,\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 })\n const diff = await reify({\n ...options,\n add,\n actual: act,\n graph,\n loadManifests: true,\n modifiers,\n })\n\n return { 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.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oBACV,GAAG;oBACH,KAAK;iBACN,CAAC;gBACJ,CAAC,CAAC,SAAS,CAAA;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-nodes.d.ts","sourceRoot":"","sources":["../../../src/lockfile/load-nodes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-nodes.d.ts","sourceRoot":"","sources":["../../../src/lockfile/load-nodes.ts"],"names":[],"mappings":"AAKA,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,SA8GnB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { splitDepID } from '@vltpkg/dep-id/browser';
|
|
2
|
-
import { getBooleanFlagsFromNum } from "./types.js";
|
|
2
|
+
import { getBooleanFlagsFromNum, getBuildStateFromNum, } from "./types.js";
|
|
3
3
|
export const loadNodes = (graph, nodes, options, actual) => {
|
|
4
4
|
const entries = Object.entries(nodes);
|
|
5
5
|
const nodeCount = entries.length;
|
|
@@ -7,7 +7,7 @@ export const loadNodes = (graph, nodes, options, actual) => {
|
|
|
7
7
|
// Only used for non-trivial graphs
|
|
8
8
|
const registryVersionCache = nodeCount > 50 ? new Map() : null;
|
|
9
9
|
for (const [id, lockfileNode] of entries) {
|
|
10
|
-
const [flags, name, integrity, resolved, location, manifest, rawManifest, platform,] = lockfileNode;
|
|
10
|
+
const [flags, name, integrity, resolved, location, manifest, rawManifest, platform, buildState,] = lockfileNode;
|
|
11
11
|
// workspace nodes and the project root node are already part of the
|
|
12
12
|
// graph and it should not create new nodes if an existing one is there
|
|
13
13
|
if (graph.nodes.has(id))
|
|
@@ -78,6 +78,10 @@ export const loadNodes = (graph, nodes, options, actual) => {
|
|
|
78
78
|
if (platform) {
|
|
79
79
|
node.platform = platform;
|
|
80
80
|
}
|
|
81
|
+
// Set build state if provided
|
|
82
|
+
if (buildState !== undefined && buildState !== null) {
|
|
83
|
+
node.buildState = getBuildStateFromNum(buildState);
|
|
84
|
+
}
|
|
81
85
|
}
|
|
82
86
|
};
|
|
83
87
|
//# sourceMappingURL=load-nodes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-nodes.js","sourceRoot":"","sources":["../../../src/lockfile/load-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"load-nodes.js","sourceRoot":"","sources":["../../../src/lockfile/load-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EACL,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,YAAY,CAAA;AAMnB,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAgB,EAChB,KAA4B,EAC5B,OAAoB,EACpB,MAAkB,EAClB,EAAE;IACF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAA4B,CAAA;IAChE,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAA;IAEhC,8DAA8D;IAC9D,mCAAmC;IACnC,MAAM,oBAAoB,GACxB,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,GAAG,EAAkB,CAAC,CAAC,CAAC,IAAI,CAAA;IAEnD,KAAK,MAAM,CAAC,EAAE,EAAE,YAAY,CAAC,IAAI,O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;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,sBAAsB;QACtB,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAC1B,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 { splitDepID } 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) => {\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 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 // 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 node.modifier = extra\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 /* c8 ignore next 3 */\n if (platform) {\n node.platform = platform\n }\n\n // Set build state if provided\n if (buildState !== undefined && buildState !== null) {\n node.buildState = getBuildStateFromNum(buildState)\n }\n }\n}\n"]}
|
|
@@ -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,C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7C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC;;OAEG;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,iCAAiC,CAAC,EAAE,OAAO,CAAA;CAC5C,CAAA;AASD,eAAO,MAAM,IAAI,YAAa,WAAW,KAAG,KAM3C,CAAA;AAED,eAAO,MAAM,UAAU,YAAa,WAAW,KAAG,KAMjD,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,UAmG7D,CAAA"}
|
|
@@ -21,7 +21,9 @@ export const loadObject = (options, lockfileData) => {
|
|
|
21
21
|
const packageJson = options.packageJson ?? new PackageJson();
|
|
22
22
|
const monorepo = options.monorepo ??
|
|
23
23
|
Monorepo.maybeLoad(options.projectRoot, { packageJson, scurry });
|
|
24
|
-
const { catalog = {}, catalogs = {}, modifiers: modifiersLockfileConfig, 'scope-registries': scopeRegistries, registry, registries, 'git-hosts': gitHosts, 'git-host-archives': gitHostArchives,
|
|
24
|
+
const { catalog = {}, catalogs = {}, modifiers: modifiersLockfileConfig, 'scope-registries': scopeRegistries, registry, registries, 'git-hosts': gitHosts, 'git-host-archives': gitHostArchives,
|
|
25
|
+
/* c8 ignore next */
|
|
26
|
+
} = lockfileData.options ?? {};
|
|
25
27
|
// Optimize options merging - only create new objects when needed
|
|
26
28
|
const mergedOptions = {
|
|
27
29
|
...options,
|
|
@@ -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;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,CAAC,CAAA;AAED,MAAM,CAAC,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AAC,MAAM,EAAE,CAAC;YAC/C,gBAAgB,GAAG,IAAI,CAAA;QACzB,CAAC;aAAM,CAAC;YACN,qDAAqD;YACrD,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;YACxD,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAA;YACtD,gBAAgB,GAAG,iBAAiB,KAAK,gBAAgB,CAAA;QAC3D,CAAC;IACH,CAAC;IACD,MAAM,sBAAsB,GAAG,CAAC,CAC9B,iCAAiC,IAAI,gBAAgB,CACtD,CAAA;IACD,IAAI,sBAAsB,EAAE,CAAC;QAC3B,SAAS,CACP,KAAK,EACL,YAAY,CAAC,KAAK,EAClB,aAAa,EACb,OAAO,CAAC,MAAM,CACf,CAAA;QACD,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,aAAa,CAAC,CAAA;IACrD,CAAC;IAED,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 * Load only importers into the graph if the modifiers have changed.\n */\n skipLoadingNodesOnModifiersChange?: 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 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 {\n mainManifest,\n modifiers,\n scurry,\n skipLoadingNodesOnModifiersChange,\n } = 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 modifiers: modifiersLockfileConfig,\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\n // When using the skipLoadingNodesOnModifiersChange option, we should skip loading\n // dependencies in case the modifiers have changed since we'll need to\n // recalculate the graph - useful for refreshing an ideal graph when\n // modifiers are swapped.\n\n // Optimize modifier comparison - avoid JSON.stringify for simple cases\n let modifiersChanged = false\n if (skipLoadingNodesOnModifiersChange) {\n const lockfileConfig = modifiersLockfileConfig ?? {}\n const optionsConfig = modifiers?.config ?? {}\n\n // Quick check for obvious differences\n const lockfileKeys = Object.keys(lockfileConfig)\n const optionsKeys = Object.keys(optionsConfig)\n\n if (lockfileKeys.length !== optionsKeys.length) {\n modifiersChanged = true\n } else {\n // Only use JSON.stringify if we need deep comparison\n const lockfileModifiers = JSON.stringify(lockfileConfig)\n const optionsModifiers = JSON.stringify(optionsConfig)\n modifiersChanged = lockfileModifiers !== optionsModifiers\n }\n }\n const shouldLoadDependencies = !(\n skipLoadingNodesOnModifiersChange && modifiersChanged\n )\n if (shouldLoadDependencies) {\n loadNodes(\n graph,\n lockfileData.nodes,\n mergedOptions,\n options.actual,\n )\n loadEdges(graph, lockfileData.edges, mergedOptions)\n }\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"]}
|
|
@@ -15,9 +15,13 @@ export type SaveOptions = SpecOptions & {
|
|
|
15
15
|
* Should it save manifest data in the lockfile?
|
|
16
16
|
*/
|
|
17
17
|
saveManifests?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Should it save build state data in the lockfile?
|
|
20
|
+
*/
|
|
21
|
+
saveBuildData?: boolean;
|
|
18
22
|
};
|
|
19
|
-
export declare const lockfileData: ({ graph, catalog, catalogs, "git-hosts": gitHosts, "git-host-archives": gitHostArchives, modifiers, registry, registries, saveManifests, "scope-registries": scopeRegistries, "jsr-registries": jsrRegistries, }: SaveOptions) => LockfileData;
|
|
23
|
+
export declare const lockfileData: ({ graph, catalog, catalogs, "git-hosts": gitHosts, "git-host-archives": gitHostArchives, modifiers, registry, registries, saveManifests, saveBuildData, "scope-registries": scopeRegistries, "jsr-registries": jsrRegistries, }: SaveOptions) => LockfileData;
|
|
20
24
|
export declare const saveData: (data: LockfileData, fileName: string, saveManifests?: boolean) => void;
|
|
21
25
|
export declare const save: (options: Omit<SaveOptions, "saveManifests">) => void;
|
|
22
|
-
export declare const saveHidden: (options: Omit<SaveOptions, "saveManifests">) => void;
|
|
26
|
+
export declare const saveHidden: (options: Omit<SaveOptions, "saveManifests" | "saveBuildData">) => void;
|
|
23
27
|
//# sourceMappingURL=save.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../../../src/lockfile/save.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,KAAK,EACV,YAAY,EAMb,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC;;OAEG;IACH,KAAK,EAAE,KAAK,CAAA;IACZ;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;
|
|
1
|
+
{"version":3,"file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