#!/usr/bin/env bun /** * Generates MISSING.yml — same structure as FOLDERS.yml but only listing * packages whose directories do not yet exist on disk. * Run: bun scripts/generate-missing.ts */ import { existsSync, writeFileSync } from "node:fs"; import { join, resolve } from "node:path"; import { parse as parseYaml, stringify as stringifyYaml } from "yaml"; const ROOT = resolve(import.meta.dir, ".."); const foldersPath = join(ROOT, "FOLDERS.yml"); type FoldersYml = Record>; const folders = parseYaml(await Bun.file(foldersPath).text()) as FoldersYml; const missing: FoldersYml = {}; let totalPackages = 0; let completedCount = 0; let missingCount = 0; for (const [top, domains] of Object.entries(folders)) { for (const [domain, pkgs] of Object.entries(domains)) { const missingPkgs: string[] = []; for (const name of pkgs) { totalPackages++; const pkgDir = join(ROOT, top, domain, name); if (existsSync(pkgDir)) { completedCount++; } else { missingPkgs.push(name); missingCount++; } } if (missingPkgs.length > 0) { if (!missing[top]) missing[top] = {}; missing[top][domain] = missingPkgs; } } } const header = [ "# MISSING — packages not yet created on disk.", "# Auto-generated by scripts/generate-missing.ts — do not edit manually.", "# Re-run after landing a new package to refresh.", "", ].join("\n"); const yaml = stringifyYaml(missing, { lineWidth: 100, defaultKeyType: "PLAIN", defaultStringType: "PLAIN", }); const outPath = join(ROOT, "MISSING.yml"); writeFileSync(outPath, header + yaml, "utf8"); console.log(`Wrote ${outPath}`); console.log(` ${totalPackages} total packages`); console.log(` ${completedCount} completed`); console.log(` ${missingCount} missing`);