@vltpkg/graph 0.0.0-0.1730239248325
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/LICENSE +15 -0
- package/README.md +33 -0
- package/dist/esm/actual/load.d.ts +54 -0
- package/dist/esm/actual/load.d.ts.map +1 -0
- package/dist/esm/actual/load.js +243 -0
- package/dist/esm/actual/load.js.map +1 -0
- package/dist/esm/browser.d.ts +9 -0
- package/dist/esm/browser.d.ts.map +1 -0
- package/dist/esm/browser.js +11 -0
- package/dist/esm/browser.js.map +1 -0
- package/dist/esm/dependencies.d.ts +69 -0
- package/dist/esm/dependencies.d.ts.map +1 -0
- package/dist/esm/dependencies.js +71 -0
- package/dist/esm/dependencies.js.map +1 -0
- package/dist/esm/diff.d.ts +49 -0
- package/dist/esm/diff.d.ts.map +1 -0
- package/dist/esm/diff.js +123 -0
- package/dist/esm/diff.js.map +1 -0
- package/dist/esm/edge.d.ts +41 -0
- package/dist/esm/edge.d.ts.map +1 -0
- package/dist/esm/edge.js +66 -0
- package/dist/esm/edge.js.map +1 -0
- package/dist/esm/graph.d.ts +123 -0
- package/dist/esm/graph.d.ts.map +1 -0
- package/dist/esm/graph.js +301 -0
- package/dist/esm/graph.js.map +1 -0
- package/dist/esm/ideal/add-nodes.d.ts +19 -0
- package/dist/esm/ideal/add-nodes.d.ts.map +1 -0
- package/dist/esm/ideal/add-nodes.js +28 -0
- package/dist/esm/ideal/add-nodes.js.map +1 -0
- package/dist/esm/ideal/append-nodes.d.ts +9 -0
- package/dist/esm/ideal/append-nodes.d.ts.map +1 -0
- package/dist/esm/ideal/append-nodes.js +121 -0
- package/dist/esm/ideal/append-nodes.js.map +1 -0
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts +15 -0
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +1 -0
- package/dist/esm/ideal/build-ideal-from-starting-graph.js +28 -0
- package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -0
- package/dist/esm/ideal/build.d.ts +32 -0
- package/dist/esm/ideal/build.d.ts.map +1 -0
- package/dist/esm/ideal/build.js +42 -0
- package/dist/esm/ideal/build.js.map +1 -0
- package/dist/esm/ideal/get-importer-specs.d.ts +13 -0
- package/dist/esm/ideal/get-importer-specs.d.ts.map +1 -0
- package/dist/esm/ideal/get-importer-specs.js +76 -0
- package/dist/esm/ideal/get-importer-specs.js.map +1 -0
- package/dist/esm/ideal/remove-nodes.d.ts +7 -0
- package/dist/esm/ideal/remove-nodes.d.ts.map +1 -0
- package/dist/esm/ideal/remove-nodes.js +19 -0
- package/dist/esm/ideal/remove-nodes.js.map +1 -0
- package/dist/esm/ideal/remove-satisfied-specs.d.ts +8 -0
- package/dist/esm/ideal/remove-satisfied-specs.d.ts.map +1 -0
- package/dist/esm/ideal/remove-satisfied-specs.js +35 -0
- package/dist/esm/ideal/remove-satisfied-specs.js.map +1 -0
- package/dist/esm/ideal/types.d.ts +35 -0
- package/dist/esm/ideal/types.d.ts.map +1 -0
- package/dist/esm/ideal/types.js +2 -0
- package/dist/esm/ideal/types.js.map +1 -0
- package/dist/esm/index.d.ts +31 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +26 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lockfile/load-edges.d.ts +5 -0
- package/dist/esm/lockfile/load-edges.d.ts.map +1 -0
- package/dist/esm/lockfile/load-edges.js +40 -0
- package/dist/esm/lockfile/load-edges.js.map +1 -0
- package/dist/esm/lockfile/load-nodes.d.ts +4 -0
- package/dist/esm/lockfile/load-nodes.d.ts.map +1 -0
- package/dist/esm/lockfile/load-nodes.js +28 -0
- package/dist/esm/lockfile/load-nodes.js.map +1 -0
- package/dist/esm/lockfile/load.d.ts +33 -0
- package/dist/esm/lockfile/load.d.ts.map +1 -0
- package/dist/esm/lockfile/load.js +53 -0
- package/dist/esm/lockfile/load.js.map +1 -0
- package/dist/esm/lockfile/save.d.ts +18 -0
- package/dist/esm/lockfile/save.d.ts.map +1 -0
- package/dist/esm/lockfile/save.js +128 -0
- package/dist/esm/lockfile/save.js.map +1 -0
- package/dist/esm/lockfile/types.d.ts +60 -0
- package/dist/esm/lockfile/types.d.ts.map +1 -0
- package/dist/esm/lockfile/types.js +13 -0
- package/dist/esm/lockfile/types.js.map +1 -0
- package/dist/esm/node.d.ts +144 -0
- package/dist/esm/node.d.ts.map +1 -0
- package/dist/esm/node.js +266 -0
- package/dist/esm/node.js.map +1 -0
- package/dist/esm/non-empty-list.d.ts +3 -0
- package/dist/esm/non-empty-list.d.ts.map +1 -0
- package/dist/esm/non-empty-list.js +3 -0
- package/dist/esm/non-empty-list.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/reify/add-edge.d.ts +11 -0
- package/dist/esm/reify/add-edge.d.ts.map +1 -0
- package/dist/esm/reify/add-edge.js +43 -0
- package/dist/esm/reify/add-edge.js.map +1 -0
- package/dist/esm/reify/add-edges.d.ts +6 -0
- package/dist/esm/reify/add-edges.d.ts.map +1 -0
- package/dist/esm/reify/add-edges.js +13 -0
- package/dist/esm/reify/add-edges.js.map +1 -0
- package/dist/esm/reify/add-nodes.d.ts +7 -0
- package/dist/esm/reify/add-nodes.d.ts.map +1 -0
- package/dist/esm/reify/add-nodes.js +37 -0
- package/dist/esm/reify/add-nodes.js.map +1 -0
- package/dist/esm/reify/bin-paths.d.ts +4 -0
- package/dist/esm/reify/bin-paths.d.ts.map +1 -0
- package/dist/esm/reify/bin-paths.js +23 -0
- package/dist/esm/reify/bin-paths.js.map +1 -0
- package/dist/esm/reify/build.d.ts +5 -0
- package/dist/esm/reify/build.d.ts.map +1 -0
- package/dist/esm/reify/build.js +90 -0
- package/dist/esm/reify/build.js.map +1 -0
- package/dist/esm/reify/delete-edge.d.ts +5 -0
- package/dist/esm/reify/delete-edge.d.ts.map +1 -0
- package/dist/esm/reify/delete-edge.js +29 -0
- package/dist/esm/reify/delete-edge.js.map +1 -0
- package/dist/esm/reify/delete-edges.d.ts +5 -0
- package/dist/esm/reify/delete-edges.d.ts.map +1 -0
- package/dist/esm/reify/delete-edges.js +14 -0
- package/dist/esm/reify/delete-edges.js.map +1 -0
- package/dist/esm/reify/delete-nodes.d.ts +5 -0
- package/dist/esm/reify/delete-nodes.d.ts.map +1 -0
- package/dist/esm/reify/delete-nodes.js +12 -0
- package/dist/esm/reify/delete-nodes.js.map +1 -0
- package/dist/esm/reify/index.d.ts +16 -0
- package/dist/esm/reify/index.d.ts.map +1 -0
- package/dist/esm/reify/index.js +85 -0
- package/dist/esm/reify/index.js.map +1 -0
- package/dist/esm/reify/optional-fail.d.ts +16 -0
- package/dist/esm/reify/optional-fail.d.ts.map +1 -0
- package/dist/esm/reify/optional-fail.js +16 -0
- package/dist/esm/reify/optional-fail.js.map +1 -0
- package/dist/esm/reify/rollback.d.ts +5 -0
- package/dist/esm/reify/rollback.d.ts.map +1 -0
- package/dist/esm/reify/rollback.js +24 -0
- package/dist/esm/reify/rollback.js.map +1 -0
- package/dist/esm/reify/update-importers-package-json.d.ts +36 -0
- package/dist/esm/reify/update-importers-package-json.d.ts.map +1 -0
- package/dist/esm/reify/update-importers-package-json.js +95 -0
- package/dist/esm/reify/update-importers-package-json.js.map +1 -0
- package/dist/esm/remove-optional-subgraph.d.ts +34 -0
- package/dist/esm/remove-optional-subgraph.d.ts.map +1 -0
- package/dist/esm/remove-optional-subgraph.js +48 -0
- package/dist/esm/remove-optional-subgraph.js.map +1 -0
- package/dist/esm/stringify-node.d.ts +3 -0
- package/dist/esm/stringify-node.d.ts.map +1 -0
- package/dist/esm/stringify-node.js +24 -0
- package/dist/esm/stringify-node.js.map +1 -0
- package/dist/esm/types.d.ts +39 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/visualization/human-readable-output.d.ts +25 -0
- package/dist/esm/visualization/human-readable-output.d.ts.map +1 -0
- package/dist/esm/visualization/human-readable-output.js +132 -0
- package/dist/esm/visualization/human-readable-output.js.map +1 -0
- package/dist/esm/visualization/json-output.d.ts +37 -0
- package/dist/esm/visualization/json-output.d.ts.map +1 -0
- package/dist/esm/visualization/json-output.js +28 -0
- package/dist/esm/visualization/json-output.js.map +1 -0
- package/dist/esm/visualization/mermaid-output.d.ts +11 -0
- package/dist/esm/visualization/mermaid-output.d.ts.map +1 -0
- package/dist/esm/visualization/mermaid-output.js +68 -0
- package/dist/esm/visualization/mermaid-output.js.map +1 -0
- package/dist/esm/visualization/object-like-output.d.ts +3 -0
- package/dist/esm/visualization/object-like-output.d.ts.map +1 -0
- package/dist/esm/visualization/object-like-output.js +49 -0
- package/dist/esm/visualization/object-like-output.js.map +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PackageInfoClient } from '@vltpkg/package-info';
|
|
2
|
+
import { LoadOptions as LoadActualOptions } from '../actual/load.js';
|
|
3
|
+
import { AddImportersDependenciesMap, RemoveImportersDependenciesMap } from '../dependencies.js';
|
|
4
|
+
import { Graph } from '../graph.js';
|
|
5
|
+
export type BuildIdealOptions = LoadActualOptions & {
|
|
6
|
+
/**
|
|
7
|
+
* A `Map` in which keys are {@link DepID} linking to another `Map` in which
|
|
8
|
+
* keys are the dependency names and values are {@link Dependency}. This
|
|
9
|
+
* structure represents dependencies that need to be added to the importer
|
|
10
|
+
* represented by {@link DepID}.
|
|
11
|
+
*/
|
|
12
|
+
add?: AddImportersDependenciesMap;
|
|
13
|
+
/**
|
|
14
|
+
* A `Map` object representing nodes to be removed from the ideal graph.
|
|
15
|
+
* Each {@link DepID} key represents an importer node and the `Set` of
|
|
16
|
+
* dependency names to be removed from its dependency list.
|
|
17
|
+
*/
|
|
18
|
+
remove?: RemoveImportersDependenciesMap;
|
|
19
|
+
/**
|
|
20
|
+
* A {@link PackageInfoClient} instance to read manifest info from.
|
|
21
|
+
*/
|
|
22
|
+
packageInfo: PackageInfoClient;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Builds an ideal {@link Graph} representing the dependencies that
|
|
26
|
+
* should be present in order to fulfill the requirements defined
|
|
27
|
+
* by the `package.json` and `vlt-lock.json` files using either the
|
|
28
|
+
* virtual or actual graph as a starting point. Also add / remove any
|
|
29
|
+
* dependencies listed in the `add` and `remove` properties.
|
|
30
|
+
*/
|
|
31
|
+
export declare const build: (options: BuildIdealOptions) => Promise<Graph>;
|
|
32
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAEL,WAAW,IAAI,iBAAiB,EACjC,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAInC,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG;IAClD;;;;;OAKG;IACH,GAAG,CAAC,EAAE,2BAA2B,CAAA;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,8BAA8B,CAAA;IACvC;;OAEG;IACH,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,YACP,iBAAiB,KACzB,OAAO,CAAC,KAAK,CAgCf,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { load as loadActual, } from '../actual/load.js';
|
|
2
|
+
import { load as loadVirtual } from '../lockfile/load.js';
|
|
3
|
+
import { buildIdealFromStartingGraph } from './build-ideal-from-starting-graph.js';
|
|
4
|
+
/**
|
|
5
|
+
* Builds an ideal {@link Graph} representing the dependencies that
|
|
6
|
+
* should be present in order to fulfill the requirements defined
|
|
7
|
+
* by the `package.json` and `vlt-lock.json` files using either the
|
|
8
|
+
* virtual or actual graph as a starting point. Also add / remove any
|
|
9
|
+
* dependencies listed in the `add` and `remove` properties.
|
|
10
|
+
*/
|
|
11
|
+
export const build = async (options) => {
|
|
12
|
+
// Creates the shared instances that are going to be used
|
|
13
|
+
// in both the loader methods and the build graph
|
|
14
|
+
const { packageInfo, packageJson, scurry, monorepo } = options;
|
|
15
|
+
const mainManifest = options.mainManifest ?? packageJson.read(options.projectRoot);
|
|
16
|
+
const add = options.add ?? new Map();
|
|
17
|
+
const remove = options.remove ?? new Map();
|
|
18
|
+
let graph;
|
|
19
|
+
try {
|
|
20
|
+
graph = loadVirtual({
|
|
21
|
+
...options,
|
|
22
|
+
mainManifest,
|
|
23
|
+
monorepo,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
graph = loadActual({
|
|
28
|
+
...options,
|
|
29
|
+
mainManifest,
|
|
30
|
+
monorepo,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return buildIdealFromStartingGraph({
|
|
34
|
+
...options,
|
|
35
|
+
scurry,
|
|
36
|
+
add,
|
|
37
|
+
graph,
|
|
38
|
+
packageInfo,
|
|
39
|
+
remove,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"AACA,OAAO,EACL,IAAI,IAAI,UAAU,GAEnB,MAAM,mBAAmB,CAAA;AAM1B,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAA;AAsBlF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EACxB,OAA0B,EACV,EAAE;IAClB,yDAAyD;IACzD,iDAAiD;IACjD,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAC9D,MAAM,YAAY,GAChB,OAAO,CAAC,YAAY,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAC/D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAA;IACpC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,GAAG,EAAE,CAAA;IAE1C,IAAI,KAAK,CAAA;IACT,IAAI,CAAC;QACH,KAAK,GAAG,WAAW,CAAC;YAClB,GAAG,OAAO;YACV,YAAY;YACZ,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,KAAK,GAAG,UAAU,CAAC;YACjB,GAAG,OAAO;YACV,YAAY;YACZ,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,2BAA2B,CAAC;QACjC,GAAG,OAAO;QACV,MAAM;QACN,GAAG;QACH,KAAK;QACL,WAAW;QACX,MAAM;KACP,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { PackageInfoClient } from '@vltpkg/package-info'\nimport {\n load as loadActual,\n LoadOptions as LoadActualOptions,\n} from '../actual/load.js'\nimport {\n AddImportersDependenciesMap,\n RemoveImportersDependenciesMap,\n} from '../dependencies.js'\nimport { Graph } from '../graph.js'\nimport { load as loadVirtual } from '../lockfile/load.js'\nimport { buildIdealFromStartingGraph } from './build-ideal-from-starting-graph.js'\n\nexport type BuildIdealOptions = LoadActualOptions & {\n /**\n * A `Map` in which keys are {@link DepID} linking to another `Map` in which\n * keys are the dependency names and values are {@link Dependency}. This\n * structure represents dependencies that need to be added to the importer\n * represented by {@link DepID}.\n */\n add?: AddImportersDependenciesMap\n /**\n * A `Map` object representing nodes to be removed from the ideal graph.\n * Each {@link DepID} key represents an importer node and the `Set` of\n * dependency names to be removed from its dependency list.\n */\n remove?: RemoveImportersDependenciesMap\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n}\n\n/**\n * Builds an ideal {@link Graph} representing the dependencies that\n * should be present in order to fulfill the requirements defined\n * by the `package.json` and `vlt-lock.json` files using either the\n * virtual or actual graph as a starting point. Also add / remove any\n * dependencies listed in the `add` and `remove` properties.\n */\nexport const build = async (\n options: BuildIdealOptions,\n): Promise<Graph> => {\n // Creates the shared instances that are going to be used\n // in both the loader methods and the build graph\n const { packageInfo, packageJson, scurry, monorepo } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(options.projectRoot)\n const add = options.add ?? new Map()\n const remove = options.remove ?? new Map()\n\n let graph\n try {\n graph = loadVirtual({\n ...options,\n mainManifest,\n monorepo,\n })\n } catch {\n graph = loadActual({\n ...options,\n mainManifest,\n monorepo,\n })\n }\n\n return buildIdealFromStartingGraph({\n ...options,\n scurry,\n add,\n graph,\n packageInfo,\n remove,\n })\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AddImportersDependenciesMap, RemoveImportersDependenciesMap } from '../dependencies.js';
|
|
2
|
+
import { BuildIdealAddOptions, BuildIdealFromGraphOptions, BuildIdealRemoveOptions } from './types.js';
|
|
3
|
+
export type GetImporterSpecsOptions = BuildIdealAddOptions & BuildIdealFromGraphOptions & BuildIdealRemoveOptions;
|
|
4
|
+
/**
|
|
5
|
+
* Given a {@link Graph} and a list of {@link Dependency}, merges the
|
|
6
|
+
* dependencies info found in the graph importers and returns the add & remove
|
|
7
|
+
* results as a Map in which keys are {@link DepID} of each importer node.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getImporterSpecs: ({ add, graph, remove, }: GetImporterSpecsOptions) => {
|
|
10
|
+
add: AddImportersDependenciesMap;
|
|
11
|
+
remove: RemoveImportersDependenciesMap;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=get-importer-specs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-importer-specs.d.ts","sourceRoot":"","sources":["../../../src/ideal/get-importer-specs.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAE3B,8BAA8B,EAE/B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACxB,MAAM,YAAY,CAAA;AAInB,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GACxD,0BAA0B,GAC1B,uBAAuB,CAAA;AAWzB;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,4BAI1B,uBAAuB;;;CA+DzB,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { longDependencyTypes, } from '../dependencies.js';
|
|
3
|
+
import { removeSatisfiedSpecs } from './remove-satisfied-specs.js';
|
|
4
|
+
const hasDepName = (importer, edge) => {
|
|
5
|
+
for (const depType of longDependencyTypes) {
|
|
6
|
+
const listedDeps = importer.manifest?.[depType];
|
|
7
|
+
if (listedDeps && Object.hasOwn(listedDeps, edge.name))
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Given a {@link Graph} and a list of {@link Dependency}, merges the
|
|
14
|
+
* dependencies info found in the graph importers and returns the add & remove
|
|
15
|
+
* results as a Map in which keys are {@link DepID} of each importer node.
|
|
16
|
+
*/
|
|
17
|
+
export const getImporterSpecs = ({ add, graph, remove, }) => {
|
|
18
|
+
const addResult = new Map();
|
|
19
|
+
const removeResult = new Map();
|
|
20
|
+
// traverse the list of importers in the starting graph
|
|
21
|
+
for (const importer of graph.importers) {
|
|
22
|
+
// uses a Map keying to the spec.name in order to easily make sure there's
|
|
23
|
+
// only a single dependency entry for a given dependency for each importer
|
|
24
|
+
const addDeps = new Map();
|
|
25
|
+
const removeDeps = new Set();
|
|
26
|
+
for (const edge of importer.edgesOut.values()) {
|
|
27
|
+
if (hasDepName(importer, edge)) {
|
|
28
|
+
addDeps.set(edge.name, {
|
|
29
|
+
spec: edge.spec,
|
|
30
|
+
type: edge.type,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
removeDeps.add(edge.name);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
addResult.set(importer.id, addDeps);
|
|
38
|
+
removeResult.set(importer.id, removeDeps);
|
|
39
|
+
}
|
|
40
|
+
// merges any provided specs to add to the current found results
|
|
41
|
+
for (const [id, addDeps] of add.entries()) {
|
|
42
|
+
const deps = addResult.get(id);
|
|
43
|
+
if (!deps) {
|
|
44
|
+
throw error('Not an importer', { found: id });
|
|
45
|
+
}
|
|
46
|
+
for (const [name, dep] of addDeps.entries()) {
|
|
47
|
+
deps.set(name, dep);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Merges results from user-provided `remove` option with any remove
|
|
51
|
+
// results found from comparing the manifest with the loaded graph
|
|
52
|
+
for (const [key, removeSet] of remove) {
|
|
53
|
+
const importerRemoveItem = removeResult.get(key);
|
|
54
|
+
if (importerRemoveItem) {
|
|
55
|
+
for (const depName of removeSet) {
|
|
56
|
+
importerRemoveItem.add(depName);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Removes any references to an importer that no longer has specs
|
|
61
|
+
for (const [key, removeItem] of removeResult) {
|
|
62
|
+
if (removeItem.size === 0) {
|
|
63
|
+
removeResult.delete(key);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// removes already satisfied dependencies from the dependencies list
|
|
67
|
+
removeSatisfiedSpecs({
|
|
68
|
+
add: addResult,
|
|
69
|
+
graph,
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
add: addResult,
|
|
73
|
+
remove: removeResult,
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=get-importer-specs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-importer-specs.js","sourceRoot":"","sources":["../../../src/ideal/get-importer-specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAIL,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAalE,MAAM,UAAU,GAAG,CAAC,QAAc,EAAE,IAAU,EAAW,EAAE;IACzD,KAAK,MAAM,OAAO,IAAI,mBAAmB,EAAE,CAAC;QAC1C,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAA;QAC/C,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC;YACpD,OAAO,IAAI,CAAA;IACf,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAC/B,GAAG,EACH,KAAK,EACL,MAAM,GACkB,EAAE,EAAE;IAC5B,MAAM,SAAS,GAAgC,IAAI,GAAG,EAAE,CAAA;IACxD,MAAM,YAAY,GAAmC,IAAI,GAAG,EAAE,CAAA;IAE9D,uDAAuD;IACvD,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACvC,0EAA0E;QAC1E,0EAA0E;QAC1E,MAAM,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAA;QAC7C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAA;QACpC,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC9C,IAAI,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC;gBAC/B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE;oBACrB,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,IAAI,EAAE,IAAI,CAAC,IAAI;iBAChB,CAAC,CAAA;YACJ,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAC3B,CAAC;QACH,CAAC;QACD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;QACnC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,CAAA;IAC3C,CAAC;IAED,gEAAgE;IAChE,KAAK,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAC9B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,KAAK,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA;QAC/C,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;YAC5C,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QACrB,CAAC;IACH,CAAC;IAED,oEAAoE;IACpE,kEAAkE;IAClE,KAAK,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,IAAI,MAAM,EAAE,CAAC;QACtC,MAAM,kBAAkB,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAChD,IAAI,kBAAkB,EAAE,CAAC;YACvB,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE,CAAC;gBAChC,kBAAkB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACjC,CAAC;QACH,CAAC;IACH,CAAC;IAED,iEAAiE;IACjE,KAAK,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,YAAY,EAAE,CAAC;QAC7C,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC1B,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;IAED,oEAAoE;IACpE,oBAAoB,CAAC;QACnB,GAAG,EAAE,SAAS;QACd,KAAK;KACN,CAAC,CAAA;IAEF,OAAO;QACL,GAAG,EAAE,SAAS;QACd,MAAM,EAAE,YAAY;KACrB,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport {\n AddImportersDependenciesMap,\n Dependency,\n RemoveImportersDependenciesMap,\n longDependencyTypes,\n} from '../dependencies.js'\nimport { removeSatisfiedSpecs } from './remove-satisfied-specs.js'\nimport {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n BuildIdealRemoveOptions,\n} from './types.js'\nimport { Edge } from '../edge.js'\nimport { Node } from '../node.js'\n\nexport type GetImporterSpecsOptions = BuildIdealAddOptions &\n BuildIdealFromGraphOptions &\n BuildIdealRemoveOptions\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\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 add,\n graph,\n remove,\n}: GetImporterSpecsOptions) => {\n const addResult: AddImportersDependenciesMap = new Map()\n const removeResult: RemoveImportersDependenciesMap = new Map()\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 for (const edge of importer.edgesOut.values()) {\n if (hasDepName(importer, edge)) {\n addDeps.set(edge.name, {\n spec: edge.spec,\n type: edge.type,\n })\n } else {\n removeDeps.add(edge.name)\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 return {\n add: addResult,\n remove: removeResult,\n }\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BuildIdealFromGraphOptions, BuildIdealRemoveOptions } from './types.js';
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-nodes.d.ts","sourceRoot":"","sources":["../../../src/ideal/remove-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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 {\n BuildIdealFromGraphOptions,\n BuildIdealRemoveOptions,\n} from './types.js'\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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BuildIdealAddOptions, BuildIdealFromGraphOptions } from './types.js';
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-satisfied-specs.d.ts","sourceRoot":"","sources":["../../../src/ideal/remove-satisfied-specs.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,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"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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 {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n} from './types.js'\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"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AddImportersDependenciesMap, RemoveImportersDependenciesMap } from '../dependencies.js';
|
|
2
|
+
import { Graph } from '../graph.js';
|
|
3
|
+
import { PackageInfoClient } from '@vltpkg/package-info';
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ideal/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ideal/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n AddImportersDependenciesMap,\n RemoveImportersDependenciesMap,\n} from '../dependencies.js'\nimport { Graph } from '../graph.js'\nimport { PackageInfoClient } from '@vltpkg/package-info'\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"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export * from './edge.js';
|
|
2
|
+
export * from './graph.js';
|
|
3
|
+
export * from './node.js';
|
|
4
|
+
export * from './dependencies.js';
|
|
5
|
+
export * from './lockfile/types.js';
|
|
6
|
+
export * from './visualization/json-output.js';
|
|
7
|
+
export * from './visualization/human-readable-output.js';
|
|
8
|
+
export * from './visualization/mermaid-output.js';
|
|
9
|
+
export * from './stringify-node.js';
|
|
10
|
+
export * from './types.js';
|
|
11
|
+
export declare const actual: {
|
|
12
|
+
load: (options: ActualLoadOptions) => import("./graph.js").Graph;
|
|
13
|
+
};
|
|
14
|
+
export declare const lockfile: {
|
|
15
|
+
load: (options: LockfileLoadOptions) => import("./graph.js").Graph;
|
|
16
|
+
loadEdges: (graph: import("./types.js").GraphLike, edges: import("./lockfile/types.js").LockfileData["edges"], options: import("@vltpkg/spec").SpecOptions) => void;
|
|
17
|
+
loadNodes: (graph: import("./types.js").GraphLike, nodes: import("./lockfile/types.js").LockfileData["nodes"]) => void;
|
|
18
|
+
save: (options: import("./lockfile/save.js").SaveOptions) => void;
|
|
19
|
+
};
|
|
20
|
+
import type { LoadOptions as ActualLoadOptions } from './actual/load.js';
|
|
21
|
+
import type { LoadOptions as LockfileLoadOptions } from './lockfile/load.js';
|
|
22
|
+
export type { ActualLoadOptions, LockfileLoadOptions };
|
|
23
|
+
export type { SaveOptions } from './lockfile/save.js';
|
|
24
|
+
import { BuildIdealOptions } from './ideal/build.js';
|
|
25
|
+
export type { BuildIdealOptions };
|
|
26
|
+
export declare const ideal: {
|
|
27
|
+
build: (options: BuildIdealOptions) => Promise<import("./graph.js").Graph>;
|
|
28
|
+
};
|
|
29
|
+
export { reify } from './reify/index.js';
|
|
30
|
+
export type { ReifyOptions } from './reify/index.js';
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0CAA0C,CAAA;AACxD,cAAc,mCAAmC,CAAA;AACjD,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAG1B,eAAO,MAAM,MAAM;;CAAuB,CAAA;AAM1C,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAA;AAED,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,KAAK,EAAE,WAAW,IAAI,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC5E,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,iBAAiB,EAAS,MAAM,kBAAkB,CAAA;AAC3D,YAAY,EAAE,iBAAiB,EAAE,CAAA;AACjC,eAAO,MAAM,KAAK;;CAAY,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export * from './edge.js';
|
|
2
|
+
export * from './graph.js';
|
|
3
|
+
export * from './node.js';
|
|
4
|
+
export * from './dependencies.js';
|
|
5
|
+
export * from './lockfile/types.js';
|
|
6
|
+
export * from './visualization/json-output.js';
|
|
7
|
+
export * from './visualization/human-readable-output.js';
|
|
8
|
+
export * from './visualization/mermaid-output.js';
|
|
9
|
+
export * from './stringify-node.js';
|
|
10
|
+
export * from './types.js';
|
|
11
|
+
import { load as actualLoad } from './actual/load.js';
|
|
12
|
+
export const actual = { load: actualLoad };
|
|
13
|
+
import { load as lockfileLoad } from './lockfile/load.js';
|
|
14
|
+
import { loadEdges } from './lockfile/load-edges.js';
|
|
15
|
+
import { loadNodes } from './lockfile/load-nodes.js';
|
|
16
|
+
import { save } from './lockfile/save.js';
|
|
17
|
+
export const lockfile = {
|
|
18
|
+
load: lockfileLoad,
|
|
19
|
+
loadEdges,
|
|
20
|
+
loadNodes,
|
|
21
|
+
save,
|
|
22
|
+
};
|
|
23
|
+
import { build } from './ideal/build.js';
|
|
24
|
+
export const ideal = { build };
|
|
25
|
+
export { reify } from './reify/index.js';
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0CAA0C,CAAA;AACxD,cAAc,mCAAmC,CAAA;AACjD,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAE1B,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACrD,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;AAE1C,OAAO,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACzD,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;AAOD,OAAO,EAAqB,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAE3D,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,KAAK,EAAE,CAAA;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA","sourcesContent":["export * from './edge.js'\nexport * from './graph.js'\nexport * from './node.js'\nexport * from './dependencies.js'\nexport * from './lockfile/types.js'\nexport * from './visualization/json-output.js'\nexport * from './visualization/human-readable-output.js'\nexport * from './visualization/mermaid-output.js'\nexport * from './stringify-node.js'\nexport * from './types.js'\n\nimport { load as actualLoad } from './actual/load.js'\nexport const actual = { load: actualLoad }\n\nimport { load as lockfileLoad } from './lockfile/load.js'\nimport { loadEdges } from './lockfile/load-edges.js'\nimport { loadNodes } from './lockfile/load-nodes.js'\nimport { save } from './lockfile/save.js'\nexport const lockfile = {\n load: lockfileLoad,\n loadEdges,\n loadNodes,\n save,\n}\n\nimport type { LoadOptions as ActualLoadOptions } from './actual/load.js'\nimport type { LoadOptions as LockfileLoadOptions } from './lockfile/load.js'\nexport type { ActualLoadOptions, LockfileLoadOptions }\nexport type { SaveOptions } from './lockfile/save.js'\n\nimport { BuildIdealOptions, build } from './ideal/build.js'\nexport type { BuildIdealOptions }\nexport const ideal = { build }\nexport { reify } from './reify/index.js'\nexport type { ReifyOptions } from './reify/index.js'\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type SpecOptions } from '@vltpkg/spec/browser';
|
|
2
|
+
import type { GraphLike } from '../types.js';
|
|
3
|
+
import { LockfileData } from './types.js';
|
|
4
|
+
export declare const loadEdges: (graph: GraphLike, edges: LockfileData["edges"], options: SpecOptions) => void;
|
|
5
|
+
//# sourceMappingURL=load-edges.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-edges.d.ts","sourceRoot":"","sources":["../../../src/lockfile/load-edges.ts"],"names":[],"mappings":"AAGA,OAAO,EAAQ,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAK7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EACL,YAAY,EAGb,MAAM,YAAY,CAAA;AAEnB,eAAO,MAAM,SAAS,UACb,SAAS,SACT,YAAY,CAAC,OAAO,CAAC,WACnB,WAAW,SA0CrB,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { asDepID } from '@vltpkg/dep-id/browser';
|
|
2
|
+
import { error } from '@vltpkg/error-cause';
|
|
3
|
+
import { fastSplit } from '@vltpkg/fast-split';
|
|
4
|
+
import { Spec } from '@vltpkg/spec/browser';
|
|
5
|
+
import { isDependencyTypeShort, longDependencyTypes, } from '../dependencies.js';
|
|
6
|
+
export const loadEdges = (graph, edges, options) => {
|
|
7
|
+
const entries = Object.entries(edges);
|
|
8
|
+
for (const [key, value] of entries) {
|
|
9
|
+
const [fromId, specName] = fastSplit(key, ' ', 2);
|
|
10
|
+
const [depType, valRest] = fastSplit(value, ' ', 2);
|
|
11
|
+
const vrSplit = valRest?.lastIndexOf(' ') ?? -1;
|
|
12
|
+
// not a valid edge record
|
|
13
|
+
/* c8 ignore start */
|
|
14
|
+
if (!valRest || !depType || !fromId || !specName || vrSplit < 1) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
/* c8 ignore stop */
|
|
18
|
+
const spec = Spec.parse(specName, valRest.substring(0, vrSplit), options);
|
|
19
|
+
const toId = valRest.substring(vrSplit + 1);
|
|
20
|
+
const from = graph.nodes.get(asDepID(fromId));
|
|
21
|
+
if (!from) {
|
|
22
|
+
throw error('Edge info missing its `from` node', {
|
|
23
|
+
found: {
|
|
24
|
+
nodes: [...graph.nodes].map(([id]) => id),
|
|
25
|
+
from,
|
|
26
|
+
fromId,
|
|
27
|
+
edge: { [key]: value },
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const to = toId === 'MISSING' ? undefined : graph.nodes.get(asDepID(toId));
|
|
32
|
+
if (!isDependencyTypeShort(depType)) {
|
|
33
|
+
throw error('Found unsupported dependency type in lockfile', {
|
|
34
|
+
validOptions: [...longDependencyTypes],
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
graph.addEdge(depType, spec, from, to);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=load-edges.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-edges.js","sourceRoot":"","sources":["../../../src/lockfile/load-edges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAoB,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EACL,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,oBAAoB,CAAA;AAQ3B,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAgB,EAChB,KAA4B,EAC5B,OAAoB,EACpB,EAAE;IACF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAGjC,CAAA;IACH,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE,CAAC;QACnC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;QACjD,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;QACnD,MAAM,OAAO,GAAG,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;QAC/C,0BAA0B;QAC1B,qBAAqB;QACrB,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;YAChE,SAAQ;QACV,CAAC;QACD,oBAAoB;QACpB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CACrB,QAAQ,EACR,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,EAC7B,OAAO,CACR,CAAA;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,CAAC,CAAC,CAAA;QAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;QAC7C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,KAAK,CAAC,mCAAmC,EAAE;gBAC/C,KAAK,EAAE;oBACL,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;oBACzC,IAAI;oBACJ,MAAM;oBACN,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE;iBACvB;aACF,CAAC,CAAA;QACJ,CAAC;QACD,MAAM,EAAE,GACN,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;QACjE,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,EAAE,CAAC;YACpC,MAAM,KAAK,CAAC,+CAA+C,EAAE;gBAC3D,YAAY,EAAE,CAAC,GAAG,mBAAmB,CAAC;aACvC,CAAC,CAAA;QACJ,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAA;IACxC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { asDepID } from '@vltpkg/dep-id/browser'\nimport { error } from '@vltpkg/error-cause'\nimport { fastSplit } from '@vltpkg/fast-split'\nimport { Spec, type SpecOptions } from '@vltpkg/spec/browser'\nimport {\n isDependencyTypeShort,\n longDependencyTypes,\n} from '../dependencies.js'\nimport type { GraphLike } from '../types.js'\nimport {\n LockfileData,\n LockfileEdgeKey,\n LockfileEdgeValue,\n} from './types.js'\n\nexport const loadEdges = (\n graph: GraphLike,\n edges: LockfileData['edges'],\n options: SpecOptions,\n) => {\n const entries = Object.entries(edges) as [\n LockfileEdgeKey,\n LockfileEdgeValue,\n ][]\n for (const [key, value] of entries) {\n const [fromId, specName] = fastSplit(key, ' ', 2)\n const [depType, valRest] = fastSplit(value, ' ', 2)\n const vrSplit = valRest?.lastIndexOf(' ') ?? -1\n // not a valid edge record\n /* c8 ignore start */\n if (!valRest || !depType || !fromId || !specName || vrSplit < 1) {\n continue\n }\n /* c8 ignore stop */\n const spec = Spec.parse(\n specName,\n valRest.substring(0, vrSplit),\n options,\n )\n const toId = valRest.substring(vrSplit + 1)\n const from = graph.nodes.get(asDepID(fromId))\n if (!from) {\n throw error('Edge info missing its `from` node', {\n found: {\n nodes: [...graph.nodes].map(([id]) => id),\n from,\n fromId,\n edge: { [key]: value },\n },\n })\n }\n const to =\n toId === 'MISSING' ? undefined : graph.nodes.get(asDepID(toId))\n if (!isDependencyTypeShort(depType)) {\n throw error('Found unsupported dependency type in lockfile', {\n validOptions: [...longDependencyTypes],\n })\n }\n graph.addEdge(depType, spec, from, to)\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-nodes.d.ts","sourceRoot":"","sources":["../../../src/lockfile/load-nodes.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,eAAO,MAAM,SAAS,UACb,SAAS,SACT,YAAY,CAAC,OAAO,CAAC,SAkC7B,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { splitDepID } from '@vltpkg/dep-id/browser';
|
|
2
|
+
import { getBooleanFlagsFromNum, } from './types.js';
|
|
3
|
+
export const loadNodes = (graph, nodes) => {
|
|
4
|
+
const entries = Object.entries(nodes);
|
|
5
|
+
for (const [id, lockfileNode] of entries) {
|
|
6
|
+
// workspace nodes and the project root node are already part of the
|
|
7
|
+
// graph and it should not create new nodes if an existing one is there
|
|
8
|
+
if (graph.nodes.has(id))
|
|
9
|
+
continue;
|
|
10
|
+
const [flags, name, integrity, resolved, location, manifest] = lockfileNode;
|
|
11
|
+
const [type, , spec] = splitDepID(id);
|
|
12
|
+
// if the lockfile has manifest data then it should just use that
|
|
13
|
+
// otherwise tries to infer name / version value from the lockfile node
|
|
14
|
+
const node = manifest ?
|
|
15
|
+
graph.addNode(id, manifest)
|
|
16
|
+
: graph.addNode(id, undefined, undefined, name ?? undefined, type === 'registry' && spec.indexOf('@') > 0 ?
|
|
17
|
+
spec.split('@').slice(-1)[0]
|
|
18
|
+
: undefined);
|
|
19
|
+
const { dev, optional } = getBooleanFlagsFromNum(flags);
|
|
20
|
+
node.dev = dev;
|
|
21
|
+
node.optional = optional;
|
|
22
|
+
node.integrity = integrity ?? undefined;
|
|
23
|
+
node.resolved = resolved ?? undefined;
|
|
24
|
+
if (location)
|
|
25
|
+
node.location = location;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=load-nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-nodes.js","sourceRoot":"","sources":["../../../src/lockfile/load-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAEL,sBAAsB,GAEvB,MAAM,YAAY,CAAA;AAInB,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAgB,EAChB,KAA4B,EAC5B,EAAE;IACF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAA4B,CAAA;IAChE,KAAK,MAAM,CAAC,EAAE,EAAE,YAAY,CAAC,IAAI,OAAO,EAAE,CAAC;QACzC,oEAAoE;QACpE,uEAAuE;QACvE,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,SAAQ;QAEjC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAC1D,YAAY,CAAA;QACd,MAAM,CAAC,IAAI,EAAE,AAAD,EAAG,IAAI,CAAC,GAAG,UAAU,CAAC,EAAE,CAAC,CAAA;QAErC,iEAAiE;QACjE,uEAAuE;QACvE,MAAM,IAAI,GACR,QAAQ,CAAC,CAAC;YACR,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC;YAC7B,CAAC,CAAC,KAAK,CAAC,OAAO,CACX,EAAE,EACF,SAAS,EACT,SAAS,EACT,IAAI,IAAI,SAAS,EACjB,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC5C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC9B,CAAC,CAAC,SAAS,CACZ,CAAA;QAEL,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAA;QACvD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,SAAS,CAAA;QACvC,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,SAAS,CAAA;QACrC,IAAI,QAAQ;YAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IACxC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { splitDepID } from '@vltpkg/dep-id/browser'\nimport {\n type LockfileData,\n getBooleanFlagsFromNum,\n type LockfileNode,\n} from './types.js'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { GraphLike } from '../types.js'\n\nexport const loadNodes = (\n graph: GraphLike,\n nodes: LockfileData['nodes'],\n) => {\n const entries = Object.entries(nodes) as [DepID, LockfileNode][]\n for (const [id, lockfileNode] of entries) {\n // workspace nodes and the project root node are already part of the\n // graph and it should not create new nodes if an existing one is there\n if (graph.nodes.has(id)) continue\n\n const [flags, name, integrity, resolved, location, manifest] =\n lockfileNode\n const [type, , spec] = splitDepID(id)\n\n // if the lockfile has manifest data then it should just use that\n // otherwise tries to infer name / version value from the lockfile node\n const node =\n manifest ?\n graph.addNode(id, manifest)\n : graph.addNode(\n id,\n undefined,\n undefined,\n name ?? undefined,\n type === 'registry' && spec.indexOf('@') > 0 ?\n spec.split('@').slice(-1)[0]\n : undefined,\n )\n\n const { dev, optional } = getBooleanFlagsFromNum(flags)\n node.dev = dev\n node.optional = optional\n node.integrity = integrity ?? undefined\n node.resolved = resolved ?? undefined\n if (location) node.location = location\n }\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { PackageJson } from '@vltpkg/package-json';
|
|
2
|
+
import { Manifest } from '@vltpkg/types';
|
|
3
|
+
import { Monorepo } from '@vltpkg/workspaces';
|
|
4
|
+
import type { SpecOptions } from '@vltpkg/spec';
|
|
5
|
+
import { PathScurry } from 'path-scurry';
|
|
6
|
+
import { Graph } from '../graph.js';
|
|
7
|
+
import type { LockfileData } from './types.js';
|
|
8
|
+
export type LoadOptions = SpecOptions & {
|
|
9
|
+
/**
|
|
10
|
+
* The project root dirname.
|
|
11
|
+
*/
|
|
12
|
+
projectRoot: string;
|
|
13
|
+
/**
|
|
14
|
+
* The project root manifest.
|
|
15
|
+
*/
|
|
16
|
+
mainManifest: Manifest;
|
|
17
|
+
/**
|
|
18
|
+
* A {@link Monorepo} object, for managing workspaces
|
|
19
|
+
*/
|
|
20
|
+
monorepo?: Monorepo;
|
|
21
|
+
/**
|
|
22
|
+
* A {@link PackageJson} object, for sharing manifest caches
|
|
23
|
+
*/
|
|
24
|
+
packageJson?: PackageJson;
|
|
25
|
+
/**
|
|
26
|
+
* A {@link PathScurry} object, for use in globs
|
|
27
|
+
*/
|
|
28
|
+
scurry?: PathScurry;
|
|
29
|
+
};
|
|
30
|
+
export declare const load: (options: LoadOptions) => Graph;
|
|
31
|
+
export declare const loadHidden: (options: LoadOptions) => Graph;
|
|
32
|
+
export declare const loadObject: (options: LoadOptions, lockfileData: LockfileData) => Graph;
|
|
33
|
+
//# sourceMappingURL=load.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/lockfile/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,YAAY,EAAE,QAAQ,CAAA;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB;;OAEG;IACH,MAAM,CAAC,EAAE,UAAU,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,IAAI,YAAa,WAAW,KAAG,KAU3C,CAAA;AAED,eAAO,MAAM,UAAU,YAAa,WAAW,KAAG,KAWjD,CAAA;AAED,eAAO,MAAM,UAAU,YACZ,WAAW,gBACN,YAAY,UA4C3B,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { PackageJson } from '@vltpkg/package-json';
|
|
2
|
+
import { Monorepo } from '@vltpkg/workspaces';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { resolve } from 'node:path';
|
|
5
|
+
import { loadEdges } from './load-edges.js';
|
|
6
|
+
import { loadNodes } from './load-nodes.js';
|
|
7
|
+
import { Graph } from '../graph.js';
|
|
8
|
+
export const load = (options) => {
|
|
9
|
+
const { projectRoot } = options;
|
|
10
|
+
return loadObject(options, JSON.parse(readFileSync(resolve(projectRoot, 'vlt-lock.json'), {
|
|
11
|
+
encoding: 'utf8',
|
|
12
|
+
})));
|
|
13
|
+
};
|
|
14
|
+
export const loadHidden = (options) => {
|
|
15
|
+
const { projectRoot } = options;
|
|
16
|
+
return loadObject(options, JSON.parse(readFileSync(resolve(projectRoot, 'node_modules/.vlt-lock.json'), { encoding: 'utf8' })));
|
|
17
|
+
};
|
|
18
|
+
export const loadObject = (options, lockfileData) => {
|
|
19
|
+
const { mainManifest, scurry } = options;
|
|
20
|
+
const packageJson = options.packageJson ?? new PackageJson();
|
|
21
|
+
const monorepo = options.monorepo ??
|
|
22
|
+
Monorepo.maybeLoad(options.projectRoot, { packageJson, scurry });
|
|
23
|
+
const { 'scope-registries': scopeRegistries, registry, registries, 'git-hosts': gitHosts, 'git-host-archives': gitHostArchives, } = lockfileData.options;
|
|
24
|
+
const mergedOptions = {
|
|
25
|
+
...options,
|
|
26
|
+
'scope-registries': {
|
|
27
|
+
...options['scope-registries'],
|
|
28
|
+
...scopeRegistries,
|
|
29
|
+
},
|
|
30
|
+
registry: registry ?? options.registry,
|
|
31
|
+
registries: {
|
|
32
|
+
...options.registries,
|
|
33
|
+
...registries,
|
|
34
|
+
},
|
|
35
|
+
'git-hosts': {
|
|
36
|
+
...options['git-hosts'],
|
|
37
|
+
...gitHosts,
|
|
38
|
+
},
|
|
39
|
+
'git-host-archives': {
|
|
40
|
+
...options['git-host-archives'],
|
|
41
|
+
...gitHostArchives,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
const graph = new Graph({
|
|
45
|
+
...mergedOptions,
|
|
46
|
+
mainManifest,
|
|
47
|
+
monorepo,
|
|
48
|
+
});
|
|
49
|
+
loadNodes(graph, lockfileData.nodes);
|
|
50
|
+
loadEdges(graph, lockfileData.edges, mergedOptions);
|
|
51
|
+
return graph;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=load.js.map
|