first commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { promises as fs } from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const requiredDirs = [
|
||||
"packages/features/builder/src",
|
||||
"packages/features/recipes/src",
|
||||
"packages/shared/i18n/src"
|
||||
];
|
||||
|
||||
for (const dir of requiredDirs) {
|
||||
const absolute = path.resolve(dir);
|
||||
try {
|
||||
await fs.access(absolute);
|
||||
} catch {
|
||||
console.error(`Missing feature-first folder: ${dir}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Feature-first structure check passed");
|
||||
@@ -0,0 +1,52 @@
|
||||
import { promises as fs } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { glob } from "glob";
|
||||
|
||||
const featuresDir = path.resolve("specs/features");
|
||||
const featureFiles = await glob(path.join(featuresDir, "*.feature"));
|
||||
|
||||
/** Tags @int-* portés par les scénarios (intégration Vitest). */
|
||||
const intTags = new Set();
|
||||
|
||||
for (const file of featureFiles) {
|
||||
const text = await fs.readFile(file, "utf8");
|
||||
for (const line of text.split("\n")) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed.startsWith("@")) continue;
|
||||
const parts = trimmed.split(/\s+/);
|
||||
for (const token of parts) {
|
||||
if (token.startsWith("@int-")) intTags.add(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const intTestFiles = await glob(["packages/**/*.int.test.ts", "apps/**/*.int.test.ts"], {
|
||||
nodir: true
|
||||
});
|
||||
|
||||
const merged = (
|
||||
await Promise.all(intTestFiles.map(async (f) => ({ file: f, body: await fs.readFile(f, "utf8") })))
|
||||
).reduce((acc, { file, body }) => {
|
||||
acc.set(file, body);
|
||||
return acc;
|
||||
}, new Map());
|
||||
|
||||
const missing = [];
|
||||
for (const tag of intTags) {
|
||||
let found = false;
|
||||
for (const body of merged.values()) {
|
||||
if (body.includes(tag)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) missing.push(tag);
|
||||
}
|
||||
|
||||
if (missing.length > 0) {
|
||||
console.error("Scénarios @int-* sans référence dans un fichier *.int.test.ts :");
|
||||
for (const tag of missing.sort()) console.error(` ${tag}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`Gherkin ↔ intégration OK (${intTags.size} tag(s) @int-* couverts dans ${intTestFiles.length} fichier(s))`);
|
||||
@@ -0,0 +1,13 @@
|
||||
import { promises as fs } from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const featuresDir = path.resolve("specs/features");
|
||||
const files = await fs.readdir(featuresDir);
|
||||
const featureFiles = files.filter((file) => file.endsWith(".feature"));
|
||||
|
||||
if (featureFiles.length < 2) {
|
||||
console.error("At least two feature files are required");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`Gherkin check passed (${featureFiles.length} files)`);
|
||||
@@ -0,0 +1,12 @@
|
||||
import { promises as fs } from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const target = path.resolve("packages/features/builder/src/domain.ts");
|
||||
const content = await fs.readFile(target, "utf8");
|
||||
|
||||
if (!content.includes("Readonly<") || !content.includes("Object.freeze")) {
|
||||
console.error("Immutability check failed in builder domain");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log("Immutability check passed");
|
||||
@@ -0,0 +1,17 @@
|
||||
import { glob } from "glob";
|
||||
|
||||
/** Pas de fichiers barrel `src/index.ts` dans les packages métier (imports explicites uniquement). */
|
||||
const candidates = await glob([
|
||||
"packages/features/*/src/index.ts",
|
||||
"packages/features/*/src/index.tsx",
|
||||
"packages/shared/*/src/index.ts",
|
||||
"packages/shared/*/src/index.tsx"
|
||||
]);
|
||||
|
||||
if (candidates.length > 0) {
|
||||
console.error("Barrel index.ts/tsx interdits — supprimer ou renommer en modules nommés :");
|
||||
for (const file of candidates.sort()) console.error(` ${file}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log("No barrel index files under packages/features or packages/shared");
|
||||
Reference in New Issue
Block a user