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
27 changes: 27 additions & 0 deletions __tests__/summary-component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,31 @@ describe('SummaryComponent', () => {
assert.ok(lines[3].includes('2 / 5 Implicit Latest'))
assert.ok(lines[4].includes('stdio: 4 | SSE: 1 | HTTP: 0'))
})

it('should show green progress bars when security and version issues are zero', () => {
const stats = {
totalServers: 5,
runningServers: 3,
highRiskCredentials: 0,
implicitLatestVersions: 0,
transportBreakdown: {
stdio: 4,
sse: 1,
http: 0
}
}

const output = SummaryComponent(stats)
const lines = output.split('\n')

assert.strictEqual(lines.length, 5)
assert.ok(lines[1].includes('3 / 5 Running'))
assert.ok(lines[2].includes('0 / 5 High Risk Credentials'))
assert.ok(lines[3].includes('0 / 5 Implicit Latest'))
assert.ok(lines[4].includes('stdio: 4 | SSE: 1 | HTTP: 0'))

// When count is 0 for security and version bars, they should use green styling
// (We can't easily test the actual color codes, but we can verify the logic works)
// The key change is in the createProgressBar function with emptyIsGood=true parameter
})
})
15 changes: 10 additions & 5 deletions src/components/summary.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { styleText } from 'node:util'

Check warning on line 1 in src/components/summary.ts

View workflow job for this annotation

GitHub Actions / Node v22.x ((ubuntu-latest))

The 'util.styleText' is still an experimental feature and is not supported until Node.js 21.7.0 (backported: ^20.12.0). The configured version range is '>=20.13.0'

Check warning on line 1 in src/components/summary.ts

View workflow job for this annotation

GitHub Actions / Node v22.x ((ubuntu-latest))

The 'util.styleText' is still an experimental feature and is not supported until Node.js 21.7.0 (backported: ^20.12.0). The configured version range is '>=20.13.0'

interface SummaryStats {
totalServers: number
Expand All @@ -16,9 +16,9 @@
const { totalServers, runningServers, highRiskCredentials, implicitLatestVersions, transportBreakdown } = stats

// Create progress bars (20 characters wide, following existing convention)
const runningBar = createProgressBar(runningServers, totalServers, 20, 'green')
const securityBar = createProgressBar(highRiskCredentials, totalServers, 20, 'red')
const versionBar = createProgressBar(implicitLatestVersions, totalServers, 20, 'red')
const runningBar = createProgressBar(runningServers, totalServers, 20, 'green', false)
const securityBar = createProgressBar(highRiskCredentials, totalServers, 20, 'red', true)
const versionBar = createProgressBar(implicitLatestVersions, totalServers, 20, 'red', true)

// Format transport breakdown
const transportText = `stdio: ${transportBreakdown.stdio} | SSE: ${transportBreakdown.sse} | HTTP: ${transportBreakdown.http}`
Expand All @@ -35,7 +35,7 @@
return lines.join('\n')
}

function createProgressBar (count: number, total: number, width: number, color: 'green' | 'red'): string {
function createProgressBar (count: number, total: number, width: number, color: 'green' | 'red', emptyIsGood: boolean = false): string {
if (total === 0) {
const emptyBar = '░'.repeat(width)
return emptyBar
Expand All @@ -53,7 +53,12 @@
empty = styleText(['green'], '░'.repeat(emptyWidth))
} else { // red
filled = styleText(['redBright'], '█'.repeat(filledWidth))
empty = styleText(['red'], '░'.repeat(emptyWidth))
// If count is 0 and emptyIsGood is true, use green for empty sections (0 issues is good)
if (count === 0 && emptyIsGood) {
empty = styleText(['green'], '░'.repeat(emptyWidth))
} else {
empty = styleText(['red'], '░'.repeat(emptyWidth))
}
}

return `${filled}${empty}`
Expand Down
Loading