nomadro/apps/work/scripts/fetch-upstream.mjs
Eric 2b574f7957 Ship native /social/work: Planka-shaped boards + Etherpad pads on FastAPI.
Secondary-dev Next UI with DnD, labels, stopwatch, archive, activity; pads with revisions; README documents pnpm dev:work-api.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-04 01:06:26 +08:00

55 lines
1.4 KiB
JavaScript

#!/usr/bin/env node
/**
* Shallow-clone Planka + Etherpad into apps/work/upstream/
* for secondary development. Does not commit upstream into git.
*/
import { spawnSync } from "node:child_process";
import { existsSync, mkdirSync, rmSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
const upstream = join(root, "upstream");
const REPOS = [
{
name: "planka",
url: "https://github.com/plankanban/planka.git",
branch: "master",
},
{
name: "etherpad",
url: "https://github.com/ether/etherpad.git",
branch: "master",
},
];
mkdirSync(upstream, { recursive: true });
function run(cmd, args, cwd) {
console.log(`$ ${cmd} ${args.join(" ")}`);
const r = spawnSync(cmd, args, { cwd, stdio: "inherit", shell: false });
if (r.status !== 0) process.exit(r.status || 1);
}
for (const repo of REPOS) {
const dest = join(upstream, repo.name);
if (existsSync(join(dest, ".git"))) {
console.log(`[skip] ${repo.name} already cloned — pull --ff-only`);
run("git", ["-C", dest, "pull", "--ff-only", "origin", repo.branch]);
continue;
}
if (existsSync(dest)) rmSync(dest, { recursive: true, force: true });
run("git", [
"clone",
"--depth",
"1",
"--branch",
repo.branch,
repo.url,
dest,
]);
}
console.log("DONE fetch-upstream →", upstream);