mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
scripts/generate-content-types.ts writes the gitignored src/types/content-ids.ts (id unions + project category values) from the four structure documents; wired as generate:ids / predev / prebuild / prepare. src/types/index.ts re-exports them type-only and keeps only the code-owned unions. Edit mode now writes JSON only: the v4 union leg is deleted (saveIdUnions, diffIdsWithUnions, applyUnionChanges, readUnionBlock, the EditBar union card, edit.union.* labels). Validator rule 7 requires a label for every category a project uses, in both ui/projects.json documents. Tests: smoke-draft.ts 11/11 (rename re-sluging + category-label rule replace checks 9-12); new scripts/smoke-generated-ids.ts 7/7. Verified: pnpm build (chunk names unchanged, no runtime reference to the generated module), lint with no new warnings, validate:content, resume HTML byte-identical before/after with identical documents. Docs: spec-v5-generated-content-ids.md added; spec-v4-live-edit.md §3.1 marked superseded + §12 row 23; AGENTS.md and README.md updated.
52 lines
2.1 KiB
TypeScript
52 lines
2.1 KiB
TypeScript
// CLI over the shared validator (spec-v4 §3.6, spec-v4-data-organization §5.1):
|
|
// the CI build gate and, from Phase 3 on, the save gate. A malformed content
|
|
// or manifest document fails here with exact file paths, so the last good
|
|
// deploy stays live.
|
|
import { experiences } from '../src/data/experience';
|
|
import { profile } from '../src/data/profile';
|
|
import { projects } from '../src/data/projects';
|
|
import { skillGroups } from '../src/data/skills';
|
|
import experienceEnJson from '../src/i18n/locales/en/content/experience.json';
|
|
import experienceViJson from '../src/i18n/locales/vi/content/experience.json';
|
|
import profileEnJson from '../src/i18n/locales/en/content/profile.json';
|
|
import profileViJson from '../src/i18n/locales/vi/content/profile.json';
|
|
import projectsEnJson from '../src/i18n/locales/en/content/projects.json';
|
|
import projectsViJson from '../src/i18n/locales/vi/content/projects.json';
|
|
import skillsEnJson from '../src/i18n/locales/en/content/skills.json';
|
|
import skillsViJson from '../src/i18n/locales/vi/content/skills.json';
|
|
import { UI } from '../src/i18n';
|
|
import type { ContentEn, ContentVi } from '../src/i18n/dict-types';
|
|
import { collectContentIssues, collectManifestIssues } from '../src/i18n/validate';
|
|
|
|
const contentVi: ContentVi = {
|
|
profile: profileViJson,
|
|
skills: skillsViJson,
|
|
experience: experienceViJson,
|
|
projects: projectsViJson,
|
|
};
|
|
const contentEn: ContentEn = {
|
|
profile: profileEnJson,
|
|
skills: skillsEnJson,
|
|
experience: experienceEnJson,
|
|
projects: projectsEnJson,
|
|
};
|
|
|
|
const structures = { profile, skills: skillGroups, experience: experiences, projects };
|
|
|
|
const issues = [
|
|
...collectContentIssues(structures, contentVi, contentEn, {
|
|
vi: UI.vi.projects.categories,
|
|
en: UI.en.projects.categories,
|
|
}),
|
|
...collectManifestIssues(structures, contentVi, contentEn, Object.keys(UI.vi)),
|
|
];
|
|
|
|
if (issues.length > 0) {
|
|
console.error(`content validation failed (${issues.length} issue(s)):`);
|
|
for (const issue of issues) {
|
|
console.error(` ${issue.path}: ${issue.message}`);
|
|
}
|
|
process.exit(1);
|
|
}
|
|
console.log('content documents valid');
|