AI Resource Pro / website / scripts / update-category-icons.ts
| 1 | import { spawn } from 'child_process'; |
| 2 | import path from 'path'; |
| 3 | import { fileURLToPath } from 'url'; |
| 4 | |
| 5 | const __filename = fileURLToPath(import.meta.url); |
| 6 | const __dirname = path.dirname(__filename); |
| 7 | |
| 8 | /** |
| 9 | * Script to update category icons in the database |
| 10 | * This runs the seed-supabase.ts script with a focus on updating emoji icons to Lucide React icons |
| 11 | */ |
| 12 | async function main() { |
| 13 | console.log('Starting category icon update...'); |
| 14 | |
| 15 | // Run the seed-supabase.ts script |
| 16 | const seedScript = path.join(__dirname, 'seed-supabase.ts'); |
| 17 | |
| 18 | const child = spawn('npx', ['ts-node', '--esm', seedScript], { |
| 19 | stdio: 'inherit', |
| 20 | shell: true |
| 21 | }); |
| 22 | |
| 23 | return new Promise((resolve, reject) => { |
| 24 | child.on('close', (code) => { |
| 25 | if (code === 0) { |
| 26 | console.log('Category icon update completed successfully'); |
| 27 | resolve(null); |
| 28 | } else { |
| 29 | console.error(`Category icon update failed with code ${code}`); |
| 30 | reject(new Error(`Process exited with code ${code}`)); |
| 31 | } |
| 32 | }); |
| 33 | |
| 34 | child.on('error', (err) => { |
| 35 | console.error('Error running seed script:', err); |
| 36 | reject(err); |
| 37 | }); |
| 38 | }); |
| 39 | } |
| 40 | |
| 41 | main() |
| 42 | .then(() => process.exit(0)) |
| 43 | .catch((error) => { |
| 44 | console.error('Unhandled error:', error); |
| 45 | process.exit(1); |
| 46 | }); |