import { readFileSync } from "node:fs"; /** `src/Git.ts` as written: the one source the structural tests read the service's surface from. */ export const gitSource = readFileSync(new URL("../src/Git.ts", import.meta.url), "utf8"); /** * Each `GitShape` member, read from the interface's own text, and whether its TSDoc opens `Mutating:`. The structural * tests compare other views of the surface (the `makeTest` double, the shape `make` returns, the mutating tuple) * against this one, so a new member costs no edit in any of them. */ export const shapeMembers = (): ReadonlyMap => { const start = gitSource.indexOf("export interface GitShape {"); const body = gitSource.slice(start, gitSource.indexOf("\n}\n", start)); const members = new Map(); for (const match of body.matchAll(/\/\*\*([\s\S]*?)\*\/\s*readonly (\w+):/g)) { const doc = (match[1] ?? "").replace(/^\s*\* ?/gm, "").trim(); members.set(match[2] ?? "", doc.startsWith("Mutating:")); } return members; }; /** * The fewest members a parse of `GitShape` may find: a guard against a walk that finds nothing, which would pass every * comparison. Well under the real count, so adding a member never touches it. */ export const SHAPE_FLOOR = 90;