Files
router-lists-ui/frontend/scripts/generate-icons-compat.cjs
T
denozord b0c8a0a4bb
Publish Docker image / build-and-push (push) Successful in 2m6s
Refactor frontend structure and update dependencies
- Changed the main entry point from main.jsx to main.tsx for TypeScript support.
- Removed Tabler JS import and integrated Tailwind CSS for styling.
- Updated package.json and package-lock.json to include new dependencies such as @fontsource-variable/geist and tailwindcss, while removing unused ones.
- Enhanced Vite configuration with path aliasing for improved import management.
- Deleted unused App.css and App.jsx files to streamline the project structure.

Made-with: Cursor
2026-04-26 14:56:48 +07:00

58 lines
1.7 KiB
JavaScript

const fs = require("fs")
const path = require("path")
const root = path.resolve(__dirname, "../src")
const exts = new Set([".js", ".jsx", ".ts", ".tsx"])
const names = new Set()
function walk(dir) {
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const fullPath = path.join(dir, entry.name)
if (entry.isDirectory()) {
walk(fullPath)
continue
}
if (!exts.has(path.extname(entry.name))) continue
const content = fs.readFileSync(fullPath, "utf8")
for (const match of content.matchAll(/\bIcon[A-Za-z0-9_]+\b/g)) {
names.add(match[0])
}
}
}
walk(root)
const sorted = [...names].sort()
const lines = [
'import React from "react"',
'import * as Lucide from "lucide-react"',
"",
"type IconProps = React.SVGProps<SVGSVGElement> & { size?: number }",
"",
"function pick(name: string) {",
" const direct = (Lucide as Record<string, React.ComponentType<IconProps>>)[name]",
" if (direct) return direct",
" const simplified = name.replace(/\\d+$/, \"\")",
" const simplifiedMatch = (Lucide as Record<string, React.ComponentType<IconProps>>)[simplified]",
" if (simplifiedMatch) return simplifiedMatch",
" return Lucide.Circle",
"}",
"",
"function create(name: string) {",
" const IconComponent = pick(name)",
" return function IconCompat(props: IconProps) {",
" return React.createElement(IconComponent, props)",
" }",
"}",
"",
]
for (const iconName of sorted) {
const lucideName = iconName.replace(/^Icon/, "")
lines.push(`export const ${iconName} = create(${JSON.stringify(lucideName)})`)
}
fs.writeFileSync(path.resolve(root, "lib/icons.tsx"), lines.join("\n"))
console.log(`generated ${sorted.length} icons`)