// Copies the real per-variant dictionary DAWGs into the mock e2e preview output (dist-e2e/e2edict/) // so the offline spec can create and play a real local vs_ai game (the mock's fetchDict serves these // files — see lib/mock/client.ts). The dawgs are NEVER committed and never enter the production // build; they live only in the throwaway dist-e2e/ that `vite preview` serves for Playwright. // // Source directory: E2E_DICT_DIR — in CI the fetched scrabble-dictionary release // ($GITHUB_WORKSPACE/dawg); locally it defaults to the sibling scrabble-solver/dawg checkout. A // missing source only warns (so the other, dawg-free specs still run); the offline spec then fails // with an obvious HTTP 404 from fetchDict. import { existsSync, mkdirSync, copyFileSync } from 'node:fs'; import { join } from 'node:path'; const srcDir = process.env.E2E_DICT_DIR ?? '../../scrabble-solver/dawg'; const outDir = 'dist-e2e/e2edict'; // The app's Variant enum value -> the release dawg file name (matches the movegen/parity mapping). const dawgFor = { scrabble_en: 'en_sowpods', scrabble_ru: 'ru_scrabble', erudit_ru: 'ru_erudit', }; mkdirSync(outDir, { recursive: true }); let copied = 0; for (const [variant, file] of Object.entries(dawgFor)) { const src = join(srcDir, `${file}.dawg`); if (!existsSync(src)) { console.warn(`e2e-dict: missing ${src} — the offline spec will 404 (set E2E_DICT_DIR)`); continue; } copyFileSync(src, join(outDir, `${variant}.dawg`)); copied++; } console.log(`e2e-dict: copied ${copied}/${Object.keys(dawgFor).length} dawgs from ${srcDir} -> ${outDir}`);