import { mkdtempSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; /** Writes extra test courses to a temp dir: a restricted one and a gated one with a deck on a module. */ export async function extraCourses(): Promise { const dir = mkdtempSync(join(tmpdir(), "stc-courses-")); await Bun.write(join(dir, "secret/stcourse.yaml"), `schema: 1 id: secret title: Secret course visibility: restricted collections: [DevOps] modules: - id: m1 title: Only module lessons: - { id: s1, title: Hidden lesson, type: text, file: a.md } `); await Bun.write(join(dir, "secret/a.md"), "# Hidden\n\nwords here"); await Bun.write(join(dir, "gated/stcourse.yaml"), `schema: 1 id: gated title: Gated course pitch: Learn things in order visibility: signed-in gating: sequential collections: [DevOps, Functional programming] decks: - { id: dk, file: "Æble slides/deck one.pdf", title: Deck one, attachTo: g2 } attachments: - { file: "Æble slides/cheat sheet.pdf", title: Cheat sheet, module: g1 } modules: - id: g1 title: First lessons: - { id: g1a, title: Start here, type: text, file: "lessons/one.md" } - { id: g1b, title: Then this, type: text, file: "lessons/two.md" } - id: g2 title: Second lessons: - { id: g2a, title: Locked lesson, type: text, file: "lessons/three.md" } `); await Bun.write(join(dir, "gated/lessons/one.md"), "# One\n\nSee [two](two.md).\n"); await Bun.write(join(dir, "gated/lessons/two.md"), "# Two\n"); await Bun.write(join(dir, "gated/lessons/three.md"), "# Three\n\nsecret content"); await Bun.write(join(dir, "gated/Æble slides/deck one.pdf"), "%PDF-1.4\n"); await Bun.write(join(dir, "gated/Æble slides/cheat sheet.pdf"), "%PDF-1.4\ncheat"); return dir; }