Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | 42x 26x 26x 17x 17x 17x 17x 17x 2x 2x 17x 17x 17x 17x 17x 17x 17x 15x 17x 2x 2x 2x 10x 10x 10x 10x 10x 10x 10x 2x 2x 3x 3x 3x 3x 3x 36x 12x 12x 4x 12x 3x 17x 17x 17x 17x 17x 17x 17x 10x 10x 7x 3x 4x 2x | /**
* Terminal output / reporting functions for the cross-platform color validator.
* All functions in this module produce console output and have no return values
* (except hexDisplay which is a pure formatting helper).
*/
import chalk from 'chalk';
import Table from 'cli-table3';
import { colorSwatch } from '../validator-utils.js';
/**
* Format a hex color value with a terminal color swatch.
* Returns a gray dash if the value is absent.
* @param {string|undefined} hex - 6-char lowercase hex without '#'
* @returns {string}
*/
export function hexDisplay(hex) {
if (!hex) return chalk.gray('—');
const withHash = '#' + hex;
return colorSwatch(withHash) + ' ' + withHash;
}
/**
* Print the header block showing which platforms are being compared and token counts.
*/
export function printSummaryHeader(
availablePlatforms,
cssColors,
androidColors,
iosColors,
rawCssCount,
deprecatedCount,
) {
console.log(chalk.bold.blue('\nCross-Platform Color Validation\n'));
console.log(`Comparing platforms: ${availablePlatforms.join(', ')}\n`);
console.log('Token counts:');
console.log(` CSS (raw): ${rawCssCount} tokens`);
if (deprecatedCount > 0) {
console.log(chalk.gray(` - ${deprecatedCount} deprecated tokens (not output by mobile)`));
console.log(` CSS (active): ${cssColors.size} tokens`);
}
if (androidColors.size > 0) console.log(` Android: ${androidColors.size} tokens`);
if (iosColors.size > 0) console.log(` iOS: ${iosColors.size} tokens`);
console.log(chalk.gray('\nNote: All platforms output -light/-dark variants for each token.'));
console.log(chalk.gray(' CSS uses light-dark() function, mobile outputs separate tokens.'));
console.log('');
}
/**
* Print a one-line summary of matching, missing, and mismatched token counts.
*/
export function printResultsSummary(matching, mismatched, missing, totalTokens) {
console.log(`${chalk.green('✅')} Matching: ${matching.length}/${totalTokens} tokens`);
if (missing.length > 0)
console.log(`${chalk.yellow('⚠️')} Missing: ${missing.length} tokens not in all platforms`);
Iif (mismatched.length > 0)
console.log(`${chalk.red('❌')} Mismatched: ${mismatched.length} tokens have different values`);
}
/**
* Print a complete table of all tokens with their values across platforms (--report mode).
*/
export function printReportTable(allTokens, cssColors, androidColors, iosColors, availablePlatforms) {
console.log(chalk.bold.blue('\n📊 Complete Token Report:\n'));
const table = new Table({
head: ['#', 'Token', 'CSS', 'Android', 'iOS', 'Status'],
colWidths: [5, 40, 18, 18, 18, 18],
style: { head: ['cyan'] },
wordWrap: true,
});
Array.from(allTokens)
.sort()
.forEach((token, index) => {
const cssHex = cssColors.get(token);
const androidHex = androidColors.get(token);
const iosHex = iosColors.get(token);
const platforms = [cssHex && 'CSS', androidHex && 'Android', iosHex && 'iOS'].filter(Boolean);
let status;
if (platforms.length < availablePlatforms.length) {
status = chalk.yellow('⚠️ Missing');
} else E{
const hexValues = [cssHex, androidHex, iosHex].filter(Boolean);
status = hexValues.every((h) => h === hexValues[0])
? chalk.green('✅ Match')
: chalk.red('❌ Mismatch');
}
table.push([index + 1, token, hexDisplay(cssHex), hexDisplay(androidHex), hexDisplay(iosHex), status]);
});
console.log(table.toString());
console.log('');
}
/**
* Print detailed tables of mismatched and missing tokens (--verbose mode).
*/
export function printVerboseTables(mismatched, missing, availablePlatforms) {
Iif (mismatched.length > 0) {
console.log(chalk.bold.blue('\n📋 Mismatched Colors:\n'));
const table = new Table({
head: ['#', 'Token', 'CSS', 'Android', 'iOS'],
colWidths: [5, 40, 25, 25, 25],
style: { head: ['red'] },
wordWrap: true,
});
mismatched.forEach(({ token, cssHex, androidHex, iosHex }, index) => {
table.push([
index + 1,
`${chalk.red('❌')} ${token}`,
hexDisplay(cssHex),
hexDisplay(androidHex),
hexDisplay(iosHex),
]);
});
console.log(table.toString());
}
Eif (missing.length > 0) {
console.log(chalk.bold.blue('\n📋 Missing Tokens:\n'));
const table = new Table({
head: ['#', 'Token', 'Present In', 'Missing From', 'Values'],
colWidths: [5, 40, 20, 20, 30],
style: { head: ['yellow'] },
wordWrap: true,
});
missing.forEach(({ token, platforms, cssHex, androidHex, iosHex }, index) => {
const missingFrom = availablePlatforms.filter((p) => !platforms.includes(p)).join(', ');
let valueDisplay = '';
if (cssHex) valueDisplay = 'CSS: ' + hexDisplay(cssHex);
else if (androidHex) valueDisplay = 'Android: ' + hexDisplay(androidHex);
else Eif (iosHex) valueDisplay = 'iOS: ' + hexDisplay(iosHex);
table.push([
index + 1,
`${chalk.yellow('⚠️')} ${token}`,
platforms.join(', '),
missingFrom,
valueDisplay,
]);
});
console.log(table.toString());
}
}
/**
* Print the final summary block with pass/fail counts and usage hints.
*/
export function printFinalSummary(matching, mismatched, missing, totalTokens, isReport, isVerbose) {
const totalIssues = mismatched.length + missing.length;
console.log(chalk.bold.blue('\n📊 Summary:'));
console.log(`${matching.length}/${totalTokens} tests passed`);
console.log(`${chalk.green('✅')} Matching: ${matching.length}`);
Iif (mismatched.length > 0) console.log(`${chalk.red('❌')} Mismatched: ${mismatched.length}`);
if (missing.length > 0) console.log(`${chalk.yellow('⚠️')} Missing: ${missing.length}`);
if (!isReport && !isVerbose && totalIssues > 0) {
console.log(chalk.gray('\nRun with --verbose to see detailed issue tables'));
console.log(chalk.gray('Run with --report to see all tokens'));
} else if (!isReport && isVerbose) {
console.log(chalk.gray('\nRun with --report to see all tokens'));
} else if (isReport && !isVerbose && totalIssues > 0) {
console.log(chalk.gray('\nRun with --verbose to see detailed issue tables'));
}
}
|