* Write the icon mapping TypeScript file for the shared integrations data * directory (`apps/sim/lib/integrations`). Mirrors `writeIconMapping` (the * docs-app variant) but targets the sim app so it imports from * `@/components/icons`. Unlike the docs variant, no bare-name aliasing is * applied
(iconMapping: Record<string, string>)
| 726 | * versioned) `integration.type` emitted into `integrations.json`. |
| 727 | */ |
| 728 | function writeIntegrationsIconMapping(iconMapping: Record<string, string>): void { |
| 729 | try { |
| 730 | if (!fs.existsSync(INTEGRATIONS_DATA_PATH)) { |
| 731 | fs.mkdirSync(INTEGRATIONS_DATA_PATH, { recursive: true }) |
| 732 | } |
| 733 | const iconMappingPath = path.join(INTEGRATIONS_DATA_PATH, 'icon-mapping.ts') |
| 734 | |
| 735 | const iconNames = [...new Set(Object.values(iconMapping))].sort(biomeSortCompare) |
| 736 | const imports = iconNames.map((icon) => ` ${icon},`).join('\n') |
| 737 | const mappingEntries = Object.entries(iconMapping) |
| 738 | .sort(([a], [b]) => a.localeCompare(b)) |
| 739 | .map(([blockType, iconName]) => ` ${blockType}: ${iconName},`) |
| 740 | .join('\n') |
| 741 | |
| 742 | const content = `// Auto-generated file - do not edit manually |
| 743 | // Generated by scripts/generate-docs.ts |
| 744 | // Maps block types to their icon component references for the integrations page |
| 745 | |
| 746 | import type { ComponentType, SVGProps } from 'react' |
| 747 | import { |
| 748 | ${imports} |
| 749 | } from '@/components/icons' |
| 750 | |
| 751 | type IconComponent = ComponentType<SVGProps<SVGSVGElement>> |
| 752 | |
| 753 | export const blockTypeToIconMap: Record<string, IconComponent> = { |
| 754 | ${mappingEntries} |
| 755 | } |
| 756 | ` |
| 757 | fs.writeFileSync(iconMappingPath, content) |
| 758 | console.log('✓ Integration icon mapping written') |
| 759 | } catch (error) { |
| 760 | console.error('Error writing integration icon mapping:', error) |
| 761 | } |
| 762 | } |
| 763 | |
| 764 | /** |
| 765 | * Collect all integration entries from block definitions and write integrations.json |
no test coverage detected