Files
HiveGrid-Wireframes/hivegrid-cloud/scripts/migrate-layout-workflow-icons-to-feather.mjs
T

95 lines
4.8 KiB
JavaScript

// Migrates the two remaining single-glyph icon-component directories to Subframe
// Feather icons via the shared icons/_feather.tsx wrapper:
// - apps/web/app/components/layouts/icons/** (sidebar / nav icons)
// - apps/web/app/modules/workflowEngine/components/icons/**
//
// Same contract as scripts/migrate-icons-to-feather.mjs: each file keeps its
// default-export `({ className }: { className?: string })` API so all call sites
// stay unchanged. Dynamic renderers (EntityIcon, SidebarIcon) and test files are
// intentionally excluded.
//
// Run from repo root: node scripts/migrate-layout-workflow-icons-to-feather.mjs
import { readFileSync, writeFileSync, existsSync } from "node:fs"
import { join, dirname } from "node:path"
import { fileURLToPath } from "node:url"
const __dirname = dirname(fileURLToPath(import.meta.url))
const repoRoot = join(__dirname, "..")
const appRoot = join(repoRoot, "apps/web/app")
const featherNames = new Set(
readFileSync("/tmp/feather-names.txt", "utf8").split("\n").map((s) => s.trim()).filter(Boolean)
)
// relative path (under apps/web/app) -> Feather component name.
const MAP = {
// --- components/layouts/icons (sidebar/nav) ---
"components/layouts/icons/IconAdmin.tsx": "FeatherShield",
"components/layouts/icons/IconAnalytics.tsx": "FeatherBarChart2",
"components/layouts/icons/IconApp.tsx": "FeatherLayoutGrid",
"components/layouts/icons/IconClients.tsx": "FeatherUsers",
"components/layouts/icons/IconCode.tsx": "FeatherCode",
"components/layouts/icons/IconComponents.tsx": "FeatherComponent",
"components/layouts/icons/IconDashboard.tsx": "FeatherLayoutDashboard",
"components/layouts/icons/IconDocs.tsx": "FeatherFileText",
"components/layouts/icons/IconEmails.tsx": "FeatherMail",
"components/layouts/icons/IconEntities.tsx": "FeatherDatabase",
"components/layouts/icons/IconEvents.tsx": "FeatherCalendar",
"components/layouts/icons/IconFeatureFlags.tsx": "FeatherFlag",
"components/layouts/icons/IconHelpDesk.tsx": "FeatherLifeBuoy",
"components/layouts/icons/IconHistory.tsx": "FeatherHistory",
"components/layouts/icons/IconKeys.tsx": "FeatherKey",
"components/layouts/icons/IconLinks.tsx": "FeatherLink",
"components/layouts/icons/IconMembers.tsx": "FeatherUsers",
"components/layouts/icons/IconMetrics.tsx": "FeatherActivity",
"components/layouts/icons/IconNavigation.tsx": "FeatherCompass",
"components/layouts/icons/IconNotifications.tsx": "FeatherBell",
"components/layouts/icons/IconOnboarding.tsx": "FeatherRocket",
"components/layouts/icons/IconPages.tsx": "FeatherFile",
"components/layouts/icons/IconPortals.tsx": "FeatherGlobe",
"components/layouts/icons/IconProfile.tsx": "FeatherUser",
"components/layouts/icons/IconPromptBuilder.tsx": "FeatherSparkles",
"components/layouts/icons/IconProviders.tsx": "FeatherPlug",
"components/layouts/icons/IconRoles.tsx": "FeatherShield",
"components/layouts/icons/IconSettings.tsx": "FeatherSettings",
"components/layouts/icons/IconTenants.tsx": "FeatherBuilding2",
"components/layouts/icons/IconUsers.tsx": "FeatherUsers",
"components/layouts/icons/IconWidgets.tsx": "FeatherBox",
"components/layouts/icons/IconWorkflows.tsx": "FeatherWorkflow",
// --- modules/workflowEngine/components/icons ---
"modules/workflowEngine/components/icons/WorkflowIcon.tsx": "FeatherWorkflow",
"modules/workflowEngine/components/icons/WorkflowIconFilled.tsx": "FeatherWorkflow",
"modules/workflowEngine/components/icons/WorkflowBlockActionIcon.tsx": "FeatherBox",
"modules/workflowEngine/components/icons/WorkflowCredentialIcon.tsx": "FeatherKey",
"modules/workflowEngine/components/icons/WorkflowCredentialIconFilled.tsx": "FeatherKey",
"modules/workflowEngine/components/icons/WorkflowExecutionIcon.tsx": "FeatherPlay",
"modules/workflowEngine/components/icons/WorkflowExecutionIconFilled.tsx": "FeatherPlay",
"modules/workflowEngine/components/icons/WorkflowVariableIcon.tsx": "FeatherVariable",
"modules/workflowEngine/components/icons/WorkflowVariableIconFilled.tsx": "FeatherVariable",
}
const entries = Object.entries(MAP)
const errors = []
for (const [file, feather] of entries) {
if (!featherNames.has(feather)) errors.push(`UNKNOWN FEATHER: ${feather} (for ${file})`)
if (!existsSync(join(appRoot, file))) errors.push(`MISSING FILE: ${file}`)
}
if (errors.length) {
console.error("Validation failed:\n" + errors.join("\n"))
process.exit(1)
}
let written = 0
for (const [file, feather] of entries) {
const abs = join(appRoot, file)
const content =
`import { ${feather} } from "@subframe/core"\n\n` +
`import { featherIcon } from "~/components/ui/icons/_feather"\n\n` +
`export default featherIcon(${feather})\n`
writeFileSync(abs, content, "utf8")
written++
}
console.log(`Rewrote ${written}/${entries.length} layout/workflow icon files to Feather.`)