UNPKG

@quasarbright/projection

Version:

A static site generator that creates a beautiful, interactive gallery to showcase your coding projects. Features search, filtering, tags, responsive design, and an admin UI.

165 lines 4.56 kB
"use strict"; /** * Logger utility for consistent, colored console output */ Object.defineProperty(exports, "__esModule", { value: true }); exports.step = exports.info = exports.warn = exports.error = exports.success = exports.log = exports.Logger = void 0; /** * ANSI color codes for terminal output */ const colors = { reset: '\x1b[0m', bright: '\x1b[1m', dim: '\x1b[2m', // Foreground colors red: '\x1b[31m', green: '\x1b[32m', yellow: '\x1b[33m', blue: '\x1b[34m', magenta: '\x1b[35m', cyan: '\x1b[36m', white: '\x1b[37m', gray: '\x1b[90m', // Background colors bgRed: '\x1b[41m', bgGreen: '\x1b[42m', bgYellow: '\x1b[43m', bgBlue: '\x1b[44m', }; /** * Check if colors should be disabled (for CI environments or when piped) */ const shouldUseColors = () => { return process.stdout.isTTY && process.env.NO_COLOR !== '1'; }; /** * Apply color to text if colors are enabled */ const colorize = (text, color) => { if (!shouldUseColors()) { return text; } return `${color}${text}${colors.reset}`; }; /** * Logger class with colored output methods */ class Logger { /** * Log a success message (green checkmark) */ static success(message) { console.log(colorize('✓', colors.green) + ' ' + message); } /** * Log an error message (red X) */ static error(message) { console.error(colorize('✗', colors.red) + ' ' + colorize(message, colors.red)); } /** * Log a warning message (yellow warning sign) */ static warn(message) { console.warn(colorize('⚠', colors.yellow) + ' ' + colorize(message, colors.yellow)); } /** * Log an info message (blue info icon) */ static info(message) { console.log(colorize('ℹ', colors.blue) + ' ' + message); } /** * Log a step/progress message (cyan arrow) */ static step(message) { console.log(colorize('→', colors.cyan) + ' ' + message); } /** * Log a header message (bright/bold) */ static header(message) { console.log('\n' + colorize(message, colors.bright)); } /** * Log a plain message */ static log(message) { console.log(message); } /** * Log a dimmed/secondary message */ static dim(message) { console.log(colorize(message, colors.dim)); } /** * Log with a custom emoji/icon */ static icon(icon, message, color) { const iconText = color ? colorize(icon, color) : icon; console.log(iconText + ' ' + message); } /** * Create a blank line */ static newline() { console.log(''); } /** * Log a list of items with bullets */ static list(items, indent = 2) { const spaces = ' '.repeat(indent); items.forEach(item => { console.log(`${spaces}${item}`); }); } /** * Log a numbered list */ static numberedList(items, indent = 2) { const spaces = ' '.repeat(indent); items.forEach((item, index) => { console.log(`${spaces}${index + 1}. ${item}`); }); } /** * Log a key-value pair */ static keyValue(key, value, indent = 2) { const spaces = ' '.repeat(indent); console.log(`${spaces}${colorize(key + ':', colors.cyan)} ${value}`); } /** * Log a separator line */ static separator(char = '─', length = 50) { console.log(colorize(char.repeat(length), colors.dim)); } /** * Log a box with a message */ static box(message) { const lines = message.split('\n'); const maxLength = Math.max(...lines.map(l => l.length)); const border = '─'.repeat(maxLength + 2); console.log(colorize('┌' + border + '┐', colors.dim)); lines.forEach(line => { const padding = ' '.repeat(maxLength - line.length); console.log(colorize('│', colors.dim) + ' ' + line + padding + ' ' + colorize('│', colors.dim)); }); console.log(colorize('└' + border + '┘', colors.dim)); } } exports.Logger = Logger; /** * Convenience exports for common logging patterns */ exports.log = Logger.log.bind(Logger); exports.success = Logger.success.bind(Logger); exports.error = Logger.error.bind(Logger); exports.warn = Logger.warn.bind(Logger); exports.info = Logger.info.bind(Logger); exports.step = Logger.step.bind(Logger); //# sourceMappingURL=logger.js.map