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", ],