Repository Public
1/**2 * pnpm content:import [--from <course-repo>] [--check]3 * Regenerates content/import/** and content/course.manifest.json from the curriculum repository and4 * content/publication.json. `--check` writes nothing and exits 1 if the snapshot is out of date.5 */6import { readFile } from "node:fs/promises";7import { resolve } from "node:path";8import { importCourse } from "./lib/importer";910const args = process.argv.slice(2);11const flag = (name: string) => { const i = args.indexOf(name); return i >= 0 ? args[i + 1] : undefined; };12const repo = flag("--from") ?? process.env.ATLAS_COURSE_REPO;13const check = args.includes("--check");14if (!repo) { console.error("Indiquer le dépôt du cours : --from <chemin> ou ATLAS_COURSE_REPO."); process.exit(2); }1516const out = resolve("content");17const publication = JSON.parse(await readFile(resolve(out, "publication.json"), "utf8"));18const { manifest, report, written, removed, unchanged } = await importCourse({ repo, out, publication, dryRun: check });1920for (const s of report.sessions) {21 const state = manifest.sessions.find((m) => m.id === s.id)!.publication;22 console.log(`${s.id} source=${s.status.padEnd(11)} état=${state.padEnd(9)} importé=[${s.imported.join(", ")}]`);23 for (const w of s.warnings) console.log(` ⚠ ${w}`);24}25for (const w of report.warnings) console.log(`⚠ ${w}`);26console.log(`\nEmpreinte de la source : ${report.sourceHash.slice(0, 16)}… · ${written.length} fichier(s) ${check ? "à écrire" : "écrit(s)"}, ${removed.length} ${check ? "à retirer" : "retiré(s)"}, ${unchanged} inchangé(s).`);27if (check && (written.length || removed.length)) { console.error("L'instantané n'est pas à jour : lancer pnpm content:import."); process.exit(1); }28