mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-17 04:17:11 +00:00
- create src/utils/ui.ts with semantic colors, status indicators, boxes, tables, spinners - add ui types (SemanticColor, BoxOptions, TableOptions, SpinnerOptions) to src/types/utils.ts - add deprecation notice to src/utils/helpers.ts for legacy color functions - add unit tests for ui module (11 test cases) - install chalk@5.6.2, boxen@8.0.1, gradient-string@3.0.0 features: - semantic color system (success, error, warning, info, primary, secondary) - ascii-only status indicators: [OK], [X], [!], [i] - tty-aware with NO_COLOR/FORCE_COLOR support - styled boxes with boxen (round, double, bold borders) - formatted tables with cli-table3 - animated spinners with ora (fallback to plain text in non-tty) - gradient text for headers (cyan-to-blue) - lazy esm module loading for chalk/boxen/gradient-string
105 lines
2.2 KiB
TypeScript
105 lines
2.2 KiB
TypeScript
/**
|
|
* Utility Types
|
|
*/
|
|
|
|
// Re-export from error-codes for consistency
|
|
export { ERROR_CODES, ErrorCode, getErrorDocUrl, getErrorCategory } from '../utils/error-codes';
|
|
|
|
/**
|
|
* Log levels
|
|
*/
|
|
export enum LogLevel {
|
|
DEBUG = 'debug',
|
|
INFO = 'info',
|
|
WARN = 'warn',
|
|
ERROR = 'error',
|
|
}
|
|
|
|
/**
|
|
* Color codes (TTY-aware)
|
|
*/
|
|
export type ColorName =
|
|
| 'red'
|
|
| 'green'
|
|
| 'yellow'
|
|
| 'blue'
|
|
| 'cyan'
|
|
| 'bold'
|
|
| 'cyanBold'
|
|
| 'reset';
|
|
|
|
/**
|
|
* Terminal capabilities
|
|
*/
|
|
export interface TerminalInfo {
|
|
isTTY: boolean;
|
|
supportsColor: boolean;
|
|
noColorEnv: boolean; // NO_COLOR env var set
|
|
}
|
|
|
|
/**
|
|
* Helper result types
|
|
*/
|
|
export type Result<T, E = Error> = { ok: true; value: T } | { ok: false; error: E };
|
|
|
|
// =============================================================================
|
|
// UI TYPES (Phase 1: CLI UI/UX Enhancement)
|
|
// =============================================================================
|
|
|
|
/**
|
|
* Semantic color names for UI elements
|
|
*/
|
|
export type SemanticColor =
|
|
| 'success' // green - [OK] messages
|
|
| 'error' // red - [X] messages
|
|
| 'warning' // yellow - [!] messages
|
|
| 'info' // cyan - [i] messages
|
|
| 'dim' // gray - secondary text
|
|
| 'primary' // #00ECFA - headers, emphasis
|
|
| 'secondary' // #0099FF - links, accents
|
|
| 'command' // yellow italic - command examples
|
|
| 'path'; // cyan underline - file paths
|
|
|
|
/**
|
|
* Box style options for boxen wrapper
|
|
*/
|
|
export interface BoxOptions {
|
|
title?: string;
|
|
titleAlignment?: 'left' | 'center' | 'right';
|
|
padding?: number;
|
|
margin?: number;
|
|
borderColor?: string;
|
|
borderStyle?: 'single' | 'double' | 'round' | 'bold' | 'classic';
|
|
}
|
|
|
|
/**
|
|
* Table style options for cli-table3 wrapper
|
|
*/
|
|
export interface TableOptions {
|
|
head?: string[];
|
|
colWidths?: number[];
|
|
wordWrap?: boolean;
|
|
style?: 'unicode' | 'ascii';
|
|
}
|
|
|
|
/**
|
|
* Spinner options for ora wrapper
|
|
*/
|
|
export interface SpinnerOptions {
|
|
text: string;
|
|
color?: string;
|
|
prefixText?: string;
|
|
}
|
|
|
|
/**
|
|
* Spinner control interface
|
|
*/
|
|
export interface SpinnerController {
|
|
succeed: (msg?: string) => void;
|
|
fail: (msg?: string) => void;
|
|
warn: (msg?: string) => void;
|
|
info: (msg?: string) => void;
|
|
update: (text: string) => void;
|
|
stop: () => void;
|
|
}
|