import { mkdir, readFile, writeFile } from 'node:fs/promises'; import { dirname, resolve } from 'node:path'; const names = [ 'bell', 'calendar-days', 'check-circle-2', 'chevron-left', 'chevron-right', 'circle-user-round', 'clock', 'folder-kanban', 'folder-open', 'inbox', 'layout-dashboard', 'list-check', 'log-out', 'monitor', 'moon', 'panel-left', 'settings', 'sun', 'triangle-alert', 'users', 'x' ]; const output = resolve('src/main/resources/static/assets/icons.svg'); const symbols = await Promise.all(names.map(async (name) => { const svg = await readFile(resolve(`node_modules/lucide-static/icons/${name}.svg`), 'utf8'); const root = svg.match(/]*)>/)?.[1]; const viewBox = root?.match(/viewBox="([^"]+)"/)?.[1] ?? '0 0 24 24'; const presentation = ['fill', 'stroke', 'stroke-width', 'stroke-linecap', 'stroke-linejoin'] .map((attribute) => root?.match(new RegExp(`${attribute}="[^"]+"`))?.[0]) .join(' '); const body = svg.match(/([\s\S]*?)<\/svg>/)?.[1]; if (!body) throw new Error(`Invalid Lucide SVG: ${name}`); return `${body.trim()}`; })); await mkdir(dirname(output), { recursive: true }); await writeFile(output, `${symbols.join('')}\n`);