|
|
import { writeFileSync, mkdirSync } from 'fs'; |
|
|
import { fileURLToPath } from 'url'; |
|
|
import { dirname, join } from 'path'; |
|
|
|
|
|
const __filename = fileURLToPath(import.meta.url); |
|
|
const __dirname = dirname(__filename); |
|
|
|
|
|
// Icons we need to extract |
|
|
const icons = [ |
|
|
'zap', // ⚡ |
|
|
'heart', // ❤️ |
|
|
'chevron-up', // ⬆️ |
|
|
'chevron-down', // ⬇️ |
|
|
'sun', // ☀️ |
|
|
'moon', // 🌙 |
|
|
'user', // 👤 |
|
|
'plus' // ➕ |
|
|
]; |
|
|
|
|
|
const staticDir = join(__dirname, '..', 'static', 'icons'); |
|
|
mkdirSync(staticDir, { recursive: true }); |
|
|
|
|
|
// Import lucide-svelte to get the icon paths |
|
|
try { |
|
|
const lucide = await import('lucide-svelte'); |
|
|
|
|
|
for (const iconName of icons) { |
|
|
// Convert kebab-case to PascalCase |
|
|
const componentName = iconName |
|
|
.split('-') |
|
|
.map(word => word.charAt(0).toUpperCase() + word.slice(1)) |
|
|
.join(''); |
|
|
|
|
|
// Get the icon component |
|
|
const IconComponent = lucide[componentName]; |
|
|
|
|
|
if (!IconComponent) { |
|
|
console.warn(`Icon ${iconName} (${componentName}) not found`); |
|
|
continue; |
|
|
} |
|
|
|
|
|
// Extract SVG path from the component |
|
|
// Lucide icons are SVG components, we need to render them to get the path |
|
|
// For now, let's use the known SVG paths from lucide |
|
|
const svgPaths = { |
|
|
'zap': '<path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/>', |
|
|
'heart': '<path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.29 1.51 4.04 3 5.5l7 7Z"/>', |
|
|
'chevron-up': '<path d="m18 15-6-6-6 6"/>', |
|
|
'chevron-down': '<path d="m6 9 6 6 6-6"/>', |
|
|
'sun': '<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>', |
|
|
'moon': '<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>', |
|
|
'user': '<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/>', |
|
|
'plus': '<path d="M5 12h14"/><path d="M12 5v14"/>' |
|
|
}; |
|
|
|
|
|
const path = svgPaths[iconName]; |
|
|
if (!path) { |
|
|
console.warn(`No SVG path found for ${iconName}`); |
|
|
continue; |
|
|
} |
|
|
|
|
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${path}</svg>`; |
|
|
|
|
|
const filePath = join(staticDir, `${iconName}.svg`); |
|
|
writeFileSync(filePath, svg, 'utf-8'); |
|
|
console.log(`Extracted ${iconName}.svg`); |
|
|
} |
|
|
|
|
|
console.log('All icons extracted successfully!'); |
|
|
} catch (error) { |
|
|
console.error('Error extracting icons:', error); |
|
|
process.exit(1); |
|
|
}
|
|
|
|