File tree Expand file tree Collapse file tree 3 files changed +34
-24
lines changed
Expand file tree Collapse file tree 3 files changed +34
-24
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Shared formatting utilities for release commands.
3+ *
4+ * Small helpers used by both `list.ts` and `view.ts` to format
5+ * health/adoption metrics consistently.
6+ */
7+
8+ /**
9+ * Format a percentage value with one decimal place, or "—" when absent.
10+ *
11+ * @example fmtPct(42.3) // "42.3%"
12+ * @example fmtPct(null) // "—"
13+ */
14+ export function fmtPct ( value : number | null | undefined ) : string {
15+ if ( value === null || value === undefined ) {
16+ return "—" ;
17+ }
18+ return `${ value . toFixed ( 1 ) } %` ;
19+ }
20+
21+ /**
22+ * Format an integer count with thousands separators, or "—" when absent.
23+ *
24+ * @example fmtCount(52000) // "52,000"
25+ * @example fmtCount(null) // "—"
26+ */
27+ export function fmtCount ( value : number | null | undefined ) : string {
28+ if ( value === null || value === undefined ) {
29+ return "—" ;
30+ }
31+ return value . toLocaleString ( "en-US" ) ;
32+ }
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
1515 type OrgListCommandDocs ,
1616} from "../../lib/list-command.js" ;
1717import type { OrgListConfig } from "../../lib/org-list.js" ;
18+ import { fmtPct } from "./format.js" ;
1819
1920export const PAGINATION_KEY = "release-list" ;
2021
@@ -30,14 +31,6 @@ function getHealthData(release: OrgReleaseResponse) {
3031 return release . projects ?. find ( ( p ) => p . healthData ?. hasHealthData ) ?. healthData ;
3132}
3233
33- /** Format a percentage value with one decimal, or "—" when absent. */
34- function fmtPct ( value : number | null | undefined ) : string {
35- if ( value === null || value === undefined ) {
36- return "—" ;
37- }
38- return `${ value . toFixed ( 1 ) } %` ;
39- }
40-
4134const RELEASE_COLUMNS : Column < ReleaseWithOrg > [ ] = [
4235 { header : "ORG" , value : ( r ) => r . orgSlug || "" } ,
4336 {
Original file line number Diff line number Diff line change @@ -27,16 +27,9 @@ import {
2727 FRESH_FLAG ,
2828} from "../../lib/list-command.js" ;
2929import { resolveOrg } from "../../lib/resolve-target.js" ;
30+ import { fmtCount , fmtPct } from "./format.js" ;
3031import { parseReleaseArg } from "./parse.js" ;
3132
32- /** Format a percentage with one decimal, colorized by threshold. */
33- function fmtPct ( value : number | null | undefined ) : string {
34- if ( value === null || value === undefined ) {
35- return "—" ;
36- }
37- return `${ value . toFixed ( 1 ) } %` ;
38- }
39-
4033/** Format a crash-free rate with color coding (green ≥ 99, yellow ≥ 95, red < 95). */
4134function fmtCrashFree ( value : number | null | undefined ) : string {
4235 if ( value === null || value === undefined ) {
@@ -52,14 +45,6 @@ function fmtCrashFree(value: number | null | undefined): string {
5245 return colorTag ( "red" , formatted ) ;
5346}
5447
55- /** Format a count with thousands separators, or "—" when absent. */
56- function fmtCount ( value : number | null | undefined ) : string {
57- if ( value === null || value === undefined ) {
58- return "—" ;
59- }
60- return value . toLocaleString ( "en-US" ) ;
61- }
62-
6348/**
6449 * Build a markdown table of per-project health data.
6550 *
You can’t perform that action at this time.
0 commit comments