@dads-framework/testing 0.2.0 → 0.3.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.
- package/README.md +4 -3
- package/bin/dad-test-import-nx.js +3 -0
- package/bin/dad-test-nx.js +3 -0
- package/dist/init/init-testing-manifest.js +1 -1
- package/dist/init/init-testing-manifest.js.map +1 -1
- package/dist/nx/atomic-output.d.ts +9 -0
- package/dist/nx/atomic-output.d.ts.map +1 -0
- package/dist/nx/atomic-output.js +39 -0
- package/dist/nx/atomic-output.js.map +1 -0
- package/dist/nx/cli.d.ts +2 -0
- package/dist/nx/cli.d.ts.map +1 -0
- package/dist/nx/cli.js +21 -0
- package/dist/nx/cli.js.map +1 -0
- package/dist/nx/dads-identifier.d.ts +11 -0
- package/dist/nx/dads-identifier.d.ts.map +1 -0
- package/dist/nx/dads-identifier.js +14 -0
- package/dist/nx/dads-identifier.js.map +1 -0
- package/dist/nx/import-digest.d.ts +12 -0
- package/dist/nx/import-digest.d.ts.map +1 -0
- package/dist/nx/import-digest.js +69 -0
- package/dist/nx/import-digest.js.map +1 -0
- package/dist/nx/import-nx-types.d.ts +166 -0
- package/dist/nx/import-nx-types.d.ts.map +1 -0
- package/dist/nx/import-nx-types.js +2 -0
- package/dist/nx/import-nx-types.js.map +1 -0
- package/dist/nx/import-nx-workspace.d.ts +7 -0
- package/dist/nx/import-nx-workspace.d.ts.map +1 -0
- package/dist/nx/import-nx-workspace.js +292 -0
- package/dist/nx/import-nx-workspace.js.map +1 -0
- package/dist/nx/import-nx.d.ts +12 -0
- package/dist/nx/import-nx.d.ts.map +1 -0
- package/dist/nx/import-nx.js +12 -0
- package/dist/nx/import-nx.js.map +1 -0
- package/dist/nx/index.d.ts +4 -0
- package/dist/nx/index.d.ts.map +1 -0
- package/dist/nx/index.js +4 -0
- package/dist/nx/index.js.map +1 -0
- package/dist/nx/json-values.d.ts +43 -0
- package/dist/nx/json-values.d.ts.map +1 -0
- package/dist/nx/json-values.js +76 -0
- package/dist/nx/json-values.js.map +1 -0
- package/dist/nx/nx-graph-fallback.d.ts +18 -0
- package/dist/nx/nx-graph-fallback.d.ts.map +1 -0
- package/dist/nx/nx-graph-fallback.js +61 -0
- package/dist/nx/nx-graph-fallback.js.map +1 -0
- package/dist/nx/nx-installation.d.ts +4 -0
- package/dist/nx/nx-installation.d.ts.map +1 -0
- package/dist/nx/nx-installation.js +97 -0
- package/dist/nx/nx-installation.js.map +1 -0
- package/dist/nx/nx-jsonc.d.ts +3 -0
- package/dist/nx/nx-jsonc.d.ts.map +1 -0
- package/dist/nx/nx-jsonc.js +91 -0
- package/dist/nx/nx-jsonc.js.map +1 -0
- package/dist/nx/nx-native-cli.d.ts +2 -0
- package/dist/nx/nx-native-cli.d.ts.map +1 -0
- package/dist/nx/nx-native-cli.js +64 -0
- package/dist/nx/nx-native-cli.js.map +1 -0
- package/dist/nx/nx-native-graph.d.ts +11 -0
- package/dist/nx/nx-native-graph.d.ts.map +1 -0
- package/dist/nx/nx-native-graph.js +130 -0
- package/dist/nx/nx-native-graph.js.map +1 -0
- package/dist/nx/nx-native-input-expansion.d.ts +9 -0
- package/dist/nx/nx-native-input-expansion.d.ts.map +1 -0
- package/dist/nx/nx-native-input-expansion.js +114 -0
- package/dist/nx/nx-native-input-expansion.js.map +1 -0
- package/dist/nx/nx-native-inputs.d.ts +9 -0
- package/dist/nx/nx-native-inputs.d.ts.map +1 -0
- package/dist/nx/nx-native-inputs.js +212 -0
- package/dist/nx/nx-native-inputs.js.map +1 -0
- package/dist/nx/nx-native-model.d.ts +28 -0
- package/dist/nx/nx-native-model.d.ts.map +1 -0
- package/dist/nx/nx-native-model.js +119 -0
- package/dist/nx/nx-native-model.js.map +1 -0
- package/dist/nx/nx-native-process.d.ts +2 -0
- package/dist/nx/nx-native-process.d.ts.map +1 -0
- package/dist/nx/nx-native-process.js +18 -0
- package/dist/nx/nx-native-process.js.map +1 -0
- package/dist/nx/nx-native-scope.d.ts +4 -0
- package/dist/nx/nx-native-scope.d.ts.map +1 -0
- package/dist/nx/nx-native-scope.js +21 -0
- package/dist/nx/nx-native-scope.js.map +1 -0
- package/dist/nx/nx-native-scratch.d.ts +5 -0
- package/dist/nx/nx-native-scratch.d.ts.map +1 -0
- package/dist/nx/nx-native-scratch.js +78 -0
- package/dist/nx/nx-native-scratch.js.map +1 -0
- package/dist/nx/nx-native-workspace.d.ts +16 -0
- package/dist/nx/nx-native-workspace.d.ts.map +1 -0
- package/dist/nx/nx-native-workspace.js +72 -0
- package/dist/nx/nx-native-workspace.js.map +1 -0
- package/dist/nx/nx-target-conversion.d.ts +9 -0
- package/dist/nx/nx-target-conversion.d.ts.map +1 -0
- package/dist/nx/nx-target-conversion.js +284 -0
- package/dist/nx/nx-target-conversion.js.map +1 -0
- package/dist/nx/nx-workspace-reader.d.ts +42 -0
- package/dist/nx/nx-workspace-reader.d.ts.map +1 -0
- package/dist/nx/nx-workspace-reader.js +302 -0
- package/dist/nx/nx-workspace-reader.js.map +1 -0
- package/dist/path-aliases/alias-file-system.d.ts +26 -0
- package/dist/path-aliases/alias-file-system.d.ts.map +1 -0
- package/dist/path-aliases/alias-file-system.js +16 -0
- package/dist/path-aliases/alias-file-system.js.map +1 -0
- package/dist/path-aliases/alias-resolver-conformance-cases.d.ts +40 -0
- package/dist/path-aliases/alias-resolver-conformance-cases.d.ts.map +1 -0
- package/dist/path-aliases/alias-resolver-conformance-cases.js +324 -0
- package/dist/path-aliases/alias-resolver-conformance-cases.js.map +1 -0
- package/dist/path-aliases/alias-resolver-conformance.d.ts +41 -0
- package/dist/path-aliases/alias-resolver-conformance.d.ts.map +1 -0
- package/dist/path-aliases/alias-resolver-conformance.js +141 -0
- package/dist/path-aliases/alias-resolver-conformance.js.map +1 -0
- package/dist/path-aliases/alias-resolver.d.ts +23 -0
- package/dist/path-aliases/alias-resolver.d.ts.map +1 -0
- package/dist/path-aliases/alias-resolver.js +199 -0
- package/dist/path-aliases/alias-resolver.js.map +1 -0
- package/dist/path-aliases/in-memory-file-system.d.ts +16 -0
- package/dist/path-aliases/in-memory-file-system.d.ts.map +1 -0
- package/dist/path-aliases/in-memory-file-system.js +43 -0
- package/dist/path-aliases/in-memory-file-system.js.map +1 -0
- package/dist/path-aliases/index.d.ts +6 -0
- package/dist/path-aliases/index.d.ts.map +1 -0
- package/dist/path-aliases/index.js +6 -0
- package/dist/path-aliases/index.js.map +1 -0
- package/dist/path-aliases/json-with-comments.d.ts +14 -0
- package/dist/path-aliases/json-with-comments.d.ts.map +1 -0
- package/dist/path-aliases/json-with-comments.js +245 -0
- package/dist/path-aliases/json-with-comments.js.map +1 -0
- package/dist/path-aliases/node-file-system.d.ts +10 -0
- package/dist/path-aliases/node-file-system.d.ts.map +1 -0
- package/dist/path-aliases/node-file-system.js +29 -0
- package/dist/path-aliases/node-file-system.js.map +1 -0
- package/dist/path-aliases/tsconfig-chain.d.ts +40 -0
- package/dist/path-aliases/tsconfig-chain.d.ts.map +1 -0
- package/dist/path-aliases/tsconfig-chain.js +139 -0
- package/dist/path-aliases/tsconfig-chain.js.map +1 -0
- package/dist/testing.tsbuildinfo +1 -1
- package/dist/vitest/dads-tsconfig-paths.d.ts +17 -0
- package/dist/vitest/dads-tsconfig-paths.d.ts.map +1 -0
- package/dist/vitest/dads-tsconfig-paths.js +38 -0
- package/dist/vitest/dads-tsconfig-paths.js.map +1 -0
- package/dist/vitest/index.d.ts +2 -0
- package/dist/vitest/index.d.ts.map +1 -0
- package/dist/vitest/index.js +2 -0
- package/dist/vitest/index.js.map +1 -0
- package/nx/README.md +259 -0
- package/package.json +35 -8
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Vite binding of the Dads alias resolver.
|
|
3
|
+
*
|
|
4
|
+
* Every rule about aliases — which config declares them, what a target may
|
|
5
|
+
* look like, which file a specifier names, and every refusal — belongs to
|
|
6
|
+
* `@dads-framework/testing/path-aliases` and is proven there against two file systems.
|
|
7
|
+
* What is left here is the one thing that is Vite's: an ordinary plugin that
|
|
8
|
+
* runs before Vite's own resolution and answers `resolveId` with the path the
|
|
9
|
+
* resolver found, or `null`.
|
|
10
|
+
*/
|
|
11
|
+
import type { Plugin } from "vite";
|
|
12
|
+
export type DadsTsconfigPathsOptions = {
|
|
13
|
+
/** Absolute paths are preferred. Relative paths resolve from process.cwd(). */
|
|
14
|
+
readonly tsconfig: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function dadsTsconfigPaths(options: DadsTsconfigPathsOptions): Plugin;
|
|
17
|
+
//# sourceMappingURL=dads-tsconfig-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dads-tsconfig-paths.d.ts","sourceRoot":"","sources":["../../src/vitest/dads-tsconfig-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,MAAM,MAAM,wBAAwB,GAAG;IACrC,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,MAAM,CAa3E"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Vite binding of the Dads alias resolver.
|
|
3
|
+
*
|
|
4
|
+
* Every rule about aliases — which config declares them, what a target may
|
|
5
|
+
* look like, which file a specifier names, and every refusal — belongs to
|
|
6
|
+
* `@dads-framework/testing/path-aliases` and is proven there against two file systems.
|
|
7
|
+
* What is left here is the one thing that is Vite's: an ordinary plugin that
|
|
8
|
+
* runs before Vite's own resolution and answers `resolveId` with the path the
|
|
9
|
+
* resolver found, or `null`.
|
|
10
|
+
*/
|
|
11
|
+
import { createAliasResolver, nodeFileSystem, } from "../path-aliases/index.js";
|
|
12
|
+
import { isRecord } from "../parse-guards.js";
|
|
13
|
+
export function dadsTsconfigPaths(options) {
|
|
14
|
+
const untrustedOptions = options;
|
|
15
|
+
const resolveTsconfigPath = createAliasResolver({
|
|
16
|
+
tsconfig: readRequiredTsconfigOption(untrustedOptions),
|
|
17
|
+
fileSystem: nodeFileSystem,
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
name: "dads-tsconfig-paths",
|
|
21
|
+
enforce: "pre",
|
|
22
|
+
resolveId(specifier) {
|
|
23
|
+
return resolveTsconfigPath(specifier);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** The plugin is called from JavaScript configs, so the options are untrusted. */
|
|
28
|
+
function readRequiredTsconfigOption(options) {
|
|
29
|
+
if (!isRecord(options)) {
|
|
30
|
+
throw new Error("dadsTsconfigPaths requires a non-empty tsconfig path.");
|
|
31
|
+
}
|
|
32
|
+
const tsconfig = options["tsconfig"];
|
|
33
|
+
if (typeof tsconfig !== "string" || tsconfig.trim().length === 0) {
|
|
34
|
+
throw new Error("dadsTsconfigPaths requires a non-empty tsconfig path.");
|
|
35
|
+
}
|
|
36
|
+
return tsconfig;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=dads-tsconfig-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dads-tsconfig-paths.js","sourceRoot":"","sources":["../../src/vitest/dads-tsconfig-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,mBAAmB,EACnB,cAAc,GAEf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAQ9C,MAAM,UAAU,iBAAiB,CAAC,OAAiC;IACjE,MAAM,gBAAgB,GAAY,OAAO,CAAC;IAC1C,MAAM,mBAAmB,GAAkB,mBAAmB,CAAC;QAC7D,QAAQ,EAAE,0BAA0B,CAAC,gBAAgB,CAAC;QACtD,UAAU,EAAE,cAAc;KAC3B,CAAC,CAAC;IACH,OAAO;QACL,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EAAE,KAAK;QACd,SAAS,CAAC,SAAS;YACjB,OAAO,mBAAmB,CAAC,SAAS,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC;AAED,kFAAkF;AAClF,SAAS,0BAA0B,CAAC,OAAgB;IAClD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vitest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vitest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAElB,MAAM,0BAA0B,CAAC"}
|
package/nx/README.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# `@dads-framework/testing/nx`
|
|
2
|
+
|
|
3
|
+
Two ways to reach Dads testing from an Nx repository: a live adapter that plans
|
|
4
|
+
and runs Nx targets in place, and a one-way command that converts a clean Nx
|
|
5
|
+
workspace into a standalone Dads manifest. The testing facade and the native
|
|
6
|
+
impact engine stay independent of Nx either way.
|
|
7
|
+
|
|
8
|
+
## What Dad does for you
|
|
9
|
+
|
|
10
|
+
Dad will meet your repository where it is and still tell you what he could not
|
|
11
|
+
prove. Every target he registers carries a reason, every target he excludes
|
|
12
|
+
carries a reason, and the ones Nx alone can explain are selected every time
|
|
13
|
+
rather than guessed at.
|
|
14
|
+
|
|
15
|
+
## Try it
|
|
16
|
+
|
|
17
|
+
The npm install below is for the public release.
|
|
18
|
+
|
|
19
|
+
Use Node.js 22 or newer and Git. The adapter uses the Nx installation in the
|
|
20
|
+
workspace. This example creates a small Nx workspace with independent
|
|
21
|
+
`api:test` and `web:test` targets. Run it in an empty directory.
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm init -y
|
|
25
|
+
npm install --save-dev nx @dads-framework/testing
|
|
26
|
+
printf '{}\n' > nx.json
|
|
27
|
+
printf 'node_modules/\n.nx/\n' > .gitignore
|
|
28
|
+
|
|
29
|
+
for project in api web; do
|
|
30
|
+
mkdir -p "apps/$project"
|
|
31
|
+
cat > "apps/$project/project.json" <<JSON
|
|
32
|
+
{
|
|
33
|
+
"name": "$project",
|
|
34
|
+
"targets": {
|
|
35
|
+
"test": {
|
|
36
|
+
"executor": "nx:run-commands",
|
|
37
|
+
"options": { "command": "node --version" }
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
JSON
|
|
42
|
+
printf 'module.exports = "v1";\n' > "apps/$project/index.js"
|
|
43
|
+
done
|
|
44
|
+
|
|
45
|
+
git init -q
|
|
46
|
+
git add .
|
|
47
|
+
git -c user.name="Dads Example" -c user.email="example@example.invalid" commit -qm baseline
|
|
48
|
+
|
|
49
|
+
printf 'module.exports = "v2";\n' > apps/api/index.js
|
|
50
|
+
npx dad-test-nx plan --base HEAD --targets test
|
|
51
|
+
npx dad-test-nx run --base HEAD --targets test
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The plan reports two registered targets, one selected and one proven
|
|
55
|
+
unaffected. The run delegates `api:test` to Nx, which executes the sample
|
|
56
|
+
`node --version` command. Add `--json` to see the project and selection
|
|
57
|
+
reason for each task. In an existing Nx workspace, start with the last two
|
|
58
|
+
commands after installing the adapter and making a change.
|
|
59
|
+
|
|
60
|
+
Keep `nx.json` at the workspace root and each `project.json` in the
|
|
61
|
+
corresponding project directory, as in `apps/api/project.json` above. The
|
|
62
|
+
[adapter fixture](../src/nx/nx-native-plugin-workspace.test.ts) builds a disposable
|
|
63
|
+
workspace with a root config and plugin-inferred targets to exercise how the
|
|
64
|
+
adapter follows dependencies and expands inputs.
|
|
65
|
+
|
|
66
|
+
## Commands
|
|
67
|
+
|
|
68
|
+
### `dad-test-nx plan|run [workspace]`
|
|
69
|
+
|
|
70
|
+
`plan` discovers the current Nx project graph and plans verification without
|
|
71
|
+
executing targets. `run` plans the same way, then delegates the selected
|
|
72
|
+
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.
|
|
77
|
+
- `--head <ref>` narrows the comparison to two commits; it requires `--base`,
|
|
78
|
+
and that revision must be the clean checked-out `HEAD`.
|
|
79
|
+
- `--all` selects the complete fallback. It cannot be combined with `--base`
|
|
80
|
+
or `--head`.
|
|
81
|
+
- `--targets <a,b>` selects exact Nx target names instead of the default
|
|
82
|
+
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.
|
|
86
|
+
|
|
87
|
+
Each call rebuilds the declared task inventory, so there is no frozen manifest
|
|
88
|
+
to silently omit a newly inferred task.
|
|
89
|
+
|
|
90
|
+
The default inventory is the exact targets `test`, `typecheck`, `lint`, and
|
|
91
|
+
`build`, plus any target starting with `test:`, `typecheck:`, `typecheck-`,
|
|
92
|
+
`lint:`, or `lint-`. Continuous targets and targets outside the selection are
|
|
93
|
+
reported as excluded. Coverage counts describe this chosen verification scope,
|
|
94
|
+
not every runnable operation in the repository; Nx may execute prerequisites
|
|
95
|
+
inside a selected target, and Dads counts the selected root invocations.
|
|
96
|
+
|
|
97
|
+
#### What a registered task's scope is
|
|
98
|
+
|
|
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.
|
|
116
|
+
|
|
117
|
+
Neither the presence of plugins, nor `targetDefaults`, nor `dependsOn`, nor
|
|
118
|
+
configurations is by itself a reason to give up on a scope. External
|
|
119
|
+
dependencies are not either: a version change reaches the lockfile and
|
|
120
|
+
`package.json`, which are already policy paths.
|
|
121
|
+
|
|
122
|
+
A task selects on every invocation, with the reason recorded, when an input
|
|
123
|
+
cannot be located as a file: a `runtime` or `env` input, an input object that
|
|
124
|
+
names neither a fileset nor a JSON file, a named input that does not resolve or
|
|
125
|
+
is cyclic, an input path that is absolute or escapes the workspace or covers the
|
|
126
|
+
whole workspace, malformed `nx.json`, `namedInputs`, `targetDefaults`, `inputs`,
|
|
127
|
+
`configurations` or `dependsOn`, a dependency or prerequisite naming a project
|
|
128
|
+
the graph does not carry, and a project rooted at the workspace root, which owns
|
|
129
|
+
every path and so cannot be scoped at all.
|
|
130
|
+
|
|
131
|
+
An unowned changed path reaches the engine's complete fallback. Where the Nx
|
|
132
|
+
graph declares a project rooted at `.`, that project owns every otherwise
|
|
133
|
+
unowned path and the fallback cannot fire; a root-level file is then in scope
|
|
134
|
+
only if Nx's own input model names it. That assumption is written into every
|
|
135
|
+
registered task's reason rather than left implied.
|
|
136
|
+
|
|
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
|
|
139
|
+
the [Nx input reference](https://nx.dev/docs/reference/inputs).
|
|
140
|
+
|
|
141
|
+
The working tree may be dirty. Discovery and planning reject concurrent changes
|
|
142
|
+
to Git-visible source. Temporary manifests and raw graphs are created only in
|
|
143
|
+
an already-ignored directory physically inside the workspace, then removed.
|
|
144
|
+
The supported scratch locations are `node_modules/.cache/dads-testing`,
|
|
145
|
+
`.nx/dads-testing`, and `tmp/dads-testing`; an actionable error is returned if
|
|
146
|
+
none is safe. Keep any retained real-repository evidence outside source
|
|
147
|
+
control.
|
|
148
|
+
|
|
149
|
+
### `dad-test-import-nx <workspace> --sha <full-git-sha>`
|
|
150
|
+
|
|
151
|
+
An optional, one-way migration. It reads a clean, committed Nx workspace whose
|
|
152
|
+
`HEAD` matches the SHA you approved, and writes `dads.testing.json` plus
|
|
153
|
+
`dads.testing.import-report.json` beside it.
|
|
154
|
+
|
|
155
|
+
```sh
|
|
156
|
+
dad-test-import-nx /path/to/clean/nx-workspace --sha <full-clean-head-sha>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
It deliberately converts only fully materialized `nx:run-commands` targets into
|
|
160
|
+
argv-based recipes. Nx executors, inferred targets, continuous targets, shell
|
|
161
|
+
control syntax and escapes, and Vite/Vitest configs that import `nxViteTsPaths`
|
|
162
|
+
stay in the report as an explicit adapter or opaque seam. The generated
|
|
163
|
+
manifest contains no Nx command, executor, or runtime dependency. On a
|
|
164
|
+
workspace whose targets are plugin-inferred, which is the common shape today,
|
|
165
|
+
it converts nothing and says so; `dad-test-nx` is the path there.
|
|
166
|
+
|
|
167
|
+
It supports the frozen `nx graph --file` JSON shape with `graph.nodes` and
|
|
168
|
+
`graph.dependencies`; each `{ source, target }` edge becomes a Dads project
|
|
169
|
+
fallback dependency from source to target. An unknown graph shape stops the
|
|
170
|
+
import and writes an explicit report rather than guessing edge direction.
|
|
171
|
+
|
|
172
|
+
## Use it
|
|
173
|
+
|
|
174
|
+
The `@dads-framework/testing/nx` entry point exports three functions, each
|
|
175
|
+
taking one options object:
|
|
176
|
+
|
|
177
|
+
- `planNativeNxTesting(options)` and `runNativeNxTesting(options)` back the
|
|
178
|
+
live adapter. Options are the testing operation request minus `manifestPath`
|
|
179
|
+
and `taskIds` — `workspaceRoot`, `base`, `head`, `all`, `jobs`, plus exact
|
|
180
|
+
`targetNames`. An explicit `nativeBinary` is available for local integration
|
|
181
|
+
testing.
|
|
182
|
+
- `importNxTestingWorkspace(options)` backs the migration, taking
|
|
183
|
+
`workspaceRoot`, the approved `expectedGitSha`, and an optional `runner`.
|
|
184
|
+
|
|
185
|
+
Installing `@dads-framework/testing` provides both CLI commands. The adapter
|
|
186
|
+
invokes the Nx installation in the target workspace.
|
|
187
|
+
|
|
188
|
+
## What it refuses to do
|
|
189
|
+
|
|
190
|
+
- No import of a dirty workspace. Uncommitted or untracked changes, or a
|
|
191
|
+
`HEAD` that does not match the approved SHA, stop the import: an import is
|
|
192
|
+
only reproducible from a commit somebody named.
|
|
193
|
+
- No guessed Nx semantics. An unknown graph shape, a self-dependency, a
|
|
194
|
+
malformed target, or a missing edge array is a refusal with a report, not a
|
|
195
|
+
best-effort conversion.
|
|
196
|
+
- No shell in a converted recipe. A command with control syntax or escapes
|
|
197
|
+
stays an opaque seam, because a standalone task has no shell to interpret it.
|
|
198
|
+
- No Nx runtime in the generated manifest. If the import succeeds, the output
|
|
199
|
+
runs without Nx installed.
|
|
200
|
+
- No scratch files outside the workspace, and none that Git can see. Without an
|
|
201
|
+
already-ignored directory inside the workspace, the adapter stops.
|
|
202
|
+
- No results from a moving target. If Git-visible source changes during
|
|
203
|
+
discovery, planning, or execution, the run fails rather than reporting
|
|
204
|
+
numbers it can no longer stand behind.
|
|
205
|
+
- No claim of coverage it did not measure. Registered and excluded counts
|
|
206
|
+
describe the selected verification scope only.
|
|
207
|
+
|
|
208
|
+
## Contract
|
|
209
|
+
|
|
210
|
+
`planNativeNxTesting` and `runNativeNxTesting` resolve to
|
|
211
|
+
`{ coverage, plan, run? }`. `coverage` carries `projects`, `targets`,
|
|
212
|
+
`registered`, `excluded`, `always`, and a `tasks` list; each entry names its
|
|
213
|
+
`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.
|
|
217
|
+
|
|
218
|
+
`importNxTestingWorkspace` resolves to `{ manifest, report, manifestPath,
|
|
219
|
+
reportPath }`. The manifest is `schemaVersion: 1` with a workspace rooted at
|
|
220
|
+
`.`, its full-fallback task ids, the projects and their fallback dependencies,
|
|
221
|
+
and tasks of kind `test`, `typecheck`, `lint`, `build`, or `custom`. The report
|
|
222
|
+
records the importer and manifest checksum, the source workspace with its
|
|
223
|
+
expected and resolved SHA, tool versions and hashed inputs, the Nx projects,
|
|
224
|
+
graph, executors and plugins, per-target audits, dropped fields, and failures.
|
|
225
|
+
|
|
226
|
+
Both files are written to unique temporary siblings first, and no file is put
|
|
227
|
+
in place until every one of them has been written, so a write failure replaces
|
|
228
|
+
nothing. Two named paths cannot be replaced in a single filesystem step: the
|
|
229
|
+
files are then renamed in order, and a rename that fails leaves the outputs
|
|
230
|
+
before it replaced and the rest as they were. The report's `manifestChecksum`
|
|
231
|
+
is the digest of the manifest bytes, so a pair torn that way does not read as a
|
|
232
|
+
matching pair. No temporary file survives either outcome.
|
|
233
|
+
|
|
234
|
+
Failures are thrown as errors and, at the CLI, written to stderr. Notable ones:
|
|
235
|
+
|
|
236
|
+
| Message | When |
|
|
237
|
+
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------ |
|
|
238
|
+
| `Usage: dad-test-nx plan\|run [workspace] …` | No operation, or more than two positionals |
|
|
239
|
+
| `Usage: dad-test-import-nx <nx-workspace-root> --sha <full-git-sha>` | Wrong argument shape; exits `2` |
|
|
240
|
+
| `--all cannot be combined with --base or --head.` | Conflicting scope options |
|
|
241
|
+
| `--head requires --base.` | `--head` alone |
|
|
242
|
+
| `Nx --head planning requires that revision to be the clean checked-out HEAD. …` | `--head` names another revision, or the tree is dirty |
|
|
243
|
+
| `--jobs must be a positive integer.` | A non-positive or non-integer `--jobs` |
|
|
244
|
+
| `--targets requires non-empty exact target names.` | An empty entry in `--targets` |
|
|
245
|
+
| `Refusing Nx import: no locally installed Nx package was found under <path>/node_modules/nx.` | No local Nx install |
|
|
246
|
+
| `Refusing Nx import: source workspace has uncommitted or untracked changes.` | The import workspace is dirty |
|
|
247
|
+
| `Refusing Nx import: expected Git SHA <a> does not match clean HEAD <b>.` | The approved SHA is not what is checked out |
|
|
248
|
+
| `Unsupported Nx graph shape: …` | The graph is not the supported `nx graph --file` shape |
|
|
249
|
+
| `No non-continuous verification targets were registered.` | Nothing in scope could be registered |
|
|
250
|
+
| `No standalone Nx tasks were convertible; see dads.testing.import-report.json.` | Nothing converted; the report is still written |
|
|
251
|
+
| `The Nx adapter needs an ignored scratch directory inside the workspace. …` | No safe ignored scratch location |
|
|
252
|
+
| `The workspace changed during Nx discovery, planning, or execution. …` | Git-visible source moved mid-run |
|
|
253
|
+
|
|
254
|
+
## Daddy issues this prevents
|
|
255
|
+
|
|
256
|
+
A migration that guesses is worse than one that stops: it converts what it
|
|
257
|
+
understood, drops what it did not, and leaves you believing the suite still
|
|
258
|
+
covers you. Everything unconvertible here is written down by name, so the gap
|
|
259
|
+
is a list rather than a surprise.
|
package/package.json
CHANGED
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dads-framework/testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22"
|
|
7
7
|
},
|
|
8
8
|
"bin": {
|
|
9
|
-
"dad-test": "./bin/dad-test.js"
|
|
9
|
+
"dad-test": "./bin/dad-test.js",
|
|
10
|
+
"dad-test-import-nx": "./bin/dad-test-import-nx.js",
|
|
11
|
+
"dad-test-nx": "./bin/dad-test-nx.js"
|
|
10
12
|
},
|
|
11
13
|
"exports": {
|
|
12
14
|
".": {
|
|
13
15
|
"types": "./dist/index.d.ts",
|
|
14
16
|
"default": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./nx": {
|
|
19
|
+
"types": "./dist/nx/index.d.ts",
|
|
20
|
+
"default": "./dist/nx/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./path-aliases": {
|
|
23
|
+
"types": "./dist/path-aliases/index.d.ts",
|
|
24
|
+
"default": "./dist/path-aliases/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./vitest": {
|
|
27
|
+
"types": "./dist/vitest/index.d.ts",
|
|
28
|
+
"default": "./dist/vitest/index.js"
|
|
15
29
|
}
|
|
16
30
|
},
|
|
17
31
|
"files": [
|
|
18
32
|
"bin",
|
|
19
33
|
"dist",
|
|
20
|
-
"README.md"
|
|
34
|
+
"README.md",
|
|
35
|
+
"nx/README.md"
|
|
21
36
|
],
|
|
22
37
|
"scripts": {
|
|
23
38
|
"prepublishOnly": "node ../../../scripts/verify-prepublish.mjs",
|
|
@@ -26,11 +41,11 @@
|
|
|
26
41
|
"typecheck": "tsc -b --pretty false"
|
|
27
42
|
},
|
|
28
43
|
"optionalDependencies": {
|
|
29
|
-
"@dads-framework/testing-native-darwin-arm64": "0.
|
|
30
|
-
"@dads-framework/testing-native-darwin-x64": "0.
|
|
31
|
-
"@dads-framework/testing-native-linux-arm64-gnu": "0.
|
|
32
|
-
"@dads-framework/testing-native-linux-x64-gnu": "0.
|
|
33
|
-
"@dads-framework/testing-native-win32-x64": "0.
|
|
44
|
+
"@dads-framework/testing-native-darwin-arm64": "0.3.0",
|
|
45
|
+
"@dads-framework/testing-native-darwin-x64": "0.3.0",
|
|
46
|
+
"@dads-framework/testing-native-linux-arm64-gnu": "0.3.0",
|
|
47
|
+
"@dads-framework/testing-native-linux-x64-gnu": "0.3.0",
|
|
48
|
+
"@dads-framework/testing-native-win32-x64": "0.3.0"
|
|
34
49
|
},
|
|
35
50
|
"license": "MIT",
|
|
36
51
|
"author": "Bryton Cooper",
|
|
@@ -41,5 +56,17 @@
|
|
|
41
56
|
},
|
|
42
57
|
"publishConfig": {
|
|
43
58
|
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"vite": ">=5"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"vite": {
|
|
65
|
+
"optional": true
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"vite": "^8.0.0",
|
|
70
|
+
"vitest": "~4.1.0"
|
|
44
71
|
}
|
|
45
72
|
}
|