test(fixtures): local-draft 샘플을 IndexedDB 소비자 fixture로 옮긴다
src/features/local-draft-feature는 기능이 아니라 IndexedDB recipe의 소비자다. 시험 5개와 recipe가 쓰고, 그래서 생성기에 NOT_A_FEATURE 예외가 있었다(S4 3.1절 S-3). 코드를 tests/fixtures/indexeddb-consumer/로 옮기고 import만 고쳤다. NOT_A_FEATURE 표식은 이 폴더만 썼고 다운스트림 둘에도 없어 생성기에서 지웠다. 선언 없는 폴더는 밖으로 옮기라는 메시지로 실패한다. 매뉴얼 오류표, README, starter-experience, capability-consumer-experience, patterns를 고쳤다. 위험: fixture는 기능 폴더 밖이라 기능 계층 규칙(dependency-cruiser)이 걸리지 않는다. recipe가 tests/ 아래 파일을 type import한다. 검증(desktop): test:contract, test:recipes, test:browser-capabilities, test:unit 통과.
This commit is contained in:
@@ -272,22 +272,15 @@ function requiredInteger(source: string, name: string, file: string): number {
|
||||
}
|
||||
|
||||
/**
|
||||
* 09-07 (D-10). A feature directory must declare itself or say it is not a
|
||||
* feature. A missing or misspelt `feature-module.ts` used to drop the
|
||||
* feature from the product without a word.
|
||||
*
|
||||
* 1103/09-09. The marker was named `NOT_INSTALLED`, the runtime state of a
|
||||
* declared feature the build or the runtime document left out
|
||||
* (`src/contracts/product-features.ts`). It marks something else, a directory
|
||||
* that is no feature at all (an architecture sample), so it has its own name,
|
||||
* and a directory may not carry both the marker and a declaration.
|
||||
* 09-07 (D-10). A feature directory must declare itself. A missing or
|
||||
* misspelt `feature-module.ts` used to drop the feature from the product
|
||||
* without a word. Code that is no feature (a test's consumer fixture) lives
|
||||
* outside src/features.
|
||||
*/
|
||||
export const NOT_A_FEATURE_MARKER = "NOT_A_FEATURE";
|
||||
|
||||
async function readDeclarations(
|
||||
directory: string,
|
||||
fileName: string,
|
||||
requiredUnless?: string,
|
||||
required = false,
|
||||
): Promise<readonly Readonly<{ directory: string; file: string; source: string }>[]> {
|
||||
const found: { directory: string; file: string; source: string }[] = [];
|
||||
let items;
|
||||
@@ -299,24 +292,13 @@ async function readDeclarations(
|
||||
for (const item of items) {
|
||||
if (!item.isDirectory()) continue;
|
||||
const file = resolve(directory, item.name, fileName);
|
||||
const marker =
|
||||
requiredUnless !== undefined &&
|
||||
(await readFile(resolve(directory, item.name, requiredUnless)).then(
|
||||
() => true,
|
||||
() => false,
|
||||
));
|
||||
let source: string;
|
||||
try {
|
||||
source = await readFile(file, "utf8");
|
||||
} catch {
|
||||
if (requiredUnless === undefined || marker) continue;
|
||||
if (!required) continue;
|
||||
throw new Error(
|
||||
`src/features/${item.name} has no ${fileName}; add one or mark the directory with ${requiredUnless}`,
|
||||
);
|
||||
}
|
||||
if (marker) {
|
||||
throw new Error(
|
||||
`src/features/${item.name} has both ${fileName} and ${requiredUnless}; delete ${requiredUnless} to install it, or ${fileName} to keep it out`,
|
||||
`src/features/${item.name} has no ${fileName}; add one, or keep code that is no feature outside src/features`,
|
||||
);
|
||||
}
|
||||
found.push({ directory: item.name, file, source });
|
||||
@@ -368,7 +350,7 @@ export async function createFileSystemDeclarationSource(
|
||||
for (const declaration of await readDeclarations(
|
||||
resolve(root, "src/features"),
|
||||
"feature-module.ts",
|
||||
NOT_A_FEATURE_MARKER,
|
||||
true,
|
||||
)) {
|
||||
const feature: FeatureDeclaration = {
|
||||
id: requiredLiteral(declaration.source, "FEATURE_MODULE_ID", declaration.file),
|
||||
|
||||
Reference in New Issue
Block a user