#!/usr/bin/env node /** * One-shot migration: replace raw Tailwind neutral-palette + white-alpha * utilities with theme tokens across the unified Mana web app. * * This is a surgical codemod, not a general-purpose tool. The mappings * encode a specific design decision: `bg-gray-800` = `bg-card`, etc. * Re-running is a no-op once the codebase is clean. * * Usage: * node scripts/migrate-theme-tokens.mjs [--dry-run] * * The mappings are ordered by specificity — longer patterns first so * `bg-gray-700/50` is tried before `bg-gray-700`. */ import { execSync } from 'node:child_process'; import { readFileSync, writeFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import { dirname, join } from 'node:path'; const __dirname = dirname(fileURLToPath(import.meta.url)); const REPO_ROOT = join(__dirname, '..'); const DRY_RUN = process.argv.includes('--dry-run'); const SCAN_GLOBS = [ 'apps/mana/apps/web/src/lib/modules/**/*.svelte', 'apps/mana/apps/web/src/routes/(app)/**/*.svelte', ]; /** * Files where `bg-white/N`, `text-white/N`, etc. are brand-literal overlays * on vivid gradient backgrounds, not theme-intent. These stay untouched * and are allowlisted in the validator via scoped