Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/ui/scan/printHealthScore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,29 @@ export function printHealthScore(
json: boolean = false,
): boolean {
let color = chalk.green;
let emoji = '💚';
let label = 'Excellent health';

if (json) return false;

if (score < 90) {
color = chalk.yellow;
label = 'Good, but can improve';
emoji = '💛';
label = 'Can improve';
}
if (score < 70) {
color = chalk.redBright;
emoji = '🧡';
label = 'Needs attention';
}
if (score < 40) {
color = chalk.red;
label = 'Poor health – critical issues detected';
emoji = '🚨';
label = 'Poor health';
}

console.log('💚 Project Health Score:', color(`${score}/100`));
console.log(` ${label}`);
console.log(`${emoji} ${color('Project Health Score:')} (${score}/100)`);
console.log(` ${color(label)}`);
console.log('');
return true;
}
4 changes: 2 additions & 2 deletions test/e2e/cli.healthscore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Health Score', () => {
const res = runCli(cwd, ['--scan-usage']);

// Missing variables reduce score → should be < 100
expect(res.stdout).toContain('💚 Project Health Score:');
expect(res.stdout).toContain('💛 Project Health Score:');
expect(res.stdout).not.toMatch(/100\/100/);
});

Expand All @@ -75,7 +75,7 @@ describe('Health Score', () => {

const res = runCli(cwd, ['--scan-usage']);

expect(res.stdout).toContain('💚 Project Health Score:');
expect(res.stdout).toContain('💛 Project Health Score:');

// High secrets should push score far down (<85)
const match = res.stdout.match(/Health Score:\s.*?(\d{1,3})\/100/);
Expand Down
Loading