zz_

app/demo/dump-ladder.ts

zzmq.dev@gmail.com/zz / app / demo / dump-ladder.ts @ 2a73adc2 Download
Ladder Summary
  • file This script is a small CLI tool that takes a repository name as an argument, locates that demo repository and its state directory, calls the **`renderLadder(repoDir, stateDir)`** function (imported from `../engine/ladderRender.js`) to materialize the repo’s ladder data stored in Git notes into a readable plain‑text representation, and writes that output (prefixed with a header showing statistics) to `state/<repo-name>/ladder.txt`. The file does not export any functions or classes itself—it only executes the described logic when run.
 // Materializes a repo's Ladder (stored as git notes, not easy to browse
 // directly) into one flat, readable text file. A dump for a human to look
 // at, not a second source of truth; re-run any time after the real notes
 // change, since this always reads live from the repo's own notes refs.
 import { writeFileSync } from "node:fs";
 import { dirname, join } from "node:path";
 import { fileURLToPath } from "node:url";
 import { renderLadder } from "../engine/ladderRender.js";
 
 const repoName = process.argv[2];
 if (!repoName) {
  console.error("usage: tsx demo/dump-ladder.ts <repo-name> (e.g. supertest)");
  process.exit(1);
 }
 
 const here = dirname(fileURLToPath(import.meta.url));
 const repoDir = join(here, "..", "demo-repos", repoName);
 const stateDir = join(here, "..", "state", repoName);
 const outPath = join(stateDir, "ladder.txt");
 
 const { text, stats } = await renderLadder(repoDir, stateDir);
 const header = `# Ladder dump for ${repoName}\n# ${stats.rungs} rungs, from ${stats.notes} git notes. Generated ${new Date().toISOString()}.\n# This is a materialized view for reading; the real data lives in refs/notes/zz/ladder/* inside ${repoDir}.\n\n`;
 
 writeFileSync(outPath, header + text + "\n");
 console.log(`wrote ${outPath} (${stats.rungs} rungs, ${stats.notes} notes)`);