MCPcopy Index your code
hub / github.com/TanStack/ai / formatGrid

Function formatGrid

packages/ai-code-mode-skills/test-cli/cli.ts:109–139  ·  view source on GitHub ↗

* Format the results grid with proper emoji alignment

(results: AdapterResult[], testsRun: TestDefinition[])

Source from the content-addressed store, hash-verified

107 * Format the results grid with proper emoji alignment
108 */
109function formatGrid(results: AdapterResult[], testsRun: TestDefinition[]) {
110 const headers = ['Adapter', ...testsRun.map((t) => t.id)]
111
112 // Build rows with result indicators
113 const rows = results.map((result) => [
114 result.adapter,
115 ...testsRun.map((test) => {
116 const outcome = result.tests[test.id]
117 if (!outcome) return '—'
118 if (outcome.ignored) return '—'
119 return outcome.passed ? '✅' : '❌'
120 }),
121 ])
122
123 // Calculate column widths based on display width
124 const colWidths = headers.map((header, index) => {
125 const headerWidth = displayWidth(header)
126 const maxCellWidth = Math.max(
127 ...rows.map((row) => displayWidth(row[index] || '')),
128 )
129 return Math.max(headerWidth, maxCellWidth)
130 })
131
132 const separator = colWidths.map((w) => '-'.repeat(w)).join('-+-')
133 const formatRow = (row: string[]) =>
134 row.map((cell, idx) => padEnd(cell, colWidths[idx]!)).join(' | ')
135
136 console.log(formatRow(headers))
137 console.log(separator)
138 rows.forEach((row) => console.log(formatRow(row)))
139}
140
141/**
142 * Clear the current line and move cursor to beginning

Callers 1

runCommandFunction · 0.85

Calls 3

displayWidthFunction · 0.85
formatRowFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected