@vltpkg/graph 0.0.0-0.1730239248325 → 0.0.0-0.1730724342581
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 +9 -4
- package/dist/esm/actual/load.d.ts +5 -5
- package/dist/esm/actual/load.d.ts.map +1 -1
- package/dist/esm/actual/load.js.map +1 -1
- package/dist/esm/dependencies.d.ts +5 -5
- package/dist/esm/dependencies.d.ts.map +1 -1
- package/dist/esm/dependencies.js +7 -2
- package/dist/esm/dependencies.js.map +1 -1
- package/dist/esm/diff.d.ts +4 -4
- package/dist/esm/diff.d.ts.map +1 -1
- package/dist/esm/diff.js.map +1 -1
- package/dist/esm/edge.d.ts +5 -5
- package/dist/esm/edge.d.ts.map +1 -1
- package/dist/esm/edge.js.map +1 -1
- package/dist/esm/graph.d.ts +4 -4
- package/dist/esm/graph.d.ts.map +1 -1
- package/dist/esm/graph.js +4 -3
- package/dist/esm/graph.js.map +1 -1
- package/dist/esm/ideal/add-nodes.d.ts +4 -4
- package/dist/esm/ideal/add-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/add-nodes.js.map +1 -1
- package/dist/esm/ideal/append-nodes.d.ts +6 -6
- package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/append-nodes.js.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts +3 -3
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.js +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -1
- package/dist/esm/ideal/build.d.ts +4 -4
- package/dist/esm/ideal/build.d.ts.map +1 -1
- package/dist/esm/ideal/build.js +3 -4
- package/dist/esm/ideal/build.js.map +1 -1
- package/dist/esm/ideal/get-importer-specs.d.ts +2 -2
- package/dist/esm/ideal/get-importer-specs.d.ts.map +1 -1
- package/dist/esm/ideal/get-importer-specs.js.map +1 -1
- package/dist/esm/ideal/remove-nodes.d.ts +1 -1
- package/dist/esm/ideal/remove-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/remove-nodes.js.map +1 -1
- package/dist/esm/ideal/remove-satisfied-specs.d.ts +1 -1
- package/dist/esm/ideal/remove-satisfied-specs.d.ts.map +1 -1
- package/dist/esm/ideal/remove-satisfied-specs.js.map +1 -1
- package/dist/esm/ideal/types.d.ts +3 -3
- package/dist/esm/ideal/types.d.ts.map +1 -1
- package/dist/esm/ideal/types.js.map +1 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lockfile/load-edges.d.ts +2 -2
- package/dist/esm/lockfile/load-edges.d.ts.map +1 -1
- package/dist/esm/lockfile/load-edges.js.map +1 -1
- package/dist/esm/lockfile/load-nodes.d.ts +1 -1
- package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
- package/dist/esm/lockfile/load-nodes.js.map +1 -1
- package/dist/esm/lockfile/load.d.ts +4 -4
- package/dist/esm/lockfile/load.d.ts.map +1 -1
- package/dist/esm/lockfile/load.js +5 -4
- package/dist/esm/lockfile/load.js.map +1 -1
- package/dist/esm/lockfile/save.d.ts +2 -2
- package/dist/esm/lockfile/save.d.ts.map +1 -1
- package/dist/esm/lockfile/save.js.map +1 -1
- package/dist/esm/lockfile/types.d.ts +5 -5
- package/dist/esm/lockfile/types.d.ts.map +1 -1
- package/dist/esm/lockfile/types.js.map +1 -1
- package/dist/esm/node.d.ts +5 -5
- package/dist/esm/node.d.ts.map +1 -1
- package/dist/esm/node.js.map +1 -1
- package/dist/esm/reify/add-edge.d.ts +4 -4
- package/dist/esm/reify/add-edge.d.ts.map +1 -1
- package/dist/esm/reify/add-edge.js.map +1 -1
- package/dist/esm/reify/add-edges.d.ts +4 -4
- package/dist/esm/reify/add-edges.d.ts.map +1 -1
- package/dist/esm/reify/add-edges.js.map +1 -1
- package/dist/esm/reify/add-nodes.d.ts +5 -5
- package/dist/esm/reify/add-nodes.d.ts.map +1 -1
- package/dist/esm/reify/add-nodes.js.map +1 -1
- package/dist/esm/reify/bin-paths.d.ts +1 -1
- package/dist/esm/reify/bin-paths.d.ts.map +1 -1
- package/dist/esm/reify/bin-paths.js.map +1 -1
- package/dist/esm/reify/build.d.ts +3 -3
- package/dist/esm/reify/build.d.ts.map +1 -1
- package/dist/esm/reify/build.js.map +1 -1
- package/dist/esm/reify/delete-edge.d.ts +3 -3
- package/dist/esm/reify/delete-edge.d.ts.map +1 -1
- package/dist/esm/reify/delete-edge.js.map +1 -1
- package/dist/esm/reify/delete-edges.d.ts +3 -3
- package/dist/esm/reify/delete-edges.d.ts.map +1 -1
- package/dist/esm/reify/delete-edges.js.map +1 -1
- package/dist/esm/reify/delete-nodes.d.ts +3 -3
- package/dist/esm/reify/delete-nodes.d.ts.map +1 -1
- package/dist/esm/reify/delete-nodes.js.map +1 -1
- package/dist/esm/reify/index.d.ts +4 -4
- package/dist/esm/reify/index.d.ts.map +1 -1
- package/dist/esm/reify/index.js +1 -1
- package/dist/esm/reify/index.js.map +1 -1
- package/dist/esm/reify/optional-fail.d.ts +2 -2
- package/dist/esm/reify/optional-fail.d.ts.map +1 -1
- package/dist/esm/reify/optional-fail.js.map +1 -1
- package/dist/esm/reify/rollback.d.ts +2 -2
- package/dist/esm/reify/rollback.d.ts.map +1 -1
- package/dist/esm/reify/rollback.js.map +1 -1
- package/dist/esm/reify/update-importers-package-json.d.ts +2 -2
- package/dist/esm/reify/update-importers-package-json.d.ts.map +1 -1
- package/dist/esm/reify/update-importers-package-json.js.map +1 -1
- package/dist/esm/remove-optional-subgraph.d.ts +2 -2
- package/dist/esm/remove-optional-subgraph.d.ts.map +1 -1
- package/dist/esm/remove-optional-subgraph.js.map +1 -1
- package/dist/esm/stringify-node.d.ts +1 -1
- package/dist/esm/stringify-node.d.ts.map +1 -1
- package/dist/esm/stringify-node.js.map +1 -1
- package/dist/esm/types.d.ts +10 -11
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/visualization/human-readable-output.d.ts +4 -2
- package/dist/esm/visualization/human-readable-output.d.ts.map +1 -1
- package/dist/esm/visualization/human-readable-output.js.map +1 -1
- package/dist/esm/visualization/json-output.d.ts +2 -2
- package/dist/esm/visualization/json-output.d.ts.map +1 -1
- package/dist/esm/visualization/json-output.js.map +1 -1
- package/dist/esm/visualization/mermaid-output.d.ts +1 -1
- package/dist/esm/visualization/mermaid-output.d.ts.map +1 -1
- package/dist/esm/visualization/mermaid-output.js.map +1 -1
- package/dist/esm/visualization/object-like-output.d.ts +1 -1
- package/dist/esm/visualization/object-like-output.d.ts.map +1 -1
- package/dist/esm/visualization/object-like-output.js +5 -6
- package/dist/esm/visualization/object-like-output.js.map +1 -1
- package/package.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"append-nodes.js","sourceRoot":"","sources":["../../../src/ideal/append-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"append-nodes.js","sourceRoot":"","sources":["../../../src/ideal/append-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,IAAI,EAAoB,MAAM,cAAc,CAAA;AAErD,OAAO,EAGL,mBAAmB,EACnB,OAAO,GACR,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAQvE;;;GAGG;AACH,MAAM,oBAAoB,GAAG,CAC3B,IAAU,EACV,OAA2B,EAC3B,EAAE,CACF,OAAO,KAAK,iBAAiB;IAC7B,IAAI,CAAC,QAAQ;IACb,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;AAE3B;;GAEG;AACH,MAAM,eAAe,GAA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,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;oBAC1B,qDAAqD;oBACrD,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE;wBAC/B,GAAG,OAAO;wBACV,QAAQ,EAAE,IAAI,CAAC,QAAQ;qBACxB,CAAC;oBACF,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC;iBACvC,CAAC,CAAC,CAAA;gBACL,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACpB,aAAa,CAAC,IAAI,CAChB,WAAW,CACT,WAAW,EACX,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,IAAI,CACL,CACF,CAAA;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;IAClC,CAAC,CAAC,CACH,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { type DepID, joinDepIDTuple } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport { type PackageInfoClient } from '@vltpkg/package-info'\nimport { Spec, type SpecOptions } from '@vltpkg/spec'\nimport { type PathScurry } from 'path-scurry'\nimport {\n type Dependency,\n type DependencyTypeLong,\n longDependencyTypes,\n shorten,\n} from '../dependencies.js'\nimport { type Graph } from '../graph.js'\nimport { type Node } from '../node.js'\nimport { removeOptionalSubgraph } from '../remove-optional-subgraph.js'\n\ntype FileTypeInfo = {\n id: DepID\n path: string\n isDirectory: boolean\n}\n\n/**\n * Only install devDeps for git dependencies and importers\n * Everything else always gets installed\n */\nconst shouldInstallDepType = (\n node: Node,\n depType: DependencyTypeLong,\n) =>\n depType !== 'devDependencies' ||\n node.importer ||\n node.id.startsWith('git')\n\n/**\n * Retrieve the {@link DepID} and location for a `file:` type {@link Node}.\n */\nconst getFileTypeInfo = (\n spec: Spec,\n fromNode: Node,\n scurry: PathScurry,\n): FileTypeInfo | undefined => {\n const f = spec.final\n if (f.type !== 'file') return\n\n /* c8 ignore start - should be impossible */\n if (!f.file) {\n throw error('no path on file specifier', { spec })\n }\n /* c8 ignore stop */\n\n // Given that both linked folders and local tarballs (both defined with\n // usage of the `file:` spec prefix) location needs to be relative to their\n // parents, build the expected path and use it for both location and id\n const target = scurry.cwd.resolve(fromNode.location).resolve(f.file)\n const path = target.relativePosix()\n const id = joinDepIDTuple(['file', path])\n\n return {\n path,\n id,\n isDirectory: !!target.lstatSync()?.isDirectory(),\n }\n}\n\nconst isStringArray = (a: unknown): a is string[] =>\n Array.isArray(a) && !a.some(b => typeof b !== 'string')\n\nexport const appendNodes = async (\n packageInfo: PackageInfoClient,\n graph: Graph,\n fromNode: Node,\n deps: Dependency[],\n scurry: PathScurry,\n options: SpecOptions,\n seen: Set<DepID>,\n) => {\n /* c8 ignore next */\n if (seen.has(fromNode.id)) return\n seen.add(fromNode.id)\n\n await Promise.all(\n deps.map(async ({ spec, type }) => {\n // see if there's a satisfying node in the graph currently\n const fileTypeInfo = getFileTypeInfo(spec, fromNode, scurry)\n const existingNode = graph.findResolution(spec, fromNode)\n if (existingNode) {\n graph.addEdge(type, spec, fromNode, existingNode)\n return\n }\n const edgeOptional =\n type === 'optional' || type === 'peerOptional'\n const mani = await packageInfo\n .manifest(spec, { from: scurry.resolve(fromNode.location) })\n .catch((er: unknown) => {\n // optional deps ignored if inaccessible\n if (edgeOptional || fromNode.optional) {\n return undefined\n }\n throw er\n })\n\n if (!mani) {\n if (!edgeOptional && fromNode.isOptional()) {\n // failed resolution of a non-optional dep of an optional node\n // have to clean up the dependents\n removeOptionalSubgraph(graph, fromNode)\n return\n } else if (edgeOptional) {\n // failed resolution of an optional dep, just ignore it,\n // nothing to prune because we never added it in the first place.\n return\n } else {\n throw error('failed to resolve dependency', {\n spec,\n from: fromNode.location,\n })\n }\n }\n\n const node = graph.placePackage(\n fromNode,\n type,\n spec,\n mani,\n fileTypeInfo?.id,\n )\n\n /* c8 ignore start - not possible, already ensured manifest */\n if (!node) {\n throw error('failed to place package', {\n from: fromNode.location,\n spec,\n })\n }\n /* c8 ignore stop */\n\n if (fileTypeInfo?.path && fileTypeInfo.isDirectory) {\n node.location = fileTypeInfo.path\n }\n node.setResolved()\n const nestedAppends: Promise<unknown>[] = []\n\n const bundleDeps = node.manifest?.bundleDependencies\n const bundled = new Set<string>(\n (\n node.id.startsWith('git') ||\n node.importer ||\n !isStringArray(bundleDeps)\n ) ?\n []\n : bundleDeps,\n )\n for (const depTypeName of longDependencyTypes) {\n const depRecord: Record<string, string> | undefined =\n mani[depTypeName]\n\n if (depRecord && shouldInstallDepType(node, depTypeName)) {\n const nextDeps: Dependency[] = Object.entries(depRecord)\n .filter(([name]) => !bundled.has(name))\n .map(([name, bareSpec]) => ({\n // if foo:a@1 depends on b@2, then it must be foo:b@2\n spec: Spec.parse(name, bareSpec, {\n ...options,\n registry: spec.registry,\n }),\n type: shorten(depTypeName, name, mani),\n }))\n if (nextDeps.length) {\n nestedAppends.push(\n appendNodes(\n packageInfo,\n graph,\n node,\n nextDeps,\n scurry,\n options,\n seen,\n ),\n )\n }\n }\n }\n await Promise.all(nestedAppends)\n }),\n )\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Graph } from '../graph.js';
|
|
2
|
-
import { AddNodesOptions } from './add-nodes.js';
|
|
3
|
-
import { RemoveNodesOptions } from './remove-nodes.js';
|
|
1
|
+
import { type Graph } from '../graph.js';
|
|
2
|
+
import { type AddNodesOptions } from './add-nodes.js';
|
|
3
|
+
import { type RemoveNodesOptions } from './remove-nodes.js';
|
|
4
4
|
export type BuildIdealFromStartingGraphOptions = AddNodesOptions & RemoveNodesOptions & {
|
|
5
5
|
projectRoot: string;
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-ideal-from-starting-graph.d.ts","sourceRoot":"","sources":["../../../src/ideal/build-ideal-from-starting-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"build-ideal-from-starting-graph.d.ts","sourceRoot":"","sources":["../../../src/ideal/build-ideal-from-starting-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,KAAK,eAAe,EAAY,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,mBAAmB,CAAA;AAE1B,MAAM,MAAM,kCAAkC,GAAG,eAAe,GAC9D,kBAAkB,GAAG;IACnB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,YAC7B,kCAAkC,KAC1C,OAAO,CAAC,KAAK,CAqBf,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getImporterSpecs } from './get-importer-specs.js';
|
|
2
2
|
import { addNodes } from './add-nodes.js';
|
|
3
|
-
import { removeNodes } from './remove-nodes.js';
|
|
3
|
+
import { removeNodes, } from './remove-nodes.js';
|
|
4
4
|
/**
|
|
5
5
|
* Builds an ideal {@link Graph} representing the dependencies that
|
|
6
6
|
* should be present in order to fulfill the requirements defined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-ideal-from-starting-graph.js","sourceRoot":"","sources":["../../../src/ideal/build-ideal-from-starting-graph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"build-ideal-from-starting-graph.js","sourceRoot":"","sources":["../../../src/ideal/build-ideal-from-starting-graph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAwB,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAEL,WAAW,GACZ,MAAM,mBAAmB,CAAA;AAO1B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,EAC9C,OAA2C,EAC3B,EAAE;IAClB,sEAAsE;IACtE,wEAAwE;IACxE,sEAAsE;IACtE,oDAAoD;IACpD,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAE/C,uEAAuE;IACvE,MAAM,QAAQ,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,aAAa,EAAE,CAAC,CAAA;IAEhD,wDAAwD;IACxD,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QAChD,IAAI,CAAC,kBAAkB,EAAE,CAAA;IAC3B,CAAC;IAED,kEAAkE;IAClE,WAAW,CAAC,OAAO,CAAC,CAAA;IAEpB,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,CAAA;IAElB,OAAO,OAAO,CAAC,KAAK,CAAA;AACtB,CAAC,CAAA","sourcesContent":["import { type Graph } from '../graph.js'\nimport { getImporterSpecs } from './get-importer-specs.js'\nimport { type AddNodesOptions, addNodes } from './add-nodes.js'\nimport {\n type RemoveNodesOptions,\n removeNodes,\n} from './remove-nodes.js'\n\nexport type BuildIdealFromStartingGraphOptions = AddNodesOptions &\n RemoveNodesOptions & {\n projectRoot: string\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 the `graph` set\n * in options as a starting point. Also add / remove any dependencies\n * listed in the `add` and `remove` properties.\n */\nexport const buildIdealFromStartingGraph = async (\n options: BuildIdealFromStartingGraphOptions,\n): Promise<Graph> => {\n // Gets a map of dependencies that are keyed to its importer node ids,\n // merging values already found in the graph with user specified values.\n // Any dependencies that are already satisfied in the starting `graph`\n // are going to be pruned from the resulting object.\n const importerSpecs = getImporterSpecs(options)\n\n // add nodes, fetching remote manifests for each dependency to be added\n await addNodes({ ...options, ...importerSpecs })\n\n // move things into their default locations, if possible\n for (const node of options.graph.nodes.values()) {\n node.setDefaultLocation()\n }\n\n // removes any dependencies that are listed in the `remove` option\n removeNodes(options)\n\n options.graph.gc()\n\n return options.graph\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
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';
|
|
1
|
+
import { type PackageInfoClient } from '@vltpkg/package-info';
|
|
2
|
+
import { type LoadOptions as LoadActualOptions } from '../actual/load.js';
|
|
3
|
+
import { type AddImportersDependenciesMap, type RemoveImportersDependenciesMap } from '../dependencies.js';
|
|
4
|
+
import { type Graph } from '../graph.js';
|
|
5
5
|
export type BuildIdealOptions = LoadActualOptions & {
|
|
6
6
|
/**
|
|
7
7
|
* A `Map` in which keys are {@link DepID} linking to another `Map` in which
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,EAEL,KAAK,WAAW,IAAI,iBAAiB,EACtC,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,8BAA8B,EAEpC,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAA;AAQxC,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,CA6Bf,CAAA"}
|
package/dist/esm/ideal/build.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { load as loadActual, } from '../actual/load.js';
|
|
2
2
|
import { load as loadVirtual } from '../lockfile/load.js';
|
|
3
3
|
import { buildIdealFromStartingGraph } from './build-ideal-from-starting-graph.js';
|
|
4
|
+
const getMap = (m) => m ?? new Map();
|
|
4
5
|
/**
|
|
5
6
|
* Builds an ideal {@link Graph} representing the dependencies that
|
|
6
7
|
* should be present in order to fulfill the requirements defined
|
|
@@ -13,8 +14,6 @@ export const build = async (options) => {
|
|
|
13
14
|
// in both the loader methods and the build graph
|
|
14
15
|
const { packageInfo, packageJson, scurry, monorepo } = options;
|
|
15
16
|
const mainManifest = options.mainManifest ?? packageJson.read(options.projectRoot);
|
|
16
|
-
const add = options.add ?? new Map();
|
|
17
|
-
const remove = options.remove ?? new Map();
|
|
18
17
|
let graph;
|
|
19
18
|
try {
|
|
20
19
|
graph = loadVirtual({
|
|
@@ -33,10 +32,10 @@ export const build = async (options) => {
|
|
|
33
32
|
return buildIdealFromStartingGraph({
|
|
34
33
|
...options,
|
|
35
34
|
scurry,
|
|
36
|
-
add,
|
|
35
|
+
add: getMap(options.add),
|
|
37
36
|
graph,
|
|
38
37
|
packageInfo,
|
|
39
|
-
remove,
|
|
38
|
+
remove: getMap(options.remove),
|
|
40
39
|
});
|
|
41
40
|
};
|
|
42
41
|
//# sourceMappingURL=build.js.map
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"AACA,OAAO,EACL,IAAI,IAAI,UAAU,GAEnB,MAAM,mBAAmB,CAAA;AAO1B,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAA;AAGlF,MAAM,MAAM,GAAG,CAA0B,CAAK,EAAE,EAAE,CAChD,CAAC,IAAK,IAAI,GAAG,EAAQ,CAAA;AAsBvB;;;;;;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,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,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;QACxB,KAAK;QACL,WAAW;QACX,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;KAC/B,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { type PackageInfoClient } from '@vltpkg/package-info'\nimport {\n load as loadActual,\n type LoadOptions as LoadActualOptions,\n} from '../actual/load.js'\nimport {\n type AddImportersDependenciesMap,\n type RemoveImportersDependenciesMap,\n type Dependency,\n} from '../dependencies.js'\nimport { type Graph } from '../graph.js'\nimport { load as loadVirtual } from '../lockfile/load.js'\nimport { buildIdealFromStartingGraph } from './build-ideal-from-starting-graph.js'\nimport { type DepID } from '@vltpkg/dep-id'\n\nconst getMap = <T extends Map<any, any>>(m?: T) =>\n m ?? (new Map() as T)\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 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: getMap(options.add),\n graph,\n packageInfo,\n remove: getMap(options.remove),\n })\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AddImportersDependenciesMap, RemoveImportersDependenciesMap } from '../dependencies.js';
|
|
2
|
-
import { BuildIdealAddOptions, BuildIdealFromGraphOptions, BuildIdealRemoveOptions } from './types.js';
|
|
1
|
+
import { type AddImportersDependenciesMap, type RemoveImportersDependenciesMap } from '../dependencies.js';
|
|
2
|
+
import { type BuildIdealAddOptions, type BuildIdealFromGraphOptions, type BuildIdealRemoveOptions } from './types.js';
|
|
3
3
|
export type GetImporterSpecsOptions = BuildIdealAddOptions & BuildIdealFromGraphOptions & BuildIdealRemoveOptions;
|
|
4
4
|
/**
|
|
5
5
|
* Given a {@link Graph} and a list of {@link Dependency}, merges the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-importer-specs.d.ts","sourceRoot":"","sources":["../../../src/ideal/get-importer-specs.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,
|
|
1
|
+
{"version":3,"file":"get-importer-specs.d.ts","sourceRoot":"","sources":["../../../src/ideal/get-importer-specs.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,2BAA2B,EAEhC,KAAK,8BAA8B,EAEpC,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC7B,MAAM,YAAY,CAAA;AAMnB,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GACxD,0BAA0B,GAC1B,uBAAuB,CAAA;AAWzB;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,4BAI1B,uBAAuB;;;CA+DzB,CAAA"}
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"get-import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,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 type AddImportersDependenciesMap,\n type Dependency,\n type RemoveImportersDependenciesMap,\n longDependencyTypes,\n} from '../dependencies.js'\nimport { removeSatisfiedSpecs } from './remove-satisfied-specs.js'\nimport {\n type BuildIdealAddOptions,\n type BuildIdealFromGraphOptions,\n type BuildIdealRemoveOptions,\n} from './types.js'\nimport { type Edge } from '../edge.js'\nimport { type Node } from '../node.js'\nimport { type Graph } from '../graph.js'\nimport { type DepID } from '@vltpkg/dep-id'\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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuildIdealFromGraphOptions, BuildIdealRemoveOptions } from './types.js';
|
|
1
|
+
import { type BuildIdealFromGraphOptions, type BuildIdealRemoveOptions } from './types.js';
|
|
2
2
|
export type RemoveNodesOptions = BuildIdealFromGraphOptions & BuildIdealRemoveOptions;
|
|
3
3
|
/**
|
|
4
4
|
* Remove nodes from the current `graph`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-nodes.d.ts","sourceRoot":"","sources":["../../../src/ideal/remove-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,
|
|
1
|
+
{"version":3,"file":"remove-nodes.d.ts","sourceRoot":"","sources":["../../../src/ideal/remove-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC7B,MAAM,YAAY,CAAA;AAGnB,MAAM,MAAM,kBAAkB,GAAG,0BAA0B,GACzD,uBAAuB,CAAA;AAEzB;;GAEG;AACH,eAAO,MAAM,WAAW,uBAGrB,kBAAkB,SAapB,CAAA"}
|
|
@@ -1 +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"]}
|
|
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 type BuildIdealFromGraphOptions,\n type 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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BuildIdealAddOptions, BuildIdealFromGraphOptions } from './types.js';
|
|
1
|
+
import { type BuildIdealAddOptions, type BuildIdealFromGraphOptions } from './types.js';
|
|
2
2
|
export type RemoveSatisfiedSpecsOptions = BuildIdealAddOptions & BuildIdealFromGraphOptions;
|
|
3
3
|
/**
|
|
4
4
|
* Traverse the objects defined in `add` and removes any references to specs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-satisfied-specs.d.ts","sourceRoot":"","sources":["../../../src/ideal/remove-satisfied-specs.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,
|
|
1
|
+
{"version":3,"file":"remove-satisfied-specs.d.ts","sourceRoot":"","sources":["../../../src/ideal/remove-satisfied-specs.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAChC,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,2BAA2B,GAAG,oBAAoB,GAC5D,0BAA0B,CAAA;AAE5B;;;GAGG;AACH,eAAO,MAAM,oBAAoB,oBAG9B,2BAA2B,SAqC7B,CAAA"}
|
|
@@ -1 +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"]}
|
|
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 type BuildIdealAddOptions,\n type 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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AddImportersDependenciesMap, RemoveImportersDependenciesMap } from '../dependencies.js';
|
|
2
|
-
import { Graph } from '../graph.js';
|
|
3
|
-
import { PackageInfoClient } from '@vltpkg/package-info';
|
|
1
|
+
import { type AddImportersDependenciesMap, type RemoveImportersDependenciesMap } from '../dependencies.js';
|
|
2
|
+
import { type Graph } from '../graph.js';
|
|
3
|
+
import { type PackageInfoClient } from '@vltpkg/package-info';
|
|
4
4
|
export type BuildIdealAddOptions = {
|
|
5
5
|
/**
|
|
6
6
|
* A {@link AddImportersDependenciesMap} in which keys are {@link DepID}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ideal/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/ideal/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,8BAA8B,EAEpC,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAG7D,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"}
|
|
@@ -1 +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"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/ideal/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n type AddImportersDependenciesMap,\n type RemoveImportersDependenciesMap,\n Dependency,\n} from '../dependencies.js'\nimport { type Graph } from '../graph.js'\nimport { type PackageInfoClient } from '@vltpkg/package-info'\nimport { type DepID } from '@vltpkg/dep-id'\n\nexport type BuildIdealAddOptions = {\n /**\n * A {@link AddImportersDependenciesMap} in which keys are {@link DepID}\n * linking to another `Map` in which keys are the dependency names and values\n * are {@link Dependency}. This structure represents dependencies that need\n * to be added to the importer represented by {@link DepID}.\n */\n add: AddImportersDependenciesMap\n}\n\nexport type BuildIdealRemoveOptions = {\n /**\n * A {@link RemoveImportersDependenciesMap} object representing nodes to be\n * removed from the ideal graph. Each {@link DepID} key represents an\n * importer node and the `Set` of dependency names to be removed from its\n * dependency list.\n */\n remove: RemoveImportersDependenciesMap\n}\n\nexport type BuildIdealFromGraphOptions = {\n /**\n * An initial {@link Graph} to start building from, adding nodes to any\n * missing edges and appending any new specs defined in `addSpecs`.\n */\n graph: Graph\n}\n\nexport type BuildIdealPackageInfoOptions = {\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n}\n"]}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -8,20 +8,20 @@ export * from './visualization/human-readable-output.js';
|
|
|
8
8
|
export * from './visualization/mermaid-output.js';
|
|
9
9
|
export * from './stringify-node.js';
|
|
10
10
|
export * from './types.js';
|
|
11
|
+
import { type LoadOptions as ActualLoadOptions } from './actual/load.js';
|
|
11
12
|
export declare const actual: {
|
|
12
13
|
load: (options: ActualLoadOptions) => import("./graph.js").Graph;
|
|
13
14
|
};
|
|
15
|
+
import { type LoadOptions as LockfileLoadOptions } from './lockfile/load.js';
|
|
14
16
|
export declare const lockfile: {
|
|
15
17
|
load: (options: LockfileLoadOptions) => import("./graph.js").Graph;
|
|
16
18
|
loadEdges: (graph: import("./types.js").GraphLike, edges: import("./lockfile/types.js").LockfileData["edges"], options: import("@vltpkg/spec").SpecOptions) => void;
|
|
17
19
|
loadNodes: (graph: import("./types.js").GraphLike, nodes: import("./lockfile/types.js").LockfileData["nodes"]) => void;
|
|
18
20
|
save: (options: import("./lockfile/save.js").SaveOptions) => void;
|
|
19
21
|
};
|
|
20
|
-
import type { LoadOptions as ActualLoadOptions } from './actual/load.js';
|
|
21
|
-
import type { LoadOptions as LockfileLoadOptions } from './lockfile/load.js';
|
|
22
22
|
export type { ActualLoadOptions, LockfileLoadOptions };
|
|
23
23
|
export type { SaveOptions } from './lockfile/save.js';
|
|
24
|
-
import { BuildIdealOptions } from './ideal/build.js';
|
|
24
|
+
import { type BuildIdealOptions } from './ideal/build.js';
|
|
25
25
|
export type { BuildIdealOptions };
|
|
26
26
|
export declare const ideal: {
|
|
27
27
|
build: (options: BuildIdealOptions) => Promise<import("./graph.js").Graph>;
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0CAA0C,CAAA;AACxD,cAAc,mCAAmC,CAAA;AACjD,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;
|
|
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;AAE1B,OAAO,EAEL,KAAK,WAAW,IAAI,iBAAiB,EACtC,MAAM,kBAAkB,CAAA;AACzB,eAAO,MAAM,MAAM;;CAAuB,CAAA;AAE1C,OAAO,EAEL,KAAK,WAAW,IAAI,mBAAmB,EACxC,MAAM,oBAAoB,CAAA;AAI3B,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAA;AAED,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,EAAE,KAAK,iBAAiB,EAAS,MAAM,kBAAkB,CAAA;AAChE,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"}
|
package/dist/esm/index.js
CHANGED
|
@@ -8,9 +8,9 @@ export * from './visualization/human-readable-output.js';
|
|
|
8
8
|
export * from './visualization/mermaid-output.js';
|
|
9
9
|
export * from './stringify-node.js';
|
|
10
10
|
export * from './types.js';
|
|
11
|
-
import { load as actualLoad } from './actual/load.js';
|
|
11
|
+
import { load as actualLoad, } from './actual/load.js';
|
|
12
12
|
export const actual = { load: actualLoad };
|
|
13
|
-
import { load as lockfileLoad } from './lockfile/load.js';
|
|
13
|
+
import { load as lockfileLoad, } from './lockfile/load.js';
|
|
14
14
|
import { loadEdges } from './lockfile/load-edges.js';
|
|
15
15
|
import { loadNodes } from './lockfile/load-nodes.js';
|
|
16
16
|
import { save } from './lockfile/save.js';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,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,
|
|
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,EACL,IAAI,IAAI,UAAU,GAEnB,MAAM,kBAAkB,CAAA;AACzB,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;AAE1C,OAAO,EACL,IAAI,IAAI,YAAY,GAErB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AACzC,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,YAAY;IAClB,SAAS;IACT,SAAS;IACT,IAAI;CACL,CAAA;AAKD,OAAO,EAA0B,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAEhE,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 {\n load as actualLoad,\n type LoadOptions as ActualLoadOptions,\n} from './actual/load.js'\nexport const actual = { load: actualLoad }\n\nimport {\n load as lockfileLoad,\n type LoadOptions as LockfileLoadOptions,\n} 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\nexport type { ActualLoadOptions, LockfileLoadOptions }\nexport type { SaveOptions } from './lockfile/save.js'\n\nimport { type 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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type SpecOptions } from '@vltpkg/spec/browser';
|
|
2
|
-
import type
|
|
3
|
-
import { LockfileData } from './types.js';
|
|
2
|
+
import { type GraphLike } from '../types.js';
|
|
3
|
+
import { type LockfileData } from './types.js';
|
|
4
4
|
export declare const loadEdges: (graph: GraphLike, edges: LockfileData["edges"], options: SpecOptions) => void;
|
|
5
5
|
//# sourceMappingURL=load-edges.d.ts.map
|
|
@@ -1 +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,
|
|
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,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,YAAY,CAAA;AAEnB,eAAO,MAAM,SAAS,UACb,SAAS,SACT,YAAY,CAAC,OAAO,CAAC,WACnB,WAAW,SA0CrB,CAAA"}
|
|
@@ -1 +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,EAA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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
|
|
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,G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AI,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 type LockfileData,\n type LockfileEdgeKey,\n type 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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type LockfileData } from './types.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type GraphLike } from '../types.js';
|
|
3
3
|
export declare const loadNodes: (graph: GraphLike, nodes: LockfileData["nodes"]) => void;
|
|
4
4
|
//# sourceMappingURL=load-nodes.d.ts.map
|
|
@@ -1 +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,
|
|
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,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAA;AAE5C,eAAO,MAAM,SAAS,UACb,SAAS,SACT,YAAY,CAAC,OAAO,CAAC,SAkC7B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-nodes.js","sourceRoot":"","sources":["../../../src/lockfile/load-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAEL,sBAAsB,GAEvB,MAAM,YAAY,CAAA;AAInB,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAgB,EAChB,KAA4B,EAC5B,EAAE;I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xC,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
|
|
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"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PackageJson } from '@vltpkg/package-json';
|
|
2
|
-
import { Manifest } from '@vltpkg/types';
|
|
2
|
+
import { type Manifest } from '@vltpkg/types';
|
|
3
3
|
import { Monorepo } from '@vltpkg/workspaces';
|
|
4
|
-
import type
|
|
5
|
-
import { PathScurry } from 'path-scurry';
|
|
4
|
+
import { type SpecOptions } from '@vltpkg/spec';
|
|
5
|
+
import { type PathScurry } from 'path-scurry';
|
|
6
6
|
import { Graph } from '../graph.js';
|
|
7
|
-
import type
|
|
7
|
+
import { type LockfileData } from './types.js';
|
|
8
8
|
export type LoadOptions = SpecOptions & {
|
|
9
9
|
/**
|
|
10
10
|
* The project root dirname.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/lockfile/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;
|
|
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,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AAG/C,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,KAAK,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;AASD,eAAO,MAAM,IAAI,YAAa,WAAW,KAAG,KAM3C,CAAA;AAED,eAAO,MAAM,UAAU,YAAa,WAAW,KAAG,KAMjD,CAAA;AAED,eAAO,MAAM,UAAU,YACZ,WAAW,gBACN,YAAY,UA4C3B,CAAA"}
|
|
@@ -5,15 +5,16 @@ import { resolve } from 'node:path';
|
|
|
5
5
|
import { loadEdges } from './load-edges.js';
|
|
6
6
|
import { loadNodes } from './load-nodes.js';
|
|
7
7
|
import { Graph } from '../graph.js';
|
|
8
|
+
const loadLockfile = (projectRoot, lockfilePath) => JSON.parse(readFileSync(resolve(projectRoot, lockfilePath), {
|
|
9
|
+
encoding: 'utf8',
|
|
10
|
+
}));
|
|
8
11
|
export const load = (options) => {
|
|
9
12
|
const { projectRoot } = options;
|
|
10
|
-
return loadObject(options,
|
|
11
|
-
encoding: 'utf8',
|
|
12
|
-
})));
|
|
13
|
+
return loadObject(options, loadLockfile(projectRoot, 'vlt-lock.json'));
|
|
13
14
|
};
|
|
14
15
|
export const loadHidden = (options) => {
|
|
15
16
|
const { projectRoot } = options;
|
|
16
|
-
return loadObject(options,
|
|
17
|
+
return loadObject(options, loadLockfile(projectRoot, 'node_modules/.vlt-lock.json'));
|
|
17
18
|
};
|
|
18
19
|
export const loadObject = (options, lockfileData) => {
|
|
19
20
|
const { mainManifest, scurry } = options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/lockfile/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,SAAS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AC,CAAA;IAEnD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { PackageJson } from '@vltpkg/package-json'\nimport { type Manifest } from '@vltpkg/types'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { type SpecOptions } from '@vltpkg/spec'\nimport { readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { type PathScurry } from 'path-scurry'\nimport { loadEdges } from './load-edges.js'\nimport { loadNodes } from './load-nodes.js'\nimport { Graph } from '../graph.js'\nimport { type LockfileData } from './types.js'\n\nexport type LoadOptions = SpecOptions & {\n /**\n * The project root dirname.\n */\n projectRoot: string\n /**\n * The project root manifest.\n */\n mainManifest: Manifest\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * A {@link PackageJson} object, for sharing manifest caches\n */\n packageJson?: PackageJson\n /**\n * A {@link PathScurry} object, for use in globs\n */\n scurry?: PathScurry\n}\n\nconst loadLockfile = (projectRoot: string, lockfilePath: string) =>\n JSON.parse(\n readFileSync(resolve(projectRoot, lockfilePath), {\n encoding: 'utf8',\n }),\n ) as LockfileData\n\nexport const load = (options: LoadOptions): Graph => {\n const { projectRoot } = options\n return loadObject(\n options,\n loadLockfile(projectRoot, 'vlt-lock.json'),\n )\n}\n\nexport const loadHidden = (options: LoadOptions): Graph => {\n const { projectRoot } = options\n return loadObject(\n options,\n loadLockfile(projectRoot, 'node_modules/.vlt-lock.json'),\n )\n}\n\nexport const loadObject = (\n options: LoadOptions,\n lockfileData: LockfileData,\n) => {\n const { mainManifest, scurry } = options\n const packageJson = options.packageJson ?? new PackageJson()\n const monorepo =\n options.monorepo ??\n Monorepo.maybeLoad(options.projectRoot, { packageJson, scurry })\n const {\n 'scope-registries': scopeRegistries,\n registry,\n registries,\n 'git-hosts': gitHosts,\n 'git-host-archives': gitHostArchives,\n } = lockfileData.options\n const mergedOptions = {\n ...options,\n 'scope-registries': {\n ...options['scope-registries'],\n ...scopeRegistries,\n },\n registry: registry ?? options.registry,\n registries: {\n ...options.registries,\n ...registries,\n },\n 'git-hosts': {\n ...options['git-hosts'],\n ...gitHosts,\n },\n 'git-host-archives': {\n ...options['git-host-archives'],\n ...gitHostArchives,\n },\n }\n const graph = new Graph({\n ...mergedOptions,\n mainManifest,\n monorepo,\n })\n\n loadNodes(graph, lockfileData.nodes)\n loadEdges(graph, lockfileData.edges, mergedOptions)\n\n return graph\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SpecOptions } from '@vltpkg/spec';
|
|
1
|
+
import { type SpecOptions } from '@vltpkg/spec';
|
|
2
2
|
import { type Graph } from '../graph.js';
|
|
3
|
-
import { LockfileData } from './types.js';
|
|
3
|
+
import { type LockfileData } from './types.js';
|
|
4
4
|
export type SaveOptions = SpecOptions & {
|
|
5
5
|
/**
|
|
6
6
|
* The graph to be stored in the lockfile.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../../../src/lockfile/save.ts"],"names":[],"mappings":"AACA,OAAO,EAML,WAAW,
|
|
1
|
+
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../../../src/lockfile/save.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,cAAc,CAAA;AAIrB,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAEL,KAAK,YAAY,EAKlB,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC;;OAEG;IACH,KAAK,EAAE,KAAK,CAAA;IACZ;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;AAgGD,eAAO,MAAM,YAAY,sJAQtB,WAAW,KAAG,YAwChB,CAAA;AAeD,eAAO,MAAM,QAAQ,SACb,YAAY,YACR,MAAM,kCAMjB,CAAA;AAED,eAAO,MAAM,IAAI,YAAa,WAAW,SAKxC,CAAA;AAED,eAAO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IAAI,GAAG,CAAC,OAAoB,EAAE,EAAE;IAC3C,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;IACzB,MAAM,IAAI,GAAG,YAAY,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAA;IAC/D,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,eAAe,CAAC,CAAA;IAC5D,OAAO,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;AACxC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAoB,EAAE,EAAE;IACjD,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;IACzB,MAAM,IAAI,GAAG,YAAY,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IAC9D,MAAM,QAAQ,GAAG,OAAO,CACtB,KAAK,CAAC,WAAW,EACjB,6BAA6B,CAC9B,CAAA;IACD,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACjD,OAAO,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;AACvC,CAAC,CAAA","sourcesContent":["import { DepID } from '@vltpkg/dep-id'\nimport {\n defaultRegistry,\n defaultRegistries,\n defaultGitHosts,\n defaultGitHostArchives,\n defaultScopeRegistries,\n SpecOptions,\n} from '@vltpkg/spec'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { type Edge } from '../edge.js'\nimport { type Graph } from '../graph.js'\nimport { type Node } from '../node.js'\nimport {\n getFlagNumFromNode,\n LockfileData,\n LockfileEdgeKey,\n LockfileEdges,\n LockfileEdgeValue,\n LockfileNode,\n} from './types.js'\n\nexport type SaveOptions = SpecOptions & {\n /**\n * The graph to be stored in the lockfile.\n */\n graph: Graph\n /**\n * Should it save manifest data in the lockfile?\n */\n saveManifests?: boolean\n}\n\nconst formatNodes = (\n nodes: Iterable<Node>,\n saveManifests?: boolean,\n registry?: string,\n) => {\n // we do not store importers in the lockfile, though we do store\n // their edges. when we load, we always read workspaces/main fresh.\n const arr: Node[] = [...nodes].filter(node => !node.importer)\n // nodes are sorted in order to have a deterministic result\n const orderedNodes: Node[] = arr.sort((a, b) =>\n a.id.localeCompare(b.id, 'en'),\n )\n\n const res: Record<DepID, LockfileNode> = {}\n for (const node of orderedNodes) {\n const customRegistry =\n node.resolved && registry && !node.resolved.startsWith(registry)\n const resolved = customRegistry ? node.resolved : undefined\n // if it's in a location other than the default, stash that\n const location =\n (\n node.id.startsWith('file') ||\n node.location.endsWith(\n '/node_modules/.vlt/' +\n node.id +\n '/node_modules/' +\n node.name,\n )\n ) ?\n undefined\n : node.location\n\n const flags = getFlagNumFromNode(node)\n const lockfileNode: LockfileNode = [flags, node.name]\n\n if (node.integrity) {\n lockfileNode[2] = node.integrity\n }\n\n if (resolved) {\n lockfileNode[3] = resolved\n }\n\n if (location) {\n lockfileNode[4] = location\n }\n\n if (saveManifests) {\n lockfileNode[5] = node.manifest\n }\n\n res[node.id] = lockfileNode\n }\n return res\n}\n\nconst formatEdges = (edges: Set<Edge>): LockfileEdges =>\n Object.fromEntries(\n [...edges]\n .sort(\n (a, b) =>\n /* c8 ignore start - nondeterminstic and annoying to test */\n // sort importers to the top, then alphabetically by\n // id, type, target\n Number(b.from.importer) - Number(a.from.importer) ||\n a.from.id.localeCompare(b.from.id, 'en') ||\n a.type.localeCompare(b.type, 'en') ||\n (a.to?.id ?? '').localeCompare(b.to?.id ?? ''),\n /* c8 ignore stop */\n )\n .map((edge): [LockfileEdgeKey, LockfileEdgeValue] => [\n `${edge.from.id} ${edge.spec.name}`,\n `${edge.type} ${edge.spec.bareSpec || '*'} ${edge.to?.id ?? 'MISSING'}`,\n ]),\n )\n\nconst isRecordStringString = (\n registries: unknown,\n): registries is Record<string, string> =>\n !(!registries || typeof registries === 'string')\n\nconst removeDefaultItems = (\n defaultItems: Record<string, string>,\n items: Record<string, string>,\n) => {\n const res: Record<string, string> = {}\n for (const [key, value] of Object.entries(items)) {\n if (!defaultItems[key] || defaultItems[key] !== value) {\n res[key] = value\n }\n }\n return res\n}\n\nexport const lockfileData = ({\n graph,\n 'git-hosts': gitHosts,\n 'git-host-archives': gitHostArchives,\n registry,\n registries,\n saveManifests,\n 'scope-registries': scopeRegistries,\n}: SaveOptions): LockfileData => {\n const cleanGitHosts =\n isRecordStringString(gitHosts) ?\n removeDefaultItems(defaultGitHosts, gitHosts)\n : undefined\n const cleanGitHostArchives =\n isRecordStringString(gitHostArchives) ?\n removeDefaultItems(defaultGitHostArchives, gitHostArchives)\n : undefined\n const cleanRegistries =\n isRecordStringString(registries) ?\n removeDefaultItems(defaultRegistries, registries)\n : undefined\n const cleanScopeRegistries =\n isRecordStringString(scopeRegistries) ?\n removeDefaultItems(defaultScopeRegistries, scopeRegistries)\n : undefined\n const hasItems = (clean: Record<string, string> | undefined) =>\n clean && Object.keys(clean).length\n return {\n options: {\n ...(hasItems(cleanScopeRegistries) ?\n { 'scope-registries': cleanScopeRegistries }\n : undefined),\n ...(registry !== undefined && registry !== defaultRegistry ?\n { registry }\n : undefined),\n ...(hasItems(registries) ?\n { registries: cleanRegistries }\n : undefined),\n ...(hasItems(cleanGitHosts) ?\n { 'git-hosts': cleanGitHosts }\n : undefined),\n ...(hasItems(cleanGitHostArchives) ?\n { 'git-host-archives': cleanGitHostArchives }\n : undefined),\n },\n nodes: formatNodes(graph.nodes.values(), saveManifests, registry),\n edges: formatEdges(graph.edges),\n }\n}\n\n// renders each node / edge as a single line entry\nconst extraFormat = (jsonString: string) => {\n const str = `${jsonString}\\n`\n const [init, ...parts] = str.split(' \"nodes\": {')\n const res = [init]\n for (const part of parts) {\n res.push(\n part.replaceAll('\\n ', '').replaceAll('\\n ]', ']'),\n )\n }\n return res.join(' \"nodes\": {')\n}\n\nexport const saveData = (\n data: LockfileData,\n fileName: string,\n saveManifests = false,\n) => {\n const json = JSON.stringify(data, null, 2)\n const content = saveManifests ? json : extraFormat(json)\n writeFileSync(fileName, content)\n}\n\nexport const save = (options: SaveOptions) => {\n const { graph } = options\n const data = lockfileData({ ...options, saveManifests: false })\n const fileName = resolve(graph.projectRoot, 'vlt-lock.json')\n return saveData(data, fileName, false)\n}\n\nexport const saveHidden = (options: SaveOptions) => {\n const { graph } = options\n const data = lockfileData({ ...options, saveManifests: true })\n const fileName = resolve(\n graph.projectRoot,\n 'node_modules/.vlt-lock.json',\n )\n mkdirSync(dirname(fileName), { recursive: true })\n return saveData(data, fileName, true)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"save.js","sourceRoot":"","sources":["../../../src/lockfile/save.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,GAEvB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAI5C,OAAO,EACL,kBAAkB,GAMnB,MAAM,YAAY,CAAA;AAanB,MAAM,WAAW,GAAG,CAClB,KAAqB,EACrB,aAAuB,EACvB,QAAiB,EACjB,EAAE;IACF,gEAAgE;IAChE,mEAAmE;IACnE,MAAM,GAAG,GAAW,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC7D,2DAA2D;IAC3D,MAAM,YAAY,GAAW,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAC7C,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,CAC/B,CAAA;IAED,MAAM,GAAG,GAAgC,EAAE,C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ry,\n defaultRegistries,\n defaultGitHosts,\n defaultGitHostArchives,\n defaultScopeRegistries,\n type SpecOptions,\n} from '@vltpkg/spec'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { type Edge } from '../edge.js'\nimport { type Graph } from '../graph.js'\nimport { type Node } from '../node.js'\nimport {\n getFlagNumFromNode,\n type LockfileData,\n type LockfileEdgeKey,\n type LockfileEdges,\n type LockfileEdgeValue,\n type LockfileNode,\n} from './types.js'\n\nexport type SaveOptions = SpecOptions & {\n /**\n * The graph to be stored in the lockfile.\n */\n graph: Graph\n /**\n * Should it save manifest data in the lockfile?\n */\n saveManifests?: boolean\n}\n\nconst formatNodes = (\n nodes: Iterable<Node>,\n saveManifests?: boolean,\n registry?: string,\n) => {\n // we do not store importers in the lockfile, though we do store\n // their edges. when we load, we always read workspaces/main fresh.\n const arr: Node[] = [...nodes].filter(node => !node.importer)\n // nodes are sorted in order to have a deterministic result\n const orderedNodes: Node[] = arr.sort((a, b) =>\n a.id.localeCompare(b.id, 'en'),\n )\n\n const res: Record<DepID, LockfileNode> = {}\n for (const node of orderedNodes) {\n const customRegistry =\n node.resolved && registry && !node.resolved.startsWith(registry)\n const resolved = customRegistry ? node.resolved : undefined\n // if it's in a location other than the default, stash that\n const location =\n (\n node.id.startsWith('file') ||\n node.location.endsWith(\n '/node_modules/.vlt/' +\n node.id +\n '/node_modules/' +\n node.name,\n )\n ) ?\n undefined\n : node.location\n\n const flags = getFlagNumFromNode(node)\n const lockfileNode: LockfileNode = [flags, node.name]\n\n if (node.integrity) {\n lockfileNode[2] = node.integrity\n }\n\n if (resolved) {\n lockfileNode[3] = resolved\n }\n\n if (location) {\n lockfileNode[4] = location\n }\n\n if (saveManifests) {\n lockfileNode[5] = node.manifest\n }\n\n res[node.id] = lockfileNode\n }\n return res\n}\n\nconst formatEdges = (edges: Set<Edge>): LockfileEdges =>\n Object.fromEntries(\n [...edges]\n .sort(\n (a, b) =>\n /* c8 ignore start - nondeterminstic and annoying to test */\n // sort importers to the top, then alphabetically by\n // id, type, target\n Number(b.from.importer) - Number(a.from.importer) ||\n a.from.id.localeCompare(b.from.id, 'en') ||\n a.type.localeCompare(b.type, 'en') ||\n (a.to?.id ?? '').localeCompare(b.to?.id ?? ''),\n /* c8 ignore stop */\n )\n .map((edge): [LockfileEdgeKey, LockfileEdgeValue] => [\n `${edge.from.id} ${edge.spec.name}`,\n `${edge.type} ${edge.spec.bareSpec || '*'} ${edge.to?.id ?? 'MISSING'}`,\n ]),\n )\n\nconst isRecordStringString = (\n registries: unknown,\n): registries is Record<string, string> =>\n !(!registries || typeof registries === 'string')\n\nconst removeDefaultItems = (\n defaultItems: Record<string, string>,\n items: Record<string, string>,\n) => {\n const res: Record<string, string> = {}\n for (const [key, value] of Object.entries(items)) {\n if (!defaultItems[key] || defaultItems[key] !== value) {\n res[key] = value\n }\n }\n return res\n}\n\nexport const lockfileData = ({\n graph,\n 'git-hosts': gitHosts,\n 'git-host-archives': gitHostArchives,\n registry,\n registries,\n saveManifests,\n 'scope-registries': scopeRegistries,\n}: SaveOptions): LockfileData => {\n const cleanGitHosts =\n isRecordStringString(gitHosts) ?\n removeDefaultItems(defaultGitHosts, gitHosts)\n : undefined\n const cleanGitHostArchives =\n isRecordStringString(gitHostArchives) ?\n removeDefaultItems(defaultGitHostArchives, gitHostArchives)\n : undefined\n const cleanRegistries =\n isRecordStringString(registries) ?\n removeDefaultItems(defaultRegistries, registries)\n : undefined\n const cleanScopeRegistries =\n isRecordStringString(scopeRegistries) ?\n removeDefaultItems(defaultScopeRegistries, scopeRegistries)\n : undefined\n const hasItems = (clean: Record<string, string> | undefined) =>\n clean && Object.keys(clean).length\n return {\n options: {\n ...(hasItems(cleanScopeRegistries) ?\n { 'scope-registries': cleanScopeRegistries }\n : undefined),\n ...(registry !== undefined && registry !== defaultRegistry ?\n { registry }\n : undefined),\n ...(hasItems(registries) ?\n { registries: cleanRegistries }\n : undefined),\n ...(hasItems(cleanGitHosts) ?\n { 'git-hosts': cleanGitHosts }\n : undefined),\n ...(hasItems(cleanGitHostArchives) ?\n { 'git-host-archives': cleanGitHostArchives }\n : undefined),\n },\n nodes: formatNodes(graph.nodes.values(), saveManifests, registry),\n edges: formatEdges(graph.edges),\n }\n}\n\n// renders each node / edge as a single line entry\nconst extraFormat = (jsonString: string) => {\n const str = `${jsonString}\\n`\n const [init, ...parts] = str.split(' \"nodes\": {')\n const res = [init]\n for (const part of parts) {\n res.push(\n part.replaceAll('\\n ', '').replaceAll('\\n ]', ']'),\n )\n }\n return res.join(' \"nodes\": {')\n}\n\nexport const saveData = (\n data: LockfileData,\n fileName: string,\n saveManifests = false,\n) => {\n const json = JSON.stringify(data, null, 2)\n const content = saveManifests ? json : extraFormat(json)\n writeFileSync(fileName, content)\n}\n\nexport const save = (options: SaveOptions) => {\n const { graph } = options\n const data = lockfileData({ ...options, saveManifests: false })\n const fileName = resolve(graph.projectRoot, 'vlt-lock.json')\n return saveData(data, fileName, false)\n}\n\nexport const saveHidden = (options: SaveOptions) => {\n const { graph } = options\n const data = lockfileData({ ...options, saveManifests: true })\n const fileName = resolve(\n graph.projectRoot,\n 'node_modules/.vlt-lock.json',\n )\n mkdirSync(dirname(fileName), { recursive: true })\n return saveData(data, fileName, true)\n}\n"]}
|