import { writeFile } from 'fs/promises' import { join } from 'path' import { colors } from './colors' type ColorScale = Record type Colors = Record type CSSVariables = string[] function generateCSSVariables(colors: Colors): CSSVariables { const cssVariables: CSSVariables = [] Object.entries(colors).forEach(([colorName, value]) => { if (typeof value === 'string') { // Handle base colors (white, black) cssVariables.push(`--${colorName}: ${value};`) } else { // Handle color scales Object.entries(value).forEach(([scale, hexValue]) => { cssVariables.push(`--${colorName}-${scale}: ${hexValue};`) }) } }) return cssVariables } async function generateColors(): Promise { const cssVariables = generateCSSVariables(colors as Colors) // Generate the CSS content const cssContent = `/* ⚠️ WARNING: This file is auto-generated by generateColors.ts Do not edit this file directly as your changes will be overwritten. To modify the colors: 1. Edit libs/blocks/src/theme/colors/colors.ts 2. The pre-commit hook will automatically generate this file when you commit If you need to generate this file manually (e.g., for testing): pnpm nx run @chainlink/blocks:generate-colors The colors are used to maintain consistent theming across the application. */ :root { ${cssVariables.join('\n ')} } ` // Write to colors.css in the same directory const outputPath = join(process.cwd(), 'src/theme/colors.css') await writeFile(outputPath, cssContent, 'utf-8') console.warn('✅ CSS color variables generated at:', outputPath) return true } void generateColors()