@vltpkg/graph 0.0.0-5 → 0.0.0-7
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/edge.d.ts +1 -1
- package/dist/esm/edge.d.ts.map +1 -1
- package/dist/esm/edge.js +1 -1
- package/dist/esm/edge.js.map +1 -1
- package/dist/esm/graph.d.ts +1 -1
- package/dist/esm/graph.d.ts.map +1 -1
- package/dist/esm/graph.js +1 -1
- package/dist/esm/graph.js.map +1 -1
- package/dist/esm/install.d.ts +3 -2
- package/dist/esm/install.d.ts.map +1 -1
- package/dist/esm/install.js +0 -3
- package/dist/esm/install.js.map +1 -1
- package/dist/esm/node.d.ts.map +1 -1
- package/dist/esm/node.js +3 -0
- package/dist/esm/node.js.map +1 -1
- package/dist/esm/reify/add-edge.js +2 -2
- package/dist/esm/reify/add-edge.js.map +1 -1
- package/dist/esm/reify/build.js +2 -2
- package/dist/esm/reify/build.js.map +1 -1
- package/dist/esm/uninstall.d.ts +3 -2
- package/dist/esm/uninstall.d.ts.map +1 -1
- package/dist/esm/uninstall.js +0 -3
- package/dist/esm/uninstall.js.map +1 -1
- package/package.json +14 -16
package/dist/esm/edge.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Spec } from '@vltpkg/spec';
|
|
2
|
-
import type { InspectOptions } from 'util';
|
|
2
|
+
import type { InspectOptions } from 'node:util';
|
|
3
3
|
import type { DependencyTypeShort } from '@vltpkg/types';
|
|
4
4
|
import type { Node } from './node.ts';
|
|
5
5
|
import type { EdgeLike } from './types.ts';
|
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,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,
|
|
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,WAAW,CAAA;AAC/C,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
CHANGED
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,O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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 'node:util'\nimport type { InspectOptions } from 'node: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
|
@@ -3,7 +3,7 @@ import { Spec } from '@vltpkg/spec';
|
|
|
3
3
|
import type { SpecOptions } from '@vltpkg/spec';
|
|
4
4
|
import type { Manifest, DependencyTypeShort } from '@vltpkg/types';
|
|
5
5
|
import type { Monorepo } from '@vltpkg/workspaces';
|
|
6
|
-
import type { InspectOptions } from 'util';
|
|
6
|
+
import type { InspectOptions } from 'node:util';
|
|
7
7
|
import type { Edge } from './edge.ts';
|
|
8
8
|
import { Node } from './node.ts';
|
|
9
9
|
import type { GraphLike, NodeLike } from './types.ts';
|
package/dist/esm/graph.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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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
|
import { satisfies } from '@vltpkg/satisfies';
|
|
4
4
|
import { Spec } from '@vltpkg/spec';
|
|
5
|
-
import { inspect } from 'util';
|
|
5
|
+
import { inspect } from 'node:util';
|
|
6
6
|
import { lockfileData } from "./lockfile/save.js";
|
|
7
7
|
import { Node } from "./node.js";
|
|
8
8
|
const kCustomInspect = Symbol.for('nodejs.util.inspect.custom');
|
package/dist/esm/graph.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAInC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAG9B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAIhC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D,kEAAkE;AAClE,qEAAqE;AACrE,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;AAI/C,MAAM,MAAM,GAAG,CAA0B,CAAK,EAAE,EAAE,CAChD,CAAC,IAAK,IAAI,GAAG,EAAQ,CAAA;AAqBvB,MAAM,OAAO,KAAK;IAChB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,qBAAqB,CAAA;IAC9B,CAAC;IAED,QAAQ,CAAc;IAEtB,YAAY,CAAa;IAEzB;;OAEG;IACH,QAAQ,CAAW;IAEnB;;OAEG;IACH,SAAS,CAAmB;IAE5B;;OAEG;IACH,KAAK,GAAG,I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CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC9B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC;QACD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAChC,IACE,WAAW;gBACX,SAAS,CACP,WAAW,CAAC,EAAE,EACd,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAClB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,QAAQ,CACd,EACD,CAAC;gBACD,IAAI,CAAC,EAAE,GAAG,WAAW,CAAA;YACvB,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACzC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO,YAAY,CAAC;YAClB,GAAG,IAAI,CAAC,QAAQ;YAChB,KAAK,EAAE,IAAI;YACX,aAAa,EAAE,IAAI;SACpB,CAAC,CAAA;IACJ,CAAC;IAED,CAAC,cAAc,CAAC,CAAC,CAAS,EAAE,OAAuB;QACjD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;QAC1B,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAA;IAChE,CAAC;CACF","sourcesContent":["import { getId, joinDepIDTuple } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport { satisfies } from '@vltpkg/satisfies'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { Manifest, DependencyTypeShort } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport { inspect } from 'util'\nimport type { InspectOptions } from 'util'\nimport type { Edge } from './edge.ts'\nimport { lockfileData } from './lockfile/save.ts'\nimport { Node } from './node.ts'\nimport type { NodeOptions } from './node.ts'\nimport type { GraphLike, NodeLike } from './types.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\n// this is always the same, but we don't hard code it as a string,\n// in case the DepID module needs to change its delimiter again ever.\nconst mainDepID = joinDepIDTuple(['file', '.'])\n\nexport type ManifestInventory = Map<DepID, Manifest>\n\nconst getMap = <T extends Map<any, any>>(m?: T) =>\n m ?? (new Map() as T)\n\nexport type GraphOptions = SpecOptions & {\n /**\n * The main importer manifest info.\n */\n mainManifest: Manifest\n /**\n * An inventory of seen manifests.\n */\n manifests?: ManifestInventory\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * Root of the project this graph represents\n */\n projectRoot: string\n}\n\nexport class Graph implements GraphLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Graph'\n }\n\n #options: GraphOptions\n\n #nodeOptions: NodeOptions\n\n /**\n * A {@link Monorepo} instance, used for managing workspaces.\n */\n monorepo?: Monorepo\n\n /**\n * An inventory with all manifests related to an install.\n */\n manifests: ManifestInventory\n\n /**\n * A set of all edges in this graph.\n */\n edges = new Set<Edge>()\n\n /**\n * Map registered dep ids to the node that represent them in the graph.\n */\n nodes = new Map<DepID, Node>()\n\n /**\n * Map of nodes by their name\n */\n nodesByName = new Map<string, Set<Node>>()\n\n /**\n * Cached resolutions for spec lookups\n */\n resolutions = new Map<string, Node>()\n\n /**\n * Reverse map of resolutions\n */\n resolutionsReverse = new Map<Node, Set<string>>()\n\n /**\n * A set of importer nodes in this graph.\n */\n importers = new Set<Node>()\n\n /**\n * The {@link Node} that represents the project root `package.json`.\n */\n mainImporter: Node\n\n /**\n * A set of extraneous dependencies found when building the graph.\n */\n extraneousDependencies = new Set<Edge>()\n\n /**\n * The root of the project this graph represents\n */\n projectRoot: string\n\n constructor(options: GraphOptions) {\n const { mainManifest, monorepo } = options\n this.#options = options\n this.manifests = getMap(options.manifests)\n this.projectRoot = options.projectRoot\n this.#nodeOptions = {\n ...this.#options,\n graph: this,\n }\n\n // add the project root node\n const mainImporterLocation = '.'\n const mainImporterSpec = Spec.parse(\n mainManifest.name || '(root)',\n mainImporterLocation,\n )\n const mainImporter = this.addNode(\n mainDepID,\n mainManifest,\n mainImporterSpec,\n )\n mainImporter.setImporterLocation(mainImporterLocation)\n mainImporter.mainImporter = true\n this.mainImporter = mainImporter\n this.importers.add(mainImporter)\n this.manifests.set(mainImporter.id, mainManifest)\n\n // uses the monorepo instance in order to retrieve info on\n // workspaces and create importer nodes for each of them\n this.monorepo = monorepo\n if (this.monorepo) {\n for (const ws of this.monorepo) {\n const wsNode = this.addNode(\n ws.id,\n ws.manifest,\n undefined,\n ws.name,\n )\n wsNode.setImporterLocation(`./${ws.path}`)\n if (wsNode.manifest) {\n this.manifests.set(wsNode.id, wsNode.manifest)\n }\n this.importers.add(wsNode)\n }\n }\n }\n\n /**\n * Delete all nodes that are unreachable from the importers.\n * The collection of deleted nodes is returned.\n *\n * NOTE: This can be extremely slow for large graphs, and is almost always\n * unnecessary! Only call when it is known that some unreachable nodes may\n * have been created, for example when deleting the unneeded subgraph when an\n * optional node fails to resolve/install.\n */\n gc() {\n const { nodes } = this\n this.nodes = new Map()\n const marked = new Set(this.importers)\n for (const imp of marked) {\n // don't delete the importer!\n nodes.delete(imp.id)\n this.nodes.set(imp.id, imp)\n for (const { to } of imp.edgesOut.values()) {\n if (!to || marked.has(to)) continue\n marked.add(to)\n nodes.delete(to.id)\n this.nodes.set(to.id, to)\n }\n }\n for (const node of nodes.values()) {\n this.removeNode(node)\n }\n return nodes\n }\n\n /**\n * Create a new edge between two nodes of the graph in case both exist,\n * in case the destination node does not exists, then a dangling edge,\n * pointing to nothing will be created to represent that missing dependency.\n */\n addEdge(\n type: DependencyTypeShort,\n spec: Spec,\n from: NodeLike,\n to?: NodeLike,\n ) {\n // fix any nameless spec\n if (spec.name === '(unknown)') {\n if (to) {\n spec.name = to.name /* c8 ignore next */ || '(unknown)'\n spec.spec = `${to.name}@${spec.bareSpec}`\n } else {\n throw error(\n 'Impossible to place a missing, nameless dependency',\n { spec },\n )\n }\n }\n const existing = from.edgesOut.get(spec.name)\n if (existing) {\n const edge = existing as Edge\n if (\n edge.type === type &&\n edge.spec.bareSpec === spec.bareSpec\n ) {\n if (to && to !== edge.to) {\n edge.to = to as Node\n edge.to.edgesIn.add(edge)\n }\n return edge\n }\n this.edges.delete(edge)\n }\n const f = from as Node\n const edgeOut = f.addEdgesTo(type, spec, to as Node | undefined)\n this.edges.add(edgeOut)\n return edgeOut\n }\n\n /**\n * Find an existing node to satisfy a dependency\n */\n findResolution(spec: Spec, fromNode: Node) {\n const f = spec.final\n // if it's a file: dep, then the fromNode location matters\n const fromPref =\n f.type === 'file' ? fromNode.location + ' : ' : ''\n const sf = fromPref + String(f)\n const cached = this.resolutions.get(sf)\n if (cached) return cached\n const nbn = this.nodesByName.get(f.name)\n if (!nbn) return undefined\n for (const node of nbn) {\n if (\n satisfies(\n node.id,\n f,\n fromNode.location,\n this.projectRoot,\n this.monorepo,\n )\n ) {\n this.resolutions.set(sf, node)\n // always set by now, because the node was added at some point\n this.resolutionsReverse.get(node)?.add(sf)\n return node\n }\n }\n }\n\n /**\n * Create a new node in the graph.\n */\n addNode(\n id?: DepID,\n manifest?: Manifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n const node = new Node(\n this.#nodeOptions,\n id,\n manifest,\n spec,\n name,\n version,\n )\n this.nodes.set(node.id, node)\n const nbn = this.nodesByName.get(node.name) ?? new Set()\n nbn.add(node)\n this.nodesByName.set(node.name, nbn)\n if (spec) {\n const f = String(spec.final)\n // if it's a file: type, then that is fromNode-specific,\n // so we can't shortcut add it here.\n if (spec.final.type !== 'file') {\n this.resolutions.set(f, node)\n const rrev = this.resolutionsReverse.get(node) ?? new Set()\n rrev.add(f)\n this.resolutionsReverse.set(node, rrev)\n }\n }\n if (manifest) {\n this.manifests.set(node.id, manifest)\n }\n return node\n }\n\n /**\n * Place a new package into the graph representation, creating the new\n * edges and possibly new nodes that are to be expected when traversing\n * the graph in a top-down direction, e.g: from importers to leafs.\n *\n * For different uses that are not a direct top-down traversal of the graph\n * consider using `addNode()` and `addEdge()` instead.\n */\n placePackage(\n fromNode: Node,\n depType: DependencyTypeShort,\n spec: Spec,\n manifest?: Manifest,\n id?: DepID,\n ) {\n // if no manifest is available, then create an edge that has no\n // reference to any other node, representing a missing dependency\n if (!manifest && !id) {\n this.addEdge(depType, spec, fromNode)\n return\n }\n\n // flags set on the node we're about to create or find.\n const flags = {\n dev: fromNode.dev || depType === 'dev',\n optional:\n fromNode.optional ||\n depType === 'optional' ||\n depType === 'peerOptional',\n }\n\n const depId = id || (manifest && getId(spec, manifest))\n\n /* c8 ignore start - should not be possible */\n if (!depId) {\n throw error('Could not find dep id when placing package', {\n spec,\n manifest,\n })\n }\n /* c8 ignore stop */\n\n // if a node for this package is already represented by a node\n // in the graph, then just creates a new edge to that node\n const toFoundNode = this.nodes.get(depId)\n if (toFoundNode) {\n this.addEdge(depType, spec, fromNode, toFoundNode)\n // the current only stays dev/optional if this dep lets it remain so\n // if it's not already, we don't make it dev or optional.\n toFoundNode.dev &&= flags.dev\n toFoundNode.optional &&= flags.optional\n return toFoundNode\n }\n\n // creates a new node and edges to its parent\n const toNode = this.addNode(depId, manifest)\n toNode.registry = spec.registry\n toNode.dev = flags.dev\n toNode.optional = flags.optional\n this.addEdge(depType, spec, fromNode, toNode)\n return toNode\n }\n\n /**\n * Removes a node and its relevant edges from the graph.\n *\n * If a replacement is provided, then any edges that were previously\n * pointing to the removed node will be directed to the replacement,\n * if it is valid to do so.\n */\n removeNode(node: Node, replacement?: Node) {\n this.nodes.delete(node.id)\n const nbn = this.nodesByName.get(node.name)\n // if it's the last one, just remove the set\n if (nbn?.size === 1) this.nodesByName.delete(node.name)\n else nbn?.delete(node)\n for (const r of this.resolutionsReverse.get(node) ?? new Set()) {\n this.resolutions.delete(r)\n }\n this.resolutionsReverse.delete(node)\n this.manifests.delete(node.id)\n for (const edge of node.edgesOut.values()) {\n this.edges.delete(edge)\n }\n for (const edge of node.edgesIn) {\n if (\n replacement &&\n satisfies(\n replacement.id,\n edge.spec,\n edge.from.location,\n this.projectRoot,\n this.monorepo,\n )\n ) {\n edge.to = replacement\n } else {\n edge.from.edgesOut.delete(edge.spec.name)\n this.edges.delete(edge)\n }\n }\n }\n\n toJSON() {\n return lockfileData({\n ...this.#options,\n graph: this,\n saveManifests: true,\n })\n }\n\n [kCustomInspect](_: number, options: InspectOptions) {\n const data = this.toJSON()\n return `${this[Symbol.toStringTag]} ${inspect(data, options)}`\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAInC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAIhC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D,kEAAkE;AAClE,qEAAqE;AACrE,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;AAI/C,MAAM,MAAM,GAAG,CAA0B,CAAK,EAAE,EAAE,C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G,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAA;IAChE,CAAC;CACF","sourcesContent":["import { getId, joinDepIDTuple } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport { satisfies } from '@vltpkg/satisfies'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { Manifest, DependencyTypeShort } from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport type { Edge } from './edge.ts'\nimport { lockfileData } from './lockfile/save.ts'\nimport { Node } from './node.ts'\nimport type { NodeOptions } from './node.ts'\nimport type { GraphLike, NodeLike } from './types.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\n// this is always the same, but we don't hard code it as a string,\n// in case the DepID module needs to change its delimiter again ever.\nconst mainDepID = joinDepIDTuple(['file', '.'])\n\nexport type ManifestInventory = Map<DepID, Manifest>\n\nconst getMap = <T extends Map<any, any>>(m?: T) =>\n m ?? (new Map() as T)\n\nexport type GraphOptions = SpecOptions & {\n /**\n * The main importer manifest info.\n */\n mainManifest: Manifest\n /**\n * An inventory of seen manifests.\n */\n manifests?: ManifestInventory\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * Root of the project this graph represents\n */\n projectRoot: string\n}\n\nexport class Graph implements GraphLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Graph'\n }\n\n #options: GraphOptions\n\n #nodeOptions: NodeOptions\n\n /**\n * A {@link Monorepo} instance, used for managing workspaces.\n */\n monorepo?: Monorepo\n\n /**\n * An inventory with all manifests related to an install.\n */\n manifests: ManifestInventory\n\n /**\n * A set of all edges in this graph.\n */\n edges = new Set<Edge>()\n\n /**\n * Map registered dep ids to the node that represent them in the graph.\n */\n nodes = new Map<DepID, Node>()\n\n /**\n * Map of nodes by their name\n */\n nodesByName = new Map<string, Set<Node>>()\n\n /**\n * Cached resolutions for spec lookups\n */\n resolutions = new Map<string, Node>()\n\n /**\n * Reverse map of resolutions\n */\n resolutionsReverse = new Map<Node, Set<string>>()\n\n /**\n * A set of importer nodes in this graph.\n */\n importers = new Set<Node>()\n\n /**\n * The {@link Node} that represents the project root `package.json`.\n */\n mainImporter: Node\n\n /**\n * A set of extraneous dependencies found when building the graph.\n */\n extraneousDependencies = new Set<Edge>()\n\n /**\n * The root of the project this graph represents\n */\n projectRoot: string\n\n constructor(options: GraphOptions) {\n const { mainManifest, monorepo } = options\n this.#options = options\n this.manifests = getMap(options.manifests)\n this.projectRoot = options.projectRoot\n this.#nodeOptions = {\n ...this.#options,\n graph: this,\n }\n\n // add the project root node\n const mainImporterLocation = '.'\n const mainImporterSpec = Spec.parse(\n mainManifest.name || '(root)',\n mainImporterLocation,\n )\n const mainImporter = this.addNode(\n mainDepID,\n mainManifest,\n mainImporterSpec,\n )\n mainImporter.setImporterLocation(mainImporterLocation)\n mainImporter.mainImporter = true\n this.mainImporter = mainImporter\n this.importers.add(mainImporter)\n this.manifests.set(mainImporter.id, mainManifest)\n\n // uses the monorepo instance in order to retrieve info on\n // workspaces and create importer nodes for each of them\n this.monorepo = monorepo\n if (this.monorepo) {\n for (const ws of this.monorepo) {\n const wsNode = this.addNode(\n ws.id,\n ws.manifest,\n undefined,\n ws.name,\n )\n wsNode.setImporterLocation(`./${ws.path}`)\n if (wsNode.manifest) {\n this.manifests.set(wsNode.id, wsNode.manifest)\n }\n this.importers.add(wsNode)\n }\n }\n }\n\n /**\n * Delete all nodes that are unreachable from the importers.\n * The collection of deleted nodes is returned.\n *\n * NOTE: This can be extremely slow for large graphs, and is almost always\n * unnecessary! Only call when it is known that some unreachable nodes may\n * have been created, for example when deleting the unneeded subgraph when an\n * optional node fails to resolve/install.\n */\n gc() {\n const { nodes } = this\n this.nodes = new Map()\n const marked = new Set(this.importers)\n for (const imp of marked) {\n // don't delete the importer!\n nodes.delete(imp.id)\n this.nodes.set(imp.id, imp)\n for (const { to } of imp.edgesOut.values()) {\n if (!to || marked.has(to)) continue\n marked.add(to)\n nodes.delete(to.id)\n this.nodes.set(to.id, to)\n }\n }\n for (const node of nodes.values()) {\n this.removeNode(node)\n }\n return nodes\n }\n\n /**\n * Create a new edge between two nodes of the graph in case both exist,\n * in case the destination node does not exists, then a dangling edge,\n * pointing to nothing will be created to represent that missing dependency.\n */\n addEdge(\n type: DependencyTypeShort,\n spec: Spec,\n from: NodeLike,\n to?: NodeLike,\n ) {\n // fix any nameless spec\n if (spec.name === '(unknown)') {\n if (to) {\n spec.name = to.name /* c8 ignore next */ || '(unknown)'\n spec.spec = `${to.name}@${spec.bareSpec}`\n } else {\n throw error(\n 'Impossible to place a missing, nameless dependency',\n { spec },\n )\n }\n }\n const existing = from.edgesOut.get(spec.name)\n if (existing) {\n const edge = existing as Edge\n if (\n edge.type === type &&\n edge.spec.bareSpec === spec.bareSpec\n ) {\n if (to && to !== edge.to) {\n edge.to = to as Node\n edge.to.edgesIn.add(edge)\n }\n return edge\n }\n this.edges.delete(edge)\n }\n const f = from as Node\n const edgeOut = f.addEdgesTo(type, spec, to as Node | undefined)\n this.edges.add(edgeOut)\n return edgeOut\n }\n\n /**\n * Find an existing node to satisfy a dependency\n */\n findResolution(spec: Spec, fromNode: Node) {\n const f = spec.final\n // if it's a file: dep, then the fromNode location matters\n const fromPref =\n f.type === 'file' ? fromNode.location + ' : ' : ''\n const sf = fromPref + String(f)\n const cached = this.resolutions.get(sf)\n if (cached) return cached\n const nbn = this.nodesByName.get(f.name)\n if (!nbn) return undefined\n for (const node of nbn) {\n if (\n satisfies(\n node.id,\n f,\n fromNode.location,\n this.projectRoot,\n this.monorepo,\n )\n ) {\n this.resolutions.set(sf, node)\n // always set by now, because the node was added at some point\n this.resolutionsReverse.get(node)?.add(sf)\n return node\n }\n }\n }\n\n /**\n * Create a new node in the graph.\n */\n addNode(\n id?: DepID,\n manifest?: Manifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n const node = new Node(\n this.#nodeOptions,\n id,\n manifest,\n spec,\n name,\n version,\n )\n this.nodes.set(node.id, node)\n const nbn = this.nodesByName.get(node.name) ?? new Set()\n nbn.add(node)\n this.nodesByName.set(node.name, nbn)\n if (spec) {\n const f = String(spec.final)\n // if it's a file: type, then that is fromNode-specific,\n // so we can't shortcut add it here.\n if (spec.final.type !== 'file') {\n this.resolutions.set(f, node)\n const rrev = this.resolutionsReverse.get(node) ?? new Set()\n rrev.add(f)\n this.resolutionsReverse.set(node, rrev)\n }\n }\n if (manifest) {\n this.manifests.set(node.id, manifest)\n }\n return node\n }\n\n /**\n * Place a new package into the graph representation, creating the new\n * edges and possibly new nodes that are to be expected when traversing\n * the graph in a top-down direction, e.g: from importers to leafs.\n *\n * For different uses that are not a direct top-down traversal of the graph\n * consider using `addNode()` and `addEdge()` instead.\n */\n placePackage(\n fromNode: Node,\n depType: DependencyTypeShort,\n spec: Spec,\n manifest?: Manifest,\n id?: DepID,\n ) {\n // if no manifest is available, then create an edge that has no\n // reference to any other node, representing a missing dependency\n if (!manifest && !id) {\n this.addEdge(depType, spec, fromNode)\n return\n }\n\n // flags set on the node we're about to create or find.\n const flags = {\n dev: fromNode.dev || depType === 'dev',\n optional:\n fromNode.optional ||\n depType === 'optional' ||\n depType === 'peerOptional',\n }\n\n const depId = id || (manifest && getId(spec, manifest))\n\n /* c8 ignore start - should not be possible */\n if (!depId) {\n throw error('Could not find dep id when placing package', {\n spec,\n manifest,\n })\n }\n /* c8 ignore stop */\n\n // if a node for this package is already represented by a node\n // in the graph, then just creates a new edge to that node\n const toFoundNode = this.nodes.get(depId)\n if (toFoundNode) {\n this.addEdge(depType, spec, fromNode, toFoundNode)\n // the current only stays dev/optional if this dep lets it remain so\n // if it's not already, we don't make it dev or optional.\n toFoundNode.dev &&= flags.dev\n toFoundNode.optional &&= flags.optional\n return toFoundNode\n }\n\n // creates a new node and edges to its parent\n const toNode = this.addNode(depId, manifest)\n toNode.registry = spec.registry\n toNode.dev = flags.dev\n toNode.optional = flags.optional\n this.addEdge(depType, spec, fromNode, toNode)\n return toNode\n }\n\n /**\n * Removes a node and its relevant edges from the graph.\n *\n * If a replacement is provided, then any edges that were previously\n * pointing to the removed node will be directed to the replacement,\n * if it is valid to do so.\n */\n removeNode(node: Node, replacement?: Node) {\n this.nodes.delete(node.id)\n const nbn = this.nodesByName.get(node.name)\n // if it's the last one, just remove the set\n if (nbn?.size === 1) this.nodesByName.delete(node.name)\n else nbn?.delete(node)\n for (const r of this.resolutionsReverse.get(node) ?? new Set()) {\n this.resolutions.delete(r)\n }\n this.resolutionsReverse.delete(node)\n this.manifests.delete(node.id)\n for (const edge of node.edgesOut.values()) {\n this.edges.delete(edge)\n }\n for (const edge of node.edgesIn) {\n if (\n replacement &&\n satisfies(\n replacement.id,\n edge.spec,\n edge.from.location,\n this.projectRoot,\n this.monorepo,\n )\n ) {\n edge.to = replacement\n } else {\n edge.from.edgesOut.delete(edge.spec.name)\n this.edges.delete(edge)\n }\n }\n }\n\n toJSON() {\n return lockfileData({\n ...this.#options,\n graph: this,\n saveManifests: true,\n })\n }\n\n [kCustomInspect](_: number, options: InspectOptions) {\n const data = this.toJSON()\n return `${this[Symbol.toStringTag]} ${inspect(data, options)}`\n }\n}\n"]}
|
package/dist/esm/install.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PackageInfoClient } from '@vltpkg/package-info';
|
|
2
2
|
import type { PackageJson } from '@vltpkg/package-json';
|
|
3
3
|
import type { LoadOptions } from './actual/load.ts';
|
|
4
4
|
import type { AddImportersDependenciesMap } from './dependencies.ts';
|
|
5
|
-
export type InstallOptions =
|
|
5
|
+
export type InstallOptions = LoadOptions & {
|
|
6
6
|
projectRoot: string;
|
|
7
7
|
packageJson: PackageJson;
|
|
8
|
+
packageInfo: PackageInfoClient;
|
|
8
9
|
};
|
|
9
10
|
export declare const install: (options: InstallOptions, add?: AddImportersDependenciesMap) => Promise<{
|
|
10
11
|
graph: import("./graph.ts").Graph;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/install.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA;AAIpE,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,WAAW,CAAA;IACxB,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAED,eAAO,MAAM,OAAO,YACT,cAAc,QACjB,2BAA2B;;;EAwBlC,CAAA"}
|
package/dist/esm/install.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PackageInfoClient } from '@vltpkg/package-info';
|
|
2
1
|
import { load as actualLoad } from "./actual/load.js";
|
|
3
2
|
import { build as idealBuild } from "./ideal/build.js";
|
|
4
3
|
import { reify } from "./reify/index.js";
|
|
@@ -9,7 +8,6 @@ export const install = async (options, add) => {
|
|
|
9
8
|
add,
|
|
10
9
|
mainManifest,
|
|
11
10
|
loadManifests: true,
|
|
12
|
-
packageInfo: new PackageInfoClient(options),
|
|
13
11
|
});
|
|
14
12
|
const act = actualLoad({
|
|
15
13
|
...options,
|
|
@@ -18,7 +16,6 @@ export const install = async (options, add) => {
|
|
|
18
16
|
});
|
|
19
17
|
const diff = await reify({
|
|
20
18
|
...options,
|
|
21
|
-
packageInfo: new PackageInfoClient(options),
|
|
22
19
|
add,
|
|
23
20
|
actual: act,
|
|
24
21
|
graph,
|
package/dist/esm/install.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/install.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAQxC,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC1B,OAAuB,EACvB,GAAiC,EACjC,EAAE;IACF,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAElE,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC;QAC7B,GAAG,OAAO;QACV,GAAG;QACH,YAAY;QACZ,aAAa,EAAE,IAAI;KACpB,CAAC,CAAA;IACF,MAAM,GAAG,GAAG,UAAU,CAAC;QACrB,GAAG,OAAO;QACV,YAAY;QACZ,aAAa,EAAE,IAAI;KACpB,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC;QACvB,GAAG,OAAO;QACV,GAAG;QACH,MAAM,EAAE,GAAG;QACX,KAAK;QACL,aAAa,EAAE,IAAI;KACpB,CAAC,CAAA;IAEF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;AACxB,CAAC,CAAA","sourcesContent":["import type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { LoadOptions } from './actual/load.ts'\nimport { load as actualLoad } from './actual/load.ts'\nimport type { AddImportersDependenciesMap } from './dependencies.ts'\nimport { build as idealBuild } from './ideal/build.ts'\nimport { reify } from './reify/index.ts'\n\nexport type InstallOptions = LoadOptions & {\n projectRoot: string\n packageJson: PackageJson\n packageInfo: PackageInfoClient\n}\n\nexport const install = async (\n options: InstallOptions,\n add?: AddImportersDependenciesMap,\n) => {\n const mainManifest = options.packageJson.read(options.projectRoot)\n\n const graph = await idealBuild({\n ...options,\n add,\n mainManifest,\n loadManifests: true,\n })\n const act = actualLoad({\n ...options,\n mainManifest,\n loadManifests: true,\n })\n const diff = await reify({\n ...options,\n add,\n actual: act,\n graph,\n loadManifests: true,\n })\n\n return { graph, diff }\n}\n"]}
|
package/dist/esm/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EAAE,KAAK,EAAc,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,mBAAmB,EACpB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAIrD,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,SAAS,CAAA;CACjB,CAAA;AAED,qBAAa,IAAK,YAAW,QAAQ;;IACnC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;IAMD;;;;;;OAMG;IACH,IAAI,QAAQ,IAGW,OAAO,CAD7B;IACD,IAAI,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAS7B;IAED,UAAU,IAAI,IAAI,IAAI,IAAI,GAAG;QAAE,QAAQ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,CAAA;IAEnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IASjB,IAAI,IAAI,WAIP;IAED;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAQrB;IAED,IAAI,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAM5B;IAED;;OAEG;IACH,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;IAI5C;;;;;;;OAOG;IACH,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;gBAQrC,OAAO,EAAE,WAAW,EACpB,EAAE,CAAC,EAAE,KAAK,EACV,QAAQ,CAAC,EAAE,QAAQ,EACnB,IAAI,CAAC,EAAE,IAAI,EACX,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM;IA2BlB;;;;OAIG;IACH,UAAU,IAAI,OAAO;IAkBrB,MAAM,CAAC,KAAK,EAAE,IAAI;IAIlB;;OAEG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM;IAKpC;;;;OAIG;IACH,WAAW;IAgBX,kBAAkB;IAclB;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI;IAO7D,MAAM;;;;;;;;;;;;;IAgBN,QAAQ;CAGT"}
|
package/dist/esm/node.js
CHANGED
|
@@ -181,6 +181,9 @@ export class Node {
|
|
|
181
181
|
this.manifest = manifest;
|
|
182
182
|
this.#name = name || this.manifest?.name;
|
|
183
183
|
this.version = version || this.manifest?.version;
|
|
184
|
+
if (this.version?.startsWith('v')) {
|
|
185
|
+
this.version = this.version.slice(1);
|
|
186
|
+
}
|
|
184
187
|
}
|
|
185
188
|
/**
|
|
186
189
|
* return true if this node is located in the vlt store
|
package/dist/esm/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAO/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAQnD,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,QAAQ,CAAa;IACrB,SAAS,CAAS;IAElB,SAAS,GAAG,KAAK,CAAA;IACjB;;;;;;OAMG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IACD,IAAI,QAAQ,CAAC,QAAiB;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACxB,8BAA8B;YAC9B,KAAK,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,QAAQ;oBAAE,EAAE,CAAC,QAAQ,GAAG,KAAK,CAAA;YACpD,CAAC;QACH,CAAC;IACH,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IAED,IAAI,GAAG,KAAK,CAAA;IACZ;;;;;OAKG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IACD,IAAI,GAAG,CAAC,GAAY;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AC,IAAI,EAAE,IAAI,CAAC,CAAA;QAClC,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM;QACJ,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAA;IACH,CAAC;IAED,QAAQ;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF","sourcesContent":["import type { PathScurry } from 'path-scurry'\nimport { getId, hydrateTuple, splitDepID } from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { typeError } from '@vltpkg/error-cause'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport type {\n Integrity,\n Manifest,\n DependencyTypeShort,\n} from '@vltpkg/types'\nimport { Edge } from './edge.ts'\nimport type { GraphLike, NodeLike } from './types.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\n\nexport type NodeOptions = SpecOptions & {\n projectRoot: string\n graph: GraphLike\n}\n\nexport class Node implements NodeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Node'\n }\n\n #options: SpecOptions\n #location?: string\n\n #optional = false\n /**\n * True if a node is only reachable via optional or peerOptional edges from\n * any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any optional-flagged non-optional dependencies.\n */\n get optional() {\n return this.#optional\n }\n set optional(optional: boolean) {\n const before = this.#optional\n this.#optional = optional\n if (before && !optional) {\n // unset for all deps, as well\n for (const { to, optional } of this.edgesOut.values()) {\n if (!optional && to?.optional) to.optional = false\n }\n }\n }\n\n isOptional(): this is Node & { optional: true } {\n return this.#optional\n }\n\n #dev = false\n /**\n * True if a node is only reachable via dev edges from any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any dev-flagged non-dev dependencies.\n */\n get dev() {\n return this.#dev\n }\n set dev(dev: boolean) {\n const before = this.#dev\n this.#dev = dev\n if (before && !dev) {\n // unset for all deps, as well\n for (const { to, dev } of this.edgesOut.values()) {\n if (!dev && to?.dev) to.dev = false\n }\n }\n }\n\n isDev(): this is Node & { dev: true } {\n return this.#dev\n }\n\n /**\n * List of edges coming into this node.\n */\n edgesIn = new Set<Edge>()\n\n /**\n * List of edges from this node into other nodes. This usually represents\n * that the connected node is a direct dependency of this node.\n */\n edgesOut = new Map<string, Edge>()\n\n /**\n * A reference to the {@link DepID} this node represents in the graph.\n */\n id: DepID\n\n /**\n * True if this node is an importer node.\n */\n importer = false\n\n /**\n * True if this node is the project root node.\n */\n mainImporter = false\n\n /**\n * A reference to the graph this node is a part of.\n */\n graph: GraphLike\n\n /**\n * The manifest integrity value.\n */\n integrity?: Integrity\n\n /**\n * The manifest this node represents in the graph.\n */\n manifest?: Manifest\n\n /**\n * Project where this node resides\n */\n projectRoot: string\n\n /**\n * For registry nodes, this is the registry we fetched them from.\n * Needed because their un-prefixed dependencies need to come from\n * the same registry, if it's not the default.\n */\n registry?: string\n\n /**\n * The name of the package represented by this node, this is usually\n * equivalent to `manifest.name` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package names instead.\n */\n #name?: string\n get name() {\n if (this.#name) return this.#name\n this.#name = this.id\n return this.#name\n }\n\n /**\n * The version of the package represented by this node, this is usually\n * equivalent to `manifest.version` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package versions instead.\n */\n version?: string\n\n /**\n * An address {@link PackageInfoClient} may use to extract this package.\n */\n resolved?: string\n\n /**\n * The file system location for this node.\n */\n get location(): string {\n if (this.#location) {\n return this.#location\n }\n this.#location = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n // if using the default location, it is in the store\n this.inVltStore = () => true\n return this.#location\n }\n\n set location(location: string) {\n this.#location = location\n // reset memoization, since it might be elsewhere now\n if (this.inVltStore !== Node.prototype.inVltStore) {\n this.inVltStore = Node.prototype.inVltStore\n }\n }\n\n /**\n * The resolved location of the node in the file system.\n */\n resolvedLocation(scurry: PathScurry): string {\n return scurry.cwd.resolve(this.location).fullpath()\n }\n\n /**\n * The location of the node_modules folder where this node's edgesOut\n * should be linked into. For nodes in the store, this is the parent\n * directory, since they're extracted into a node_modules folder\n * side by side with links to their deps. For nodes outside of the store\n * (ie, importers and arbitrary link deps) this is the node_modules folder\n * directly inside the node's directory.\n */\n nodeModules(scurry: PathScurry): string {\n const loc = this.resolvedLocation(scurry)\n return this.inVltStore() ?\n loc.substring(0, loc.length - this.name.length - 1)\n : scurry.resolve(loc, 'node_modules')\n }\n\n constructor(\n options: NodeOptions,\n id?: DepID,\n manifest?: Manifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n this.#options = options\n this.projectRoot = options.projectRoot\n if (id) {\n this.id = id\n } else {\n if (!manifest || !spec) {\n throw typeError(\n 'A new Node needs either a manifest & spec or an id parameter',\n {\n manifest,\n },\n )\n }\n this.id = getId(spec, manifest)\n }\n this.graph = options.graph\n this.manifest = manifest\n this.#name = name || this.manifest?.name\n this.version = version || this.manifest?.version\n }\n\n /**\n * return true if this node is located in the vlt store\n * memoized the first time it's called, since the store location\n * doesn't change within the context of a single operation.\n */\n inVltStore(): boolean {\n // technically this just means it's in *a* vlt store, but we can safely\n // assume that a user won't construct a path like this by accident,\n // and there's only ever one store in any given project.\n const inStore = this.location.endsWith(\n `.vlt/${this.id}/node_modules/${this.name}`,\n )\n this.inVltStore = () => inStore\n return inStore\n }\n\n #registryNodeResolved(tuple: DepIDTuple) {\n const spec = hydrateTuple(tuple, this.#name, this.#options)\n this.resolved =\n this.manifest?.dist?.tarball || spec.conventionalRegistryTarball\n this.integrity ??= this.manifest?.dist?.integrity\n }\n\n equals(other: Node) {\n return this.id === other.id && this.location === other.location\n }\n\n /**\n * Sets the node as an importer along with its location.\n */\n setImporterLocation(location: string) {\n this.#location = location\n this.importer = true\n }\n\n /**\n * Sets the appropriate resolve / integrity value for this node.\n * Note that other places might also set these values, like for\n * example the lockfile that might have already have this info.\n */\n setResolved() {\n // file | remote | workspace type of ids all points to a URI that\n // can be used as the `resolved` value, so we split the dep id\n // for these cases.\n const tuple = splitDepID(this.id)\n const [type, resolved] = tuple\n switch (type) {\n case 'registry':\n this.#registryNodeResolved(tuple)\n break\n default:\n this.resolved = resolved\n break\n }\n }\n\n setDefaultLocation() {\n const def = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n\n // only relocate if the location is in node_modules already\n if (\n !this.importer &&\n (!this.#location ||\n (this.#location !== def &&\n /^(?:\\.\\/)?node_modules\\//.test(this.#location)))\n ) {\n this.#location = def\n }\n }\n\n /**\n * Add an edge from this node connecting it to a direct dependency.\n */\n addEdgesTo(type: DependencyTypeShort, spec: Spec, node?: Node) {\n const edge = new Edge(type, spec, this, node)\n node?.edgesIn.add(edge)\n this.edgesOut.set(spec.name, edge)\n return edge\n }\n\n toJSON() {\n return {\n id: this.id,\n name: this.name,\n version: this.version,\n location: this.location,\n importer: this.importer,\n manifest: this.manifest,\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhE,OAAO,E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,CAAA;IACb,CAAC;IAED,MAAM;QACJ,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAA;IACH,CAAC;IAED,QAAQ;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF","sourcesContent":["import type { PathScurry } from 'path-scurry'\nimport { getId, hydrateTuple, splitDepID } from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { typeError } from '@vltpkg/error-cause'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport type {\n Integrity,\n Manifest,\n DependencyTypeShort,\n} from '@vltpkg/types'\nimport { Edge } from './edge.ts'\nimport type { GraphLike, NodeLike } from './types.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\n\nexport type NodeOptions = SpecOptions & {\n projectRoot: string\n graph: GraphLike\n}\n\nexport class Node implements NodeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Node'\n }\n\n #options: SpecOptions\n #location?: string\n\n #optional = false\n /**\n * True if a node is only reachable via optional or peerOptional edges from\n * any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any optional-flagged non-optional dependencies.\n */\n get optional() {\n return this.#optional\n }\n set optional(optional: boolean) {\n const before = this.#optional\n this.#optional = optional\n if (before && !optional) {\n // unset for all deps, as well\n for (const { to, optional } of this.edgesOut.values()) {\n if (!optional && to?.optional) to.optional = false\n }\n }\n }\n\n isOptional(): this is Node & { optional: true } {\n return this.#optional\n }\n\n #dev = false\n /**\n * True if a node is only reachable via dev edges from any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any dev-flagged non-dev dependencies.\n */\n get dev() {\n return this.#dev\n }\n set dev(dev: boolean) {\n const before = this.#dev\n this.#dev = dev\n if (before && !dev) {\n // unset for all deps, as well\n for (const { to, dev } of this.edgesOut.values()) {\n if (!dev && to?.dev) to.dev = false\n }\n }\n }\n\n isDev(): this is Node & { dev: true } {\n return this.#dev\n }\n\n /**\n * List of edges coming into this node.\n */\n edgesIn = new Set<Edge>()\n\n /**\n * List of edges from this node into other nodes. This usually represents\n * that the connected node is a direct dependency of this node.\n */\n edgesOut = new Map<string, Edge>()\n\n /**\n * A reference to the {@link DepID} this node represents in the graph.\n */\n id: DepID\n\n /**\n * True if this node is an importer node.\n */\n importer = false\n\n /**\n * True if this node is the project root node.\n */\n mainImporter = false\n\n /**\n * A reference to the graph this node is a part of.\n */\n graph: GraphLike\n\n /**\n * The manifest integrity value.\n */\n integrity?: Integrity\n\n /**\n * The manifest this node represents in the graph.\n */\n manifest?: Manifest\n\n /**\n * Project where this node resides\n */\n projectRoot: string\n\n /**\n * For registry nodes, this is the registry we fetched them from.\n * Needed because their un-prefixed dependencies need to come from\n * the same registry, if it's not the default.\n */\n registry?: string\n\n /**\n * The name of the package represented by this node, this is usually\n * equivalent to `manifest.name` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package names instead.\n */\n #name?: string\n get name() {\n if (this.#name) return this.#name\n this.#name = this.id\n return this.#name\n }\n\n /**\n * The version of the package represented by this node, this is usually\n * equivalent to `manifest.version` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package versions instead.\n */\n version?: string\n\n /**\n * An address {@link PackageInfoClient} may use to extract this package.\n */\n resolved?: string\n\n /**\n * The file system location for this node.\n */\n get location(): string {\n if (this.#location) {\n return this.#location\n }\n this.#location = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n // if using the default location, it is in the store\n this.inVltStore = () => true\n return this.#location\n }\n\n set location(location: string) {\n this.#location = location\n // reset memoization, since it might be elsewhere now\n if (this.inVltStore !== Node.prototype.inVltStore) {\n this.inVltStore = Node.prototype.inVltStore\n }\n }\n\n /**\n * The resolved location of the node in the file system.\n */\n resolvedLocation(scurry: PathScurry): string {\n return scurry.cwd.resolve(this.location).fullpath()\n }\n\n /**\n * The location of the node_modules folder where this node's edgesOut\n * should be linked into. For nodes in the store, this is the parent\n * directory, since they're extracted into a node_modules folder\n * side by side with links to their deps. For nodes outside of the store\n * (ie, importers and arbitrary link deps) this is the node_modules folder\n * directly inside the node's directory.\n */\n nodeModules(scurry: PathScurry): string {\n const loc = this.resolvedLocation(scurry)\n return this.inVltStore() ?\n loc.substring(0, loc.length - this.name.length - 1)\n : scurry.resolve(loc, 'node_modules')\n }\n\n constructor(\n options: NodeOptions,\n id?: DepID,\n manifest?: Manifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n this.#options = options\n this.projectRoot = options.projectRoot\n if (id) {\n this.id = id\n } else {\n if (!manifest || !spec) {\n throw typeError(\n 'A new Node needs either a manifest & spec or an id parameter',\n {\n manifest,\n },\n )\n }\n this.id = getId(spec, manifest)\n }\n this.graph = options.graph\n this.manifest = manifest\n this.#name = name || this.manifest?.name\n\n this.version = version || this.manifest?.version\n if (this.version?.startsWith('v')) {\n this.version = this.version.slice(1)\n }\n }\n\n /**\n * return true if this node is located in the vlt store\n * memoized the first time it's called, since the store location\n * doesn't change within the context of a single operation.\n */\n inVltStore(): boolean {\n // technically this just means it's in *a* vlt store, but we can safely\n // assume that a user won't construct a path like this by accident,\n // and there's only ever one store in any given project.\n const inStore = this.location.endsWith(\n `.vlt/${this.id}/node_modules/${this.name}`,\n )\n this.inVltStore = () => inStore\n return inStore\n }\n\n #registryNodeResolved(tuple: DepIDTuple) {\n const spec = hydrateTuple(tuple, this.#name, this.#options)\n this.resolved =\n this.manifest?.dist?.tarball || spec.conventionalRegistryTarball\n this.integrity ??= this.manifest?.dist?.integrity\n }\n\n equals(other: Node) {\n return this.id === other.id && this.location === other.location\n }\n\n /**\n * Sets the node as an importer along with its location.\n */\n setImporterLocation(location: string) {\n this.#location = location\n this.importer = true\n }\n\n /**\n * Sets the appropriate resolve / integrity value for this node.\n * Note that other places might also set these values, like for\n * example the lockfile that might have already have this info.\n */\n setResolved() {\n // file | remote | workspace type of ids all points to a URI that\n // can be used as the `resolved` value, so we split the dep id\n // for these cases.\n const tuple = splitDepID(this.id)\n const [type, resolved] = tuple\n switch (type) {\n case 'registry':\n this.#registryNodeResolved(tuple)\n break\n default:\n this.resolved = resolved\n break\n }\n }\n\n setDefaultLocation() {\n const def = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n\n // only relocate if the location is in node_modules already\n if (\n !this.importer &&\n (!this.#location ||\n (this.#location !== def &&\n /^(?:\\.\\/)?node_modules\\//.test(this.#location)))\n ) {\n this.#location = def\n }\n }\n\n /**\n * Add an edge from this node connecting it to a direct dependency.\n */\n addEdgesTo(type: DependencyTypeShort, spec: Spec, node?: Node) {\n const edge = new Edge(type, spec, this, node)\n node?.edgesIn.add(edge)\n this.edgesOut.set(spec.name, edge)\n return edge\n }\n\n toJSON() {\n return {\n id: this.id,\n name: this.name,\n version: this.version,\n location: this.location,\n importer: this.importer,\n manifest: this.manifest,\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mkdir, symlink } from 'fs/promises';
|
|
2
|
-
import { dirname, relative } from 'path';
|
|
1
|
+
import { mkdir, symlink } from 'node:fs/promises';
|
|
2
|
+
import { dirname, relative } from 'node:path';
|
|
3
3
|
import { binPaths } from "./bin-paths.js";
|
|
4
4
|
const clobberSymlink = async (target, link, remover, type = 'file') => {
|
|
5
5
|
await mkdir(dirname(link), { recursive: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-edge.js","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"add-edge.js","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAG7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,MAAM,cAAc,GAAG,KAAK,EAC1B,MAAc,EACd,IAAY,EACZ,OAAuB,EACvB,IAAI,GAAG,MAAM,EACb,EAAE;IACF,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC/C,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACnC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,EAAE,GAAG,CAA0B,CAAA;QACrC,IAAI,EAAE,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACzB,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;YACzD,qBAAqB;QACvB,CAAC;aAAM,CAAC;YACN,MAAM,EAAE,CAAA;QACV,CAAC;IACH,CAAC;IACD,oBAAoB;AACtB,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,O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pkg/rollback-remove'\nimport type { Manifest } from '@vltpkg/types'\nimport { mkdir, symlink } from 'node:fs/promises'\nimport { dirname, relative } from 'node:path'\nimport type { PathScurry } from 'path-scurry'\nimport type { Edge } from '../edge.ts'\nimport { binPaths } from './bin-paths.ts'\n\nconst clobberSymlink = async (\n target: string,\n link: string,\n remover: RollbackRemove,\n type = 'file',\n) => {\n await mkdir(dirname(link), { recursive: true })\n try {\n await symlink(target, link, type)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (er.code === 'EEXIST') {\n return remover.rm(link).then(() => symlink(target, link))\n /* c8 ignore start */\n } else {\n throw er\n }\n }\n /* c8 ignore stop */\n}\n\n/**\n * reify an edge into a node_modules folder, with bins linked\n * this does NOT chmod the bins to 0o777, because they might not exist\n * until scripts are run, in the case of non-store deps like workspaces\n */\nexport const addEdge = async (\n edge: Edge,\n manifest: Manifest,\n scurry: PathScurry,\n remover: RollbackRemove,\n) => {\n if (!edge.to) return\n const binRoot = scurry.resolve(\n edge.from.nodeModules(scurry),\n '.bin',\n )\n const path = scurry.resolve(\n edge.from.nodeModules(scurry),\n edge.spec.name,\n )\n const promises: Promise<unknown>[] = []\n const target = relative(\n dirname(path),\n edge.to.resolvedLocation(scurry),\n )\n promises.push(clobberSymlink(target, path, remover, 'dir'))\n const bp = binPaths(manifest)\n for (const [key, val] of Object.entries(bp)) {\n const link = scurry.resolve(binRoot, key)\n const target = relative(binRoot, scurry.resolve(path, val))\n // TODO: bash/cmd/pwsh shims on Windows\n promises.push(clobberSymlink(target, link, remover))\n }\n await Promise.all(promises)\n}\n"]}
|
package/dist/esm/reify/build.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// at the end, we get back to the importers, and run their prepare
|
|
3
3
|
// script as well as install script.
|
|
4
4
|
import { run } from '@vltpkg/run';
|
|
5
|
-
import { statSync } from 'fs';
|
|
6
|
-
import { chmod } from 'fs/promises';
|
|
5
|
+
import { statSync } from 'node:fs';
|
|
6
|
+
import { chmod } from 'node:fs/promises';
|
|
7
7
|
import { graphRun } from 'graph-run';
|
|
8
8
|
import { nonEmptyList } from "../non-empty-list.js";
|
|
9
9
|
import { binPaths } from "./bin-paths.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/reify/build.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAClE,oCAAoC;AAGpC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/reify/build.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAClE,oCAAoC;AAGpC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAIpC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EACxB,IAAU,EACV,WAAwB,EACxB,MAAkB,EAClB,EAAE;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,CAAA;IACrB,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAA;IAChD,4DAA4D;IAC5D,IAAI,CAAC,KAAK;QAAE,OAAM;IAElB,MAAM,QAAQ,CAAgB;QAC5B,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,KAAK,EAAE,IAAU,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;YACxC,2DAA2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AACpE,IAAI,QAAQ,GAAG,CAAC,CAAA;AAChB,MAAM,cAAc,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC5C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAA;IAClD,CAAC;IACD,MAAM,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["// walk the graph of added nodes, building and chmoding their bins\n// at the end, we get back to the importers, and run their prepare\n// script as well as install script.\n\nimport type { PackageJson } from '@vltpkg/package-json'\nimport { run } from '@vltpkg/run'\nimport { statSync } from 'node:fs'\nimport { chmod } from 'node:fs/promises'\nimport { graphRun } from 'graph-run'\nimport type { PathScurry } from 'path-scurry'\nimport type { Diff } from '../diff.ts'\nimport type { Node } from '../node.ts'\nimport { nonEmptyList } from '../non-empty-list.ts'\nimport { binPaths } from './bin-paths.ts'\nimport { optionalFail } from './optional-fail.ts'\n\nexport const build = async (\n diff: Diff,\n packageJson: PackageJson,\n scurry: PathScurry,\n) => {\n const graph = diff.to\n const nodes = nonEmptyList([...graph.importers])\n /* c8 ignore next - all graphs have at least one importer */\n if (!nodes) return\n\n await graphRun<Node, unknown>({\n graph: nodes,\n visit: async (node: Node, signal, path) => {\n // if it's not an importer or an added node, nothing to do.\n // TODO: only build importers if it has changed deps, there's never\n // been a previous build, or it contains something newer than the\n // most recent build.\n // For now, just always build all importers, because we don't\n // track all that other stuff.\n if (!node.importer && !diff.nodes.add.has(node)) return\n\n await visit(packageJson, scurry, node, signal, path).then(\n x => x,\n optionalFail(diff, node),\n )\n },\n\n getDeps: node => {\n const deps: Node[] = []\n for (const { to } of node.edgesOut.values()) {\n /* c8 ignore next - vanishingly unlikely in practice */\n if (to) deps.push(to)\n }\n return deps\n },\n })\n}\n\nconst visit = async (\n packageJson: PackageJson,\n scurry: PathScurry,\n node: Node,\n signal: AbortSignal,\n _path: Node[],\n): Promise<void> => {\n node.manifest ??= packageJson.read(node.resolvedLocation(scurry))\n const { manifest } = node\n const { scripts = {} } = manifest\n\n const {\n install,\n preinstall,\n postinstall,\n prepare,\n preprepare,\n postprepare,\n } = scripts\n\n // if it has install script, run it\n const runInstall = !!(install || preinstall || postinstall)\n if (runInstall) {\n await run({\n signal,\n arg0: 'install',\n ignoreMissing: true,\n packageJson,\n cwd: node.resolvedLocation(scurry),\n projectRoot: node.projectRoot,\n manifest,\n })\n }\n\n // if it's an importer or git, run prepare\n const prepable =\n node.id.startsWith('git') || node.importer || !node.inVltStore()\n const runPrepare =\n !!(prepare || preprepare || postprepare) && prepable\n\n if (runPrepare) {\n await run({\n signal,\n arg0: 'prepare',\n ignoreMissing: true,\n packageJson,\n cwd: node.resolvedLocation(scurry),\n projectRoot: node.projectRoot,\n manifest,\n })\n }\n\n const chmods: Promise<unknown>[] = []\n for (const bin of Object.values(binPaths(manifest))) {\n const path = scurry.resolve(\n `${node.resolvedLocation(scurry)}/${bin}`,\n )\n chmods.push(makeExecutable(path))\n }\n await Promise.all(chmods)\n}\n\n// 0 is \"not yet set\"\n// This is defined by doing `0o111 | <mode>` so that systems\n// that create files group-writable result in 0o775 instead of 0o755\nlet execMode = 0\nconst makeExecutable = async (path: string) => {\n if (!execMode) {\n execMode = (statSync(path).mode & 0o777) | 0o111\n }\n await chmod(path, execMode)\n}\n"]}
|
package/dist/esm/uninstall.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PackageInfoClient } from '@vltpkg/package-info';
|
|
2
2
|
import type { PackageJson } from '@vltpkg/package-json';
|
|
3
3
|
import type { LoadOptions } from './actual/load.ts';
|
|
4
4
|
import type { RemoveImportersDependenciesMap } from './dependencies.ts';
|
|
5
|
-
export type UninstallOptions =
|
|
5
|
+
export type UninstallOptions = LoadOptions & {
|
|
6
6
|
projectRoot: string;
|
|
7
7
|
packageJson: PackageJson;
|
|
8
|
+
packageInfo: PackageInfoClient;
|
|
8
9
|
};
|
|
9
10
|
export declare const uninstall: (options: UninstallOptions, remove?: RemoveImportersDependenciesMap) => Promise<{
|
|
10
11
|
graph: import("./graph.ts").Graph;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uninstall.d.ts","sourceRoot":"","sources":["../../src/uninstall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"uninstall.d.ts","sourceRoot":"","sources":["../../src/uninstall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAA;AAIvE,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAC3C,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,WAAW,CAAA;IACxB,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAED,eAAO,MAAM,SAAS,YACX,gBAAgB,WAChB,8BAA8B;;;EAwBxC,CAAA"}
|
package/dist/esm/uninstall.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PackageInfoClient } from '@vltpkg/package-info';
|
|
2
1
|
import { load as actualLoad } from "./actual/load.js";
|
|
3
2
|
import { build as idealBuild } from "./ideal/build.js";
|
|
4
3
|
import { reify } from "./reify/index.js";
|
|
@@ -6,7 +5,6 @@ export const uninstall = async (options, remove) => {
|
|
|
6
5
|
const mainManifest = options.packageJson.read(options.projectRoot);
|
|
7
6
|
const graph = await idealBuild({
|
|
8
7
|
...options,
|
|
9
|
-
packageInfo: new PackageInfoClient(options),
|
|
10
8
|
remove,
|
|
11
9
|
mainManifest,
|
|
12
10
|
loadManifests: true,
|
|
@@ -18,7 +16,6 @@ export const uninstall = async (options, remove) => {
|
|
|
18
16
|
});
|
|
19
17
|
const diff = await reify({
|
|
20
18
|
...options,
|
|
21
|
-
packageInfo: new PackageInfoClient(options),
|
|
22
19
|
remove,
|
|
23
20
|
actual: act,
|
|
24
21
|
graph,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../src/uninstall.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../src/uninstall.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAQxC,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,OAAyB,EACzB,MAAuC,EACvC,EAAE;IACF,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAElE,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC;QAC7B,GAAG,OAAO;QACV,MAAM;QACN,YAAY;QACZ,aAAa,EAAE,IAAI;KACpB,CAAC,CAAA;IACF,MAAM,GAAG,GAAG,UAAU,CAAC;QACrB,GAAG,OAAO;QACV,YAAY;QACZ,aAAa,EAAE,IAAI;KACpB,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC;QACvB,GAAG,OAAO;QACV,MAAM;QACN,MAAM,EAAE,GAAG;QACX,KAAK;QACL,aAAa,EAAE,IAAI;KACpB,CAAC,CAAA;IAEF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;AACxB,CAAC,CAAA","sourcesContent":["import type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { PackageJson } from '@vltpkg/package-json'\nimport type { LoadOptions } from './actual/load.ts'\nimport { load as actualLoad } from './actual/load.ts'\nimport type { RemoveImportersDependenciesMap } from './dependencies.ts'\nimport { build as idealBuild } from './ideal/build.ts'\nimport { reify } from './reify/index.ts'\n\nexport type UninstallOptions = LoadOptions & {\n projectRoot: string\n packageJson: PackageJson\n packageInfo: PackageInfoClient\n}\n\nexport const uninstall = async (\n options: UninstallOptions,\n remove?: RemoveImportersDependenciesMap,\n) => {\n const mainManifest = options.packageJson.read(options.projectRoot)\n\n const graph = await idealBuild({\n ...options,\n remove,\n mainManifest,\n loadManifests: true,\n })\n const act = actualLoad({\n ...options,\n mainManifest,\n loadManifests: true,\n })\n const diff = await reify({\n ...options,\n remove,\n actual: act,\n graph,\n loadManifests: true,\n })\n\n return { graph, diff }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/graph",
|
|
3
3
|
"description": "A library that helps understanding & expressing what happens on an install",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-7",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/vltpkg/vltpkg.git",
|
|
@@ -23,21 +23,19 @@
|
|
|
23
23
|
"graph-run": "^1.0.4",
|
|
24
24
|
"path-scurry": "^2.0.0",
|
|
25
25
|
"promise-call-limit": "^3.0.2",
|
|
26
|
-
"@vltpkg/dep-id": "0.0.0-
|
|
27
|
-
"@vltpkg/
|
|
28
|
-
"@vltpkg/
|
|
29
|
-
"@vltpkg/output": "0.0.0-
|
|
30
|
-
"@vltpkg/package-
|
|
31
|
-
"@vltpkg/
|
|
32
|
-
"@vltpkg/
|
|
33
|
-
"@vltpkg/rollback-remove": "0.0.0-
|
|
34
|
-
"@vltpkg/
|
|
35
|
-
"@vltpkg/
|
|
36
|
-
"@vltpkg/
|
|
37
|
-
"@vltpkg/
|
|
38
|
-
"@vltpkg/spec": "0.0.0-
|
|
39
|
-
"@vltpkg/types": "0.0.0-5",
|
|
40
|
-
"@vltpkg/workspaces": "0.0.0-5"
|
|
26
|
+
"@vltpkg/dep-id": "0.0.0-7",
|
|
27
|
+
"@vltpkg/error-cause": "0.0.0-7",
|
|
28
|
+
"@vltpkg/fast-split": "0.0.0-7",
|
|
29
|
+
"@vltpkg/output": "0.0.0-7",
|
|
30
|
+
"@vltpkg/package-json": "0.0.0-7",
|
|
31
|
+
"@vltpkg/pick-manifest": "0.0.0-7",
|
|
32
|
+
"@vltpkg/package-info": "0.0.0-7",
|
|
33
|
+
"@vltpkg/rollback-remove": "0.0.0-7",
|
|
34
|
+
"@vltpkg/satisfies": "0.0.0-7",
|
|
35
|
+
"@vltpkg/run": "0.0.0-7",
|
|
36
|
+
"@vltpkg/types": "0.0.0-7",
|
|
37
|
+
"@vltpkg/workspaces": "0.0.0-7",
|
|
38
|
+
"@vltpkg/spec": "0.0.0-7"
|
|
41
39
|
},
|
|
42
40
|
"devDependencies": {
|
|
43
41
|
"@eslint/js": "^9.20.0",
|