@@ -17,9 +17,9 @@ import {
1717 type BranchMetricsReport
1818} from '@xata.io/utils' ;
1919import chalk from 'chalk' ;
20- import Table from 'cli-table3' ;
2120import type { LocalContext } from '~/context' ;
2221import { getErrorMessage } from '~/lib/cli-utils' ;
22+ import { renderTable } from '~/lib/table' ;
2323
2424type OutputFormat = 'table' | 'json' | 'ndjson' | 'tui' ;
2525
@@ -229,14 +229,12 @@ async function watchMetrics(
229229}
230230
231231function renderSummaryTable ( report : BranchMetricsReport , aggregation : BranchMetricAggregation ) : string {
232- const table = new Table ( {
233- head : [ 'Metric' , 'Instance' , 'Agg' , 'Latest' , 'Min' , 'Max' , 'Avg' , 'Unit' , 'Status' ]
234- } ) ;
232+ const rows : string [ ] [ ] = [ ] ;
235233
236234 for ( const metric of report . metrics ) {
237235 const series = metric . series . filter ( ( s ) => s . aggregation === aggregation ) ;
238236 if ( series . length === 0 ) {
239- table . push ( [
237+ rows . push ( [
240238 metric . key ,
241239 '' ,
242240 aggregation ,
@@ -251,7 +249,7 @@ function renderSummaryTable(report: BranchMetricsReport, aggregation: BranchMetr
251249 }
252250
253251 for ( const serie of series ) {
254- table . push ( [
252+ rows . push ( [
255253 metric . key ,
256254 serie . instanceName ,
257255 serie . aggregation ,
@@ -265,9 +263,11 @@ function renderSummaryTable(report: BranchMetricsReport, aggregation: BranchMetr
265263 }
266264 }
267265
266+ const table = renderTable ( [ 'Metric' , 'Instance' , 'Agg' , 'Latest' , 'Min' , 'Max' , 'Avg' , 'Unit' , 'Status' ] , rows ) ;
267+
268268 return `${ chalk . bold ( `Metrics for ${ report . target . branchName } (${ report . target . branchId } )` ) } \n${ chalk . dim (
269269 `${ report . timeRange . start } → ${ report . timeRange . end } `
270- ) } \n${ table . toString ( ) } \n`;
270+ ) } \n${ table } \n`;
271271}
272272
273273function renderDashboard ( report : BranchMetricsReport , aggregation : BranchMetricAggregation ) : string {
0 commit comments