@vltpkg/graph 1.0.0-rc.2 → 1.0.0-rc.23
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/README.md +101 -22
- package/package.json +51 -63
- package/dist/esm/actual/load.d.ts +0 -100
- package/dist/esm/actual/load.d.ts.map +0 -1
- package/dist/esm/actual/load.js +0 -304
- package/dist/esm/actual/load.js.map +0 -1
- package/dist/esm/browser.d.ts +0 -15
- package/dist/esm/browser.d.ts.map +0 -1
- package/dist/esm/browser.js +0 -17
- package/dist/esm/browser.js.map +0 -1
- package/dist/esm/build.d.ts +0 -29
- package/dist/esm/build.d.ts.map +0 -1
- package/dist/esm/build.js +0 -79
- package/dist/esm/build.js.map +0 -1
- package/dist/esm/dependencies.d.ts +0 -66
- package/dist/esm/dependencies.d.ts.map +0 -1
- package/dist/esm/dependencies.js +0 -112
- package/dist/esm/dependencies.js.map +0 -1
- package/dist/esm/diff.d.ts +0 -116
- package/dist/esm/diff.d.ts.map +0 -1
- package/dist/esm/diff.js +0 -148
- package/dist/esm/diff.js.map +0 -1
- package/dist/esm/edge.d.ts +0 -46
- package/dist/esm/edge.d.ts.map +0 -1
- package/dist/esm/edge.js +0 -74
- package/dist/esm/edge.js.map +0 -1
- package/dist/esm/graph.d.ts +0 -133
- package/dist/esm/graph.d.ts.map +0 -1
- package/dist/esm/graph.js +0 -407
- package/dist/esm/graph.js.map +0 -1
- package/dist/esm/ideal/add-nodes.d.ts +0 -34
- 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/append-nodes.d.ts +0 -19
- package/dist/esm/ideal/append-nodes.d.ts.map +0 -1
- package/dist/esm/ideal/append-nodes.js +0 -289
- package/dist/esm/ideal/append-nodes.js.map +0 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts +0 -15
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +0 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.js +0 -55
- package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +0 -1
- package/dist/esm/ideal/build.d.ts +0 -41
- package/dist/esm/ideal/build.d.ts.map +0 -1
- package/dist/esm/ideal/build.js +0 -48
- package/dist/esm/ideal/build.js.map +0 -1
- package/dist/esm/ideal/get-importer-specs.d.ts +0 -14
- package/dist/esm/ideal/get-importer-specs.d.ts.map +0 -1
- package/dist/esm/ideal/get-importer-specs.js +0 -106
- package/dist/esm/ideal/get-importer-specs.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/ideal/remove-satisfied-specs.d.ts +0 -8
- package/dist/esm/ideal/remove-satisfied-specs.d.ts.map +0 -1
- package/dist/esm/ideal/remove-satisfied-specs.js +0 -35
- package/dist/esm/ideal/remove-satisfied-specs.js.map +0 -1
- package/dist/esm/ideal/types.d.ts +0 -35
- package/dist/esm/ideal/types.d.ts.map +0 -1
- package/dist/esm/ideal/types.js +0 -2
- package/dist/esm/ideal/types.js.map +0 -1
- package/dist/esm/index.d.ts +0 -38
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js +0 -32
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/install.d.ts +0 -19
- package/dist/esm/install.d.ts.map +0 -1
- package/dist/esm/install.js +0 -173
- package/dist/esm/install.js.map +0 -1
- package/dist/esm/lockfile/load-edges.d.ts +0 -12
- package/dist/esm/lockfile/load-edges.d.ts.map +0 -1
- package/dist/esm/lockfile/load-edges.js +0 -105
- package/dist/esm/lockfile/load-edges.js.map +0 -1
- package/dist/esm/lockfile/load-nodes.d.ts +0 -5
- package/dist/esm/lockfile/load-nodes.d.ts.map +0 -1
- package/dist/esm/lockfile/load-nodes.js +0 -95
- package/dist/esm/lockfile/load-nodes.js.map +0 -1
- package/dist/esm/lockfile/load.d.ts +0 -50
- package/dist/esm/lockfile/load.d.ts.map +0 -1
- package/dist/esm/lockfile/load.js +0 -89
- package/dist/esm/lockfile/load.js.map +0 -1
- package/dist/esm/lockfile/save.d.ts +0 -31
- package/dist/esm/lockfile/save.d.ts.map +0 -1
- package/dist/esm/lockfile/save.js +0 -173
- package/dist/esm/lockfile/save.js.map +0 -1
- package/dist/esm/lockfile/types.d.ts +0 -89
- package/dist/esm/lockfile/types.d.ts.map +0 -1
- package/dist/esm/lockfile/types.js +0 -44
- package/dist/esm/lockfile/types.js.map +0 -1
- package/dist/esm/modifiers.d.ts +0 -189
- package/dist/esm/modifiers.d.ts.map +0 -1
- package/dist/esm/modifiers.js +0 -330
- package/dist/esm/modifiers.js.map +0 -1
- package/dist/esm/node.d.ts +0 -219
- package/dist/esm/node.d.ts.map +0 -1
- package/dist/esm/node.js +0 -368
- package/dist/esm/node.js.map +0 -1
- package/dist/esm/non-empty-list.d.ts +0 -3
- package/dist/esm/non-empty-list.d.ts.map +0 -1
- package/dist/esm/non-empty-list.js +0 -3
- package/dist/esm/non-empty-list.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/esm/reify/add-edge.d.ts +0 -10
- package/dist/esm/reify/add-edge.d.ts.map +0 -1
- package/dist/esm/reify/add-edge.js +0 -65
- package/dist/esm/reify/add-edge.js.map +0 -1
- package/dist/esm/reify/add-edges.d.ts +0 -5
- package/dist/esm/reify/add-edges.d.ts.map +0 -1
- package/dist/esm/reify/add-edges.js +0 -12
- package/dist/esm/reify/add-edges.js.map +0 -1
- package/dist/esm/reify/add-nodes.d.ts +0 -7
- package/dist/esm/reify/add-nodes.d.ts.map +0 -1
- package/dist/esm/reify/add-nodes.js +0 -17
- package/dist/esm/reify/add-nodes.js.map +0 -1
- package/dist/esm/reify/bin-chmod.d.ts +0 -11
- package/dist/esm/reify/bin-chmod.d.ts.map +0 -1
- package/dist/esm/reify/bin-chmod.js +0 -39
- package/dist/esm/reify/bin-chmod.js.map +0 -1
- package/dist/esm/reify/build.d.ts +0 -14
- package/dist/esm/reify/build.d.ts.map +0 -1
- package/dist/esm/reify/build.js +0 -103
- package/dist/esm/reify/build.js.map +0 -1
- package/dist/esm/reify/calculate-save-value.d.ts +0 -3
- package/dist/esm/reify/calculate-save-value.d.ts.map +0 -1
- package/dist/esm/reify/calculate-save-value.js +0 -45
- package/dist/esm/reify/calculate-save-value.js.map +0 -1
- package/dist/esm/reify/check-needed-build.d.ts +0 -25
- package/dist/esm/reify/check-needed-build.d.ts.map +0 -1
- package/dist/esm/reify/check-needed-build.js +0 -50
- package/dist/esm/reify/check-needed-build.js.map +0 -1
- package/dist/esm/reify/delete-edge.d.ts +0 -5
- package/dist/esm/reify/delete-edge.d.ts.map +0 -1
- package/dist/esm/reify/delete-edge.js +0 -28
- package/dist/esm/reify/delete-edge.js.map +0 -1
- package/dist/esm/reify/delete-edges.d.ts +0 -5
- package/dist/esm/reify/delete-edges.d.ts.map +0 -1
- package/dist/esm/reify/delete-edges.js +0 -14
- package/dist/esm/reify/delete-edges.js.map +0 -1
- package/dist/esm/reify/delete-nodes.d.ts +0 -5
- package/dist/esm/reify/delete-nodes.d.ts.map +0 -1
- package/dist/esm/reify/delete-nodes.js +0 -16
- package/dist/esm/reify/delete-nodes.js.map +0 -1
- package/dist/esm/reify/extract-node.d.ts +0 -24
- package/dist/esm/reify/extract-node.d.ts.map +0 -1
- package/dist/esm/reify/extract-node.js +0 -76
- package/dist/esm/reify/extract-node.js.map +0 -1
- package/dist/esm/reify/index.d.ts +0 -34
- package/dist/esm/reify/index.d.ts.map +0 -1
- package/dist/esm/reify/index.js +0 -161
- package/dist/esm/reify/index.js.map +0 -1
- package/dist/esm/reify/internal-hoist.d.ts +0 -9
- package/dist/esm/reify/internal-hoist.d.ts.map +0 -1
- package/dist/esm/reify/internal-hoist.js +0 -134
- package/dist/esm/reify/internal-hoist.js.map +0 -1
- package/dist/esm/reify/optional-fail.d.ts +0 -16
- package/dist/esm/reify/optional-fail.d.ts.map +0 -1
- package/dist/esm/reify/optional-fail.js +0 -16
- package/dist/esm/reify/optional-fail.js.map +0 -1
- package/dist/esm/reify/rollback.d.ts +0 -5
- package/dist/esm/reify/rollback.d.ts.map +0 -1
- package/dist/esm/reify/rollback.js +0 -24
- package/dist/esm/reify/rollback.js.map +0 -1
- package/dist/esm/reify/update-importers-package-json.d.ts +0 -36
- package/dist/esm/reify/update-importers-package-json.d.ts.map +0 -1
- package/dist/esm/reify/update-importers-package-json.js +0 -120
- package/dist/esm/reify/update-importers-package-json.js.map +0 -1
- package/dist/esm/remove-optional-subgraph.d.ts +0 -34
- package/dist/esm/remove-optional-subgraph.d.ts.map +0 -1
- package/dist/esm/remove-optional-subgraph.js +0 -48
- package/dist/esm/remove-optional-subgraph.js.map +0 -1
- package/dist/esm/resolve-save-type.d.ts +0 -6
- package/dist/esm/resolve-save-type.d.ts.map +0 -1
- package/dist/esm/resolve-save-type.js +0 -5
- package/dist/esm/resolve-save-type.js.map +0 -1
- package/dist/esm/stringify-node.d.ts +0 -3
- package/dist/esm/stringify-node.d.ts.map +0 -1
- package/dist/esm/stringify-node.js +0 -24
- package/dist/esm/stringify-node.js.map +0 -1
- package/dist/esm/transfer-data/load.d.ts +0 -44
- package/dist/esm/transfer-data/load.d.ts.map +0 -1
- package/dist/esm/transfer-data/load.js +0 -176
- package/dist/esm/transfer-data/load.js.map +0 -1
- package/dist/esm/uninstall.d.ts +0 -15
- package/dist/esm/uninstall.d.ts.map +0 -1
- package/dist/esm/uninstall.js +0 -58
- package/dist/esm/uninstall.js.map +0 -1
- package/dist/esm/update.d.ts +0 -13
- package/dist/esm/update.d.ts.map +0 -1
- package/dist/esm/update.js +0 -63
- package/dist/esm/update.js.map +0 -1
- package/dist/esm/virtual-root.d.ts +0 -16
- package/dist/esm/virtual-root.d.ts.map +0 -1
- package/dist/esm/virtual-root.js +0 -79
- package/dist/esm/virtual-root.js.map +0 -1
- package/dist/esm/visualization/human-readable-output.d.ts +0 -27
- package/dist/esm/visualization/human-readable-output.d.ts.map +0 -1
- package/dist/esm/visualization/human-readable-output.js +0 -159
- package/dist/esm/visualization/human-readable-output.js.map +0 -1
- package/dist/esm/visualization/json-output.d.ts +0 -41
- package/dist/esm/visualization/json-output.d.ts.map +0 -1
- package/dist/esm/visualization/json-output.js +0 -51
- package/dist/esm/visualization/json-output.js.map +0 -1
- package/dist/esm/visualization/mermaid-output.d.ts +0 -17
- package/dist/esm/visualization/mermaid-output.d.ts.map +0 -1
- package/dist/esm/visualization/mermaid-output.js +0 -123
- package/dist/esm/visualization/mermaid-output.js.map +0 -1
- package/dist/esm/visualization/object-like-output.d.ts +0 -3
- package/dist/esm/visualization/object-like-output.d.ts.map +0 -1
- package/dist/esm/visualization/object-like-output.js +0 -48
- package/dist/esm/visualization/object-like-output.js.map +0 -1
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import { longDependencyTypes } from '@vltpkg/types';
|
|
3
|
-
import { shorten, asDependency } from "../dependencies.js";
|
|
4
|
-
import { removeSatisfiedSpecs } from "./remove-satisfied-specs.js";
|
|
5
|
-
import { Spec } from '@vltpkg/spec';
|
|
6
|
-
const hasDepName = (importer, edge) => {
|
|
7
|
-
for (const depType of longDependencyTypes) {
|
|
8
|
-
const listedDeps = importer.manifest?.[depType];
|
|
9
|
-
if (listedDeps && Object.hasOwn(listedDeps, edge.name))
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
return false;
|
|
13
|
-
};
|
|
14
|
-
class AddImportersDependenciesMapImpl extends Map {
|
|
15
|
-
modifiedDependencies = false;
|
|
16
|
-
}
|
|
17
|
-
class RemoveImportersDependenciesMapImpl extends Map {
|
|
18
|
-
modifiedDependencies = false;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Given a {@link Graph} and a list of {@link Dependency}, merges the
|
|
22
|
-
* dependencies info found in the graph importers and returns the add & remove
|
|
23
|
-
* results as a Map in which keys are {@link DepID} of each importer node.
|
|
24
|
-
*/
|
|
25
|
-
export const getImporterSpecs = (options) => {
|
|
26
|
-
const { add, graph, remove } = options;
|
|
27
|
-
const addResult = new AddImportersDependenciesMapImpl();
|
|
28
|
-
const removeResult = new RemoveImportersDependenciesMapImpl();
|
|
29
|
-
// traverse the list of importers in the starting graph
|
|
30
|
-
for (const importer of graph.importers) {
|
|
31
|
-
// uses a Map keying to the spec.name in order to easily make sure there's
|
|
32
|
-
// only a single dependency entry for a given dependency for each importer
|
|
33
|
-
const addDeps = new Map();
|
|
34
|
-
const removeDeps = new Set();
|
|
35
|
-
// if an edge from the graph is not listed in the manifest,
|
|
36
|
-
// add that edge to the list of dependencies to be removed
|
|
37
|
-
for (const edge of importer.edgesOut.values()) {
|
|
38
|
-
if (!hasDepName(importer, edge) &&
|
|
39
|
-
!add.get(importer.id)?.has(edge.name)) {
|
|
40
|
-
removeDeps.add(edge.name);
|
|
41
|
-
removeResult.modifiedDependencies = true;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// if a dependency is listed in the manifest but not in the graph,
|
|
45
|
-
// add that dependency to the list of dependencies to be added
|
|
46
|
-
for (const depType of longDependencyTypes) {
|
|
47
|
-
const deps = Object.entries(importer.manifest?.[depType] ?? {});
|
|
48
|
-
for (const [depName, depSpec] of deps) {
|
|
49
|
-
const edge = importer.edgesOut.get(depName);
|
|
50
|
-
const dependency = asDependency({
|
|
51
|
-
spec: Spec.parse(depName, depSpec, options),
|
|
52
|
-
type: shorten(depType, depName, importer.manifest),
|
|
53
|
-
});
|
|
54
|
-
if (!edge?.to) {
|
|
55
|
-
addDeps.set(depName, dependency);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
addResult.set(importer.id, addDeps);
|
|
60
|
-
removeResult.set(importer.id, removeDeps);
|
|
61
|
-
}
|
|
62
|
-
// merges any provided specs to add to the current found results
|
|
63
|
-
for (const [id, addDeps] of add.entries()) {
|
|
64
|
-
const deps = addResult.get(id);
|
|
65
|
-
if (!deps) {
|
|
66
|
-
throw error('Not an importer', { found: id });
|
|
67
|
-
}
|
|
68
|
-
for (const [name, dep] of addDeps.entries()) {
|
|
69
|
-
deps.set(name, dep);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// Merges results from user-provided `remove` option with any remove
|
|
73
|
-
// results found from comparing the manifest with the loaded graph
|
|
74
|
-
for (const [key, removeSet] of remove) {
|
|
75
|
-
const importerRemoveItem = removeResult.get(key);
|
|
76
|
-
if (importerRemoveItem) {
|
|
77
|
-
for (const depName of removeSet) {
|
|
78
|
-
importerRemoveItem.add(depName);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
// Removes any references to an importer that no longer has specs
|
|
83
|
-
for (const [key, removeItem] of removeResult) {
|
|
84
|
-
if (removeItem.size === 0) {
|
|
85
|
-
removeResult.delete(key);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// removes already satisfied dependencies from the dependencies list
|
|
89
|
-
removeSatisfiedSpecs({
|
|
90
|
-
add: addResult,
|
|
91
|
-
graph,
|
|
92
|
-
});
|
|
93
|
-
// set the modifiedDependencies flag if any
|
|
94
|
-
// of the importers have modified dependencies
|
|
95
|
-
for (const addDeps of addResult.values()) {
|
|
96
|
-
if (addDeps.size > 0) {
|
|
97
|
-
addResult.modifiedDependencies = true;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
add: addResult,
|
|
103
|
-
remove: removeResult,
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
//# sourceMappingURL=get-importer-specs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-importer-specs.js","sourceRoot":"","sources":["../../../src/ideal/get-importer-specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAA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AI,GAAG,CAAC,EAAE,CAAC;YACrB,SAAS,CAAC,oBAAoB,GAAG,IAAI,CAAA;YACrC,MAAK;QACP,CAAC;IACH,CAAC;IAED,OAAO;QACL,GAAG,EAAE,SAAS;QACd,MAAM,EAAE,YAAY;KACrB,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { longDependencyTypes } from '@vltpkg/types'\nimport { shorten, asDependency } from '../dependencies.ts'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n} from '../dependencies.ts'\nimport { removeSatisfiedSpecs } from './remove-satisfied-specs.ts'\nimport type {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n BuildIdealRemoveOptions,\n} from './types.ts'\nimport type { Edge } from '../edge.ts'\nimport type { Node } from '../node.ts'\nimport type { Graph } from '../graph.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\n\nexport type GetImporterSpecsOptions = BuildIdealAddOptions &\n BuildIdealFromGraphOptions &\n BuildIdealRemoveOptions &\n SpecOptions\n\nconst hasDepName = (importer: Node, edge: Edge): boolean => {\n for (const depType of longDependencyTypes) {\n const listedDeps = importer.manifest?.[depType]\n if (listedDeps && Object.hasOwn(listedDeps, edge.name))\n return true\n }\n return false\n}\n\nclass AddImportersDependenciesMapImpl\n extends Map\n implements AddImportersDependenciesMap\n{\n modifiedDependencies = false\n}\n\nclass RemoveImportersDependenciesMapImpl\n extends Map\n implements RemoveImportersDependenciesMap\n{\n modifiedDependencies = false\n}\n\n/**\n * Given a {@link Graph} and a list of {@link Dependency}, merges the\n * dependencies info found in the graph importers and returns the add & remove\n * results as a Map in which keys are {@link DepID} of each importer node.\n */\nexport const getImporterSpecs = (\n options: GetImporterSpecsOptions,\n) => {\n const { add, graph, remove } = options\n const addResult: AddImportersDependenciesMap =\n new AddImportersDependenciesMapImpl()\n const removeResult: RemoveImportersDependenciesMap =\n new RemoveImportersDependenciesMapImpl()\n\n // traverse the list of importers in the starting graph\n for (const importer of graph.importers) {\n // uses a Map keying to the spec.name in order to easily make sure there's\n // only a single dependency entry for a given dependency for each importer\n const addDeps = new Map<string, Dependency>()\n const removeDeps = new Set<string>()\n // if an edge from the graph is not listed in the manifest,\n // add that edge to the list of dependencies to be removed\n for (const edge of importer.edgesOut.values()) {\n if (\n !hasDepName(importer, edge) &&\n !add.get(importer.id)?.has(edge.name)\n ) {\n removeDeps.add(edge.name)\n removeResult.modifiedDependencies = true\n }\n }\n // if a dependency is listed in the manifest but not in the graph,\n // add that dependency to the list of dependencies to be added\n for (const depType of longDependencyTypes) {\n const deps = Object.entries(importer.manifest?.[depType] ?? {})\n for (const [depName, depSpec] of deps) {\n const edge = importer.edgesOut.get(depName)\n const dependency = asDependency({\n spec: Spec.parse(depName, depSpec, options),\n type: shorten(depType, depName, importer.manifest),\n })\n if (!edge?.to) {\n addDeps.set(depName, dependency)\n }\n }\n }\n addResult.set(importer.id, addDeps)\n removeResult.set(importer.id, removeDeps)\n }\n\n // merges any provided specs to add to the current found results\n for (const [id, addDeps] of add.entries()) {\n const deps = addResult.get(id)\n if (!deps) {\n throw error('Not an importer', { found: id })\n }\n for (const [name, dep] of addDeps.entries()) {\n deps.set(name, dep)\n }\n }\n\n // Merges results from user-provided `remove` option with any remove\n // results found from comparing the manifest with the loaded graph\n for (const [key, removeSet] of remove) {\n const importerRemoveItem = removeResult.get(key)\n if (importerRemoveItem) {\n for (const depName of removeSet) {\n importerRemoveItem.add(depName)\n }\n }\n }\n\n // Removes any references to an importer that no longer has specs\n for (const [key, removeItem] of removeResult) {\n if (removeItem.size === 0) {\n removeResult.delete(key)\n }\n }\n\n // removes already satisfied dependencies from the dependencies list\n removeSatisfiedSpecs({\n add: addResult,\n graph,\n })\n\n // set the modifiedDependencies flag if any\n // of the importers have modified dependencies\n for (const addDeps of addResult.values()) {\n if (addDeps.size > 0) {\n addResult.modifiedDependencies = true\n break\n }\n }\n\n return {\n add: addResult,\n remove: removeResult,\n }\n}\n"]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { BuildIdealFromGraphOptions, BuildIdealRemoveOptions } from './types.ts';
|
|
2
|
-
export type RemoveNodesOptions = BuildIdealFromGraphOptions & BuildIdealRemoveOptions;
|
|
3
|
-
/**
|
|
4
|
-
* Remove nodes from the current `graph`.
|
|
5
|
-
*/
|
|
6
|
-
export declare const removeNodes: ({ graph, remove, }: RemoveNodesOptions) => void;
|
|
7
|
-
//# sourceMappingURL=remove-nodes.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-nodes.d.ts","sourceRoot":"","sources":["../../../src/ideal/remove-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,uBAAuB,EACxB,MAAM,YAAY,CAAA;AAGnB,MAAM,MAAM,kBAAkB,GAAG,0BAA0B,GACzD,uBAAuB,CAAA;AAEzB;;GAEG;AACH,eAAO,MAAM,WAAW,uBAGrB,kBAAkB,SAapB,CAAA"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
/**
|
|
3
|
-
* Remove nodes from the current `graph`.
|
|
4
|
-
*/
|
|
5
|
-
export const removeNodes = ({ graph, remove, }) => {
|
|
6
|
-
for (const [depID, names] of remove) {
|
|
7
|
-
const importer = graph.nodes.get(depID);
|
|
8
|
-
if (!importer) {
|
|
9
|
-
throw error('Could not find importer', { found: depID });
|
|
10
|
-
}
|
|
11
|
-
// Removes any edges / nodes pointing to the specified name
|
|
12
|
-
for (const name of names) {
|
|
13
|
-
const node = importer.edgesOut.get(name)?.to;
|
|
14
|
-
if (node)
|
|
15
|
-
graph.removeNode(node);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=remove-nodes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-nodes.js","sourceRoot":"","sources":["../../../src/ideal/remove-nodes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAK3C;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,KAAK,EACL,MAAM,GACa,EAAE,EAAE;IACvB,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACvC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,KAAK,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;QAC1D,CAAC;QAED,2DAA2D;QAC3D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,CAAA;YAC5C,IAAI,IAAI;gBAAE,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["import type {\n BuildIdealFromGraphOptions,\n BuildIdealRemoveOptions,\n} from './types.ts'\nimport { error } from '@vltpkg/error-cause'\n\nexport type RemoveNodesOptions = BuildIdealFromGraphOptions &\n BuildIdealRemoveOptions\n\n/**\n * Remove nodes from the current `graph`.\n */\nexport const removeNodes = ({\n graph,\n remove,\n}: RemoveNodesOptions) => {\n for (const [depID, names] of remove) {\n const importer = graph.nodes.get(depID)\n if (!importer) {\n throw error('Could not find importer', { found: depID })\n }\n\n // Removes any edges / nodes pointing to the specified name\n for (const name of names) {\n const node = importer.edgesOut.get(name)?.to\n if (node) graph.removeNode(node)\n }\n }\n}\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { BuildIdealAddOptions, BuildIdealFromGraphOptions } from './types.ts';
|
|
2
|
-
export type RemoveSatisfiedSpecsOptions = BuildIdealAddOptions & BuildIdealFromGraphOptions;
|
|
3
|
-
/**
|
|
4
|
-
* Traverse the objects defined in `add` and removes any references to specs
|
|
5
|
-
* that are already satisfied by the contents of the actual `graph`.
|
|
6
|
-
*/
|
|
7
|
-
export declare const removeSatisfiedSpecs: ({ add, graph, }: RemoveSatisfiedSpecsOptions) => void;
|
|
8
|
-
//# sourceMappingURL=remove-satisfied-specs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-satisfied-specs.d.ts","sourceRoot":"","sources":["../../../src/ideal/remove-satisfied-specs.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,2BAA2B,GAAG,oBAAoB,GAC5D,0BAA0B,CAAA;AAE5B;;;GAGG;AACH,eAAO,MAAM,oBAAoB,oBAG9B,2BAA2B,SAqC7B,CAAA"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import { satisfies } from '@vltpkg/satisfies';
|
|
3
|
-
/**
|
|
4
|
-
* Traverse the objects defined in `add` and removes any references to specs
|
|
5
|
-
* that are already satisfied by the contents of the actual `graph`.
|
|
6
|
-
*/
|
|
7
|
-
export const removeSatisfiedSpecs = ({ add, graph, }) => {
|
|
8
|
-
for (const [depID, dependencies] of add.entries()) {
|
|
9
|
-
const importer = graph.nodes.get(depID);
|
|
10
|
-
if (!importer) {
|
|
11
|
-
throw error('Referred importer node id could not be found', {
|
|
12
|
-
found: depID,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
for (const [name, dependency] of dependencies) {
|
|
16
|
-
const edge = importer.edgesOut.get(name);
|
|
17
|
-
if (!edge) {
|
|
18
|
-
// brand new edge being added
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
// If the current graph edge is already valid, then we remove that
|
|
22
|
-
// dependency item from the list of items to be added to the graph
|
|
23
|
-
if (satisfies(edge.to?.id, dependency.spec, edge.from.location, graph.projectRoot, graph.monorepo)) {
|
|
24
|
-
dependencies.delete(name);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// Removes any references to an importer that no longer has specs
|
|
29
|
-
for (const [depID, dependencies] of add.entries()) {
|
|
30
|
-
if (dependencies.size === 0) {
|
|
31
|
-
add.delete(depID);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=remove-satisfied-specs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remove-satisfied-specs.js","sourceRoot":"","sources":["../../../src/ideal/remove-satisfied-specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAS7C;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACnC,GAAG,EACH,KAAK,GACuB,EAAE,EAAE;IAChC,KAAK,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACvC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,KAAK,CAAC,8CAA8C,EAAE;gBAC1D,KAAK,EAAE,KAAK;aACb,CAAC,CAAA;QACJ,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,YAAY,EAAE,CAAC;YAC9C,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACxC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,6BAA6B;gBAC7B,SAAQ;YACV,CAAC;YAED,kEAAkE;YAClE,kEAAkE;YAClE,IACE,SAAS,CACP,IAAI,CAAC,EAAE,EAAE,EAAE,EACX,UAAU,CAAC,IAAI,EACf,IAAI,CAAC,IAAI,CAAC,QAAQ,EAClB,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,QAAQ,CACf,EACD,CAAC;gBACD,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YAC3B,CAAC;QACH,CAAC;IACH,CAAC;IAED,iEAAiE;IACjE,KAAK,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;QAClD,IAAI,YAAY,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC5B,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACnB,CAAC;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { satisfies } from '@vltpkg/satisfies'\nimport type {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n} from './types.ts'\n\nexport type RemoveSatisfiedSpecsOptions = BuildIdealAddOptions &\n BuildIdealFromGraphOptions\n\n/**\n * Traverse the objects defined in `add` and removes any references to specs\n * that are already satisfied by the contents of the actual `graph`.\n */\nexport const removeSatisfiedSpecs = ({\n add,\n graph,\n}: RemoveSatisfiedSpecsOptions) => {\n for (const [depID, dependencies] of add.entries()) {\n const importer = graph.nodes.get(depID)\n if (!importer) {\n throw error('Referred importer node id could not be found', {\n found: depID,\n })\n }\n for (const [name, dependency] of dependencies) {\n const edge = importer.edgesOut.get(name)\n if (!edge) {\n // brand new edge being added\n continue\n }\n\n // If the current graph edge is already valid, then we remove that\n // dependency item from the list of items to be added to the graph\n if (\n satisfies(\n edge.to?.id,\n dependency.spec,\n edge.from.location,\n graph.projectRoot,\n graph.monorepo,\n )\n ) {\n dependencies.delete(name)\n }\n }\n }\n\n // Removes any references to an importer that no longer has specs\n for (const [depID, dependencies] of add.entries()) {\n if (dependencies.size === 0) {\n add.delete(depID)\n }\n }\n}\n"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { PackageInfoClient } from '@vltpkg/package-info';
|
|
2
|
-
import type { AddImportersDependenciesMap, RemoveImportersDependenciesMap } from '../dependencies.ts';
|
|
3
|
-
import type { Graph } from '../graph.ts';
|
|
4
|
-
export type BuildIdealAddOptions = {
|
|
5
|
-
/**
|
|
6
|
-
* A {@link AddImportersDependenciesMap} in which keys are {@link DepID}
|
|
7
|
-
* linking to another `Map` in which keys are the dependency names and values
|
|
8
|
-
* are {@link Dependency}. This structure represents dependencies that need
|
|
9
|
-
* to be added to the importer represented by {@link DepID}.
|
|
10
|
-
*/
|
|
11
|
-
add: AddImportersDependenciesMap;
|
|
12
|
-
};
|
|
13
|
-
export type BuildIdealRemoveOptions = {
|
|
14
|
-
/**
|
|
15
|
-
* A {@link RemoveImportersDependenciesMap} object representing nodes to be
|
|
16
|
-
* removed from the ideal graph. Each {@link DepID} key represents an
|
|
17
|
-
* importer node and the `Set` of dependency names to be removed from its
|
|
18
|
-
* dependency list.
|
|
19
|
-
*/
|
|
20
|
-
remove: RemoveImportersDependenciesMap;
|
|
21
|
-
};
|
|
22
|
-
export type BuildIdealFromGraphOptions = {
|
|
23
|
-
/**
|
|
24
|
-
* An initial {@link Graph} to start building from, adding nodes to any
|
|
25
|
-
* missing edges and appending any new specs defined in `addSpecs`.
|
|
26
|
-
*/
|
|
27
|
-
graph: Graph;
|
|
28
|
-
};
|
|
29
|
-
export type BuildIdealPackageInfoOptions = {
|
|
30
|
-
/**
|
|
31
|
-
* A {@link PackageInfoClient} instance to read manifest info from.
|
|
32
|
-
*/
|
|
33
|
-
packageInfo: PackageInfoClient;
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ideal/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EACV,2BAA2B,EAE3B,8BAA8B,EAC/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;;;OAKG;IACH,GAAG,EAAE,2BAA2B,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;;OAKG;IACH,MAAM,EAAE,8BAA8B,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;OAGG;IACH,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG;IACzC;;OAEG;IACH,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA"}
|
package/dist/esm/ideal/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ideal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n} from '../dependencies.ts'\nimport type { Graph } from '../graph.ts'\n\nexport type BuildIdealAddOptions = {\n /**\n * A {@link AddImportersDependenciesMap} in which keys are {@link DepID}\n * linking to another `Map` in which keys are the dependency names and values\n * are {@link Dependency}. This structure represents dependencies that need\n * to be added to the importer represented by {@link DepID}.\n */\n add: AddImportersDependenciesMap\n}\n\nexport type BuildIdealRemoveOptions = {\n /**\n * A {@link RemoveImportersDependenciesMap} object representing nodes to be\n * removed from the ideal graph. Each {@link DepID} key represents an\n * importer node and the `Set` of dependency names to be removed from its\n * dependency list.\n */\n remove: RemoveImportersDependenciesMap\n}\n\nexport type BuildIdealFromGraphOptions = {\n /**\n * An initial {@link Graph} to start building from, adding nodes to any\n * missing edges and appending any new specs defined in `addSpecs`.\n */\n graph: Graph\n}\n\nexport type BuildIdealPackageInfoOptions = {\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n}\n"]}
|
package/dist/esm/index.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export * from './build.ts';
|
|
2
|
-
export * from './edge.ts';
|
|
3
|
-
export * from './graph.ts';
|
|
4
|
-
export * from './node.ts';
|
|
5
|
-
export * from './dependencies.ts';
|
|
6
|
-
export * from './lockfile/types.ts';
|
|
7
|
-
export * from './visualization/json-output.ts';
|
|
8
|
-
export * from './visualization/human-readable-output.ts';
|
|
9
|
-
export * from './visualization/mermaid-output.ts';
|
|
10
|
-
export * from './stringify-node.ts';
|
|
11
|
-
export * from './install.ts';
|
|
12
|
-
export * from './uninstall.ts';
|
|
13
|
-
export * from './update.ts';
|
|
14
|
-
export * from './diff.ts';
|
|
15
|
-
export * from './modifiers.ts';
|
|
16
|
-
export * from './virtual-root.ts';
|
|
17
|
-
import type { LoadOptions as ActualLoadOptions } from './actual/load.ts';
|
|
18
|
-
export declare const actual: {
|
|
19
|
-
load: (options: ActualLoadOptions) => import("./graph.ts").Graph;
|
|
20
|
-
};
|
|
21
|
-
import type { LoadOptions as LockfileLoadOptions } from './lockfile/load.ts';
|
|
22
|
-
export declare const lockfile: {
|
|
23
|
-
load: (options: LockfileLoadOptions) => import("./graph.ts").Graph;
|
|
24
|
-
loadEdges: (graph: import("@vltpkg/types").GraphLike, edges: import("./lockfile/types.ts").LockfileData["edges"], options: import("@vltpkg/spec").SpecOptions) => void;
|
|
25
|
-
loadNodes: (graph: import("@vltpkg/types").GraphLike, nodes: import("./lockfile/types.ts").LockfileData["nodes"], options: import("@vltpkg/spec").SpecOptions, actual?: import("@vltpkg/types").GraphLike, throwOnMissingManifest?: boolean) => void;
|
|
26
|
-
save: (options: Omit<import("./lockfile/save.ts").SaveOptions, "saveManifests">) => void;
|
|
27
|
-
};
|
|
28
|
-
export type { ActualLoadOptions, LockfileLoadOptions };
|
|
29
|
-
export type { SaveOptions } from './lockfile/save.ts';
|
|
30
|
-
import type { BuildIdealOptions } from './ideal/build.ts';
|
|
31
|
-
export type { BuildIdealOptions };
|
|
32
|
-
export declare const ideal: {
|
|
33
|
-
build: (options: BuildIdealOptions) => Promise<import("./graph.ts").Graph>;
|
|
34
|
-
};
|
|
35
|
-
export { reify } from './reify/index.ts';
|
|
36
|
-
export type { ReifyOptions } from './reify/index.ts';
|
|
37
|
-
export type { BuildResult } from './reify/build.ts';
|
|
38
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export * from "./build.js";
|
|
2
|
-
export * from "./edge.js";
|
|
3
|
-
export * from "./graph.js";
|
|
4
|
-
export * from "./node.js";
|
|
5
|
-
export * from "./dependencies.js";
|
|
6
|
-
export * from "./lockfile/types.js";
|
|
7
|
-
export * from "./visualization/json-output.js";
|
|
8
|
-
export * from "./visualization/human-readable-output.js";
|
|
9
|
-
export * from "./visualization/mermaid-output.js";
|
|
10
|
-
export * from "./stringify-node.js";
|
|
11
|
-
export * from "./install.js";
|
|
12
|
-
export * from "./uninstall.js";
|
|
13
|
-
export * from "./update.js";
|
|
14
|
-
export * from "./diff.js";
|
|
15
|
-
export * from "./modifiers.js";
|
|
16
|
-
export * from "./virtual-root.js";
|
|
17
|
-
import { load as actualLoad } from "./actual/load.js";
|
|
18
|
-
export const actual = { load: actualLoad };
|
|
19
|
-
import { load as lockfileLoad } from "./lockfile/load.js";
|
|
20
|
-
import { loadEdges } from "./lockfile/load-edges.js";
|
|
21
|
-
import { loadNodes } from "./lockfile/load-nodes.js";
|
|
22
|
-
import { save } from "./lockfile/save.js";
|
|
23
|
-
export const lockfile = {
|
|
24
|
-
load: lockfileLoad,
|
|
25
|
-
loadEdges,
|
|
26
|
-
loadNodes,
|
|
27
|
-
save,
|
|
28
|
-
};
|
|
29
|
-
import { build } from "./ideal/build.js";
|
|
30
|
-
export const ideal = { build };
|
|
31
|
-
export { reify } from "./reify/index.js";
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","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;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
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { PackageInfoClient } from '@vltpkg/package-info';
|
|
2
|
-
import type { LoadOptions } from './actual/load.ts';
|
|
3
|
-
import type { AddImportersDependenciesMap } from './dependencies.ts';
|
|
4
|
-
import type { DepID } from '@vltpkg/dep-id';
|
|
5
|
-
export type InstallOptions = LoadOptions & {
|
|
6
|
-
packageInfo: PackageInfoClient;
|
|
7
|
-
cleanInstall?: boolean;
|
|
8
|
-
allowScripts: string;
|
|
9
|
-
};
|
|
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;
|
|
16
|
-
graph: import("./graph.ts").Graph;
|
|
17
|
-
diff: import("./diff.ts").Diff;
|
|
18
|
-
}>;
|
|
19
|
-
//# sourceMappingURL=install.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { load as actualLoad } from "./actual/load.js";
|
|
2
|
-
import { build as idealBuild } from "./ideal/build.js";
|
|
3
|
-
import { reify } from "./reify/index.js";
|
|
4
|
-
import { GraphModifier } from "./modifiers.js";
|
|
5
|
-
import { init } from '@vltpkg/init';
|
|
6
|
-
import { error } from '@vltpkg/error-cause';
|
|
7
|
-
import { asError } from '@vltpkg/types';
|
|
8
|
-
import { getDependencies } from "./dependencies.js";
|
|
9
|
-
import { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
10
|
-
import { existsSync } from 'node:fs';
|
|
11
|
-
import { resolve } from 'node:path';
|
|
12
|
-
import { load as loadVirtual } from "./lockfile/load.js";
|
|
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";
|
|
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
|
-
}
|
|
21
|
-
if (options.expectLockfile || options.frozenLockfile) {
|
|
22
|
-
const lockfilePath = resolve(options.projectRoot, 'vlt-lock.json');
|
|
23
|
-
if (!existsSync(lockfilePath)) {
|
|
24
|
-
throw error('vlt-lock.json file is required when using --expect-lockfile, --frozen-lockfile, or ci command', {
|
|
25
|
-
path: lockfilePath,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
let mainManifest = undefined;
|
|
30
|
-
try {
|
|
31
|
-
mainManifest = options.packageJson.read(options.projectRoot);
|
|
32
|
-
}
|
|
33
|
-
catch (err) {
|
|
34
|
-
if (asError(err).message === 'Could not read package.json file') {
|
|
35
|
-
await init({ cwd: options.projectRoot });
|
|
36
|
-
mainManifest = options.packageJson.read(options.projectRoot, {
|
|
37
|
-
reload: true,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
throw err;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (options.frozenLockfile) {
|
|
45
|
-
if (add?.modifiedDependencies) {
|
|
46
|
-
const dependencies = [];
|
|
47
|
-
for (const [, deps] of add) {
|
|
48
|
-
for (const [name] of deps) {
|
|
49
|
-
dependencies.push(name);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
throw error('Cannot add dependencies when using --frozen-lockfile', { found: dependencies.join(', ') });
|
|
53
|
-
}
|
|
54
|
-
const lockfileGraph = loadVirtual({
|
|
55
|
-
...options,
|
|
56
|
-
mainManifest,
|
|
57
|
-
skipLoadingNodesOnModifiersChange: false,
|
|
58
|
-
});
|
|
59
|
-
const emptyAdd = Object.assign(new Map(), { modifiedDependencies: false });
|
|
60
|
-
const emptyRemove = Object.assign(new Map(), {
|
|
61
|
-
modifiedDependencies: false,
|
|
62
|
-
});
|
|
63
|
-
const importerSpecs = getImporterSpecs({
|
|
64
|
-
graph: lockfileGraph,
|
|
65
|
-
add: emptyAdd,
|
|
66
|
-
remove: emptyRemove,
|
|
67
|
-
...options,
|
|
68
|
-
});
|
|
69
|
-
// Check for spec changes by comparing package.json specs with lockfile edges
|
|
70
|
-
const specChanges = [];
|
|
71
|
-
for (const importer of lockfileGraph.importers) {
|
|
72
|
-
const deps = getDependencies(importer, options);
|
|
73
|
-
for (const [depName, dep] of deps) {
|
|
74
|
-
const edge = importer.edgesOut.get(depName);
|
|
75
|
-
if (edge?.spec) {
|
|
76
|
-
if (edge.spec.toString() !== dep.spec.toString()) {
|
|
77
|
-
const node = lockfileGraph.nodes.get(importer.id);
|
|
78
|
-
/* c8 ignore next */
|
|
79
|
-
const location = node?.location || importer.id;
|
|
80
|
-
specChanges.push(` ${location}: ${depName} spec changed from "${edge.spec}" to "${dep.spec}"`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (importerSpecs.add.modifiedDependencies ||
|
|
86
|
-
importerSpecs.remove.modifiedDependencies ||
|
|
87
|
-
specChanges.length > 0) {
|
|
88
|
-
const details = [];
|
|
89
|
-
if (specChanges.length > 0) {
|
|
90
|
-
details.push(...specChanges);
|
|
91
|
-
}
|
|
92
|
-
for (const [importerId, deps] of importerSpecs.add) {
|
|
93
|
-
if (deps.size > 0) {
|
|
94
|
-
const node = lockfileGraph.nodes.get(importerId);
|
|
95
|
-
const location = node?.location || importerId;
|
|
96
|
-
const depNames = Array.from(deps.keys());
|
|
97
|
-
details.push(` ${location}: ${deps.size} dependencies to add (${depNames.join(', ')})`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
for (const [importerId, deps] of importerSpecs.remove) {
|
|
101
|
-
if (deps.size > 0) {
|
|
102
|
-
const node = lockfileGraph.nodes.get(importerId);
|
|
103
|
-
const location = node?.location || importerId;
|
|
104
|
-
const depNames = Array.from(deps);
|
|
105
|
-
details.push(` ${location}: ${deps.size} dependencies to remove (${depNames.join(', ')})`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
const lockfilePath = resolve(options.projectRoot, 'vlt-lock.json');
|
|
109
|
-
throw error('Lockfile is out of sync with package.json. Run "vlt install" to update.\n' +
|
|
110
|
-
details.join('\n'), {
|
|
111
|
-
path: lockfilePath,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
const remover = new RollbackRemove();
|
|
116
|
-
if (options.cleanInstall) {
|
|
117
|
-
const nodeModulesPath = resolve(options.projectRoot, 'node_modules');
|
|
118
|
-
if (existsSync(nodeModulesPath)) {
|
|
119
|
-
await remover.rm(nodeModulesPath);
|
|
120
|
-
remover.confirm();
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
const modifiers = GraphModifier.maybeLoad(options);
|
|
125
|
-
const act = actualLoad({
|
|
126
|
-
...options,
|
|
127
|
-
mainManifest,
|
|
128
|
-
loadManifests: true,
|
|
129
|
-
modifiers: undefined, // modifiers should not be used here
|
|
130
|
-
});
|
|
131
|
-
const graph = await idealBuild({
|
|
132
|
-
...options,
|
|
133
|
-
actual: act,
|
|
134
|
-
add,
|
|
135
|
-
mainManifest,
|
|
136
|
-
loadManifests: true,
|
|
137
|
-
modifiers,
|
|
138
|
-
remover,
|
|
139
|
-
});
|
|
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({
|
|
157
|
-
...options,
|
|
158
|
-
add,
|
|
159
|
-
actual: act,
|
|
160
|
-
graph,
|
|
161
|
-
loadManifests: true,
|
|
162
|
-
modifiers,
|
|
163
|
-
remover,
|
|
164
|
-
});
|
|
165
|
-
return { buildQueue, graph, diff };
|
|
166
|
-
}
|
|
167
|
-
catch (err) {
|
|
168
|
-
/* c8 ignore next */
|
|
169
|
-
await remover.rollback().catch(() => { });
|
|
170
|
-
throw err;
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
//# sourceMappingURL=install.js.map
|
package/dist/esm/install.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;AAKnD,OAAO,EAAE,cAAc,EAAE,MAAM,yBA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AM,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,12 +0,0 @@
|
|
|
1
|
-
import { Spec } from '@vltpkg/spec/browser';
|
|
2
|
-
import type { SpecOptions } from '@vltpkg/spec/browser';
|
|
3
|
-
import type { DependencyTypeShort, GraphLike, NodeLike } from '@vltpkg/types';
|
|
4
|
-
import type { LockfileData } from './types.ts';
|
|
5
|
-
export type ProcessingEdge = {
|
|
6
|
-
fromNode: NodeLike;
|
|
7
|
-
toNode: NodeLike | undefined;
|
|
8
|
-
depType: DependencyTypeShort;
|
|
9
|
-
spec: Spec;
|
|
10
|
-
};
|
|
11
|
-
export declare const loadEdges: (graph: GraphLike, edges: LockfileData["edges"], options: SpecOptions) => void;
|
|
12
|
-
//# sourceMappingURL=load-edges.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load-edges.d.ts","sourceRoot":"","sources":["../../../src/lockfile/load-edges.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD,OAAO,KAAK,EACV,mBAAmB,EACnB,SAAS,EACT,QAAQ,EACT,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAK,EACV,YAAY,EAGb,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,QAAQ,CAAA;IAClB,MAAM,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC5B,OAAO,EAAE,mBAAmB,CAAA;IAC5B,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AA0BD,eAAO,MAAM,SAAS,UACb,SAAS,SACT,YAAY,CAAC,OAAO,CAAC,WACnB,WAAW,SA2GrB,CAAA"}
|