@dads-framework/testing 0.5.1 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +111 -18
  2. package/dist/commands/diagnose.d.ts +15 -0
  3. package/dist/commands/diagnose.d.ts.map +1 -0
  4. package/dist/commands/diagnose.js +119 -0
  5. package/dist/commands/diagnose.js.map +1 -0
  6. package/dist/commands/plan-run.d.ts.map +1 -1
  7. package/dist/commands/plan-run.js +11 -1
  8. package/dist/commands/plan-run.js.map +1 -1
  9. package/dist/dad-test-cli.d.ts.map +1 -1
  10. package/dist/dad-test-cli.js +20 -3
  11. package/dist/dad-test-cli.js.map +1 -1
  12. package/dist/dst/fault-delivery.d.ts +60 -0
  13. package/dist/dst/fault-delivery.d.ts.map +1 -0
  14. package/dist/dst/fault-delivery.js +164 -0
  15. package/dist/dst/fault-delivery.js.map +1 -0
  16. package/dist/dst/fault-transactions.d.ts +58 -0
  17. package/dist/dst/fault-transactions.d.ts.map +1 -0
  18. package/dist/dst/fault-transactions.js +127 -0
  19. package/dist/dst/fault-transactions.js.map +1 -0
  20. package/dist/dst/index.d.ts +7 -0
  21. package/dist/dst/index.d.ts.map +1 -0
  22. package/dist/dst/index.js +7 -0
  23. package/dist/dst/index.js.map +1 -0
  24. package/dist/dst/prng.d.ts +36 -0
  25. package/dist/dst/prng.d.ts.map +1 -0
  26. package/dist/dst/prng.js +98 -0
  27. package/dist/dst/prng.js.map +1 -0
  28. package/dist/dst/sim-clock.d.ts +32 -0
  29. package/dist/dst/sim-clock.d.ts.map +1 -0
  30. package/dist/dst/sim-clock.js +75 -0
  31. package/dist/dst/sim-clock.js.map +1 -0
  32. package/dist/dst/sim-world.d.ts +28 -0
  33. package/dist/dst/sim-world.d.ts.map +1 -0
  34. package/dist/dst/sim-world.js +26 -0
  35. package/dist/dst/sim-world.js.map +1 -0
  36. package/dist/dst/simulation-runner.d.ts +78 -0
  37. package/dist/dst/simulation-runner.d.ts.map +1 -0
  38. package/dist/dst/simulation-runner.js +209 -0
  39. package/dist/dst/simulation-runner.js.map +1 -0
  40. package/dist/explain-plan.d.ts +4 -0
  41. package/dist/explain-plan.d.ts.map +1 -1
  42. package/dist/explain-plan.js +30 -36
  43. package/dist/explain-plan.js.map +1 -1
  44. package/dist/index.d.ts +3 -2
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +2 -1
  47. package/dist/index.js.map +1 -1
  48. package/dist/init/check-testing-manifest.js +9 -0
  49. package/dist/init/check-testing-manifest.js.map +1 -1
  50. package/dist/init/dads-app-discovery.d.ts +24 -0
  51. package/dist/init/dads-app-discovery.d.ts.map +1 -0
  52. package/dist/init/dads-app-discovery.js +168 -0
  53. package/dist/init/dads-app-discovery.js.map +1 -0
  54. package/dist/init/infer-dads-app.d.ts +11 -0
  55. package/dist/init/infer-dads-app.d.ts.map +1 -0
  56. package/dist/init/infer-dads-app.js +228 -0
  57. package/dist/init/infer-dads-app.js.map +1 -0
  58. package/dist/init/infer-one-package.d.ts.map +1 -1
  59. package/dist/init/infer-one-package.js +5 -4
  60. package/dist/init/infer-one-package.js.map +1 -1
  61. package/dist/init/init-testing-manifest.d.ts.map +1 -1
  62. package/dist/init/init-testing-manifest.js +3 -2
  63. package/dist/init/init-testing-manifest.js.map +1 -1
  64. package/dist/nx/dads-identifier.d.ts +7 -3
  65. package/dist/nx/dads-identifier.d.ts.map +1 -1
  66. package/dist/nx/dads-identifier.js +23 -5
  67. package/dist/nx/dads-identifier.js.map +1 -1
  68. package/dist/nx/index.d.ts +5 -1
  69. package/dist/nx/index.d.ts.map +1 -1
  70. package/dist/nx/index.js +5 -1
  71. package/dist/nx/index.js.map +1 -1
  72. package/dist/nx/nx-eject-targets.d.ts +30 -0
  73. package/dist/nx/nx-eject-targets.d.ts.map +1 -0
  74. package/dist/nx/nx-eject-targets.js +283 -0
  75. package/dist/nx/nx-eject-targets.js.map +1 -0
  76. package/dist/nx/nx-eject-vitest.d.ts +24 -0
  77. package/dist/nx/nx-eject-vitest.d.ts.map +1 -0
  78. package/dist/nx/nx-eject-vitest.js +156 -0
  79. package/dist/nx/nx-eject-vitest.js.map +1 -0
  80. package/dist/nx/nx-eject-workspace.d.ts +45 -0
  81. package/dist/nx/nx-eject-workspace.d.ts.map +1 -0
  82. package/dist/nx/nx-eject-workspace.js +267 -0
  83. package/dist/nx/nx-eject-workspace.js.map +1 -0
  84. package/dist/nx/nx-native-cli.js +88 -8
  85. package/dist/nx/nx-native-cli.js.map +1 -1
  86. package/dist/nx/nx-native-inputs.d.ts +9 -2
  87. package/dist/nx/nx-native-inputs.d.ts.map +1 -1
  88. package/dist/nx/nx-native-inputs.js +87 -35
  89. package/dist/nx/nx-native-inputs.js.map +1 -1
  90. package/dist/nx/nx-native-model.d.ts +3 -2
  91. package/dist/nx/nx-native-model.d.ts.map +1 -1
  92. package/dist/nx/nx-native-model.js +117 -28
  93. package/dist/nx/nx-native-model.js.map +1 -1
  94. package/dist/nx/nx-native-scope.d.ts +1 -1
  95. package/dist/nx/nx-native-scope.d.ts.map +1 -1
  96. package/dist/nx/nx-native-workspace.d.ts +14 -1
  97. package/dist/nx/nx-native-workspace.d.ts.map +1 -1
  98. package/dist/nx/nx-native-workspace.js +40 -5
  99. package/dist/nx/nx-native-workspace.js.map +1 -1
  100. package/dist/plan-reasons.d.ts.map +1 -1
  101. package/dist/plan-reasons.js +4 -0
  102. package/dist/plan-reasons.js.map +1 -1
  103. package/dist/testing-api.d.ts +78 -0
  104. package/dist/testing-api.d.ts.map +1 -1
  105. package/dist/testing-api.js +9 -0
  106. package/dist/testing-api.js.map +1 -1
  107. package/dist/testing-manifest-sql.d.ts +24 -0
  108. package/dist/testing-manifest-sql.d.ts.map +1 -0
  109. package/dist/testing-manifest-sql.js +104 -0
  110. package/dist/testing-manifest-sql.js.map +1 -0
  111. package/dist/testing-manifest.d.ts +12 -0
  112. package/dist/testing-manifest.d.ts.map +1 -1
  113. package/dist/testing-manifest.js +74 -3
  114. package/dist/testing-manifest.js.map +1 -1
  115. package/dist/testing.tsbuildinfo +1 -1
  116. package/dst/README.md +75 -0
  117. package/nx/README.md +78 -39
  118. package/package.json +11 -6
package/nx/README.md CHANGED
@@ -65,27 +65,45 @@ adapter follows dependencies and expands inputs.
65
65
 
66
66
  ## Commands
67
67
 
68
- ### `dad-test-nx plan|run [workspace]`
68
+ ### `dad-test-nx plan|run|diagnose|eject [workspace]`
69
69
 
70
70
  `plan` discovers the current Nx project graph and plans verification without
71
- executing targets. `run` plans the same way, then delegates the selected
71
+ executing targets, using Oxc symbol-level reachability for `test`, `typecheck`,
72
+ and `build` targets. `run` plans the same way, then delegates the selected
72
73
  targets to the installed Nx CLI, preserving configurations, inferred
73
- executors, command options, environment settings, and prerequisites. The
74
- workspace defaults to the current directory. Both accept:
75
-
76
- - `--base <ref>` compares that ref with the working tree.
74
+ executors, command options, environment settings, and prerequisites. `diagnose`
75
+ runs the coupling and precision X-ray directly against the live Nx graph with
76
+ zero hand-authored manifest (`dad-test diagnose` also auto-detects `nx.json`
77
+ and invokes this path automatically). `eject` is the one-command exit ramp off
78
+ Nx: it reads the live Nx project graph (including plugin-inferred Vitest,
79
+ ESLint, TypeScript, and `nx:run-commands` targets) and generates a standalone,
80
+ zero-Nx `dads.testing.json` with Vitest `fileNarrowing`, pure-check `dependsOn`
81
+ wiring, optional `nxViteTsPaths()` → `dadsTsconfigPaths()` config rewriting,
82
+ and an uninstall checklist. The workspace defaults to the current directory.
83
+ Options:
84
+
85
+ - `--base <ref>` compares that ref with the working tree (`plan`, `run`).
77
86
  - `--head <ref>` narrows the comparison to two commits; it requires `--base`,
78
- and that revision must be the clean checked-out `HEAD`.
87
+ and that revision must be the clean checked-out `HEAD` (`plan`, `run`).
79
88
  - `--all` selects the complete fallback. It cannot be combined with `--base`
80
- or `--head`.
89
+ or `--head` (`plan`, `run`).
81
90
  - `--targets <a,b>` selects exact Nx target names instead of the default
82
91
  verification families. Each name must be non-empty.
83
- - `--jobs <n>` sets the worker limit; it must be a positive integer.
84
- - `--json` prints the whole result object. The human two-line summary above is
85
- not a contract.
92
+ - `--jobs <n>` sets the worker limit; it must be a positive integer (`run`).
93
+ - `--write` writes `dads.testing.json` and `dads.testing.eject-report.json`
94
+ (`eject` runs as a dry-run preview without `--write`).
95
+ - `--force` allows overwriting an existing `dads.testing.json` (`eject --write`).
96
+ - `--replace-nx-vite-paths` rewrites clean `nxViteTsPaths()` imports and calls
97
+ to `dadsTsconfigPaths()` from `@dads-framework/testing/vitest` (`eject --write`).
98
+ - `--json` prints the whole result object with readable project and task ids
99
+ (such as `api:test`, escaping only names that contain non-identifier
100
+ characters). The human summary lines are not a contract.
101
+ - `-h`, `--help` prints full command usage and exits `0`.
86
102
 
87
103
  Each call rebuilds the declared task inventory, so there is no frozen manifest
88
- to silently omit a newly inferred task.
104
+ to silently omit a newly inferred task. When `.nx/` is gitignored, `nx graph`
105
+ reuses the workspace's existing `.nx/workspace-data` cache instead of forcing a
106
+ cold plugin scan.
89
107
 
90
108
  The default inventory is the exact targets `test`, `typecheck`, `lint`, and
91
109
  `build`, plus any target starting with `test:`, `typecheck:`, `typecheck-`,
@@ -96,23 +114,34 @@ inside a selected target, and Dads counts the selected root invocations.
96
114
 
97
115
  #### What a registered task's scope is
98
116
 
99
- A plugin-inferred target is scoped, not refused. Each registered task carries a
100
- conservative file scope built from what Nx itself declares:
101
-
102
- - the project's own root, and the root of every project it transitively depends
103
- on;
104
- - the workspace policy files — `nx.json`, `package.json`, the npm, pnpm and
105
- yarn lockfiles, `pnpm-workspace.yaml`, `tsconfig.json`, `tsconfig.base.json`;
106
- - every file input the target declares, or — when it declares none — the inputs
107
- of the `targetDefaults` entries keyed by its target name, its executor, or a
108
- wildcard, with named inputs expanded through the workspace and project
109
- `namedInputs`;
110
- - the inputs of every configuration, unioned, because a configuration matters
111
- only when it adds an input the default does not;
112
- - the project root, dependency roots and further prerequisites of every task in
113
- `dependsOn`. Nx normalizes `^build` into an explicit project list, and those
114
- projects are frequently outside the declaring project's import graph, so each
115
- one is followed rather than assumed.
117
+ A plugin-inferred target is scoped, not refused. Each registered task combines
118
+ Nx's declared input model with Oxc symbol-level reachability:
119
+
120
+ - **`test`, `typecheck`, and `build` targets** use `impact.mode: "reachability"`
121
+ across their project root and transitive Nx dependency roots (runtime edges
122
+ for `test`, full runtime plus `import type` edges for `typecheck` and
123
+ `build`), while retaining all non-graph paths in `impact.paths` (workspace
124
+ policy files, shared global inputs, and output-producing `dependsOn`
125
+ prerequisites such as `build` or codegen targets). Editing a comment,
126
+ private unused helper, or unimported export skips unaffected downstream
127
+ projects; editing a non-JS file, shared input, policy file, or dynamic
128
+ import widens conservatively.
129
+ - **`lint` and custom targets** stay on `impact.mode: "changed-files"` across
130
+ their project root, transitive dependency roots, workspace policy files, and
131
+ expanded file inputs so comment and formatting edits still run linters.
132
+ - **Pure-check prerequisites** (targets with explicit `outputs: []`, or
133
+ `lint`/`test`/`typecheck` targets with no declared `outputs`, such as a
134
+ repo-wide `workspace-scripts:lint-walls` gate) are registered once and wired
135
+ into `dependsOn` instead of folding their inputs into every consumer. When
136
+ the gate's own inputs change (or it is `always`), the gate runs once while
137
+ unaffected projects stay skipped.
138
+ - **Output-producing prerequisites** (`^build`, codegen targets, or any target
139
+ with declared `outputs`) stay folded into their consumer's `impact.paths` so
140
+ upstream generator or build source changes always invalidate the consumer.
141
+ - Workspace policy files (`nx.json`, `package.json`, lockfiles,
142
+ `pnpm-workspace.yaml`, `tsconfig.json`, `tsconfig.base.json`), target-level
143
+ and `targetDefaults` inputs (with `namedInputs` expanded), and every
144
+ configuration's inputs are always included.
116
145
 
117
146
  Neither the presence of plugins, nor `targetDefaults`, nor `dependsOn`, nor
118
147
  configurations is by itself a reason to give up on a scope. External
@@ -134,8 +163,7 @@ unowned path and the fallback cannot fire; a root-level file is then in scope
134
163
  only if Nx's own input model names it. That assumption is written into every
135
164
  registered task's reason rather than left implied.
136
165
 
137
- This first adapter does not promise symbol-level precision for opaque Nx tasks;
138
- Nx remains authoritative for their execution. Its input model is documented in
166
+ Nx remains authoritative for target execution; its input model is documented in
139
167
  the [Nx input reference](https://nx.dev/docs/reference/inputs).
140
168
 
141
169
  The working tree may be dirty. Discovery and planning reject concurrent changes
@@ -171,15 +199,24 @@ import and writes an explicit report rather than guessing edge direction.
171
199
 
172
200
  ## Use it
173
201
 
174
- The `@dads-framework/testing/nx` entry point exports three functions, each
175
- taking one options object:
202
+ The `@dads-framework/testing/nx` entry point exports the live adapter,
203
+ diagnostic, identifier, and migration functions:
176
204
 
177
205
  - `planNativeNxTesting(options)` and `runNativeNxTesting(options)` back the
178
206
  live adapter. Options are the testing operation request minus `manifestPath`
179
207
  and `taskIds` — `workspaceRoot`, `base`, `head`, `all`, `jobs`, plus exact
180
208
  `targetNames`. An explicit `nativeBinary` is available for local integration
181
209
  testing.
182
- - `importNxTestingWorkspace(options)` backs the migration, taking
210
+ - `diagnoseNativeNxTesting(options)` runs the coupling and precision X-ray
211
+ directly against the live Nx graph (`workspaceRoot`, optional `targetNames`,
212
+ optional `nativeBinary`).
213
+ - `ejectNativeNxTesting(options)` materializes Vitest, ESLint, TypeScript, and
214
+ `nx:run-commands` targets into a standalone zero-Nx `dads.testing.json`
215
+ (`workspaceRoot`, optional `targetNames`, `write`, `force`,
216
+ `replaceNxViteTsPaths`, `nativeBinary`).
217
+ - `dadsIdentifier(name)` and `decodeDadsIdentifier(id)` convert between Nx
218
+ names and readable, collision-free Dads identifiers.
219
+ - `importNxTestingWorkspace(options)` backs the one-way migration, taking
183
220
  `workspaceRoot`, the approved `expectedGitSha`, and an optional `runner`.
184
221
 
185
222
  Installing `@dads-framework/testing` provides both CLI commands. The adapter
@@ -208,12 +245,14 @@ invokes the Nx installation in the target workspace.
208
245
  ## Contract
209
246
 
210
247
  `planNativeNxTesting` and `runNativeNxTesting` resolve to
211
- `{ coverage, plan, run? }`. `coverage` carries `projects`, `targets`,
248
+ `{ coverage, plan, run? }`; `diagnoseNativeNxTesting` resolves to
249
+ `{ coverage, diagnose }`. `coverage` carries `projects`, `targets`,
212
250
  `registered`, `excluded`, `always`, and a `tasks` list; each entry names its
213
251
  `project` and `target`, a `classification` of `registered` or `excluded`, a
214
- `reason`, and for a registered target its `taskId` and an `impactMode` of
215
- `changed-files` or `always`. `plan` and `run` are the testing facade's plan and
216
- run results. `dad-test-nx` exits with the run's exit code, or `0` after a plan.
252
+ `reason`, and for a registered target its readable `taskId` and an `impactMode`
253
+ of `reachability`, `changed-files`, or `always`. `plan`, `run`, and `diagnose`
254
+ are the testing facade's plan, run, and diagnosis results. `dad-test-nx` exits
255
+ with the run's exit code, or `0` after `plan`, `diagnose`, or `--help`.
217
256
 
218
257
  `importNxTestingWorkspace` resolves to `{ manifest, report, manifestPath,
219
258
  reportPath }`. The manifest is `schemaVersion: 1` with a workspace rooted at
@@ -235,7 +274,7 @@ Failures are thrown as errors and, at the CLI, written to stderr. Notable ones:
235
274
 
236
275
  | Message | When |
237
276
  | --------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
238
- | `Usage: dad-test-nx plan\|run [workspace] …` | No operation, or more than two positionals |
277
+ | `Usage: dad-test-nx plan\|run\|diagnose\|eject [workspace] …` | No operation, or more than two positionals |
239
278
  | `Usage: dad-test-import-nx <nx-workspace-root> --sha <full-git-sha>` | Wrong argument shape; exits `2` |
240
279
  | `--all cannot be combined with --base or --head.` | Conflicting scope options |
241
280
  | `--head requires --base.` | `--head` alone |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dads-framework/testing",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -15,6 +15,10 @@
15
15
  "types": "./dist/index.d.ts",
16
16
  "default": "./dist/index.js"
17
17
  },
18
+ "./dst": {
19
+ "types": "./dist/dst/index.d.ts",
20
+ "default": "./dist/dst/index.js"
21
+ },
18
22
  "./nx": {
19
23
  "types": "./dist/nx/index.d.ts",
20
24
  "default": "./dist/nx/index.js"
@@ -32,6 +36,7 @@
32
36
  "bin",
33
37
  "dist",
34
38
  "README.md",
39
+ "dst/README.md",
35
40
  "nx/README.md"
36
41
  ],
37
42
  "scripts": {
@@ -41,11 +46,11 @@
41
46
  "typecheck": "tsc -b --pretty false"
42
47
  },
43
48
  "optionalDependencies": {
44
- "@dads-framework/testing-native-darwin-arm64": "0.5.1",
45
- "@dads-framework/testing-native-darwin-x64": "0.5.1",
46
- "@dads-framework/testing-native-linux-arm64-gnu": "0.5.1",
47
- "@dads-framework/testing-native-linux-x64-gnu": "0.5.1",
48
- "@dads-framework/testing-native-win32-x64": "0.5.1"
49
+ "@dads-framework/testing-native-darwin-arm64": "0.6.1",
50
+ "@dads-framework/testing-native-darwin-x64": "0.6.1",
51
+ "@dads-framework/testing-native-linux-arm64-gnu": "0.6.1",
52
+ "@dads-framework/testing-native-linux-x64-gnu": "0.6.1",
53
+ "@dads-framework/testing-native-win32-x64": "0.6.1"
49
54
  },
50
55
  "license": "MIT",
51
56
  "author": "Bryton Cooper",