|
| 1 | +#!/usr/bin/env node |
| 2 | + |
| 3 | +/** |
| 4 | + * Copies required twemoji SVG files from node_modules to src-tauri/assets. |
| 5 | + * Run this as part of the build process before `tauri build`. |
| 6 | + */ |
| 7 | + |
| 8 | +import { existsSync, mkdirSync, cpSync, readdirSync } from 'node:fs'; |
| 9 | +import { dirname, join } from 'node:path'; |
| 10 | +import { fileURLToPath } from 'node:url'; |
| 11 | + |
| 12 | +const __dirname = dirname(fileURLToPath(import.meta.url)); |
| 13 | +const projectRoot = join(__dirname, '..'); |
| 14 | + |
| 15 | +const sourceDir = join( |
| 16 | + projectRoot, |
| 17 | + 'node_modules/@discordapp/twemoji/dist/svg', |
| 18 | +); |
| 19 | +const targetDir = join(projectRoot, 'src-tauri/assets/twemoji'); |
| 20 | + |
| 21 | +// Emoji codepoints used in the app (from constants.ts and utils/errors.ts) |
| 22 | +const REQUIRED_EMOJIS = [ |
| 23 | + '1f389', // 🎉 party popper |
| 24 | + '1f38a', // 🎊 confetti ball |
| 25 | + '1f3c6', // 🏆 trophy |
| 26 | + '1f3d6', // 🏖️ beach with umbrella |
| 27 | + '1f44f', // 👏 clapping hands |
| 28 | + '1f513', // 🔓 unlocked |
| 29 | + '1f52d', // 🔭 telescope |
| 30 | + '1f60e', // 😎 smiling face with sunglasses |
| 31 | + '1f62e-200d-1f4a8', // 😮💨 face exhaling |
| 32 | + '1f633', // 😳 flushed face |
| 33 | + '1f643', // 🙃 upside-down face |
| 34 | + '1f648', // 🙈 see-no-evil monkey |
| 35 | + '1f64c', // 🙌 raising hands |
| 36 | + '1f680', // 🚀 rocket |
| 37 | + '1f6dc', // 🛜 wireless |
| 38 | + '1f914', // 🤔 thinking face |
| 39 | + '1f972', // 🥲 smiling face with tear |
| 40 | + '1f973', // 🥳 partying face |
| 41 | + '1fae0', // 🫠 melting face |
| 42 | + '2728', // ✨ sparkles |
| 43 | +]; |
| 44 | + |
| 45 | +if (!existsSync(sourceDir)) { |
| 46 | + console.error(`Source directory not found: ${sourceDir}`); |
| 47 | + console.error('Run "pnpm install" first.'); |
| 48 | + process.exit(1); |
| 49 | +} |
| 50 | + |
| 51 | +// Create target directory if it doesn't exist |
| 52 | +if (!existsSync(targetDir)) { |
| 53 | + mkdirSync(targetDir, { recursive: true }); |
| 54 | +} |
| 55 | + |
| 56 | +let copied = 0; |
| 57 | +let missing = 0; |
| 58 | + |
| 59 | +for (const emoji of REQUIRED_EMOJIS) { |
| 60 | + const sourceFile = join(sourceDir, `${emoji}.svg`); |
| 61 | + const targetFile = join(targetDir, `${emoji}.svg`); |
| 62 | + |
| 63 | + if (existsSync(sourceFile)) { |
| 64 | + cpSync(sourceFile, targetFile); |
| 65 | + copied++; |
| 66 | + } else { |
| 67 | + console.warn(`Missing emoji SVG: ${emoji}`); |
| 68 | + missing++; |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +console.log(`Copied ${copied} twemoji SVG files to ${targetDir}`); |
| 73 | +if (missing > 0) { |
| 74 | + console.warn(`${missing} emoji files were not found`); |
| 75 | +} |
0 commit comments