#!/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);