feat: release notes (#283)
* 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
This commit is contained in:
69
utils/log.ts
69
utils/log.ts
@@ -1,26 +1,3 @@
|
||||
type ColorType = 'success' | 'info' | 'error' | 'warning' | keyof typeof COLORS;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
console.log(color, message);
|
||||
}
|
||||
|
||||
const COLORS = {
|
||||
Reset: '\x1b[0m',
|
||||
Bright: '\x1b[1m',
|
||||
@@ -46,3 +23,49 @@ const COLORS = {
|
||||
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');
|
||||
|
||||
Reference in New Issue
Block a user