UNPKG

@eventcatalog/notifier

Version:

CLI tool to detect EventCatalog changes and send notifications

103 lines 4.24 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Logger = void 0; const picocolors_1 = __importDefault(require("picocolors")); const prompts_1 = require("@clack/prompts"); class Logger { constructor(verbose = false) { this.isVerbose = verbose; } // Enhanced intro for CLI sessions intro(title) { (0, prompts_1.intro)(picocolors_1.default.bgCyan(picocolors_1.default.black(` ${title} `))); } // Enhanced outro for CLI sessions outro(message) { (0, prompts_1.outro)(message); } info(message, indent = 0) { const indentation = ' '.repeat(indent); console.log(indentation + picocolors_1.default.blue('ℹ'), message); } success(message, indent = 0) { const indentation = ' '.repeat(indent); console.log(indentation + picocolors_1.default.green('✓'), message); } warn(message, indent = 0) { const indentation = ' '.repeat(indent); console.log(indentation + picocolors_1.default.yellow('⚠'), message); } error(message, indent = 0) { const indentation = ' '.repeat(indent); console.log(indentation + picocolors_1.default.red('✗'), message); } verbose(message, indent = 0) { if (this.isVerbose) { const indentation = ' '.repeat(indent); console.log(indentation + picocolors_1.default.dim(`🔍 ${message}`)); } } debug(data, indent = 0) { if (this.isVerbose) { const indentation = ' '.repeat(indent); console.log(indentation + picocolors_1.default.dim('🐛 Debug:'), data); } } // Enhanced box display for important information box(title, content) { console.log(); console.log(picocolors_1.default.bold(picocolors_1.default.bgBlue(picocolors_1.default.white(` ${title} `)))); console.log(picocolors_1.default.dim('┌' + '─'.repeat(content.length + 2) + '┐')); console.log(picocolors_1.default.dim('│ ') + content + picocolors_1.default.dim(' │')); console.log(picocolors_1.default.dim('└' + '─'.repeat(content.length + 2) + '┘')); console.log(); } // Display a step in the process step(message, step, total) { const stepInfo = picocolors_1.default.dim(`[${step}/${total}]`); console.log(picocolors_1.default.cyan('→'), stepInfo, message); } // Helper for formatted error messages with proper spacing errorWithDetails(title, message, suggestions = []) { this.error(title); if (message) { console.log(picocolors_1.default.dim(message)); } if (suggestions.length > 0) { console.log(); // Single newline before suggestions suggestions.forEach((suggestion) => { console.log(picocolors_1.default.dim(` ${suggestion}`)); }); } } // Helper for stack traces in verbose mode stackTrace(error) { if (this.isVerbose) { console.log(); // Single newline before stack trace console.log(picocolors_1.default.red('Stack trace:')); console.log(picocolors_1.default.dim(error.stack || 'No stack trace available')); } } // Display a summary table of results summary(title, items) { console.log(); console.log(picocolors_1.default.bold(title)); console.log(picocolors_1.default.dim('─'.repeat(title.length))); items.forEach((item) => { const statusIcon = item.status === 'success' ? picocolors_1.default.green('✓') : item.status === 'error' ? picocolors_1.default.red('✗') : item.status === 'warn' ? picocolors_1.default.yellow('⚠') : picocolors_1.default.blue('ℹ'); console.log(`${statusIcon} ${item.label}: ${picocolors_1.default.cyan(item.value)}`); }); console.log(); } } exports.Logger = Logger; //# sourceMappingURL=logger.js.map