UNPKG

color-cleaner

Version:

A CLI tool to clean and consolidate colors in your project files.

34 lines (27 loc) 1.39 kB
#!/usr/bin/env node import {getConfig, askConvertToHex} from './lib/inquireConfig.js'; import logger from './setup/logger.js'; import { getAllFiles, createPallet } from './lib/filesService.js'; import { getColorLines } from './lib/colorExtractorService.js'; import { consolidateColors, convertMapColorsToHex } from './lib/cleanerService.js'; import { replaceColorsWithVariable } from './lib/replaceService.js'; import { printColorPalette, printSummary } from './lib/prettyConsoleService.js'; async function main() { logger.info('Welcome to Color Cleaner! 🎨'); logger.info('Let\'s set up your configuration...'); const config = await getConfig(); logger.success('Configuration received!'); logger.debug('Config:', config); const files = await getAllFiles(config, process.cwd()); const colorLines = await getColorLines(files, config); const groups = consolidateColors(colorLines, config.thresholdSensitivity); const replacedGroups = await replaceColorsWithVariable(groups); const updatedGroups = await askConvertToHex() ? convertMapColorsToHex(replacedGroups) : replacedGroups; printColorPalette(updatedGroups); printSummary(colorLines.length, groups.length, files.length); createPallet(Object.fromEntries(updatedGroups)); } main().catch(error => { logger.error('An error occurred:', error); process.exit(1); });