@dads-framework/testing 0.2.0 → 0.4.0

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 +4 -3
  2. package/bin/dad-test-import-nx.js +3 -0
  3. package/bin/dad-test-nx.js +3 -0
  4. package/dist/cli-arguments.d.ts.map +1 -1
  5. package/dist/cli-arguments.js +1 -3
  6. package/dist/cli-arguments.js.map +1 -1
  7. package/dist/cli-output.d.ts.map +1 -1
  8. package/dist/cli-output.js.map +1 -1
  9. package/dist/commands/explain.d.ts.map +1 -1
  10. package/dist/commands/explain.js.map +1 -1
  11. package/dist/commands/init.d.ts.map +1 -1
  12. package/dist/commands/init.js +2 -6
  13. package/dist/commands/init.js.map +1 -1
  14. package/dist/commands/plan-run.d.ts.map +1 -1
  15. package/dist/commands/plan-run.js +2 -6
  16. package/dist/commands/plan-run.js.map +1 -1
  17. package/dist/dad-test-cli.d.ts.map +1 -1
  18. package/dist/dad-test-cli.js +1 -3
  19. package/dist/dad-test-cli.js.map +1 -1
  20. package/dist/explain-plan.d.ts.map +1 -1
  21. package/dist/explain-plan.js +9 -24
  22. package/dist/explain-plan.js.map +1 -1
  23. package/dist/index.d.ts +4 -4
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +4 -4
  26. package/dist/index.js.map +1 -1
  27. package/dist/init/check-testing-manifest.d.ts.map +1 -1
  28. package/dist/init/check-testing-manifest.js +1 -2
  29. package/dist/init/check-testing-manifest.js.map +1 -1
  30. package/dist/init/detect-workspace.d.ts.map +1 -1
  31. package/dist/init/detect-workspace.js +1 -1
  32. package/dist/init/detect-workspace.js.map +1 -1
  33. package/dist/init/infer-one-package.d.ts.map +1 -1
  34. package/dist/init/infer-one-package.js +5 -14
  35. package/dist/init/infer-one-package.js.map +1 -1
  36. package/dist/init/infer-testing-manifest.d.ts.map +1 -1
  37. package/dist/init/infer-testing-manifest.js +1 -4
  38. package/dist/init/infer-testing-manifest.js.map +1 -1
  39. package/dist/init/init-testing-manifest.d.ts.map +1 -1
  40. package/dist/init/init-testing-manifest.js +12 -30
  41. package/dist/init/init-testing-manifest.js.map +1 -1
  42. package/dist/init/package-inventory.d.ts.map +1 -1
  43. package/dist/init/package-inventory.js +3 -11
  44. package/dist/init/package-inventory.js.map +1 -1
  45. package/dist/init/pnpm-workspace-yaml.d.ts.map +1 -1
  46. package/dist/init/pnpm-workspace-yaml.js.map +1 -1
  47. package/dist/init/project-ids.d.ts.map +1 -1
  48. package/dist/init/project-ids.js +1 -3
  49. package/dist/init/project-ids.js.map +1 -1
  50. package/dist/init/strip-json-comments.js.map +1 -1
  51. package/dist/init/workspace-glob.d.ts.map +1 -1
  52. package/dist/init/workspace-glob.js +2 -6
  53. package/dist/init/workspace-glob.js.map +1 -1
  54. package/dist/init/workspace-relative-path.d.ts.map +1 -1
  55. package/dist/init/workspace-relative-path.js.map +1 -1
  56. package/dist/native-platform.d.ts.map +1 -1
  57. package/dist/native-platform.js +4 -10
  58. package/dist/native-platform.js.map +1 -1
  59. package/dist/nx/atomic-output.d.ts +9 -0
  60. package/dist/nx/atomic-output.d.ts.map +1 -0
  61. package/dist/nx/atomic-output.js +39 -0
  62. package/dist/nx/atomic-output.js.map +1 -0
  63. package/dist/nx/cli.d.ts +2 -0
  64. package/dist/nx/cli.d.ts.map +1 -0
  65. package/dist/nx/cli.js +18 -0
  66. package/dist/nx/cli.js.map +1 -0
  67. package/dist/nx/dads-identifier.d.ts +11 -0
  68. package/dist/nx/dads-identifier.d.ts.map +1 -0
  69. package/dist/nx/dads-identifier.js +14 -0
  70. package/dist/nx/dads-identifier.js.map +1 -0
  71. package/dist/nx/import-digest.d.ts +12 -0
  72. package/dist/nx/import-digest.d.ts.map +1 -0
  73. package/dist/nx/import-digest.js +69 -0
  74. package/dist/nx/import-digest.js.map +1 -0
  75. package/dist/nx/import-nx-types.d.ts +166 -0
  76. package/dist/nx/import-nx-types.d.ts.map +1 -0
  77. package/dist/nx/import-nx-types.js +2 -0
  78. package/dist/nx/import-nx-types.js.map +1 -0
  79. package/dist/nx/import-nx-workspace.d.ts +7 -0
  80. package/dist/nx/import-nx-workspace.d.ts.map +1 -0
  81. package/dist/nx/import-nx-workspace.js +292 -0
  82. package/dist/nx/import-nx-workspace.js.map +1 -0
  83. package/dist/nx/import-nx.d.ts +12 -0
  84. package/dist/nx/import-nx.d.ts.map +1 -0
  85. package/dist/nx/import-nx.js +12 -0
  86. package/dist/nx/import-nx.js.map +1 -0
  87. package/dist/nx/index.d.ts +4 -0
  88. package/dist/nx/index.d.ts.map +1 -0
  89. package/dist/nx/index.js +4 -0
  90. package/dist/nx/index.js.map +1 -0
  91. package/dist/nx/json-values.d.ts +43 -0
  92. package/dist/nx/json-values.d.ts.map +1 -0
  93. package/dist/nx/json-values.js +73 -0
  94. package/dist/nx/json-values.js.map +1 -0
  95. package/dist/nx/nx-graph-fallback.d.ts +18 -0
  96. package/dist/nx/nx-graph-fallback.d.ts.map +1 -0
  97. package/dist/nx/nx-graph-fallback.js +61 -0
  98. package/dist/nx/nx-graph-fallback.js.map +1 -0
  99. package/dist/nx/nx-installation.d.ts +4 -0
  100. package/dist/nx/nx-installation.d.ts.map +1 -0
  101. package/dist/nx/nx-installation.js +95 -0
  102. package/dist/nx/nx-installation.js.map +1 -0
  103. package/dist/nx/nx-jsonc.d.ts +3 -0
  104. package/dist/nx/nx-jsonc.d.ts.map +1 -0
  105. package/dist/nx/nx-jsonc.js +91 -0
  106. package/dist/nx/nx-jsonc.js.map +1 -0
  107. package/dist/nx/nx-native-cli.d.ts +2 -0
  108. package/dist/nx/nx-native-cli.d.ts.map +1 -0
  109. package/dist/nx/nx-native-cli.js +64 -0
  110. package/dist/nx/nx-native-cli.js.map +1 -0
  111. package/dist/nx/nx-native-graph.d.ts +11 -0
  112. package/dist/nx/nx-native-graph.d.ts.map +1 -0
  113. package/dist/nx/nx-native-graph.js +120 -0
  114. package/dist/nx/nx-native-graph.js.map +1 -0
  115. package/dist/nx/nx-native-input-expansion.d.ts +9 -0
  116. package/dist/nx/nx-native-input-expansion.d.ts.map +1 -0
  117. package/dist/nx/nx-native-input-expansion.js +104 -0
  118. package/dist/nx/nx-native-input-expansion.js.map +1 -0
  119. package/dist/nx/nx-native-inputs.d.ts +9 -0
  120. package/dist/nx/nx-native-inputs.d.ts.map +1 -0
  121. package/dist/nx/nx-native-inputs.js +210 -0
  122. package/dist/nx/nx-native-inputs.js.map +1 -0
  123. package/dist/nx/nx-native-model.d.ts +28 -0
  124. package/dist/nx/nx-native-model.d.ts.map +1 -0
  125. package/dist/nx/nx-native-model.js +104 -0
  126. package/dist/nx/nx-native-model.js.map +1 -0
  127. package/dist/nx/nx-native-process.d.ts +2 -0
  128. package/dist/nx/nx-native-process.d.ts.map +1 -0
  129. package/dist/nx/nx-native-process.js +18 -0
  130. package/dist/nx/nx-native-process.js.map +1 -0
  131. package/dist/nx/nx-native-scope.d.ts +4 -0
  132. package/dist/nx/nx-native-scope.d.ts.map +1 -0
  133. package/dist/nx/nx-native-scope.js +20 -0
  134. package/dist/nx/nx-native-scope.js.map +1 -0
  135. package/dist/nx/nx-native-scratch.d.ts +5 -0
  136. package/dist/nx/nx-native-scratch.d.ts.map +1 -0
  137. package/dist/nx/nx-native-scratch.js +72 -0
  138. package/dist/nx/nx-native-scratch.js.map +1 -0
  139. package/dist/nx/nx-native-workspace.d.ts +16 -0
  140. package/dist/nx/nx-native-workspace.d.ts.map +1 -0
  141. package/dist/nx/nx-native-workspace.js +69 -0
  142. package/dist/nx/nx-native-workspace.js.map +1 -0
  143. package/dist/nx/nx-target-conversion.d.ts +9 -0
  144. package/dist/nx/nx-target-conversion.d.ts.map +1 -0
  145. package/dist/nx/nx-target-conversion.js +282 -0
  146. package/dist/nx/nx-target-conversion.js.map +1 -0
  147. package/dist/nx/nx-workspace-reader.d.ts +42 -0
  148. package/dist/nx/nx-workspace-reader.d.ts.map +1 -0
  149. package/dist/nx/nx-workspace-reader.js +294 -0
  150. package/dist/nx/nx-workspace-reader.js.map +1 -0
  151. package/dist/path-aliases/alias-file-system.d.ts +26 -0
  152. package/dist/path-aliases/alias-file-system.d.ts.map +1 -0
  153. package/dist/path-aliases/alias-file-system.js +16 -0
  154. package/dist/path-aliases/alias-file-system.js.map +1 -0
  155. package/dist/path-aliases/alias-resolver-conformance-cases.d.ts +40 -0
  156. package/dist/path-aliases/alias-resolver-conformance-cases.d.ts.map +1 -0
  157. package/dist/path-aliases/alias-resolver-conformance-cases.js +320 -0
  158. package/dist/path-aliases/alias-resolver-conformance-cases.js.map +1 -0
  159. package/dist/path-aliases/alias-resolver-conformance.d.ts +41 -0
  160. package/dist/path-aliases/alias-resolver-conformance.d.ts.map +1 -0
  161. package/dist/path-aliases/alias-resolver-conformance.js +129 -0
  162. package/dist/path-aliases/alias-resolver-conformance.js.map +1 -0
  163. package/dist/path-aliases/alias-resolver.d.ts +23 -0
  164. package/dist/path-aliases/alias-resolver.d.ts.map +1 -0
  165. package/dist/path-aliases/alias-resolver.js +199 -0
  166. package/dist/path-aliases/alias-resolver.js.map +1 -0
  167. package/dist/path-aliases/in-memory-file-system.d.ts +16 -0
  168. package/dist/path-aliases/in-memory-file-system.d.ts.map +1 -0
  169. package/dist/path-aliases/in-memory-file-system.js +43 -0
  170. package/dist/path-aliases/in-memory-file-system.js.map +1 -0
  171. package/dist/path-aliases/index.d.ts +6 -0
  172. package/dist/path-aliases/index.d.ts.map +1 -0
  173. package/dist/path-aliases/index.js +6 -0
  174. package/dist/path-aliases/index.js.map +1 -0
  175. package/dist/path-aliases/json-with-comments.d.ts +14 -0
  176. package/dist/path-aliases/json-with-comments.d.ts.map +1 -0
  177. package/dist/path-aliases/json-with-comments.js +240 -0
  178. package/dist/path-aliases/json-with-comments.js.map +1 -0
  179. package/dist/path-aliases/node-file-system.d.ts +10 -0
  180. package/dist/path-aliases/node-file-system.d.ts.map +1 -0
  181. package/dist/path-aliases/node-file-system.js +29 -0
  182. package/dist/path-aliases/node-file-system.js.map +1 -0
  183. package/dist/path-aliases/tsconfig-chain.d.ts +40 -0
  184. package/dist/path-aliases/tsconfig-chain.d.ts.map +1 -0
  185. package/dist/path-aliases/tsconfig-chain.js +138 -0
  186. package/dist/path-aliases/tsconfig-chain.js.map +1 -0
  187. package/dist/plan-issues.d.ts.map +1 -1
  188. package/dist/plan-issues.js +2 -5
  189. package/dist/plan-issues.js.map +1 -1
  190. package/dist/plan-reasons.d.ts.map +1 -1
  191. package/dist/plan-reasons.js.map +1 -1
  192. package/dist/testing-api.d.ts.map +1 -1
  193. package/dist/testing-api.js +4 -8
  194. package/dist/testing-api.js.map +1 -1
  195. package/dist/testing-manifest.d.ts.map +1 -1
  196. package/dist/testing-manifest.js +6 -25
  197. package/dist/testing-manifest.js.map +1 -1
  198. package/dist/testing-report.d.ts.map +1 -1
  199. package/dist/testing-report.js +7 -20
  200. package/dist/testing-report.js.map +1 -1
  201. package/dist/testing.tsbuildinfo +1 -1
  202. package/dist/vitest/dads-tsconfig-paths.d.ts +17 -0
  203. package/dist/vitest/dads-tsconfig-paths.d.ts.map +1 -0
  204. package/dist/vitest/dads-tsconfig-paths.js +38 -0
  205. package/dist/vitest/dads-tsconfig-paths.js.map +1 -0
  206. package/dist/vitest/index.d.ts +2 -0
  207. package/dist/vitest/index.d.ts.map +1 -0
  208. package/dist/vitest/index.js +2 -0
  209. package/dist/vitest/index.js.map +1 -0
  210. package/nx/README.md +259 -0
  211. package/package.json +35 -8
package/dist/nx/cli.js ADDED
@@ -0,0 +1,18 @@
1
+ import { importNxTestingWorkspace } from "./import-nx.js";
2
+ const [workspaceRoot, shaFlag, expectedGitSha] = process.argv.slice(2);
3
+ if (!workspaceRoot || shaFlag !== "--sha" || !expectedGitSha || process.argv.length !== 5) {
4
+ process.stderr.write("Usage: dad-test-import-nx <nx-workspace-root> --sha <full-git-sha>\n");
5
+ process.exitCode = 2;
6
+ }
7
+ else {
8
+ importNxTestingWorkspace({ workspaceRoot, expectedGitSha })
9
+ .then((result) => {
10
+ process.stdout.write(`Imported ${String(result.manifest.tasks.length)} standalone task(s); report: ${result.reportPath}\n`);
11
+ })
12
+ .catch((error) => {
13
+ const message = error instanceof Error ? error.message : "Unknown import failure.";
14
+ process.stderr.write(`${message}\n`);
15
+ process.exitCode = 1;
16
+ });
17
+ }
18
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/nx/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,CAAC,aAAa,EAAE,OAAO,EAAE,cAAc,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEvE,IAAI,CAAC,aAAa,IAAI,OAAO,KAAK,OAAO,IAAI,CAAC,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IAC1F,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sEAAsE,CAAC,CAAC;IAC7F,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC;KAAM,CAAC;IACN,wBAAwB,CAAC,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC;SACxD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,YAAY,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,gCAAgC,MAAM,CAAC,UAAU,IAAI,CACtG,CAAC;IACJ,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;QACxB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,yBAAyB,CAAC;QACnF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;QACrC,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * One spelling for the Dads identifier an Nx name becomes.
3
+ *
4
+ * Both import paths — the recipe the workspace reader writes and the manifest
5
+ * the native reader builds — name the same project, and a task id minted one
6
+ * way must equal the project id minted the other. Encoding the name in one
7
+ * place is what makes that equality hold for every character Nx allows.
8
+ */
9
+ /** A stable, collision-free Dads identifier for an arbitrary Nx name. */
10
+ export declare function dadsIdentifier(value: string): string;
11
+ //# sourceMappingURL=dads-identifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dads-identifier.d.ts","sourceRoot":"","sources":["../../src/nx/dads-identifier.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGpD"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * One spelling for the Dads identifier an Nx name becomes.
3
+ *
4
+ * Both import paths — the recipe the workspace reader writes and the manifest
5
+ * the native reader builds — name the same project, and a task id minted one
6
+ * way must equal the project id minted the other. Encoding the name in one
7
+ * place is what makes that equality hold for every character Nx allows.
8
+ */
9
+ /** A stable, collision-free Dads identifier for an arbitrary Nx name. */
10
+ export function dadsIdentifier(value) {
11
+ const encoded = Array.from(value, (character) => character.codePointAt(0)?.toString(16) ?? "0").join("-");
12
+ return `nx-${encoded || "empty"}`;
13
+ }
14
+ //# sourceMappingURL=dads-identifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dads-identifier.js","sourceRoot":"","sources":["../../src/nx/dads-identifier.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,yEAAyE;AACzE,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1G,OAAO,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;AACpC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { DigestedInput } from "./import-nx-types.js";
2
+ /** The hex SHA-256 of `value`. */
3
+ export declare function sha256(value: string | Uint8Array): string;
4
+ /** Digests the workspace-level files that exist. */
5
+ export declare function digestInputs(workspaceRoot: string): Promise<readonly DigestedInput[]>;
6
+ /**
7
+ * Adds each project's own configuration files to `rootInputs`, keyed by path
8
+ * so a project rooted at the workspace root cannot record `package.json`
9
+ * twice, and returns the whole set sorted by path.
10
+ */
11
+ export declare function digestProjectInputs(workspaceRoot: string, rootInputs: readonly DigestedInput[], projectRoots: readonly string[]): Promise<readonly DigestedInput[]>;
12
+ //# sourceMappingURL=import-digest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-digest.d.ts","sourceRoot":"","sources":["../../src/nx/import-digest.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAiB1D,kCAAkC;AAClC,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAEzD;AAED,oDAAoD;AACpD,wBAAsB,YAAY,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAO3F;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,SAAS,aAAa,EAAE,EACpC,YAAY,EAAE,SAAS,MAAM,EAAE,GAC9B,OAAO,CAAC,SAAS,aAAa,EAAE,CAAC,CAUnC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The evidence an import was taken over one exact set of bytes.
3
+ *
4
+ * A manifest is only reproducible if the inputs it was derived from can be
5
+ * recognized again, so every file that can change the answer — the lockfile,
6
+ * `nx.json`, and each project's own configuration — is hashed and recorded. A
7
+ * file that is simply absent is not evidence of anything and is skipped; any
8
+ * other read failure is a real failure and is raised.
9
+ */
10
+ import { createHash } from "node:crypto";
11
+ import { promises as fs } from "node:fs";
12
+ import path from "node:path";
13
+ import { isMissingFile, normalizeRoot } from "./nx-workspace-reader.js";
14
+ /** Workspace-level files, in the order the report lists them. */
15
+ const workspaceInputNames = [
16
+ "package-lock.json",
17
+ "npm-shrinkwrap.json",
18
+ "pnpm-lock.yaml",
19
+ "yarn.lock",
20
+ "nx.json",
21
+ "workspace.json",
22
+ "package.json",
23
+ ];
24
+ /** Per-project files that can change what a project's targets mean. */
25
+ const projectInputNames = ["project.json", "package.json"];
26
+ /** The hex SHA-256 of `value`. */
27
+ export function sha256(value) {
28
+ return createHash("sha256").update(value).digest("hex");
29
+ }
30
+ /** Digests the workspace-level files that exist. */
31
+ export async function digestInputs(workspaceRoot) {
32
+ const entries = [];
33
+ for (const name of workspaceInputNames) {
34
+ const digested = await digestOptionalFile(workspaceRoot, name);
35
+ if (digested)
36
+ entries.push(digested);
37
+ }
38
+ return entries;
39
+ }
40
+ /**
41
+ * Adds each project's own configuration files to `rootInputs`, keyed by path
42
+ * so a project rooted at the workspace root cannot record `package.json`
43
+ * twice, and returns the whole set sorted by path.
44
+ */
45
+ export async function digestProjectInputs(workspaceRoot, rootInputs, projectRoots) {
46
+ const entries = new Map(rootInputs.map((entry) => [entry.path, entry]));
47
+ for (const root of projectRoots) {
48
+ for (const name of projectInputNames) {
49
+ const relative = normalizeRoot(path.posix.join(root, name));
50
+ const digested = await digestOptionalFile(workspaceRoot, relative);
51
+ if (digested)
52
+ entries.set(relative, digested);
53
+ }
54
+ }
55
+ return [...entries.values()].sort((left, right) => left.path.localeCompare(right.path));
56
+ }
57
+ /** Digests one workspace-relative file, or `undefined` when it is absent. */
58
+ async function digestOptionalFile(workspaceRoot, relativePath) {
59
+ try {
60
+ const contents = await fs.readFile(path.join(workspaceRoot, relativePath));
61
+ return { path: relativePath, sha256: sha256(contents) };
62
+ }
63
+ catch (error) {
64
+ if (isMissingFile(error))
65
+ return undefined;
66
+ throw error;
67
+ }
68
+ }
69
+ //# sourceMappingURL=import-digest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-digest.js","sourceRoot":"","sources":["../../src/nx/import-digest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAExE,iEAAiE;AACjE,MAAM,mBAAmB,GAAG;IAC1B,mBAAmB;IACnB,qBAAqB;IACrB,gBAAgB;IAChB,WAAW;IACX,SAAS;IACT,gBAAgB;IAChB,cAAc;CACf,CAAC;AAEF,uEAAuE;AACvE,MAAM,iBAAiB,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;AAE3D,kCAAkC;AAClC,MAAM,UAAU,MAAM,CAAC,KAA0B;IAC/C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,oDAAoD;AACpD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,aAAqB;IACtD,MAAM,OAAO,GAAoB,EAAE,CAAC;IACpC,KAAK,MAAM,IAAI,IAAI,mBAAmB,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;QAC/D,IAAI,QAAQ;YAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH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,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Every shape the Nx importer reads, produces, or hands back.
3
+ *
4
+ * Two vocabularies meet here and are deliberately kept apart. `Nx*` types
5
+ * describe what was read out of an Nx workspace and are internal; `Dads*`
6
+ * types and the report describe what this package publishes and are the
7
+ * contract consumers depend on. Nothing in this file behaves, so a reader who
8
+ * wants to know what an import produces can read one file and stop.
9
+ */
10
+ import type { JsonValue } from "./json-values.js";
11
+ export type NxCommandRunner = (input: {
12
+ readonly executable: string;
13
+ readonly args: readonly string[];
14
+ readonly cwd: string;
15
+ }) => Promise<{
16
+ readonly stdout: string;
17
+ readonly stderr: string;
18
+ }>;
19
+ export type ImportNxTestingOptions = {
20
+ readonly workspaceRoot: string;
21
+ /** Full immutable Git object ID the caller approved for this import. */
22
+ readonly expectedGitSha: string;
23
+ readonly runner?: NxCommandRunner;
24
+ };
25
+ export type DadsTestingTask = {
26
+ readonly id: string;
27
+ readonly project: string;
28
+ readonly kind: "test" | "typecheck" | "lint" | "build" | "custom";
29
+ readonly execution: {
30
+ readonly executable: string;
31
+ readonly args?: readonly string[];
32
+ readonly cwd: string;
33
+ };
34
+ readonly dependsOn: readonly string[];
35
+ readonly impact: {
36
+ readonly mode: "project";
37
+ };
38
+ };
39
+ export type DadsTestingManifest = {
40
+ readonly schemaVersion: 1;
41
+ readonly workspace: {
42
+ readonly root: ".";
43
+ readonly fullFallback: {
44
+ readonly taskIds: readonly string[];
45
+ };
46
+ };
47
+ readonly projects: readonly {
48
+ readonly id: string;
49
+ readonly root: string;
50
+ readonly fallbackDependencies: readonly string[];
51
+ }[];
52
+ readonly tasks: readonly DadsTestingTask[];
53
+ };
54
+ export type NxImportReport = {
55
+ readonly schemaVersion: 1;
56
+ readonly importer: {
57
+ /** Producer identifier used by schema version 1. */
58
+ readonly name: "@dads-framework/testing-import-nx";
59
+ readonly manifestChecksum: string | null;
60
+ };
61
+ readonly source: {
62
+ readonly workspaceRoot: string;
63
+ readonly expectedGitSha: string;
64
+ readonly resolvedGitSha: string;
65
+ readonly versions: Readonly<Record<string, string>>;
66
+ readonly inputs: readonly {
67
+ readonly path: string;
68
+ readonly sha256: string;
69
+ }[];
70
+ readonly locations: readonly string[];
71
+ };
72
+ readonly nx: {
73
+ readonly projects: readonly string[];
74
+ readonly resolvedProjects: readonly {
75
+ readonly name: string;
76
+ readonly configuration: JsonValue;
77
+ }[];
78
+ readonly projectGraph: JsonValue;
79
+ readonly executors: readonly string[];
80
+ readonly plugins: readonly string[];
81
+ };
82
+ readonly summary: {
83
+ readonly projects: number;
84
+ readonly targets: number;
85
+ readonly converted: number;
86
+ readonly excluded: number;
87
+ };
88
+ readonly tasks: readonly ImportedTaskAudit[];
89
+ readonly droppedFields: readonly DroppedField[];
90
+ readonly failures: readonly ImportFailure[];
91
+ };
92
+ export type ImportNxTestingResult = {
93
+ readonly manifest: DadsTestingManifest;
94
+ readonly report: NxImportReport;
95
+ readonly manifestPath: string;
96
+ readonly reportPath: string;
97
+ };
98
+ export type ImportedTaskAudit = {
99
+ readonly project: string;
100
+ readonly target: string;
101
+ readonly sourceLocation: string;
102
+ readonly classification: "converted" | "native-adapter-needed" | "opaque" | "excluded";
103
+ readonly reason: string;
104
+ readonly executor?: string;
105
+ readonly substitutions: readonly PlaceholderSubstitution[];
106
+ readonly droppedFields: readonly string[];
107
+ };
108
+ export type PlaceholderSubstitution = {
109
+ readonly placeholder: "{workspaceRoot}" | "{projectRoot}";
110
+ readonly value: string;
111
+ };
112
+ export type DroppedField = {
113
+ readonly project: string;
114
+ readonly target: string;
115
+ readonly field: string;
116
+ };
117
+ export type ImportFailure = {
118
+ readonly stage: "nx-command" | "json" | "graph" | "project" | "conversion";
119
+ readonly subject: string;
120
+ readonly message: string;
121
+ };
122
+ /** Why one Nx target did not become a standalone task. */
123
+ export type TargetExclusion = {
124
+ readonly classification: ImportedTaskAudit["classification"];
125
+ readonly reason: string;
126
+ };
127
+ /** What converting one Nx target contributed to the import. */
128
+ export type TargetConversion = {
129
+ readonly task?: DadsTestingTask;
130
+ readonly audit: ImportedTaskAudit;
131
+ readonly droppedFields: readonly DroppedField[];
132
+ readonly failure?: ImportFailure;
133
+ };
134
+ export type NxProject = {
135
+ readonly name: string;
136
+ readonly id: string;
137
+ readonly root: string;
138
+ readonly targets: readonly NxTarget[];
139
+ };
140
+ export type NxTarget = {
141
+ readonly name: string;
142
+ readonly id: string;
143
+ readonly executor?: string;
144
+ readonly command?: string;
145
+ readonly cwd?: string;
146
+ readonly continuous: boolean;
147
+ readonly inferred: boolean;
148
+ readonly unresolvedExecutionFields: readonly string[];
149
+ readonly droppedFields: readonly string[];
150
+ };
151
+ /** One project's configuration exactly as `nx show project` returned it. */
152
+ export type NxProjectSnapshot = {
153
+ readonly name: string;
154
+ readonly value: JsonValue;
155
+ };
156
+ /** The Git object ID the caller approved, and the one HEAD actually holds. */
157
+ export type GitSnapshot = {
158
+ readonly expected: string;
159
+ readonly resolved: string;
160
+ };
161
+ /** One file whose content the import was taken over. */
162
+ export type DigestedInput = {
163
+ readonly path: string;
164
+ readonly sha256: string;
165
+ };
166
+ //# sourceMappingURL=import-nx-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-nx-types.d.ts","sourceRoot":"","sources":["../../src/nx/import-nx-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE;IACpC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,KAAK,OAAO,CAAC;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC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CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,yBAAyB,EAAE,SAAS,MAAM,EAAE,CAAC;IACtD,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B,CAAC;AAEF,8EAA8E;AAC9E,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,wDAAwD;AACxD,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=import-nx-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-nx-types.js","sourceRoot":"","sources":["../../src/nx/import-nx-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { ImportNxTestingOptions, ImportNxTestingResult } from "./import-nx-types.js";
2
+ /**
3
+ * Imports only fully materialized, shell-free Nx run-commands targets. The
4
+ * output is a Dads-owned manifest; Nx is not read when the manifest executes.
5
+ */
6
+ export declare function importNxTestingWorkspace(options: ImportNxTestingOptions): Promise<ImportNxTestingResult>;
7
+ //# sourceMappingURL=import-nx-workspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"import-nx-workspace.d.ts","sourceRoot":"","sources":["../../src/nx/import-nx-workspace.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAQV,sBAAsB,EACtB,qBAAqB,EAMtB,MAAM,sBAAsB,CAAC;AA+C9B;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAuB9G"}
@@ -0,0 +1,292 @@
1
+ /**
2
+ * The import, read top to bottom.
3
+ *
4
+ * One Nx workspace becomes two files: a Dads-owned manifest that runs without
5
+ * Nx, and a report that says what was read, what was converted, and what was
6
+ * left behind and why. The phases below run in the order they are written —
7
+ * pin the source tree, read the graph, read the projects, convert the targets,
8
+ * then write — and each of the two shapes Nx can answer in that this importer
9
+ * does not understand ends with a report on disk before the failure is raised,
10
+ * so a refused import is still evidence rather than a stack trace.
11
+ */
12
+ import path from "node:path";
13
+ import { resolveLocalNxCli } from "./nx-installation.js";
14
+ import { writeOutputsAtomically } from "./atomic-output.js";
15
+ import { digestInputs, digestProjectInputs, sha256 } from "./import-digest.js";
16
+ import { stableJson } from "./json-values.js";
17
+ import { parseNxGraphFallbackDependencies } from "./nx-graph-fallback.js";
18
+ import { convertTarget } from "./nx-target-conversion.js";
19
+ import { parseProject, readNxPlugins, readOptionalJson, readNxProjectConfiguration, readProjects, readProjectGraph, readVersions, relativeLocation, requireCleanCommittedWorkspace, runProcess, } from "./nx-workspace-reader.js";
20
+ const outputManifestName = "dads.testing.json";
21
+ const outputReportName = "dads.testing.import-report.json";
22
+ /**
23
+ * Imports only fully materialized, shell-free Nx run-commands targets. The
24
+ * output is a Dads-owned manifest; Nx is not read when the manifest executes.
25
+ */
26
+ export async function importNxTestingWorkspace(options) {
27
+ const workspaceRoot = path.resolve(options.workspaceRoot);
28
+ const runner = options.runner ?? runProcess;
29
+ const source = await readNxSource(workspaceRoot, options.expectedGitSha, runner);
30
+ const graph = await readGraphOrReport(workspaceRoot, source, runner);
31
+ const workspace = await readWorkspaceProjects(workspaceRoot, source, runner);
32
+ const fallbackDependencies = await resolveFallbackOrReport({
33
+ workspaceRoot,
34
+ source,
35
+ workspace,
36
+ graph,
37
+ });
38
+ const conversion = await convertProjects(workspaceRoot, workspace.parsedProjects);
39
+ const manifest = buildManifest(workspace, conversion, fallbackDependencies);
40
+ const manifestContents = stableJson(manifest);
41
+ const report = buildReport({
42
+ source,
43
+ workspace,
44
+ graph,
45
+ conversion,
46
+ manifestChecksum: sha256(manifestContents),
47
+ });
48
+ return writeImportOutputs(workspaceRoot, manifest, manifestContents, report);
49
+ }
50
+ // --- Phases --------------------------------------------------------------
51
+ /** Pins the source tree, then reads everything that is not a project. */
52
+ async function readNxSource(workspaceRoot, expectedGitSha, runner) {
53
+ const gitSnapshot = await requireCleanCommittedWorkspace(workspaceRoot, expectedGitSha, runner);
54
+ const nxExecutable = await resolveLocalNxCli(workspaceRoot);
55
+ const versions = await readVersions(workspaceRoot, nxExecutable, runner);
56
+ const rootInputs = await digestInputs(workspaceRoot);
57
+ const nxConfig = await readOptionalJson(path.join(workspaceRoot, "nx.json"));
58
+ const plugins = readNxPlugins(nxConfig);
59
+ const projects = await readProjects(workspaceRoot, nxExecutable, runner);
60
+ return {
61
+ gitSnapshot,
62
+ nxExecutable,
63
+ versions,
64
+ rootInputs,
65
+ plugins,
66
+ projects,
67
+ };
68
+ }
69
+ /** Reads the project graph, or leaves a report saying why it could not. */
70
+ async function readGraphOrReport(workspaceRoot, source, runner) {
71
+ try {
72
+ return await readProjectGraph(workspaceRoot, source.nxExecutable, runner);
73
+ }
74
+ catch (error) {
75
+ const message = failureMessage(error, "Unknown graph collection failure.");
76
+ await writeUnsupportedGraphReport({
77
+ workspaceRoot,
78
+ source,
79
+ inputs: source.rootInputs,
80
+ message,
81
+ });
82
+ throw new Error(message, { cause: error });
83
+ }
84
+ }
85
+ /** Reads every project, and digests the files each one is derived from. */
86
+ async function readWorkspaceProjects(workspaceRoot, source, runner) {
87
+ const snapshots = await Promise.all(source.projects.map(async (project) => ({
88
+ name: project,
89
+ value: await readNxProjectConfiguration(workspaceRoot, source.nxExecutable, runner, project),
90
+ })));
91
+ const parsed = snapshots.map((snapshot) => parseProject(snapshot.value, snapshot.name));
92
+ const inputs = await digestProjectInputs(workspaceRoot, source.rootInputs, parsed.map((project) => project.root));
93
+ return {
94
+ snapshots,
95
+ parsedProjects: [...parsed].sort((left, right) => left.name.localeCompare(right.name)),
96
+ inputs,
97
+ };
98
+ }
99
+ /** Reads the fallback edges, or leaves a report naming the shape it saw. */
100
+ async function resolveFallbackOrReport(input) {
101
+ try {
102
+ return parseNxGraphFallbackDependencies(input.graph, input.workspace.parsedProjects);
103
+ }
104
+ catch (error) {
105
+ const message = failureMessage(error, "Unknown Nx graph shape failure.");
106
+ await writeUnsupportedGraphReport({
107
+ workspaceRoot: input.workspaceRoot,
108
+ source: input.source,
109
+ inputs: input.workspace.inputs,
110
+ graph: input.graph,
111
+ resolvedProjects: input.workspace.snapshots,
112
+ message,
113
+ });
114
+ throw new Error(message, { cause: error });
115
+ }
116
+ }
117
+ /** Converts every target of every project, keeping the audit for each one. */
118
+ async function convertProjects(workspaceRoot, projects) {
119
+ const conversions = [];
120
+ const executors = new Set();
121
+ let targetCount = 0;
122
+ for (const project of projects) {
123
+ const sourceLocation = relativeLocation(workspaceRoot, project.root);
124
+ for (const target of project.targets) {
125
+ targetCount += 1;
126
+ if (target.executor)
127
+ executors.add(target.executor);
128
+ conversions.push(await convertTarget({ workspaceRoot, project, target, sourceLocation }));
129
+ }
130
+ }
131
+ return {
132
+ tasks: conversions.flatMap((one) => (one.task ? [one.task] : [])),
133
+ audits: conversions.map((one) => one.audit),
134
+ droppedFields: conversions.flatMap((one) => one.droppedFields),
135
+ failures: conversions.flatMap((one) => (one.failure ? [one.failure] : [])),
136
+ executors: [...executors].sort(),
137
+ targetCount,
138
+ };
139
+ }
140
+ // --- The two outputs -----------------------------------------------------
141
+ /** The manifest: projects and tasks, each sorted by its Dads identifier. */
142
+ function buildManifest(workspace, conversion, fallbackDependencies) {
143
+ return {
144
+ schemaVersion: 1,
145
+ workspace: {
146
+ root: ".",
147
+ fullFallback: {
148
+ taskIds: conversion.tasks.map((task) => task.id).sort(),
149
+ },
150
+ },
151
+ projects: workspace.parsedProjects
152
+ .map((project) => ({
153
+ id: project.id,
154
+ root: project.root,
155
+ fallbackDependencies: fallbackDependencies.get(project.name) ?? [],
156
+ }))
157
+ .sort((left, right) => left.id.localeCompare(right.id)),
158
+ tasks: [...conversion.tasks].sort((left, right) => left.id.localeCompare(right.id)),
159
+ };
160
+ }
161
+ /** The report: what was read, what it became, and everything left behind. */
162
+ function buildReport(input) {
163
+ const { source, workspace, conversion } = input;
164
+ return {
165
+ schemaVersion: 1,
166
+ importer: {
167
+ name: "@dads-framework/testing-import-nx",
168
+ manifestChecksum: input.manifestChecksum,
169
+ },
170
+ source: {
171
+ workspaceRoot: ".",
172
+ expectedGitSha: source.gitSnapshot.expected,
173
+ resolvedGitSha: source.gitSnapshot.resolved,
174
+ versions: source.versions,
175
+ inputs: workspace.inputs,
176
+ locations: workspace.inputs.map((entry) => entry.path),
177
+ },
178
+ nx: {
179
+ projects: source.projects,
180
+ resolvedProjects: resolvedConfigurations(workspace.snapshots),
181
+ projectGraph: input.graph,
182
+ executors: conversion.executors,
183
+ plugins: source.plugins,
184
+ },
185
+ summary: {
186
+ projects: source.projects.length,
187
+ targets: conversion.targetCount,
188
+ converted: conversion.tasks.length,
189
+ excluded: conversion.audits.length - conversion.tasks.length,
190
+ },
191
+ tasks: [...conversion.audits].sort(byAuditIdentity),
192
+ droppedFields: [...conversion.droppedFields].sort(byDroppedFieldIdentity),
193
+ failures: [...conversion.failures].sort((left, right) => left.subject.localeCompare(right.subject)),
194
+ };
195
+ }
196
+ /** Each project's configuration exactly as Nx gave it, sorted by name. */
197
+ function resolvedConfigurations(snapshots) {
198
+ return snapshots
199
+ .map((snapshot) => ({
200
+ name: snapshot.name,
201
+ configuration: snapshot.value,
202
+ }))
203
+ .sort((left, right) => left.name.localeCompare(right.name));
204
+ }
205
+ /**
206
+ * Writes both outputs, or — when nothing converted — only the report. A strict
207
+ * v1 manifest needs at least one task, so an empty import is a failure that
208
+ * still leaves the evidence of why behind.
209
+ */
210
+ async function writeImportOutputs(workspaceRoot, manifest, manifestContents, report) {
211
+ const manifestPath = path.join(workspaceRoot, outputManifestName);
212
+ const reportPath = path.join(workspaceRoot, outputReportName);
213
+ if (manifest.tasks.length === 0) {
214
+ const contents = stableJson(noStandaloneReport(report));
215
+ await writeOutputsAtomically([{ path: reportPath, contents }]);
216
+ throw new Error("No standalone Nx tasks were convertible; see dads.testing.import-report.json.");
217
+ }
218
+ await writeOutputsAtomically([
219
+ { path: manifestPath, contents: manifestContents },
220
+ { path: reportPath, contents: stableJson(report) },
221
+ ]);
222
+ return { manifest, report, manifestPath, reportPath };
223
+ }
224
+ /** The report as it reads when no manifest was written beside it. */
225
+ function noStandaloneReport(report) {
226
+ return {
227
+ ...report,
228
+ importer: { ...report.importer, manifestChecksum: null },
229
+ failures: [
230
+ ...report.failures,
231
+ {
232
+ stage: "conversion",
233
+ subject: "manifest",
234
+ message: "No standalone tasks were convertible; no dads.testing.json was written because strict v1 manifests require at least one task.",
235
+ },
236
+ ],
237
+ };
238
+ }
239
+ /** Nothing converted, because nothing was ever read. */
240
+ const nothingConverted = {
241
+ tasks: [],
242
+ audits: [],
243
+ droppedFields: [],
244
+ failures: [],
245
+ executors: [],
246
+ targetCount: 0,
247
+ };
248
+ /**
249
+ * The report an import leaves behind when Nx answered in a shape this
250
+ * importer does not understand: the same report as a successful import, made
251
+ * of everything that had been read, carrying the one failure that stopped it.
252
+ */
253
+ async function writeUnsupportedGraphReport(input) {
254
+ const report = buildReport({
255
+ source: input.source,
256
+ workspace: {
257
+ snapshots: input.resolvedProjects ?? [],
258
+ parsedProjects: [],
259
+ inputs: input.inputs,
260
+ },
261
+ graph: input.graph ?? null,
262
+ conversion: nothingConverted,
263
+ manifestChecksum: null,
264
+ });
265
+ await writeOutputsAtomically([
266
+ {
267
+ path: path.join(input.workspaceRoot, outputReportName),
268
+ contents: stableJson({
269
+ ...report,
270
+ failures: [
271
+ {
272
+ stage: "graph",
273
+ subject: "nx graph --file",
274
+ message: input.message,
275
+ },
276
+ ],
277
+ }),
278
+ },
279
+ ]);
280
+ }
281
+ // --- Ordering ------------------------------------------------------------
282
+ /** `error`'s message, or `fallback` when it was not an `Error` at all. */
283
+ function failureMessage(error, fallback) {
284
+ return error instanceof Error ? error.message : fallback;
285
+ }
286
+ function byAuditIdentity(left, right) {
287
+ return `${left.project}:${left.target}`.localeCompare(`${right.project}:${right.target}`);
288
+ }
289
+ function byDroppedFieldIdentity(left, right) {
290
+ return `${left.project}:${left.target}:${left.field}`.localeCompare(`${right.project}:${right.target}:${right.field}`);
291
+ }
292
+ //# sourceMappingURL=import-nx-workspace.js.map