fix(build): render product index before entry points (R-0)

src/.generated is gitignored, but no entry point rendered it, so a fresh
checkout failed check:architecture, check:types:app/node/test, unit and
component tests, verify:documentation, dev and build.

- run-vitest renders the index before starting Vitest (all vitest suites)
- package scripts that load src (dev, build, storybook, architecture,
  app/node/test type checks, the five fixtures that reach the index,
  verify:documentation) render it first; CI runs these scripts by name
- tests/unit/product-index-entrypoints.test.ts guards the wiring

Verified from a fresh state (src/.generated removed before each gate):
architecture, types app/node/test, lint, unit 1781/1781, component 132/132,
verify:documentation, build, dev (HTTP 200), check:ci all pass;
fixture route-runtime still fails with its expected TS2740.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-24 11:52:34 +09:00
co-authored by Claude Opus 5.5
parent ea0f01ff05
commit f0d3953ef2
5 changed files with 73 additions and 18 deletions
+15 -15
View File
@@ -9,13 +9,13 @@
"pnpm": ">=11.0.0 <12.0.0"
},
"scripts": {
"dev": "vite",
"build": "node scripts/build-frontend.ts",
"dev": "node scripts/generate-product-feature-index.ts && vite",
"build": "node scripts/generate-product-feature-index.ts && node scripts/build-frontend.ts",
"build:profile": "node scripts/generate-runtime-config.ts",
"build:release-candidate": "corepack pnpm build && corepack pnpm generate:supply-chain && corepack pnpm scan:security && corepack pnpm verify:release && node scripts/verify-supply-chain-artifacts.ts && node scripts/create-release-candidate.ts",
"preview": "vite preview",
"lint": "eslint src scripts tests recipes .storybook vite.config.ts vitest.config.ts playwright*.config.ts --max-warnings=0",
"check:architecture": "node scripts/check-architecture.ts",
"check:architecture": "node scripts/generate-product-feature-index.ts && node scripts/check-architecture.ts",
"check:design-system": "node scripts/check-design-system.ts",
"check:design-system:fixture": "node scripts/check-design-system.ts --fixture",
"check:i18n": "node scripts/check-i18n.ts",
@@ -26,9 +26,9 @@
"check:diagnostics": "node scripts/check-diagnostics.ts",
"check:diagnostics:fixture": "node scripts/check-diagnostics.ts --fixture",
"check:types": "corepack pnpm check:types:app && corepack pnpm check:types:node && corepack pnpm check:types:test && corepack pnpm check:types:recipes && corepack pnpm check:types:web-worker && corepack pnpm check:types:service-worker",
"check:types:app": "tsc --project tsconfig.app.json",
"check:types:node": "tsc --project tsconfig.node.json",
"check:types:test": "tsc --project tsconfig.test.json",
"check:types:app": "node scripts/generate-product-feature-index.ts && tsc --project tsconfig.app.json",
"check:types:node": "node scripts/generate-product-feature-index.ts && tsc --project tsconfig.node.json",
"check:types:test": "node scripts/generate-product-feature-index.ts && tsc --project tsconfig.test.json",
"check:types:recipes": "node scripts/check-optional-recipe-types.ts",
"check:types:fixture": "tsc -p tests/fixtures/typecheck/tsconfig.port-call.json",
"check:types:fixture:ts-port": "tsc -p tests/fixtures/typecheck/tsconfig.port-implementation.json",
@@ -39,11 +39,11 @@
"check:types:fixture:failure-kind": "tsc -p tests/fixtures/typecheck/tsconfig.failure-kind.json",
"check:types:fixture:reference-operation": "tsc -p tests/fixtures/typecheck/tsconfig.reference-operation.json",
"check:types:fixture:async-overlay": "tsc -p tests/fixtures/typecheck/tsconfig.async-overlay.json",
"check:types:fixture:route-runtime": "tsc -p tests/fixtures/typecheck/tsconfig.route-runtime.json",
"check:types:fixture:page-action": "tsc -p tests/fixtures/typecheck/tsconfig.page-action.json",
"check:types:fixture:icon-button": "tsc -p tests/fixtures/typecheck/tsconfig.icon-button.json",
"check:types:fixture:i18n-key": "tsc -p tests/fixtures/typecheck/tsconfig.message-key.json",
"check:types:fixture:i18n-params": "tsc -p tests/fixtures/typecheck/tsconfig.message-params.json",
"check:types:fixture:route-runtime": "node scripts/generate-product-feature-index.ts && tsc -p tests/fixtures/typecheck/tsconfig.route-runtime.json",
"check:types:fixture:page-action": "node scripts/generate-product-feature-index.ts && tsc -p tests/fixtures/typecheck/tsconfig.page-action.json",
"check:types:fixture:icon-button": "node scripts/generate-product-feature-index.ts && tsc -p tests/fixtures/typecheck/tsconfig.icon-button.json",
"check:types:fixture:i18n-key": "node scripts/generate-product-feature-index.ts && tsc -p tests/fixtures/typecheck/tsconfig.message-key.json",
"check:types:fixture:i18n-params": "node scripts/generate-product-feature-index.ts && tsc -p tests/fixtures/typecheck/tsconfig.message-params.json",
"check:types:fixture:diagnostics": "tsc -p tests/fixtures/typecheck/tsconfig.diagnostics-port.json",
"check:types:fixture:image-resolve-signal": "tsc -p tests/fixtures/typecheck/tsconfig.image-cdn-resolve-signal.json",
"test:runtime-schema": "node scripts/run-vitest.ts run tests/runtime-schema --reporter=default --reporter=junit --outputFile.junit=artifacts/tests/runtime-schema.xml --passWithNoTests",
@@ -59,8 +59,8 @@
"test:e2e:dev": "playwright test --config playwright.dev.config.ts",
"test:browser-capabilities": "playwright test --config playwright.capabilities.config.ts",
"verify:browser-capability-evidence": "node scripts/verify-browser-capability-evidence.ts",
"storybook": "storybook dev -p 6006",
"build:storybook": "storybook build -o artifacts/storybook/static",
"storybook": "node scripts/generate-product-feature-index.ts && storybook dev -p 6006",
"build:storybook": "node scripts/generate-product-feature-index.ts && storybook build -o artifacts/storybook/static",
"test:storybook": "playwright test --config playwright.storybook.config.ts",
"test:visual": "playwright test --config playwright.visual.config.ts",
"test:visual:update": "playwright test --config playwright.visual.config.ts --update-snapshots",
@@ -120,8 +120,8 @@
"generate:ci-workflow": "node scripts/generate-ci-workflow.ts",
"check:ci-workflow": "node scripts/generate-ci-workflow.ts --check",
"check:ci": "corepack pnpm check:artifact-schemas && node scripts/check-ci-contract.ts && corepack pnpm check:ci-workflow",
"verify:documentation": "node scripts/verify-documentation-readiness.ts",
"build:app-only": "vite build && node scripts/generate-build-manifest.ts",
"verify:documentation": "node scripts/generate-product-feature-index.ts && node scripts/verify-documentation-readiness.ts",
"build:app-only": "node scripts/generate-product-feature-index.ts && vite build && node scripts/generate-build-manifest.ts",
"generate:contract-set": "node scripts/generate-contract-set.ts",
"check:types:web-worker": "tsc --project tsconfig.web-worker.json",
"check:types:service-worker": "tsc --project tsconfig.service-worker.json",
+12
View File
@@ -47,6 +47,18 @@ for (const key of [
delete testEnvironment[key];
}
// src/.generated is gitignored; every suite imports the product index, so a
// fresh checkout must render it before Vitest resolves the module graph.
const generated = spawnSync(
process.execPath,
[fileURLToPath(new URL("./generate-product-feature-index.ts", import.meta.url))],
{ stdio: "inherit", env: testEnvironment },
);
if (generated.status !== 0) {
process.stderr.write("Product feature index generation failed.\n");
process.exit(generated.status ?? 1);
}
const result = spawnSync(
process.execPath,
[vitestEntry, ...process.argv.slice(2)],
+1 -1
View File
@@ -38,7 +38,7 @@
## Task List (요약 — 상세는 tasks/todo.md)
### Phase 0: 기반
- [ ] T01 R-0 깨끗한 체크아웃에서 게이트 동작
- [x] T01 R-0 깨끗한 체크아웃에서 게이트 동작
### Checkpoint 0
- [ ] `src/.generated` 삭제 후 arch/types/lint/unit/component/verify:documentation 통과
+2 -2
View File
@@ -16,8 +16,8 @@
### T01 — R-0 깨끗한 체크아웃에서 게이트 동작 (리뷰 6.0)
- 완료 조건:
- [ ] `rm -rf src/.generated` 뒤 `dev`(기동까지), `build`, `check:architecture`, `check:types:app`, `test:unit`, `test:component`, `verify:documentation`이 통과한다
- [ ] CI(`config/ci/gates.json` → 생성 workflow)도 생성 단계를 거친다. `check:ci-contract` 등 관련 검사가 통과한다
- [x] `rm -rf src/.generated` 뒤 `dev`(기동까지), `build`, `check:architecture`, `check:types:app`, `test:unit`, `test:component`, `verify:documentation`이 통과한다
- [x] CI(`config/ci/gates.json` → 생성 workflow)도 생성 단계를 거친다. `check:ci-contract` 등 관련 검사가 통과한다
- 테스트: 스크립트 레벨 검증(위 명령). 필요하면 `tests/scripts/generate-product-feature-index.test.ts`에 보강
- 파일: `package.json`, `scripts/*`(진입점), `config/ci/gates.json`, 생성 workflow
- 의존: 없음 · 크기: M
@@ -0,0 +1,43 @@
import { readFile } from "node:fs/promises";
import { describe, expect, it } from "vitest";
// src/.generated is gitignored (R-0): every entry point that loads the product
// index must render it first, or a fresh checkout cannot run the gates.
const GENERATE = "node scripts/generate-product-feature-index.ts && ";
const ENTRY_SCRIPTS = [
"dev",
"build",
"build:app-only",
"storybook",
"build:storybook",
"check:architecture",
"check:types:app",
"check:types:node",
"check:types:test",
"check:types:fixture:route-runtime",
"check:types:fixture:page-action",
"check:types:fixture:icon-button",
"check:types:fixture:i18n-key",
"check:types:fixture:i18n-params",
"verify:documentation",
] as const;
describe("product index entry points", () => {
it("renders the generated index before scripts that load src", async () => {
const { scripts } = JSON.parse(await readFile("package.json", "utf8")) as {
scripts: Record<string, string>;
};
for (const name of ENTRY_SCRIPTS) {
expect(scripts[name], name).toMatch(new RegExp(`^${GENERATE.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`));
}
});
it("renders the generated index before every Vitest run", async () => {
const runner = await readFile("scripts/run-vitest.ts", "utf8");
expect(runner.indexOf("generate-product-feature-index.ts")).toBeGreaterThan(-1);
expect(runner.indexOf("generate-product-feature-index.ts")).toBeLessThan(
runner.indexOf("vitestEntry, ...process.argv"),
);
});
});