@elench/testkit 0.1.66 → 0.1.67
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 +37 -62
- package/lib/app/doctor.mjs +139 -0
- package/lib/app/typecheck.mjs +203 -0
- package/lib/cli/commands/doctor.mjs +39 -0
- package/lib/cli/commands/typecheck.mjs +28 -0
- package/lib/cli/entrypoint.mjs +2 -0
- package/lib/config/index.mjs +11 -0
- package/lib/config/runtime.mjs +11 -1
- package/lib/config/runtime.test.mjs +26 -0
- package/lib/coverage/index.test.mjs +4 -2
- package/lib/discovery/file-metadata.mjs +122 -0
- package/lib/discovery/file-metadata.test.mjs +51 -0
- package/lib/discovery/index.mjs +10 -2
- package/lib/discovery/index.test.mjs +19 -19
- package/lib/runner/planning.mjs +10 -3
- package/lib/runner/planning.test.mjs +26 -0
- package/lib/setup/index.d.ts +88 -21
- package/lib/setup/index.mjs +177 -50
- package/lib/setup/index.test.mjs +194 -64
- package/lib/shared/build-config.mjs +144 -0
- package/lib/shared/build-config.test.mjs +81 -0
- package/node_modules/@elench/next-analysis/package.json +1 -1
- package/node_modules/@elench/testkit-bridge/package.json +2 -2
- package/node_modules/@elench/testkit-protocol/package.json +1 -1
- package/node_modules/@elench/ts-analysis/package.json +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { normalizeConfiguredInputs, normalizeConfiguredSteps, normalizeOptionalString } from "./configured-steps.mjs";
|
|
3
|
+
|
|
4
|
+
export function normalizeBuildConfig(value, label) {
|
|
5
|
+
if (value == null) return null;
|
|
6
|
+
if (!value || typeof value !== "object") {
|
|
7
|
+
throw new Error(`${label} must be an object`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const kind = normalizeOptionalString(value.kind);
|
|
11
|
+
if (kind === "tsc") {
|
|
12
|
+
return {
|
|
13
|
+
kind,
|
|
14
|
+
cwd: normalizeOptionalString(value.cwd),
|
|
15
|
+
entry: normalizeOptionalString(value.entry) || "src/index.ts",
|
|
16
|
+
tsconfig: normalizeOptionalString(value.tsconfig) || "tsconfig.json",
|
|
17
|
+
outDir: normalizeOptionalString(value.outDir) || "dist",
|
|
18
|
+
inputs: normalizeConfiguredInputs(value.inputs, `${label}.inputs`),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (kind === "script") {
|
|
23
|
+
const script = normalizeOptionalString(value.script);
|
|
24
|
+
if (!script) throw new Error(`${label}.script must be a non-empty string`);
|
|
25
|
+
return {
|
|
26
|
+
kind,
|
|
27
|
+
cwd: normalizeOptionalString(value.cwd),
|
|
28
|
+
script,
|
|
29
|
+
inputs: normalizeConfiguredInputs(value.inputs, `${label}.inputs`),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (kind === "steps") {
|
|
34
|
+
return {
|
|
35
|
+
kind,
|
|
36
|
+
inputs: normalizeConfiguredInputs(value.inputs, `${label}.inputs`),
|
|
37
|
+
steps: normalizeConfiguredSteps(value.steps, `${label}.steps`),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
throw new Error(`${label}.kind must be one of: tsc, script, steps`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function finalizeBuildConfig(build, transform) {
|
|
45
|
+
if (!build) return null;
|
|
46
|
+
if (build.kind === "tsc") {
|
|
47
|
+
return {
|
|
48
|
+
...build,
|
|
49
|
+
cwd: build.cwd ? transform(build.cwd) : build.cwd,
|
|
50
|
+
entry: transform(build.entry),
|
|
51
|
+
tsconfig: transform(build.tsconfig),
|
|
52
|
+
outDir: transform(build.outDir),
|
|
53
|
+
inputs: build.inputs.map((input) => transform(input)),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
if (build.kind === "script") {
|
|
57
|
+
return {
|
|
58
|
+
...build,
|
|
59
|
+
cwd: build.cwd ? transform(build.cwd) : build.cwd,
|
|
60
|
+
script: transform(build.script),
|
|
61
|
+
inputs: build.inputs.map((input) => transform(input)),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
...build,
|
|
66
|
+
inputs: build.inputs.map((input) => transform(input)),
|
|
67
|
+
steps: build.steps.map((step) => ({
|
|
68
|
+
...step,
|
|
69
|
+
...(typeof step.cmd === "string" ? { cmd: transform(step.cmd) } : {}),
|
|
70
|
+
...(typeof step.cwd === "string" ? { cwd: transform(step.cwd) } : {}),
|
|
71
|
+
...(typeof step.path === "string" ? { path: transform(step.path) } : {}),
|
|
72
|
+
...(typeof step.specifier === "string" ? { specifier: transform(step.specifier) } : {}),
|
|
73
|
+
inputs: (step.inputs || []).map((input) => transform(input)),
|
|
74
|
+
})),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function buildConfigToPrepare(build) {
|
|
79
|
+
if (!build) {
|
|
80
|
+
return {
|
|
81
|
+
inputs: [],
|
|
82
|
+
steps: [],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (build.kind === "steps") {
|
|
87
|
+
return {
|
|
88
|
+
inputs: [...build.inputs],
|
|
89
|
+
steps: [...build.steps],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (build.kind === "script") {
|
|
94
|
+
return {
|
|
95
|
+
inputs: [...build.inputs],
|
|
96
|
+
steps: [
|
|
97
|
+
{
|
|
98
|
+
kind: "command",
|
|
99
|
+
cmd: build.script,
|
|
100
|
+
cwd: build.cwd || undefined,
|
|
101
|
+
inputs: [...build.inputs],
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const inputs = build.inputs.length > 0 ? [...build.inputs] : defaultTscInputs(build);
|
|
108
|
+
const cmd = `./node_modules/.bin/tsc -p ${build.tsconfig} --outDir "{prepareDir}/${build.outDir}"`;
|
|
109
|
+
return {
|
|
110
|
+
inputs,
|
|
111
|
+
steps: [
|
|
112
|
+
{
|
|
113
|
+
kind: "command",
|
|
114
|
+
cmd,
|
|
115
|
+
cwd: build.cwd || undefined,
|
|
116
|
+
inputs,
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function compiledEntryFromBuild(build) {
|
|
123
|
+
if (!build || build.kind !== "tsc") return null;
|
|
124
|
+
return path.posix.join(build.outDir, sourceEntryToOutputPath(build.entry));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function sourceEntryToOutputPath(entry) {
|
|
128
|
+
const normalized = String(entry).split(path.sep).join("/");
|
|
129
|
+
const withoutExtension = normalized.replace(/\.[cm]?[jt]sx?$/i, ".js");
|
|
130
|
+
if (withoutExtension.startsWith("src/")) {
|
|
131
|
+
return withoutExtension.slice(4);
|
|
132
|
+
}
|
|
133
|
+
return withoutExtension;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function defaultTscInputs(build) {
|
|
137
|
+
const inputs = new Set([build.tsconfig, "package.json"]);
|
|
138
|
+
const normalizedEntry = String(build.entry).split(path.sep).join("/");
|
|
139
|
+
const topLevelDir = normalizedEntry.includes("/") ? normalizedEntry.slice(0, normalizedEntry.indexOf("/")) : normalizedEntry;
|
|
140
|
+
if (topLevelDir) {
|
|
141
|
+
inputs.add(topLevelDir);
|
|
142
|
+
}
|
|
143
|
+
return [...inputs];
|
|
144
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
buildConfigToPrepare,
|
|
4
|
+
compiledEntryFromBuild,
|
|
5
|
+
normalizeBuildConfig,
|
|
6
|
+
} from "./build-config.mjs";
|
|
7
|
+
|
|
8
|
+
describe("shared build config helpers", () => {
|
|
9
|
+
it("normalizes tsc build config and derives prepare steps", () => {
|
|
10
|
+
const build = normalizeBuildConfig(
|
|
11
|
+
{
|
|
12
|
+
kind: "tsc",
|
|
13
|
+
entry: "src/server.ts",
|
|
14
|
+
outDir: "dist",
|
|
15
|
+
},
|
|
16
|
+
"runtime.build"
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
expect(build).toEqual({
|
|
20
|
+
kind: "tsc",
|
|
21
|
+
cwd: null,
|
|
22
|
+
entry: "src/server.ts",
|
|
23
|
+
tsconfig: "tsconfig.json",
|
|
24
|
+
outDir: "dist",
|
|
25
|
+
inputs: [],
|
|
26
|
+
});
|
|
27
|
+
expect(compiledEntryFromBuild(build)).toBe("dist/server.js");
|
|
28
|
+
expect(buildConfigToPrepare(build)).toEqual({
|
|
29
|
+
inputs: ["tsconfig.json", "package.json", "src"],
|
|
30
|
+
steps: [
|
|
31
|
+
{
|
|
32
|
+
kind: "command",
|
|
33
|
+
cmd: './node_modules/.bin/tsc -p tsconfig.json --outDir "{prepareDir}/dist"',
|
|
34
|
+
cwd: undefined,
|
|
35
|
+
inputs: ["tsconfig.json", "package.json", "src"],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("normalizes script and steps builds", () => {
|
|
42
|
+
expect(
|
|
43
|
+
normalizeBuildConfig(
|
|
44
|
+
{
|
|
45
|
+
kind: "script",
|
|
46
|
+
script: "npm run build",
|
|
47
|
+
cwd: "frontend",
|
|
48
|
+
inputs: ["frontend/package.json"],
|
|
49
|
+
},
|
|
50
|
+
"runtime.build"
|
|
51
|
+
)
|
|
52
|
+
).toEqual({
|
|
53
|
+
kind: "script",
|
|
54
|
+
script: "npm run build",
|
|
55
|
+
cwd: "frontend",
|
|
56
|
+
inputs: ["frontend/package.json"],
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
expect(
|
|
60
|
+
normalizeBuildConfig(
|
|
61
|
+
{
|
|
62
|
+
kind: "steps",
|
|
63
|
+
inputs: ["scripts/prepare.mjs"],
|
|
64
|
+
steps: [{ kind: "command", cmd: "node scripts/prepare.mjs" }],
|
|
65
|
+
},
|
|
66
|
+
"runtime.build"
|
|
67
|
+
)
|
|
68
|
+
).toEqual({
|
|
69
|
+
kind: "steps",
|
|
70
|
+
inputs: ["scripts/prepare.mjs"],
|
|
71
|
+
steps: [
|
|
72
|
+
{
|
|
73
|
+
kind: "command",
|
|
74
|
+
cmd: "node scripts/prepare.mjs",
|
|
75
|
+
cwd: null,
|
|
76
|
+
inputs: [],
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elench/testkit-bridge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.67",
|
|
4
4
|
"description": "Browser bridge helpers for testkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@elench/testkit-protocol": "0.1.
|
|
25
|
+
"@elench/testkit-protocol": "0.1.67"
|
|
26
26
|
},
|
|
27
27
|
"private": false
|
|
28
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elench/testkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.67",
|
|
4
4
|
"description": "CLI for discovering and running local HTTP, DAL, and Playwright test suites",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"workspaces": [
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"vitest": "^3.2.4"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@elench/next-analysis": "0.1.
|
|
68
|
-
"@elench/ts-analysis": "0.1.
|
|
69
|
-
"@elench/testkit-bridge": "0.1.
|
|
70
|
-
"@elench/testkit-protocol": "0.1.
|
|
67
|
+
"@elench/next-analysis": "0.1.67",
|
|
68
|
+
"@elench/ts-analysis": "0.1.67",
|
|
69
|
+
"@elench/testkit-bridge": "0.1.67",
|
|
70
|
+
"@elench/testkit-protocol": "0.1.67",
|
|
71
71
|
"@babel/code-frame": "^7.29.0",
|
|
72
72
|
"@oclif/core": "^4.10.6",
|
|
73
73
|
"esbuild": "^0.25.11",
|