From 50b631e4cda812972ecbec29d64a110f2a3b250e Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 5 Nov 2026 22:59:32 +0900 Subject: [PATCH] =?UTF-8?q?refactor(removal):=20=EC=A7=80=EC=9A=B8=20?= =?UTF-8?q?=EC=88=98=20=EC=9E=88=EB=8A=94=20=ED=85=9C=ED=94=8C=EB=A6=BF=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EB=AA=A9=EB=A1=9D=EC=9D=84=20=ED=95=9C=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=EC=97=90=20=EB=91=94=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제 템플릿은 지울 수 있는 기능을 둘 둔다. 참조 기능(README)과 예제 화면 기능 platform-examples-feature(starter-experience.md, CHANGELOG 6단계)다. 그 기능이 가진 경로는 제거 드릴의 SAMPLE_EXTRAS에만 있다. 그래서 문서 검사가 "이 경로는 지운 템플릿 기능의 것"을 알 길이 없다(1105/14-01, 14-03). 문서 검사가 따로 목록을 가지면 드릴과 갈라진다. 고른 방법 - scripts/lib/removable-template-features.ts에 두 기능을 적는다. 기능 ID(= src/features·tests/features 폴더 이름), 혼자 속한 context, 폴더 밖 전용 파일, 전용 package script. - 드릴은 참조 기능의 전용 파일·script를 이 모듈에서 읽는다. 목록 내용과 주석은 그대로 옮겼다. 동작은 바뀌지 않는다. - 예제 기능 항목은 다음 커밋(1105/14-01)의 문서 검사가 읽는다. 드릴은 예제 기능을 지금처럼 locateFeature로 찾는다. - 버린 대안: 문서 검사 안에 목록을 따로 두기. 드릴의 SAMPLE_EXTRAS와 두 벌이 된다. 위험·한계 - 동작 변경은 없다. 드릴 출력과 지우는 경로가 같다. 검증 - desktop batch에서 확인: corepack pnpm check:types, corepack pnpm lint, node scripts/run-vitest.ts run tests/unit/feature-removal-argument.test.ts Refs: 1105/14-01, 1105/14-03 --- scripts/lib/removable-template-features.ts | 62 ++++++++++++++++++++++ scripts/test-sample-removal.ts | 29 +++++----- 2 files changed, 74 insertions(+), 17 deletions(-) create mode 100644 scripts/lib/removable-template-features.ts diff --git a/scripts/lib/removable-template-features.ts b/scripts/lib/removable-template-features.ts new file mode 100644 index 00000000..415f56e7 --- /dev/null +++ b/scripts/lib/removable-template-features.ts @@ -0,0 +1,62 @@ +/** + * The features this template ships that a copied project may delete: the + * reference sample (README "Files you can delete after copying") and the + * example screens (docs/architecture/starter-experience.md, CHANGELOG "먼저 + * 할 일" 6). Each owns its folder under `src/features/` and `tests/features/` + * and the context it is the only feature of. The reference sample also owns + * files outside them, which `scripts/test-sample-removal.ts` deletes with it. + * + * This is the one list. The removal drill reads the reference sample's paths + * and scripts from it, and the documentation check reads the whole of it. + */ +export type RemovableTemplateFeature = Readonly<{ + /** Its FEATURE_MODULE_ID, also its folder under src/features and tests/features. */ + featureId: string; + /** The bounded context it is the only feature of; it goes with the feature. */ + contextDirectory: string; + /** Files outside those folders that only this feature uses. */ + extraPaths: readonly string[]; + /** Package scripts that only this feature uses. */ + scripts: readonly string[]; +}>; + +export const REMOVABLE_TEMPLATE_FEATURES: readonly RemovableTemplateFeature[] = Object.freeze([ + Object.freeze({ + featureId: "reference-feature", + contextDirectory: "src/contexts/reference-context", + // 0929/10-02. The HTTP scenario catalog (tests/mocks) and the negative + // type fixtures of the feature APIs run on the test contracts, so they + // are platform checks and stay (commonTestPaths in the drill). + extraPaths: Object.freeze([ + "tests/component/product-feature-switch.test.tsx", + "tests/e2e/reference-form.spec.ts", + "tests/e2e/reference-route.spec.ts", + "tests/e2e/reference-save.spec.ts", + // 11-04: the growth measurement copies this sample feature. + "tests/unit/feature-shape-growth.test.ts", + "scripts/scale/measure-feature-shape-growth.ts", + "config/scale/feature-shape-growth.json", + "config/scale/feature-shape-ceilings.json", + ]), + scripts: Object.freeze(["test:reference-feature"]), + }), + // 1103/09-04. The example screens /examples/ui, /examples/states and + // /examples/auth. The platform overview (/examples/platform) is a platform + // route and is not part of it. + Object.freeze({ + featureId: "platform-examples-feature", + contextDirectory: "src/contexts/platform-examples-context", + extraPaths: Object.freeze([]), + scripts: Object.freeze([]), + }), +]); + +/** Every path removing `feature` deletes: its folders, its context and its extra files. */ +export function removableTemplateFeaturePaths(feature: RemovableTemplateFeature): readonly string[] { + return Object.freeze([ + `src/features/${feature.featureId}`, + `tests/features/${feature.featureId}`, + feature.contextDirectory, + ...feature.extraPaths, + ]); +} diff --git a/scripts/test-sample-removal.ts b/scripts/test-sample-removal.ts index 8d91f788..8c4dbc10 100644 --- a/scripts/test-sample-removal.ts +++ b/scripts/test-sample-removal.ts @@ -29,6 +29,7 @@ import { sealRemovalFixtureRepository, type RemovalCheck, } from "./lib/removal-fixture.ts"; +import { REMOVABLE_TEMPLATE_FEATURES } from "./lib/removable-template-features.ts"; /** * 09-07 (D-10). Removes one installed feature, `--feature=` (default: the @@ -49,25 +50,19 @@ type FeatureExtras = Readonly<{ residue: RegExp; }>; +// The sample's own files and scripts outside its folders are declared with +// the other removable template features, which verify:documentation reads too. +const REFERENCE_SAMPLE = REMOVABLE_TEMPLATE_FEATURES.find( + (feature) => feature.featureId === "reference-feature", +); +if (REFERENCE_SAMPLE === undefined) { + throw new Error("scripts/lib/removable-template-features.ts does not declare reference-feature"); +} + const SAMPLE_EXTRAS: Readonly> = Object.freeze({ "reference-feature": Object.freeze({ - // 0929/10-02. The HTTP scenario catalog (tests/mocks) and the negative - // type fixtures of the feature APIs run on the test contracts, so they are - // platform checks and stay (commonTestPaths below). - paths: [ - "tests/component/product-feature-switch.test.tsx", - "tests/e2e/reference-form.spec.ts", - "tests/e2e/reference-route.spec.ts", - "tests/e2e/reference-save.spec.ts", - // 11-04: the growth measurement copies this sample feature. - "tests/unit/feature-shape-growth.test.ts", - "scripts/scale/measure-feature-shape-growth.ts", - "config/scale/feature-shape-growth.json", - "config/scale/feature-shape-ceilings.json", - ], - ciScripts: [ - "test:reference-feature", - ], + paths: REFERENCE_SAMPLE.extraPaths, + ciScripts: REFERENCE_SAMPLE.scripts, evidencePathFragments: [ "reference-feature.xml", ],