frontend-quality-gates / merge / static checks (pull_request) Successful in 2m50s
frontend-quality-gates / merge / tests (pull_request) Failing after 14m15s
frontend-quality-gates / merge / browser tests (pull_request) Successful in 10m29s
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Skipped
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Skipped
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Skipped
frontend-quality-gates / external-vulnerability-provider (pull_request) Skipped
frontend-quality-gates / external-provenance-provider (pull_request) Skipped
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Skipped
frontend-quality-gates / deploy-promoted-release (pull_request) Skipped
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Skipped
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Skipped
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Skipped
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Skipped
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Skipped
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Skipped
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Skipped
frontend-quality-gates / main / checker self-tests (pull_request) Skipped
템플릿 시험과 드릴이 저장소 사본에 고정 ID로 기능을 만든다. 매뉴얼 코드 조각 시험은 매뉴얼 예시 invoice-feature를(FE-GATE-005), 생성 기능 e2e·청크 복구·부팅 실패 spec은 order-feature를(FE-GATE-008), scaffold 드릴은 scaffold-feature를(FE-GATE-020) 쓴다. 사본에는 제품 기능이 들어 있고 create:feature는 같은 ID나 같은 접두어를 거부한다. 그래서 매뉴얼 1단계 예시대로 invoice-feature를 만든 제품은 기능 코드와 상관없이 merge 게이트에서 막힌다. 고른 방법: 사본에 만드는 기능 ID를 모두 이미 정한 예약 접두어 typecheck-probe-로 옮기고 scripts/lib/template-probe-features.ts 한 곳에 둔다. 매뉴얼 조각은 invoice-feature 기준 그대로 두고, 시험이 조각과 검사 파일의 이름(INVOICE_, Invoice, invoice-, invoice)을 예약 기능의 이름으로 바꿔 넣는다(renameFeatureText). 생성 기능 e2e는 메시지 키와 계약 이름을 ID에서 만든다. 버린 대안: 사본에서 제품의 같은 이름 기능을 먼저 지우기(등록·조립 파일까지 지워야 해 사본이 제품과 달라진다), create:feature가 흔한 이름을 거부하기(제품 이름을 막는다). 위험·한계: 이름 바꾸기는 낱말 단위 치환이라 조각의 영어 문장 속 invoice도 바뀐다(조각과 검사가 함께 바뀌어 결과는 같다). 제품이 typecheck-probe-로 시작하는 기능을 만들면 다시 부딪친다. 매뉴얼과 create-feature 참조에 쓰지 말라고 적었고 생성 명령이 막지는 않는다. measure-feature-shape-growth의 s000-feature 꼴 ID는 그대로 뒀다. 검증: desktop에서 RED(이 커밋의 시험을 기준 커밋에 얹음)와 GREEN, 제품 상태(invoice-feature·order-feature를 만든 사본)의 FE-GATE-005·008 재현은 PR 본문에 적는다. Refs: 1112/08-02
141 lines
5.9 KiB
TypeScript
141 lines
5.9 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import { cp, mkdtemp, rename, rm } from "node:fs/promises";
|
|
import { existsSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import { pathToFileURL } from "node:url";
|
|
|
|
import { namesOf } from "../create-feature.ts";
|
|
import { localBuildEnvironment } from "./build-environment.ts";
|
|
import { linkFixtureNodeModules } from "./fixture-node-modules.ts";
|
|
import { REMOVAL_FIXTURE_COPY_TARGETS } from "./removal-fixture.ts";
|
|
import { TEMPLATE_PROBE_PREFIX } from "./template-probe-features.ts";
|
|
|
|
/**
|
|
* 2026-11-07. The template ships no feature. What needs one in a real build
|
|
* runs on the feature `create:feature` writes, added to a copy of the
|
|
* repository: the browser checks that one feature works end to end (route,
|
|
* form, save, a save whose result is lost; tests/e2e/generated-feature.spec.ts
|
|
* and the chunk recovery spec, whose fixture builds take `addGeneratedFeature`
|
|
* as their edit) and the browser soak's failing-backend visits
|
|
* (scripts/scale/browser-soak.ts, `buildWithGeneratedFeature`). A change of
|
|
* the generator's output fails there. The `--keyed` write slice is the widest
|
|
* one the command makes.
|
|
*
|
|
* 1112/08-02. The id begins with the reserved probe prefix: the copy holds
|
|
* the product's own features, and a product that had built `order-feature`
|
|
* made create:feature refuse this one.
|
|
*/
|
|
export const GENERATED_FEATURE_ID = `${TEMPLATE_PROBE_PREFIX}order-feature`;
|
|
|
|
const NAMES = namesOf(GENERATED_FEATURE_ID);
|
|
|
|
/** The key of one of the feature's words (`<camel>.list.title`). */
|
|
export function generatedMessageKey(suffix: string): string {
|
|
return `${NAMES.camel}.${suffix}`;
|
|
}
|
|
|
|
export type GeneratedRoute = Readonly<{
|
|
routeId: string;
|
|
path: string;
|
|
chunkId: string;
|
|
/** The lazy page's module id (`routeRuntimeContracts`), the name of its chunk. */
|
|
moduleId: string;
|
|
}>;
|
|
|
|
export type GeneratedFeature = Readonly<{
|
|
list: GeneratedRoute;
|
|
detail: GeneratedRoute;
|
|
create: GeneratedRoute;
|
|
/** The feature's ko-KR and en-US catalogs. */
|
|
messages: Readonly<Record<"ko-KR" | "en-US", Readonly<Record<string, string>>>>;
|
|
/** The collection the operations call: API_BASE_URL of the build plus the path. */
|
|
api: string;
|
|
}>;
|
|
|
|
function node(root: string, args: readonly string[]): string {
|
|
const result = spawnSync(process.execPath, args, { cwd: root, encoding: "utf8" });
|
|
if (result.status !== 0) {
|
|
throw new Error(`node ${args.join(" ")} failed in ${root}:\n${result.stdout}\n${result.stderr}`);
|
|
}
|
|
return result.stdout;
|
|
}
|
|
|
|
/** The edit of a fixture build: `corepack pnpm create:feature <GENERATED_FEATURE_ID> --with-create --keyed`. */
|
|
export async function addGeneratedFeature(root: string): Promise<void> {
|
|
node(root, ["scripts/generate-product-feature-index.ts"]);
|
|
node(root, ["scripts/create-feature.ts", GENERATED_FEATURE_ID, "--with-create", "--keyed"]);
|
|
}
|
|
|
|
/**
|
|
* What the specs need to drive the feature, read from the copy the command
|
|
* wrote it into (node runs that TypeScript as it is): the three routes, the
|
|
* words and where its API is.
|
|
*/
|
|
export function generatedFeature(root: string): GeneratedFeature {
|
|
const feature = path.join(root, "src/features", GENERATED_FEATURE_ID);
|
|
const module = (file: string) => JSON.stringify(pathToFileURL(path.join(feature, file)).href);
|
|
const { base, upper } = NAMES;
|
|
const source = `
|
|
const { ${upper}_FEATURE_CONTRACT: CONTRACT } = await import(${module(`contracts/${GENERATED_FEATURE_ID}-contract.ts`)});
|
|
const { ${upper}_MESSAGE_CATALOGS: CATALOGS } = await import(${module(`contracts/${base}-message-catalog.ts`)});
|
|
const { ${upper}_LIST_ITEMS_CONTRACT: LIST_ITEMS } = await import(${module(`contracts/${base}-contract-contribution.ts`)});
|
|
const { API_BASE_URL } = JSON.parse(await (await import("node:fs/promises")).readFile("config/runtime/local.json", "utf8"));
|
|
const route = (id) => ({
|
|
routeId: id,
|
|
path: CONTRACT.routes[id].path,
|
|
chunkId: CONTRACT.routes[id].chunkId,
|
|
moduleId: CONTRACT.routeRuntimeContracts[id].moduleId,
|
|
});
|
|
process.stdout.write(JSON.stringify({
|
|
list: route("${upper}_LIST"),
|
|
detail: route("${upper}_DETAIL"),
|
|
create: route("${upper}_CREATE"),
|
|
messages: CATALOGS,
|
|
api: new URL(LIST_ITEMS.contract.pathTemplate.slice(1), API_BASE_URL).href,
|
|
}));
|
|
`;
|
|
return JSON.parse(node(root, ["--input-type=module", "-e", source])) as GeneratedFeature;
|
|
}
|
|
|
|
/** A route's path with its one parameter filled in. */
|
|
export function routePath(route: GeneratedRoute, id?: string): string {
|
|
return id === undefined ? route.path : route.path.replace(/:[A-Za-z][A-Za-z0-9_]*/u, id);
|
|
}
|
|
|
|
/**
|
|
* A production build of a copy of the repository with the generated feature,
|
|
* in the local configuration. `remove` deletes the copy.
|
|
*/
|
|
export async function buildWithGeneratedFeature(prefix: string): Promise<
|
|
Readonly<{ dist: string; feature: GeneratedFeature; remove(): Promise<void> }>
|
|
> {
|
|
const root = await mkdtemp(path.join(tmpdir(), `${prefix}-`));
|
|
const remove = () => rm(root, { recursive: true, force: true });
|
|
try {
|
|
for (const entry of REMOVAL_FIXTURE_COPY_TARGETS) {
|
|
if (!existsSync(entry)) continue;
|
|
await cp(entry, path.join(root, entry), {
|
|
recursive: true,
|
|
filter: (source) => !source.includes(`${path.sep}.generated`),
|
|
});
|
|
}
|
|
await linkFixtureNodeModules(root);
|
|
await addGeneratedFeature(root);
|
|
const build = spawnSync(process.execPath, ["scripts/build-frontend.ts"], {
|
|
cwd: root,
|
|
encoding: "utf8",
|
|
env: localBuildEnvironment(),
|
|
});
|
|
if (build.status !== 0) {
|
|
throw new Error(`scripts/build-frontend.ts failed in ${root}:\n${build.stdout}\n${build.stderr}`);
|
|
}
|
|
const dist = path.join(root, "dist-generated-feature");
|
|
await rename(path.join(root, "dist"), dist);
|
|
return Object.freeze({ dist, feature: generatedFeature(root), remove });
|
|
} catch (error) {
|
|
await remove();
|
|
throw error;
|
|
}
|
|
}
|