Cotton code
22 lines · 1.2 KB · TypeScriptRaw
// The app registry a cut test hands phone-cut.sh: the real rows, with the apps the// test cuts put in development. A cut refuses any app that is not development or// production, and the real registry's phases follow the App Store records, so a// test never leans on which app happens to hold records today.import { readFileSync, writeFileSync } from "node:fs";import { join } from "node:path";/** The real registry's text with `slugs` in development, in the registry's one spelling. */export function cutRegistry(root: string, slugs: readonly string[] = ["books"]): string {  const registry = JSON.parse(readFileSync(join(root, "apps/registry.json"), "utf8")) as { apps: Array<{ slug: string; phase: string }> };  for (const slug of slugs) {    const app = registry.apps.find((a) => a.slug === slug);    if (!app) throw new Error(`no app ${slug} in apps/registry.json`);    app.phase = "development";  }  return `${JSON.stringify(registry, null, 2)}\n`;}/** Writes `cutRegistry(root, slugs)` to `dest`. */export function writeCutRegistry(root: string, dest: string, slugs: readonly string[] = ["books"]): void {  writeFileSync(dest, cutRegistry(root, slugs));}