* feat: add release.ts * feat: add utils * chore: add scripts to tsconfig.json include * feat: add changelog logic, component, storybook file, scripts, and update to Node v20.9.0 (LTS) * chore: update packages * feat: use conventionalcommits for changelog preset * feat: update padding, width, and change font to mono * feat: refactor to use DialogProvider * chore: remove extra args * feat: update CHANGELOG.md, add title, and add button * refactor: use hook * chore: fix typo
72 lines
1.7 KiB
TypeScript
72 lines
1.7 KiB
TypeScript
const COLORS = {
|
|
Reset: '\x1b[0m',
|
|
Bright: '\x1b[1m',
|
|
Dim: '\x1b[2m',
|
|
Underscore: '\x1b[4m',
|
|
Blink: '\x1b[5m',
|
|
Reverse: '\x1b[7m',
|
|
Hidden: '\x1b[8m',
|
|
FgBlack: '\x1b[30m',
|
|
FgRed: '\x1b[31m',
|
|
FgGreen: '\x1b[32m',
|
|
FgYellow: '\x1b[33m',
|
|
FgBlue: '\x1b[34m',
|
|
FgMagenta: '\x1b[35m',
|
|
FgCyan: '\x1b[36m',
|
|
FgWhite: '\x1b[37m',
|
|
BgBlack: '\x1b[40m',
|
|
BgRed: '\x1b[41m',
|
|
BgGreen: '\x1b[42m',
|
|
BgYellow: '\x1b[43m',
|
|
BgBlue: '\x1b[44m',
|
|
BgMagenta: '\x1b[45m',
|
|
BgCyan: '\x1b[46m',
|
|
BgWhite: '\x1b[47m',
|
|
} as const;
|
|
|
|
type ColorType = 'success' | 'info' | 'error' | 'warning' | keyof typeof COLORS;
|
|
|
|
/**
|
|
* Logs a message with an optional color type.
|
|
*
|
|
* @param message - The message to be logged.
|
|
* @param type - The color type of the log message. Defaults to undefined.
|
|
*/
|
|
export default function colorLog(message: string, type?: ColorType) {
|
|
let color: string = type || COLORS.FgBlack;
|
|
|
|
switch (type) {
|
|
case 'success':
|
|
color = COLORS.FgGreen;
|
|
break;
|
|
case 'info':
|
|
color = COLORS.FgBlue;
|
|
break;
|
|
case 'error':
|
|
color = COLORS.FgRed;
|
|
break;
|
|
case 'warning':
|
|
color = COLORS.FgYellow;
|
|
break;
|
|
default:
|
|
color = COLORS.FgWhite;
|
|
break;
|
|
}
|
|
|
|
console.log(color, message);
|
|
}
|
|
|
|
/**
|
|
* Logs an info message
|
|
*
|
|
* @param message - The message to be logged.
|
|
*/
|
|
export const info = (message: string) => colorLog(message, 'info');
|
|
|
|
/**
|
|
* Logs an error message.
|
|
*
|
|
* @param message - The message to be logged
|
|
*/
|
|
export const error = (message: string) => colorLog(message, 'error');
|