create-palladium
Version:
A modern CLI tool to create Vite + React + TypeScript projects with various configurations
80 lines (79 loc) • 2.58 kB
JavaScript
import chalk from 'chalk';
import boxen from 'boxen';
export class Logger {
constructor() { }
static getInstance() {
if (!Logger.instance) {
Logger.instance = new Logger();
}
return Logger.instance;
}
info(message) {
console.log(chalk.blue('ℹ'), message);
}
success(message) {
console.log(chalk.green('✓'), message);
}
warning(message) {
console.log(chalk.yellow('⚠'), message);
}
error(message) {
console.log(chalk.red('✗'), message);
}
step(message) {
console.log(chalk.cyan('→'), message);
}
title(title) {
console.log(chalk.bold.cyan(boxen(title, {
padding: 1,
margin: 1,
borderStyle: 'round',
borderColor: 'cyan'
})));
}
progress(steps) {
steps.forEach((step) => {
const status = this.getStatusIcon(step.status);
const message = step.message || step.name;
console.log(`${status} ${message}`);
});
}
getStatusIcon(status) {
switch (status) {
case 'pending':
return chalk.gray('○');
case 'running':
return chalk.yellow('⟳');
case 'completed':
return chalk.green('✓');
case 'failed':
return chalk.red('✗');
default:
return chalk.gray('○');
}
}
showSuccessMessage(projectName, runDev) {
console.log('\n' + chalk.green.bold('🎉 프로젝트 생성 완료!'));
console.log(chalk.cyan('\n다음 명령어를 실행하세요:\n'));
console.log(chalk.blue(`cd ${projectName}`));
console.log(chalk.blue('npm install'));
if (runDev) {
console.log(chalk.blue('npm run dev'));
}
else {
console.log(chalk.blue('npm run dev'));
}
console.log(chalk.gray('\n즐거운 코딩 되세요! 🚀'));
}
showErrorMessage(error) {
console.log('\n' + chalk.red.bold('❌ 오류가 발생했습니다:'));
console.log(chalk.red(error.message));
if (error.stack) {
console.log(chalk.gray('\n스택 트레이스:'));
console.log(chalk.gray(error.stack));
}
console.log(chalk.yellow('\n문제가 지속되면 이슈를 등록해주세요:'));
console.log(chalk.blue('https://github.com/RosieOh/create-palladium/issues'));
}
}
export const logger = Logger.getInstance();