#!/usr/bin/env node // Expansion Drop must touch only content: fail if any changed path is under an engine dir. import { execFileSync } from "node:child_process"; import { posix } from "node:path"; import { fail, readCourseConfig } from "./lib.mjs"; const [ws, baseRef] = process.argv.slice(2); if (!ws || !baseRef) fail("usage: expansion-check.mjs "); const git = (...a) => execFileSync("git", a, { cwd: ws, encoding: "utf8" }).split("\n").filter(Boolean); const cfg = readCourseConfig(ws); const changed = new Set([ ...git("diff", "--name-only", "--no-renames", "--relative", baseRef), ...git("ls-files", "--others", "--exclude-standard"), ]); const engine = (cfg.engineDirs || []).map((d) => posix.normalize(d).replace(/\/$/, "")); const bad = [...changed].filter((p) => engine.some((d) => p === d || p.startsWith(d + "/"))); if (bad.length) fail("expansion-check: engine changed during Expansion Drop\n" + bad.map((p) => " " + p).join("\n")); console.log(`expansion-check: ok (${changed.size} changed, none in engine)`);