UNPKG

gitset

Version:

Enhanced git init with user configuration management

74 lines • 2.76 kB
import figlet from 'figlet'; import chalk from 'chalk'; import path from 'path'; import { MESSAGES, UI_CONFIG } from '../config/constants.js'; export class WelcomeScreen { async show() { console.clear(); try { const asciiArt = await this.generateAsciiArt(); console.log(chalk.cyan(asciiArt)); } catch { // Fallback if figlet fails console.log(chalk.cyan.bold(`\n${MESSAGES.welcome.fallbackTitle}\n`)); } console.log(chalk.gray(`${MESSAGES.welcome.description}\n`)); console.log(chalk.yellow(MESSAGES.welcome.helpTitle)); MESSAGES.welcome.features.forEach(feature => { console.log(chalk.white(` ${feature}`)); }); console.log(); // Empty line } generateAsciiArt() { return new Promise((resolve, reject) => { figlet.text('Git Start', { font: UI_CONFIG.figlet.font, horizontalLayout: UI_CONFIG.figlet.horizontalLayout, verticalLayout: UI_CONFIG.figlet.verticalLayout, width: UI_CONFIG.figlet.width, whitespaceBreak: UI_CONFIG.figlet.whitespaceBreak, }, (err, data) => { if (err) { reject(err); } else { resolve(data || 'Git Start'); } }); }); } showSuccess(directory, userInfo, isConfigUpdate) { const absolutePath = path.resolve(directory); console.log(chalk.green.bold('\nšŸŽ‰ SUCCESS! šŸŽ‰\n')); if (isConfigUpdate) { console.log(chalk.green(`${MESSAGES.success.gitConfigUpdated} ${absolutePath}`)); } else { console.log(chalk.green(`${MESSAGES.success.gitInit} ${absolutePath}`)); } console.log(chalk.white(`${MESSAGES.success.configured} ${userInfo.name} <${userInfo.email}>`)); if (!isConfigUpdate) { console.log(chalk.gray('\nšŸ’” Next steps:')); MESSAGES.welcome.nextSteps.forEach(step => { console.log(chalk.gray(` ${step}`)); }); } console.log(); // Empty line } showError(error, suggestion) { console.log(chalk.red.bold('\nāŒ ERROR āŒ\n')); console.log(chalk.red(error)); if (suggestion) { console.log(chalk.yellow(`\nšŸ’” Suggestion: ${suggestion}`)); } console.log(chalk.gray('\nšŸ”§ For help, run: gitset --help\n')); } showWarning(warning) { console.log(chalk.yellow(`āš ļø ${warning}`)); } showInfo(info) { console.log(chalk.blue(`ā„¹ļø ${info}`)); } } //# sourceMappingURL=welcome.js.map