73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
/**
|
|
* Centralized console output for tsbuild.
|
|
*
|
|
* Visual hierarchy (4 levels):
|
|
* HEADER — top-level section start (emoji + bold text + separator line)
|
|
* STEP — major action within a section (emoji + text, no indent)
|
|
* DETAIL — supplementary info under a step (3-space indent + emoji + text)
|
|
* SUCCESS/ERROR/WARN — outcome indicators (emoji + text, no indent)
|
|
*/
|
|
export class TsBuildLogger {
|
|
static readonly c = {
|
|
reset: '\x1b[0m',
|
|
bold: '\x1b[1m',
|
|
dim: '\x1b[2m',
|
|
red: '\x1b[31m',
|
|
green: '\x1b[32m',
|
|
yellow: '\x1b[33m',
|
|
cyan: '\x1b[36m',
|
|
white: '\x1b[37m',
|
|
brightRed: '\x1b[91m',
|
|
brightGreen: '\x1b[92m',
|
|
brightYellow: '\x1b[93m',
|
|
};
|
|
|
|
static readonly SEPARATOR_WIDTH = 70;
|
|
|
|
static separator(char = '─'): string {
|
|
return char.repeat(this.SEPARATOR_WIDTH);
|
|
}
|
|
|
|
/** Level 1: Section header. Blank line before, separator after. */
|
|
static header(emoji: string, text: string): void {
|
|
console.log('');
|
|
console.log(`${emoji} ${this.c.bold}${text}${this.c.reset}`);
|
|
console.log(this.c.dim + this.separator() + this.c.reset);
|
|
}
|
|
|
|
/** Level 2: Step within a section. No indent. */
|
|
static step(emoji: string, text: string): void {
|
|
console.log(`${emoji} ${text}`);
|
|
}
|
|
|
|
/** Level 3: Detail under a step. 3-space indent. */
|
|
static detail(emoji: string, text: string): void {
|
|
console.log(` ${emoji} ${text}`);
|
|
}
|
|
|
|
/** Outcome: success */
|
|
static success(text: string): void {
|
|
console.log(`${this.c.green}✅ ${text}${this.c.reset}`);
|
|
}
|
|
|
|
/** Outcome: error (goes to stderr) */
|
|
static error(text: string): void {
|
|
console.error(`${this.c.red}❌ ${text}${this.c.reset}`);
|
|
}
|
|
|
|
/** Outcome: warning */
|
|
static warn(text: string): void {
|
|
console.log(`${this.c.yellow}⚠️ ${text}${this.c.reset}`);
|
|
}
|
|
|
|
/** Plain indented line (for code snippets, list items, etc.) */
|
|
static indent(text: string, level = 1): void {
|
|
console.log(' '.repeat(level) + text);
|
|
}
|
|
|
|
/** Blank line */
|
|
static blank(): void {
|
|
console.log('');
|
|
}
|
|
}
|