#!/usr/bin/env node
// Orchestrator. Runs every targets/watch/Generated/*.swift generator
// in deterministic order. Imported by plugins/withWatchGenerated.js
// (so prebuild runs them) and usable directly:
//   node targets/_scripts/gen-all.mjs

import { generate as genAccents } from './gen-accent-variants.mjs'
import { generate as genBranding } from './gen-watch-branding.mjs'
import { generate as genDevAuth } from './gen-watch-devauth.mjs'
import { generate as genLetters } from './gen-tapestry-letters.mjs'
import { generate as genWindow } from './gen-tapestry-window.mjs'

export function runAll() {
  return {
    branding: genBranding(),
    letters: genLetters(),
    window: genWindow(),
    devAuth: genDevAuth(),
    accents: genAccents(),
  }
}

if (import.meta.url === `file://${process.argv[1]}`) {
  const out = runAll()
  console.log('targets/watch/Generated:')
  console.log(`  Branding.swift              ← src/lib/branding.json`)
  console.log(
    `  TapestryLetters.swift       ← src/lib/tapestry/grammar.ts (${out.letters.count} letters)`
  )
  console.log(
    `  TapestryWindow.swift        ← src/lib/tapestry/window.ts (PAGE_MINUTES=${out.window.pageMinutes})`
  )
  console.log(
    `  DevAuth.swift               ← .env.watch.local (auth ${out.devAuth.present ? 'present' : 'absent'})`
  )
  console.log(
    `  AccentVariants.swift        ← src/lib/accentVariants.ts (${out.accents.count} variants)`
  )
}
