@vltpkg/graph 0.0.0-8 → 1.0.0-rc.1

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.
Files changed (182) hide show
  1. package/README.md +136 -1
  2. package/dist/esm/actual/load.d.ts +49 -3
  3. package/dist/esm/actual/load.d.ts.map +1 -1
  4. package/dist/esm/actual/load.js +124 -73
  5. package/dist/esm/actual/load.js.map +1 -1
  6. package/dist/esm/browser.d.ts +8 -4
  7. package/dist/esm/browser.d.ts.map +1 -1
  8. package/dist/esm/browser.js +6 -2
  9. package/dist/esm/browser.js.map +1 -1
  10. package/dist/esm/build.d.ts +29 -0
  11. package/dist/esm/build.d.ts.map +1 -0
  12. package/dist/esm/build.js +79 -0
  13. package/dist/esm/build.js.map +1 -0
  14. package/dist/esm/dependencies.d.ts +14 -5
  15. package/dist/esm/dependencies.d.ts.map +1 -1
  16. package/dist/esm/dependencies.js +67 -2
  17. package/dist/esm/dependencies.js.map +1 -1
  18. package/dist/esm/diff.d.ts +67 -0
  19. package/dist/esm/diff.d.ts.map +1 -1
  20. package/dist/esm/diff.js +25 -0
  21. package/dist/esm/diff.js.map +1 -1
  22. package/dist/esm/edge.d.ts +7 -2
  23. package/dist/esm/edge.d.ts.map +1 -1
  24. package/dist/esm/edge.js +8 -0
  25. package/dist/esm/edge.js.map +1 -1
  26. package/dist/esm/graph.d.ts +21 -11
  27. package/dist/esm/graph.d.ts.map +1 -1
  28. package/dist/esm/graph.js +126 -22
  29. package/dist/esm/graph.js.map +1 -1
  30. package/dist/esm/ideal/add-nodes.d.ts +17 -2
  31. package/dist/esm/ideal/add-nodes.d.ts.map +1 -1
  32. package/dist/esm/ideal/add-nodes.js +15 -4
  33. package/dist/esm/ideal/add-nodes.js.map +1 -1
  34. package/dist/esm/ideal/append-nodes.d.ts +11 -1
  35. package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
  36. package/dist/esm/ideal/append-nodes.js +176 -31
  37. package/dist/esm/ideal/append-nodes.js.map +1 -1
  38. package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +1 -1
  39. package/dist/esm/ideal/build-ideal-from-starting-graph.js +9 -5
  40. package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -1
  41. package/dist/esm/ideal/build.d.ts +9 -0
  42. package/dist/esm/ideal/build.d.ts.map +1 -1
  43. package/dist/esm/ideal/build.js +4 -1
  44. package/dist/esm/ideal/build.js.map +1 -1
  45. package/dist/esm/ideal/get-importer-specs.d.ts +3 -2
  46. package/dist/esm/ideal/get-importer-specs.d.ts.map +1 -1
  47. package/dist/esm/ideal/get-importer-specs.js +7 -5
  48. package/dist/esm/ideal/get-importer-specs.js.map +1 -1
  49. package/dist/esm/index.d.ts +8 -4
  50. package/dist/esm/index.d.ts.map +1 -1
  51. package/dist/esm/index.js +4 -1
  52. package/dist/esm/index.js.map +1 -1
  53. package/dist/esm/install.d.ts +8 -3
  54. package/dist/esm/install.d.ts.map +1 -1
  55. package/dist/esm/install.js +167 -20
  56. package/dist/esm/install.js.map +1 -1
  57. package/dist/esm/lockfile/load-edges.d.ts +8 -1
  58. package/dist/esm/lockfile/load-edges.d.ts.map +1 -1
  59. package/dist/esm/lockfile/load-edges.js +79 -15
  60. package/dist/esm/lockfile/load-edges.js.map +1 -1
  61. package/dist/esm/lockfile/load-nodes.d.ts +3 -2
  62. package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
  63. package/dist/esm/lockfile/load-nodes.js +72 -12
  64. package/dist/esm/lockfile/load-nodes.js.map +1 -1
  65. package/dist/esm/lockfile/load.d.ts +18 -5
  66. package/dist/esm/lockfile/load.d.ts.map +1 -1
  67. package/dist/esm/lockfile/load.js +53 -22
  68. package/dist/esm/lockfile/load.js.map +1 -1
  69. package/dist/esm/lockfile/save.d.ts +12 -3
  70. package/dist/esm/lockfile/save.d.ts.map +1 -1
  71. package/dist/esm/lockfile/save.js +49 -16
  72. package/dist/esm/lockfile/save.js.map +1 -1
  73. package/dist/esm/lockfile/types.d.ts +34 -4
  74. package/dist/esm/lockfile/types.d.ts.map +1 -1
  75. package/dist/esm/lockfile/types.js +31 -0
  76. package/dist/esm/lockfile/types.js.map +1 -1
  77. package/dist/esm/modifiers.d.ts +189 -0
  78. package/dist/esm/modifiers.d.ts.map +1 -0
  79. package/dist/esm/modifiers.js +330 -0
  80. package/dist/esm/modifiers.js.map +1 -0
  81. package/dist/esm/node.d.ts +77 -6
  82. package/dist/esm/node.d.ts.map +1 -1
  83. package/dist/esm/node.js +98 -5
  84. package/dist/esm/node.js.map +1 -1
  85. package/dist/esm/reify/add-edge.d.ts +1 -2
  86. package/dist/esm/reify/add-edge.d.ts.map +1 -1
  87. package/dist/esm/reify/add-edge.js +39 -17
  88. package/dist/esm/reify/add-edge.js.map +1 -1
  89. package/dist/esm/reify/add-edges.d.ts +1 -2
  90. package/dist/esm/reify/add-edges.d.ts.map +1 -1
  91. package/dist/esm/reify/add-edges.js +2 -3
  92. package/dist/esm/reify/add-edges.js.map +1 -1
  93. package/dist/esm/reify/add-nodes.d.ts.map +1 -1
  94. package/dist/esm/reify/add-nodes.js +4 -27
  95. package/dist/esm/reify/add-nodes.js.map +1 -1
  96. package/dist/esm/reify/bin-chmod.d.ts +11 -0
  97. package/dist/esm/reify/bin-chmod.d.ts.map +1 -0
  98. package/dist/esm/reify/bin-chmod.js +39 -0
  99. package/dist/esm/reify/bin-chmod.js.map +1 -0
  100. package/dist/esm/reify/build.d.ts +10 -1
  101. package/dist/esm/reify/build.d.ts.map +1 -1
  102. package/dist/esm/reify/build.js +36 -23
  103. package/dist/esm/reify/build.js.map +1 -1
  104. package/dist/esm/reify/calculate-save-value.d.ts +3 -0
  105. package/dist/esm/reify/calculate-save-value.d.ts.map +1 -0
  106. package/dist/esm/reify/calculate-save-value.js +45 -0
  107. package/dist/esm/reify/calculate-save-value.js.map +1 -0
  108. package/dist/esm/reify/check-needed-build.d.ts +25 -0
  109. package/dist/esm/reify/check-needed-build.d.ts.map +1 -0
  110. package/dist/esm/reify/check-needed-build.js +50 -0
  111. package/dist/esm/reify/check-needed-build.js.map +1 -0
  112. package/dist/esm/reify/delete-edge.d.ts.map +1 -1
  113. package/dist/esm/reify/delete-edge.js +4 -5
  114. package/dist/esm/reify/delete-edge.js.map +1 -1
  115. package/dist/esm/reify/delete-nodes.d.ts.map +1 -1
  116. package/dist/esm/reify/delete-nodes.js +4 -0
  117. package/dist/esm/reify/delete-nodes.js.map +1 -1
  118. package/dist/esm/reify/extract-node.d.ts +24 -0
  119. package/dist/esm/reify/extract-node.d.ts.map +1 -0
  120. package/dist/esm/reify/extract-node.js +76 -0
  121. package/dist/esm/reify/extract-node.js.map +1 -0
  122. package/dist/esm/reify/index.d.ts +18 -1
  123. package/dist/esm/reify/index.d.ts.map +1 -1
  124. package/dist/esm/reify/index.js +84 -14
  125. package/dist/esm/reify/index.js.map +1 -1
  126. package/dist/esm/reify/internal-hoist.d.ts +9 -0
  127. package/dist/esm/reify/internal-hoist.d.ts.map +1 -0
  128. package/dist/esm/reify/internal-hoist.js +134 -0
  129. package/dist/esm/reify/internal-hoist.js.map +1 -0
  130. package/dist/esm/reify/update-importers-package-json.d.ts +1 -1
  131. package/dist/esm/reify/update-importers-package-json.d.ts.map +1 -1
  132. package/dist/esm/reify/update-importers-package-json.js +35 -12
  133. package/dist/esm/reify/update-importers-package-json.js.map +1 -1
  134. package/dist/esm/remove-optional-subgraph.js +1 -1
  135. package/dist/esm/remove-optional-subgraph.js.map +1 -1
  136. package/dist/esm/resolve-save-type.d.ts +6 -0
  137. package/dist/esm/resolve-save-type.d.ts.map +1 -0
  138. package/dist/esm/resolve-save-type.js +5 -0
  139. package/dist/esm/resolve-save-type.js.map +1 -0
  140. package/dist/esm/stringify-node.d.ts +1 -1
  141. package/dist/esm/stringify-node.d.ts.map +1 -1
  142. package/dist/esm/stringify-node.js.map +1 -1
  143. package/dist/esm/transfer-data/load.d.ts +44 -0
  144. package/dist/esm/transfer-data/load.d.ts.map +1 -0
  145. package/dist/esm/transfer-data/load.js +176 -0
  146. package/dist/esm/transfer-data/load.js.map +1 -0
  147. package/dist/esm/uninstall.d.ts +5 -4
  148. package/dist/esm/uninstall.d.ts.map +1 -1
  149. package/dist/esm/uninstall.js +51 -19
  150. package/dist/esm/uninstall.js.map +1 -1
  151. package/dist/esm/update.d.ts +13 -0
  152. package/dist/esm/update.d.ts.map +1 -0
  153. package/dist/esm/update.js +63 -0
  154. package/dist/esm/update.js.map +1 -0
  155. package/dist/esm/virtual-root.d.ts +16 -0
  156. package/dist/esm/virtual-root.d.ts.map +1 -0
  157. package/dist/esm/virtual-root.js +79 -0
  158. package/dist/esm/virtual-root.js.map +1 -0
  159. package/dist/esm/visualization/human-readable-output.d.ts +4 -5
  160. package/dist/esm/visualization/human-readable-output.d.ts.map +1 -1
  161. package/dist/esm/visualization/human-readable-output.js +51 -24
  162. package/dist/esm/visualization/human-readable-output.js.map +1 -1
  163. package/dist/esm/visualization/json-output.d.ts +7 -3
  164. package/dist/esm/visualization/json-output.d.ts.map +1 -1
  165. package/dist/esm/visualization/json-output.js +35 -12
  166. package/dist/esm/visualization/json-output.js.map +1 -1
  167. package/dist/esm/visualization/mermaid-output.d.ts +7 -1
  168. package/dist/esm/visualization/mermaid-output.d.ts.map +1 -1
  169. package/dist/esm/visualization/mermaid-output.js +64 -9
  170. package/dist/esm/visualization/mermaid-output.js.map +1 -1
  171. package/dist/esm/visualization/object-like-output.d.ts +1 -1
  172. package/dist/esm/visualization/object-like-output.d.ts.map +1 -1
  173. package/dist/esm/visualization/object-like-output.js.map +1 -1
  174. package/package.json +30 -23
  175. package/dist/esm/reify/bin-paths.d.ts +0 -4
  176. package/dist/esm/reify/bin-paths.d.ts.map +0 -1
  177. package/dist/esm/reify/bin-paths.js +0 -23
  178. package/dist/esm/reify/bin-paths.js.map +0 -1
  179. package/dist/esm/types.d.ts +0 -39
  180. package/dist/esm/types.d.ts.map +0 -1
  181. package/dist/esm/types.js +0 -2
  182. package/dist/esm/types.js.map +0 -1
@@ -1,19 +1,18 @@
1
1
  import type { DepID } from '@vltpkg/dep-id';
2
2
  import { Spec } from '@vltpkg/spec';
3
3
  import type { SpecOptions } from '@vltpkg/spec';
4
- import type { Manifest, DependencyTypeShort } from '@vltpkg/types';
4
+ import type { GraphLike, NodeLike, NormalizedManifest, DependencySaveType } from '@vltpkg/types';
5
5
  import type { Monorepo } from '@vltpkg/workspaces';
6
6
  import type { InspectOptions } from 'node:util';
7
- import type { Edge } from './edge.ts';
7
+ import { Edge } from './edge.ts';
8
8
  import { Node } from './node.ts';
9
- import type { GraphLike, NodeLike } from './types.ts';
10
9
  declare const kCustomInspect: unique symbol;
11
- export type ManifestInventory = Map<DepID, Manifest>;
10
+ export type ManifestInventory = Map<DepID, NormalizedManifest>;
12
11
  export type GraphOptions = SpecOptions & {
13
12
  /**
14
13
  * The main importer manifest info.
15
14
  */
16
- mainManifest: Manifest;
15
+ mainManifest: NormalizedManifest;
17
16
  /**
18
17
  * An inventory of seen manifests.
19
18
  */
@@ -76,7 +75,7 @@ export declare class Graph implements GraphLike {
76
75
  projectRoot: string;
77
76
  constructor(options: GraphOptions);
78
77
  /**
79
- * Delete all nodes that are unreachable from the importers.
78
+ * Delete all nodes and edges that are unreachable from the importers.
80
79
  * The collection of deleted nodes is returned.
81
80
  *
82
81
  * NOTE: This can be extremely slow for large graphs, and is almost always
@@ -90,15 +89,15 @@ export declare class Graph implements GraphLike {
90
89
  * in case the destination node does not exists, then a dangling edge,
91
90
  * pointing to nothing will be created to represent that missing dependency.
92
91
  */
93
- addEdge(type: DependencyTypeShort, spec: Spec, from: NodeLike, to?: NodeLike): Edge;
92
+ addEdge(type: DependencySaveType, spec: Spec, from: NodeLike, to?: NodeLike): Edge;
94
93
  /**
95
94
  * Find an existing node to satisfy a dependency
96
95
  */
97
- findResolution(spec: Spec, fromNode: Node): Node | undefined;
96
+ findResolution(spec: Spec, fromNode: Node, queryModifier?: string): Node | undefined;
98
97
  /**
99
98
  * Create a new node in the graph.
100
99
  */
101
- addNode(id?: DepID, manifest?: Manifest, spec?: Spec, name?: string, version?: string): Node;
100
+ addNode(id?: DepID, manifest?: NormalizedManifest, spec?: Spec, name?: string, version?: string): Node;
102
101
  /**
103
102
  * Place a new package into the graph representation, creating the new
104
103
  * edges and possibly new nodes that are to be expected when traversing
@@ -107,15 +106,26 @@ export declare class Graph implements GraphLike {
107
106
  * For different uses that are not a direct top-down traversal of the graph
108
107
  * consider using `addNode()` and `addEdge()` instead.
109
108
  */
110
- placePackage(fromNode: Node, depType: DependencyTypeShort, spec: Spec, manifest?: Manifest, id?: DepID): Node | undefined;
109
+ placePackage(fromNode: Node, depType: DependencySaveType, spec: Spec, manifest?: NormalizedManifest, id?: DepID, extra?: string): Node | undefined;
111
110
  /**
112
111
  * Removes a node and its relevant edges from the graph.
113
112
  *
113
+ * Use the `keepEdges` option to keep the edges that were pointing to
114
+ * this node and only removes their `to` property value.
115
+ *
114
116
  * If a replacement is provided, then any edges that were previously
115
117
  * pointing to the removed node will be directed to the replacement,
116
118
  * if it is valid to do so.
117
119
  */
118
- removeNode(node: Node, replacement?: Node): void;
120
+ removeNode(node: Node, replacement?: Node, keepEdges?: boolean): void;
121
+ /**
122
+ * Removes the resolved node of a given edge.
123
+ */
124
+ removeEdgeResolution(edge: Edge, queryModifier?: string): void;
125
+ /**
126
+ * Reset resolution cache data.
127
+ */
128
+ resetResolution(): void;
119
129
  toJSON(): import("./index.ts").LockfileData;
120
130
  [kCustomInspect](_: number, options: InspectOptions): string;
121
131
  }
@@ -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,EA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,EAAE,kBAAkB,EAC7B,IAAI,CAAC,EAAE,IAAI,EACX,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM;IAoBlB;;;;;;;OAOG;IACH,YAAY,CACV,QAAQ,EAAE,IAAI,EACd,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,IAAI,EACV,QAAQ,CAAC,EAAE,kBAAkB,EAC7B,EAAE,CAAC,EAAE,KAAK,EACV,KAAK,CAAC,EAAE,MAAM,GACb,IAAI,GAAG,SAAS;IAiFnB;;;;;;;;;OASG;IACH,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,OAAO;IAmC9D;;OAEG;IACH,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,SAAK;IAmBnD;;OAEG;IACH,eAAe;IAyCf,MAAM;IAQN,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc;CAIpD"}
package/dist/esm/graph.js CHANGED
@@ -4,12 +4,34 @@ import { satisfies } from '@vltpkg/satisfies';
4
4
  import { Spec } from '@vltpkg/spec';
5
5
  import { inspect } from 'node:util';
6
6
  import { lockfileData } from "./lockfile/save.js";
7
+ import { Edge } from "./edge.js";
7
8
  import { Node } from "./node.js";
9
+ import { resolveSaveType } from "./resolve-save-type.js";
8
10
  const kCustomInspect = Symbol.for('nodejs.util.inspect.custom');
11
+ const cacheKeySeparator = '│';
9
12
  // this is always the same, but we don't hard code it as a string,
10
13
  // in case the DepID module needs to change its delimiter again ever.
11
14
  const mainDepID = joinDepIDTuple(['file', '.']);
12
15
  const getMap = (m) => m ?? new Map();
16
+ /**
17
+ * Get a cache key for a resolution based on the
18
+ * spec, location and query modifier.
19
+ */
20
+ const getResolutionCacheKey = (spec, location, queryModifier) => {
21
+ const f = spec.final;
22
+ // if it's a file: dep, then the fromNode location matters
23
+ const fromPrefix = f.type === 'file' ? location + ' : ' : '';
24
+ // the unique key should also precise what is the type of the spec,
25
+ // and in the case of a registry, what registry it is from.
26
+ const typePrecisionKey = f.registry ?
27
+ `${cacheKeySeparator}registry` +
28
+ `${cacheKeySeparator}${f.registry}`
29
+ : f.gitRemote ?
30
+ `${cacheKeySeparator}git` + `${cacheKeySeparator}${f.gitRemote}`
31
+ : `${cacheKeySeparator}${f.type}`;
32
+ const modifierSuffix = `${cacheKeySeparator}${queryModifier}`;
33
+ return fromPrefix + String(f) + typePrecisionKey + modifierSuffix;
34
+ };
13
35
  export class Graph {
14
36
  get [Symbol.toStringTag]() {
15
37
  return '@vltpkg/graph.Graph';
@@ -76,6 +98,7 @@ export class Graph {
76
98
  mainImporter.setImporterLocation(mainImporterLocation);
77
99
  mainImporter.mainImporter = true;
78
100
  this.mainImporter = mainImporter;
101
+ this.mainImporter.workspaces = new Map();
79
102
  this.importers.add(mainImporter);
80
103
  this.manifests.set(mainImporter.id, mainManifest);
81
104
  // uses the monorepo instance in order to retrieve info on
@@ -89,11 +112,14 @@ export class Graph {
89
112
  this.manifests.set(wsNode.id, wsNode.manifest);
90
113
  }
91
114
  this.importers.add(wsNode);
115
+ // creates a virtual edge to connect the workspaces to the root node
116
+ const edge = new Edge('prod', Spec.parse(wsNode.name, 'workspace:*', this.#options), this.mainImporter, wsNode);
117
+ this.mainImporter.workspaces.set(wsNode.name, edge);
92
118
  }
93
119
  }
94
120
  }
95
121
  /**
96
- * Delete all nodes that are unreachable from the importers.
122
+ * Delete all nodes and edges that are unreachable from the importers.
97
123
  * The collection of deleted nodes is returned.
98
124
  *
99
125
  * NOTE: This can be extremely slow for large graphs, and is almost always
@@ -103,13 +129,16 @@ export class Graph {
103
129
  */
104
130
  gc() {
105
131
  const { nodes } = this;
132
+ this.edges.clear();
106
133
  this.nodes = new Map();
107
134
  const marked = new Set(this.importers);
108
135
  for (const imp of marked) {
109
136
  // don't delete the importer!
110
137
  nodes.delete(imp.id);
111
138
  this.nodes.set(imp.id, imp);
112
- for (const { to } of imp.edgesOut.values()) {
139
+ for (const edge of imp.edgesOut.values()) {
140
+ this.edges.add(edge);
141
+ const { to } = edge;
113
142
  if (!to || marked.has(to))
114
143
  continue;
115
144
  marked.add(to);
@@ -144,6 +173,9 @@ export class Graph {
144
173
  if (edge.type === type &&
145
174
  edge.spec.bareSpec === spec.bareSpec) {
146
175
  if (to && to !== edge.to) {
176
+ // removes this edge from its destination edgesIn ref
177
+ edge.to?.edgesIn.delete(edge);
178
+ // now swap the destination to the new one
147
179
  edge.to = to;
148
180
  edge.to.edgesIn.add(edge);
149
181
  }
@@ -152,18 +184,16 @@ export class Graph {
152
184
  this.edges.delete(edge);
153
185
  }
154
186
  const f = from;
155
- const edgeOut = f.addEdgesTo(type, spec, to);
187
+ const edgeOut = f.addEdgesTo(resolveSaveType(from, spec.name, type), spec, to);
156
188
  this.edges.add(edgeOut);
157
189
  return edgeOut;
158
190
  }
159
191
  /**
160
192
  * Find an existing node to satisfy a dependency
161
193
  */
162
- findResolution(spec, fromNode) {
194
+ findResolution(spec, fromNode, queryModifier = '') {
163
195
  const f = spec.final;
164
- // if it's a file: dep, then the fromNode location matters
165
- const fromPref = f.type === 'file' ? fromNode.location + ' : ' : '';
166
- const sf = fromPref + String(f);
196
+ const sf = getResolutionCacheKey(f, fromNode.location, queryModifier);
167
197
  const cached = this.resolutions.get(sf);
168
198
  if (cached)
169
199
  return cached;
@@ -188,17 +218,6 @@ export class Graph {
188
218
  const nbn = this.nodesByName.get(node.name) ?? new Set();
189
219
  nbn.add(node);
190
220
  this.nodesByName.set(node.name, nbn);
191
- if (spec) {
192
- const f = String(spec.final);
193
- // if it's a file: type, then that is fromNode-specific,
194
- // so we can't shortcut add it here.
195
- if (spec.final.type !== 'file') {
196
- this.resolutions.set(f, node);
197
- const rrev = this.resolutionsReverse.get(node) ?? new Set();
198
- rrev.add(f);
199
- this.resolutionsReverse.set(node, rrev);
200
- }
201
- }
202
221
  if (manifest) {
203
222
  this.manifests.set(node.id, manifest);
204
223
  }
@@ -212,7 +231,7 @@ export class Graph {
212
231
  * For different uses that are not a direct top-down traversal of the graph
213
232
  * consider using `addNode()` and `addEdge()` instead.
214
233
  */
215
- placePackage(fromNode, depType, spec, manifest, id) {
234
+ placePackage(fromNode, depType, spec, manifest, id, extra) {
216
235
  // if no manifest is available, then create an edge that has no
217
236
  // reference to any other node, representing a missing dependency
218
237
  if (!manifest && !id) {
@@ -226,7 +245,7 @@ export class Graph {
226
245
  depType === 'optional' ||
227
246
  depType === 'peerOptional',
228
247
  };
229
- const depId = id || (manifest && getId(spec, manifest));
248
+ const depId = id || (manifest && getId(spec, manifest, extra));
230
249
  /* c8 ignore start - should not be possible */
231
250
  if (!depId) {
232
251
  throw error('Could not find dep id when placing package', {
@@ -247,21 +266,51 @@ export class Graph {
247
266
  return toFoundNode;
248
267
  }
249
268
  // creates a new node and edges to its parent
250
- const toNode = this.addNode(depId, manifest);
269
+ const toNode = this.addNode(depId, manifest, spec);
251
270
  toNode.registry = spec.registry;
252
271
  toNode.dev = flags.dev;
253
272
  toNode.optional = flags.optional;
273
+ toNode.modifier = extra;
274
+ // add extra manifest info if available
275
+ if (manifest) {
276
+ const { bin, engines, os, cpu } = manifest;
277
+ // add platform info if available
278
+ if (engines || os || cpu) {
279
+ const platform = {};
280
+ if (engines)
281
+ platform.engines = engines;
282
+ if (os)
283
+ platform.os = os;
284
+ if (cpu)
285
+ platform.cpu = cpu;
286
+ toNode.platform = platform;
287
+ }
288
+ // add bin info if available
289
+ if (bin) {
290
+ toNode.bins = bin;
291
+ }
292
+ }
293
+ toNode.maybeSetConfusedManifest(spec, manifest);
254
294
  this.addEdge(depType, spec, fromNode, toNode);
295
+ // populate resolution cache if applicable
296
+ const f = getResolutionCacheKey(spec.final, fromNode.location, extra || '');
297
+ this.resolutions.set(f, toNode);
298
+ const rrev = this.resolutionsReverse.get(toNode) ?? new Set();
299
+ rrev.add(f);
300
+ this.resolutionsReverse.set(toNode, rrev);
255
301
  return toNode;
256
302
  }
257
303
  /**
258
304
  * Removes a node and its relevant edges from the graph.
259
305
  *
306
+ * Use the `keepEdges` option to keep the edges that were pointing to
307
+ * this node and only removes their `to` property value.
308
+ *
260
309
  * If a replacement is provided, then any edges that were previously
261
310
  * pointing to the removed node will be directed to the replacement,
262
311
  * if it is valid to do so.
263
312
  */
264
- removeNode(node, replacement) {
313
+ removeNode(node, replacement, keepEdges) {
265
314
  this.nodes.delete(node.id);
266
315
  const nbn = this.nodesByName.get(node.name);
267
316
  // if it's the last one, just remove the set
@@ -282,12 +331,67 @@ export class Graph {
282
331
  satisfies(replacement.id, edge.spec, edge.from.location, this.projectRoot, this.monorepo)) {
283
332
  edge.to = replacement;
284
333
  }
334
+ else if (keepEdges) {
335
+ edge.to = undefined;
336
+ }
285
337
  else {
286
338
  edge.from.edgesOut.delete(edge.spec.name);
287
339
  this.edges.delete(edge);
288
340
  }
289
341
  }
290
342
  }
343
+ /**
344
+ * Removes the resolved node of a given edge.
345
+ */
346
+ removeEdgeResolution(edge, queryModifier = '') {
347
+ const node = edge.to;
348
+ const resolutionKey = getResolutionCacheKey(edge.spec, edge.from.location, queryModifier);
349
+ if (node) {
350
+ edge.to = undefined;
351
+ this.resolutions.delete(resolutionKey);
352
+ this.resolutionsReverse.get(node)?.delete(resolutionKey);
353
+ this.nodesByName.delete(node.name);
354
+ node.edgesIn.delete(edge);
355
+ if (node.edgesIn.size === 0) {
356
+ this.nodes.delete(node.id);
357
+ }
358
+ }
359
+ }
360
+ /**
361
+ * Reset resolution cache data.
362
+ */
363
+ resetResolution() {
364
+ // Clear all cache structures
365
+ this.resolutions.clear();
366
+ this.resolutionsReverse.clear();
367
+ this.nodesByName.clear();
368
+ // Rebuild nodesByName from all nodes
369
+ for (const node of this.nodes.values()) {
370
+ const nbn = this.nodesByName.get(node.name) ?? new Set();
371
+ nbn.add(node);
372
+ this.nodesByName.set(node.name, nbn);
373
+ }
374
+ // Rebuild resolution caches from all edges that have resolved targets
375
+ const seenNodes = new Set();
376
+ for (const edge of this.edges) {
377
+ const { to: node } = edge;
378
+ if (!node)
379
+ continue; // Skip unresolved edges
380
+ // Only process each node once to avoid duplicate cache entries
381
+ if (seenNodes.has(node))
382
+ continue;
383
+ seenNodes.add(node);
384
+ // Initialize resolutionsReverse entry for this node if it doesn't exist
385
+ if (!this.resolutionsReverse.has(node)) {
386
+ this.resolutionsReverse.set(node, new Set());
387
+ }
388
+ // Get the modifier if the node has one associated to it
389
+ const queryModifier = node.modifier || '';
390
+ const resolutionKey = getResolutionCacheKey(edge.spec.final, edge.from.location, queryModifier);
391
+ this.resolutions.set(resolutionKey, node);
392
+ this.resolutionsReverse.get(node)?.add(resolutionKey);
393
+ }
394
+ }
291
395
  toJSON() {
292
396
  return lockfileData({
293
397
  ...this.#options,
@@ -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,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,CAChD,CAAC,IAAK,IAAI,GAAG,EAAQ,CAAA;AAqBvB,MAAM,OAAO,KAAK;IAChB,IAAI,CAA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E,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"]}
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,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,M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IAAI;gBAAE,SAAQ,CAAC,wBAAwB;YAE5C,+DAA+D;YAC/D,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,SAAQ;YACjC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YAEnB,wEAAwE;YACxE,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,EAAE,CAAC,CAAA;YAC9C,CAAC;YAED,wDAAwD;YACxD,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAA;YACzC,MAAM,aAAa,GAAG,qBAAqB,CACzC,IAAI,CAAC,IAAI,CAAC,KAAK,EACf,IAAI,CAAC,IAAI,CAAC,QAAQ,EAClB,aAAa,CACd,CAAA;YAED,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;YACzC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC,CAAA;QACvD,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 {\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,8 +1,15 @@
1
+ import type { PathScurry } from 'path-scurry';
1
2
  import type { PackageInfoClient } from '@vltpkg/package-info';
2
3
  import type { SpecOptions } from '@vltpkg/spec';
3
- import type { PathScurry } from 'path-scurry';
4
+ import type { RollbackRemove } from '@vltpkg/rollback-remove';
4
5
  import type { BuildIdealAddOptions, BuildIdealFromGraphOptions } from './types.ts';
6
+ import type { GraphModifier } from '../modifiers.ts';
7
+ import type { Graph } from '../graph.ts';
5
8
  export type AddNodesOptions = BuildIdealAddOptions & BuildIdealFromGraphOptions & SpecOptions & {
9
+ /**
10
+ * The graph modifiers helper object.
11
+ */
12
+ modifiers?: GraphModifier;
6
13
  /**
7
14
  * A {@link PathScurry} instance based on the `projectRoot` path
8
15
  */
@@ -11,9 +18,17 @@ export type AddNodesOptions = BuildIdealAddOptions & BuildIdealFromGraphOptions
11
18
  * A {@link PackageInfoClient} instance to read manifest info from.
12
19
  */
13
20
  packageInfo: PackageInfoClient;
21
+ /**
22
+ * The actual graph to compare against for early extraction
23
+ */
24
+ actual?: Graph;
25
+ /**
26
+ * A {@link RollbackRemove} instance to handle extraction rollbacks
27
+ */
28
+ remover: RollbackRemove;
14
29
  };
15
30
  /**
16
31
  * Add new nodes in the given `graph` for dependencies specified at `add`.
17
32
  */
18
- export declare const addNodes: ({ add, graph, packageInfo, scurry, ...specOptions }: AddNodesOptions) => Promise<void>;
33
+ export declare const addNodes: ({ add, graph, modifiers, packageInfo, scurry, actual, remover, ...specOptions }: AddNodesOptions) => Promise<void>;
19
34
  //# sourceMappingURL=add-nodes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/ideal/add-nodes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,YAAY,CAAA;AAEnB,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAChD,0BAA0B,GAC1B,WAAW,GAAG;IACZ;;OAEG;IACH,MAAM,EAAE,UAAU,CAAA;IAElB;;OAEG;IACH,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,QAAQ,wDAMlB,eAAe,kBA+BjB,CAAA"}
1
+ {"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/ideal/add-nodes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAChD,0BAA0B,GAC1B,WAAW,GAAG;IACZ;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB;;OAEG;IACH,MAAM,EAAE,UAAU,CAAA;IAElB;;OAEG;IACH,WAAW,EAAE,iBAAiB,CAAA;IAE9B;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAA;IAEd;;OAEG;IACH,OAAO,EAAE,cAAc,CAAA;CACxB,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,QAAQ,oFASlB,eAAe,kBAiDjB,CAAA"}
@@ -1,10 +1,13 @@
1
1
  import { error } from '@vltpkg/error-cause';
2
2
  import { appendNodes } from "./append-nodes.js";
3
+ import { resolveSaveType } from "../resolve-save-type.js";
3
4
  /**
4
5
  * Add new nodes in the given `graph` for dependencies specified at `add`.
5
6
  */
6
- export const addNodes = async ({ add, graph, packageInfo, scurry, ...specOptions }) => {
7
+ export const addNodes = async ({ add, graph, modifiers, packageInfo, scurry, actual, remover, ...specOptions }) => {
7
8
  const seen = new Set();
9
+ const extractPromises = [];
10
+ const seenExtracted = new Set();
8
11
  // iterates on the list of dependencies per importer updating
9
12
  // the graph using metadata fetch from the registry manifest files
10
13
  for (const [depID, dependencies] of add) {
@@ -12,17 +15,25 @@ export const addNodes = async ({ add, graph, packageInfo, scurry, ...specOptions
12
15
  if (!importer) {
13
16
  throw error('Could not find importer', { found: depID });
14
17
  }
18
+ modifiers?.tryImporter(importer);
15
19
  // Removes any edges and nodes that are currently part of the
16
20
  // graph but are also in the list of dependencies to be installed
17
21
  const deps = [...dependencies.values()];
18
- for (const { spec } of deps) {
19
- const node = importer.edgesOut.get(spec.name)?.to;
22
+ for (const dep of deps) {
23
+ const { spec } = dep;
24
+ const existingEdge = importer.edgesOut.get(spec.name);
25
+ dep.type = resolveSaveType(importer, spec.name, dep.type);
26
+ const node = existingEdge?.to;
20
27
  if (node)
21
28
  graph.removeNode(node);
22
29
  }
23
30
  // Add new nodes for packages defined in the dependencies list fetching
24
31
  // metadata from the registry manifests and updating the graph
25
- await appendNodes(dependencies, packageInfo, graph, importer, deps, scurry, specOptions, seen);
32
+ await appendNodes(dependencies, packageInfo, graph, importer, deps, scurry, specOptions, seen, modifiers, modifiers?.tryDependencies(importer, deps), extractPromises, actual, seenExtracted, remover);
33
+ }
34
+ // Wait for all extraction promises to complete
35
+ if (extractPromises.length > 0) {
36
+ await Promise.all(extractPromises);
26
37
  }
27
38
  };
28
39
  //# sourceMappingURL=add-nodes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"add-nodes.js","sourceRoot":"","sources":["../../../src/ideal/add-nodes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAI3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAoB/C;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,EAC7B,GAAG,EACH,KAAK,EACL,WAAW,EACX,MAAM,EACN,GAAG,WAAW,EACE,EAAE,EAAE;IACpB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAS,CAAA;IAC7B,6DAA6D;IAC7D,kEAAkE;IAClE,KAAK,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,GAAG,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACvC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,KAAK,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;QAC1D,CAAC;QAED,6DAA6D;QAC7D,iEAAiE;QACjE,MAAM,IAAI,GAAG,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,CAAC,CAAA;QACvC,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;YAC5B,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAA;YACjD,IAAI,IAAI;gBAAE,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;QAED,uEAAuE;QACvE,8DAA8D;QAC9D,MAAM,WAAW,CACf,YAAY,EACZ,WAAW,EACX,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,WAAW,EACX,IAAI,CACL,CAAA;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { PathScurry } from 'path-scurry'\nimport { appendNodes } from './append-nodes.ts'\nimport type {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n} from './types.ts'\n\nexport type AddNodesOptions = BuildIdealAddOptions &\n BuildIdealFromGraphOptions &\n SpecOptions & {\n /**\n * A {@link PathScurry} instance based on the `projectRoot` path\n */\n scurry: PathScurry\n\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n }\n\n/**\n * Add new nodes in the given `graph` for dependencies specified at `add`.\n */\nexport const addNodes = async ({\n add,\n graph,\n packageInfo,\n scurry,\n ...specOptions\n}: AddNodesOptions) => {\n const seen = new Set<DepID>()\n // iterates on the list of dependencies per importer updating\n // the graph using metadata fetch from the registry manifest files\n for (const [depID, dependencies] of add) {\n const importer = graph.nodes.get(depID)\n if (!importer) {\n throw error('Could not find importer', { found: depID })\n }\n\n // Removes any edges and nodes that are currently part of the\n // graph but are also in the list of dependencies to be installed\n const deps = [...dependencies.values()]\n for (const { spec } of deps) {\n const node = importer.edgesOut.get(spec.name)?.to\n if (node) graph.removeNode(node)\n }\n\n // Add new nodes for packages defined in the dependencies list fetching\n // metadata from the registry manifests and updating the graph\n await appendNodes(\n dependencies,\n packageInfo,\n graph,\n importer,\n deps,\n scurry,\n specOptions,\n seen,\n )\n }\n}\n"]}
1
+ {"version":3,"file":"add-nodes.js","sourceRoot":"","sources":["../../../src/ideal/add-nodes.ts"],"names":[],"mappings":"A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MAAM,IAAI,GAAG,YAAY,EAAE,EAAE,CAAA;YAC7B,IAAI,IAAI;gBAAE,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC;QAED,uEAAuE;QACvE,8DAA8D;QAC9D,MAAM,WAAW,CACf,YAAY,EACZ,WAAW,EACX,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,WAAW,EACX,IAAI,EACJ,SAAS,EACT,SAAS,EAAE,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,EAC1C,eAAe,EACf,MAAM,EACN,aAAa,EACb,OAAO,CACR,CAAA;IACH,CAAC;IAED,+CAA+C;IAC/C,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;IACpC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { appendNodes } from './append-nodes.ts'\nimport { resolveSaveType } from '../resolve-save-type.ts'\nimport type { PathScurry } from 'path-scurry'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type {\n BuildIdealAddOptions,\n BuildIdealFromGraphOptions,\n} from './types.ts'\nimport type { GraphModifier } from '../modifiers.ts'\nimport type { ExtractResult } from '../reify/extract-node.ts'\nimport type { Graph } from '../graph.ts'\n\nexport type AddNodesOptions = BuildIdealAddOptions &\n BuildIdealFromGraphOptions &\n SpecOptions & {\n /**\n * The graph modifiers helper object.\n */\n modifiers?: GraphModifier\n /**\n * A {@link PathScurry} instance based on the `projectRoot` path\n */\n scurry: PathScurry\n\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n\n /**\n * The actual graph to compare against for early extraction\n */\n actual?: Graph\n\n /**\n * A {@link RollbackRemove} instance to handle extraction rollbacks\n */\n remover: RollbackRemove\n }\n\n/**\n * Add new nodes in the given `graph` for dependencies specified at `add`.\n */\nexport const addNodes = async ({\n add,\n graph,\n modifiers,\n packageInfo,\n scurry,\n actual,\n remover,\n ...specOptions\n}: AddNodesOptions) => {\n const seen = new Set<DepID>()\n const extractPromises: Promise<ExtractResult>[] = []\n const seenExtracted = new Set<DepID>()\n\n // iterates on the list of dependencies per importer updating\n // the graph using metadata fetch from the registry manifest files\n for (const [depID, dependencies] of add) {\n const importer = graph.nodes.get(depID)\n if (!importer) {\n throw error('Could not find importer', { found: depID })\n }\n modifiers?.tryImporter(importer)\n\n // Removes any edges and nodes that are currently part of the\n // graph but are also in the list of dependencies to be installed\n const deps = [...dependencies.values()]\n for (const dep of deps) {\n const { spec } = dep\n const existingEdge = importer.edgesOut.get(spec.name)\n dep.type = resolveSaveType(importer, spec.name, dep.type)\n const node = existingEdge?.to\n if (node) graph.removeNode(node)\n }\n\n // Add new nodes for packages defined in the dependencies list fetching\n // metadata from the registry manifests and updating the graph\n await appendNodes(\n dependencies,\n packageInfo,\n graph,\n importer,\n deps,\n scurry,\n specOptions,\n seen,\n modifiers,\n modifiers?.tryDependencies(importer, deps),\n extractPromises,\n actual,\n seenExtracted,\n remover,\n )\n }\n\n // Wait for all extraction promises to complete\n if (extractPromises.length > 0) {\n await Promise.all(extractPromises)\n }\n}\n"]}
@@ -5,5 +5,15 @@ import type { PathScurry } from 'path-scurry';
5
5
  import type { Dependency } from '../dependencies.ts';
6
6
  import type { Graph } from '../graph.ts';
7
7
  import type { Node } from '../node.ts';
8
- export declare const appendNodes: (add: Map<string, Dependency>, packageInfo: PackageInfoClient, graph: Graph, fromNode: Node, deps: Dependency[], scurry: PathScurry, options: SpecOptions, seen: Set<DepID>) => Promise<void>;
8
+ import type { GraphModifier, ModifierActiveEntry } from '../modifiers.ts';
9
+ import type { ExtractResult } from '../reify/extract-node.ts';
10
+ import type { RollbackRemove } from '@vltpkg/rollback-remove';
11
+ /**
12
+ * Append new nodes in the given `graph` for dependencies specified at `add`
13
+ * and missing dependencies from the `deps` parameter.
14
+ *
15
+ * It also applies any modifiers that applies to a given node as it processes
16
+ * and builds the graph.
17
+ */
18
+ export declare const appendNodes: (add: Map<string, Dependency>, packageInfo: PackageInfoClient, graph: Graph, fromNode: Node, deps: Dependency[], scurry: PathScurry, options: SpecOptions, seen: Set<DepID>, modifiers?: GraphModifier, modifierRefs?: Map<string, ModifierActiveEntry>, extractPromises?: Promise<ExtractResult>[], actual?: Graph, seenExtracted?: Set<DepID>, remover?: RollbackRemove) => Promise<void>;
9
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;AAG/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;AAuDtC,eAAO,MAAM,WAAW,QACjB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,eACf,iBAAiB,SACvB,KAAK,YACF,IAAI,QACR,UAAU,EAAE,UACV,UAAU,WACT,WAAW,QACd,GAAG,CAAC,KAAK,CAAC,kBAwIjB,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,EA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