@vltpkg/graph 1.0.0-rc.5 → 1.0.0-rc.6
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.map +1 -1
- package/dist/esm/actual/load.js +25 -8
- package/dist/esm/actual/load.js.map +1 -1
- package/dist/esm/diff.d.ts +2 -0
- package/dist/esm/diff.d.ts.map +1 -1
- package/dist/esm/edge.d.ts +1 -0
- package/dist/esm/edge.d.ts.map +1 -1
- package/dist/esm/edge.js +4 -0
- package/dist/esm/edge.js.map +1 -1
- package/dist/esm/graph.d.ts +18 -4
- package/dist/esm/graph.d.ts.map +1 -1
- package/dist/esm/graph.js +50 -39
- package/dist/esm/graph.js.map +1 -1
- package/dist/esm/ideal/append-nodes.d.ts +1 -1
- package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/append-nodes.js +146 -64
- package/dist/esm/ideal/append-nodes.js.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts +2 -5
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.js +23 -12
- package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -1
- package/dist/esm/ideal/build.d.ts.map +1 -1
- package/dist/esm/ideal/build.js +0 -2
- package/dist/esm/ideal/build.js.map +1 -1
- package/dist/esm/ideal/get-ordered-dependencies.d.ts +10 -0
- package/dist/esm/ideal/get-ordered-dependencies.d.ts.map +1 -0
- package/dist/esm/ideal/get-ordered-dependencies.js +42 -0
- package/dist/esm/ideal/get-ordered-dependencies.js.map +1 -0
- package/dist/esm/ideal/peers.d.ts +71 -0
- package/dist/esm/ideal/peers.d.ts.map +1 -0
- package/dist/esm/ideal/peers.js +318 -0
- package/dist/esm/ideal/peers.js.map +1 -0
- package/dist/esm/ideal/{add-nodes.d.ts → refresh-ideal-graph.d.ts} +9 -5
- package/dist/esm/ideal/refresh-ideal-graph.d.ts.map +1 -0
- package/dist/esm/ideal/refresh-ideal-graph.js +79 -0
- package/dist/esm/ideal/refresh-ideal-graph.js.map +1 -0
- package/dist/esm/ideal/types.d.ts +65 -1
- package/dist/esm/ideal/types.d.ts.map +1 -1
- package/dist/esm/ideal/types.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 +21 -5
- package/dist/esm/install.js.map +1 -1
- package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
- package/dist/esm/lockfile/load-nodes.js +8 -2
- package/dist/esm/lockfile/load-nodes.js.map +1 -1
- package/dist/esm/lockfile/load.d.ts +0 -4
- package/dist/esm/lockfile/load.d.ts.map +1 -1
- package/dist/esm/lockfile/load.js +4 -29
- package/dist/esm/lockfile/load.js.map +1 -1
- package/dist/esm/node.d.ts +14 -0
- package/dist/esm/node.d.ts.map +1 -1
- package/dist/esm/node.js +16 -0
- package/dist/esm/node.js.map +1 -1
- package/package.json +21 -21
- package/dist/esm/ideal/add-nodes.d.ts.map +0 -1
- package/dist/esm/ideal/add-nodes.js +0 -39
- package/dist/esm/ideal/add-nodes.js.map +0 -1
- package/dist/esm/ideal/remove-nodes.d.ts +0 -7
- package/dist/esm/ideal/remove-nodes.d.ts.map +0 -1
- package/dist/esm/ideal/remove-nodes.js +0 -19
- package/dist/esm/ideal/remove-nodes.js.map +0 -1
package/dist/esm/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;AASnC,OAAO,EAAE,OAAO,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E,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 {\n GraphLike,\n NodeLike,\n NormalizedManifest,\n DependencySaveType,\n} from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport { lockfileData } from './lockfile/save.ts'\nimport { Edge } from './edge.ts'\nimport { Node } from './node.ts'\nimport type { NodeOptions } from './node.ts'\nimport { resolveSaveType } from './resolve-save-type.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nconst cacheKeySeparator = '│'\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, NormalizedManifest>\n\nconst getMap = <T extends Map<any, any>>(m?: T) =>\n m ?? (new Map() as T)\n\n/**\n * Get a cache key for a resolution based on the\n * spec, location and query modifier.\n */\nconst getResolutionCacheKey = (\n spec: Spec,\n location: string,\n queryModifier: string,\n): string => {\n const f = spec.final\n // if it's a file: dep, then the fromNode location matters\n const fromPrefix = f.type === 'file' ? location + ' : ' : ''\n // the unique key should also precise what is the type of the spec,\n // and in the case of a registry, what registry it is from.\n const typePrecisionKey =\n f.registry ?\n `${cacheKeySeparator}registry` +\n `${cacheKeySeparator}${f.registry}`\n : f.gitRemote ?\n `${cacheKeySeparator}git` + `${cacheKeySeparator}${f.gitRemote}`\n : `${cacheKeySeparator}${f.type}`\n const modifierSuffix = `${cacheKeySeparator}${queryModifier}`\n return fromPrefix + String(f) + typePrecisionKey + modifierSuffix\n}\n\nexport type GraphOptions = SpecOptions & {\n /**\n * The main importer manifest info.\n */\n mainManifest: NormalizedManifest\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.mainImporter.workspaces = new Map()\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 // creates a virtual edge to connect the workspaces to the root node\n const edge = new Edge(\n 'prod',\n Spec.parse(wsNode.name, 'workspace:*', this.#options),\n this.mainImporter,\n wsNode,\n )\n this.mainImporter.workspaces.set(wsNode.name, edge)\n }\n }\n }\n\n /**\n * Delete all nodes and edges 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.edges.clear()\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 edge of imp.edgesOut.values()) {\n this.edges.add(edge)\n const { to } = edge\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: DependencySaveType,\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 // removes this edge from its destination edgesIn ref\n edge.to?.edgesIn.delete(edge)\n // now swap the destination to the new one\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(\n resolveSaveType(from, spec.name, type),\n spec,\n to as Node | undefined,\n )\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, queryModifier = '') {\n const f = spec.final\n const sf = getResolutionCacheKey(\n f,\n fromNode.location,\n queryModifier,\n )\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?: NormalizedManifest,\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 (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: DependencySaveType,\n spec: Spec,\n manifest?: NormalizedManifest,\n id?: DepID,\n extra?: string,\n ): Node | undefined {\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, extra))\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, spec)\n toNode.registry = spec.registry\n toNode.dev = flags.dev\n toNode.optional = flags.optional\n toNode.modifier = extra\n\n // add extra manifest info if available\n if (manifest) {\n const { bin, engines, os, cpu } = manifest\n // add platform info if available\n if (engines || os || cpu) {\n const platform: NodeLike['platform'] = {}\n if (engines) platform.engines = engines\n if (os) platform.os = os\n if (cpu) platform.cpu = cpu\n toNode.platform = platform\n }\n // add bin info if available\n if (bin) {\n toNode.bins = bin\n }\n }\n toNode.maybeSetConfusedManifest(spec, manifest)\n\n this.addEdge(depType, spec, fromNode, toNode)\n\n // populate resolution cache if applicable\n const f = getResolutionCacheKey(\n spec.final,\n fromNode.location,\n extra || '',\n )\n this.resolutions.set(f, toNode)\n const rrev = this.resolutionsReverse.get(toNode) ?? new Set()\n rrev.add(f)\n this.resolutionsReverse.set(toNode, rrev)\n\n return toNode\n }\n\n /**\n * Removes a node and its relevant edges from the graph.\n *\n * Use the `keepEdges` option to keep the edges that were pointing to\n * this node and only removes their `to` property value.\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, keepEdges?: boolean) {\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 if (keepEdges) {\n edge.to = undefined\n } else {\n edge.from.edgesOut.delete(edge.spec.name)\n this.edges.delete(edge)\n }\n }\n }\n\n /**\n * Removes the resolved node of a given edge.\n */\n removeEdgeResolution(edge: Edge, queryModifier = '') {\n const node = edge.to\n const resolutionKey = getResolutionCacheKey(\n edge.spec,\n edge.from.location,\n queryModifier,\n )\n if (node) {\n edge.to = undefined\n this.resolutions.delete(resolutionKey)\n this.resolutionsReverse.get(node)?.delete(resolutionKey)\n this.nodesByName.delete(node.name)\n node.edgesIn.delete(edge)\n if (node.edgesIn.size === 0) {\n this.nodes.delete(node.id)\n }\n }\n }\n\n /**\n * Reset resolution cache data.\n */\n resetResolution() {\n // Clear all cache structures\n this.resolutions.clear()\n this.resolutionsReverse.clear()\n this.nodesByName.clear()\n\n // Rebuild nodesByName from all nodes\n for (const node of this.nodes.values()) {\n const nbn = this.nodesByName.get(node.name) ?? new Set()\n nbn.add(node)\n this.nodesByName.set(node.name, nbn)\n }\n\n // Rebuild resolution caches from all edges that have resolved targets\n const seenNodes = new Set<Node>()\n for (const edge of this.edges) {\n const { to: node } = edge\n if (!node) continue // Skip unresolved edges\n\n // Only process each node once to avoid duplicate cache entries\n if (seenNodes.has(node)) continue\n seenNodes.add(node)\n\n // Initialize resolutionsReverse entry for this node if it doesn't exist\n if (!this.resolutionsReverse.has(node)) {\n this.resolutionsReverse.set(node, new Set())\n }\n\n // Get the modifier if the node has one associated to it\n const queryModifier = node.modifier || ''\n const resolutionKey = getResolutionCacheKey(\n edge.spec.final,\n edge.from.location,\n queryModifier,\n )\n\n this.resolutions.set(resolutionKey, node)\n this.resolutionsReverse.get(node)?.add(resolutionKey)\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,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAElE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AASnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAGxD,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAE7B,kEAAkE;AAClE,qEAAqE;AACrE,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;AAI/C,MAAM,MAAM,GAAG,CAA0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Q;gBAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;YAEvC,oCAAoC;YACpC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;YACrB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QACtB,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, splitExtra } 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 {\n GraphLike,\n NodeLike,\n NormalizedManifest,\n DependencySaveType,\n} from '@vltpkg/types'\nimport type { Monorepo } from '@vltpkg/workspaces'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport { lockfileData } from './lockfile/save.ts'\nimport { Edge } from './edge.ts'\nimport { Node } from './node.ts'\nimport type { NodeOptions } from './node.ts'\nimport { resolveSaveType } from './resolve-save-type.ts'\nimport type { PeerContext } from './ideal/types.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nconst cacheKeySeparator = '│'\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, NormalizedManifest>\n\nconst getMap = <T extends Map<any, any>>(m?: T) =>\n m ?? (new Map() as T)\n\n/**\n * Get a cache key for a resolution based on the\n * spec, location and query modifier.\n */\nconst getResolutionCacheKey = (\n spec: Spec,\n location: string,\n extra: string,\n): string => {\n const f = spec.final\n // if it's a file: dep, then the fromNode location matters\n const fromPrefix = f.type === 'file' ? location + ' : ' : ''\n // the unique key should also precise what is the type of the spec,\n // and in the case of a registry, what registry it is from.\n const typePrecisionKey =\n f.registry ?\n `${cacheKeySeparator}registry` +\n `${cacheKeySeparator}${f.registry}`\n : f.gitRemote ?\n `${cacheKeySeparator}git` + `${cacheKeySeparator}${f.gitRemote}`\n : `${cacheKeySeparator}${f.type}`\n const modifierSuffix = `${cacheKeySeparator}${extra}`\n return fromPrefix + String(f) + typePrecisionKey + modifierSuffix\n}\n\nexport type GraphOptions = SpecOptions & {\n /**\n * The main importer manifest info.\n */\n mainManifest: NormalizedManifest\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 /**\n * The peer context sets used to resolve peer dependencies within this graph.\n */\n peerContexts: PeerContext[]\n\n /**\n * Tracks the current peer context index.\n */\n currentPeerContextIndex = 0\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.mainImporter.workspaces = new Map()\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 // creates a virtual edge to connect the workspaces to the root node\n const edge = new Edge(\n 'prod',\n Spec.parse(wsNode.name, 'workspace:*', this.#options),\n this.mainImporter,\n wsNode,\n )\n this.mainImporter.workspaces.set(wsNode.name, edge)\n }\n }\n\n // initializes the peer context set collection\n const initialPeerContext: PeerContext = new Map()\n initialPeerContext.index = this.currentPeerContextIndex\n this.peerContexts = [initialPeerContext]\n }\n\n /**\n * Get the next peer context index.\n */\n nextPeerContextIndex() {\n return ++this.currentPeerContextIndex\n }\n\n /**\n * Delete all nodes and edges 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.edges.clear()\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 edge of imp.edgesOut.values()) {\n this.edges.add(edge)\n const { to } = edge\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: DependencySaveType,\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 // removes this edge from its destination edgesIn ref\n edge.to?.edgesIn.delete(edge)\n // now swap the destination to the new one\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(\n resolveSaveType(from, spec.name, type),\n spec,\n to as Node | undefined,\n )\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, extra = '') {\n const f = spec.final\n const sf = getResolutionCacheKey(f, fromNode.location, extra)\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?: NormalizedManifest,\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\n // ensure the nodes by name set is always sorted, this will help\n // keeping a deterministic graph resolution when reusing nodes\n const newByNameSet = new Set(\n [...nbn].sort((a, b) => a.id.localeCompare(b.id)),\n )\n this.nodesByName.set(node.name, newByNameSet)\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: DependencySaveType,\n spec: Spec,\n manifest?: NormalizedManifest,\n id?: DepID,\n extra?: string,\n ): Node | undefined {\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, extra))\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.detached = false\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, spec)\n toNode.registry = spec.registry\n toNode.dev = flags.dev\n toNode.optional = flags.optional\n // split extra into modifier and peerSetHash\n if (extra) {\n const { modifier, peerSetHash } = splitExtra(extra)\n toNode.modifier = modifier\n toNode.peerSetHash = peerSetHash\n }\n\n // add extra manifest info if available\n if (manifest) {\n const { bin, engines, os, cpu } = manifest\n // add platform info if available\n if (engines || os || cpu) {\n const platform: NodeLike['platform'] = {}\n if (engines) platform.engines = engines\n if (os) platform.os = os\n if (cpu) platform.cpu = cpu\n toNode.platform = platform\n }\n // add bin info if available\n if (bin) {\n toNode.bins = bin\n }\n }\n toNode.maybeSetConfusedManifest(spec, manifest)\n\n this.addEdge(depType, spec, fromNode, toNode)\n\n // populate resolution cache if applicable\n const f = getResolutionCacheKey(\n spec.final,\n fromNode.location,\n extra || '',\n )\n this.resolutions.set(f, toNode)\n const rrev = this.resolutionsReverse.get(toNode) ?? new Set()\n rrev.add(f)\n this.resolutionsReverse.set(toNode, rrev)\n\n return toNode\n }\n\n /**\n * Removes a node and its relevant edges from the graph.\n *\n * Use the `keepEdges` option to keep the edges that were pointing to\n * this node and only removes their `to` property value.\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, keepEdges?: boolean) {\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 if (keepEdges) {\n edge.to = undefined\n } else {\n edge.from.edgesOut.delete(edge.spec.name)\n this.edges.delete(edge)\n }\n }\n }\n\n /**\n * Removes the resolved node of a given edge.\n */\n removeEdgeResolution(edge: Edge, extra = '') {\n const node = edge.to\n const resolutionKey = getResolutionCacheKey(\n edge.spec,\n edge.from.location,\n extra,\n )\n if (node) {\n edge.to = undefined\n this.resolutions.delete(resolutionKey)\n this.resolutionsReverse.get(node)?.delete(resolutionKey)\n this.nodesByName.delete(node.name)\n node.edgesIn.delete(edge)\n if (node.edgesIn.size === 0) {\n this.nodes.delete(node.id)\n }\n }\n }\n\n /**\n * Remove all edges from the graph while preserving nodes and resolution caches.\n * This allows the graph to be reconstructed efficiently using the existing nodes.\n */\n resetEdges() {\n // Clear the global edges set\n this.edges.clear()\n\n // Clear all node edge relationships\n for (const node of this.nodes.values()) {\n // marking nodes as detached needs to be restricted to only those\n // that had a manifest, otherwise we'd be skipping fetching manifest\n // for nodes we don't have a manifest during the ideal build phase\n if (node.manifest) node.detached = true\n\n // detaches all edges from this node\n node.edgesOut.clear()\n node.edgesIn.clear()\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"]}
|
|
@@ -15,5 +15,5 @@ import type { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
|
15
15
|
* It also applies any modifiers that applies to a given node as it processes
|
|
16
16
|
* and builds the graph.
|
|
17
17
|
*/
|
|
18
|
-
export declare const appendNodes: (
|
|
18
|
+
export declare const appendNodes: (packageInfo: PackageInfoClient, graph: Graph, fromNode: Node, deps: Dependency[], scurry: PathScurry, options: SpecOptions, seen: Set<DepID>, add?: Map<string, Dependency>, modifiers?: GraphModifier, modifierRefs?: Map<string, ModifierActiveEntry>, extractPromises?: Promise<ExtractResult>[], actual?: Graph, seenExtracted?: Set<DepID>, remover?: RollbackRemove) => Promise<void>;
|
|
19
19
|
//# sourceMappingURL=append-nodes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"append-nodes.d.ts","sourceRoot":"","sources":["../../../src/ideal/append-nodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAO/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"append-nodes.d.ts","sourceRoot":"","sources":["../../../src/ideal/append-nodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAO/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,KAAK,EACV,aAAa,EACb,mBAAmB,EACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAid7D;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,gBACT,iBAAiB,SACvB,KAAK,YACF,IAAI,QACR,UAAU,EAAE,UACV,UAAU,WACT,WAAW,QACd,GAAG,CAAC,KAAK,CAAC,QACV,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,cACjB,aAAa,iBACV,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,oBAC7B,OAAO,CAAC,aAAa,CAAC,EAAE,WACjC,KAAK,kBACE,GAAG,CAAC,KAAK,CAAC,YAChB,cAAc,kBAuGzB,CAAA"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { joinDepIDTuple } from '@vltpkg/dep-id';
|
|
1
|
+
import { joinDepIDTuple, joinExtra } from '@vltpkg/dep-id';
|
|
2
2
|
import { error } from '@vltpkg/error-cause';
|
|
3
3
|
import { Spec } from '@vltpkg/spec';
|
|
4
4
|
import { longDependencyTypes, normalizeManifest } from '@vltpkg/types';
|
|
5
5
|
import { asDependency, shorten } from "../dependencies.js";
|
|
6
6
|
import { removeOptionalSubgraph } from "../remove-optional-subgraph.js";
|
|
7
7
|
import { extractNode } from "../reify/extract-node.js";
|
|
8
|
+
import { endPeerPlacement, postPlacementPeerCheck, startPeerPlacement, } from "./peers.js";
|
|
8
9
|
/**
|
|
9
10
|
* Only install devDeps for git dependencies and importers
|
|
10
11
|
* Everything else always gets installed
|
|
@@ -40,9 +41,10 @@ const isStringArray = (a) => Array.isArray(a) && !a.some(b => typeof b !== 'stri
|
|
|
40
41
|
/**
|
|
41
42
|
* Fetch manifests for dependencies and create placement tasks.
|
|
42
43
|
*/
|
|
43
|
-
const fetchManifestsForDeps = async (packageInfo, graph, fromNode, deps, scurry, modifierRefs, depth = 0) => {
|
|
44
|
+
const fetchManifestsForDeps = async (packageInfo, graph, fromNode, deps, scurry, peerContext, modifierRefs, depth = 0) => {
|
|
44
45
|
// Create fetch tasks for all dependencies at this level
|
|
45
46
|
const fetchTasks = [];
|
|
47
|
+
const placementTasks = [];
|
|
46
48
|
for (const { spec: originalSpec, type } of deps) {
|
|
47
49
|
let spec = originalSpec;
|
|
48
50
|
const fileTypeInfo = getFileTypeInfo(spec, fromNode, scurry);
|
|
@@ -60,31 +62,47 @@ const fetchManifestsForDeps = async (packageInfo, graph, fromNode, deps, scurry,
|
|
|
60
62
|
continue;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
65
|
+
const peer = type === 'peer' || type === 'peerOptional';
|
|
66
|
+
// skip reusing nodes for peer deps since their reusability
|
|
67
|
+
// is handled ahead-of-time during its parent's placement
|
|
63
68
|
const existingNode = graph.findResolution(spec, fromNode, queryModifier);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
// defines what nodes are eligible to be reused
|
|
70
|
+
const validExistingNode = existingNode &&
|
|
71
|
+
!existingNode.detached &&
|
|
72
|
+
// Regular deps can always reuse
|
|
73
|
+
/* c8 ignore start */
|
|
74
|
+
(!peer ||
|
|
75
|
+
// otherwise reusing peer deps only in case of a peerSetHash matche
|
|
76
|
+
existingNode.peerSetHash === fromNode.peerSetHash);
|
|
77
|
+
/* c8 ignore stop */
|
|
78
|
+
if (validExistingNode ||
|
|
79
|
+
// importers are handled at the ./add-nodes.ts top-level
|
|
80
|
+
// so we should just skip whenever we find one
|
|
81
|
+
existingNode?.importer) {
|
|
82
|
+
graph.addEdge(type, spec, fromNode, existingNode);
|
|
74
83
|
continue;
|
|
75
84
|
}
|
|
85
|
+
// is the current edge pointint go an optional dependency?
|
|
76
86
|
const edgeOptional = type === 'optional' || type === 'peerOptional';
|
|
77
87
|
// Start manifest fetch immediately for parallel processing
|
|
78
|
-
const manifestPromise =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
const manifestPromise =
|
|
89
|
+
// the "detached" node state means that it has already been load as
|
|
90
|
+
// part of a graph (either lockfile or actual) and it has valid manifest
|
|
91
|
+
// data so we shortcut the package info manifest fetch here
|
|
92
|
+
existingNode?.detached ?
|
|
93
|
+
Promise.resolve(existingNode.manifest)
|
|
94
|
+
// this is the entry point to fetch calls to retrieve manifests
|
|
95
|
+
// from the build ideal graph point of view
|
|
96
|
+
: packageInfo
|
|
97
|
+
.manifest(spec, { from: scurry.resolve(fromNode.location) })
|
|
98
|
+
.then(manifest => manifest)
|
|
99
|
+
.catch((er) => {
|
|
100
|
+
// optional deps ignored if inaccessible
|
|
101
|
+
if (edgeOptional || fromNode.optional) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
throw er;
|
|
105
|
+
});
|
|
88
106
|
const fetchTask = {
|
|
89
107
|
spec,
|
|
90
108
|
type,
|
|
@@ -95,11 +113,11 @@ const fetchManifestsForDeps = async (packageInfo, graph, fromNode, deps, scurry,
|
|
|
95
113
|
edgeOptional,
|
|
96
114
|
manifestPromise,
|
|
97
115
|
depth,
|
|
116
|
+
peerContext,
|
|
98
117
|
};
|
|
99
118
|
fetchTasks.push(fetchTask);
|
|
100
119
|
}
|
|
101
|
-
// Create placement tasks
|
|
102
|
-
const placementTasks = [];
|
|
120
|
+
// Create placement tasks from fetch tasks
|
|
103
121
|
for (const fetchTask of fetchTasks) {
|
|
104
122
|
const manifest = await fetchTask.manifestPromise;
|
|
105
123
|
placementTasks.push({
|
|
@@ -107,26 +125,45 @@ const fetchManifestsForDeps = async (packageInfo, graph, fromNode, deps, scurry,
|
|
|
107
125
|
manifest,
|
|
108
126
|
});
|
|
109
127
|
}
|
|
128
|
+
// sort placement tasks: non-peer dependencies first, then peer dependencies
|
|
129
|
+
// so that peer dependencies can easily reuse already placed regular
|
|
130
|
+
// dependencies as part of peer context set resolution also makes sure to
|
|
131
|
+
// sort by the manifest name for deterministic order.
|
|
132
|
+
placementTasks.sort((a, b) => {
|
|
133
|
+
const aIsPeer = (a.manifest?.peerDependencies &&
|
|
134
|
+
Object.keys(a.manifest.peerDependencies).length > 0) ?
|
|
135
|
+
1
|
|
136
|
+
: 0;
|
|
137
|
+
const bIsPeer = (b.manifest?.peerDependencies &&
|
|
138
|
+
Object.keys(b.manifest.peerDependencies).length > 0) ?
|
|
139
|
+
1
|
|
140
|
+
: 0;
|
|
141
|
+
// regular dependencies first, peer dependencies last
|
|
142
|
+
if (aIsPeer !== bIsPeer) {
|
|
143
|
+
return aIsPeer - bIsPeer;
|
|
144
|
+
}
|
|
145
|
+
// if both are in the same group,
|
|
146
|
+
// sort alphabetically by manifest name (fallback to spec.name)
|
|
147
|
+
const aName = a.manifest?.name /* c8 ignore next */ || a.fetchTask.spec.name;
|
|
148
|
+
const bName = b.manifest?.name || b.fetchTask.spec.name;
|
|
149
|
+
return aName.localeCompare(bName, 'en');
|
|
150
|
+
});
|
|
110
151
|
return placementTasks;
|
|
111
152
|
};
|
|
112
153
|
/**
|
|
113
|
-
* Process placement tasks and collect child dependencies
|
|
154
|
+
* Process placement tasks and collect child dependencies, this is the
|
|
155
|
+
* second step of the appendNodes operation after manifest fetching in
|
|
156
|
+
* which the final graph data structure is actually built.
|
|
114
157
|
*/
|
|
115
|
-
const processPlacementTasks = async (
|
|
158
|
+
const processPlacementTasks = async (graph, options, placementTasks, add, modifiers, scurry, packageInfo, extractPromises, actual, seenExtracted, remover) => {
|
|
116
159
|
const childDepsToProcess = [];
|
|
117
160
|
for (const placementTask of placementTasks) {
|
|
118
161
|
const { fetchTask, manifest } = placementTask;
|
|
119
|
-
let { spec } = fetchTask;
|
|
120
|
-
const type = fetchTask.type;
|
|
121
|
-
const fromNode = fetchTask.fromNode;
|
|
122
|
-
const fileTypeInfo = fetchTask.fileTypeInfo;
|
|
123
|
-
const activeModifier = fetchTask.activeModifier;
|
|
124
|
-
const queryModifier = fetchTask.queryModifier;
|
|
125
|
-
const edgeOptional = fetchTask.edgeOptional;
|
|
162
|
+
let { activeModifier, edgeOptional, fileTypeInfo, fromNode, peerContext, queryModifier, spec, type, } = fetchTask;
|
|
126
163
|
// Handle nameless dependencies
|
|
127
164
|
if (manifest?.name && spec.name === '(unknown)') {
|
|
128
|
-
const s = add
|
|
129
|
-
if (s) {
|
|
165
|
+
const s = add?.get(String(spec));
|
|
166
|
+
if (add && s) {
|
|
130
167
|
// removes the previous, placeholder entry key
|
|
131
168
|
add.delete(String(spec));
|
|
132
169
|
// replaces spec with a version with the correct name
|
|
@@ -159,14 +196,14 @@ const processPlacementTasks = async (add, graph, options, placementTasks, modifi
|
|
|
159
196
|
});
|
|
160
197
|
}
|
|
161
198
|
}
|
|
162
|
-
//
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
199
|
+
// start peer deps placement process, populating the peer context with
|
|
200
|
+
// dependency data; adding the parent node deps and this manifest's
|
|
201
|
+
// peer deps references to the current peer context set
|
|
202
|
+
const peerPlacement = startPeerPlacement(peerContext, manifest, fromNode, options);
|
|
203
|
+
const peerSetHash = peerPlacement.peerSetHash;
|
|
204
|
+
const queuedEntries = peerPlacement.queuedEntries;
|
|
168
205
|
// places a new node in the graph representing a newly seen dependency
|
|
169
|
-
const node = graph.placePackage(fromNode, type, spec, normalizeManifest(manifest), fileTypeInfo?.id, queryModifier);
|
|
206
|
+
const node = graph.placePackage(fromNode, type, spec, normalizeManifest(manifest), fileTypeInfo?.id, joinExtra({ peerSetHash, modifier: queryModifier }));
|
|
170
207
|
/* c8 ignore start - not possible, already ensured manifest */
|
|
171
208
|
if (!node) {
|
|
172
209
|
throw error('failed to place package', {
|
|
@@ -179,14 +216,20 @@ const processPlacementTasks = async (add, graph, options, placementTasks, modifi
|
|
|
179
216
|
if (activeModifier) {
|
|
180
217
|
modifiers?.updateActiveEntry(node, activeModifier);
|
|
181
218
|
}
|
|
182
|
-
|
|
183
|
-
|
|
219
|
+
const eligibleForExtraction = type !== 'peer' &&
|
|
220
|
+
type !== 'peerOptional' &&
|
|
221
|
+
remover &&
|
|
184
222
|
extractPromises &&
|
|
185
223
|
actual &&
|
|
186
224
|
scurry &&
|
|
187
225
|
packageInfo &&
|
|
188
226
|
node.inVltStore() &&
|
|
189
|
-
!node.isOptional()
|
|
227
|
+
!node.isOptional() &&
|
|
228
|
+
// this fixes an issue with installing `file:pathname` specs
|
|
229
|
+
/* c8 ignore next */ !fileTypeInfo?.isDirectory &&
|
|
230
|
+
!node.importer;
|
|
231
|
+
// extract the node if it meets the criteria for early extraction
|
|
232
|
+
if (eligibleForExtraction) {
|
|
190
233
|
/* c8 ignore start */
|
|
191
234
|
if (seenExtracted?.has(node.id)) {
|
|
192
235
|
continue;
|
|
@@ -195,7 +238,7 @@ const processPlacementTasks = async (add, graph, options, placementTasks, modifi
|
|
|
195
238
|
seenExtracted?.add(node.id);
|
|
196
239
|
const actualNode = actual.nodes.get(node.id);
|
|
197
240
|
if (!actualNode?.equals(node)) {
|
|
198
|
-
//
|
|
241
|
+
// extract the node without awaiting - push the promise to the array
|
|
199
242
|
const extractPromise = extractNode(node, scurry, remover, options, packageInfo);
|
|
200
243
|
extractPromises.push(extractPromise);
|
|
201
244
|
}
|
|
@@ -205,40 +248,55 @@ const processPlacementTasks = async (add, graph, options, placementTasks, modifi
|
|
|
205
248
|
node.location = fileTypeInfo.path;
|
|
206
249
|
}
|
|
207
250
|
node.setResolved();
|
|
208
|
-
//
|
|
251
|
+
// collect child dependencies for processing in the next level
|
|
252
|
+
const nextPeerDeps = new Map();
|
|
253
|
+
// compute deps normally
|
|
209
254
|
const bundleDeps = manifest.bundleDependencies;
|
|
210
255
|
const bundled = new Set((node.id.startsWith('git') ||
|
|
211
256
|
node.importer ||
|
|
212
257
|
!isStringArray(bundleDeps)) ?
|
|
213
258
|
[]
|
|
214
259
|
: bundleDeps);
|
|
215
|
-
//
|
|
260
|
+
// setup next level to process all child dependencies in the manifest
|
|
216
261
|
const nextDeps = [];
|
|
262
|
+
// traverse actual dependency declarations in the manifest
|
|
263
|
+
// creating dependency entries for them
|
|
217
264
|
for (const depTypeName of longDependencyTypes) {
|
|
218
265
|
const depRecord = manifest[depTypeName];
|
|
219
266
|
if (depRecord && shouldInstallDepType(node, depTypeName)) {
|
|
220
267
|
for (const [name, bareSpec] of Object.entries(depRecord)) {
|
|
268
|
+
// might need to skip already placed peer deps here
|
|
221
269
|
if (bundled.has(name))
|
|
222
270
|
continue;
|
|
223
|
-
|
|
271
|
+
const dep = {
|
|
224
272
|
type: shorten(depTypeName, name, manifest),
|
|
225
273
|
spec: Spec.parse(name, bareSpec, {
|
|
226
274
|
...options,
|
|
227
275
|
registry: spec.registry,
|
|
228
276
|
}),
|
|
229
|
-
}
|
|
277
|
+
};
|
|
278
|
+
if (depTypeName === 'peerDependencies') {
|
|
279
|
+
nextPeerDeps.set(name, dep);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
nextDeps.push(dep);
|
|
283
|
+
}
|
|
230
284
|
}
|
|
231
285
|
}
|
|
232
286
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
287
|
+
// finish peer placement for this node, resolving satisfied peers
|
|
288
|
+
// to seen nodes from the peer context and adding unsatisfied peers
|
|
289
|
+
// to `nextDeps` so they get processed along regular dependencies
|
|
290
|
+
const updateContext = endPeerPlacement(peerContext, nextDeps, nextPeerDeps, graph, spec, fromNode, node, type, queuedEntries);
|
|
291
|
+
childDepsToProcess.push({
|
|
292
|
+
node,
|
|
293
|
+
deps: nextDeps,
|
|
294
|
+
modifierRefs: modifiers?.tryDependencies(node, nextDeps),
|
|
295
|
+
peerContext,
|
|
296
|
+
updateContext,
|
|
297
|
+
});
|
|
240
298
|
}
|
|
241
|
-
return
|
|
299
|
+
return childDepsToProcess;
|
|
242
300
|
};
|
|
243
301
|
/**
|
|
244
302
|
* Append new nodes in the given `graph` for dependencies specified at `add`
|
|
@@ -247,30 +305,54 @@ const processPlacementTasks = async (add, graph, options, placementTasks, modifi
|
|
|
247
305
|
* It also applies any modifiers that applies to a given node as it processes
|
|
248
306
|
* and builds the graph.
|
|
249
307
|
*/
|
|
250
|
-
export const appendNodes = async (
|
|
308
|
+
export const appendNodes = async (packageInfo, graph, fromNode, deps, scurry, options, seen, add, modifiers, modifierRefs, extractPromises, actual, seenExtracted, remover) => {
|
|
251
309
|
/* c8 ignore next */
|
|
252
310
|
if (seen.has(fromNode.id))
|
|
253
311
|
return;
|
|
254
312
|
seen.add(fromNode.id);
|
|
313
|
+
// Get the initial peer context from the graph
|
|
314
|
+
const [initialPeerContext] = graph.peerContexts;
|
|
315
|
+
/* c8 ignore start - impossible */
|
|
316
|
+
if (!initialPeerContext) {
|
|
317
|
+
throw error('no initial peer context found in graph');
|
|
318
|
+
}
|
|
319
|
+
/* c8 ignore stop */
|
|
255
320
|
// Use a queue for breadth-first processing
|
|
256
321
|
let currentLevelDeps = [
|
|
257
|
-
{
|
|
322
|
+
{
|
|
323
|
+
node: fromNode,
|
|
324
|
+
deps,
|
|
325
|
+
modifierRefs,
|
|
326
|
+
depth: 0,
|
|
327
|
+
peerContext: initialPeerContext,
|
|
328
|
+
/* c8 ignore start */
|
|
329
|
+
updateContext: {
|
|
330
|
+
putEntries: () => undefined,
|
|
331
|
+
resolvePeerDeps: () => { },
|
|
332
|
+
},
|
|
333
|
+
/* c8 ignore stop */
|
|
334
|
+
},
|
|
258
335
|
];
|
|
259
336
|
while (currentLevelDeps.length > 0) {
|
|
260
337
|
const nextLevelDeps = [];
|
|
261
338
|
// Process all nodes at the current level in parallel
|
|
262
|
-
const levelResults = await Promise.all(currentLevelDeps.map(async ({ node, deps: nodeDeps, modifierRefs: nodeModifierRefs, depth, }) => {
|
|
339
|
+
const levelResults = await Promise.all(currentLevelDeps.map(async ({ node, deps: nodeDeps, modifierRefs: nodeModifierRefs, peerContext, depth, }) => {
|
|
263
340
|
// Mark node as seen when we start processing its dependencies
|
|
264
341
|
seen.add(node.id);
|
|
265
342
|
// Fetch manifests for this node's dependencies
|
|
266
343
|
const placementTasks = await fetchManifestsForDeps(packageInfo, graph, node,
|
|
267
344
|
// Sort dependencies by spec.name for deterministic ordering
|
|
268
|
-
nodeDeps.sort((a, b) => a.spec.name.localeCompare(b.spec.name, 'en')), scurry, nodeModifierRefs, depth);
|
|
345
|
+
nodeDeps.sort((a, b) => a.spec.name.localeCompare(b.spec.name, 'en')), scurry, peerContext, nodeModifierRefs, depth);
|
|
269
346
|
// Process the placement tasks and get child dependencies
|
|
270
|
-
return await processPlacementTasks(
|
|
347
|
+
return await processPlacementTasks(graph, options, placementTasks, add, modifiers, scurry, packageInfo, extractPromises, actual, seenExtracted, remover);
|
|
271
348
|
}));
|
|
349
|
+
// Traverse the queued up children dependencies, adding and tracking
|
|
350
|
+
// dependencies on the peer context set, forking the context as needed
|
|
351
|
+
// and resolving any peer dependency that is able to be resolved using
|
|
352
|
+
// the current peer context set
|
|
353
|
+
postPlacementPeerCheck(graph, levelResults);
|
|
272
354
|
// Collect all child dependencies for the next level
|
|
273
|
-
for (const
|
|
355
|
+
for (const childDepsToProcess of levelResults) {
|
|
274
356
|
for (const childDep of childDepsToProcess) {
|
|
275
357
|
if (!seen.has(childDep.node.id)) {
|
|
276
358
|
/* c8 ignore next */
|