Files
discord-github-ticket-relay/scripts/build-icons.mjs

63 lines
3.0 KiB
JavaScript

// Regenerates src/web/icon-data.ts from the lucide-static package (dev dependency).
// Only the icons listed here are bundled. Run: node scripts/build-icons.mjs
import { readFileSync, writeFileSync } from 'node:fs';
import { createRequire } from 'node:module';
import path from 'node:path';
const NAMES = [
'arrow-down', 'arrow-left', 'arrow-left-right', 'arrow-right', 'arrow-up', 'arrow-up-right', 'award', 'bot', 'boxes', 'bug',
'check', 'chevron-down', 'chevron-left', 'chevron-right', 'chevrons-up-down', 'circle-check', 'circle-dashed', 'circle-dot',
'circle-help', 'circle-slash', 'circle-x', 'clock', 'copy', 'ellipsis', 'eye', 'eye-off', 'folder-git-2', 'github', 'globe',
'hash', 'inbox', 'info', 'key-round', 'layout-dashboard', 'lightbulb', 'link', 'link-2-off', 'list-filter', 'loader-circle',
'lock', 'log-out', 'menu', 'message-circle', 'message-circle-question', 'pencil', 'plus', 'refresh-cw', 'rotate-ccw', 'search',
'search-check', 'search-x', 'send', 'server', 'settings', 'sliders-horizontal', 'tag', 'ticket', 'trash-2', 'triangle-alert', 'undo-2',
'unplug', 'user-cog', 'user-minus', 'user-plus', 'user-x', 'users', 'x',
// Forms and files
'align-left', 'clipboard-list', 'file-x', 'heading', 'paperclip', 'scan-search', 'text',
'text-cursor-input', 'upload',
// Server health and Claude
'activity', 'cpu', 'database', 'gauge', 'hard-drive', 'memory-stick', 'sparkles', 'timer',
// Triage
'bell', 'file-text', 'flask-conical', 'git-compare-arrows', 'history', 'message-square', 'play', 'split', 'tags',
// Alerts and dev mode
'circle-alert', 'circle-pause', 'external-link', 'minus', 'wrench',
// Triage knowledge and screenshots
'book-open', 'corner-down-left', 'image',
// Live studio
'chevron-up', 'square',
// Repository changes
'git-merge', 'git-commit-horizontal',
// Repo status
'chart-no-axes-column-increasing', 'flame', 'git-pull-request', 'package', 'download',
// Pull requests
'git-pull-request-draft',
// Analytics
'chart-line', 'star',
// Announcements
'megaphone', 'bell-off',
// Moderation
'shield', 'reply', 'keyboard', 'pin',
// MCP
'plug', 'square-terminal',
// Linked workspaces
'corner-down-right', 'building-2',
];
const require = createRequire(import.meta.url);
const pkgDir = path.dirname(require.resolve('lucide-static/package.json'));
const version = JSON.parse(readFileSync(path.join(pkgDir, 'package.json'), 'utf8')).version;
const entries = NAMES.map((name) => {
const svg = readFileSync(path.join(pkgDir, 'icons', `${name}.svg`), 'utf8');
const inner = svg.slice(svg.indexOf('>', svg.indexOf('<svg')) + 1, svg.lastIndexOf('</svg>'))
.split('\n').map((l) => l.trim()).filter(Boolean).join('').replace(/ \/>/g, '/>');
return ` '${name}': '${inner}',`;
});
writeFileSync('src/web/icon-data.ts', `// Generated by scripts/build-icons.mjs from lucide-static ${version} (ISC license). Do not edit.
export const ICON_PATHS = {
${entries.join('\n')}
} as const;
export type IconName = keyof typeof ICON_PATHS;
`);
console.log(`Wrote ${NAMES.length} icons from lucide-static ${version}`);