@leitwerk-dev/test-support 0.1.9 → 0.2.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/dist/{chunk-KIDBCGNW.js → chunk-2PCDTYVH.js} +26 -26
- package/dist/chunk-2PCDTYVH.js.map +1 -0
- package/dist/chunk-5BZSJ4OO.js +192 -0
- package/dist/chunk-5BZSJ4OO.js.map +1 -0
- package/dist/{chunk-QFCJV2VA.js → chunk-ECAWLVYB.js} +224 -17
- package/dist/chunk-ECAWLVYB.js.map +1 -0
- package/dist/{chunk-JUH3LUYK.js → chunk-EXHTWQAE.js} +5 -1
- package/dist/chunk-EXHTWQAE.js.map +1 -0
- package/dist/compact-process-detail-fixture.d.ts +3 -0
- package/dist/compact-process-detail-fixture.d.ts.map +1 -1
- package/dist/fakes/fake-git-ops.d.ts +12 -0
- package/dist/fakes/fake-git-ops.d.ts.map +1 -1
- package/dist/fakes/fake-llm.d.ts +11 -0
- package/dist/fakes/fake-llm.d.ts.map +1 -1
- package/dist/fakes/index.d.ts +1 -1
- package/dist/fakes/index.d.ts.map +1 -1
- package/dist/fakes/index.js +111 -2
- package/dist/fakes/index.js.map +1 -1
- package/dist/fixtures.js +137 -2
- package/dist/fixtures.js.map +1 -1
- package/dist/http-launch.d.ts +9 -0
- package/dist/http-launch.d.ts.map +1 -0
- package/dist/index.d.ts +24 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +113 -12
- package/dist/index.js.map +1 -1
- package/dist/integration-harness.d.ts +36 -1
- package/dist/integration-harness.d.ts.map +1 -1
- package/dist/integration.d.ts +3 -3
- package/dist/integration.d.ts.map +1 -1
- package/dist/integration.js +184 -4
- package/dist/integration.js.map +1 -1
- package/dist/local-git.d.ts +231 -0
- package/dist/local-git.d.ts.map +1 -0
- package/dist/local-git.js +428 -0
- package/dist/local-git.js.map +1 -0
- package/dist/model-provider-fixtures.d.ts +15 -0
- package/dist/model-provider-fixtures.d.ts.map +1 -0
- package/dist/polling.d.ts +2 -1
- package/dist/polling.d.ts.map +1 -1
- package/dist/process-driver.d.ts +14 -0
- package/dist/process-driver.d.ts.map +1 -0
- package/dist/question-fixtures.d.ts +2 -0
- package/dist/question-fixtures.d.ts.map +1 -1
- package/dist/server-extension-test-harness.d.ts +57 -2
- package/dist/server-extension-test-harness.d.ts.map +1 -1
- package/dist/stub-worker-entry.js +9 -5
- package/dist/stub-worker-entry.js.map +1 -1
- package/dist/test-diagnostics.d.ts +14 -0
- package/dist/test-diagnostics.d.ts.map +1 -0
- package/dist/worker-testing/in-process-worker-spawn.d.ts +21 -0
- package/dist/worker-testing/in-process-worker-spawn.d.ts.map +1 -1
- package/dist/worker-testing/index.d.ts +6 -7
- package/dist/worker-testing/index.d.ts.map +1 -1
- package/dist/worker-testing/index.js +381 -7
- package/dist/worker-testing/index.js.map +1 -1
- package/dist/worker-testing/schema-driven-stub-pi.d.ts +5 -0
- package/dist/worker-testing/schema-driven-stub-pi.d.ts.map +1 -1
- package/dist/worker-testing/stub-pi-controls.d.ts +4 -0
- package/dist/worker-testing/stub-pi-controls.d.ts.map +1 -1
- package/dist/worker-testing/stub-pi-tree-handle.d.ts +93 -1
- package/dist/worker-testing/stub-pi-tree-handle.d.ts.map +1 -1
- package/dist/worker-testing/worker-runtime-harness.d.ts +37 -2
- package/dist/worker-testing/worker-runtime-harness.d.ts.map +1 -1
- package/dist/worker-testing/worker-start-payload.d.ts +17 -1
- package/dist/worker-testing/worker-start-payload.d.ts.map +1 -1
- package/package.json +15 -9
- package/src/compact-process-detail-fixture.ts +37 -3
- package/src/fakes/fake-git-ops.ts +12 -0
- package/src/fakes/fake-llm.ts +11 -0
- package/src/fakes/index.ts +1 -1
- package/src/http-launch.ts +88 -0
- package/src/index.ts +31 -41
- package/src/integration-harness.ts +100 -9
- package/src/integration.ts +3 -9
- package/src/local-git.ts +499 -0
- package/src/model-provider-fixtures.ts +36 -0
- package/src/polling.ts +3 -2
- package/src/process-driver.ts +63 -0
- package/src/question-fixtures.ts +2 -0
- package/src/server-extension-test-harness.ts +100 -6
- package/src/test-diagnostics.ts +69 -0
- package/src/worker-testing/in-process-worker-spawn.ts +49 -2
- package/src/worker-testing/index.ts +4 -26
- package/src/worker-testing/schema-driven-stub-pi.ts +8 -1
- package/src/worker-testing/stub-pi-controls.ts +4 -0
- package/src/worker-testing/stub-pi-tree-handle.ts +301 -21
- package/src/worker-testing/worker-runtime-harness.ts +57 -6
- package/src/worker-testing/worker-start-payload.ts +18 -1
- package/dist/chunk-3MQO3NCX.js +0 -15
- package/dist/chunk-3MQO3NCX.js.map +0 -1
- package/dist/chunk-7ZK5QRGP.js +0 -98
- package/dist/chunk-7ZK5QRGP.js.map +0 -1
- package/dist/chunk-JUH3LUYK.js.map +0 -1
- package/dist/chunk-KIDBCGNW.js.map +0 -1
- package/dist/chunk-QFCJV2VA.js.map +0 -1
- package/dist/chunk-R4KVUGWR.js +0 -83
- package/dist/chunk-R4KVUGWR.js.map +0 -1
- package/dist/chunk-ST2C4VKX.js +0 -297
- package/dist/chunk-ST2C4VKX.js.map +0 -1
- package/dist/compact-process-detail-fixture.js +0 -73
- package/dist/compact-process-detail-fixture.js.map +0 -1
- package/dist/fakes/fake-git-ops.js +0 -101
- package/dist/fakes/fake-git-ops.js.map +0 -1
- package/dist/fakes/fake-llm.js +0 -27
- package/dist/fakes/fake-llm.js.map +0 -1
- package/dist/in-process-worker.js +0 -2
- package/dist/in-process-worker.js.map +0 -1
- package/dist/integration-harness.js +0 -38
- package/dist/integration-harness.js.map +0 -1
- package/dist/polling.js +0 -14
- package/dist/polling.js.map +0 -1
- package/dist/question-fixtures.js +0 -26
- package/dist/question-fixtures.js.map +0 -1
- package/dist/server-extension-test-harness.js +0 -169
- package/dist/server-extension-test-harness.js.map +0 -1
- package/dist/test-app.d.ts +0 -23
- package/dist/test-app.d.ts.map +0 -1
- package/dist/test-app.js +0 -47
- package/dist/test-app.js.map +0 -1
- package/dist/worker-testing/in-process-worker-spawn.js +0 -61
- package/dist/worker-testing/in-process-worker-spawn.js.map +0 -1
- package/dist/worker-testing/ipc-harness.d.ts +0 -11
- package/dist/worker-testing/ipc-harness.d.ts.map +0 -1
- package/dist/worker-testing/ipc-harness.js +0 -17
- package/dist/worker-testing/ipc-harness.js.map +0 -1
- package/dist/worker-testing/schema-driven-stub-pi.js +0 -65
- package/dist/worker-testing/schema-driven-stub-pi.js.map +0 -1
- package/dist/worker-testing/stub-pi-controls.js +0 -10
- package/dist/worker-testing/stub-pi-controls.js.map +0 -1
- package/dist/worker-testing/stub-pi-tree-handle.js +0 -515
- package/dist/worker-testing/stub-pi-tree-handle.js.map +0 -1
- package/dist/worker-testing/worker-runtime-harness.js +0 -231
- package/dist/worker-testing/worker-runtime-harness.js.map +0 -1
- package/dist/worker-testing/worker-start-payload.js +0 -101
- package/dist/worker-testing/worker-start-payload.js.map +0 -1
- package/dist/workspace-source-aliases.d.ts +0 -6
- package/dist/workspace-source-aliases.d.ts.map +0 -1
- package/dist/workspace-source-aliases.js +0 -126
- package/dist/workspace-source-aliases.js.map +0 -1
- package/src/test-app.ts +0 -82
- package/src/worker-testing/ipc-harness.ts +0 -19
- package/src/workspace-source-aliases.ts +0 -171
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
interface RootPackageJson {
|
|
5
|
-
workspaces?: string[] | { packages?: string[] };
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface WorkspacePackageJson {
|
|
9
|
-
name?: string;
|
|
10
|
-
exports?: unknown;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface JsonRecord {
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface WorkspaceSourceAlias {
|
|
18
|
-
find: RegExp;
|
|
19
|
-
replacement: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function buildWorkspaceSourceAliases(
|
|
23
|
-
rootDir: string,
|
|
24
|
-
additionalPackageDirs: readonly string[] = [],
|
|
25
|
-
): WorkspaceSourceAlias[] {
|
|
26
|
-
const packageDirs = [
|
|
27
|
-
...new Set([...listWorkspacePackageDirs(rootDir), ...additionalPackageDirs]),
|
|
28
|
-
];
|
|
29
|
-
const aliases = packageDirs.flatMap((packageDir) => buildAliasesForPackage(packageDir));
|
|
30
|
-
|
|
31
|
-
return aliases.sort((left, right) => {
|
|
32
|
-
const lengthDelta = right.find.source.length - left.find.source.length;
|
|
33
|
-
if (lengthDelta !== 0) {
|
|
34
|
-
return lengthDelta;
|
|
35
|
-
}
|
|
36
|
-
return left.find.source.localeCompare(right.find.source);
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function buildAliasesForPackage(packageDir: string): WorkspaceSourceAlias[] {
|
|
41
|
-
const packageJson = readJson<WorkspacePackageJson>(path.join(packageDir, "package.json"));
|
|
42
|
-
if (!packageJson.name) {
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return listPackageExportTargets(packageJson.name, packageJson.exports).flatMap(
|
|
47
|
-
({ specifier, importTarget }) => {
|
|
48
|
-
const replacement = resolveSourceFile(packageDir, importTarget);
|
|
49
|
-
if (!replacement) {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
return [{ find: createExactSpecifierPattern(specifier), replacement }];
|
|
53
|
-
},
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function listWorkspacePackageDirs(rootDir: string): string[] {
|
|
58
|
-
const rootPackageJson = readJson<RootPackageJson>(path.join(rootDir, "package.json"));
|
|
59
|
-
const workspacePatterns = Array.isArray(rootPackageJson.workspaces)
|
|
60
|
-
? rootPackageJson.workspaces
|
|
61
|
-
: (rootPackageJson.workspaces?.packages ?? []);
|
|
62
|
-
|
|
63
|
-
return workspacePatterns
|
|
64
|
-
.flatMap((pattern) => expandWorkspacePattern(rootDir, pattern))
|
|
65
|
-
.filter((packageDir, index, dirs) => dirs.indexOf(packageDir) === index)
|
|
66
|
-
.sort((left, right) => left.localeCompare(right));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function expandWorkspacePattern(rootDir: string, pattern: string): string[] {
|
|
70
|
-
if (pattern.endsWith("/*")) {
|
|
71
|
-
const baseDir = path.join(rootDir, pattern.slice(0, -2));
|
|
72
|
-
if (!existsSync(baseDir)) {
|
|
73
|
-
return [];
|
|
74
|
-
}
|
|
75
|
-
return readdirSync(baseDir, { withFileTypes: true })
|
|
76
|
-
.filter((entry) => entry.isDirectory())
|
|
77
|
-
.map((entry) => path.join(baseDir, entry.name))
|
|
78
|
-
.filter((packageDir) => existsSync(path.join(packageDir, "package.json")));
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const packageDir = path.join(rootDir, pattern);
|
|
82
|
-
return existsSync(path.join(packageDir, "package.json")) ? [packageDir] : [];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function listPackageExportTargets(
|
|
86
|
-
packageName: string,
|
|
87
|
-
exportsField: unknown,
|
|
88
|
-
): Array<{ specifier: string; importTarget: string }> {
|
|
89
|
-
if (!exportsField) {
|
|
90
|
-
return [];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (isPackageSubpathExportMap(exportsField)) {
|
|
94
|
-
return Object.entries(exportsField).flatMap(([subpath, exportValue]) => {
|
|
95
|
-
const importTarget = resolveImportTarget(exportValue);
|
|
96
|
-
if (!importTarget) {
|
|
97
|
-
return [];
|
|
98
|
-
}
|
|
99
|
-
const specifier = subpath === "." ? packageName : `${packageName}/${subpath.slice(2)}`;
|
|
100
|
-
return [{ specifier, importTarget }];
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const importTarget = resolveImportTarget(exportsField);
|
|
105
|
-
return importTarget ? [{ specifier: packageName, importTarget }] : [];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function isPackageSubpathExportMap(value: unknown): value is JsonRecord {
|
|
109
|
-
if (!isJsonRecord(value)) {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
return Object.keys(value).some((key) => key === "." || key.startsWith("./"));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function resolveImportTarget(exportValue: unknown): string | null {
|
|
116
|
-
if (typeof exportValue === "string") {
|
|
117
|
-
return exportValue;
|
|
118
|
-
}
|
|
119
|
-
if (!isJsonRecord(exportValue)) {
|
|
120
|
-
return null;
|
|
121
|
-
}
|
|
122
|
-
if (typeof exportValue.import === "string") {
|
|
123
|
-
return exportValue.import;
|
|
124
|
-
}
|
|
125
|
-
if (typeof exportValue.default === "string") {
|
|
126
|
-
return exportValue.default;
|
|
127
|
-
}
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function resolveSourceFile(packageDir: string, importTarget: string): string | null {
|
|
132
|
-
const normalizedTarget = importTarget.startsWith("./") ? importTarget.slice(2) : importTarget;
|
|
133
|
-
for (const candidate of buildSourceCandidates(normalizedTarget)) {
|
|
134
|
-
const absoluteCandidate = path.join(packageDir, candidate);
|
|
135
|
-
if (existsSync(absoluteCandidate)) {
|
|
136
|
-
return absoluteCandidate;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function buildSourceCandidates(importTarget: string): string[] {
|
|
143
|
-
const srcTarget = importTarget.startsWith("dist/")
|
|
144
|
-
? `src/${importTarget.slice("dist/".length)}`
|
|
145
|
-
: importTarget;
|
|
146
|
-
const extensionlessTarget = srcTarget.replace(/\.(?:[cm]?js)$/, "");
|
|
147
|
-
|
|
148
|
-
return [
|
|
149
|
-
`${extensionlessTarget}.ts`,
|
|
150
|
-
`${extensionlessTarget}.tsx`,
|
|
151
|
-
`${extensionlessTarget}.mts`,
|
|
152
|
-
`${extensionlessTarget}.cts`,
|
|
153
|
-
srcTarget,
|
|
154
|
-
];
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function createExactSpecifierPattern(specifier: string): RegExp {
|
|
158
|
-
return new RegExp(`^${escapeRegExp(specifier)}$`);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function escapeRegExp(value: string): string {
|
|
162
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function isJsonRecord(value: unknown): value is JsonRecord {
|
|
166
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function readJson<T>(filePath: string): T {
|
|
170
|
-
return JSON.parse(readFileSync(filePath, "utf8")) as T;
|
|
171
|
-
}
|