import { writeFile } from "node:fs/promises";
import { allQuestions, chapters } from "../lib/question-bank.js";

const catalog = {
  generatedFrom: "lib/question-bank.js",
  chapters: chapters.map(({ id, number }) => ({ id, number })),
  questions: Object.fromEntries(
    allQuestions.map(({ id, chapterId, xp }) => [id, { chapterId, xp }])
  )
};

await writeFile(
  new URL("../server/question-catalog.json", import.meta.url),
  `${JSON.stringify(catalog, null, 2)}\n`
);
