문제: 기능 하나를 더하면 템플릿 추적 파일 두 개가 바뀐다.
create:feature가 public/release-manifest.json(dev server manifest)의
setDigest·packages를 다시 쓰고, 참조 기능이 있는 동안은 초기 JS 기록
(config/scale/feature-shape-ceilings.json initialJavascript)을 명령으로 다시
써야 한다. 03 문서 A절은 "생성 명령이 쓰는 폴더 밖 파일은 둘"(context 선언,
a11y 기록)이라고만 적고, 정본 표(starter-experience.md "Adding a feature")에도
두 파일이 없다. 기능 브랜치 둘은 같은 setDigest 줄을 다른 값으로 바꿔
충돌하는데, 어떻게 푸는지는 test:unit 실패 문구에만 있다.
고른 방법(리뷰 대안 (a)): 문서와 생성 출력에 두 파일, 쓰는 주체, 다시 쓰는
명령, 충돌 처리("아무 쪽이나 고르고 명령을 다시 돌린다")를 적는다.
- scripts/create-feature.ts에 FEATURE_TRACKED_FILE_REWRITES(경로·명령)를
두고 생성 출력이 충돌 처리 줄에 쓴다.
- 03 A절에 표와 충돌 단락, "기능을 지울 때"에 초기 JS 기록 재작성, 정본 표에
두 행, 01 1단계 흐름에 manifest 재작성 줄을 더했다.
- 새 단위 테스트가 그 상수의 파일·명령이 03 A절과 정본 표에 있는지 본다.
초기 JS 기록과 그 측정 스크립트 경로는 참조 기능과 함께 지워지므로 문서에서
백틱 없이 적었다(performance-evidence.md와 같은 규칙, 제거 드릴의
verify:documentation).
버린 대안(이번에 하지 않음, 결정 대기):
- (b) dev manifest를 생성 파일로 두고(.gitignore) dev·Playwright 시작 전에
만들기: 커밋 줄이 사라지지만 dev 스크립트와 Playwright webServer 명령을
바꿔야 한다. Playwright 설정은 다른 작업(12-04)이 고치는 중이다.
- (d) 초기 JS 기록이 템플릿 자신의 값만 담게 측정에서 설치된 제품 기능을
빼기: 측정 스크립트가 어떤 기능이 템플릿 것인지 알아야 한다.
위험·한계: 충돌 자체는 남는다. 두 기능 브랜치를 합칠 때 사람이 명령을 다시
돌려야 한다. 완료 기준의 둘째 길("03 A절·정본 표가 두 파일과 충돌 처리
명령을 적는다")만 채운다. 실제 두 브랜치 git merge로 재현하지 않았다.
테스트는 문서를 읽으므로, 문서를 복사하지 않는 기능 제거 드릴에서는 돌지
않는다(`scripts/lib/removal-fixture.ts`의 문서 테스트 목록).
검증: desktop batch에서 확인.
node scripts/run-vitest.ts run tests/unit/feature-tracked-files.test.ts
corepack pnpm verify:documentation
corepack pnpm test:realtime-removal
Refs: 1105/16-01
59 lines
2.4 KiB
TypeScript
59 lines
2.4 KiB
TypeScript
import { readFile } from "node:fs/promises";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { FEATURE_TRACKED_FILE_REWRITES } from "../../scripts/create-feature.ts";
|
|
|
|
/**
|
|
* 1105/16-01. Adding a feature changes two tracked template files: the dev
|
|
* server's manifest (`create:feature` rewrites it) and, while the sample is
|
|
* installed, the initial JavaScript record (rewritten by command). The 03
|
|
* manual's section A said the command writes two files outside the feature
|
|
* folder and named neither, the canonical table in starter-experience.md
|
|
* had neither, and nothing said what to do when two feature branches change
|
|
* the same `setDigest` line. The documents name each file with the command
|
|
* that rewrites it, which is also how a merge conflict on it is resolved.
|
|
*/
|
|
function between(text: string, start: string, end: string): string {
|
|
const from = text.indexOf(start);
|
|
const to = text.indexOf(end, from + start.length);
|
|
if (from < 0 || to < 0) throw new Error(`no section from "${start}" to "${end}"`);
|
|
return text.slice(from, to);
|
|
}
|
|
|
|
describe("tracked files a feature changes (1105/16-01)", () => {
|
|
it("lists the generator's tracked rewrites", () => {
|
|
expect(FEATURE_TRACKED_FILE_REWRITES.map((file) => file.path)).toEqual([
|
|
"public/release-manifest.json",
|
|
"config/scale/feature-shape-ceilings.json",
|
|
]);
|
|
});
|
|
|
|
it("names each file and its rewrite command in the 03 manual's section A", async () => {
|
|
const section = between(
|
|
await readFile("docs/manual/03-outside-feature-folder.md", "utf8"),
|
|
"## A. 생성 명령이 만든다",
|
|
"## B. ",
|
|
);
|
|
for (const file of FEATURE_TRACKED_FILE_REWRITES) {
|
|
expect(section, file.path).toContain(file.path);
|
|
expect(section, file.path).toContain(file.command);
|
|
}
|
|
expect(section).toMatch(/충돌/u);
|
|
});
|
|
|
|
it("names each file and its rewrite command in the canonical table", async () => {
|
|
const table = between(
|
|
await readFile("docs/architecture/starter-experience.md", "utf8"),
|
|
"Files outside the feature directory.",
|
|
"The central catalogs",
|
|
);
|
|
for (const file of FEATURE_TRACKED_FILE_REWRITES) {
|
|
const row = table.split("\n").find((line) => line.startsWith("|") && line.includes(file.path));
|
|
expect(row, file.path).toBeDefined();
|
|
expect(row, file.path).toContain(file.command);
|
|
expect(row, file.path).toMatch(/merge conflict/u);
|
|
}
|
|
});
|
|
});
|