UNPKG

superjolt

Version:

AI-powered deployment platform with MCP support - Deploy JavaScript apps using natural language with Claude Desktop

195 lines 6.38 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TABLE_STYLES = exports.STATUS_INDICATORS = void 0; exports.createResourceTable = createResourceTable; exports.createInfoTable = createInfoTable; exports.createKeyValueTable = createKeyValueTable; exports.formatDate = formatDate; exports.getStatusIndicator = getStatusIndicator; exports.formatStatus = formatStatus; exports.createProgressBar = createProgressBar; exports.truncate = truncate; exports.formatBytes = formatBytes; const cli_table3_1 = __importDefault(require("cli-table3")); const chalk_1 = __importDefault(require("chalk")); exports.STATUS_INDICATORS = { running: chalk_1.default.green('●'), active: chalk_1.default.green('●'), stopped: chalk_1.default.red('○'), inactive: chalk_1.default.yellow('○'), error: chalk_1.default.red('✖'), failed: chalk_1.default.red('✖'), pending: chalk_1.default.gray('◌'), starting: chalk_1.default.blue('◐'), stopping: chalk_1.default.yellow('◐'), restarting: chalk_1.default.blue('◐'), deploying: chalk_1.default.blue('◐'), deployed: chalk_1.default.green('●'), created: chalk_1.default.gray('◌'), unknown: chalk_1.default.gray('◌'), }; exports.TABLE_STYLES = { modern: { chars: { top: '─', 'top-mid': '┬', 'top-left': '┌', 'top-right': '┐', bottom: '─', 'bottom-mid': '┴', 'bottom-left': '└', 'bottom-right': '┘', left: '│', 'left-mid': '├', mid: '─', 'mid-mid': '┼', right: '│', 'right-mid': '┤', middle: '│', }, }, compact: { compact: true, chars: { top: '', 'top-mid': '', 'top-left': '', 'top-right': '', bottom: '', 'bottom-mid': '', 'bottom-left': '', 'bottom-right': '', left: '', 'left-mid': '', mid: '', 'mid-mid': '', right: '', 'right-mid': '', middle: ' ', }, }, }; function createResourceTable(headers, options) { return new cli_table3_1.default({ head: headers.map((h) => chalk_1.default.bold.cyan(h)), style: { head: [], border: [], }, ...exports.TABLE_STYLES.modern, ...options, }); } function createInfoTable() { return new cli_table3_1.default({ style: { head: [], border: [], }, ...exports.TABLE_STYLES.compact, colWidths: [20, 50], }); } function createKeyValueTable() { return new cli_table3_1.default({ head: [chalk_1.default.bold.cyan('Key'), chalk_1.default.bold.cyan('Value')], style: { head: [], border: [], }, ...exports.TABLE_STYLES.modern, colWidths: [30, 50], wordWrap: true, }); } function formatDate(dateString) { const date = new Date(dateString); const now = new Date(); const diffMs = now.getTime() - date.getTime(); const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)); if (diffDays === 0) { return chalk_1.default.green('Today'); } else if (diffDays === 1) { return chalk_1.default.green('Yesterday'); } else if (diffDays < 7) { return `${diffDays} days ago`; } else if (diffDays < 30) { const weeks = Math.floor(diffDays / 7); return `${weeks} week${weeks > 1 ? 's' : ''} ago`; } else { return date.toLocaleDateString(); } } function getStatusIndicator(status) { if (!status) return exports.STATUS_INDICATORS.unknown; const normalizedStatus = status.toLowerCase().trim(); return exports.STATUS_INDICATORS[normalizedStatus] || exports.STATUS_INDICATORS.unknown; } function formatStatus(status) { if (!status) { return `${exports.STATUS_INDICATORS.unknown} ${chalk_1.default.gray('unknown')}`; } const normalizedStatus = status.toLowerCase().trim(); const indicator = getStatusIndicator(status); switch (normalizedStatus) { case 'running': case 'active': case 'deployed': return `${indicator} ${chalk_1.default.green(status)}`; case 'stopped': return `${indicator} ${chalk_1.default.red(status)}`; case 'inactive': return `${indicator} ${chalk_1.default.yellow(status)}`; case 'error': case 'failed': return `${indicator} ${chalk_1.default.red(status)}`; case 'pending': case 'starting': case 'deploying': case 'restarting': return `${indicator} ${chalk_1.default.blue(status)}`; case 'stopping': return `${indicator} ${chalk_1.default.yellow(status)}`; case 'created': return `${indicator} ${chalk_1.default.gray('created')}`; case 'unknown': return `${indicator} ${chalk_1.default.gray('unknown')}`; default: return `${indicator} ${chalk_1.default.gray(status)}`; } } function createProgressBar(current, max, width = 20) { const percentage = (current / max) * 100; const filled = Math.round((percentage / 100) * width); const empty = width - filled; let color = chalk_1.default.green; if (percentage >= 100) { color = chalk_1.default.red; } else if (percentage >= 80) { color = chalk_1.default.yellow; } const bar = color('█'.repeat(filled)) + chalk_1.default.gray('░'.repeat(empty)); return `${bar} ${color(`${Math.round(percentage)}%`)}`; } function truncate(str, maxLength) { if (str.length <= maxLength) return str; return str.substring(0, maxLength - 3) + '...'; } function formatBytes(bytes) { const sizes = ['B', 'KB', 'MB', 'GB', 'TB']; if (bytes === 0) return '0 B'; const i = Math.floor(Math.log(bytes) / Math.log(1024)); return `${(bytes / Math.pow(1024, i)).toFixed(2)} ${sizes[i]}`; } //# sourceMappingURL=table.utils.js.map