@vltpkg/graph 1.0.0-rc.9 → 1.0.2
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/dist/{esm/actual → actual}/load.d.ts +8 -1
- package/dist/{esm/actual → actual}/load.js +29 -6
- package/dist/{esm/browser.d.ts → browser.d.ts} +0 -1
- package/dist/{esm/browser.js → browser.js} +0 -1
- package/dist/{esm/build.d.ts → build.d.ts} +0 -1
- package/dist/{esm/build.js → build.js} +0 -1
- package/dist/{esm/dependencies.d.ts → dependencies.d.ts} +0 -1
- package/dist/{esm/dependencies.js → dependencies.js} +3 -2
- package/dist/{esm/diff.d.ts → diff.d.ts} +2 -1
- package/dist/{esm/diff.js → diff.js} +5 -2
- package/dist/{esm/edge.d.ts → edge.d.ts} +0 -1
- package/dist/{esm/edge.js → edge.js} +0 -1
- package/dist/{esm/fixup-added-names.d.ts → fixup-added-names.d.ts} +4 -2
- package/dist/{esm/fixup-added-names.js → fixup-added-names.js} +16 -1
- package/dist/{esm/graph.d.ts → graph.d.ts} +13 -1
- package/dist/{esm/graph.js → graph.js} +49 -12
- package/dist/{esm/ideal → ideal}/append-nodes.d.ts +14 -3
- package/dist/{esm/ideal → ideal}/append-nodes.js +252 -64
- package/dist/{esm/ideal → ideal}/build-ideal-from-starting-graph.d.ts +0 -1
- package/dist/{esm/ideal → ideal}/build-ideal-from-starting-graph.js +0 -1
- package/dist/{esm/ideal → ideal}/build.d.ts +0 -1
- package/dist/{esm/ideal → ideal}/build.js +15 -2
- package/dist/{esm/ideal → ideal}/get-importer-specs.d.ts +0 -1
- package/dist/{esm/ideal → ideal}/get-importer-specs.js +13 -2
- package/dist/ideal/peers.d.ts +160 -0
- package/dist/ideal/peers.js +696 -0
- package/dist/{esm/ideal → ideal}/refresh-ideal-graph.d.ts +0 -5
- package/dist/{esm/ideal → ideal}/refresh-ideal-graph.js +11 -26
- package/dist/{esm/ideal → ideal}/remove-satisfied-specs.d.ts +0 -1
- package/dist/{esm/ideal → ideal}/remove-satisfied-specs.js +8 -1
- package/dist/ideal/sorting.d.ts +45 -0
- package/dist/ideal/sorting.js +70 -0
- package/dist/{esm/ideal → ideal}/types.d.ts +1 -6
- package/dist/ideal/types.js +1 -0
- package/dist/{esm/index.d.ts → index.d.ts} +0 -1
- package/dist/{esm/index.js → index.js} +0 -1
- package/dist/{esm/install.d.ts → install.d.ts} +2 -1
- package/dist/{esm/install.js → install.js} +24 -4
- package/dist/{esm/lockfile → lockfile}/load-edges.d.ts +0 -1
- package/dist/{esm/lockfile → lockfile}/load-edges.js +16 -6
- package/dist/{esm/lockfile → lockfile}/load-nodes.d.ts +0 -1
- package/dist/{esm/lockfile → lockfile}/load-nodes.js +6 -3
- package/dist/{esm/lockfile → lockfile}/load.d.ts +0 -1
- package/dist/lockfile/load.js +171 -0
- package/dist/{esm/lockfile → lockfile}/save.d.ts +1 -2
- package/dist/{esm/lockfile → lockfile}/save.js +17 -11
- package/dist/{esm/lockfile → lockfile}/types.d.ts +7 -1
- package/dist/{esm/lockfile → lockfile}/types.js +6 -1
- package/dist/{esm/modifiers.d.ts → modifiers.d.ts} +0 -1
- package/dist/{esm/modifiers.js → modifiers.js} +0 -1
- package/dist/{esm/node.d.ts → node.d.ts} +2 -1
- package/dist/{esm/node.js → node.js} +5 -1
- package/dist/{esm/non-empty-list.d.ts → non-empty-list.d.ts} +0 -1
- package/dist/{esm/non-empty-list.js → non-empty-list.js} +0 -1
- package/dist/path-security-error.d.ts +5 -0
- package/dist/path-security-error.js +13 -0
- package/dist/{esm/reify → reify}/add-edge.d.ts +0 -1
- package/dist/{esm/reify → reify}/add-edge.js +10 -4
- package/dist/{esm/reify → reify}/add-edges.d.ts +0 -1
- package/dist/{esm/reify → reify}/add-edges.js +0 -1
- package/dist/{esm/reify → reify}/add-nodes.d.ts +0 -1
- package/dist/{esm/reify → reify}/add-nodes.js +0 -1
- package/dist/{esm/reify → reify}/bin-chmod.d.ts +0 -1
- package/dist/{esm/reify → reify}/bin-chmod.js +0 -1
- package/dist/{esm/reify → reify}/build.d.ts +0 -1
- package/dist/{esm/reify → reify}/build.js +12 -4
- package/dist/{esm/reify → reify}/calculate-save-value.d.ts +1 -2
- package/dist/{esm/reify → reify}/calculate-save-value.js +11 -5
- package/dist/{esm/reify → reify}/check-needed-build.d.ts +10 -1
- package/dist/reify/check-needed-build.js +71 -0
- package/dist/{esm/reify → reify}/delete-edge.d.ts +0 -1
- package/dist/{esm/reify → reify}/delete-edge.js +0 -1
- package/dist/{esm/reify → reify}/delete-edges.d.ts +0 -1
- package/dist/{esm/reify → reify}/delete-edges.js +0 -1
- package/dist/{esm/reify → reify}/delete-nodes.d.ts +0 -1
- package/dist/{esm/reify → reify}/delete-nodes.js +0 -1
- package/dist/{esm/reify → reify}/extract-node.d.ts +0 -1
- package/dist/{esm/reify → reify}/extract-node.js +10 -3
- package/dist/{esm/reify → reify}/index.d.ts +3 -1
- package/dist/{esm/reify → reify}/index.js +25 -5
- package/dist/{esm/reify → reify}/internal-hoist.d.ts +0 -1
- package/dist/{esm/reify → reify}/internal-hoist.js +0 -1
- package/dist/{esm/reify → reify}/optional-fail.d.ts +0 -1
- package/dist/{esm/reify → reify}/optional-fail.js +0 -1
- package/dist/{esm/reify → reify}/rollback.d.ts +0 -1
- package/dist/{esm/reify → reify}/rollback.js +0 -1
- package/dist/{esm/reify → reify}/update-importers-package-json.d.ts +11 -2
- package/dist/{esm/reify → reify}/update-importers-package-json.js +4 -5
- package/dist/{esm/remove-optional-subgraph.d.ts → remove-optional-subgraph.d.ts} +0 -1
- package/dist/{esm/remove-optional-subgraph.js → remove-optional-subgraph.js} +0 -1
- package/dist/{esm/resolve-save-type.d.ts → resolve-save-type.d.ts} +0 -1
- package/dist/{esm/resolve-save-type.js → resolve-save-type.js} +0 -1
- package/dist/{esm/stringify-node.d.ts → stringify-node.d.ts} +0 -1
- package/dist/{esm/stringify-node.js → stringify-node.js} +0 -1
- package/dist/{esm/transfer-data → transfer-data}/load.d.ts +0 -1
- package/dist/{esm/transfer-data → transfer-data}/load.js +8 -5
- package/dist/{esm/uninstall.d.ts → uninstall.d.ts} +0 -1
- package/dist/{esm/uninstall.js → uninstall.js} +17 -7
- package/dist/{esm/update.d.ts → update.d.ts} +0 -1
- package/dist/{esm/update.js → update.js} +1 -1
- package/dist/{esm/virtual-root.d.ts → virtual-root.d.ts} +0 -1
- package/dist/{esm/virtual-root.js → virtual-root.js} +0 -1
- package/dist/{esm/visualization → visualization}/human-readable-output.d.ts +0 -1
- package/dist/{esm/visualization → visualization}/human-readable-output.js +0 -1
- package/dist/{esm/visualization → visualization}/json-output.d.ts +0 -1
- package/dist/{esm/visualization → visualization}/json-output.js +0 -1
- package/dist/{esm/visualization → visualization}/mermaid-output.d.ts +2 -2
- package/dist/{esm/visualization → visualization}/mermaid-output.js +27 -21
- package/dist/{esm/visualization → visualization}/object-like-output.d.ts +0 -1
- package/dist/{esm/visualization → visualization}/object-like-output.js +0 -1
- package/package.json +57 -62
- package/dist/esm/actual/load.d.ts.map +0 -1
- package/dist/esm/actual/load.js.map +0 -1
- package/dist/esm/browser.d.ts.map +0 -1
- package/dist/esm/browser.js.map +0 -1
- package/dist/esm/build.d.ts.map +0 -1
- package/dist/esm/build.js.map +0 -1
- package/dist/esm/dependencies.d.ts.map +0 -1
- package/dist/esm/dependencies.js.map +0 -1
- package/dist/esm/diff.d.ts.map +0 -1
- package/dist/esm/diff.js.map +0 -1
- package/dist/esm/edge.d.ts.map +0 -1
- package/dist/esm/edge.js.map +0 -1
- package/dist/esm/fixup-added-names.d.ts.map +0 -1
- package/dist/esm/fixup-added-names.js.map +0 -1
- package/dist/esm/graph.d.ts.map +0 -1
- package/dist/esm/graph.js.map +0 -1
- package/dist/esm/ideal/append-nodes.d.ts.map +0 -1
- package/dist/esm/ideal/append-nodes.js.map +0 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +0 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +0 -1
- package/dist/esm/ideal/build.d.ts.map +0 -1
- package/dist/esm/ideal/build.js.map +0 -1
- package/dist/esm/ideal/get-importer-specs.d.ts.map +0 -1
- package/dist/esm/ideal/get-importer-specs.js.map +0 -1
- package/dist/esm/ideal/get-ordered-dependencies.d.ts +0 -10
- package/dist/esm/ideal/get-ordered-dependencies.d.ts.map +0 -1
- package/dist/esm/ideal/get-ordered-dependencies.js +0 -42
- package/dist/esm/ideal/get-ordered-dependencies.js.map +0 -1
- package/dist/esm/ideal/peers.d.ts +0 -71
- package/dist/esm/ideal/peers.d.ts.map +0 -1
- package/dist/esm/ideal/peers.js +0 -318
- package/dist/esm/ideal/peers.js.map +0 -1
- package/dist/esm/ideal/refresh-ideal-graph.d.ts.map +0 -1
- package/dist/esm/ideal/refresh-ideal-graph.js.map +0 -1
- package/dist/esm/ideal/remove-satisfied-specs.d.ts.map +0 -1
- package/dist/esm/ideal/remove-satisfied-specs.js.map +0 -1
- 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.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/install.d.ts.map +0 -1
- package/dist/esm/install.js.map +0 -1
- package/dist/esm/lockfile/load-edges.d.ts.map +0 -1
- package/dist/esm/lockfile/load-edges.js.map +0 -1
- package/dist/esm/lockfile/load-nodes.d.ts.map +0 -1
- package/dist/esm/lockfile/load-nodes.js.map +0 -1
- package/dist/esm/lockfile/load.d.ts.map +0 -1
- package/dist/esm/lockfile/load.js +0 -64
- package/dist/esm/lockfile/load.js.map +0 -1
- package/dist/esm/lockfile/save.d.ts.map +0 -1
- package/dist/esm/lockfile/save.js.map +0 -1
- package/dist/esm/lockfile/types.d.ts.map +0 -1
- package/dist/esm/lockfile/types.js.map +0 -1
- package/dist/esm/modifiers.d.ts.map +0 -1
- package/dist/esm/modifiers.js.map +0 -1
- package/dist/esm/node.d.ts.map +0 -1
- package/dist/esm/node.js.map +0 -1
- package/dist/esm/non-empty-list.d.ts.map +0 -1
- 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.map +0 -1
- package/dist/esm/reify/add-edge.js.map +0 -1
- package/dist/esm/reify/add-edges.d.ts.map +0 -1
- package/dist/esm/reify/add-edges.js.map +0 -1
- package/dist/esm/reify/add-nodes.d.ts.map +0 -1
- package/dist/esm/reify/add-nodes.js.map +0 -1
- package/dist/esm/reify/bin-chmod.d.ts.map +0 -1
- package/dist/esm/reify/bin-chmod.js.map +0 -1
- package/dist/esm/reify/build.d.ts.map +0 -1
- package/dist/esm/reify/build.js.map +0 -1
- package/dist/esm/reify/calculate-save-value.d.ts.map +0 -1
- package/dist/esm/reify/calculate-save-value.js.map +0 -1
- 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.map +0 -1
- package/dist/esm/reify/delete-edge.js.map +0 -1
- package/dist/esm/reify/delete-edges.d.ts.map +0 -1
- package/dist/esm/reify/delete-edges.js.map +0 -1
- package/dist/esm/reify/delete-nodes.d.ts.map +0 -1
- package/dist/esm/reify/delete-nodes.js.map +0 -1
- package/dist/esm/reify/extract-node.d.ts.map +0 -1
- package/dist/esm/reify/extract-node.js.map +0 -1
- package/dist/esm/reify/index.d.ts.map +0 -1
- package/dist/esm/reify/index.js.map +0 -1
- package/dist/esm/reify/internal-hoist.d.ts.map +0 -1
- package/dist/esm/reify/internal-hoist.js.map +0 -1
- package/dist/esm/reify/optional-fail.d.ts.map +0 -1
- package/dist/esm/reify/optional-fail.js.map +0 -1
- package/dist/esm/reify/rollback.d.ts.map +0 -1
- package/dist/esm/reify/rollback.js.map +0 -1
- package/dist/esm/reify/update-importers-package-json.d.ts.map +0 -1
- package/dist/esm/reify/update-importers-package-json.js.map +0 -1
- package/dist/esm/remove-optional-subgraph.d.ts.map +0 -1
- package/dist/esm/remove-optional-subgraph.js.map +0 -1
- package/dist/esm/resolve-save-type.d.ts.map +0 -1
- package/dist/esm/resolve-save-type.js.map +0 -1
- package/dist/esm/stringify-node.d.ts.map +0 -1
- package/dist/esm/stringify-node.js.map +0 -1
- package/dist/esm/transfer-data/load.d.ts.map +0 -1
- package/dist/esm/transfer-data/load.js.map +0 -1
- package/dist/esm/uninstall.d.ts.map +0 -1
- package/dist/esm/uninstall.js.map +0 -1
- package/dist/esm/update.d.ts.map +0 -1
- package/dist/esm/update.js.map +0 -1
- package/dist/esm/virtual-root.d.ts.map +0 -1
- package/dist/esm/virtual-root.js.map +0 -1
- package/dist/esm/visualization/human-readable-output.d.ts.map +0 -1
- package/dist/esm/visualization/human-readable-output.js.map +0 -1
- package/dist/esm/visualization/json-output.d.ts.map +0 -1
- package/dist/esm/visualization/json-output.js.map +0 -1
- package/dist/esm/visualization/mermaid-output.d.ts.map +0 -1
- package/dist/esm/visualization/mermaid-output.js.map +0 -1
- package/dist/esm/visualization/object-like-output.d.ts.map +0 -1
- package/dist/esm/visualization/object-like-output.js.map +0 -1
|
@@ -41,8 +41,3 @@ export type RefreshIdealGraphOptions = BuildIdealAddOptions & BuildIdealRemoveOp
|
|
|
41
41
|
* Rebuilds the provided ideal graph.
|
|
42
42
|
*/
|
|
43
43
|
export declare const refreshIdealGraph: ({ add, graph, modifiers, packageInfo, scurry, actual, remove, remover, transientAdd, transientRemove, ...specOptions }: RefreshIdealGraphOptions) => Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Retrieve the next unique index for a peer context set.
|
|
46
|
-
*/
|
|
47
|
-
export declare const nextPeerContextIndex: () => number;
|
|
48
|
-
//# sourceMappingURL=refresh-ideal-graph.d.ts.map
|
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
import { appendNodes } from "./append-nodes.js";
|
|
2
|
-
import { getNodeOrderedDependencies } from "./
|
|
2
|
+
import { compareByHasPeerDeps, getNodeOrderedDependencies, } from "./sorting.js";
|
|
3
3
|
/**
|
|
4
4
|
* Returns an ordered list of importer nodes.
|
|
5
5
|
*/
|
|
6
6
|
const getOrderedImporters = (graph) => {
|
|
7
7
|
const orderedImporters = [...graph.importers].sort((a, b) => {
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
1
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
1
|
|
16
|
-
: 0;
|
|
17
|
-
// importers with regular deps only first, with peer deps last
|
|
18
|
-
if (aIsPeer !== bIsPeer) {
|
|
19
|
-
return aIsPeer - bIsPeer;
|
|
20
|
-
}
|
|
21
|
-
// if both are in the same group, sort alphabetically by manifest name
|
|
22
|
-
return a.name.localeCompare(b.name, 'en');
|
|
8
|
+
// mainImporter always comes first
|
|
9
|
+
/* c8 ignore next */
|
|
10
|
+
if (a === graph.mainImporter)
|
|
11
|
+
return -1;
|
|
12
|
+
if (b === graph.mainImporter)
|
|
13
|
+
return 1;
|
|
14
|
+
return compareByHasPeerDeps({ manifest: a.manifest }, { manifest: b.manifest });
|
|
23
15
|
});
|
|
24
16
|
return orderedImporters;
|
|
25
17
|
};
|
|
@@ -40,7 +32,9 @@ export const refreshIdealGraph = async ({ add, graph, modifiers, packageInfo, sc
|
|
|
40
32
|
depsPerImporter.set(importer, deps);
|
|
41
33
|
}
|
|
42
34
|
// removes all edges to start recalculating the graph
|
|
43
|
-
if (add.modifiedDependencies ||
|
|
35
|
+
if (add.modifiedDependencies ||
|
|
36
|
+
remove.modifiedDependencies ||
|
|
37
|
+
graph.optionsChanged) {
|
|
44
38
|
graph.resetEdges();
|
|
45
39
|
}
|
|
46
40
|
// iterates on the list of dependencies per importer updating
|
|
@@ -68,12 +62,3 @@ export const refreshIdealGraph = async ({ add, graph, modifiers, packageInfo, sc
|
|
|
68
62
|
await Promise.all(extractPromises);
|
|
69
63
|
}
|
|
70
64
|
};
|
|
71
|
-
/**
|
|
72
|
-
* Global index to assign unique ids used to track peer context sets.
|
|
73
|
-
*/
|
|
74
|
-
let peerContextIndex = 0;
|
|
75
|
-
/**
|
|
76
|
-
* Retrieve the next unique index for a peer context set.
|
|
77
|
-
*/
|
|
78
|
-
export const nextPeerContextIndex = () => peerContextIndex++;
|
|
79
|
-
//# sourceMappingURL=refresh-ideal-graph.js.map
|
|
@@ -5,4 +5,3 @@ export type RemoveSatisfiedSpecsOptions = BuildIdealAddOptions & BuildIdealFromG
|
|
|
5
5
|
* that are already satisfied by the contents of the actual `graph`.
|
|
6
6
|
*/
|
|
7
7
|
export declare const removeSatisfiedSpecs: ({ add, graph, }: RemoveSatisfiedSpecsOptions) => void;
|
|
8
|
-
//# sourceMappingURL=remove-satisfied-specs.d.ts.map
|
|
@@ -18,6 +18,14 @@ export const removeSatisfiedSpecs = ({ add, graph, }) => {
|
|
|
18
18
|
// brand new edge being added
|
|
19
19
|
continue;
|
|
20
20
|
}
|
|
21
|
+
// If the spec type has changed (e.g., from "registry" to
|
|
22
|
+
// "catalog" or vice versa), keep it in the add list so the
|
|
23
|
+
// edge gets rebuilt with the updated spec, even if the
|
|
24
|
+
// resolved node is the same.
|
|
25
|
+
const edgeIsCatalog = edge.spec.type === 'catalog';
|
|
26
|
+
const depIsCatalog = dependency.spec.type === 'catalog';
|
|
27
|
+
if (edgeIsCatalog !== depIsCatalog)
|
|
28
|
+
continue;
|
|
21
29
|
// If the current graph edge is already valid, then we remove that
|
|
22
30
|
// dependency item from the list of items to be added to the graph
|
|
23
31
|
if (satisfies(edge.to?.id, dependency.spec, edge.from.location, graph.projectRoot, graph.monorepo)) {
|
|
@@ -32,4 +40,3 @@ export const removeSatisfiedSpecs = ({ add, graph, }) => {
|
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
42
|
};
|
|
35
|
-
//# sourceMappingURL=remove-satisfied-specs.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { BuildIdealAddOptions, BuildIdealRemoveOptions } from './types.ts';
|
|
2
|
+
import type { Spec } from '@vltpkg/spec';
|
|
3
|
+
import type { Manifest, NormalizedManifest } from '@vltpkg/types';
|
|
4
|
+
import type { Node } from '../node.ts';
|
|
5
|
+
import type { Dependency } from '../dependencies.ts';
|
|
6
|
+
type SortableByHasPeerDeps = {
|
|
7
|
+
/** Package manifest containing dependency information */
|
|
8
|
+
manifest?: Manifest | NormalizedManifest;
|
|
9
|
+
/** Package name */
|
|
10
|
+
name?: string;
|
|
11
|
+
/** Package specifier */
|
|
12
|
+
spec?: Spec;
|
|
13
|
+
};
|
|
14
|
+
type SortableByType = {
|
|
15
|
+
/** Dependency type (e.g., 'prod', 'dev', 'peer', 'peerOptional') */
|
|
16
|
+
type: string;
|
|
17
|
+
/** Target node with package name */
|
|
18
|
+
target?: {
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
/** Package specifier */
|
|
22
|
+
spec?: Spec;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a dependency type is a peer dependency.
|
|
26
|
+
*/
|
|
27
|
+
export declare const isPeerType: (type: string) => type is "peer" | "peerOptional";
|
|
28
|
+
/**
|
|
29
|
+
* Sorts a list of dependencies by whether they have peer dependencies.
|
|
30
|
+
*/
|
|
31
|
+
export declare const compareByHasPeerDeps: (a: SortableByHasPeerDeps, b: SortableByHasPeerDeps) => number;
|
|
32
|
+
/**
|
|
33
|
+
* Sorts a list of dependencies by type and name.
|
|
34
|
+
*/
|
|
35
|
+
export declare const compareByType: (a: SortableByType, b: SortableByType) => number;
|
|
36
|
+
/**
|
|
37
|
+
* Computes the ordered list of dependencies for an given node,
|
|
38
|
+
* taking into account additions and removals.
|
|
39
|
+
*/
|
|
40
|
+
export declare const getNodeOrderedDependencies: (fromNode: Node, options?: BuildIdealAddOptions & BuildIdealRemoveOptions) => Dependency[];
|
|
41
|
+
/**
|
|
42
|
+
* Sorts a list of dependencies by type.
|
|
43
|
+
*/
|
|
44
|
+
export declare const getOrderedDependencies: (deps: Dependency[]) => Dependency[];
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a dependency type is a peer dependency.
|
|
3
|
+
*/
|
|
4
|
+
export const isPeerType = (type) => type === 'peer' || type === 'peerOptional';
|
|
5
|
+
/**
|
|
6
|
+
* Sorts a list of dependencies by whether they have peer dependencies.
|
|
7
|
+
*/
|
|
8
|
+
export const compareByHasPeerDeps = (a, b) => {
|
|
9
|
+
const aHasPeer = (a.manifest?.peerDependencies &&
|
|
10
|
+
Object.keys(a.manifest.peerDependencies).length > 0) ?
|
|
11
|
+
1
|
|
12
|
+
: 0;
|
|
13
|
+
const bHasPeer = (b.manifest?.peerDependencies &&
|
|
14
|
+
Object.keys(b.manifest.peerDependencies).length > 0) ?
|
|
15
|
+
1
|
|
16
|
+
: 0;
|
|
17
|
+
if (aHasPeer !== bHasPeer)
|
|
18
|
+
return aHasPeer - bHasPeer;
|
|
19
|
+
const aName = a.manifest?.name || a.spec?.name || a.name || '';
|
|
20
|
+
const bName = b.manifest?.name ||
|
|
21
|
+
/* c8 ignore next - very hard to test */ b.spec?.name ||
|
|
22
|
+
b.name ||
|
|
23
|
+
'';
|
|
24
|
+
return aName.localeCompare(bName, 'en');
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Sorts a list of dependencies by type and name.
|
|
28
|
+
*/
|
|
29
|
+
export const compareByType = (a, b) => {
|
|
30
|
+
const aIsPeer = isPeerType(a.type) ? 1 : 0;
|
|
31
|
+
const bIsPeer = isPeerType(b.type) ? 1 : 0;
|
|
32
|
+
if (aIsPeer !== bIsPeer)
|
|
33
|
+
return aIsPeer - bIsPeer;
|
|
34
|
+
const aName = a.target?.name ?? a.spec?.name ?? '';
|
|
35
|
+
const bName = b.target?.name ?? b.spec?.name ?? '';
|
|
36
|
+
return aName.localeCompare(bName, 'en');
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Computes the ordered list of dependencies for an given node,
|
|
40
|
+
* taking into account additions and removals.
|
|
41
|
+
*/
|
|
42
|
+
export const getNodeOrderedDependencies = (fromNode, options) => {
|
|
43
|
+
// using a map here instead of an array helps us get simpler
|
|
44
|
+
// deduplication while iterating through all the items at hand:
|
|
45
|
+
// existing dependencies in the graph, dependencies to be added, etc.
|
|
46
|
+
const deps = new Map();
|
|
47
|
+
for (const [name, { spec, type }] of fromNode.edgesOut.entries()) {
|
|
48
|
+
deps.set(name, { spec, type });
|
|
49
|
+
}
|
|
50
|
+
// next iterate through the list of dependencies to be added
|
|
51
|
+
const addedDeps = options?.add.get(fromNode.id);
|
|
52
|
+
if (addedDeps) {
|
|
53
|
+
for (const [name, { spec, type }] of addedDeps.entries()) {
|
|
54
|
+
deps.set(name, { spec, type });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// finally iterate through the list of dependencies to be removed
|
|
58
|
+
const removedDeps = options?.remove.get(fromNode.id);
|
|
59
|
+
if (removedDeps) {
|
|
60
|
+
for (const name of removedDeps) {
|
|
61
|
+
deps.delete(name);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// now turn the map into a sorted array
|
|
65
|
+
return getOrderedDependencies([...deps.values()]);
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Sorts a list of dependencies by type.
|
|
69
|
+
*/
|
|
70
|
+
export const getOrderedDependencies = (deps) => [...deps].sort(compareByType);
|
|
@@ -59,11 +59,7 @@ export type AppendNodeEntry = {
|
|
|
59
59
|
depth: number;
|
|
60
60
|
peerContext: PeerContext;
|
|
61
61
|
updateContext: {
|
|
62
|
-
putEntries: () =>
|
|
63
|
-
dependent: Node;
|
|
64
|
-
spec: Spec;
|
|
65
|
-
type: DependencySaveType;
|
|
66
|
-
}[] | undefined;
|
|
62
|
+
putEntries: () => PeerContextEntryInput[] | undefined;
|
|
67
63
|
resolvePeerDeps: () => void;
|
|
68
64
|
};
|
|
69
65
|
};
|
|
@@ -109,4 +105,3 @@ export type PeerContextEntryInput = {
|
|
|
109
105
|
export type PeerContext = Map<string, PeerContextEntry> & {
|
|
110
106
|
index?: number;
|
|
111
107
|
};
|
|
112
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,6 +7,8 @@ export type InstallOptions = LoadOptions & {
|
|
|
7
7
|
packageInfo: PackageInfoClient;
|
|
8
8
|
cleanInstall?: boolean;
|
|
9
9
|
allowScripts: string;
|
|
10
|
+
saveExact?: boolean;
|
|
11
|
+
savePrefix?: string;
|
|
10
12
|
};
|
|
11
13
|
export declare const install: (options: InstallOptions, add?: AddImportersDependenciesMap) => Promise<{
|
|
12
14
|
graph: Graph;
|
|
@@ -17,4 +19,3 @@ export declare const install: (options: InstallOptions, add?: AddImportersDepend
|
|
|
17
19
|
graph: Graph;
|
|
18
20
|
diff: import("./diff.ts").Diff;
|
|
19
21
|
}>;
|
|
20
|
-
//# sourceMappingURL=install.d.ts.map
|
|
@@ -13,6 +13,7 @@ import { load as loadVirtual } from "./lockfile/load.js";
|
|
|
13
13
|
import { getImporterSpecs } from "./ideal/get-importer-specs.js";
|
|
14
14
|
import { lockfile } from "./index.js";
|
|
15
15
|
import { updatePackageJson } from "./reify/update-importers-package-json.js";
|
|
16
|
+
import { Monorepo } from '@vltpkg/workspaces';
|
|
16
17
|
export const install = async (options, add) => {
|
|
17
18
|
// Validate incompatible options
|
|
18
19
|
if (options.lockfileOnly && options.cleanInstall) {
|
|
@@ -41,6 +42,14 @@ export const install = async (options, add) => {
|
|
|
41
42
|
throw err;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
45
|
+
// Load an unfiltered monorepo to ensure all workspace importers are
|
|
46
|
+
// included in the graph. This is necessary because the options.monorepo
|
|
47
|
+
// may be filtered by -w/--workspace flags, which would cause nodes/edges
|
|
48
|
+
// from other workspaces to be lost during graph construction.
|
|
49
|
+
const fullMonorepo = Monorepo.maybeLoad(options.projectRoot, {
|
|
50
|
+
packageJson: options.packageJson,
|
|
51
|
+
scurry: options.scurry,
|
|
52
|
+
});
|
|
44
53
|
if (options.frozenLockfile) {
|
|
45
54
|
// validates no add/remove operations are requested
|
|
46
55
|
if (add?.modifiedDependencies) {
|
|
@@ -55,6 +64,7 @@ export const install = async (options, add) => {
|
|
|
55
64
|
const lockfileGraph = loadVirtual({
|
|
56
65
|
...options,
|
|
57
66
|
mainManifest,
|
|
67
|
+
monorepo: fullMonorepo,
|
|
58
68
|
});
|
|
59
69
|
const emptyAdd = Object.assign(new Map(), { modifiedDependencies: false });
|
|
60
70
|
const emptyRemove = Object.assign(new Map(), {
|
|
@@ -84,8 +94,12 @@ export const install = async (options, add) => {
|
|
|
84
94
|
}
|
|
85
95
|
if (importerSpecs.add.modifiedDependencies ||
|
|
86
96
|
importerSpecs.remove.modifiedDependencies ||
|
|
87
|
-
specChanges.length > 0
|
|
97
|
+
specChanges.length > 0 ||
|
|
98
|
+
lockfileGraph.optionsChanged) {
|
|
88
99
|
const details = [];
|
|
100
|
+
if (lockfileGraph.optionsChanged) {
|
|
101
|
+
details.push(' Configuration options have changed (e.g. modifiers, registries, catalogs)');
|
|
102
|
+
}
|
|
89
103
|
if (specChanges.length > 0) {
|
|
90
104
|
details.push(...specChanges);
|
|
91
105
|
}
|
|
@@ -134,6 +148,7 @@ export const install = async (options, add) => {
|
|
|
134
148
|
mainManifest,
|
|
135
149
|
loadManifests: true,
|
|
136
150
|
modifiers: undefined, // modifiers should not be used here
|
|
151
|
+
monorepo: fullMonorepo,
|
|
137
152
|
});
|
|
138
153
|
// if the actual graph has no dependencies, it's simpler to ignore it
|
|
139
154
|
// this allows us to check for its availability later on for properly
|
|
@@ -150,11 +165,17 @@ export const install = async (options, add) => {
|
|
|
150
165
|
modifiers,
|
|
151
166
|
remove,
|
|
152
167
|
remover,
|
|
168
|
+
monorepo: fullMonorepo,
|
|
153
169
|
});
|
|
154
170
|
// If lockfileOnly is enabled, skip reify and only save the lockfile
|
|
155
171
|
if (options.lockfileOnly) {
|
|
156
|
-
// Save only the main lockfile, skip all filesystem operations
|
|
157
|
-
|
|
172
|
+
// Save only the main lockfile, skip all filesystem operations.
|
|
173
|
+
// Spread `options` so that spec-level config (registry,
|
|
174
|
+
// scoped-registries, git-hosts, catalogs, etc.) round-trips
|
|
175
|
+
// through the lockfile - otherwise subsequent installs lose
|
|
176
|
+
// the configured registry and rewrite node/edge DepIDs back
|
|
177
|
+
// to the default npm registry. (See vltpkg/vltpkg#1580.)
|
|
178
|
+
lockfile.save({ ...options, graph, modifiers });
|
|
158
179
|
const saveImportersPackageJson =
|
|
159
180
|
/* c8 ignore next */
|
|
160
181
|
add?.modifiedDependencies || remove.modifiedDependencies ?
|
|
@@ -194,4 +215,3 @@ export const install = async (options, add) => {
|
|
|
194
215
|
throw err;
|
|
195
216
|
}
|
|
196
217
|
};
|
|
197
|
-
//# sourceMappingURL=install.js.map
|
|
@@ -7,6 +7,11 @@ import { isDependencyTypeShort } from "../dependencies.js";
|
|
|
7
7
|
const retrieveNodeFromGraph = (key, value, graph, fromId, seenNodes) => {
|
|
8
8
|
const foundNode = graph.nodes.get(asDepID(fromId));
|
|
9
9
|
if (!foundNode) {
|
|
10
|
+
// workspace or file nodes may be missing if the folder was removed
|
|
11
|
+
// while still referenced in the lockfile — skip gracefully
|
|
12
|
+
if (fromId.startsWith('workspace') || fromId.startsWith('file')) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
10
15
|
throw error('Edge info missing its `from` node', {
|
|
11
16
|
found: {
|
|
12
17
|
nodes: [...graph.nodes].map(([id]) => id),
|
|
@@ -59,6 +64,9 @@ export const loadEdges = (graph, edges, options) => {
|
|
|
59
64
|
else {
|
|
60
65
|
fromNode = retrieveNodeFromGraph(key, value, graph, fromId);
|
|
61
66
|
}
|
|
67
|
+
// skip edges from workspace nodes that no longer exist
|
|
68
|
+
if (!fromNode)
|
|
69
|
+
continue;
|
|
62
70
|
const toId = valRest.substring(vrSplit + 1);
|
|
63
71
|
let toNode = undefined;
|
|
64
72
|
if (toId !== 'MISSING') {
|
|
@@ -78,11 +86,14 @@ export const loadEdges = (graph, edges, options) => {
|
|
|
78
86
|
toNode = graph.nodes.get(asDepID(toId));
|
|
79
87
|
}
|
|
80
88
|
}
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
89
|
+
// Use the merged options directly — they already carry the
|
|
90
|
+
// correct registry from the lockfile's `options` + caller config.
|
|
91
|
+
// `fromNode.registry` is not populated yet at this point (the
|
|
92
|
+
// post-load hydration loop in load.ts sets it *after* edges are
|
|
93
|
+
// loaded), so overriding here would always inject `undefined`
|
|
94
|
+
// and silently revert to the default npm registry.
|
|
95
|
+
// See vltpkg/vltpkg#1580.
|
|
96
|
+
const spec = Spec.parse(specName, valRest.substring(0, vrSplit), options);
|
|
86
97
|
if (useOptimizations) {
|
|
87
98
|
edgeProcessingQueue.push({
|
|
88
99
|
fromNode,
|
|
@@ -103,4 +114,3 @@ export const loadEdges = (graph, edges, options) => {
|
|
|
103
114
|
}
|
|
104
115
|
}
|
|
105
116
|
};
|
|
106
|
-
//# sourceMappingURL=load-edges.js.map
|
|
@@ -2,4 +2,3 @@ import type { LockfileData } from './types.ts';
|
|
|
2
2
|
import type { GraphLike } from '@vltpkg/types';
|
|
3
3
|
import type { SpecOptions } from '@vltpkg/spec/browser';
|
|
4
4
|
export declare const loadNodes: (graph: GraphLike, nodes: LockfileData["nodes"], options: SpecOptions, actual?: GraphLike, throwOnMissingManifest?: boolean) => void;
|
|
5
|
-
//# sourceMappingURL=load-nodes.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
|
-
import { splitDepID, splitExtra } from '@vltpkg/dep-id/browser';
|
|
2
|
+
import { asDepID, splitDepID, splitExtra, } from '@vltpkg/dep-id/browser';
|
|
3
3
|
import { getBooleanFlagsFromNum, getBuildStateFromNum, } from "./types.js";
|
|
4
4
|
export const loadNodes = (graph, nodes, options, actual, throwOnMissingManifest) => {
|
|
5
5
|
const entries = Object.entries(nodes);
|
|
@@ -8,6 +8,9 @@ export const loadNodes = (graph, nodes, options, actual, throwOnMissingManifest)
|
|
|
8
8
|
// Only used for non-trivial graphs
|
|
9
9
|
const registryVersionCache = nodeCount > 50 ? new Map() : null;
|
|
10
10
|
for (const [id, lockfileNode] of entries) {
|
|
11
|
+
// lockfile keys have never been through `encode`, so they can hold
|
|
12
|
+
// anything, and the id is the store directory name
|
|
13
|
+
asDepID(id);
|
|
11
14
|
const [flags, name, integrity, resolved, location, manifest, rawManifest, platform, bins, buildState,] = lockfileNode;
|
|
12
15
|
// workspace nodes and the project root node are already part of the
|
|
13
16
|
// graph and it should not create new nodes if an existing one is there
|
|
@@ -68,7 +71,8 @@ export const loadNodes = (graph, nodes, options, actual, throwOnMissingManifest)
|
|
|
68
71
|
node.dev = dev;
|
|
69
72
|
node.optional = optional;
|
|
70
73
|
node.integrity = integrity ?? referenceNode?.integrity;
|
|
71
|
-
node.resolved =
|
|
74
|
+
node.resolved =
|
|
75
|
+
type === 'remote' ? filepath : ((resolved ?? referenceNode?.resolved));
|
|
72
76
|
node.projectRoot = graph.projectRoot;
|
|
73
77
|
if (!node.resolved)
|
|
74
78
|
node.setResolved();
|
|
@@ -98,4 +102,3 @@ export const loadNodes = (graph, nodes, options, actual, throwOnMissingManifest)
|
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
104
|
};
|
|
101
|
-
//# sourceMappingURL=load-nodes.js.map
|
|
@@ -43,4 +43,3 @@ export type LoadOptions = SpecOptions & {
|
|
|
43
43
|
export declare const load: (options: LoadOptions) => Graph;
|
|
44
44
|
export declare const loadHidden: (options: LoadOptions) => Graph;
|
|
45
45
|
export declare const loadObject: (options: LoadOptions, lockfileData: Omit<LockfileData, "options" | "lockfileVersion"> & Partial<Pick<LockfileData, "options" | "lockfileVersion">>) => Graph;
|
|
46
|
-
//# sourceMappingURL=load.d.ts.map
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { PackageJson } from '@vltpkg/package-json';
|
|
3
|
+
import { defaultGitHostArchives, defaultGitHosts, defaultJsrRegistries, defaultRegistries, defaultRegistryName, defaultScopeRegistries, } from '@vltpkg/spec';
|
|
4
|
+
import { isRecordStringString } from '@vltpkg/types';
|
|
5
|
+
import { Monorepo } from '@vltpkg/workspaces';
|
|
6
|
+
import { readFileSync } from 'node:fs';
|
|
7
|
+
import { resolve } from 'node:path';
|
|
8
|
+
import { loadEdges } from "./load-edges.js";
|
|
9
|
+
import { loadNodes } from "./load-nodes.js";
|
|
10
|
+
import { Graph } from "../graph.js";
|
|
11
|
+
import { LOCKFILE_VERSION } from "./types.js";
|
|
12
|
+
const loadLockfile = (projectRoot, lockfilePath) => JSON.parse(readFileSync(resolve(projectRoot, lockfilePath), {
|
|
13
|
+
encoding: 'utf8',
|
|
14
|
+
}));
|
|
15
|
+
export const load = (options) => {
|
|
16
|
+
const { projectRoot } = options;
|
|
17
|
+
return loadObject(options, loadLockfile(projectRoot, 'vlt-lock.json'));
|
|
18
|
+
};
|
|
19
|
+
export const loadHidden = (options) => {
|
|
20
|
+
const { projectRoot } = options;
|
|
21
|
+
// Ensure that missing manifests throw an error when loading hidden lockfiles
|
|
22
|
+
options.throwOnMissingManifest = true;
|
|
23
|
+
return loadObject(options, loadLockfile(projectRoot, 'node_modules/.vlt-lock.json'));
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Removes entries from `items` that match the corresponding
|
|
27
|
+
* entry in `defaultItems`, returning only non-default values.
|
|
28
|
+
*/
|
|
29
|
+
const removeDefaultItems = (defaultItems, items) => {
|
|
30
|
+
const res = {};
|
|
31
|
+
for (const [key, value] of Object.entries(items)) {
|
|
32
|
+
if (!defaultItems[key] || defaultItems[key] !== value) {
|
|
33
|
+
res[key] = value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return res;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Builds a normalized options object from the current runtime config
|
|
40
|
+
* using the same cleaning logic as `lockfile/save.ts` so that it can
|
|
41
|
+
* be compared directly against the options stored in a lockfile.
|
|
42
|
+
*/
|
|
43
|
+
const buildCurrentOptions = (options) => {
|
|
44
|
+
const hasItems = (o) => o && Object.keys(o).length > 0;
|
|
45
|
+
const cleanModifiers = (options.modifiers &&
|
|
46
|
+
isRecordStringString(options.modifiers.config)) ?
|
|
47
|
+
options.modifiers.config
|
|
48
|
+
: undefined;
|
|
49
|
+
const cleanRegistries = isRecordStringString(options.registries) ?
|
|
50
|
+
removeDefaultItems(defaultRegistries, options.registries)
|
|
51
|
+
: undefined;
|
|
52
|
+
const cleanScopeRegistries = isRecordStringString(options['scoped-registries']) ?
|
|
53
|
+
removeDefaultItems(defaultScopeRegistries, options['scoped-registries'])
|
|
54
|
+
: undefined;
|
|
55
|
+
const cleanJsrRegistries = isRecordStringString(options['jsr-registries']) ?
|
|
56
|
+
removeDefaultItems(defaultJsrRegistries, options['jsr-registries'])
|
|
57
|
+
: undefined;
|
|
58
|
+
const cleanGitHosts = isRecordStringString(options['git-hosts']) ?
|
|
59
|
+
removeDefaultItems(defaultGitHosts, options['git-hosts'])
|
|
60
|
+
: undefined;
|
|
61
|
+
const cleanGitHostArchives = isRecordStringString(options['git-host-archives']) ?
|
|
62
|
+
removeDefaultItems(defaultGitHostArchives, options['git-host-archives'])
|
|
63
|
+
: undefined;
|
|
64
|
+
return {
|
|
65
|
+
...(hasItems(cleanModifiers) ?
|
|
66
|
+
{ modifiers: cleanModifiers }
|
|
67
|
+
: {}),
|
|
68
|
+
...(hasItems(options.catalog) ?
|
|
69
|
+
{ catalog: options.catalog }
|
|
70
|
+
: {}),
|
|
71
|
+
...(hasItems(options.catalogs) ?
|
|
72
|
+
{ catalogs: options.catalogs }
|
|
73
|
+
: {}),
|
|
74
|
+
...(hasItems(cleanScopeRegistries) ?
|
|
75
|
+
{ 'scoped-registries': cleanScopeRegistries }
|
|
76
|
+
: undefined),
|
|
77
|
+
...(hasItems(cleanJsrRegistries) ?
|
|
78
|
+
{ 'jsr-registries': cleanJsrRegistries }
|
|
79
|
+
: undefined),
|
|
80
|
+
...(options.registry !== undefined ?
|
|
81
|
+
{ registry: options.registry }
|
|
82
|
+
: undefined),
|
|
83
|
+
...((options['default-registry-alias'] !== undefined &&
|
|
84
|
+
options['default-registry-alias'] !== defaultRegistryName) ?
|
|
85
|
+
{ 'default-registry-alias': options['default-registry-alias'] }
|
|
86
|
+
: undefined),
|
|
87
|
+
...(hasItems(cleanRegistries) ?
|
|
88
|
+
{ registries: cleanRegistries }
|
|
89
|
+
: undefined),
|
|
90
|
+
...(hasItems(cleanGitHosts) ?
|
|
91
|
+
{ 'git-hosts': cleanGitHosts }
|
|
92
|
+
: undefined),
|
|
93
|
+
...(hasItems(cleanGitHostArchives) ?
|
|
94
|
+
{ 'git-host-archives': cleanGitHostArchives }
|
|
95
|
+
: undefined),
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
export const loadObject = (options, lockfileData) => {
|
|
99
|
+
const version = lockfileData.lockfileVersion;
|
|
100
|
+
// Lockfile version is required, likely a corrupted lockfile if missing
|
|
101
|
+
if (version == null) {
|
|
102
|
+
throw error('Missing lockfile version', {
|
|
103
|
+
code: 'ELOCKFILEVERSION',
|
|
104
|
+
found: version,
|
|
105
|
+
wanted: LOCKFILE_VERSION,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
// Lockfile version must match current version
|
|
109
|
+
if (version !== LOCKFILE_VERSION) {
|
|
110
|
+
throw error(`Unsupported lockfile version.
|
|
111
|
+
|
|
112
|
+
Run: \`vlt update\` to start a new, supported lockfile.`, {
|
|
113
|
+
code: 'ELOCKFILEVERSION',
|
|
114
|
+
found: version,
|
|
115
|
+
wanted: LOCKFILE_VERSION,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
const { mainManifest, scurry } = options;
|
|
119
|
+
const packageJson = options.packageJson ?? new PackageJson();
|
|
120
|
+
const monorepo = options.monorepo ??
|
|
121
|
+
Monorepo.maybeLoad(options.projectRoot, { packageJson, scurry });
|
|
122
|
+
const { catalog = {}, catalogs = {}, 'scoped-registries': scopedRegistriesOption, registry, registries, 'default-registry-alias': defaultRegistryAlias, 'git-hosts': gitHosts, 'git-host-archives': gitHostArchives,
|
|
123
|
+
/* c8 ignore next */
|
|
124
|
+
} = lockfileData.options ?? {};
|
|
125
|
+
// backwards-compat: legacy lockfiles wrote this field as `scope-registries`
|
|
126
|
+
const scopeRegistries = scopedRegistriesOption ??
|
|
127
|
+
lockfileData.options['scope-registries'];
|
|
128
|
+
// Detect whether the current config options differ from those
|
|
129
|
+
// stored in the lockfile. When they do the ideal builder must
|
|
130
|
+
// reset edges and rebuild the graph.
|
|
131
|
+
const currentOptions = buildCurrentOptions(options);
|
|
132
|
+
/* c8 ignore next */
|
|
133
|
+
const lockfileOptions = lockfileData.options ?? {};
|
|
134
|
+
const optionsChanged = JSON.stringify(currentOptions) !== JSON.stringify(lockfileOptions);
|
|
135
|
+
// Optimize options merging - only create new objects when needed
|
|
136
|
+
const mergedOptions = {
|
|
137
|
+
...options,
|
|
138
|
+
catalog,
|
|
139
|
+
catalogs,
|
|
140
|
+
'scoped-registries': scopeRegistries ?
|
|
141
|
+
{ ...options['scoped-registries'], ...scopeRegistries }
|
|
142
|
+
: options['scoped-registries'],
|
|
143
|
+
registry: registry ?? options.registry,
|
|
144
|
+
'default-registry-alias': defaultRegistryAlias ?? options['default-registry-alias'],
|
|
145
|
+
registries: registries ?
|
|
146
|
+
{ ...options.registries, ...registries }
|
|
147
|
+
: options.registries,
|
|
148
|
+
'git-hosts': gitHosts ?
|
|
149
|
+
{ ...options['git-hosts'], ...gitHosts }
|
|
150
|
+
: options['git-hosts'],
|
|
151
|
+
'git-host-archives': gitHostArchives ?
|
|
152
|
+
{ ...options['git-host-archives'], ...gitHostArchives }
|
|
153
|
+
: options['git-host-archives'],
|
|
154
|
+
};
|
|
155
|
+
const graph = new Graph({
|
|
156
|
+
...mergedOptions,
|
|
157
|
+
mainManifest,
|
|
158
|
+
monorepo,
|
|
159
|
+
});
|
|
160
|
+
graph.optionsChanged = optionsChanged;
|
|
161
|
+
loadNodes(graph, lockfileData.nodes, mergedOptions, options.actual, options.throwOnMissingManifest);
|
|
162
|
+
loadEdges(graph, lockfileData.edges, mergedOptions);
|
|
163
|
+
// hydrate missing node-level registry data
|
|
164
|
+
for (const node of graph.nodes.values()) {
|
|
165
|
+
const [firstEdge] = node.edgesIn;
|
|
166
|
+
if (firstEdge?.spec.registry) {
|
|
167
|
+
node.registry = firstEdge.spec.registry;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return graph;
|
|
171
|
+
};
|
|
@@ -24,8 +24,7 @@ export type SaveOptions = SpecOptions & {
|
|
|
24
24
|
*/
|
|
25
25
|
throwOnMissingManifest?: boolean;
|
|
26
26
|
};
|
|
27
|
-
export declare const lockfileData: ({ graph, catalog, catalogs, "git-hosts": gitHosts, "git-host-archives": gitHostArchives, modifiers, registry, registries, saveManifests, saveBuildData, "
|
|
27
|
+
export declare const lockfileData: ({ graph, catalog, catalogs, "git-hosts": gitHosts, "git-host-archives": gitHostArchives, modifiers, registry, registries, "default-registry-alias": defaultRegistryAlias, saveManifests, saveBuildData, "scoped-registries": scopeRegistries, "jsr-registries": jsrRegistries, throwOnMissingManifest, }: SaveOptions) => LockfileData;
|
|
28
28
|
export declare const saveData: (data: LockfileData, fileName: string, saveManifests?: boolean) => void;
|
|
29
29
|
export declare const save: (options: Omit<SaveOptions, "saveManifests">) => void;
|
|
30
30
|
export declare const saveHidden: (options: Omit<SaveOptions, "saveManifests" | "saveBuildData">) => void;
|
|
31
|
-
//# sourceMappingURL=save.d.ts.map
|