@vltpkg/graph 1.0.0-rc.3 → 1.0.0-rc.30
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 +57 -22
- 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} +0 -1
- package/dist/{esm/diff.d.ts → diff.d.ts} +4 -1
- package/dist/{esm/diff.js → diff.js} +5 -2
- package/dist/{esm/edge.d.ts → edge.d.ts} +1 -1
- package/dist/{esm/edge.js → edge.js} +4 -1
- package/dist/fixup-added-names.d.ts +18 -0
- package/dist/fixup-added-names.js +46 -0
- package/dist/{esm/graph.d.ts → graph.d.ts} +25 -5
- package/dist/{esm/graph.js → graph.js} +92 -43
- package/dist/ideal/append-nodes.d.ts +31 -0
- package/dist/ideal/append-nodes.js +560 -0
- package/dist/{esm/ideal → ideal}/build-ideal-from-starting-graph.d.ts +4 -5
- package/dist/ideal/build-ideal-from-starting-graph.js +69 -0
- package/dist/{esm/ideal → ideal}/build.d.ts +0 -1
- package/dist/ideal/build.js +84 -0
- package/dist/{esm/ideal → ideal}/get-importer-specs.d.ts +9 -3
- package/dist/{esm/ideal → ideal}/get-importer-specs.js +80 -6
- package/dist/ideal/peers.d.ts +160 -0
- package/dist/ideal/peers.js +696 -0
- package/dist/ideal/refresh-ideal-graph.d.ts +43 -0
- package/dist/ideal/refresh-ideal-graph.js +62 -0
- 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/ideal/types.d.ts +107 -0
- package/dist/ideal/types.js +1 -0
- package/dist/{esm/index.d.ts → index.d.ts} +1 -1
- package/dist/{esm/index.js → index.js} +1 -1
- package/dist/{esm/install.d.ts → install.d.ts} +3 -3
- package/dist/{esm/install.js → install.js} +49 -9
- package/dist/{esm/lockfile → lockfile}/load-edges.d.ts +0 -1
- package/dist/{esm/lockfile → lockfile}/load-edges.js +7 -4
- package/dist/{esm/lockfile → lockfile}/load-nodes.d.ts +0 -1
- package/dist/{esm/lockfile → lockfile}/load-nodes.js +10 -4
- package/dist/{esm/lockfile → lockfile}/load.d.ts +0 -5
- package/dist/{esm/lockfile → lockfile}/load.js +31 -33
- package/dist/{esm/lockfile → lockfile}/save.d.ts +1 -2
- package/dist/{esm/lockfile → lockfile}/save.js +8 -7
- 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} +16 -1
- package/dist/{esm/node.js → node.js} +21 -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/{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 +1 -2
- package/dist/{esm/reify → reify}/add-edges.js +2 -2
- 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 +0 -1
- package/dist/{esm/reify → reify}/calculate-save-value.js +6 -1
- 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 +1 -1
- package/dist/{esm/reify → reify}/index.js +4 -4
- 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 +1 -2
- package/dist/{esm/reify → reify}/update-importers-package-json.js +19 -17
- 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} +10 -2
- package/dist/{esm/transfer-data → transfer-data}/load.d.ts +0 -1
- package/dist/{esm/transfer-data → transfer-data}/load.js +5 -3
- package/dist/{esm/uninstall.d.ts → uninstall.d.ts} +0 -1
- package/dist/{esm/uninstall.js → uninstall.js} +27 -7
- package/dist/{esm/update.d.ts → update.d.ts} +0 -1
- package/dist/{esm/update.js → update.js} +11 -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 +7 -3
- package/dist/{esm/visualization → visualization}/json-output.d.ts +2 -2
- package/dist/{esm/visualization → visualization}/json-output.js +2 -3
- package/dist/{esm/visualization → visualization}/mermaid-output.d.ts +2 -2
- package/dist/visualization/mermaid-output.js +170 -0
- 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 +51 -63
- 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/graph.d.ts.map +0 -1
- 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.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.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.map +0 -1
- 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.map +0 -1
- 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.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.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 +0 -123
- 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
|
@@ -42,11 +42,15 @@ export const extractNode = async (node, scurry, remover, options, packageInfo, d
|
|
|
42
42
|
await remover.rm(target);
|
|
43
43
|
if (removeOptionalFailedNode) {
|
|
44
44
|
try {
|
|
45
|
-
await packageInfo.extract(spec, target, {
|
|
45
|
+
const result = await packageInfo.extract(spec, target, {
|
|
46
46
|
from,
|
|
47
47
|
integrity,
|
|
48
48
|
resolved,
|
|
49
49
|
});
|
|
50
|
+
// Store computed integrity for git/remote deps
|
|
51
|
+
if (result.integrity && !node.integrity) {
|
|
52
|
+
node.integrity = result.integrity;
|
|
53
|
+
}
|
|
50
54
|
return { success: true, node };
|
|
51
55
|
}
|
|
52
56
|
catch (error) {
|
|
@@ -55,11 +59,15 @@ export const extractNode = async (node, scurry, remover, options, packageInfo, d
|
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
else {
|
|
58
|
-
await packageInfo.extract(spec, target, {
|
|
62
|
+
const result = await packageInfo.extract(spec, target, {
|
|
59
63
|
from,
|
|
60
64
|
integrity,
|
|
61
65
|
resolved,
|
|
62
66
|
});
|
|
67
|
+
// Store computed integrity for git/remote deps
|
|
68
|
+
if (result.integrity && !node.integrity) {
|
|
69
|
+
node.integrity = result.integrity;
|
|
70
|
+
}
|
|
63
71
|
return { success: true, node };
|
|
64
72
|
}
|
|
65
73
|
}
|
|
@@ -73,4 +81,3 @@ export const extractNode = async (node, scurry, remover, options, packageInfo, d
|
|
|
73
81
|
throw error;
|
|
74
82
|
}
|
|
75
83
|
};
|
|
76
|
-
//# sourceMappingURL=extract-node.js.map
|
|
@@ -15,6 +15,7 @@ export type ReifyOptions = LoadOptions & {
|
|
|
15
15
|
packageInfo: PackageInfoClient;
|
|
16
16
|
modifiers?: GraphModifier;
|
|
17
17
|
remover: RollbackRemove;
|
|
18
|
+
update?: boolean;
|
|
18
19
|
};
|
|
19
20
|
export type ReifyResult = {
|
|
20
21
|
/**
|
|
@@ -31,4 +32,3 @@ export type ReifyResult = {
|
|
|
31
32
|
* Make the current project match the supplied graph.
|
|
32
33
|
*/
|
|
33
34
|
export declare const reify: (options: ReifyOptions) => Promise<ReifyResult>;
|
|
34
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -67,8 +67,9 @@ export const reify = async (options) => {
|
|
|
67
67
|
const noModifiedDependencies = !options.add?.modifiedDependencies &&
|
|
68
68
|
!options.remove?.modifiedDependencies;
|
|
69
69
|
const skipOptionalOnly = noModifiedDependencies && diff.optionalOnly;
|
|
70
|
+
const skippable = skipOptionalOnly && !options.update;
|
|
70
71
|
const res = { diff };
|
|
71
|
-
if (!diff.hasChanges() ||
|
|
72
|
+
if (!diff.hasChanges() || skippable) {
|
|
72
73
|
// nothing to do, so just return the diff
|
|
73
74
|
done();
|
|
74
75
|
return res;
|
|
@@ -115,11 +116,11 @@ const reify_ = async (options, diff, remover) => {
|
|
|
115
116
|
// create all node_modules symlinks, and link bins to nm/.bin
|
|
116
117
|
const edgeActions = addEdges(diff, scurry, remover);
|
|
117
118
|
if (edgeActions.length)
|
|
118
|
-
await
|
|
119
|
+
await callLimit(edgeActions, { limit });
|
|
119
120
|
await internalHoist(diff.to, options, remover);
|
|
120
121
|
// looks up all nodes setting buildState = 'needed'
|
|
121
122
|
// on nodes that require building
|
|
122
|
-
checkNeededBuild({ diff });
|
|
123
|
+
checkNeededBuild({ diff, scurry, packageJson });
|
|
123
124
|
// Filter nodes allowed to run scripts if allowScripts query is provided
|
|
124
125
|
const allowScriptsNodes = await filterNodesByQuery(diff.to, allowScripts);
|
|
125
126
|
// ensure that all added bins are chmod +x
|
|
@@ -158,4 +159,3 @@ const reify_ = async (options, diff, remover) => {
|
|
|
158
159
|
// returns the result object
|
|
159
160
|
return res;
|
|
160
161
|
};
|
|
161
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -6,4 +6,3 @@ type InternalHoistOptions = Pick<ReifyOptions, 'projectRoot' | 'scurry'>;
|
|
|
6
6
|
export declare const pickNodeToHoist: (nodes: Set<Node>) => Node | undefined;
|
|
7
7
|
export declare const internalHoist: (graph: Graph, options: InternalHoistOptions, remover: RollbackRemove) => Promise<void>;
|
|
8
8
|
export {};
|
|
9
|
-
//# sourceMappingURL=internal-hoist.d.ts.map
|
|
@@ -2,4 +2,3 @@ import { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
|
2
2
|
import type { PathScurry } from 'path-scurry';
|
|
3
3
|
import type { Diff } from '../diff.ts';
|
|
4
4
|
export declare const rollback: (remover: RollbackRemove, diff: Diff, scurry: PathScurry) => Promise<void>;
|
|
5
|
-
//# sourceMappingURL=rollback.d.ts.map
|
|
@@ -29,8 +29,7 @@ export type UpdatePackageJsonOptions = {
|
|
|
29
29
|
packageJson: PackageJson;
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
|
-
* Updates
|
|
32
|
+
* Updates nodes of a provided {@link Graph} accordingly to the
|
|
33
33
|
* provided add or remove arguments.
|
|
34
34
|
*/
|
|
35
35
|
export declare const updatePackageJson: ({ add, graph, packageJson, remove, }: UpdatePackageJsonOptions) => () => void;
|
|
36
|
-
//# sourceMappingURL=update-importers-package-json.d.ts.map
|
|
@@ -10,20 +10,20 @@ const depTypesMap = new Map([
|
|
|
10
10
|
['peerOptional', 'peerDependencies'],
|
|
11
11
|
['optional', 'optionalDependencies'],
|
|
12
12
|
]);
|
|
13
|
-
const addOrRemoveDeps = (
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
-
throw error('Failed to retrieve
|
|
17
|
-
found:
|
|
13
|
+
const addOrRemoveDeps = (nodeId, graph, addOrRemove) => {
|
|
14
|
+
const node = graph.nodes.get(nodeId);
|
|
15
|
+
if (!node) {
|
|
16
|
+
throw error('Failed to retrieve node', {
|
|
17
|
+
found: nodeId,
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
const manifest =
|
|
20
|
+
const manifest = node.manifest;
|
|
21
21
|
if (!manifest) {
|
|
22
22
|
throw error('Could not find manifest data for node', {
|
|
23
|
-
found:
|
|
23
|
+
found: nodeId,
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
const deps = addOrRemove?.get(
|
|
26
|
+
const deps = addOrRemove?.get(nodeId);
|
|
27
27
|
/* c8 ignore start -- impossible but TS doesn't know that */
|
|
28
28
|
if (!deps) {
|
|
29
29
|
throw error('Failed to retrieve added deps info', {
|
|
@@ -49,7 +49,7 @@ const addOrRemoveDeps = (importerId, graph, addOrRemove) => {
|
|
|
49
49
|
else {
|
|
50
50
|
const [name, dep] = deleteNameOrAddItem;
|
|
51
51
|
// peerOptional also needs to add peerDependenciesMeta entry
|
|
52
|
-
const depTypeShort = resolveSaveType(
|
|
52
|
+
const depTypeShort = resolveSaveType(node, name, dep.type);
|
|
53
53
|
const depType = depTypesMap.get(depTypeShort);
|
|
54
54
|
if (!depType) {
|
|
55
55
|
throw error('Failed to retrieve dependency type', {
|
|
@@ -57,11 +57,11 @@ const addOrRemoveDeps = (importerId, graph, addOrRemove) => {
|
|
|
57
57
|
found: dep.type,
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
60
|
+
const n = node.edgesOut.get(name)?.to;
|
|
61
|
+
if (!n) {
|
|
62
62
|
throw error('Dependency node could not be found');
|
|
63
63
|
}
|
|
64
|
-
const [nodeType] = splitDepID(
|
|
64
|
+
const [nodeType] = splitDepID(n.id);
|
|
65
65
|
for (const dtype of longDependencyTypes) {
|
|
66
66
|
if (dtype === depType || !manifest[dtype])
|
|
67
67
|
continue;
|
|
@@ -86,7 +86,7 @@ const addOrRemoveDeps = (importerId, graph, addOrRemove) => {
|
|
|
86
86
|
// If the manifest does not contain anything, then update it.
|
|
87
87
|
// Only for registry dependencies
|
|
88
88
|
const existing = dependencies[name];
|
|
89
|
-
const saveValue = calculateSaveValue(nodeType, dep.spec, existing,
|
|
89
|
+
const saveValue = calculateSaveValue(nodeType, dep.spec, existing, n.version);
|
|
90
90
|
dependencies[name] = saveValue;
|
|
91
91
|
manifestChanged = manifestChanged || saveValue !== existing;
|
|
92
92
|
}
|
|
@@ -94,7 +94,7 @@ const addOrRemoveDeps = (importerId, graph, addOrRemove) => {
|
|
|
94
94
|
return manifestChanged ? manifest : undefined;
|
|
95
95
|
};
|
|
96
96
|
/**
|
|
97
|
-
* Updates
|
|
97
|
+
* Updates nodes of a provided {@link Graph} accordingly to the
|
|
98
98
|
* provided add or remove arguments.
|
|
99
99
|
*/
|
|
100
100
|
export const updatePackageJson = ({ add, graph, packageJson, remove, }) => {
|
|
@@ -102,8 +102,11 @@ export const updatePackageJson = ({ add, graph, packageJson, remove, }) => {
|
|
|
102
102
|
const operations = new Set([add, remove]);
|
|
103
103
|
for (const operation of operations) {
|
|
104
104
|
if (operation) {
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
// These node ids are from either importer nodes or dependencies
|
|
106
|
+
// that are nested folders from which the user can also add new
|
|
107
|
+
// dependencies to
|
|
108
|
+
for (const nodeId of operation.keys()) {
|
|
109
|
+
const manifest = addOrRemoveDeps(nodeId, graph, operation);
|
|
107
110
|
if (manifest) {
|
|
108
111
|
manifestsToUpdate.add(manifest);
|
|
109
112
|
}
|
|
@@ -117,4 +120,3 @@ export const updatePackageJson = ({ add, graph, packageJson, remove, }) => {
|
|
|
117
120
|
};
|
|
118
121
|
return commit;
|
|
119
122
|
};
|
|
120
|
-
//# sourceMappingURL=update-importers-package-json.js.map
|
|
@@ -3,4 +3,3 @@ import type { DependencySaveType, DependencyTypeShort, NodeLike } from '@vltpkg/
|
|
|
3
3
|
* Resolve a {@link DependencySaveType} to a {@link DependencyTypeShort}
|
|
4
4
|
*/
|
|
5
5
|
export declare const resolveSaveType: (node: NodeLike, name: string, saveType: DependencySaveType) => DependencyTypeShort;
|
|
6
|
-
//# sourceMappingURL=resolve-save-type.d.ts.map
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { splitDepID } from '@vltpkg/dep-id/browser';
|
|
2
|
+
import { defaultRegistryName } from '@vltpkg/spec/browser';
|
|
2
3
|
export const stringifyNode = (node) => {
|
|
3
4
|
if (!node)
|
|
4
5
|
return '';
|
|
5
6
|
const version = node.version ? `@${node.version}` : '';
|
|
6
7
|
const [type, ref, nameVersion] = splitDepID(node.id);
|
|
7
8
|
if (type === 'registry') {
|
|
8
|
-
|
|
9
|
+
let prefix = `${defaultRegistryName}:`;
|
|
10
|
+
if (ref) {
|
|
11
|
+
if (/^https?:\/\//.test(ref)) {
|
|
12
|
+
prefix = `registry:${ref}#`;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
prefix = `${ref}:`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
9
18
|
return `${prefix}${nameVersion}`;
|
|
10
19
|
}
|
|
11
20
|
else if (type === 'workspace') {
|
|
@@ -21,4 +30,3 @@ export const stringifyNode = (node) => {
|
|
|
21
30
|
return `${type}(${ref})${nameVersion}`;
|
|
22
31
|
}
|
|
23
32
|
};
|
|
24
|
-
//# sourceMappingURL=stringify-node.js.map
|
|
@@ -5,7 +5,10 @@ import { stringifyNode } from "../stringify-node.js";
|
|
|
5
5
|
import { loadEdges } from "../lockfile/load-edges.js";
|
|
6
6
|
import { loadNodes } from "../lockfile/load-nodes.js";
|
|
7
7
|
const loadSpecOptions = (lockfile) => {
|
|
8
|
-
const { catalog = {}, catalogs = {}, registries, registry, 'git-hosts': gitHosts, 'git-host-archives': gitHostArchives, '
|
|
8
|
+
const { catalog = {}, catalogs = {}, registries, registry, 'git-hosts': gitHosts, 'git-host-archives': gitHostArchives, 'scoped-registries': scopedRegistriesOption, 'jsr-registries': jsrRegistries, } = lockfile.options;
|
|
9
|
+
// backwards-compat: legacy lockfiles wrote this field as `scope-registries`
|
|
10
|
+
const scopeRegistries = scopedRegistriesOption ??
|
|
11
|
+
lockfile.options['scope-registries'];
|
|
9
12
|
return {
|
|
10
13
|
catalog,
|
|
11
14
|
catalogs,
|
|
@@ -17,7 +20,7 @@ const loadSpecOptions = (lockfile) => {
|
|
|
17
20
|
...defaultGitHostArchives,
|
|
18
21
|
...gitHostArchives,
|
|
19
22
|
},
|
|
20
|
-
'
|
|
23
|
+
'scoped-registries': {
|
|
21
24
|
...defaultScopeRegistries,
|
|
22
25
|
...scopeRegistries,
|
|
23
26
|
},
|
|
@@ -173,4 +176,3 @@ export const load = (transfered) => {
|
|
|
173
176
|
securityArchive,
|
|
174
177
|
};
|
|
175
178
|
};
|
|
176
|
-
//# sourceMappingURL=load.js.map
|
|
@@ -5,27 +5,40 @@ import { reify } from "./reify/index.js";
|
|
|
5
5
|
import { lockfile } from "./index.js";
|
|
6
6
|
import { updatePackageJson } from "./reify/update-importers-package-json.js";
|
|
7
7
|
import { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
8
|
+
import { existsSync, rmSync } from 'node:fs';
|
|
9
|
+
import { resolve } from 'node:path';
|
|
8
10
|
export const uninstall = async (options, remove) => {
|
|
9
11
|
const mainManifest = options.packageJson.read(options.projectRoot);
|
|
10
12
|
const modifiers = GraphModifier.maybeLoad(options);
|
|
11
13
|
const remover = new RollbackRemove();
|
|
12
14
|
try {
|
|
13
|
-
|
|
15
|
+
// Load the actual graph before building the ideal graph so that
|
|
16
|
+
// manifest data from installed packages can be used to hydrate
|
|
17
|
+
// nodes loaded from the lockfile. Without this, nodes loaded from
|
|
18
|
+
// vlt-lock.json (which does not store manifests) will be missing
|
|
19
|
+
// manifest data, causing the hidden lockfile save to silently fail
|
|
20
|
+
// due to throwOnMissingManifest and leaving stale entries behind.
|
|
21
|
+
const act = actualLoad({
|
|
14
22
|
...options,
|
|
15
|
-
|
|
23
|
+
modifiers: undefined,
|
|
16
24
|
mainManifest,
|
|
17
25
|
loadManifests: true,
|
|
18
|
-
remover,
|
|
19
26
|
});
|
|
20
|
-
const
|
|
27
|
+
const graph = await idealBuild({
|
|
21
28
|
...options,
|
|
29
|
+
actual: act,
|
|
30
|
+
remove,
|
|
22
31
|
mainManifest,
|
|
23
32
|
loadManifests: true,
|
|
33
|
+
remover,
|
|
24
34
|
});
|
|
25
35
|
// If lockfileOnly is enabled, skip reify and only save the lockfile
|
|
26
36
|
if (options.lockfileOnly) {
|
|
27
|
-
// Save only the main lockfile, skip all filesystem operations
|
|
28
|
-
|
|
37
|
+
// Save only the main lockfile, skip all filesystem operations.
|
|
38
|
+
// Spread `options` so that spec-level config (registry,
|
|
39
|
+
// scoped-registries, git-hosts, catalogs, etc.) round-trips
|
|
40
|
+
// through the lockfile. See vltpkg/vltpkg#1580.
|
|
41
|
+
lockfile.save({ ...options, graph, modifiers });
|
|
29
42
|
const saveImportersPackageJson =
|
|
30
43
|
/* c8 ignore next */
|
|
31
44
|
remove?.modifiedDependencies ?
|
|
@@ -51,8 +64,15 @@ export const uninstall = async (options, remove) => {
|
|
|
51
64
|
}
|
|
52
65
|
catch (err) {
|
|
53
66
|
await remover.rollback().catch(() => { });
|
|
67
|
+
// Remove hidden lockfile on failure
|
|
68
|
+
try {
|
|
69
|
+
const hiddenLockfile = resolve(options.projectRoot, 'node_modules/.vlt-lock.json');
|
|
70
|
+
if (existsSync(hiddenLockfile)) {
|
|
71
|
+
rmSync(hiddenLockfile, { force: true });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch { }
|
|
54
75
|
throw err;
|
|
55
76
|
}
|
|
56
77
|
/* c8 ignore stop */
|
|
57
78
|
};
|
|
58
|
-
//# sourceMappingURL=uninstall.js.map
|
|
@@ -7,6 +7,8 @@ import { asError } from '@vltpkg/types';
|
|
|
7
7
|
import { Graph } from "./graph.js";
|
|
8
8
|
import { graphStep } from '@vltpkg/output';
|
|
9
9
|
import { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
10
|
+
import { existsSync, rmSync } from 'node:fs';
|
|
11
|
+
import { resolve } from 'node:path';
|
|
10
12
|
export const update = async (options) => {
|
|
11
13
|
let mainManifest = undefined;
|
|
12
14
|
try {
|
|
@@ -50,14 +52,22 @@ export const update = async (options) => {
|
|
|
50
52
|
loadManifests: true,
|
|
51
53
|
modifiers,
|
|
52
54
|
remover,
|
|
55
|
+
update: true,
|
|
53
56
|
});
|
|
54
57
|
return { buildQueue, graph, diff };
|
|
55
58
|
/* c8 ignore start */
|
|
56
59
|
}
|
|
57
60
|
catch (err) {
|
|
58
61
|
await remover.rollback().catch(() => { });
|
|
62
|
+
// Remove hidden lockfile on failure
|
|
63
|
+
try {
|
|
64
|
+
const hiddenLockfile = resolve(options.projectRoot, 'node_modules/.vlt-lock.json');
|
|
65
|
+
if (existsSync(hiddenLockfile)) {
|
|
66
|
+
rmSync(hiddenLockfile, { force: true });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch { }
|
|
59
70
|
throw err;
|
|
60
71
|
}
|
|
61
72
|
/* c8 ignore stop */
|
|
62
73
|
};
|
|
63
|
-
//# sourceMappingURL=update.js.map
|
|
@@ -13,4 +13,3 @@ export declare const VIRTUAL_ROOT_ID: import("@vltpkg/dep-id/browser").DepID;
|
|
|
13
13
|
* Returns undefined if a virtual root is not needed.
|
|
14
14
|
*/
|
|
15
15
|
export declare const createVirtualRoot: (name: string | undefined, options: SpecOptions, mainImporters: NodeLike[]) => NodeLike | undefined;
|
|
16
|
-
//# sourceMappingURL=virtual-root.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defaultRegistryName } from '@vltpkg/spec';
|
|
1
2
|
import { splitDepID } from '@vltpkg/dep-id';
|
|
2
3
|
import { styleText as utilStyleText } from 'node:util';
|
|
3
4
|
const styleText = (format, s) => utilStyleText(format, s, { validateStream: false });
|
|
@@ -119,7 +120,9 @@ export function humanReadableOutput(options, { colors }) {
|
|
|
119
120
|
// prefixes the node name with the registry name
|
|
120
121
|
// if a custom registry name is found
|
|
121
122
|
const depIdTuple = nextItem.node?.id && splitDepID(nextItem.node.id);
|
|
122
|
-
const hasCustomReg = depIdTuple?.[0] === 'registry' &&
|
|
123
|
+
const hasCustomReg = depIdTuple?.[0] === 'registry' &&
|
|
124
|
+
depIdTuple[1] &&
|
|
125
|
+
depIdTuple[1] !== defaultRegistryName;
|
|
123
126
|
const nodeName = hasCustomReg ?
|
|
124
127
|
`${depIdTuple[1]}:${nextItem.node?.name}`
|
|
125
128
|
: nextItem.node?.name;
|
|
@@ -127,7 +130,9 @@ export function humanReadableOutput(options, { colors }) {
|
|
|
127
130
|
`${nodeName}@${nextItem.node.version}`
|
|
128
131
|
: nodeName;
|
|
129
132
|
const nextChar = isLast ? 'last-child' : 'middle-child';
|
|
130
|
-
const aliasedPackage =
|
|
133
|
+
const aliasedPackage = hasCustomReg ||
|
|
134
|
+
(nextItem.node?.name &&
|
|
135
|
+
nextItem.edge?.name !== nextItem.node.name);
|
|
131
136
|
nextItem.name =
|
|
132
137
|
nextItem.node?.confused ?
|
|
133
138
|
`${nextItem.edge?.name} ${red('(confused)')}`
|
|
@@ -156,4 +161,3 @@ export function humanReadableOutput(options, { colors }) {
|
|
|
156
161
|
}
|
|
157
162
|
return reset(res);
|
|
158
163
|
}
|
|
159
|
-
//# sourceMappingURL=human-readable-output.js.map
|
|
@@ -32,10 +32,10 @@ export type JSONOutputItem = {
|
|
|
32
32
|
};
|
|
33
33
|
export type JSONOutputGraph = {
|
|
34
34
|
edges: EdgeLike[];
|
|
35
|
+
nodes: NodeLike[];
|
|
35
36
|
importers: Set<NodeLike>;
|
|
36
37
|
};
|
|
37
38
|
/**
|
|
38
39
|
* Returns a JSON string representation of the graph.
|
|
39
40
|
*/
|
|
40
|
-
export declare function jsonOutput({ edges, importers }: JSONOutputGraph): JSONOutputItem[];
|
|
41
|
-
//# sourceMappingURL=json-output.d.ts.map
|
|
41
|
+
export declare function jsonOutput({ edges, nodes, importers, }: JSONOutputGraph): JSONOutputItem[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns a JSON string representation of the graph.
|
|
3
3
|
*/
|
|
4
|
-
export function jsonOutput({ edges, importers }) {
|
|
4
|
+
export function jsonOutput({ edges, nodes, importers, }) {
|
|
5
5
|
const res = [];
|
|
6
6
|
const seenIds = new Set();
|
|
7
7
|
// Collects edge & it's linked nodes as json output items
|
|
@@ -37,7 +37,7 @@ export function jsonOutput({ edges, importers }) {
|
|
|
37
37
|
return a.name.localeCompare(b.name);
|
|
38
38
|
});
|
|
39
39
|
for (const node of orderedImporters) {
|
|
40
|
-
if (seenIds.has(node.id))
|
|
40
|
+
if (!nodes.includes(node) || seenIds.has(node.id))
|
|
41
41
|
continue;
|
|
42
42
|
res.unshift({
|
|
43
43
|
/* c8 ignore next - name can't be missing but ts won't know */
|
|
@@ -48,4 +48,3 @@ export function jsonOutput({ edges, importers }) {
|
|
|
48
48
|
}
|
|
49
49
|
return res;
|
|
50
50
|
}
|
|
51
|
-
//# sourceMappingURL=json-output.js.map
|
|
@@ -3,6 +3,7 @@ export type MermaidOutputGraph = {
|
|
|
3
3
|
edges: EdgeLike[];
|
|
4
4
|
importers: Set<NodeLike>;
|
|
5
5
|
nodes: NodeLike[];
|
|
6
|
+
highlightSelection?: boolean;
|
|
6
7
|
};
|
|
7
8
|
/**
|
|
8
9
|
* Generates a short identifier for a given index following the pattern:
|
|
@@ -13,5 +14,4 @@ export declare function generateShortId(index: number): string;
|
|
|
13
14
|
/**
|
|
14
15
|
* Returns a mermaid string representation of the graph.
|
|
15
16
|
*/
|
|
16
|
-
export declare function mermaidOutput(
|
|
17
|
-
//# sourceMappingURL=mermaid-output.d.ts.map
|
|
17
|
+
export declare function mermaidOutput(options: MermaidOutputGraph): string;
|