UNPKG

color-cleaner

Version:

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

32 lines (27 loc) • 1.31 kB
import chalk from 'chalk'; import Color from 'color'; export function printColorPalette(colorMap) { console.log('\nšŸŽØ Color Palette:\n'); const sortedEntries = Array.from(colorMap.entries()).sort((a, b) => { const brightnessA = Color(a[1]).luminosity(); const brightnessB = Color(b[1]).luminosity(); return brightnessA - brightnessB; }); sortedEntries.forEach(([variable, color]) => { const paddedVariable = variable.padEnd(15); const paddedColor = color.padEnd(20); console.log(`${paddedVariable} ${chalk.hex(color)('ā– ')} ${paddedColor}`); }); } export function printSummary(amountBefore, amountAfter, totalFiles) { const reduction = amountBefore - amountAfter; const reductionPercentage = ((reduction / amountBefore) * 100).toFixed(1); console.log('\nšŸ“Š Summary:'); console.log(`Files scanned: ${chalk.cyan(totalFiles)}`); console.log(`Colors before: ${chalk.yellow(amountBefore)}`); console.log(`Colors after: ${chalk.green(amountAfter)}`); console.log(`Reduction: ${chalk.blue(reduction)} colors (${reductionPercentage}%)\n`); } export function printUpdate(currentPath, lineNumber) { console.log(`${chalk.green('āœ”')} Updated color in ${chalk.cyan(currentPath)} at line ${chalk.yellow(lineNumber)}`); }