import { readFileSync, writeFileSync, readdirSync } from 'fs'
import { join, basename } from 'path'
import { fileURLToPath } from 'url'
const __dirname = fileURLToPath(new URL('.', import.meta.url))
const iconsDir = join(__dirname, '../src/assets/icons')
const svgFiles = readdirSync(iconsDir)
.filter(f => f.endsWith('.svg') && f !== 'sprite.svg')
.sort()
if (!svgFiles.length) {
console.error('No SVG files found in', iconsDir)
process.exit(1)
}
// Extract viewBox and inner content from each SVG file
const symbols = svgFiles.map((file) => {
const name = basename(file, '.svg')
const raw = readFileSync(join(iconsDir, file), 'utf-8')
const viewBox = (raw.match(/viewBox="([^"]+)"/) ?? [])[1] ?? '0 0 24 24'
// Everything between
const inner = (raw.match(/