음성 타입 fixture마다 옵션이 같은 tsconfig 하나, package script 하나, 게이트 명령 하나가 있었다(23벌). 옵션은 모두 같고 파일 하나만 달라서 fixture를 더할 때마다 세 곳을 같이 고쳤다. `tsconfig.recipes.json`도 `tsconfig.test.json`과 lib가 같고 types만 하나 적었다. `tsconfig.web-worker.json`은 `files: []`로 0파일을 검사하고 통과했다 (2026-09-25 리뷰가 기록, FE-GATE-003이 통과로 보였다). 고른 방법(design-docs repo-structure/04-frontend-layout.md 5.3절 (가), 소유자 승인 2026-11-07): - fixture 첫 줄에 기대(`// expect: TS2322`, `// expect: pass`)를 쓰고 `scripts/check-type-fixtures.ts`가 fixture마다 `.tmp/type-fixtures/`에 한 파일 tsconfig를 써서 tsc를 돈다. 판정은 run-ci-gate.ts가 명령마다 하던 것과 같다(exit 1과 `error TS<code>:`). 결과를 fixture별로 출력한다. 기대 줄이 없는 fixture와 fixture 0개는 실패한다. - recipes는 `tsconfig.test.json` include로 옮긴다. - web-worker tsconfig와 script는 지운다(결정 D4). Worker를 들일 때 더하는 단계는 매뉴얼 03에 쓴다(뒤 커밋). - `scripts/check-typecheck-inputs.ts`를 `check:types` 끝에 둔다. package script가 tsc에 넘기는 tsconfig마다 이 repo 파일이 1개 이상인지 본다. `files: []` tsconfig가 통과로 보이던 구멍을 막는다(R8). 버린 것: TypeScript API로 한 프로세스에서 돌리는 방법. 이 repo의 TypeScript 7.0(네이티브판)은 JS API를 싣지 않는다. 위반마다 `@ts-expect-error`를 쓰는 방법(5.3절 (나))은 오류 코드 고정을 잃는다. 위험: recipe가 이제 `vite/client` 타입이 있는 프로그램에서 검사된다. recipe가 `import.meta.env`를 쓰면 전에는 실패했고 이제는 통과한다 (복사한 제품도 Vite라 가치가 작다, 설계 5.1절). CI 계약 기준선을 다시 받았다(명령 99 → 76). 검증(desktop): `check:types:fixtures` 23개 PASS, 각 fixture의 기대 코드가 출력에 그대로 나온다. `TelemetryPort.emit` 인자를 `string`으로 넓히는 변이(2026-09-25 리뷰 07-05)에서 `invalid-diagnostics-port.ts`가 TS2578로 FAIL, 실행기 rc=1. 되돌린 뒤 작업 트리 0줄. `check:types` rc=0 (Typecheck inputs: app 379, node 312, service-worker 22, test 915). Refs: design-docs repo-structure/04-frontend-layout.md 5.3·9.2·9.3절, README.md 3.4절 D4
88 lines
4.3 KiB
TypeScript
88 lines
4.3 KiB
TypeScript
import { readFile } from "node:fs/promises";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { loadCiGateContract } from "../../scripts/contracts/ci-gates.ts";
|
|
import {
|
|
SCAFFOLD_DRILL_EXCLUDED_SCRIPTS,
|
|
scaffoldDrillCommands,
|
|
} from "../../scripts/lib/feature-scaffold-drill.ts";
|
|
|
|
// 1103/12-02. The scaffold drill claimed "every merge gate" and ran 15
|
|
// hand-picked commands of the 88 in the merge stage.
|
|
describe("feature scaffold drill commands", () => {
|
|
it("are the merge stage minus the named exclusions, each command once", async () => {
|
|
const contract = await loadCiGateContract(process.cwd());
|
|
const merge = contract.stages.find(({ id }) => id === "merge")!;
|
|
const mergeCommandIds = new Set(
|
|
merge.gateIds.flatMap((gateId) => contract.gates.find(({ id }) => id === gateId)!.commandIds),
|
|
);
|
|
const commands = scaffoldDrillCommands(contract);
|
|
const runCommandIds = commands.map(({ name }) => name.split(":").slice(1).join(":"));
|
|
expect(new Set(runCommandIds).size).toBe(runCommandIds.length);
|
|
for (const commandId of mergeCommandIds) {
|
|
const command = contract.commands.find(({ id }) => id === commandId)!;
|
|
expect(
|
|
runCommandIds.includes(commandId) || Object.hasOwn(SCAFFOLD_DRILL_EXCLUDED_SCRIPTS, command.script),
|
|
commandId,
|
|
).toBe(true);
|
|
}
|
|
expect(commands.map(({ script }) => script)).toEqual(expect.arrayContaining([
|
|
"check:types", "lint", "test:unit", "test:coverage", "build", "check:bundle",
|
|
"test:contract", "test:runtime-schema", "check:request-fanout", "build:release-candidate",
|
|
]));
|
|
for (const reason of Object.values(SCAFFOLD_DRILL_EXCLUDED_SCRIPTS)) {
|
|
expect(reason.length).toBeGreaterThan(10);
|
|
}
|
|
});
|
|
|
|
it("keeps a negative fixture's registered exit and diagnostic", async () => {
|
|
const contract = await loadCiGateContract(process.cwd());
|
|
expect(scaffoldDrillCommands(contract).find(({ script }) => script === "check:coverage:fixture"))
|
|
.toMatchObject({ expectation: { kind: "fail", expectedExitCode: 1, expectedDiagnosticId: "Risk coverage failed:" } });
|
|
});
|
|
|
|
it("runs a command added to the merge stage without an edit to the drill", async () => {
|
|
const contract = structuredClone(await loadCiGateContract(process.cwd()));
|
|
contract.commands.push({ id: "check-probe", script: "check:probe", expect: "pass" } as never);
|
|
contract.gates.find(({ id }) => id === "FE-GATE-010")!.commandIds.push("check-probe");
|
|
expect(scaffoldDrillCommands(contract).map(({ name }) => name)).toContain("FE-GATE-010:check-probe");
|
|
});
|
|
|
|
it("refuses an exclusion for a command the contract runs outside the merge stage", async () => {
|
|
const contract = await loadCiGateContract(process.cwd());
|
|
const merge = new Set(contract.stages.find(({ id }) => id === "merge")!.gateIds);
|
|
const mergeCommandIds = new Set(
|
|
contract.gates.filter(({ id }) => merge.has(id)).flatMap(({ commandIds }) => commandIds),
|
|
);
|
|
const mergeScripts = new Set(
|
|
contract.commands.filter(({ id }) => mergeCommandIds.has(id)).map(({ script }) => script),
|
|
);
|
|
const outside = contract.commands.find(({ script }) => !mergeScripts.has(script))!;
|
|
expect(() => scaffoldDrillCommands(contract, {
|
|
...SCAFFOLD_DRILL_EXCLUDED_SCRIPTS,
|
|
[outside.script]: "not in the merge stage",
|
|
})).toThrow(`outside the merge stage: ${outside.script}`);
|
|
});
|
|
|
|
// A removal drill prunes its capability's commands from the contract, and
|
|
// this file runs inside that fixture too.
|
|
it("accepts an exclusion whose command the contract no longer has", async () => {
|
|
const contract = structuredClone(await loadCiGateContract(process.cwd()));
|
|
const removed = contract.commands.find(({ script }) =>
|
|
Object.hasOwn(SCAFFOLD_DRILL_EXCLUDED_SCRIPTS, script)
|
|
)!;
|
|
contract.commands = contract.commands.filter(({ id }) => id !== removed.id);
|
|
for (const gate of contract.gates) {
|
|
gate.commandIds = gate.commandIds.filter((id) => id !== removed.id);
|
|
}
|
|
expect(() => scaffoldDrillCommands(contract)).not.toThrow();
|
|
});
|
|
|
|
it("is what test:feature-scaffold runs", async () => {
|
|
const drill = await readFile("scripts/test-feature-scaffold.ts", "utf8");
|
|
expect(drill).toContain("scaffoldDrillCommands(");
|
|
expect(drill).toContain("loadCiGateContract(fixtureRoot)");
|
|
});
|
|
});
|