#!/usr/bin/env node // One-off: add frameId + matteId to every TransformPair entry in // app/data/transformPairs.ts, inferred from the medium string. Idempotent — // skips pairs that already carry frameId. // // Lookup table is per-pair-id (the `n:` field). Frame mapping rationale: // - "ivory frame" / "white frame" → 'white' // - "gilt frame" / "gold frame" → 'gold' // - "walnut frame" → 'walnut' // - "oak frame" → 'oak' // - "matte black frame" / "black frame" → 'black' // Matte choices favour 'warmwhite' for gold + walnut frames (warm-on-warm), // 'snowwhite' for cool/neutral frames, and a few overrides per style. import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const FILE = path.resolve(__dirname, '..', 'app/data/transformPairs.ts'); const FRAME_MATTE = { '01': { frame: 'white', matte: 'warmwhite' }, // Teddy — impasto, ivory '02': { frame: 'white', matte: 'warmwhite' }, // Otto — landscape oil, ivory '03': { frame: 'white', matte: 'snowwhite' }, // Pepper — pop art, ivory '04': { frame: 'white', matte: 'snowwhite' }, // Cooper — vector, ivory '05': { frame: 'white', matte: 'snowwhite' }, // Bowie — pop art, ivory '06': { frame: 'walnut', matte: 'snowwhite' }, // Koda — named portrait '07': { frame: 'white', matte: 'snowwhite' }, // Maple — watercolor, ivory '08': { frame: 'white', matte: 'snowwhite' }, // Juno — line drawing, ivory '09': { frame: 'white', matte: 'snowwhite' }, // Clover — watercolor, ivory (was Henry — royal, retired) '10': { frame: 'white', matte: 'warmwhite' }, // Otis — cubist, ivory '11': { frame: 'white', matte: 'warmwhite' }, // Sakura — ukiyo-e, ivory '12': { frame: 'gold', matte: 'warmwhite' }, // Tenzin — thangka, gilt '13': { frame: 'white', matte: 'snowwhite' }, // Sable — charcoal, ivory '14': { frame: 'white', matte: 'snowwhite' }, // Marlow — watercolor, white '15': { frame: 'white', matte: 'snowwhite' }, // Mortimer — vector, ivory (was Major — royal, retired) '16': { frame: 'white', matte: 'snowwhite' }, // Clover — charcoal, white '17': { frame: 'walnut', matte: 'warmwhite' }, // Wren — ukiyo-e, walnut '18': { frame: 'black', matte: 'snowwhite' }, // Hamlet — pop art, matte black '19': { frame: 'oak', matte: 'snowwhite' }, // Mortimer — vector, oak '20': { frame: 'walnut', matte: 'warmwhite' }, // Quill — mixed-media, walnut '21': { frame: 'white', matte: 'snowwhite' }, // Clover — watercolor, white '22': { frame: 'black', matte: 'snowwhite' }, // Major — line drawing, black '23': { frame: 'oak', matte: 'snowwhite' }, // Marlow — cubist, oak '24': { frame: 'gold', matte: 'warmwhite' }, // Mortimer — thangka, gold '25': { frame: 'walnut', matte: 'warmwhite' }, // Hamlet — modern portrait, walnut '26': { frame: 'oak', matte: 'snowwhite' }, // Murph — risograph '27': { frame: 'walnut', matte: 'snowwhite' }, // Suki — risograph '28': { frame: 'white', matte: 'snowwhite' }, // Chip — risograph '29': { frame: 'walnut', matte: 'warmwhite' }, // Frank — at home '30': { frame: 'oak', matte: 'warmwhite' }, // Marmalade — at home '31': { frame: 'walnut', matte: 'warmwhite' }, // Popcorn — at home '32': { frame: 'black', matte: 'black' }, // Rex — neo-expressionist '33': { frame: 'black', matte: 'snowwhite' }, // Iggy — neo-expressionist '34': { frame: 'black', matte: 'black' }, // Capy — neo-expressionist }; let content = fs.readFileSync(FILE, 'utf8'); let changed = 0; let skipped = 0; // Match each pair object — from `n: 'NN',` up to (but not including) the // `tilt:` line. We insert frameId/matteId right before `tilt:`. content = content.replace( /(\n {4}n: '(\d{2})',\n)([\s\S]*?)( {4}tilt: )/g, (match, header, n, body, tiltLine) => { const fm = FRAME_MATTE[n]; if (!fm) { console.warn(` no frame/matte entry for n='${n}' — skipping`); skipped++; return match; } if (/frameId:/.test(body)) { skipped++; return match; } changed++; const insertion = ` frameId: '${fm.frame}',\n matteId: '${fm.matte}',\n`; return header + body + insertion + tiltLine; }, ); fs.writeFileSync(FILE, content); console.log(`Done. ${changed} pairs updated, ${skipped} pairs skipped (already had frameId or no entry).`);