#!/usr/bin/env node import { execFileSync } from "node:child_process"; import { existsSync } from "node:fs"; import { mkdir, readFile } from "node:fs/promises"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; const org = "storytold"; const scriptDir = dirname(fileURLToPath(import.meta.url)); const config = JSON.parse(await readFile(join(scriptDir, "config.json"), "utf8")); const upstream = join(scriptDir, "upstream"); await mkdir(upstream, { recursive: true }); let failed = 0; for (const app of config.repos) { const dir = join(upstream, app); const args = existsSync(dir) ? ["-C", dir, "fetch", "origin", "--tags"] : ["clone", `https://github.com/${org}/${app}`, dir]; try { execFileSync("git", args, { stdio: "inherit" }); } catch { failed++; console.error(`${app}: git ${args[0] === "-C" ? "fetch" : "clone"} failed`); } } process.exit(failed ? 1 : 0);