@vltpkg/graph 0.0.0-0.1730724342581 → 0.0.0-3
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/dist/esm/actual/load.d.ts +6 -6
- package/dist/esm/actual/load.d.ts.map +1 -1
- package/dist/esm/actual/load.js +8 -4
- package/dist/esm/actual/load.js.map +1 -1
- package/dist/esm/browser.d.ts +8 -6
- package/dist/esm/browser.d.ts.map +1 -1
- package/dist/esm/browser.js +8 -6
- package/dist/esm/browser.js.map +1 -1
- package/dist/esm/dependencies.d.ts +15 -27
- package/dist/esm/dependencies.d.ts.map +1 -1
- package/dist/esm/dependencies.js +1 -30
- 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 +10 -10
- 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 +2 -2
- package/dist/esm/ideal/add-nodes.js.map +1 -1
- package/dist/esm/ideal/append-nodes.d.ts +8 -8
- package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/append-nodes.js +37 -15
- 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 +28 -5
- 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 +8 -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 +39 -11
- 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 +25 -22
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +20 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/install.d.ts +13 -0
- package/dist/esm/install.d.ts.map +1 -0
- package/dist/esm/install.js +29 -0
- package/dist/esm/install.js.map +1 -0
- package/dist/esm/lockfile/load-edges.d.ts +3 -3
- package/dist/esm/lockfile/load-edges.d.ts.map +1 -1
- package/dist/esm/lockfile/load-edges.js +2 -1
- package/dist/esm/lockfile/load-edges.js.map +1 -1
- package/dist/esm/lockfile/load-nodes.d.ts +2 -2
- package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
- package/dist/esm/lockfile/load-nodes.js +3 -1
- package/dist/esm/lockfile/load-nodes.js.map +1 -1
- package/dist/esm/lockfile/load.d.ts +5 -5
- package/dist/esm/lockfile/load.d.ts.map +1 -1
- package/dist/esm/lockfile/load.js +6 -4
- package/dist/esm/lockfile/load.js.map +1 -1
- package/dist/esm/lockfile/save.d.ts +3 -3
- package/dist/esm/lockfile/save.d.ts.map +1 -1
- package/dist/esm/lockfile/save.js +1 -1
- package/dist/esm/lockfile/save.js.map +1 -1
- package/dist/esm/lockfile/types.d.ts +3 -4
- 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 +19 -15
- package/dist/esm/node.d.ts.map +1 -1
- package/dist/esm/node.js +23 -17
- 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 +4 -4
- 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 +2 -2
- 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 +10 -7
- 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 +7 -7
- 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 +2 -2
- 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 +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 +6 -5
- package/dist/esm/reify/index.d.ts.map +1 -1
- package/dist/esm/reify/index.js +25 -19
- 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 +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 +1 -1
- package/dist/esm/reify/rollback.js.map +1 -1
- package/dist/esm/reify/update-importers-package-json.d.ts +3 -3
- package/dist/esm/reify/update-importers-package-json.d.ts.map +1 -1
- package/dist/esm/reify/update-importers-package-json.js +5 -3
- 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 +5 -4
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/uninstall.d.ts +13 -0
- package/dist/esm/uninstall.d.ts.map +1 -0
- package/dist/esm/uninstall.js +29 -0
- package/dist/esm/uninstall.js.map +1 -0
- package/dist/esm/visualization/human-readable-output.d.ts +7 -6
- package/dist/esm/visualization/human-readable-output.d.ts.map +1 -1
- package/dist/esm/visualization/human-readable-output.js +2 -2
- package/dist/esm/visualization/human-readable-output.js.map +1 -1
- package/dist/esm/visualization/json-output.d.ts +4 -4
- package/dist/esm/visualization/json-output.d.ts.map +1 -1
- package/dist/esm/visualization/json-output.js +1 -1
- package/dist/esm/visualization/json-output.js.map +1 -1
- package/dist/esm/visualization/mermaid-output.d.ts +3 -3
- package/dist/esm/visualization/mermaid-output.d.ts.map +1 -1
- package/dist/esm/visualization/mermaid-output.js +2 -2
- 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.map +1 -1
- package/package.json +34 -26
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { Graph } from '../graph.
|
|
1
|
+
import type { PackageJson } from '@vltpkg/package-json';
|
|
2
|
+
import type { SpecOptions } from '@vltpkg/spec';
|
|
3
|
+
import type { Manifest } from '@vltpkg/types';
|
|
4
|
+
import type { Monorepo } from '@vltpkg/workspaces';
|
|
5
|
+
import type { Path, PathScurry } from 'path-scurry';
|
|
6
|
+
import { Graph } from '../graph.ts';
|
|
7
7
|
export type LoadOptions = SpecOptions & {
|
|
8
8
|
/**
|
|
9
9
|
* The project root dirname.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/actual/load.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/actual/load.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGnD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAKnC,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAA;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB;;OAEG;IACH,WAAW,EAAE,WAAW,CAAA;IACxB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAA;IAClB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,IAAI,CAAA;CACf,CAAA;AA6QD;;;;GAIG;AACH,eAAO,MAAM,IAAI,YAAa,WAAW,KAAG,KAwD3C,CAAA"}
|
package/dist/esm/actual/load.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { asDepID, hydrate, joinDepIDTuple
|
|
1
|
+
import { asDepID, hydrate, joinDepIDTuple } from '@vltpkg/dep-id';
|
|
2
2
|
import { Spec } from '@vltpkg/spec';
|
|
3
|
-
import { longDependencyTypes
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { longDependencyTypes } from '@vltpkg/types';
|
|
4
|
+
import { shorten } from "../dependencies.js";
|
|
5
|
+
import { Graph } from "../graph.js";
|
|
6
|
+
import { loadHidden } from "../lockfile/load.js";
|
|
7
|
+
import { graphStep } from '@vltpkg/output';
|
|
6
8
|
const pathBasedType = new Set(['file', 'workspace']);
|
|
7
9
|
const isPathBasedType = (type) => pathBasedType.has(type);
|
|
8
10
|
const getPathBasedId = (spec, path) => isPathBasedType(spec.type) ?
|
|
@@ -209,6 +211,7 @@ const parseDir = (options, scurry, packageJson, depsFound, graph, fromNode, curr
|
|
|
209
211
|
* between the dependencies found.
|
|
210
212
|
*/
|
|
211
213
|
export const load = (options) => {
|
|
214
|
+
const done = graphStep('actual');
|
|
212
215
|
// TODO: once hidden lockfile is more reliable, default to false here
|
|
213
216
|
const { skipHiddenLockfile = true, projectRoot, packageJson, scurry, monorepo, } = options;
|
|
214
217
|
const mainManifest = options.mainManifest ?? packageJson.read(projectRoot);
|
|
@@ -238,6 +241,7 @@ export const load = (options) => {
|
|
|
238
241
|
for (const [node, path] of depsFound.entries()) {
|
|
239
242
|
parseDir(options, scurry, packageJson, depsFound, graph, node, path);
|
|
240
243
|
}
|
|
244
|
+
done();
|
|
241
245
|
return graph;
|
|
242
246
|
};
|
|
243
247
|
//# sourceMappingURL=load.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/actual/load.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,OAAO,EACP,cAAc,GACf,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,IAAI,EAAoB,MAAM,cAAc,CAAA;AAIrD,OAAO,EACL,mBAAmB,EAEnB,OAAO,GACR,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AA8ChD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA;AACpD,MAAM,eAAe,GAAG,CACtB,IAAY,EACkB,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AAC1D,MAAM,cAAc,GAAG,CACrB,IAAU,EACV,IAAY,EACO,EAAE,CACrB,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1B,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,SAAS,CAAA;AAEb;;GAEG;AACH,MAAM,SAAS,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAQ,EAAqB,EAAE,CAC9D,MAAM,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CA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GAAG,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,eAAe,CAAC,CACxD,CAAA;IACH,CAAC;IAED,qEAAqE;IACrE,sEAAsE;IACtE,0DAA0D;IAC1D,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;QAC/C,QAAQ,CACN,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,KAAK,EACL,IAAI,EACJ,IAAI,CACL,CAAA;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import {\n asDepID,\n type DepID,\n hydrate,\n joinDepIDTuple,\n} from '@vltpkg/dep-id'\nimport { type PackageJson } from '@vltpkg/package-json'\nimport { Spec, type SpecOptions } from '@vltpkg/spec'\nimport { type Manifest } from '@vltpkg/types'\nimport { type Monorepo } from '@vltpkg/workspaces'\nimport { type Path, type PathScurry } from 'path-scurry'\nimport {\n longDependencyTypes,\n type RawDependency,\n shorten,\n} from '../dependencies.js'\nimport { Graph } from '../graph.js'\nimport { loadHidden } from '../lockfile/load.js'\nimport { type Node } from '../node.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 * If set to `false`, `actual.load` will not load any `package.json`\n * files while traversing the file system.\n *\n * The resulting {@link Graph} from loading with `loadManifests=false`\n * has no information on dependency types or the specs defined and\n * no information on missing and extraneous dependencies.\n */\n loadManifests?: boolean\n /**\n * If set to `true`, then do not shortcut the process by reading the\n * hidden lockfile at `node_modules/.vlt-lock.json`\n */\n skipHiddenLockfile?: boolean\n}\n\nexport type ReadEntry = {\n alias: string\n name: string\n realpath: Path\n}\n\nconst pathBasedType = new Set(['file', 'workspace'])\nconst isPathBasedType = (\n type: string,\n): type is 'file' | 'workspace' => pathBasedType.has(type)\nconst getPathBasedId = (\n spec: Spec,\n path: string,\n): DepID | undefined =>\n isPathBasedType(spec.type) ?\n joinDepIDTuple([spec.type, path])\n : undefined\n\n/**\n * Retrieve the {@link DepID} for a given package from its location.\n */\nconst findDepID = ({ parent, name }: Path): DepID | undefined =>\n parent?.name === '.vlt' ? asDepID(name)\n : parent?.isCWD === false ? findDepID(parent)\n : undefined\n\n/**\n * Retrieves the closest `node_modules` parent {@link Path} found.\n */\nconst findNodeModules = ({\n parent,\n name,\n isCWD,\n}: Path): Path | undefined =>\n parent?.name === 'node_modules' ? parent\n : parent && name !== '.vlt' && !isCWD ? findNodeModules(parent)\n : undefined\n\n/**\n * Retrieves the scoped-normalized package name from its {@link Path}.\n */\nconst findName = ({ parent, name }: Path): string =>\n parent?.name.startsWith('@') ? `${parent.name}/${name}` : name\n\nconst isStringArray = (a: unknown): a is string[] =>\n Array.isArray(a) && !a.some(b => typeof b !== 'string')\n\n/*\n * Retrieves a map of all dependencies, of all types, that can be iterated\n * on and consulted when parsing the directory contents of the current node.\n */\nconst getDeps = (node: Node) => {\n const dependencies = new Map<string, RawDependency>()\n const bundleDeps: unknown = node.manifest?.bundleDependencies ?? []\n // if it's an importer, bundleDeps are just normal. if it's a dep,\n // then they're ignored entirely.\n const bundled =\n (\n !node.importer &&\n !node.id.startsWith('git') &&\n isStringArray(bundleDeps)\n ) ?\n new Set(bundleDeps)\n : new Set<string>()\n for (const depType of longDependencyTypes) {\n const obj: Record<string, string> | undefined =\n node.manifest?.[depType]\n // only care about devDeps for importers and git or symlink deps\n // technically this will also include devDeps for tarball file: specs,\n // but that is likely rare enough to not worry about too much.\n if (\n depType === 'devDependencies' &&\n !node.importer &&\n !node.id.startsWith('git') &&\n !node.id.startsWith('file')\n ) {\n continue\n }\n if (obj) {\n for (const [name, bareSpec] of Object.entries(obj)) {\n // if it's a bundled dependency, we just ignore it entirely.\n if (bundled.has(name)) continue\n dependencies.set(name, {\n name,\n type: depType,\n bareSpec,\n registry: node.registry,\n })\n }\n }\n }\n return dependencies\n}\n\n/**\n * Reads the current directory defined at `currDir` and looks for folder\n * names and their realpath resolution, normalizing scoped package names\n * and removing any invalid symlinks from the list of items that should\n * be parsed through in order to build the graph.\n */\nconst readDir = (\n scurry: PathScurry,\n currDir: Path,\n fromNodeName?: string,\n) => {\n const res = new Set<ReadEntry>()\n for (const entry of scurry.readdirSync(currDir)) {\n // ignore any hidden files / folders\n if (entry.name.startsWith('.')) continue\n\n // scope folder found, it will need to be read and iterated over\n // in order to find any scoped packages inside\n if (entry.name.startsWith('@')) {\n const scopedItems = readDir(scurry, entry, fromNodeName)\n for (const scopedItem of scopedItems) {\n res.add(scopedItem)\n }\n continue\n }\n\n // skip anything that isn't a symlink, it's not an edge\n if (!entry.isSymbolicLink()) continue\n\n // we'll need to learn what is the real path for this entry in order\n // to retrieve the `location` and `id` properties for the node, if a\n // realpath is not found just move on to the next element\n const realpath = entry.realpathSync()\n if (!realpath) {\n continue\n }\n\n // infer both the alias and proper package names, including scopes\n const alias = findName(entry)\n const name = findName(realpath)\n res.add({\n alias,\n name,\n realpath,\n })\n }\n return res\n}\n\n/**\n * Parses the files located at `currDir` and place packages found inside\n * as dependencies of `fromNode`, building the instantiated `graph`.\n */\nconst parseDir = (\n options: LoadOptions,\n scurry: PathScurry,\n packageJson: PackageJson,\n depsFound: Map<Node, Path>,\n graph: Graph,\n fromNode: Node,\n currDir: Path,\n) => {\n const { loadManifests } = options\n const dependencies = getDeps(fromNode)\n const seenDeps = new Set<string>()\n const readItems: Set<ReadEntry> = readDir(\n scurry,\n currDir,\n fromNode.name,\n )\n\n for (const { alias, name, realpath } of readItems) {\n let node\n\n // tracks what dependencies have been seen\n // so that we can mark missing dependencies\n seenDeps.add(alias)\n\n // places the package in the graph reading\n // its manifest only if necessary\n if (!loadManifests) {\n const depId = findDepID(realpath)\n\n if (depId) {\n const h = hydrate(depId, alias, {\n ...options,\n registry: fromNode.registry,\n })\n\n // graphs build with no manifest have no notion of\n // dependency types and or spec definitions since those\n // would have to be parsed from a manifest\n node = graph.placePackage(\n fromNode,\n 'prod', // defaults to prod deps\n h, // uses spec from hydrated id\n {\n name,\n ...(h.registrySpec ?\n { version: h.registrySpec } // adds version if available\n : null),\n },\n depId,\n )\n }\n }\n\n // retrieve references to the current folder name found in `fromNode`\n // manifest listed dependencies, removing it from the map will leave\n // a list of missing dependencies at the end of the iteration\n const deps = dependencies.get(alias)\n\n // in case this graph is skipping manifests, this next block might\n // still need to execute, thus actually loading a manifest file, for\n // edge-cases such as loading a linked node that is not going to have\n // DepID info available in its realpath or extraneous nodes\n if (!node) {\n const mani = packageJson.read(realpath.fullpath())\n // declares fallback default values for both depType and bareSpec\n // in order to support loadManifests=false fallback for link nodes\n const type = deps?.type || 'dependencies'\n const bareSpec = deps?.bareSpec || '*'\n\n const depType = shorten(type, alias, fromNode.manifest)\n const spec = Spec.parse(alias, bareSpec, {\n ...options,\n registry: fromNode.registry,\n })\n const maybeId = getPathBasedId(spec, realpath.relativePosix())\n node = graph.placePackage(\n fromNode,\n depType,\n spec,\n mani,\n maybeId,\n )\n }\n\n if (node) {\n // If a found dependency is not declared in any of the original\n // node dependencies, then add an edge to the graph pointing to it\n // and mark it as extraneous.\n //\n // This only makes sense if full manifests are being loaded\n // so that we have reference to dependencies info.\n if (loadManifests && !deps) {\n const [edge] = node.edgesIn\n if (edge) {\n graph.extraneousDependencies.add(edge)\n }\n }\n\n // for a succesfully created node, add its location\n // property and queue up to read its dependencies\n node.location = `./${realpath.relativePosix()}`\n const node_modules = findNodeModules(realpath)\n\n // queue items up to continue parsing dirs in case a node was succesfully\n // placed in the graph and its node_modules folder was correctly found\n if (node_modules) {\n depsFound.set(node, node_modules)\n }\n }\n }\n\n // any remaining dependencies that have not been found\n // when reading the directory should be marked as missing\n for (const { name, type, bareSpec } of dependencies.values()) {\n if (!seenDeps.has(name)) {\n const depType = shorten(type, name, fromNode.manifest)\n const spec = Spec.parse(name, bareSpec, {\n ...options,\n registry: fromNode.registry,\n })\n graph.placePackage(fromNode, depType, spec)\n }\n }\n}\n\n/**\n * Read the file system looking for `node_modules` folders and\n * returns a new {@link Graph} that represents the relationship\n * between the dependencies found.\n */\nexport const load = (options: LoadOptions): Graph => {\n // TODO: once hidden lockfile is more reliable, default to false here\n const {\n skipHiddenLockfile = true,\n projectRoot,\n packageJson,\n scurry,\n monorepo,\n } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(projectRoot)\n\n if (!skipHiddenLockfile) {\n try {\n const graph = loadHidden({\n projectRoot,\n mainManifest,\n packageJson,\n monorepo,\n scurry,\n })\n // TODO: check mtime of lockfile vs .vlt folder\n return graph\n } catch {}\n }\n\n const graph = new Graph({ ...options, mainManifest })\n const depsFound = new Map<Node, Path>()\n\n // starts the list of initial folders to parse using the importer nodes\n for (const importer of graph.importers) {\n depsFound.set(\n importer,\n scurry.cwd.resolve(`${importer.location}/node_modules`),\n )\n }\n\n // breadth-first traversal of the file system tree reading deps found\n // starting from the node_modules folder of every importer in order to\n // find the actual installed dependencies at each location\n for (const [node, path] of depsFound.entries()) {\n parseDir(\n options,\n scurry,\n packageJson,\n depsFound,\n graph,\n node,\n path,\n )\n }\n\n return graph\n}\n"]}
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/actual/load.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAGjE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAInD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAq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AM,EACN,QAAQ,GACT,GAAG,OAAO,CAAA;IACX,MAAM,YAAY,GAChB,OAAO,CAAC,YAAY,IAAI,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAEvD,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,UAAU,CAAC;gBACvB,WAAW;gBACX,YAAY;gBACZ,WAAW;gBACX,QAAQ;gBACR,MAAM;aACP,CAAC,CAAA;YACF,+CAA+C;YAC/C,OAAO,KAAK,CAAA;QACd,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,YAAY,EAAE,CAAC,CAAA;IACrD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAA;IAEvC,uEAAuE;IACvE,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACvC,SAAS,CAAC,GAAG,CACX,QAAQ,EACR,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,QAAQ,eAAe,CAAC,CACxD,CAAA;IACH,CAAC;IAED,qEAAqE;IACrE,sEAAsE;IACtE,0DAA0D;IAC1D,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;QAC/C,QAAQ,CACN,OAAO,EACP,MAAM,EACN,WAAW,EACX,SAAS,EACT,KAAK,EACL,IAAI,EACJ,IAAI,CACL,CAAA;IACH,CAAC;IAED,IAAI,EAAE,CAAA;IAEN,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { asDepID, hydrate, joinDepIDTuple } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport { longDependencyTypes } from '@vltpkg/types'\nimport type { Manifest } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport type { Path, PathScurry } from 'path-scurry'\nimport { shorten } from '../dependencies.ts'\nimport type { RawDependency } from '../dependencies.ts'\nimport { Graph } from '../graph.ts'\nimport { loadHidden } from '../lockfile/load.ts'\nimport type { Node } from '../node.ts'\nimport { graphStep } from '@vltpkg/output'\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 * If set to `false`, `actual.load` will not load any `package.json`\n * files while traversing the file system.\n *\n * The resulting {@link Graph} from loading with `loadManifests=false`\n * has no information on dependency types or the specs defined and\n * no information on missing and extraneous dependencies.\n */\n loadManifests?: boolean\n /**\n * If set to `true`, then do not shortcut the process by reading the\n * hidden lockfile at `node_modules/.vlt-lock.json`\n */\n skipHiddenLockfile?: boolean\n}\n\nexport type ReadEntry = {\n alias: string\n name: string\n realpath: Path\n}\n\nconst pathBasedType = new Set(['file', 'workspace'])\nconst isPathBasedType = (\n type: string,\n): type is 'file' | 'workspace' => pathBasedType.has(type)\nconst getPathBasedId = (\n spec: Spec,\n path: string,\n): DepID | undefined =>\n isPathBasedType(spec.type) ?\n joinDepIDTuple([spec.type, path])\n : undefined\n\n/**\n * Retrieve the {@link DepID} for a given package from its location.\n */\nconst findDepID = ({ parent, name }: Path): DepID | undefined =>\n parent?.name === '.vlt' ? asDepID(name)\n : parent?.isCWD === false ? findDepID(parent)\n : undefined\n\n/**\n * Retrieves the closest `node_modules` parent {@link Path} found.\n */\nconst findNodeModules = ({\n parent,\n name,\n isCWD,\n}: Path): Path | undefined =>\n parent?.name === 'node_modules' ? parent\n : parent && name !== '.vlt' && !isCWD ? findNodeModules(parent)\n : undefined\n\n/**\n * Retrieves the scoped-normalized package name from its {@link Path}.\n */\nconst findName = ({ parent, name }: Path): string =>\n parent?.name.startsWith('@') ? `${parent.name}/${name}` : name\n\nconst isStringArray = (a: unknown): a is string[] =>\n Array.isArray(a) && !a.some(b => typeof b !== 'string')\n\n/*\n * Retrieves a map of all dependencies, of all types, that can be iterated\n * on and consulted when parsing the directory contents of the current node.\n */\nconst getDeps = (node: Node) => {\n const dependencies = new Map<string, RawDependency>()\n const bundleDeps: unknown = node.manifest?.bundleDependencies ?? []\n // if it's an importer, bundleDeps are just normal. if it's a dep,\n // then they're ignored entirely.\n const bundled =\n (\n !node.importer &&\n !node.id.startsWith('git') &&\n isStringArray(bundleDeps)\n ) ?\n new Set(bundleDeps)\n : new Set<string>()\n for (const depType of longDependencyTypes) {\n const obj: Record<string, string> | undefined =\n node.manifest?.[depType]\n // only care about devDeps for importers and git or symlink deps\n // technically this will also include devDeps for tarball file: specs,\n // but that is likely rare enough to not worry about too much.\n if (\n depType === 'devDependencies' &&\n !node.importer &&\n !node.id.startsWith('git') &&\n !node.id.startsWith('file')\n ) {\n continue\n }\n if (obj) {\n for (const [name, bareSpec] of Object.entries(obj)) {\n // if it's a bundled dependency, we just ignore it entirely.\n if (bundled.has(name)) continue\n dependencies.set(name, {\n name,\n type: depType,\n bareSpec,\n registry: node.registry,\n })\n }\n }\n }\n return dependencies\n}\n\n/**\n * Reads the current directory defined at `currDir` and looks for folder\n * names and their realpath resolution, normalizing scoped package names\n * and removing any invalid symlinks from the list of items that should\n * be parsed through in order to build the graph.\n */\nconst readDir = (\n scurry: PathScurry,\n currDir: Path,\n fromNodeName?: string,\n) => {\n const res = new Set<ReadEntry>()\n for (const entry of scurry.readdirSync(currDir)) {\n // ignore any hidden files / folders\n if (entry.name.startsWith('.')) continue\n\n // scope folder found, it will need to be read and iterated over\n // in order to find any scoped packages inside\n if (entry.name.startsWith('@')) {\n const scopedItems = readDir(scurry, entry, fromNodeName)\n for (const scopedItem of scopedItems) {\n res.add(scopedItem)\n }\n continue\n }\n\n // skip anything that isn't a symlink, it's not an edge\n if (!entry.isSymbolicLink()) continue\n\n // we'll need to learn what is the real path for this entry in order\n // to retrieve the `location` and `id` properties for the node, if a\n // realpath is not found just move on to the next element\n const realpath = entry.realpathSync()\n if (!realpath) {\n continue\n }\n\n // infer both the alias and proper package names, including scopes\n const alias = findName(entry)\n const name = findName(realpath)\n res.add({\n alias,\n name,\n realpath,\n })\n }\n return res\n}\n\n/**\n * Parses the files located at `currDir` and place packages found inside\n * as dependencies of `fromNode`, building the instantiated `graph`.\n */\nconst parseDir = (\n options: LoadOptions,\n scurry: PathScurry,\n packageJson: PackageJson,\n depsFound: Map<Node, Path>,\n graph: Graph,\n fromNode: Node,\n currDir: Path,\n) => {\n const { loadManifests } = options\n const dependencies = getDeps(fromNode)\n const seenDeps = new Set<string>()\n const readItems: Set<ReadEntry> = readDir(\n scurry,\n currDir,\n fromNode.name,\n )\n\n for (const { alias, name, realpath } of readItems) {\n let node\n\n // tracks what dependencies have been seen\n // so that we can mark missing dependencies\n seenDeps.add(alias)\n\n // places the package in the graph reading\n // its manifest only if necessary\n if (!loadManifests) {\n const depId = findDepID(realpath)\n\n if (depId) {\n const h = hydrate(depId, alias, {\n ...options,\n registry: fromNode.registry,\n })\n\n // graphs build with no manifest have no notion of\n // dependency types and or spec definitions since those\n // would have to be parsed from a manifest\n node = graph.placePackage(\n fromNode,\n 'prod', // defaults to prod deps\n h, // uses spec from hydrated id\n {\n name,\n ...(h.registrySpec ?\n { version: h.registrySpec } // adds version if available\n : null),\n },\n depId,\n )\n }\n }\n\n // retrieve references to the current folder name found in `fromNode`\n // manifest listed dependencies, removing it from the map will leave\n // a list of missing dependencies at the end of the iteration\n const deps = dependencies.get(alias)\n\n // in case this graph is skipping manifests, this next block might\n // still need to execute, thus actually loading a manifest file, for\n // edge-cases such as loading a linked node that is not going to have\n // DepID info available in its realpath or extraneous nodes\n if (!node) {\n const mani = packageJson.read(realpath.fullpath())\n // declares fallback default values for both depType and bareSpec\n // in order to support loadManifests=false fallback for link nodes\n const type = deps?.type || 'dependencies'\n const bareSpec = deps?.bareSpec || '*'\n\n const depType = shorten(type, alias, fromNode.manifest)\n const spec = Spec.parse(alias, bareSpec, {\n ...options,\n registry: fromNode.registry,\n })\n const maybeId = getPathBasedId(spec, realpath.relativePosix())\n node = graph.placePackage(\n fromNode,\n depType,\n spec,\n mani,\n maybeId,\n )\n }\n\n if (node) {\n // If a found dependency is not declared in any of the original\n // node dependencies, then add an edge to the graph pointing to it\n // and mark it as extraneous.\n //\n // This only makes sense if full manifests are being loaded\n // so that we have reference to dependencies info.\n if (loadManifests && !deps) {\n const [edge] = node.edgesIn\n if (edge) {\n graph.extraneousDependencies.add(edge)\n }\n }\n\n // for a succesfully created node, add its location\n // property and queue up to read its dependencies\n node.location = `./${realpath.relativePosix()}`\n const node_modules = findNodeModules(realpath)\n\n // queue items up to continue parsing dirs in case a node was succesfully\n // placed in the graph and its node_modules folder was correctly found\n if (node_modules) {\n depsFound.set(node, node_modules)\n }\n }\n }\n\n // any remaining dependencies that have not been found\n // when reading the directory should be marked as missing\n for (const { name, type, bareSpec } of dependencies.values()) {\n if (!seenDeps.has(name)) {\n const depType = shorten(type, name, fromNode.manifest)\n const spec = Spec.parse(name, bareSpec, {\n ...options,\n registry: fromNode.registry,\n })\n graph.placePackage(fromNode, depType, spec)\n }\n }\n}\n\n/**\n * Read the file system looking for `node_modules` folders and\n * returns a new {@link Graph} that represents the relationship\n * between the dependencies found.\n */\nexport const load = (options: LoadOptions): Graph => {\n const done = graphStep('actual')\n // TODO: once hidden lockfile is more reliable, default to false here\n const {\n skipHiddenLockfile = true,\n projectRoot,\n packageJson,\n scurry,\n monorepo,\n } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(projectRoot)\n\n if (!skipHiddenLockfile) {\n try {\n const graph = loadHidden({\n projectRoot,\n mainManifest,\n packageJson,\n monorepo,\n scurry,\n })\n // TODO: check mtime of lockfile vs .vlt folder\n return graph\n } catch {}\n }\n\n const graph = new Graph({ ...options, mainManifest })\n const depsFound = new Map<Node, Path>()\n\n // starts the list of initial folders to parse using the importer nodes\n for (const importer of graph.importers) {\n depsFound.set(\n importer,\n scurry.cwd.resolve(`${importer.location}/node_modules`),\n )\n }\n\n // breadth-first traversal of the file system tree reading deps found\n // starting from the node_modules folder of every importer in order to\n // find the actual installed dependencies at each location\n for (const [node, path] of depsFound.entries()) {\n parseDir(\n options,\n scurry,\n packageJson,\n depsFound,\n graph,\n node,\n path,\n )\n }\n\n done()\n\n return graph\n}\n"]}
|
package/dist/esm/browser.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { longDependencyTypes } from '@vltpkg/types';
|
|
2
|
+
import { asDependencyTypeShort, shorten } from './dependencies.ts';
|
|
3
|
+
import { getBooleanFlagsFromNum } from './lockfile/types.ts';
|
|
4
|
+
import { stringifyNode } from './stringify-node.ts';
|
|
5
|
+
export * from './types.ts';
|
|
4
6
|
declare const lockfile: {
|
|
5
|
-
loadEdges: (graph: import("./types.
|
|
6
|
-
loadNodes: (graph: import("./types.
|
|
7
|
+
loadEdges: (graph: import("./types.ts").GraphLike, edges: import("./lockfile/types.ts").LockfileData["edges"], options: import("@vltpkg/spec").SpecOptions) => void;
|
|
8
|
+
loadNodes: (graph: import("./types.ts").GraphLike, nodes: import("./lockfile/types.ts").LockfileData["nodes"]) => void;
|
|
7
9
|
};
|
|
8
|
-
export { asDependencyTypeShort, getBooleanFlagsFromNum, lockfile, stringifyNode, };
|
|
10
|
+
export { asDependencyTypeShort, getBooleanFlagsFromNum, lockfile, longDependencyTypes, shorten, stringifyNode, };
|
|
9
11
|
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnD,cAAc,YAAY,CAAA;AAE1B,QAAA,MAAM,QAAQ;;;CAGb,CAAA;AAED,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,QAAQ,EACR,mBAAmB,EACnB,OAAO,EACP,aAAa,GACd,CAAA"}
|
package/dist/esm/browser.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { longDependencyTypes } from '@vltpkg/types';
|
|
2
|
+
import { asDependencyTypeShort, shorten } from "./dependencies.js";
|
|
3
|
+
import { getBooleanFlagsFromNum } from "./lockfile/types.js";
|
|
4
|
+
import { stringifyNode } from "./stringify-node.js";
|
|
5
|
+
import { loadEdges } from "./lockfile/load-edges.js";
|
|
6
|
+
import { loadNodes } from "./lockfile/load-nodes.js";
|
|
7
|
+
export * from "./types.js";
|
|
6
8
|
const lockfile = {
|
|
7
9
|
loadEdges,
|
|
8
10
|
loadNodes,
|
|
9
11
|
};
|
|
10
|
-
export { asDependencyTypeShort, getBooleanFlagsFromNum, lockfile, stringifyNode, };
|
|
12
|
+
export { asDependencyTypeShort, getBooleanFlagsFromNum, lockfile, longDependencyTypes, shorten, stringifyNode, };
|
|
11
13
|
//# sourceMappingURL=browser.js.map
|
package/dist/esm/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,cAAc,YAAY,CAAA;AAE1B,MAAM,QAAQ,GAAG;IACf,SAAS;IACT,SAAS;CACV,CAAA;AAED,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,QAAQ,EACR,mBAAmB,EACnB,OAAO,EACP,aAAa,GACd,CAAA","sourcesContent":["import { longDependencyTypes } from '@vltpkg/types'\nimport { asDependencyTypeShort, shorten } from './dependencies.ts'\nimport { getBooleanFlagsFromNum } from './lockfile/types.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport { loadEdges } from './lockfile/load-edges.ts'\nimport { loadNodes } from './lockfile/load-nodes.ts'\nexport * from './types.ts'\n\nconst lockfile = {\n loadEdges,\n loadNodes,\n}\n\nexport {\n asDependencyTypeShort,\n getBooleanFlagsFromNum,\n lockfile,\n longDependencyTypes,\n shorten,\n stringifyNode,\n}\n"]}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
/**
|
|
5
|
-
* Name of the package.json keys used to define different types of dependencies.
|
|
6
|
-
*/
|
|
7
|
-
export type DependencyTypeLong = 'dependencies' | 'devDependencies' | 'optionalDependencies' | 'peerDependencies';
|
|
8
|
-
/**
|
|
9
|
-
* Unique keys that define different types of dependencies relationship.
|
|
10
|
-
*/
|
|
11
|
-
export type DependencyTypeShort = 'dev' | 'optional' | 'peer' | 'peerOptional' | 'prod';
|
|
1
|
+
import type { DepID } from '@vltpkg/dep-id';
|
|
2
|
+
import type { Spec } from '@vltpkg/spec';
|
|
3
|
+
import type { Manifest, DependencyTypeLong, DependencyTypeShort } from '@vltpkg/types';
|
|
12
4
|
export declare const isDependencyTypeShort: (obj: unknown) => obj is DependencyTypeShort;
|
|
13
5
|
export declare const asDependencyTypeShort: (obj: unknown) => DependencyTypeShort;
|
|
14
6
|
/**
|
|
@@ -38,30 +30,26 @@ export type Dependency = {
|
|
|
38
30
|
* keys are the dependency names and values are {@link Dependency}. This
|
|
39
31
|
* structure represents dependencies that need to be added to the importer
|
|
40
32
|
* represented by {@link DepID}.
|
|
33
|
+
*
|
|
34
|
+
* The `modifiedDependencies` property can be used to indicate that there
|
|
35
|
+
* are added dependencies to any of the importer nodes.
|
|
41
36
|
*/
|
|
42
|
-
export type AddImportersDependenciesMap = Map<DepID, Map<string, Dependency
|
|
37
|
+
export type AddImportersDependenciesMap = Map<DepID, Map<string, Dependency>> & {
|
|
38
|
+
modifiedDependencies: boolean;
|
|
39
|
+
};
|
|
43
40
|
/**
|
|
44
41
|
* A `Map` object representing nodes to be removed from the ideal graph.
|
|
45
42
|
* Each {@link DepID} key represents an importer node and the `Set` of
|
|
46
43
|
* dependency names to be removed from its dependency list.
|
|
44
|
+
*
|
|
45
|
+
* The `modifiedDependencies` property can be used to indicate that there
|
|
46
|
+
* are added dependencies to any of the importer nodes.
|
|
47
47
|
*/
|
|
48
|
-
export type RemoveImportersDependenciesMap = Map<DepID, Set<string
|
|
48
|
+
export type RemoveImportersDependenciesMap = Map<DepID, Set<string>> & {
|
|
49
|
+
modifiedDependencies: boolean;
|
|
50
|
+
};
|
|
49
51
|
export declare const isDependency: (o: unknown) => o is Dependency;
|
|
50
52
|
export declare const asDependency: (obj: unknown) => Dependency;
|
|
51
|
-
/**
|
|
52
|
-
* A set of the possible long dependency type names,
|
|
53
|
-
* as used in `package.json` files.
|
|
54
|
-
*/
|
|
55
|
-
export declare const longDependencyTypes: Set<DependencyTypeLong>;
|
|
56
|
-
/**
|
|
57
|
-
* A set of the short type keys used to represent dependency relationships.
|
|
58
|
-
*/
|
|
59
|
-
export declare const shortDependencyTypes: Set<DependencyTypeShort>;
|
|
60
|
-
/**
|
|
61
|
-
* Maps between long form names usually used in `package.json` files
|
|
62
|
-
* to a corresponding short form name, used in lockfiles.
|
|
63
|
-
*/
|
|
64
|
-
export declare const dependencyTypes: Map<DependencyTypeLong, DependencyTypeShort>;
|
|
65
53
|
/**
|
|
66
54
|
* Get the {@link DependencyTypeShort} from a {@link DependencyTypeLong}.
|
|
67
55
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAMxC,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,eAAe,CAAA;AAEtB,eAAO,MAAM,qBAAqB,QAC3B,OAAO,KACX,GAAG,IAAI,mBAC4C,CAAA;AAEtD,eAAO,MAAM,qBAAqB,QAC3B,OAAO,KACX,mBAQF,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,kBAAkB,CAAA;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IACV;;OAEG;IACH,IAAI,EAAE,mBAAmB,CAAA;CAC1B,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,2BAA2B,GAAG,GAAG,CAC3C,KAAK,EACL,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CACxB,GAAG;IAAE,oBAAoB,EAAE,OAAO,CAAA;CAAE,CAAA;AAErC;;;;;;;GAOG;AACH,MAAM,MAAM,8BAA8B,GAAG,GAAG,CAC9C,KAAK,EACL,GAAG,CAAC,MAAM,CAAC,CACZ,GAAG;IAAE,oBAAoB,EAAE,OAAO,CAAA;CAAE,CAAA;AAMrC,eAAO,MAAM,YAAY,MAAO,OAAO,KAAG,CAAC,IAAI,UAKhB,CAAA;AAE/B,eAAO,MAAM,YAAY,QAAS,OAAO,KAAG,UAK3C,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,OAAO,aACR,kBAAkB,SACrB,MAAM,aACF,QAAQ,KAClB,mBAkBF,CAAA"}
|
package/dist/esm/dependencies.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { longDependencyTypes, shortDependencyTypes, dependencyTypes, } from '@vltpkg/types';
|
|
2
3
|
export const isDependencyTypeShort = (obj) => shortDependencyTypes.has(obj);
|
|
3
4
|
export const asDependencyTypeShort = (obj) => {
|
|
4
5
|
if (!isDependencyTypeShort(obj)) {
|
|
@@ -23,36 +24,6 @@ export const asDependency = (obj) => {
|
|
|
23
24
|
}
|
|
24
25
|
return obj;
|
|
25
26
|
};
|
|
26
|
-
/**
|
|
27
|
-
* A set of the possible long dependency type names,
|
|
28
|
-
* as used in `package.json` files.
|
|
29
|
-
*/
|
|
30
|
-
export const longDependencyTypes = new Set([
|
|
31
|
-
'dependencies',
|
|
32
|
-
'devDependencies',
|
|
33
|
-
'peerDependencies',
|
|
34
|
-
'optionalDependencies',
|
|
35
|
-
]);
|
|
36
|
-
/**
|
|
37
|
-
* A set of the short type keys used to represent dependency relationships.
|
|
38
|
-
*/
|
|
39
|
-
export const shortDependencyTypes = new Set([
|
|
40
|
-
'prod',
|
|
41
|
-
'dev',
|
|
42
|
-
'peer',
|
|
43
|
-
'optional',
|
|
44
|
-
'peerOptional',
|
|
45
|
-
]);
|
|
46
|
-
/**
|
|
47
|
-
* Maps between long form names usually used in `package.json` files
|
|
48
|
-
* to a corresponding short form name, used in lockfiles.
|
|
49
|
-
*/
|
|
50
|
-
export const dependencyTypes = new Map([
|
|
51
|
-
['dependencies', 'prod'],
|
|
52
|
-
['devDependencies', 'dev'],
|
|
53
|
-
['peerDependencies', 'peer'],
|
|
54
|
-
['optionalDependencies', 'optional'],
|
|
55
|
-
]);
|
|
56
27
|
/**
|
|
57
28
|
* Get the {@link DependencyTypeShort} from a {@link DependencyTypeLong}.
|
|
58
29
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/dependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/dependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,GAChB,MAAM,eAAe,CAAA;AAOtB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,GAAY,EACgB,EAAE,CAC9B,oBAAoB,CAAC,GAAG,CAAC,GAA0B,CAAC,CAAA;AAEtD,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,GAAY,EACS,EAAE;IACvB,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC;QAChC,MAAM,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EAAE,oBAAoB,EAAE,CAAC,IAAI,CAAC,EAAE,QAAQ,KAAK,IAAI,EACzD,CAAC;QACD,OAAO,cAAc,CAAA;IACvB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport type { Spec } from '@vltpkg/spec'\nimport {\n longDependencyTypes,\n shortDependencyTypes,\n dependencyTypes,\n} from '@vltpkg/types'\nimport type {\n Manifest,\n DependencyTypeLong,\n DependencyTypeShort,\n} from '@vltpkg/types'\n\nexport const isDependencyTypeShort = (\n obj: unknown,\n): obj is DependencyTypeShort =>\n shortDependencyTypes.has(obj as DependencyTypeShort)\n\nexport const asDependencyTypeShort = (\n obj: unknown,\n): DependencyTypeShort => {\n if (!isDependencyTypeShort(obj)) {\n throw error('Invalid dependency type', {\n found: obj,\n validOptions: [...shortDependencyTypes],\n })\n }\n return obj\n}\n\n/**\n * Dependency entries info as defined in a package.json file.\n */\nexport type RawDependency = {\n name: string\n bareSpec: string\n type: DependencyTypeLong\n registry?: string\n}\n\n/**\n * Parsed dependency entries info.\n */\nexport type Dependency = {\n /**\n * The parsed {@link Spec} object describing the dependency requirements.\n */\n spec: Spec\n /**\n * The {@link DependencyTypeShort}, describing the type of dependency.\n */\n type: DependencyTypeShort\n}\n\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 * The `modifiedDependencies` property can be used to indicate that there\n * are added dependencies to any of the importer nodes.\n */\nexport type AddImportersDependenciesMap = Map<\n DepID,\n Map<string, Dependency>\n> & { modifiedDependencies: boolean }\n\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 * The `modifiedDependencies` property can be used to indicate that there\n * are added dependencies to any of the importer nodes.\n */\nexport type RemoveImportersDependenciesMap = Map<\n DepID,\n Set<string>\n> & { modifiedDependencies: boolean }\n\nconst isObj = (o: unknown): o is Record<string, unknown> =>\n !!o && typeof o === 'object'\n\n// TODO: it would be nice to have a @vltpkg/spec.isSpec method\nexport const isDependency = (o: unknown): o is Dependency =>\n // TODO: it would be nice to have a @vltpkg/spec.isSpec method\n isObj(o) &&\n isObj(o.spec) &&\n !!o.spec.type &&\n isDependencyTypeShort(o.type)\n\nexport const asDependency = (obj: unknown): Dependency => {\n if (!isDependency(obj)) {\n throw error('Invalid dependency', { found: obj })\n }\n return obj\n}\n\n/**\n * Get the {@link DependencyTypeShort} from a {@link DependencyTypeLong}.\n */\nexport const shorten = (\n typeLong: DependencyTypeLong,\n name?: string,\n manifest?: Manifest,\n): DependencyTypeShort => {\n const shortName = dependencyTypes.get(typeLong)\n if (!shortName) {\n throw error('Invalid dependency type name', {\n found: typeLong,\n validOptions: [...longDependencyTypes],\n })\n }\n if (shortName !== 'peer') {\n return shortName\n }\n if (\n name &&\n manifest?.peerDependenciesMeta?.[name]?.optional === true\n ) {\n return 'peerOptional'\n }\n return 'peer'\n}\n"]}
|
package/dist/esm/diff.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { InspectOptions } from 'node:util';
|
|
2
|
+
import type { Edge } from './edge.ts';
|
|
3
|
+
import type { Graph } from './graph.ts';
|
|
4
|
+
import type { Node } from './node.ts';
|
|
5
5
|
declare const kCustomInspect: unique symbol;
|
|
6
6
|
/**
|
|
7
7
|
* A Diff object is a representation of a set of changes from one
|
package/dist/esm/diff.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/diff.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/diff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;YACrC,oBAAoB;YACpB,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAA;YAC5B,KAAK,CAAC,IAAI,CACR,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAC3D,CAAA;QACH,CAAC;QACD,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,CAAmB,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAC1D,MAAM,KAAK,GACT,OAAO,EAAE,MAAM,CAAC,CAAC;YACf,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;YACzD,CAAC,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAA;QAEpB,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;EACpC,KAAK;aACJ,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;aAClE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;aACzB,IAAI,CAAC,IAAI,CAAC;EACX,CAAA;IACA,CAAC;CACF","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport {
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAM3C,uDAAuD;AACvD,6EAA6E;AAC7E,4BAA4B;AAC5B,w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AC;EACX,CAAA;IACA,CAAC;CACF","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { InspectOptions } from 'node:util'\nimport type { Edge } from './edge.ts'\nimport type { Graph } from './graph.ts'\nimport type { Node } from './node.ts'\n\n// XXX should file deps *always* be considered changed?\n// unless the thing containing it wasn't possibly changed because it's inside\n// a dep that didn't change?\n// Same with remote deps\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\n/**\n * A Diff object is a representation of a set of changes from one\n * graph to another, typically from the actual graph as it is reified\n * on disk, to an intended ideal graph.\n *\n * The naming convention can get a bit confusing here, because it's a\n * set of directed changes from one set of directed objects to another.\n *\n * Within the context the Diff object, `from` is the Graph we're coming from,\n * and `to` is the Graph we're trying to create.\n */\nexport class Diff {\n from: Graph\n to: Graph\n\n projectRoot: string\n\n /**\n * If changes need to be made later for failures of optional nodes,\n * set this flag so that we know to call graph.gc() at the appropriate time.\n */\n hadOptionalFailures = false\n\n /**\n * Collection of nodes to add and delete\n */\n nodes = {\n /** Nodes in the `to` graph that are not in the `from` graph */\n add: new Set<Node>(),\n /** Nodes in the `from` graph that are not in the `to` graph */\n delete: new Set<Node>(),\n }\n\n /**\n * Collection of nodes to add and delete\n */\n edges = {\n /** Edges in the `to` graph that are not found in the `from` graph */\n add: new Set<Edge>(),\n /** Edges in the `from` graph that are not found in the `to` graph */\n delete: new Set<Edge>(),\n }\n\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Diff'\n }\n\n constructor(from: Graph, to: Graph) {\n this.from = from\n this.to = to\n this.projectRoot = from.projectRoot\n if (to.projectRoot !== from.projectRoot) {\n throw error('projectRoot mismatch in Graph diff', {\n wanted: from.projectRoot,\n found: to.projectRoot,\n })\n }\n\n for (const [id, node] of this.from.nodes) {\n if (!this.to.nodes.get(id)?.equals(node)) {\n this.nodes.delete.add(node)\n }\n }\n\n for (const [id, node] of this.to.nodes) {\n if (!this.from.nodes.get(id)?.equals(node)) {\n this.nodes.add.add(node)\n }\n }\n\n for (const edge of this.to.edges) {\n // the node with this dep, in the from graph\n const fromNode = this.from.nodes.get(edge.from.id)\n const fromEdge = fromNode?.edgesOut.get(edge.spec.name)\n if (fromEdge?.to?.id === edge.to?.id) continue\n if (fromEdge?.to) this.edges.delete.add(fromEdge)\n if (edge.to) this.edges.add.add(edge)\n }\n for (const edge of this.from.edges) {\n // the node with this dep, in the to graph\n const toNode = this.to.nodes.get(edge.from.id)\n const toEdge = toNode?.edgesOut.get(edge.spec.name)\n if (toEdge?.to?.id === edge.to?.id) continue\n if (edge.to) this.edges.delete.add(edge)\n if (toEdge?.to) this.edges.add.add(toEdge)\n }\n }\n\n [kCustomInspect](_: number, options?: InspectOptions): string {\n const red: [string, string] =\n options?.colors ? ['\\x1b[31m', '\\x1b[m'] : ['', '']\n const green: [string, string] =\n options?.colors ? ['\\x1b[32m', '\\x1b[m'] : ['', '']\n const lines: string[] = []\n for (const node of this.nodes.add) {\n lines.push(`+ ${node.id}`)\n }\n for (const node of this.nodes.delete) {\n lines.push(`- ${node.id}`)\n }\n for (const edge of this.edges.add) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `+ ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n for (const edge of this.edges.delete) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `- ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n const wrap = (s: string, c: [string, string]) => c.join(s)\n const color =\n options?.colors ?\n (s: string) => wrap(s, s.startsWith('+') ? green : red)\n : (s: string) => s\n\n return `${this[Symbol.toStringTag]} {\n${lines\n .sort((a, b) => a.substring(1).localeCompare(b.substring(1), 'en'))\n .map(s => ' ' + color(s))\n .join('\\n')}\n}`\n }\n}\n"]}
|
package/dist/esm/edge.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import type { Spec } from '@vltpkg/spec';
|
|
2
|
+
import type { InspectOptions } from 'util';
|
|
3
|
+
import type { DependencyTypeShort } from '@vltpkg/types';
|
|
4
|
+
import type { Node } from './node.ts';
|
|
5
|
+
import type { EdgeLike } from './types.ts';
|
|
6
6
|
declare const kCustomInspect: unique symbol;
|
|
7
7
|
export declare class Edge implements EdgeLike {
|
|
8
8
|
get [Symbol.toStringTag](): string;
|
package/dist/esm/edge.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AAC1C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C,QAAA,MAAM,cAAc,eAA2C,CAAA;AAE/D,qBAAa,IAAK,YAAW,QAAQ;IACnC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;IAED,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc;IAanD;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IAEV;;OAEG;IACH,EAAE,CAAC,EAAE,IAAI,CAAA;IAET;;OAEG;IACH,IAAI,EAAE,mBAAmB,CAAA;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;gBAGR,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,EAAE,CAAC,EAAE,IAAI;IAQX;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,IAAI,IAAI,OAAO,CAElB;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,KAAK,IAAI,OAAO;CAUjB"}
|
package/dist/esm/edge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge.js","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"edge.js","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAM9B,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,CAAC,cAAc,CAAC,CAAC,CAAS,EAAE,OAAuB;QACjD,MAAM,GAAG,GAAG,OAAO,CACjB;YACE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YACvB,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;SAChB,EACD,OAAO,CACR,CAAA;QACD,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,GAAG,EAAE,CAAA;IAC7C,CAAC;IAED;;OAEG;IACH,IAAI,CAAM;IAEV;;OAEG;IACH,EAAE,CAAO;IAET;;OAEG;IACH,IAAI,CAAqB;IAEzB;;OAEG;IACH,IAAI,CAAM;IAEV,YACE,IAAyB,EACzB,IAAU,EACV,IAAU,EACV,EAAS;QAET,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAA;IAC5B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,CAAA;IACjE,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;IAC7D,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;IACrC,CAAC;IAED,KAAK;QACH,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACb,IAAI,CAAC,QAAQ;YACf,CAAC,CAAC,SAAS,CACP,IAAI,CAAC,EAAE,CAAC,EAAE,EACV,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAClB,IAAI,CAAC,IAAI,CAAC,WAAW,CACtB,CAAA;IACP,CAAC;CACF","sourcesContent":["import { satisfies } from '@vltpkg/satisfies'\nimport type { Spec } from '@vltpkg/spec'\nimport { inspect } from 'util'\nimport type { InspectOptions } from 'util'\nimport type { DependencyTypeShort } from '@vltpkg/types'\nimport type { Node } from './node.ts'\nimport type { EdgeLike } from './types.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport class Edge implements EdgeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Edge'\n }\n\n [kCustomInspect](_: number, options: InspectOptions) {\n const str = inspect(\n {\n from: this.from.id,\n type: this.type,\n spec: String(this.spec),\n to: this.to?.id,\n },\n options,\n )\n return `${this[Symbol.toStringTag]} ${str}`\n }\n\n /**\n * The Node this Edge is connecting from, this is usually the dependent.\n */\n from: Node\n\n /**\n * The node this Edge is connecting to, this is usually a direct dependency.\n */\n to?: Node\n\n /**\n * What type of dependency relationship `from` and `to` nodes have.\n */\n type: DependencyTypeShort\n\n /**\n * The defined spec value for `to` as parsed from the dependent metadata.\n */\n spec: Spec\n\n constructor(\n type: DependencyTypeShort,\n spec: Spec,\n from: Node,\n to?: Node,\n ) {\n this.from = from\n this.to = to\n this.type = type\n this.spec = spec\n }\n\n /**\n * The name of the dependency `to` as defined in the dependent metadata.\n */\n get name() {\n return this.spec.name\n }\n\n /**\n * This edge was defined as part of a `devDependencies` in `package.json`\n */\n get dev(): boolean {\n return this.type === 'dev'\n }\n\n get optional(): boolean {\n return this.type === 'peerOptional' || this.type === 'optional'\n }\n\n get peer(): boolean {\n return this.type === 'peer' || this.type === 'peerOptional'\n }\n\n get peerOptional(): boolean {\n return this.type === 'peerOptional'\n }\n\n valid(): boolean {\n return !this.to ?\n this.optional\n : satisfies(\n this.to.id,\n this.spec,\n this.from.location,\n this.from.projectRoot,\n )\n }\n}\n"]}
|
package/dist/esm/graph.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Spec
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { Node } from './node.
|
|
9
|
-
import {
|
|
1
|
+
import type { DepID } from '@vltpkg/dep-id';
|
|
2
|
+
import { Spec } from '@vltpkg/spec';
|
|
3
|
+
import type { SpecOptions } from '@vltpkg/spec';
|
|
4
|
+
import type { Manifest, DependencyTypeShort } from '@vltpkg/types';
|
|
5
|
+
import type { Monorepo } from '@vltpkg/workspaces';
|
|
6
|
+
import type { InspectOptions } from 'util';
|
|
7
|
+
import type { Edge } from './edge.ts';
|
|
8
|
+
import { Node } from './node.ts';
|
|
9
|
+
import type { GraphLike, NodeLike } from './types.ts';
|
|
10
10
|
declare const kCustomInspect: unique symbol;
|
|
11
11
|
export type ManifestInventory = Map<DepID, Manifest>;
|
|
12
12
|
export type GraphOptions = SpecOptions & {
|
|
@@ -116,7 +116,7 @@ export declare class Graph implements GraphLike {
|
|
|
116
116
|
* if it is valid to do so.
|
|
117
117
|
*/
|
|
118
118
|
removeNode(node: Node, replacement?: Node): void;
|
|
119
|
-
toJSON(): import("./index.
|
|
119
|
+
toJSON(): import("./index.ts").LockfileData;
|
|
120
120
|
[kCustomInspect](_: number, options: InspectOptions): string;
|
|
121
121
|
}
|
|
122
122
|
export {};
|
package/dist/esm/graph.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/graph.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/graph.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAG3C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAA;AAC1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAE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,KAAK,EACV,QAAQ,CAAC,EAAE,QAAQ,EACnB,IAAI,CAAC,EAAE,IAAI,EACX,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM;IA+BlB;;;;;;;OAOG;IACH,YAAY,CACV,QAAQ,EAAE,IAAI,EACd,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,IAAI,EACV,QAAQ,CAAC,EAAE,QAAQ,EACnB,EAAE,CAAC,EAAE,KAAK;IAkDZ;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,EAAE,IAAI;IAiCzC,MAAM;IAQN,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc;CAIpD"}
|
package/dist/esm/graph.js
CHANGED
|
@@ -3,8 +3,8 @@ import { error } from '@vltpkg/error-cause';
|
|
|
3
3
|
import { satisfies } from '@vltpkg/satisfies';
|
|
4
4
|
import { Spec } from '@vltpkg/spec';
|
|
5
5
|
import { inspect } from 'util';
|
|
6
|
-
import { lockfileData } from
|
|
7
|
-
import { Node } from
|
|
6
|
+
import { lockfileData } from "./lockfile/save.js";
|
|
7
|
+
import { Node } from "./node.js";
|
|
8
8
|
const kCustomInspect = Symbol.for('nodejs.util.inspect.custom');
|
|
9
9
|
// this is always the same, but we don't hard code it as a string,
|
|
10
10
|
// in case the DepID module needs to change its delimiter again ever.
|
|
@@ -283,7 +283,8 @@ export class Graph {
|
|
|
283
283
|
edge.to = replacement;
|
|
284
284
|
}
|
|
285
285
|
else {
|
|
286
|
-
edge.
|
|
286
|
+
edge.from.edgesOut.delete(edge.spec.name);
|
|
287
|
+
this.edges.delete(edge);
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
}
|