@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.
- package/README.md +111 -18
- package/dist/commands/diagnose.d.ts +15 -0
- package/dist/commands/diagnose.d.ts.map +1 -0
- package/dist/commands/diagnose.js +119 -0
- package/dist/commands/diagnose.js.map +1 -0
- package/dist/commands/plan-run.d.ts.map +1 -1
- package/dist/commands/plan-run.js +11 -1
- package/dist/commands/plan-run.js.map +1 -1
- package/dist/dad-test-cli.d.ts.map +1 -1
- package/dist/dad-test-cli.js +20 -3
- package/dist/dad-test-cli.js.map +1 -1
- package/dist/dst/fault-delivery.d.ts +60 -0
- package/dist/dst/fault-delivery.d.ts.map +1 -0
- package/dist/dst/fault-delivery.js +164 -0
- package/dist/dst/fault-delivery.js.map +1 -0
- package/dist/dst/fault-transactions.d.ts +58 -0
- package/dist/dst/fault-transactions.d.ts.map +1 -0
- package/dist/dst/fault-transactions.js +127 -0
- package/dist/dst/fault-transactions.js.map +1 -0
- package/dist/dst/index.d.ts +7 -0
- package/dist/dst/index.d.ts.map +1 -0
- package/dist/dst/index.js +7 -0
- package/dist/dst/index.js.map +1 -0
- package/dist/dst/prng.d.ts +36 -0
- package/dist/dst/prng.d.ts.map +1 -0
- package/dist/dst/prng.js +98 -0
- package/dist/dst/prng.js.map +1 -0
- package/dist/dst/sim-clock.d.ts +32 -0
- package/dist/dst/sim-clock.d.ts.map +1 -0
- package/dist/dst/sim-clock.js +75 -0
- package/dist/dst/sim-clock.js.map +1 -0
- package/dist/dst/sim-world.d.ts +28 -0
- package/dist/dst/sim-world.d.ts.map +1 -0
- package/dist/dst/sim-world.js +26 -0
- package/dist/dst/sim-world.js.map +1 -0
- package/dist/dst/simulation-runner.d.ts +78 -0
- package/dist/dst/simulation-runner.d.ts.map +1 -0
- package/dist/dst/simulation-runner.js +209 -0
- package/dist/dst/simulation-runner.js.map +1 -0
- package/dist/explain-plan.d.ts +4 -0
- package/dist/explain-plan.d.ts.map +1 -1
- package/dist/explain-plan.js +30 -36
- package/dist/explain-plan.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/init/check-testing-manifest.js +9 -0
- package/dist/init/check-testing-manifest.js.map +1 -1
- package/dist/init/dads-app-discovery.d.ts +24 -0
- package/dist/init/dads-app-discovery.d.ts.map +1 -0
- package/dist/init/dads-app-discovery.js +168 -0
- package/dist/init/dads-app-discovery.js.map +1 -0
- package/dist/init/infer-dads-app.d.ts +11 -0
- package/dist/init/infer-dads-app.d.ts.map +1 -0
- package/dist/init/infer-dads-app.js +228 -0
- package/dist/init/infer-dads-app.js.map +1 -0
- package/dist/init/infer-one-package.d.ts.map +1 -1
- package/dist/init/infer-one-package.js +5 -4
- package/dist/init/infer-one-package.js.map +1 -1
- package/dist/init/init-testing-manifest.d.ts.map +1 -1
- package/dist/init/init-testing-manifest.js +3 -2
- package/dist/init/init-testing-manifest.js.map +1 -1
- package/dist/nx/dads-identifier.d.ts +7 -3
- package/dist/nx/dads-identifier.d.ts.map +1 -1
- package/dist/nx/dads-identifier.js +23 -5
- package/dist/nx/dads-identifier.js.map +1 -1
- package/dist/nx/index.d.ts +5 -1
- package/dist/nx/index.d.ts.map +1 -1
- package/dist/nx/index.js +5 -1
- package/dist/nx/index.js.map +1 -1
- package/dist/nx/nx-eject-targets.d.ts +30 -0
- package/dist/nx/nx-eject-targets.d.ts.map +1 -0
- package/dist/nx/nx-eject-targets.js +283 -0
- package/dist/nx/nx-eject-targets.js.map +1 -0
- package/dist/nx/nx-eject-vitest.d.ts +24 -0
- package/dist/nx/nx-eject-vitest.d.ts.map +1 -0
- package/dist/nx/nx-eject-vitest.js +156 -0
- package/dist/nx/nx-eject-vitest.js.map +1 -0
- package/dist/nx/nx-eject-workspace.d.ts +45 -0
- package/dist/nx/nx-eject-workspace.d.ts.map +1 -0
- package/dist/nx/nx-eject-workspace.js +267 -0
- package/dist/nx/nx-eject-workspace.js.map +1 -0
- package/dist/nx/nx-native-cli.js +88 -8
- package/dist/nx/nx-native-cli.js.map +1 -1
- package/dist/nx/nx-native-inputs.d.ts +9 -2
- package/dist/nx/nx-native-inputs.d.ts.map +1 -1
- package/dist/nx/nx-native-inputs.js +87 -35
- package/dist/nx/nx-native-inputs.js.map +1 -1
- package/dist/nx/nx-native-model.d.ts +3 -2
- package/dist/nx/nx-native-model.d.ts.map +1 -1
- package/dist/nx/nx-native-model.js +117 -28
- package/dist/nx/nx-native-model.js.map +1 -1
- package/dist/nx/nx-native-scope.d.ts +1 -1
- package/dist/nx/nx-native-scope.d.ts.map +1 -1
- package/dist/nx/nx-native-workspace.d.ts +14 -1
- package/dist/nx/nx-native-workspace.d.ts.map +1 -1
- package/dist/nx/nx-native-workspace.js +40 -5
- package/dist/nx/nx-native-workspace.js.map +1 -1
- package/dist/plan-reasons.d.ts.map +1 -1
- package/dist/plan-reasons.js +4 -0
- package/dist/plan-reasons.js.map +1 -1
- package/dist/testing-api.d.ts +78 -0
- package/dist/testing-api.d.ts.map +1 -1
- package/dist/testing-api.js +9 -0
- package/dist/testing-api.js.map +1 -1
- package/dist/testing-manifest-sql.d.ts +24 -0
- package/dist/testing-manifest-sql.d.ts.map +1 -0
- package/dist/testing-manifest-sql.js +104 -0
- package/dist/testing-manifest-sql.js.map +1 -0
- package/dist/testing-manifest.d.ts +12 -0
- package/dist/testing-manifest.d.ts.map +1 -1
- package/dist/testing-manifest.js +74 -3
- package/dist/testing-manifest.js.map +1 -1
- package/dist/testing.tsbuildinfo +1 -1
- package/dst/README.md +75 -0
- package/nx/README.md +78 -39
- package/package.json +11 -6
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inspecting Vite/Vitest configs for Nx eject: detects `nxViteTsPaths()` usage,
|
|
3
|
+
* extracts statically verifiable `setupFiles` for fail-closed Vitest file
|
|
4
|
+
* narrowing, and optionally rewrites `nxViteTsPaths()` to `dadsTsconfigPaths()`.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
const defaultConfigNames = [
|
|
9
|
+
"vitest.config.ts",
|
|
10
|
+
"vitest.config.mts",
|
|
11
|
+
"vitest.config.js",
|
|
12
|
+
"vitest.config.mjs",
|
|
13
|
+
"vite.config.ts",
|
|
14
|
+
"vite.config.mts",
|
|
15
|
+
"vite.config.js",
|
|
16
|
+
"vite.config.mjs",
|
|
17
|
+
];
|
|
18
|
+
const nxViteImportPattern = /^import\s+\{\s*nxViteTsPaths\s*\}\s+from\s+(['"])@nx\/vite\/plugins\/nx-tsconfig-paths\.plugin\1\s*;?\s*$/m;
|
|
19
|
+
const nxViteAnyMentionPattern = /\bnxViteTsPaths\b/;
|
|
20
|
+
const nxVitePlainCallPattern = /\bnxViteTsPaths\s*\(\s*\)/g;
|
|
21
|
+
const nxViteAnyCallPattern = /\bnxViteTsPaths\s*\([^)]*\)/g;
|
|
22
|
+
const setupFilesMentionPattern = /\bsetupFiles\s*:/;
|
|
23
|
+
const setupFilesLiteralArrayPattern = /\bsetupFiles\s*:\s*\[([^\]]*)\]/;
|
|
24
|
+
const setupFilesSingleStringPattern = /\bsetupFiles\s*:\s*(['"])([^'"\n]+)\1/;
|
|
25
|
+
/** Inspects a project's Vite/Vitest config without executing it. */
|
|
26
|
+
export function inspectVitestConfig(workspaceRoot, projectRoot, configuredPath) {
|
|
27
|
+
const configPath = resolveVitestConfigPath(workspaceRoot, projectRoot, configuredPath);
|
|
28
|
+
if (configPath === undefined) {
|
|
29
|
+
return { usesNxViteTsPaths: false, setupFiles: [], dynamicSetupFiles: false };
|
|
30
|
+
}
|
|
31
|
+
const absolute = path.join(workspaceRoot, configPath);
|
|
32
|
+
if (!existsSync(absolute)) {
|
|
33
|
+
return { configPath, usesNxViteTsPaths: false, setupFiles: [], dynamicSetupFiles: true };
|
|
34
|
+
}
|
|
35
|
+
const source = readFileSync(absolute, "utf8");
|
|
36
|
+
const usesNxViteTsPaths = nxViteAnyMentionPattern.test(source);
|
|
37
|
+
const setup = extractStaticSetupFiles(source, projectRoot);
|
|
38
|
+
return {
|
|
39
|
+
configPath,
|
|
40
|
+
usesNxViteTsPaths,
|
|
41
|
+
setupFiles: setup.paths,
|
|
42
|
+
dynamicSetupFiles: setup.dynamic,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** Resolves the workspace root tsconfig file that `dadsTsconfigPaths` should read. */
|
|
46
|
+
export function detectWorkspaceTsconfig(workspaceRoot) {
|
|
47
|
+
if (existsSync(path.join(workspaceRoot, "tsconfig.base.json")))
|
|
48
|
+
return "tsconfig.base.json";
|
|
49
|
+
return "tsconfig.json";
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Rewrites clean `nxViteTsPaths()` imports and zero-argument calls to
|
|
53
|
+
* `dadsTsconfigPaths({ tsconfig: fileURLToPath(new URL(..., import.meta.url)) })`.
|
|
54
|
+
* Any complex invocation (custom arguments, aliased imports) is left untouched
|
|
55
|
+
* and flagged for manual review.
|
|
56
|
+
*/
|
|
57
|
+
export function rewriteNxViteTsPaths(workspaceRoot, configRelativePath, workspaceTsconfig) {
|
|
58
|
+
const absolute = path.join(workspaceRoot, configRelativePath);
|
|
59
|
+
const source = readFileSync(absolute, "utf8");
|
|
60
|
+
if (!nxViteAnyMentionPattern.test(source)) {
|
|
61
|
+
return { configPath: configRelativePath, status: "already-clean", detail: "No nxViteTsPaths usage found." };
|
|
62
|
+
}
|
|
63
|
+
if (!nxViteImportPattern.test(source) || hasNonTrivialNxViteCall(source)) {
|
|
64
|
+
return {
|
|
65
|
+
configPath: configRelativePath,
|
|
66
|
+
status: "manual-review-needed",
|
|
67
|
+
detail: "Custom nxViteTsPaths import or options detected; replace with dadsTsconfigPaths manually.",
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const rewritten = applyNxViteReplacement(source, configRelativePath, workspaceTsconfig);
|
|
71
|
+
writeFileSync(absolute, rewritten, "utf8");
|
|
72
|
+
return {
|
|
73
|
+
configPath: configRelativePath,
|
|
74
|
+
status: "rewritten",
|
|
75
|
+
detail: `Replaced nxViteTsPaths() with dadsTsconfigPaths({ tsconfig: ${workspaceTsconfig} }).`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function resolveVitestConfigPath(workspaceRoot, projectRoot, configuredPath) {
|
|
79
|
+
if (configuredPath !== undefined && configuredPath.trim() !== "") {
|
|
80
|
+
const cleaned = configuredPath.replace(/^\{projectRoot\}\/?/, "").replace(/^\{workspaceRoot\}\/?/, "");
|
|
81
|
+
const candidate = configuredPath.startsWith("{workspaceRoot}")
|
|
82
|
+
? cleaned
|
|
83
|
+
: projectRoot === "."
|
|
84
|
+
? cleaned
|
|
85
|
+
: path.posix.join(projectRoot, cleaned);
|
|
86
|
+
return normalizePosix(candidate);
|
|
87
|
+
}
|
|
88
|
+
for (const name of defaultConfigNames) {
|
|
89
|
+
const relative = projectRoot === "." ? name : path.posix.join(projectRoot, name);
|
|
90
|
+
if (existsSync(path.join(workspaceRoot, relative)))
|
|
91
|
+
return relative;
|
|
92
|
+
}
|
|
93
|
+
return undefined;
|
|
94
|
+
}
|
|
95
|
+
function extractStaticSetupFiles(source, projectRoot) {
|
|
96
|
+
if (!setupFilesMentionPattern.test(source))
|
|
97
|
+
return { paths: [], dynamic: false };
|
|
98
|
+
const single = setupFilesSingleStringPattern.exec(source);
|
|
99
|
+
if (single?.[2] !== undefined) {
|
|
100
|
+
const resolved = resolveSetupPath(projectRoot, single[2]);
|
|
101
|
+
return resolved === undefined ? { paths: [], dynamic: true } : { paths: [resolved], dynamic: false };
|
|
102
|
+
}
|
|
103
|
+
const arrayMatch = setupFilesLiteralArrayPattern.exec(source);
|
|
104
|
+
if (arrayMatch?.[1] === undefined)
|
|
105
|
+
return { paths: [], dynamic: true };
|
|
106
|
+
return parseSetupArrayBody(arrayMatch[1], projectRoot);
|
|
107
|
+
}
|
|
108
|
+
function parseSetupArrayBody(body, projectRoot) {
|
|
109
|
+
const trimmed = body.trim();
|
|
110
|
+
if (trimmed === "")
|
|
111
|
+
return { paths: [], dynamic: false };
|
|
112
|
+
const parts = trimmed
|
|
113
|
+
.split(",")
|
|
114
|
+
.map((item) => item.trim())
|
|
115
|
+
.filter(Boolean);
|
|
116
|
+
const paths = [];
|
|
117
|
+
for (const part of parts) {
|
|
118
|
+
const match = /^(['"])([^'"\n]+)\1$/.exec(part);
|
|
119
|
+
if (match?.[2] === undefined)
|
|
120
|
+
return { paths: [], dynamic: true };
|
|
121
|
+
const resolved = resolveSetupPath(projectRoot, match[2]);
|
|
122
|
+
if (resolved === undefined)
|
|
123
|
+
return { paths: [], dynamic: true };
|
|
124
|
+
paths.push(resolved);
|
|
125
|
+
}
|
|
126
|
+
return { paths: [...new Set(paths)].sort(), dynamic: false };
|
|
127
|
+
}
|
|
128
|
+
function resolveSetupPath(projectRoot, entry) {
|
|
129
|
+
if (entry.startsWith("/") || entry.includes("${") || entry.includes("*"))
|
|
130
|
+
return undefined;
|
|
131
|
+
const joined = projectRoot === "." ? entry : path.posix.join(projectRoot, entry);
|
|
132
|
+
const normalized = normalizePosix(joined);
|
|
133
|
+
if (normalized === ".." || normalized.startsWith("../"))
|
|
134
|
+
return undefined;
|
|
135
|
+
return normalized;
|
|
136
|
+
}
|
|
137
|
+
function hasNonTrivialNxViteCall(source) {
|
|
138
|
+
const allCalls = source.match(nxViteAnyCallPattern) ?? [];
|
|
139
|
+
const plainCalls = source.match(nxVitePlainCallPattern) ?? [];
|
|
140
|
+
return allCalls.length === 0 || allCalls.length !== plainCalls.length;
|
|
141
|
+
}
|
|
142
|
+
function applyNxViteReplacement(source, configRelativePath, workspaceTsconfig) {
|
|
143
|
+
const configDir = path.posix.dirname(configRelativePath);
|
|
144
|
+
const relativeTsconfig = path.posix.relative(configDir, workspaceTsconfig);
|
|
145
|
+
const specifier = relativeTsconfig.startsWith(".") ? relativeTsconfig : `./${relativeTsconfig}`;
|
|
146
|
+
const hasFileUrlImport = /\bfileURLToPath\b/.test(source);
|
|
147
|
+
const importReplacement = hasFileUrlImport
|
|
148
|
+
? 'import { dadsTsconfigPaths } from "@dads-framework/testing/vitest";'
|
|
149
|
+
: 'import { fileURLToPath } from "node:url";\nimport { dadsTsconfigPaths } from "@dads-framework/testing/vitest";';
|
|
150
|
+
const callReplacement = `dadsTsconfigPaths({ tsconfig: fileURLToPath(new URL(${JSON.stringify(specifier)}, import.meta.url)) })`;
|
|
151
|
+
return source.replace(nxViteImportPattern, importReplacement).replace(nxVitePlainCallPattern, callReplacement);
|
|
152
|
+
}
|
|
153
|
+
function normalizePosix(value) {
|
|
154
|
+
return path.posix.normalize(value.replaceAll("\\", "/")).replace(/^\.\//, "");
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=nx-eject-vitest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-eject-vitest.js","sourceRoot":"","sources":["../../src/nx/nx-eject-vitest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,kBAAkB,GAAG;IACzB,kBAAkB;IAClB,mBAAmB;IACnB,kBAAkB;IAClB,mBAAmB;IACnB,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,iBAAiB;CAClB,CAAC;AAEF,MAAM,mBAAmB,GACvB,4GAA4G,CAAC;AAC/G,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AACpD,MAAM,sBAAsB,GAAG,4BAA4B,CAAC;AAC5D,MAAM,oBAAoB,GAAG,8BAA8B,CAAC;AAC5D,MAAM,wBAAwB,GAAG,kBAAkB,CAAC;AACpD,MAAM,6BAA6B,GAAG,iCAAiC,CAAC;AACxE,MAAM,6BAA6B,GAAG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,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1D,MAAM,iBAAiB,GAAG,gBAAgB;QACxC,CAAC,CAAC,qEAAqE;QACvE,CAAC,CAAC,gHAAgH,CAAC;IACrH,MAAM,eAAe,GAAG,uDAAuD,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,wBAAwB,CAAC;IACjI,OAAO,MAAM,CAAC,OAAO,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;AACjH,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type TestingManifest } from "../testing-manifest.js";
|
|
2
|
+
import { type EjectedTargetAudit } from "./nx-eject-targets.js";
|
|
3
|
+
import { type RewriteNxViteResult } from "./nx-eject-vitest.js";
|
|
4
|
+
export declare const ejectReportFileName = "dads.testing.eject-report.json";
|
|
5
|
+
export type NativeNxEjectOptions = {
|
|
6
|
+
readonly workspaceRoot: string;
|
|
7
|
+
/** Exact Nx target names; omitted selects verification target families. */
|
|
8
|
+
readonly targetNames?: readonly string[];
|
|
9
|
+
/** Write `dads.testing.json` and `dads.testing.eject-report.json` (default: false = dry-run preview). */
|
|
10
|
+
readonly write?: boolean;
|
|
11
|
+
/** Allow overwriting an existing `dads.testing.json` when `write` is true. */
|
|
12
|
+
readonly force?: boolean;
|
|
13
|
+
/** Rewrite clean `nxViteTsPaths()` usages to `dadsTsconfigPaths()` when `write` is true. */
|
|
14
|
+
readonly replaceNxViteTsPaths?: boolean;
|
|
15
|
+
/** Explicit native binary path used to validate the generated manifest. */
|
|
16
|
+
readonly nativeBinary?: string;
|
|
17
|
+
};
|
|
18
|
+
export type NativeNxEjectReport = {
|
|
19
|
+
readonly schemaVersion: 1;
|
|
20
|
+
readonly dryRun: boolean;
|
|
21
|
+
readonly summary: {
|
|
22
|
+
readonly projects: number;
|
|
23
|
+
readonly targets: number;
|
|
24
|
+
readonly converted: number;
|
|
25
|
+
readonly opaque: number;
|
|
26
|
+
readonly excluded: number;
|
|
27
|
+
readonly vitestNarrowed: number;
|
|
28
|
+
readonly nxViteConfigsFound: number;
|
|
29
|
+
readonly nxViteConfigsRewritten: number;
|
|
30
|
+
};
|
|
31
|
+
readonly tasks: readonly EjectedTargetAudit[];
|
|
32
|
+
readonly nxViteConfigs: readonly RewriteNxViteResult[];
|
|
33
|
+
readonly nxPackagesDetected: readonly string[];
|
|
34
|
+
readonly uninstallCommands: readonly string[];
|
|
35
|
+
};
|
|
36
|
+
export type NativeNxEjectResult = {
|
|
37
|
+
readonly manifest: TestingManifest;
|
|
38
|
+
readonly report: NativeNxEjectReport;
|
|
39
|
+
readonly written: boolean;
|
|
40
|
+
readonly manifestPath: string;
|
|
41
|
+
readonly reportPath: string;
|
|
42
|
+
};
|
|
43
|
+
/** Discovers the live Nx graph and builds (or writes) a standalone zero-Nx `dads.testing.json`. */
|
|
44
|
+
export declare function ejectNativeNxTesting(options: NativeNxEjectOptions): Promise<NativeNxEjectResult>;
|
|
45
|
+
//# sourceMappingURL=nx-eject-workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-eject-workspace.d.ts","sourceRoot":"","sources":["../../src/nx/nx-eject-workspace.ts"],"names":[],"mappings":"AAaA,OAAO,EAGL,KAAK,eAAe,EAErB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAe,KAAK,kBAAkB,EAA4B,MAAM,uBAAuB,CAAC;AACvG,OAAO,EAAiD,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAQ/G,eAAO,MAAM,mBAAmB,mCAAmC,CAAC;AAEpE,MAAM,MAAM,o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,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAAC;AAOF,mGAAmG;AACnG,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAwBtG"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-command Nx eject: turns a live Nx project graph (including plugin-inferred
|
|
3
|
+
* Vitest, ESLint, TypeScript, and `nx:run-commands` targets) into a standalone,
|
|
4
|
+
* zero-Nx `dads.testing.json` with symbol-level reachability, Vitest file
|
|
5
|
+
* narrowing, pure-check `dependsOn` wiring, and optional `nxViteTsPaths()` ->
|
|
6
|
+
* `dadsTsconfigPaths()` codemodding.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
9
|
+
import { promises as fs } from "node:fs";
|
|
10
|
+
import path from "node:path";
|
|
11
|
+
import { checkTestingManifest } from "../init/check-testing-manifest.js";
|
|
12
|
+
import { isRecord } from "../parse-guards.js";
|
|
13
|
+
import { planTesting } from "../testing-api.js";
|
|
14
|
+
import { defaultTestingManifestFileName, serializeTestingManifest, } from "../testing-manifest.js";
|
|
15
|
+
import { writeFilesAtomically } from "../write-files-atomically.js";
|
|
16
|
+
import { dadsIdentifier } from "./dads-identifier.js";
|
|
17
|
+
import { ejectTarget } from "./nx-eject-targets.js";
|
|
18
|
+
import { detectWorkspaceTsconfig, rewriteNxViteTsPaths } from "./nx-eject-vitest.js";
|
|
19
|
+
import { parseNxConfiguration, resolveLocalNxCli } from "./nx-installation.js";
|
|
20
|
+
import { readNativeProjects } from "./nx-native-graph.js";
|
|
21
|
+
import { reachesTask } from "./nx-native-model.js";
|
|
22
|
+
import { nativeNxProcess } from "./nx-native-process.js";
|
|
23
|
+
import { createNativeNxScratch } from "./nx-native-scratch.js";
|
|
24
|
+
export const ejectReportFileName = "dads.testing.eject-report.json";
|
|
25
|
+
/** Discovers the live Nx graph and builds (or writes) a standalone zero-Nx `dads.testing.json`. */
|
|
26
|
+
export async function ejectNativeNxTesting(options) {
|
|
27
|
+
const workspaceRoot = await fs.realpath(path.resolve(options.workspaceRoot));
|
|
28
|
+
const manifestPath = path.join(workspaceRoot, defaultTestingManifestFileName);
|
|
29
|
+
const reportPath = path.join(workspaceRoot, ejectReportFileName);
|
|
30
|
+
const write = options.write === true;
|
|
31
|
+
if (write && existsSync(manifestPath) && options.force !== true) {
|
|
32
|
+
throw new Error(`Refusing to overwrite existing ${defaultTestingManifestFileName}; pass --force to replace it.`);
|
|
33
|
+
}
|
|
34
|
+
const { graph, nxConfiguration } = await readLiveNxGraph(workspaceRoot);
|
|
35
|
+
const projects = readNativeProjects(graph);
|
|
36
|
+
const built = convertWorkspaceTargets(workspaceRoot, projects, nxConfiguration, options.targetNames);
|
|
37
|
+
const manifest = assembleManifest(projects, built.tasks);
|
|
38
|
+
assertStructurallyValid(manifest);
|
|
39
|
+
const nxViteConfigs = handleNxViteConfigs(workspaceRoot, built.nxViteConfigPaths, write && options.replaceNxViteTsPaths === true);
|
|
40
|
+
const nxPackagesDetected = detectNxPackages(workspaceRoot);
|
|
41
|
+
const report = buildEjectReport(projects.size, built, nxViteConfigs, nxPackagesDetected, !write);
|
|
42
|
+
if (write) {
|
|
43
|
+
await writeValidatedOutputs(workspaceRoot, manifestPath, reportPath, manifest, report, options.nativeBinary);
|
|
44
|
+
}
|
|
45
|
+
return { manifest, report, written: write, manifestPath, reportPath };
|
|
46
|
+
}
|
|
47
|
+
async function readLiveNxGraph(workspaceRoot) {
|
|
48
|
+
const nxCli = await resolveLocalNxCli(workspaceRoot);
|
|
49
|
+
const scratch = await createNativeNxScratch(workspaceRoot);
|
|
50
|
+
try {
|
|
51
|
+
const graphPath = path.join(scratch, "project-graph.json");
|
|
52
|
+
const env = (await isNxDirIgnored(workspaceRoot))
|
|
53
|
+
? {}
|
|
54
|
+
: {
|
|
55
|
+
NX_WORKSPACE_DATA_DIRECTORY: path.join(scratch, "workspace-data"),
|
|
56
|
+
NX_CACHE_DIRECTORY: path.join(scratch, "cache"),
|
|
57
|
+
};
|
|
58
|
+
await nativeNxProcess(process.execPath, [nxCli, "graph", `--file=${graphPath}`, "--open=false"], workspaceRoot, env);
|
|
59
|
+
const graph = JSON.parse(await fs.readFile(graphPath, "utf8"));
|
|
60
|
+
const nxConfiguration = parseNxConfiguration(await fs.readFile(path.join(workspaceRoot, "nx.json"), "utf8"), "nx.json");
|
|
61
|
+
return { graph, nxConfiguration };
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
await fs.rm(scratch, { recursive: true, force: true });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function isNxDirIgnored(workspaceRoot) {
|
|
68
|
+
try {
|
|
69
|
+
await nativeNxProcess("git", ["check-ignore", "--quiet", "--", ".nx/"], workspaceRoot);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function convertWorkspaceTargets(workspaceRoot, projects, nxConfiguration, targetNames) {
|
|
77
|
+
const entries = new Map();
|
|
78
|
+
const auditsByKey = new Map();
|
|
79
|
+
const nxViteConfigPaths = new Set();
|
|
80
|
+
const pendingPrereqs = [];
|
|
81
|
+
for (const project of projects.values()) {
|
|
82
|
+
for (const [name, value] of Object.entries(project.targets).sort(([l], [r]) => l.localeCompare(r))) {
|
|
83
|
+
const key = `${project.name}:${name}`;
|
|
84
|
+
if (!isRecord(value))
|
|
85
|
+
continue;
|
|
86
|
+
const chosen = targetNames === undefined ? isVerificationTarget(name) : targetNames.includes(name);
|
|
87
|
+
if (value["continuous"] === true || !chosen) {
|
|
88
|
+
auditsByKey.set(key, {
|
|
89
|
+
project: project.name,
|
|
90
|
+
target: name,
|
|
91
|
+
classification: "excluded",
|
|
92
|
+
reason: value["continuous"] === true ? "Continuous targets are excluded." : "Outside requested verification scope.",
|
|
93
|
+
});
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const result = ejectTarget({ workspaceRoot, project, name, target: value, projects, nxConfiguration });
|
|
97
|
+
recordEjected(key, result, entries, auditsByKey, nxViteConfigPaths, pendingPrereqs);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
ejectCheckPrerequisites(workspaceRoot, projects, nxConfiguration, entries, auditsByKey, nxViteConfigPaths, pendingPrereqs);
|
|
101
|
+
return {
|
|
102
|
+
tasks: wireDependencies(entries),
|
|
103
|
+
audits: [...auditsByKey.values()],
|
|
104
|
+
nxViteConfigPaths: [...nxViteConfigPaths].sort(),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function ejectCheckPrerequisites(workspaceRoot, projects, nxConfiguration, entries, auditsByKey, nxViteConfigPaths, pendingPrereqs) {
|
|
108
|
+
for (let index = 0; index < pendingPrereqs.length; index += 1) {
|
|
109
|
+
const prereq = pendingPrereqs[index];
|
|
110
|
+
if (prereq === undefined)
|
|
111
|
+
continue;
|
|
112
|
+
const id = `${dadsIdentifier(prereq.project.name)}:${dadsIdentifier(prereq.name)}`;
|
|
113
|
+
if (entries.has(id))
|
|
114
|
+
continue;
|
|
115
|
+
const raw = prereq.project.targets[prereq.name];
|
|
116
|
+
if (!isRecord(raw) || raw["continuous"] === true)
|
|
117
|
+
continue;
|
|
118
|
+
const result = ejectTarget({
|
|
119
|
+
workspaceRoot,
|
|
120
|
+
project: prereq.project,
|
|
121
|
+
name: prereq.name,
|
|
122
|
+
target: raw,
|
|
123
|
+
projects,
|
|
124
|
+
nxConfiguration,
|
|
125
|
+
});
|
|
126
|
+
recordEjected(`${prereq.project.name}:${prereq.name}`, result, entries, auditsByKey, nxViteConfigPaths, pendingPrereqs);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function recordEjected(key, result, entries, auditsByKey, nxViteConfigPaths, pendingPrereqs) {
|
|
130
|
+
auditsByKey.set(key, result.audit);
|
|
131
|
+
if (result.nxViteConfigPath !== undefined)
|
|
132
|
+
nxViteConfigPaths.add(result.nxViteConfigPath);
|
|
133
|
+
if (result.task !== undefined) {
|
|
134
|
+
entries.set(result.task.id, { task: result.task, checkPrerequisites: result.checkPrerequisites });
|
|
135
|
+
pendingPrereqs.push(...result.checkPrerequisites);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function wireDependencies(entries) {
|
|
139
|
+
const edges = new Map();
|
|
140
|
+
const tasks = [];
|
|
141
|
+
for (const entry of entries.values()) {
|
|
142
|
+
const dependsOn = [];
|
|
143
|
+
for (const prereq of entry.checkPrerequisites) {
|
|
144
|
+
const targetId = `${dadsIdentifier(prereq.project.name)}:${dadsIdentifier(prereq.name)}`;
|
|
145
|
+
if (targetId === entry.task.id || !entries.has(targetId) || reachesTask(targetId, entry.task.id, edges))
|
|
146
|
+
continue;
|
|
147
|
+
if (!dependsOn.includes(targetId))
|
|
148
|
+
dependsOn.push(targetId);
|
|
149
|
+
}
|
|
150
|
+
dependsOn.sort();
|
|
151
|
+
edges.set(entry.task.id, dependsOn);
|
|
152
|
+
tasks.push({ ...entry.task, dependsOn });
|
|
153
|
+
}
|
|
154
|
+
return tasks.sort((left, right) => left.id.localeCompare(right.id));
|
|
155
|
+
}
|
|
156
|
+
function assembleManifest(projects, tasks) {
|
|
157
|
+
if (tasks.length === 0) {
|
|
158
|
+
throw new Error("No Nx targets could be ejected to standalone Dads tasks.");
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
schemaVersion: 1,
|
|
162
|
+
workspace: {
|
|
163
|
+
root: ".",
|
|
164
|
+
fullFallback: { taskIds: tasks.map((task) => task.id).sort() },
|
|
165
|
+
},
|
|
166
|
+
projects: [...projects.values()]
|
|
167
|
+
.map((project) => ({
|
|
168
|
+
id: dadsIdentifier(project.name),
|
|
169
|
+
root: project.root,
|
|
170
|
+
fallbackDependencies: project.dependencies.map(dadsIdentifier).sort(),
|
|
171
|
+
}))
|
|
172
|
+
.sort((left, right) => left.id.localeCompare(right.id)),
|
|
173
|
+
tasks,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function assertStructurallyValid(manifest) {
|
|
177
|
+
const issues = checkTestingManifest(manifest);
|
|
178
|
+
if (issues.length > 0) {
|
|
179
|
+
throw new Error(`Ejected manifest failed structural validation: ${issues.join(" ")}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function handleNxViteConfigs(workspaceRoot, configPaths, applyRewrite) {
|
|
183
|
+
const workspaceTsconfig = detectWorkspaceTsconfig(workspaceRoot);
|
|
184
|
+
return configPaths.map((configPath) => applyRewrite
|
|
185
|
+
? rewriteNxViteTsPaths(workspaceRoot, configPath, workspaceTsconfig)
|
|
186
|
+
: {
|
|
187
|
+
configPath,
|
|
188
|
+
status: "manual-review-needed",
|
|
189
|
+
detail: "Uses nxViteTsPaths(); re-run with --write --replace-nx-vite-paths to swap to dadsTsconfigPaths().",
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
function detectNxPackages(workspaceRoot) {
|
|
193
|
+
const parsed = readWorkspaceManifestJson(workspaceRoot);
|
|
194
|
+
if (parsed === undefined)
|
|
195
|
+
return [];
|
|
196
|
+
const names = new Set();
|
|
197
|
+
for (const field of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
198
|
+
collectNxNames(parsed[field], names);
|
|
199
|
+
}
|
|
200
|
+
return [...names].sort();
|
|
201
|
+
}
|
|
202
|
+
function readWorkspaceManifestJson(workspaceRoot) {
|
|
203
|
+
const packageJsonPath = path.join(workspaceRoot, "package.json");
|
|
204
|
+
if (!existsSync(packageJsonPath))
|
|
205
|
+
return undefined;
|
|
206
|
+
try {
|
|
207
|
+
const parsed = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
208
|
+
return isRecord(parsed) ? parsed : undefined;
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function collectNxNames(section, names) {
|
|
215
|
+
if (!isRecord(section))
|
|
216
|
+
return;
|
|
217
|
+
for (const name of Object.keys(section)) {
|
|
218
|
+
if (name === "nx" || name.startsWith("@nx/"))
|
|
219
|
+
names.add(name);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function buildEjectReport(projectCount, built, nxViteConfigs, nxPackagesDetected, dryRun) {
|
|
223
|
+
const uninstallCommands = [
|
|
224
|
+
"npx dad-test plan --base origin/main",
|
|
225
|
+
"npx dad-test run --base origin/main --cache",
|
|
226
|
+
"rm -rf nx.json .nx",
|
|
227
|
+
...(nxPackagesDetected.length > 0 ? [`npm uninstall ${nxPackagesDetected.join(" ")}`] : []),
|
|
228
|
+
];
|
|
229
|
+
return {
|
|
230
|
+
schemaVersion: 1,
|
|
231
|
+
dryRun,
|
|
232
|
+
summary: {
|
|
233
|
+
projects: projectCount,
|
|
234
|
+
targets: built.audits.length,
|
|
235
|
+
converted: built.tasks.length,
|
|
236
|
+
opaque: built.audits.filter((a) => a.classification === "opaque").length,
|
|
237
|
+
excluded: built.audits.filter((a) => a.classification === "excluded").length,
|
|
238
|
+
vitestNarrowed: built.tasks.filter((t) => t.execution.fileNarrowing !== undefined).length,
|
|
239
|
+
nxViteConfigsFound: nxViteConfigs.length,
|
|
240
|
+
nxViteConfigsRewritten: nxViteConfigs.filter((c) => c.status === "rewritten").length,
|
|
241
|
+
},
|
|
242
|
+
tasks: built.audits,
|
|
243
|
+
nxViteConfigs,
|
|
244
|
+
nxPackagesDetected,
|
|
245
|
+
uninstallCommands,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
async function writeValidatedOutputs(workspaceRoot, manifestPath, reportPath, manifest, report, nativeBinary) {
|
|
249
|
+
const manifestText = serializeTestingManifest(manifest);
|
|
250
|
+
writeFilesAtomically([
|
|
251
|
+
{ path: manifestPath, contents: manifestText },
|
|
252
|
+
{ path: reportPath, contents: `${JSON.stringify(report, null, 2)}\n` },
|
|
253
|
+
]);
|
|
254
|
+
if (nativeBinary !== undefined) {
|
|
255
|
+
await planTesting({
|
|
256
|
+
workspaceRoot,
|
|
257
|
+
manifestPath: defaultTestingManifestFileName,
|
|
258
|
+
all: true,
|
|
259
|
+
taskIds: [],
|
|
260
|
+
nativeBinary,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function isVerificationTarget(name) {
|
|
265
|
+
return /^(test|typecheck|lint|build)$/.test(name) || /^(test:|typecheck[:-]|lint[:-])/.test(name);
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=nx-eject-workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nx-eject-workspace.js","sourceRoot":"","sources":["../../src/nx/nx-eject-workspace.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EACL,8BAA8B,EAC9B,wBAAwB,GAGzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAqD,MAAM,uBAAuB,CAAC;AACvG,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAA4B,MAAM,sBAAsB,CAAC;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b,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAY;IACxC,OAAO,+BAA+B,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,iCAAiC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpG,CAAC"}
|
package/dist/nx/nx-native-cli.js
CHANGED
|
@@ -1,14 +1,59 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
|
-
import {
|
|
2
|
+
import { renderDiagnosis } from "../commands/diagnose.js";
|
|
3
|
+
import { ejectNativeNxTesting } from "./nx-eject-workspace.js";
|
|
4
|
+
import { diagnoseNativeNxTesting, planNativeNxTesting, runNativeNxTesting, } from "./nx-native-workspace.js";
|
|
5
|
+
const usageText = [
|
|
6
|
+
"Usage: dad-test-nx <plan|run|diagnose|eject> [workspace] [options]",
|
|
7
|
+
"",
|
|
8
|
+
"Commands:",
|
|
9
|
+
" plan [workspace] Select affected Nx targets using Oxc symbol-level reachability",
|
|
10
|
+
" run [workspace] Execute selected Nx targets through Nx",
|
|
11
|
+
" diagnose [workspace] Inspect widening culprits, coupling hotspots, and fallback traps",
|
|
12
|
+
" eject [workspace] Generate a standalone zero-Nx dads.testing.json (dry-run unless --write)",
|
|
13
|
+
"",
|
|
14
|
+
"Options:",
|
|
15
|
+
" --base <ref> Compare working tree (or --head) against a Git base ref",
|
|
16
|
+
" --head <ref> Compare --base..<ref> (must match clean checked-out HEAD)",
|
|
17
|
+
" --targets <a,b> Comma-separated exact Nx target names",
|
|
18
|
+
" --all Select every registered verification target",
|
|
19
|
+
" --jobs <n> Maximum concurrent tasks during run",
|
|
20
|
+
" --write Write dads.testing.json and eject report (eject only)",
|
|
21
|
+
" --force Overwrite existing dads.testing.json (eject --write)",
|
|
22
|
+
" --replace-nx-vite-paths Swap nxViteTsPaths() to dadsTsconfigPaths() (eject --write)",
|
|
23
|
+
" --json Emit machine-readable JSON output",
|
|
24
|
+
" -h, --help Show this help message",
|
|
25
|
+
].join("\n");
|
|
3
26
|
async function main() {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
27
|
+
const invocation = readInvocation();
|
|
28
|
+
if (invocation.kind === "help") {
|
|
29
|
+
process.stdout.write(`${usageText}\n`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (invocation.kind === "eject") {
|
|
33
|
+
const result = await ejectNativeNxTesting(invocation.options);
|
|
34
|
+
process.stdout.write(invocation.json ? `${JSON.stringify(result)}\n` : renderEjectSummary(result));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (invocation.kind === "diagnose") {
|
|
38
|
+
await runDiagnoseCli(invocation.request, invocation.json);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const invoke = invocation.kind === "run" ? runNativeNxTesting : planNativeNxTesting;
|
|
42
|
+
const result = await invoke(invocation.request);
|
|
43
|
+
process.stdout.write(invocation.json
|
|
8
44
|
? `${JSON.stringify(result)}\n`
|
|
9
45
|
: `${String(result.coverage.registered)} verification targets registered; ${String(result.coverage.excluded)} targets excluded.\n${String(result.plan.counts.run)} selected, ${String(result.plan.counts.skipProvenUnaffected)} proven unaffected. Nx owns prerequisite execution; see --json for coverage reasons.\n`);
|
|
10
46
|
process.exitCode = result.run?.exitCode ?? 0;
|
|
11
47
|
}
|
|
48
|
+
async function runDiagnoseCli(request, json) {
|
|
49
|
+
const result = await diagnoseNativeNxTesting({
|
|
50
|
+
workspaceRoot: request.workspaceRoot,
|
|
51
|
+
...(request.targetNames === undefined ? {} : { targetNames: request.targetNames }),
|
|
52
|
+
});
|
|
53
|
+
process.stdout.write(json
|
|
54
|
+
? `${JSON.stringify(result)}\n`
|
|
55
|
+
: `${String(result.coverage.registered)} verification targets registered; ${String(result.coverage.excluded)} targets excluded.\n${renderDiagnosis(result.diagnose)}`);
|
|
56
|
+
}
|
|
12
57
|
function readInvocation() {
|
|
13
58
|
const { values, positionals } = parseArgs({
|
|
14
59
|
allowPositionals: true,
|
|
@@ -18,19 +63,54 @@ function readInvocation() {
|
|
|
18
63
|
targets: { type: "string" },
|
|
19
64
|
jobs: { type: "string" },
|
|
20
65
|
all: { type: "boolean" },
|
|
66
|
+
write: { type: "boolean" },
|
|
67
|
+
force: { type: "boolean" },
|
|
68
|
+
"replace-nx-vite-paths": { type: "boolean" },
|
|
21
69
|
json: { type: "boolean" },
|
|
70
|
+
help: { type: "boolean", short: "h" },
|
|
22
71
|
},
|
|
23
72
|
});
|
|
24
73
|
const [operation, workspaceRoot = process.cwd()] = positionals;
|
|
25
|
-
if (
|
|
26
|
-
|
|
74
|
+
if (values.help === true || operation === "help") {
|
|
75
|
+
return { kind: "help" };
|
|
76
|
+
}
|
|
77
|
+
if (operation === "eject" && positionals.length <= 2) {
|
|
78
|
+
return readEjectInvocation(workspaceRoot, values);
|
|
79
|
+
}
|
|
80
|
+
if ((operation !== "plan" && operation !== "run" && operation !== "diagnose") || positionals.length > 2) {
|
|
81
|
+
throw new Error("Usage: dad-test-nx plan|run|diagnose|eject [workspace] [--base ref] [--head ref] [--targets test,lint] [--all] [--jobs n] [--write] [--replace-nx-vite-paths] [--json]");
|
|
27
82
|
}
|
|
28
83
|
return {
|
|
29
|
-
operation,
|
|
84
|
+
kind: operation,
|
|
30
85
|
request: readOptions(workspaceRoot, values),
|
|
31
86
|
json: values.json === true,
|
|
32
87
|
};
|
|
33
88
|
}
|
|
89
|
+
function readEjectInvocation(workspaceRoot, values) {
|
|
90
|
+
const targetNames = readTargets(values.targets);
|
|
91
|
+
return {
|
|
92
|
+
kind: "eject",
|
|
93
|
+
options: {
|
|
94
|
+
workspaceRoot,
|
|
95
|
+
...(targetNames === undefined ? {} : { targetNames }),
|
|
96
|
+
write: values.write === true,
|
|
97
|
+
force: values.force === true,
|
|
98
|
+
replaceNxViteTsPaths: values["replace-nx-vite-paths"] === true,
|
|
99
|
+
},
|
|
100
|
+
json: values.json === true,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function renderEjectSummary(result) {
|
|
104
|
+
const { summary, uninstallCommands } = result.report;
|
|
105
|
+
const header = result.written
|
|
106
|
+
? `Ejected ${String(summary.converted)} standalone task(s) to ${result.manifestPath} (${String(summary.vitestNarrowed)} with Vitest fileNarrowing, ${String(summary.opaque)} opaque, ${String(summary.excluded)} excluded).`
|
|
107
|
+
: `Dry-run: ${String(summary.converted)} task(s) ready to eject (${String(summary.vitestNarrowed)} with Vitest fileNarrowing, ${String(summary.opaque)} opaque, ${String(summary.excluded)} excluded). Re-run with --write to generate dads.testing.json.`;
|
|
108
|
+
const viteLine = summary.nxViteConfigsFound > 0
|
|
109
|
+
? `nxViteTsPaths configs: ${String(summary.nxViteConfigsFound)} found, ${String(summary.nxViteConfigsRewritten)} rewritten.${summary.nxViteConfigsRewritten < summary.nxViteConfigsFound ? " Pass --write --replace-nx-vite-paths to swap to dadsTsconfigPaths()." : ""}`
|
|
110
|
+
: "nxViteTsPaths configs: none found.";
|
|
111
|
+
const nextSteps = uninstallCommands.map((cmd) => ` ${cmd}`).join("\n");
|
|
112
|
+
return `${header}\n${viteLine}\nNext steps to verify and remove Nx:\n${nextSteps}\n`;
|
|
113
|
+
}
|
|
34
114
|
function readOptions(workspaceRoot, values) {
|
|
35
115
|
const jobs = readJobs(values.jobs);
|
|
36
116
|
const targetNames = readTargets(values.targets);
|