app/demo-repos/setup.ts
zzmq.dev@gmail.com/zz / app / demo-repos / setup.ts
@ 5e5720fb
Download
Ladder Summary
- file The script **clones** the two upstream repositories (`superagent` and `supertest`) into a `demo-repos` folder next to the file, skipping any repository that already exists so the operation is idempotent. It determines its own directory, iterates over a hard‑coded list of repo URLs, runs `git clone` via `execFileSync` for missing repos, and logs progress to the console. **Exports:** none (the file contains only top‑level side‑effect code, no functions or classes are exported).
// Clones the real repos used for the superagent/supertest demo slice.
// Idempotent: skips any repo that's already cloned.
import { execFileSync } from "node:child_process";
import { existsSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const here = dirname(fileURLToPath(import.meta.url));
// Both repos transferred orgs since this was first written: ladjs/superagent
// and visionmedia/supertest are now GitHub redirects, the real canonical
// names are under forwardemail (verified via `gh api repos/<old>` --jq
// '.full_name', which GitHub resolves to the current name even for a
// renamed repo). Clone from the canonical URL, not the redirect, since a
// redirect isn't guaranteed to hold forever if the old name is ever reused.
const repos = [
{ name: "superagent", url: "https://github.com/forwardemail/superagent.git" },
{ name: "supertest", url: "https://github.com/forwardemail/supertest.git" },
];
for (const repo of repos) {
const dest = join(here, repo.name);
if (existsSync(dest)) {
console.log(`already cloned: ${repo.name}`);
continue;
}
console.log(`cloning ${repo.name}...`);
execFileSync("git", ["clone", "--quiet", repo.url, dest], { stdio: "inherit" });
}
console.log("done.");