@vltpkg/graph 1.0.0-rc.2 → 1.0.0-rc.22

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 (211) hide show
  1. package/README.md +101 -22
  2. package/package.json +51 -63
  3. package/dist/esm/actual/load.d.ts +0 -100
  4. package/dist/esm/actual/load.d.ts.map +0 -1
  5. package/dist/esm/actual/load.js +0 -304
  6. package/dist/esm/actual/load.js.map +0 -1
  7. package/dist/esm/browser.d.ts +0 -15
  8. package/dist/esm/browser.d.ts.map +0 -1
  9. package/dist/esm/browser.js +0 -17
  10. package/dist/esm/browser.js.map +0 -1
  11. package/dist/esm/build.d.ts +0 -29
  12. package/dist/esm/build.d.ts.map +0 -1
  13. package/dist/esm/build.js +0 -79
  14. package/dist/esm/build.js.map +0 -1
  15. package/dist/esm/dependencies.d.ts +0 -66
  16. package/dist/esm/dependencies.d.ts.map +0 -1
  17. package/dist/esm/dependencies.js +0 -112
  18. package/dist/esm/dependencies.js.map +0 -1
  19. package/dist/esm/diff.d.ts +0 -116
  20. package/dist/esm/diff.d.ts.map +0 -1
  21. package/dist/esm/diff.js +0 -148
  22. package/dist/esm/diff.js.map +0 -1
  23. package/dist/esm/edge.d.ts +0 -46
  24. package/dist/esm/edge.d.ts.map +0 -1
  25. package/dist/esm/edge.js +0 -74
  26. package/dist/esm/edge.js.map +0 -1
  27. package/dist/esm/graph.d.ts +0 -133
  28. package/dist/esm/graph.d.ts.map +0 -1
  29. package/dist/esm/graph.js +0 -407
  30. package/dist/esm/graph.js.map +0 -1
  31. package/dist/esm/ideal/add-nodes.d.ts +0 -34
  32. package/dist/esm/ideal/add-nodes.d.ts.map +0 -1
  33. package/dist/esm/ideal/add-nodes.js +0 -39
  34. package/dist/esm/ideal/add-nodes.js.map +0 -1
  35. package/dist/esm/ideal/append-nodes.d.ts +0 -19
  36. package/dist/esm/ideal/append-nodes.d.ts.map +0 -1
  37. package/dist/esm/ideal/append-nodes.js +0 -289
  38. package/dist/esm/ideal/append-nodes.js.map +0 -1
  39. package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts +0 -15
  40. package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +0 -1
  41. package/dist/esm/ideal/build-ideal-from-starting-graph.js +0 -55
  42. package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +0 -1
  43. package/dist/esm/ideal/build.d.ts +0 -41
  44. package/dist/esm/ideal/build.d.ts.map +0 -1
  45. package/dist/esm/ideal/build.js +0 -48
  46. package/dist/esm/ideal/build.js.map +0 -1
  47. package/dist/esm/ideal/get-importer-specs.d.ts +0 -14
  48. package/dist/esm/ideal/get-importer-specs.d.ts.map +0 -1
  49. package/dist/esm/ideal/get-importer-specs.js +0 -106
  50. package/dist/esm/ideal/get-importer-specs.js.map +0 -1
  51. package/dist/esm/ideal/remove-nodes.d.ts +0 -7
  52. package/dist/esm/ideal/remove-nodes.d.ts.map +0 -1
  53. package/dist/esm/ideal/remove-nodes.js +0 -19
  54. package/dist/esm/ideal/remove-nodes.js.map +0 -1
  55. package/dist/esm/ideal/remove-satisfied-specs.d.ts +0 -8
  56. package/dist/esm/ideal/remove-satisfied-specs.d.ts.map +0 -1
  57. package/dist/esm/ideal/remove-satisfied-specs.js +0 -35
  58. package/dist/esm/ideal/remove-satisfied-specs.js.map +0 -1
  59. package/dist/esm/ideal/types.d.ts +0 -35
  60. package/dist/esm/ideal/types.d.ts.map +0 -1
  61. package/dist/esm/ideal/types.js +0 -2
  62. package/dist/esm/ideal/types.js.map +0 -1
  63. package/dist/esm/index.d.ts +0 -38
  64. package/dist/esm/index.d.ts.map +0 -1
  65. package/dist/esm/index.js +0 -32
  66. package/dist/esm/index.js.map +0 -1
  67. package/dist/esm/install.d.ts +0 -19
  68. package/dist/esm/install.d.ts.map +0 -1
  69. package/dist/esm/install.js +0 -173
  70. package/dist/esm/install.js.map +0 -1
  71. package/dist/esm/lockfile/load-edges.d.ts +0 -12
  72. package/dist/esm/lockfile/load-edges.d.ts.map +0 -1
  73. package/dist/esm/lockfile/load-edges.js +0 -105
  74. package/dist/esm/lockfile/load-edges.js.map +0 -1
  75. package/dist/esm/lockfile/load-nodes.d.ts +0 -5
  76. package/dist/esm/lockfile/load-nodes.d.ts.map +0 -1
  77. package/dist/esm/lockfile/load-nodes.js +0 -95
  78. package/dist/esm/lockfile/load-nodes.js.map +0 -1
  79. package/dist/esm/lockfile/load.d.ts +0 -50
  80. package/dist/esm/lockfile/load.d.ts.map +0 -1
  81. package/dist/esm/lockfile/load.js +0 -89
  82. package/dist/esm/lockfile/load.js.map +0 -1
  83. package/dist/esm/lockfile/save.d.ts +0 -31
  84. package/dist/esm/lockfile/save.d.ts.map +0 -1
  85. package/dist/esm/lockfile/save.js +0 -173
  86. package/dist/esm/lockfile/save.js.map +0 -1
  87. package/dist/esm/lockfile/types.d.ts +0 -89
  88. package/dist/esm/lockfile/types.d.ts.map +0 -1
  89. package/dist/esm/lockfile/types.js +0 -44
  90. package/dist/esm/lockfile/types.js.map +0 -1
  91. package/dist/esm/modifiers.d.ts +0 -189
  92. package/dist/esm/modifiers.d.ts.map +0 -1
  93. package/dist/esm/modifiers.js +0 -330
  94. package/dist/esm/modifiers.js.map +0 -1
  95. package/dist/esm/node.d.ts +0 -219
  96. package/dist/esm/node.d.ts.map +0 -1
  97. package/dist/esm/node.js +0 -368
  98. package/dist/esm/node.js.map +0 -1
  99. package/dist/esm/non-empty-list.d.ts +0 -3
  100. package/dist/esm/non-empty-list.d.ts.map +0 -1
  101. package/dist/esm/non-empty-list.js +0 -3
  102. package/dist/esm/non-empty-list.js.map +0 -1
  103. package/dist/esm/package.json +0 -3
  104. package/dist/esm/reify/add-edge.d.ts +0 -10
  105. package/dist/esm/reify/add-edge.d.ts.map +0 -1
  106. package/dist/esm/reify/add-edge.js +0 -65
  107. package/dist/esm/reify/add-edge.js.map +0 -1
  108. package/dist/esm/reify/add-edges.d.ts +0 -5
  109. package/dist/esm/reify/add-edges.d.ts.map +0 -1
  110. package/dist/esm/reify/add-edges.js +0 -12
  111. package/dist/esm/reify/add-edges.js.map +0 -1
  112. package/dist/esm/reify/add-nodes.d.ts +0 -7
  113. package/dist/esm/reify/add-nodes.d.ts.map +0 -1
  114. package/dist/esm/reify/add-nodes.js +0 -17
  115. package/dist/esm/reify/add-nodes.js.map +0 -1
  116. package/dist/esm/reify/bin-chmod.d.ts +0 -11
  117. package/dist/esm/reify/bin-chmod.d.ts.map +0 -1
  118. package/dist/esm/reify/bin-chmod.js +0 -39
  119. package/dist/esm/reify/bin-chmod.js.map +0 -1
  120. package/dist/esm/reify/build.d.ts +0 -14
  121. package/dist/esm/reify/build.d.ts.map +0 -1
  122. package/dist/esm/reify/build.js +0 -103
  123. package/dist/esm/reify/build.js.map +0 -1
  124. package/dist/esm/reify/calculate-save-value.d.ts +0 -3
  125. package/dist/esm/reify/calculate-save-value.d.ts.map +0 -1
  126. package/dist/esm/reify/calculate-save-value.js +0 -45
  127. package/dist/esm/reify/calculate-save-value.js.map +0 -1
  128. package/dist/esm/reify/check-needed-build.d.ts +0 -25
  129. package/dist/esm/reify/check-needed-build.d.ts.map +0 -1
  130. package/dist/esm/reify/check-needed-build.js +0 -50
  131. package/dist/esm/reify/check-needed-build.js.map +0 -1
  132. package/dist/esm/reify/delete-edge.d.ts +0 -5
  133. package/dist/esm/reify/delete-edge.d.ts.map +0 -1
  134. package/dist/esm/reify/delete-edge.js +0 -28
  135. package/dist/esm/reify/delete-edge.js.map +0 -1
  136. package/dist/esm/reify/delete-edges.d.ts +0 -5
  137. package/dist/esm/reify/delete-edges.d.ts.map +0 -1
  138. package/dist/esm/reify/delete-edges.js +0 -14
  139. package/dist/esm/reify/delete-edges.js.map +0 -1
  140. package/dist/esm/reify/delete-nodes.d.ts +0 -5
  141. package/dist/esm/reify/delete-nodes.d.ts.map +0 -1
  142. package/dist/esm/reify/delete-nodes.js +0 -16
  143. package/dist/esm/reify/delete-nodes.js.map +0 -1
  144. package/dist/esm/reify/extract-node.d.ts +0 -24
  145. package/dist/esm/reify/extract-node.d.ts.map +0 -1
  146. package/dist/esm/reify/extract-node.js +0 -76
  147. package/dist/esm/reify/extract-node.js.map +0 -1
  148. package/dist/esm/reify/index.d.ts +0 -34
  149. package/dist/esm/reify/index.d.ts.map +0 -1
  150. package/dist/esm/reify/index.js +0 -161
  151. package/dist/esm/reify/index.js.map +0 -1
  152. package/dist/esm/reify/internal-hoist.d.ts +0 -9
  153. package/dist/esm/reify/internal-hoist.d.ts.map +0 -1
  154. package/dist/esm/reify/internal-hoist.js +0 -134
  155. package/dist/esm/reify/internal-hoist.js.map +0 -1
  156. package/dist/esm/reify/optional-fail.d.ts +0 -16
  157. package/dist/esm/reify/optional-fail.d.ts.map +0 -1
  158. package/dist/esm/reify/optional-fail.js +0 -16
  159. package/dist/esm/reify/optional-fail.js.map +0 -1
  160. package/dist/esm/reify/rollback.d.ts +0 -5
  161. package/dist/esm/reify/rollback.d.ts.map +0 -1
  162. package/dist/esm/reify/rollback.js +0 -24
  163. package/dist/esm/reify/rollback.js.map +0 -1
  164. package/dist/esm/reify/update-importers-package-json.d.ts +0 -36
  165. package/dist/esm/reify/update-importers-package-json.d.ts.map +0 -1
  166. package/dist/esm/reify/update-importers-package-json.js +0 -120
  167. package/dist/esm/reify/update-importers-package-json.js.map +0 -1
  168. package/dist/esm/remove-optional-subgraph.d.ts +0 -34
  169. package/dist/esm/remove-optional-subgraph.d.ts.map +0 -1
  170. package/dist/esm/remove-optional-subgraph.js +0 -48
  171. package/dist/esm/remove-optional-subgraph.js.map +0 -1
  172. package/dist/esm/resolve-save-type.d.ts +0 -6
  173. package/dist/esm/resolve-save-type.d.ts.map +0 -1
  174. package/dist/esm/resolve-save-type.js +0 -5
  175. package/dist/esm/resolve-save-type.js.map +0 -1
  176. package/dist/esm/stringify-node.d.ts +0 -3
  177. package/dist/esm/stringify-node.d.ts.map +0 -1
  178. package/dist/esm/stringify-node.js +0 -24
  179. package/dist/esm/stringify-node.js.map +0 -1
  180. package/dist/esm/transfer-data/load.d.ts +0 -44
  181. package/dist/esm/transfer-data/load.d.ts.map +0 -1
  182. package/dist/esm/transfer-data/load.js +0 -176
  183. package/dist/esm/transfer-data/load.js.map +0 -1
  184. package/dist/esm/uninstall.d.ts +0 -15
  185. package/dist/esm/uninstall.d.ts.map +0 -1
  186. package/dist/esm/uninstall.js +0 -58
  187. package/dist/esm/uninstall.js.map +0 -1
  188. package/dist/esm/update.d.ts +0 -13
  189. package/dist/esm/update.d.ts.map +0 -1
  190. package/dist/esm/update.js +0 -63
  191. package/dist/esm/update.js.map +0 -1
  192. package/dist/esm/virtual-root.d.ts +0 -16
  193. package/dist/esm/virtual-root.d.ts.map +0 -1
  194. package/dist/esm/virtual-root.js +0 -79
  195. package/dist/esm/virtual-root.js.map +0 -1
  196. package/dist/esm/visualization/human-readable-output.d.ts +0 -27
  197. package/dist/esm/visualization/human-readable-output.d.ts.map +0 -1
  198. package/dist/esm/visualization/human-readable-output.js +0 -159
  199. package/dist/esm/visualization/human-readable-output.js.map +0 -1
  200. package/dist/esm/visualization/json-output.d.ts +0 -41
  201. package/dist/esm/visualization/json-output.d.ts.map +0 -1
  202. package/dist/esm/visualization/json-output.js +0 -51
  203. package/dist/esm/visualization/json-output.js.map +0 -1
  204. package/dist/esm/visualization/mermaid-output.d.ts +0 -17
  205. package/dist/esm/visualization/mermaid-output.d.ts.map +0 -1
  206. package/dist/esm/visualization/mermaid-output.js +0 -123
  207. package/dist/esm/visualization/mermaid-output.js.map +0 -1
  208. package/dist/esm/visualization/object-like-output.d.ts +0 -3
  209. package/dist/esm/visualization/object-like-output.d.ts.map +0 -1
  210. package/dist/esm/visualization/object-like-output.js +0 -48
  211. package/dist/esm/visualization/object-like-output.js.map +0 -1
@@ -1,39 +0,0 @@
1
- import { error } from '@vltpkg/error-cause';
2
- import { appendNodes } from "./append-nodes.js";
3
- import { resolveSaveType } from "../resolve-save-type.js";
4
- /**
5
- * Add new nodes in the given `graph` for dependencies specified at `add`.
6
- */
7
- export const addNodes = async ({ add, graph, modifiers, packageInfo, scurry, actual, remover, ...specOptions }) => {
8
- const seen = new Set();
9
- const extractPromises = [];
10
- const seenExtracted = new Set();
11
- // iterates on the list of dependencies per importer updating
12
- // the graph using metadata fetch from the registry manifest files
13
- for (const [depID, dependencies] of add) {
14
- const importer = graph.nodes.get(depID);
15
- if (!importer) {
16
- throw error('Could not find importer', { found: depID });
17
- }
18
- modifiers?.tryImporter(importer);
19
- // Removes any edges and nodes that are currently part of the
20
- // graph but are also in the list of dependencies to be installed
21
- const deps = [...dependencies.values()];
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;
27
- if (node)
28
- graph.removeNode(node);
29
- }
30
- // Add new nodes for packages defined in the dependencies list fetching
31
- // metadata from the registry manifests and updating the graph
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);
37
- }
38
- };
39
- //# sourceMappingURL=add-nodes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"add-nodes.js","sourceRoot":"","sources":["../../../src/ideal/add-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AA0CzD;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,EAC7B,GAAG,EACH,KAAK,EACL,SAAS,EACT,WAAW,EACX,MAAM,EACN,MAAM,EACN,OAAO,EACP,GAAG,WAAW,EACE,EAAE,EAAE;IACpB,MAAM,IAAI,GAAG,IAA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AAa,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"]}
@@ -1,19 +0,0 @@
1
- import type { DepID } from '@vltpkg/dep-id';
2
- import type { PackageInfoClient } from '@vltpkg/package-info';
3
- import type { SpecOptions } from '@vltpkg/spec';
4
- import type { PathScurry } from 'path-scurry';
5
- import type { Dependency } from '../dependencies.ts';
6
- import type { Graph } from '../graph.ts';
7
- import type { Node } from '../node.ts';
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>;
19
- //# sourceMappingURL=append-nodes.d.ts.map
@@ -1 +0,0 @@
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;AA8W7D;;;;;;GAMG;AACH,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,cACJ,aAAa,iBACV,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,oBAC7B,OAAO,CAAC,aAAa,CAAC,EAAE,WACjC,KAAK,kBACE,GAAG,CAAC,KAAK,CAAC,YAChB,cAAc,kBA2EzB,CAAA"}
@@ -1,289 +0,0 @@
1
- import { joinDepIDTuple } from '@vltpkg/dep-id';
2
- import { error } from '@vltpkg/error-cause';
3
- import { Spec } from '@vltpkg/spec';
4
- import { longDependencyTypes, normalizeManifest } from '@vltpkg/types';
5
- import { asDependency, shorten } from "../dependencies.js";
6
- import { removeOptionalSubgraph } from "../remove-optional-subgraph.js";
7
- import { extractNode } from "../reify/extract-node.js";
8
- /**
9
- * Only install devDeps for git dependencies and importers
10
- * Everything else always gets installed
11
- */
12
- const shouldInstallDepType = (node, depType) => depType !== 'devDependencies' ||
13
- node.importer ||
14
- node.id.startsWith('git');
15
- /**
16
- * Retrieve the {@link DepID} and location for a `file:` type {@link Node}.
17
- */
18
- const getFileTypeInfo = (spec, fromNode, scurry) => {
19
- const f = spec.final;
20
- if (f.type !== 'file')
21
- return;
22
- /* c8 ignore start - should be impossible */
23
- if (!f.file) {
24
- throw error('no path on file specifier', { spec });
25
- }
26
- /* c8 ignore stop */
27
- // Given that both linked folders and local tarballs (both defined with
28
- // usage of the `file:` spec prefix) location needs to be relative to their
29
- // parents, build the expected path and use it for both location and id
30
- const target = scurry.cwd.resolve(fromNode.location).resolve(f.file);
31
- const path = target.relativePosix();
32
- const id = joinDepIDTuple(['file', path]);
33
- return {
34
- path,
35
- id,
36
- isDirectory: !!target.lstatSync()?.isDirectory(),
37
- };
38
- };
39
- const isStringArray = (a) => Array.isArray(a) && !a.some(b => typeof b !== 'string');
40
- /**
41
- * Fetch manifests for dependencies and create placement tasks.
42
- */
43
- const fetchManifestsForDeps = async (packageInfo, graph, fromNode, deps, scurry, modifierRefs, depth = 0) => {
44
- // Create fetch tasks for all dependencies at this level
45
- const fetchTasks = [];
46
- for (const { spec: originalSpec, type } of deps) {
47
- let spec = originalSpec;
48
- const fileTypeInfo = getFileTypeInfo(spec, fromNode, scurry);
49
- const activeModifier = modifierRefs?.get(spec.name);
50
- // here is the place we swap specs if a edge modifier was defined
51
- const queryModifier = activeModifier?.modifier.query;
52
- const completeModifier = activeModifier &&
53
- activeModifier.interactiveBreadcrumb.current ===
54
- activeModifier.modifier.breadcrumb.last;
55
- if (queryModifier &&
56
- completeModifier &&
57
- 'spec' in activeModifier.modifier) {
58
- spec = activeModifier.modifier.spec;
59
- if (spec.bareSpec === '-') {
60
- continue;
61
- }
62
- }
63
- const existingNode = graph.findResolution(spec, fromNode, queryModifier);
64
- if (existingNode) {
65
- // For peerOptional dependencies, create a dangling edge instead of linking to existing node
66
- if (type === 'peerOptional') {
67
- /* c8 ignore next 3 */
68
- // This case happens when peerOptional dep already exists in graph
69
- graph.addEdge(type, spec, fromNode);
70
- }
71
- else {
72
- graph.addEdge(type, spec, fromNode, existingNode);
73
- }
74
- continue;
75
- }
76
- const edgeOptional = type === 'optional' || type === 'peerOptional';
77
- // Start manifest fetch immediately for parallel processing
78
- const manifestPromise = packageInfo
79
- .manifest(spec, { from: scurry.resolve(fromNode.location) })
80
- .then(manifest => manifest)
81
- .catch((er) => {
82
- // optional deps ignored if inaccessible
83
- if (edgeOptional || fromNode.optional) {
84
- return undefined;
85
- }
86
- throw er;
87
- });
88
- const fetchTask = {
89
- spec,
90
- type,
91
- fromNode,
92
- fileTypeInfo,
93
- activeModifier,
94
- queryModifier,
95
- edgeOptional,
96
- manifestPromise,
97
- depth,
98
- };
99
- fetchTasks.push(fetchTask);
100
- }
101
- // Create placement tasks
102
- const placementTasks = [];
103
- for (const fetchTask of fetchTasks) {
104
- const manifest = await fetchTask.manifestPromise;
105
- placementTasks.push({
106
- fetchTask,
107
- manifest,
108
- });
109
- }
110
- return placementTasks;
111
- };
112
- /**
113
- * Process placement tasks and collect child dependencies
114
- */
115
- const processPlacementTasks = async (add, graph, options, placementTasks, modifiers, scurry, packageInfo, extractPromises, actual, seenExtracted, remover) => {
116
- const childDepsToProcess = [];
117
- for (const placementTask of placementTasks) {
118
- 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;
126
- // Handle nameless dependencies
127
- if (manifest?.name && spec.name === '(unknown)') {
128
- const s = add.get(String(spec));
129
- if (s) {
130
- // removes the previous, placeholder entry key
131
- add.delete(String(spec));
132
- // replaces spec with a version with the correct name
133
- spec = Spec.parse(manifest.name, spec.bareSpec, options);
134
- // updates the add map with the fixed up spec
135
- const n = asDependency({
136
- ...s,
137
- spec,
138
- });
139
- add.set(manifest.name, n);
140
- }
141
- }
142
- // handles missing manifest resolution
143
- if (!manifest) {
144
- if (!edgeOptional && fromNode.isOptional()) {
145
- // failed resolution of a non-optional dep of an optional node
146
- // have to clean up the dependents
147
- removeOptionalSubgraph(graph, fromNode);
148
- continue;
149
- }
150
- else if (edgeOptional) {
151
- // failed resolution of an optional dep, just ignore it,
152
- // nothing to prune because we never added it in the first place.
153
- continue;
154
- }
155
- else {
156
- throw error('failed to resolve dependency', {
157
- spec,
158
- from: fromNode.location,
159
- });
160
- }
161
- }
162
- // Skip placing peerOptional dependencies, just create a dangling edge
163
- if (type === 'peerOptional') {
164
- /* c8 ignore next 3 */
165
- graph.addEdge(type, spec, fromNode);
166
- continue;
167
- }
168
- // 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);
170
- /* c8 ignore start - not possible, already ensured manifest */
171
- if (!node) {
172
- throw error('failed to place package', {
173
- from: fromNode.location,
174
- spec,
175
- });
176
- }
177
- /* c8 ignore stop */
178
- // update the node modifier tracker
179
- if (activeModifier) {
180
- modifiers?.updateActiveEntry(node, activeModifier);
181
- }
182
- // Extract the node if it doesn't exist in the actual graph and we have the necessary parameters
183
- if (remover &&
184
- extractPromises &&
185
- actual &&
186
- scurry &&
187
- packageInfo &&
188
- node.inVltStore() &&
189
- !node.isOptional()) {
190
- /* c8 ignore start */
191
- if (seenExtracted?.has(node.id)) {
192
- continue;
193
- }
194
- /* c8 ignore stop */
195
- seenExtracted?.add(node.id);
196
- const actualNode = actual.nodes.get(node.id);
197
- if (!actualNode?.equals(node)) {
198
- // Extract the node without awaiting - push the promise to the array
199
- const extractPromise = extractNode(node, scurry, remover, options, packageInfo);
200
- extractPromises.push(extractPromise);
201
- }
202
- }
203
- // updates graph node information
204
- if (fileTypeInfo?.path && fileTypeInfo.isDirectory) {
205
- node.location = fileTypeInfo.path;
206
- }
207
- node.setResolved();
208
- // Collect child dependencies for processing in the next level
209
- const bundleDeps = manifest.bundleDependencies;
210
- const bundled = new Set((node.id.startsWith('git') ||
211
- node.importer ||
212
- !isStringArray(bundleDeps)) ?
213
- []
214
- : bundleDeps);
215
- // recursively process all child dependencies in the manifest
216
- const nextDeps = [];
217
- for (const depTypeName of longDependencyTypes) {
218
- const depRecord = manifest[depTypeName];
219
- if (depRecord && shouldInstallDepType(node, depTypeName)) {
220
- for (const [name, bareSpec] of Object.entries(depRecord)) {
221
- if (bundled.has(name))
222
- continue;
223
- nextDeps.push({
224
- type: shorten(depTypeName, name, manifest),
225
- spec: Spec.parse(name, bareSpec, {
226
- ...options,
227
- registry: spec.registry,
228
- }),
229
- });
230
- }
231
- }
232
- }
233
- if (nextDeps.length > 0) {
234
- childDepsToProcess.push({
235
- node,
236
- deps: nextDeps,
237
- modifierRefs: modifiers?.tryDependencies(node, nextDeps),
238
- });
239
- }
240
- }
241
- return { childDepsToProcess };
242
- };
243
- /**
244
- * Append new nodes in the given `graph` for dependencies specified at `add`
245
- * and missing dependencies from the `deps` parameter.
246
- *
247
- * It also applies any modifiers that applies to a given node as it processes
248
- * and builds the graph.
249
- */
250
- export const appendNodes = async (add, packageInfo, graph, fromNode, deps, scurry, options, seen, modifiers, modifierRefs, extractPromises, actual, seenExtracted, remover) => {
251
- /* c8 ignore next */
252
- if (seen.has(fromNode.id))
253
- return;
254
- seen.add(fromNode.id);
255
- // Use a queue for breadth-first processing
256
- let currentLevelDeps = [
257
- { node: fromNode, deps, modifierRefs, depth: 0 },
258
- ];
259
- while (currentLevelDeps.length > 0) {
260
- const nextLevelDeps = [];
261
- // Process all nodes at the current level in parallel
262
- const levelResults = await Promise.all(currentLevelDeps.map(async ({ node, deps: nodeDeps, modifierRefs: nodeModifierRefs, depth, }) => {
263
- // Mark node as seen when we start processing its dependencies
264
- seen.add(node.id);
265
- // Fetch manifests for this node's dependencies
266
- const placementTasks = await fetchManifestsForDeps(packageInfo, graph, node,
267
- // Sort dependencies by spec.name for deterministic ordering
268
- nodeDeps.sort((a, b) => a.spec.name.localeCompare(b.spec.name, 'en')), scurry, nodeModifierRefs, depth);
269
- // Process the placement tasks and get child dependencies
270
- return await processPlacementTasks(add, graph, options, placementTasks, modifiers, scurry, packageInfo, extractPromises, actual, seenExtracted, remover);
271
- }));
272
- // Collect all child dependencies for the next level
273
- for (const { childDepsToProcess } of levelResults) {
274
- for (const childDep of childDepsToProcess) {
275
- if (!seen.has(childDep.node.id)) {
276
- /* c8 ignore next */
277
- const currentDepth = currentLevelDeps[0]?.depth ?? 0;
278
- nextLevelDeps.push({
279
- ...childDep,
280
- depth: currentDepth + 1,
281
- });
282
- }
283
- }
284
- }
285
- // Move to the next level
286
- currentLevelDeps = nextLevelDeps;
287
- }
288
- };
289
- //# sourceMappingURL=append-nodes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"append-nodes.js","sourceRoot":"","sources":["../../../src/ideal/append-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAOtE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAI1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAMvE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAStD;;;GAGG;AACH,MAAM,oBAAoB,GAAG,CAC3B,IAAU,EACV,OAA2B,EAC3B,EAAE,CACF,OAAO,KAAK,iBAAiB;IAC7B,IAAI,CAAC,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B;QACzB,gBAAgB,GAAG,aAAa,CAAA;IAClC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { joinDepIDTuple } from '@vltpkg/dep-id'\nimport type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport { Spec } from '@vltpkg/spec'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport { longDependencyTypes, normalizeManifest } from '@vltpkg/types'\nimport type {\n DependencyTypeLong,\n DependencySaveType,\n Manifest,\n} from '@vltpkg/types'\nimport type { PathScurry } from 'path-scurry'\nimport { asDependency, shorten } from '../dependencies.ts'\nimport type { Dependency } from '../dependencies.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\nimport { removeOptionalSubgraph } from '../remove-optional-subgraph.ts'\nimport type {\n GraphModifier,\n ModifierActiveEntry,\n} from '../modifiers.ts'\nimport type { ExtractResult } from '../reify/extract-node.ts'\nimport { extractNode } from '../reify/extract-node.ts'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\n\ntype FileTypeInfo = {\n id: DepID\n path: string\n isDirectory: boolean\n}\n\n/**\n * Only install devDeps for git dependencies and importers\n * Everything else always gets installed\n */\nconst shouldInstallDepType = (\n node: Node,\n depType: DependencyTypeLong,\n) =>\n depType !== 'devDependencies' ||\n node.importer ||\n node.id.startsWith('git')\n\n/**\n * Retrieve the {@link DepID} and location for a `file:` type {@link Node}.\n */\nconst getFileTypeInfo = (\n spec: Spec,\n fromNode: Node,\n scurry: PathScurry,\n): FileTypeInfo | undefined => {\n const f = spec.final\n if (f.type !== 'file') return\n\n /* c8 ignore start - should be impossible */\n if (!f.file) {\n throw error('no path on file specifier', { spec })\n }\n /* c8 ignore stop */\n\n // Given that both linked folders and local tarballs (both defined with\n // usage of the `file:` spec prefix) location needs to be relative to their\n // parents, build the expected path and use it for both location and id\n const target = scurry.cwd.resolve(fromNode.location).resolve(f.file)\n const path = target.relativePosix()\n const id = joinDepIDTuple(['file', path])\n\n return {\n path,\n id,\n isDirectory: !!target.lstatSync()?.isDirectory(),\n }\n}\n\nconst isStringArray = (a: unknown): a is string[] =>\n Array.isArray(a) && !a.some(b => typeof b !== 'string')\n\n/**\n * Represents a manifest fetch operation with all the context needed.\n */\ntype ManifestFetchTask = {\n spec: Spec\n type: DependencySaveType\n fromNode: Node\n fileTypeInfo?: FileTypeInfo\n activeModifier?: ModifierActiveEntry\n queryModifier?: string\n edgeOptional: boolean\n manifestPromise: Promise<Manifest | undefined>\n depth: number\n}\n\n/**\n * Represents a node placement operation that depends on a resolved manifest.\n */\ntype NodePlacementTask = {\n fetchTask: ManifestFetchTask\n manifest: Manifest | undefined\n node?: Node\n childDeps?: Dependency[]\n childModifierRefs?: Map<string, ModifierActiveEntry>\n}\n\n/**\n * Represents an ongoing append operation for a node and its dependencies.\n */\ntype AppendNodeEntry = {\n node: Node\n deps: Dependency[]\n modifierRefs?: Map<string, ModifierActiveEntry>\n depth: number\n}\n\n/**\n * Fetch manifests for dependencies and create placement tasks.\n */\nconst fetchManifestsForDeps = async (\n packageInfo: PackageInfoClient,\n graph: Graph,\n fromNode: Node,\n deps: Dependency[],\n scurry: PathScurry,\n modifierRefs?: Map<string, ModifierActiveEntry>,\n depth = 0,\n): Promise<NodePlacementTask[]> => {\n // Create fetch tasks for all dependencies at this level\n const fetchTasks: ManifestFetchTask[] = []\n\n for (const { spec: originalSpec, type } of deps) {\n let spec = originalSpec\n const fileTypeInfo = getFileTypeInfo(spec, fromNode, scurry)\n const activeModifier = modifierRefs?.get(spec.name)\n\n // here is the place we swap specs if a edge modifier was defined\n const queryModifier = activeModifier?.modifier.query\n const completeModifier =\n activeModifier &&\n activeModifier.interactiveBreadcrumb.current ===\n activeModifier.modifier.breadcrumb.last\n if (\n queryModifier &&\n completeModifier &&\n 'spec' in activeModifier.modifier\n ) {\n spec = activeModifier.modifier.spec\n if (spec.bareSpec === '-') {\n continue\n }\n }\n\n const existingNode = graph.findResolution(\n spec,\n fromNode,\n queryModifier,\n )\n if (existingNode) {\n // For peerOptional dependencies, create a dangling edge instead of linking to existing node\n if (type === 'peerOptional') {\n /* c8 ignore next 3 */\n // This case happens when peerOptional dep already exists in graph\n graph.addEdge(type, spec, fromNode)\n } else {\n graph.addEdge(type, spec, fromNode, existingNode)\n }\n continue\n }\n\n const edgeOptional =\n type === 'optional' || type === 'peerOptional'\n\n // Start manifest fetch immediately for parallel processing\n const manifestPromise = packageInfo\n .manifest(spec, { from: scurry.resolve(fromNode.location) })\n .then(manifest => manifest as Manifest | undefined)\n .catch((er: unknown) => {\n // optional deps ignored if inaccessible\n if (edgeOptional || fromNode.optional) {\n return undefined\n }\n throw er\n })\n\n const fetchTask: ManifestFetchTask = {\n spec,\n type,\n fromNode,\n fileTypeInfo,\n activeModifier,\n queryModifier,\n edgeOptional,\n manifestPromise,\n depth,\n }\n\n fetchTasks.push(fetchTask)\n }\n\n // Create placement tasks\n const placementTasks: NodePlacementTask[] = []\n for (const fetchTask of fetchTasks) {\n const manifest = await fetchTask.manifestPromise\n\n placementTasks.push({\n fetchTask,\n manifest,\n })\n }\n\n return placementTasks\n}\n\n/**\n * Process placement tasks and collect child dependencies\n */\nconst processPlacementTasks = async (\n add: Map<string, Dependency>,\n graph: Graph,\n options: SpecOptions,\n placementTasks: NodePlacementTask[],\n modifiers?: GraphModifier,\n scurry?: PathScurry,\n packageInfo?: PackageInfoClient,\n extractPromises?: Promise<ExtractResult>[],\n actual?: Graph,\n seenExtracted?: Set<DepID>,\n remover?: RollbackRemove,\n): Promise<{\n childDepsToProcess: Omit<AppendNodeEntry, 'depth'>[]\n}> => {\n const childDepsToProcess: Omit<AppendNodeEntry, 'depth'>[] = []\n\n for (const placementTask of placementTasks) {\n const { fetchTask, manifest } = placementTask\n let { spec } = fetchTask\n const type = fetchTask.type\n const fromNode = fetchTask.fromNode\n const fileTypeInfo = fetchTask.fileTypeInfo\n const activeModifier = fetchTask.activeModifier\n const queryModifier = fetchTask.queryModifier\n const edgeOptional = fetchTask.edgeOptional\n\n // Handle nameless dependencies\n if (manifest?.name && spec.name === '(unknown)') {\n const s = add.get(String(spec))\n if (s) {\n // removes the previous, placeholder entry key\n add.delete(String(spec))\n // replaces spec with a version with the correct name\n spec = Spec.parse(manifest.name, spec.bareSpec, options)\n // updates the add map with the fixed up spec\n const n = asDependency({\n ...s,\n spec,\n })\n add.set(manifest.name, n)\n }\n }\n\n // handles missing manifest resolution\n if (!manifest) {\n if (!edgeOptional && fromNode.isOptional()) {\n // failed resolution of a non-optional dep of an optional node\n // have to clean up the dependents\n removeOptionalSubgraph(graph, fromNode)\n continue\n } else if (edgeOptional) {\n // failed resolution of an optional dep, just ignore it,\n // nothing to prune because we never added it in the first place.\n continue\n } else {\n throw error('failed to resolve dependency', {\n spec,\n from: fromNode.location,\n })\n }\n }\n\n // Skip placing peerOptional dependencies, just create a dangling edge\n if (type === 'peerOptional') {\n /* c8 ignore next 3 */\n graph.addEdge(type, spec, fromNode)\n continue\n }\n\n // places a new node in the graph representing a newly seen dependency\n const node = graph.placePackage(\n fromNode,\n type,\n spec,\n normalizeManifest(manifest),\n fileTypeInfo?.id,\n queryModifier,\n )\n\n /* c8 ignore start - not possible, already ensured manifest */\n if (!node) {\n throw error('failed to place package', {\n from: fromNode.location,\n spec,\n })\n }\n /* c8 ignore stop */\n\n // update the node modifier tracker\n if (activeModifier) {\n modifiers?.updateActiveEntry(node, activeModifier)\n }\n\n // Extract the node if it doesn't exist in the actual graph and we have the necessary parameters\n if (\n remover &&\n extractPromises &&\n actual &&\n scurry &&\n packageInfo &&\n node.inVltStore() &&\n !node.isOptional()\n ) {\n /* c8 ignore start */\n if (seenExtracted?.has(node.id)) {\n continue\n }\n /* c8 ignore stop */\n seenExtracted?.add(node.id)\n const actualNode = actual.nodes.get(node.id)\n if (!actualNode?.equals(node)) {\n // Extract the node without awaiting - push the promise to the array\n const extractPromise = extractNode(\n node,\n scurry,\n remover,\n options,\n packageInfo,\n )\n extractPromises.push(extractPromise)\n }\n }\n\n // updates graph node information\n if (fileTypeInfo?.path && fileTypeInfo.isDirectory) {\n node.location = fileTypeInfo.path\n }\n node.setResolved()\n\n // Collect child dependencies for processing in the next level\n const bundleDeps = manifest.bundleDependencies\n const bundled = new Set<string>(\n (\n node.id.startsWith('git') ||\n node.importer ||\n !isStringArray(bundleDeps)\n ) ?\n []\n : bundleDeps,\n )\n\n // recursively process all child dependencies in the manifest\n const nextDeps: Dependency[] = []\n\n for (const depTypeName of longDependencyTypes) {\n const depRecord: Record<string, string> | undefined =\n manifest[depTypeName]\n\n if (depRecord && shouldInstallDepType(node, depTypeName)) {\n for (const [name, bareSpec] of Object.entries(depRecord)) {\n if (bundled.has(name)) continue\n nextDeps.push({\n type: shorten(depTypeName, name, manifest),\n spec: Spec.parse(name, bareSpec, {\n ...options,\n registry: spec.registry,\n }),\n })\n }\n }\n }\n\n if (nextDeps.length > 0) {\n childDepsToProcess.push({\n node,\n deps: nextDeps,\n modifierRefs: modifiers?.tryDependencies(node, nextDeps),\n })\n }\n }\n\n return { childDepsToProcess }\n}\n\n/**\n * Append new nodes in the given `graph` for dependencies specified at `add`\n * and missing dependencies from the `deps` parameter.\n *\n * It also applies any modifiers that applies to a given node as it processes\n * and builds the graph.\n */\nexport const appendNodes = async (\n add: Map<string, Dependency>,\n packageInfo: PackageInfoClient,\n graph: Graph,\n fromNode: Node,\n deps: Dependency[],\n scurry: PathScurry,\n options: SpecOptions,\n seen: Set<DepID>,\n modifiers?: GraphModifier,\n modifierRefs?: Map<string, ModifierActiveEntry>,\n extractPromises?: Promise<ExtractResult>[],\n actual?: Graph,\n seenExtracted?: Set<DepID>,\n remover?: RollbackRemove,\n) => {\n /* c8 ignore next */\n if (seen.has(fromNode.id)) return\n seen.add(fromNode.id)\n\n // Use a queue for breadth-first processing\n let currentLevelDeps: AppendNodeEntry[] = [\n { node: fromNode, deps, modifierRefs, depth: 0 },\n ]\n\n while (currentLevelDeps.length > 0) {\n const nextLevelDeps: AppendNodeEntry[] = []\n\n // Process all nodes at the current level in parallel\n const levelResults = await Promise.all(\n currentLevelDeps.map(\n async ({\n node,\n deps: nodeDeps,\n modifierRefs: nodeModifierRefs,\n depth,\n }: AppendNodeEntry) => {\n // Mark node as seen when we start processing its dependencies\n seen.add(node.id)\n\n // Fetch manifests for this node's dependencies\n const placementTasks = await fetchManifestsForDeps(\n packageInfo,\n graph,\n node,\n // Sort dependencies by spec.name for deterministic ordering\n nodeDeps.sort((a, b) =>\n a.spec.name.localeCompare(b.spec.name, 'en'),\n ),\n scurry,\n nodeModifierRefs,\n depth,\n )\n\n // Process the placement tasks and get child dependencies\n return await processPlacementTasks(\n add,\n graph,\n options,\n placementTasks,\n modifiers,\n scurry,\n packageInfo,\n extractPromises,\n actual,\n seenExtracted,\n remover,\n )\n },\n ),\n )\n\n // Collect all child dependencies for the next level\n for (const { childDepsToProcess } of levelResults) {\n for (const childDep of childDepsToProcess) {\n if (!seen.has(childDep.node.id)) {\n /* c8 ignore next */\n const currentDepth = currentLevelDeps[0]?.depth ?? 0\n nextLevelDeps.push({\n ...childDep,\n depth: currentDepth + 1,\n })\n }\n }\n }\n\n // Move to the next level\n currentLevelDeps = nextLevelDeps\n }\n}\n"]}
@@ -1,15 +0,0 @@
1
- import type { Graph } from '../graph.ts';
2
- import type { AddNodesOptions } from './add-nodes.ts';
3
- import type { RemoveNodesOptions } from './remove-nodes.ts';
4
- export type BuildIdealFromStartingGraphOptions = AddNodesOptions & RemoveNodesOptions & {
5
- projectRoot: string;
6
- };
7
- /**
8
- * Builds an ideal {@link Graph} representing the dependencies that
9
- * should be present in order to fulfill the requirements defined
10
- * by the `package.json` and `vlt-lock.json` files using the `graph` set
11
- * in options as a starting point. Also add / remove any dependencies
12
- * listed in the `add` and `remove` properties.
13
- */
14
- export declare const buildIdealFromStartingGraph: (options: BuildIdealFromStartingGraphOptions) => Promise<Graph>;
15
- //# sourceMappingURL=build-ideal-from-starting-graph.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-ideal-from-starting-graph.d.ts","sourceRoot":"","sources":["../../../src/ideal/build-ideal-from-starting-graph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,MAAM,MAAM,kCAAkC,GAAG,eAAe,GAC9D,kBAAkB,GAAG;IACnB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,YAC7B,kCAAkC,KAC1C,OAAO,CAAC,KAAK,CAoDf,CAAA"}
@@ -1,55 +0,0 @@
1
- import { getImporterSpecs } from "./get-importer-specs.js";
2
- import { addNodes } from "./add-nodes.js";
3
- import { removeNodes } from "./remove-nodes.js";
4
- /**
5
- * Builds an ideal {@link Graph} representing the dependencies that
6
- * should be present in order to fulfill the requirements defined
7
- * by the `package.json` and `vlt-lock.json` files using the `graph` set
8
- * in options as a starting point. Also add / remove any dependencies
9
- * listed in the `add` and `remove` properties.
10
- */
11
- export const buildIdealFromStartingGraph = async (options) => {
12
- // Gets a map of dependencies that are keyed to its importer node ids,
13
- // merging values already found in the graph with user specified values.
14
- // Any dependencies that are already satisfied in the starting `graph`
15
- // are going to be pruned from the resulting object.
16
- const importerSpecs = getImporterSpecs(options);
17
- // merge modifiedDependencies flags
18
- options.add.modifiedDependencies =
19
- options.add.modifiedDependencies ||
20
- importerSpecs.add.modifiedDependencies;
21
- options.remove.modifiedDependencies =
22
- options.remove.modifiedDependencies ||
23
- importerSpecs.remove.modifiedDependencies;
24
- // merge values found on importer specs with
25
- // user-provided values from `options.add`
26
- for (const [importerId, deps] of importerSpecs.add) {
27
- if (!options.add.has(importerId)) {
28
- options.add.set(importerId, deps);
29
- continue;
30
- }
31
- // merge any deps found when reading the importers manifest
32
- // with the ones provided by the user in the `add` options,
33
- // user-provided deps should take precedence
34
- for (const [depName, dep] of deps) {
35
- if (!options.add.get(importerId)?.has(depName)) {
36
- options.add.get(importerId)?.set(depName, dep);
37
- }
38
- }
39
- }
40
- // hydrate the resolution cache
41
- if (options.add.modifiedDependencies) {
42
- options.graph.resetResolution();
43
- // add nodes, fetching remote manifests for each dependency to be added
44
- await addNodes(options);
45
- // move things into their default locations, if possible
46
- for (const node of options.graph.nodes.values()) {
47
- node.setDefaultLocation();
48
- }
49
- }
50
- // removes any dependencies that are listed in the `remove` option
51
- removeNodes({ ...options, remove: importerSpecs.remove });
52
- options.graph.gc();
53
- return options.graph;
54
- };
55
- //# sourceMappingURL=build-ideal-from-starting-graph.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-ideal-from-starting-graph.js","sourceRoot":"","sources":["../../../src/ideal/build-ideal-from-starting-graph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAQ/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,EAC9C,OAA2C,EAC3B,EAAE;IAClB,sEAAsE;IACtE,wEAAwE;IACxE,sEAAsE;IACtE,oDAAoD;IACpD,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAA;IAE/C,mCAAmC;IACnC,OAAO,CAAC,GAAG,CAAC,oBAAoB;QAC9B,OAAO,CAAC,GAAG,CAAC,oBAAoB;YAChC,aAAa,CAAC,GAAG,CAAC,oBAAoB,CAAA;IACxC,OAAO,CAAC,MAAM,CAAC,oBAAoB;QACjC,OAAO,CAAC,MAAM,CAAC,oBAAoB;YACnC,aAAa,CAAC,MAAM,CAAC,oBAAoB,CAAA;IAE3C,4CAA4C;IAC5C,0CAA0C;IAC1C,KAAK,MAAM,C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'./add-nodes.ts'\nimport type { AddNodesOptions } from './add-nodes.ts'\nimport { removeNodes } from './remove-nodes.ts'\nimport type { RemoveNodesOptions } from './remove-nodes.ts'\n\nexport type BuildIdealFromStartingGraphOptions = AddNodesOptions &\n RemoveNodesOptions & {\n projectRoot: string\n }\n\n/**\n * Builds an ideal {@link Graph} representing the dependencies that\n * should be present in order to fulfill the requirements defined\n * by the `package.json` and `vlt-lock.json` files using the `graph` set\n * in options as a starting point. Also add / remove any dependencies\n * listed in the `add` and `remove` properties.\n */\nexport const buildIdealFromStartingGraph = async (\n options: BuildIdealFromStartingGraphOptions,\n): Promise<Graph> => {\n // Gets a map of dependencies that are keyed to its importer node ids,\n // merging values already found in the graph with user specified values.\n // Any dependencies that are already satisfied in the starting `graph`\n // are going to be pruned from the resulting object.\n const importerSpecs = getImporterSpecs(options)\n\n // merge modifiedDependencies flags\n options.add.modifiedDependencies =\n options.add.modifiedDependencies ||\n importerSpecs.add.modifiedDependencies\n options.remove.modifiedDependencies =\n options.remove.modifiedDependencies ||\n importerSpecs.remove.modifiedDependencies\n\n // merge values found on importer specs with\n // user-provided values from `options.add`\n for (const [importerId, deps] of importerSpecs.add) {\n if (!options.add.has(importerId)) {\n options.add.set(importerId, deps)\n continue\n }\n\n // merge any deps found when reading the importers manifest\n // with the ones provided by the user in the `add` options,\n // user-provided deps should take precedence\n for (const [depName, dep] of deps) {\n if (!options.add.get(importerId)?.has(depName)) {\n options.add.get(importerId)?.set(depName, dep)\n }\n }\n }\n\n // hydrate the resolution cache\n if (options.add.modifiedDependencies) {\n options.graph.resetResolution()\n\n // add nodes, fetching remote manifests for each dependency to be added\n await addNodes(options)\n\n // move things into their default locations, if possible\n for (const node of options.graph.nodes.values()) {\n node.setDefaultLocation()\n }\n }\n\n // removes any dependencies that are listed in the `remove` option\n removeNodes({ ...options, remove: importerSpecs.remove })\n\n options.graph.gc()\n\n return options.graph\n}\n"]}
@@ -1,41 +0,0 @@
1
- import type { PackageInfoClient } from '@vltpkg/package-info';
2
- import type { LoadOptions as LoadActualOptions } from '../actual/load.ts';
3
- import type { AddImportersDependenciesMap, RemoveImportersDependenciesMap } from '../dependencies.ts';
4
- import type { Graph } from '../graph.ts';
5
- import type { RollbackRemove } from '@vltpkg/rollback-remove';
6
- export type BuildIdealOptions = LoadActualOptions & {
7
- /**
8
- * An actual graph
9
- */
10
- actual?: Graph;
11
- /**
12
- * A `Map` in which keys are {@link DepID} linking to another `Map` in which
13
- * keys are the dependency names and values are {@link Dependency}. This
14
- * structure represents dependencies that need to be added to the importer
15
- * represented by {@link DepID}.
16
- */
17
- add?: AddImportersDependenciesMap;
18
- /**
19
- * A `Map` object representing nodes to be removed from the ideal graph.
20
- * Each {@link DepID} key represents an importer node and the `Set` of
21
- * dependency names to be removed from its dependency list.
22
- */
23
- remove?: RemoveImportersDependenciesMap;
24
- /**
25
- * A {@link RollbackRemove} instance to handle extraction rollbacks
26
- */
27
- remover: RollbackRemove;
28
- /**
29
- * A {@link PackageInfoClient} instance to read manifest info from.
30
- */
31
- packageInfo: PackageInfoClient;
32
- };
33
- /**
34
- * Builds an ideal {@link Graph} representing the dependencies that
35
- * should be present in order to fulfill the requirements defined
36
- * by the `package.json` and `vlt-lock.json` files using either the
37
- * virtual or actual graph as a starting point. Also add / remove any
38
- * dependencies listed in the `add` and `remove` properties.
39
- */
40
- export declare const build: (options: BuildIdealOptions) => Promise<Graph>;
41
- //# sourceMappingURL=build.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,KAAK,EACV,2BAA2B,EAC3B,8BAA8B,EAE/B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAK7D,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,GAAG;IAClD;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAA;IACd;;;;;OAKG;IACH,GAAG,CAAC,EAAE,2BAA2B,CAAA;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,8BAA8B,CAAA;IACvC;;OAEG;IACH,OAAO,EAAE,cAAc,CAAA;IACvB;;OAEG;IACH,WAAW,EAAE,iBAAiB,CAAA;CAC/B,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,YACP,iBAAiB,KACzB,OAAO,CAAC,KAAK,CAoCf,CAAA"}
@@ -1,48 +0,0 @@
1
- import { graphStep } from '@vltpkg/output';
2
- import { load as loadActual } from "../actual/load.js";
3
- import { load as loadVirtual } from "../lockfile/load.js";
4
- import { buildIdealFromStartingGraph } from "./build-ideal-from-starting-graph.js";
5
- const getMap = (m) => m ?? new Map();
6
- /**
7
- * Builds an ideal {@link Graph} representing the dependencies that
8
- * should be present in order to fulfill the requirements defined
9
- * by the `package.json` and `vlt-lock.json` files using either the
10
- * virtual or actual graph as a starting point. Also add / remove any
11
- * dependencies listed in the `add` and `remove` properties.
12
- */
13
- export const build = async (options) => {
14
- const done = graphStep('build');
15
- // Creates the shared instances that are going to be used
16
- // in both the loader methods and the build graph
17
- const { packageInfo, packageJson, scurry, monorepo } = options;
18
- const mainManifest = options.mainManifest ?? packageJson.read(options.projectRoot);
19
- let graph;
20
- try {
21
- graph = loadVirtual({
22
- ...options,
23
- mainManifest,
24
- monorepo,
25
- skipLoadingNodesOnModifiersChange: true,
26
- });
27
- }
28
- catch {
29
- graph = loadActual({
30
- ...options,
31
- mainManifest,
32
- monorepo,
33
- skipLoadingNodesOnModifiersChange: true,
34
- });
35
- }
36
- const res = await buildIdealFromStartingGraph({
37
- ...options,
38
- scurry,
39
- add: getMap(options.add),
40
- graph,
41
- packageInfo,
42
- remove: getMap(options.remove),
43
- actual: options.actual,
44
- });
45
- done();
46
- return res;
47
- };
48
- //# sourceMappingURL=build.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/ideal/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAA;AAYlF,MAAM,MAAM,GAAG,CAA0B,CAAK,EAAE,EAAE,CAChD,CAAC,IAAK,IAAI,GAAG,EAAQ,CAAA;AA8BvB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EACxB,OAA0B,EACV,EAAE;IAClB,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,CAAA;IAE/B,yDAAyD;IACzD,iDAAiD;IACjD,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAC9D,MAAM,YAAY,GAChB,OAAO,CAAC,YAAY,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAC/D,IAAI,KAAK,CAAA;IACT,IAAI,CAAC;QACH,KAAK,GAAG,WAAW,CAAC;YAClB,GAAG,OAAO;YACV,YAAY;YACZ,QAAQ;YACR,iCAAiC,EAAE,IAAI;SACxC,CAAC,CAAA;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,KAAK,GAAG,UAAU,CAAC;YACjB,GAAG,OAAO;YACV,YAAY;YACZ,QAAQ;YACR,iCAAiC,EAAE,IAAI;SACxC,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,2BAA2B,CAAC;QAC5C,GAAG,OAAO;QACV,MAAM;QACN,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;QACxB,KAAK;QACL,WAAW;QACX,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAA;IACF,IAAI,EAAE,CAAA;IACN,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import { graphStep } from '@vltpkg/output'\nimport { load as loadActual } from '../actual/load.ts'\nimport { load as loadVirtual } from '../lockfile/load.ts'\nimport { buildIdealFromStartingGraph } from './build-ideal-from-starting-graph.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { LoadOptions as LoadActualOptions } from '../actual/load.ts'\nimport type {\n AddImportersDependenciesMap,\n RemoveImportersDependenciesMap,\n Dependency,\n} from '../dependencies.ts'\nimport type { Graph } from '../graph.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\n\nconst getMap = <T extends Map<any, any>>(m?: T) =>\n m ?? (new Map() as T)\n\nexport type BuildIdealOptions = LoadActualOptions & {\n /**\n * An actual graph\n */\n actual?: Graph\n /**\n * A `Map` in which keys are {@link DepID} linking to another `Map` in which\n * keys are the dependency names and values are {@link Dependency}. This\n * structure represents dependencies that need to be added to the importer\n * represented by {@link DepID}.\n */\n add?: AddImportersDependenciesMap\n /**\n * A `Map` object representing nodes to be removed from the ideal graph.\n * Each {@link DepID} key represents an importer node and the `Set` of\n * dependency names to be removed from its dependency list.\n */\n remove?: RemoveImportersDependenciesMap\n /**\n * A {@link RollbackRemove} instance to handle extraction rollbacks\n */\n remover: RollbackRemove\n /**\n * A {@link PackageInfoClient} instance to read manifest info from.\n */\n packageInfo: PackageInfoClient\n}\n\n/**\n * Builds an ideal {@link Graph} representing the dependencies that\n * should be present in order to fulfill the requirements defined\n * by the `package.json` and `vlt-lock.json` files using either the\n * virtual or actual graph as a starting point. Also add / remove any\n * dependencies listed in the `add` and `remove` properties.\n */\nexport const build = async (\n options: BuildIdealOptions,\n): Promise<Graph> => {\n const done = graphStep('build')\n\n // Creates the shared instances that are going to be used\n // in both the loader methods and the build graph\n const { packageInfo, packageJson, scurry, monorepo } = options\n const mainManifest =\n options.mainManifest ?? packageJson.read(options.projectRoot)\n let graph\n try {\n graph = loadVirtual({\n ...options,\n mainManifest,\n monorepo,\n skipLoadingNodesOnModifiersChange: true,\n })\n } catch {\n graph = loadActual({\n ...options,\n mainManifest,\n monorepo,\n skipLoadingNodesOnModifiersChange: true,\n })\n }\n\n const res = await buildIdealFromStartingGraph({\n ...options,\n scurry,\n add: getMap(options.add),\n graph,\n packageInfo,\n remove: getMap(options.remove),\n actual: options.actual,\n })\n done()\n return res\n}\n"]}
@@ -1,14 +0,0 @@
1
- import type { AddImportersDependenciesMap, RemoveImportersDependenciesMap } from '../dependencies.ts';
2
- import type { BuildIdealAddOptions, BuildIdealFromGraphOptions, BuildIdealRemoveOptions } from './types.ts';
3
- import type { SpecOptions } from '@vltpkg/spec';
4
- export type GetImporterSpecsOptions = BuildIdealAddOptions & BuildIdealFromGraphOptions & BuildIdealRemoveOptions & SpecOptions;
5
- /**
6
- * Given a {@link Graph} and a list of {@link Dependency}, merges the
7
- * dependencies info found in the graph importers and returns the add & remove
8
- * results as a Map in which keys are {@link DepID} of each importer node.
9
- */
10
- export declare const getImporterSpecs: (options: GetImporterSpecsOptions) => {
11
- add: AddImportersDependenciesMap;
12
- remove: RemoveImportersDependenciesMap;
13
- };
14
- //# sourceMappingURL=get-importer-specs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-importer-specs.d.ts","sourceRoot":"","sources":["../../../src/ideal/get-importer-specs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,2BAA2B,EAE3B,8BAA8B,EAC/B,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACxB,MAAM,YAAY,CAAA;AAMnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GACxD,0BAA0B,GAC1B,uBAAuB,GACvB,WAAW,CAAA;AAyBb;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,YAClB,uBAAuB;;;CA4FjC,CAAA"}