UNPKG

plazbot-cli

Version:
88 lines (87 loc) 3.96 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.showBanner = showBanner; exports.showMiniHeader = showMiniHeader; const chalk_1 = __importDefault(require("chalk")); const credentials_1 = require("./credentials"); const VERSION = '0.2.0'; // ASCII art del logo Plazbot (burbujas de chat) const logo = [ ' ╭──────────╮ ', ' │ ● ● ● │ ', ' ╰────┬─────╯ ', ' ╭─────┴────────╮ ', ' │ ╭─╮ ╭─╮ │ ', ' │ ╰─╯ ╰─╯ │ ', ' │ ╰────╯ │ ', ' ╰───────────────╯ ', ]; const coloredLogo = logo.map(line => chalk_1.default.hex('#2E8B57')(line)); async function showBanner() { const width = 70; // Intentar cargar credenciales let credentials = null; try { credentials = await (0, credentials_1.getStoredCredentials)(); } catch { // No hay credenciales guardadas } console.log(); console.log(chalk_1.default.hex('#4CAF50')('─'.repeat(width))); console.log(); // Layout de 2 columnas const leftWidth = 30; const rightStart = leftWidth + 4; // Línea del título const title = chalk_1.default.bold.hex('#4CAF50')(` Plazbot CLI v${VERSION}`); // Info columna derecha const rightColumn = []; if (credentials) { rightColumn.push(chalk_1.default.bold.hex('#4CAF50')('Workspace conectado')); rightColumn.push(chalk_1.default.gray(` ${credentials.workspace || 'N/A'}`)); rightColumn.push(chalk_1.default.gray(` ${credentials.email || ''}`)); rightColumn.push(chalk_1.default.gray(` Zona: ${credentials.zone || 'N/A'}`)); rightColumn.push(''); rightColumn.push(chalk_1.default.hex('#4CAF50')('─'.repeat(35))); rightColumn.push(''); rightColumn.push(chalk_1.default.bold.hex('#4CAF50')('Comandos rapidos')); rightColumn.push(chalk_1.default.white(' plazbot agent list')); rightColumn.push(chalk_1.default.white(' plazbot agent create')); rightColumn.push(chalk_1.default.white(' plazbot agent chat -a <id>')); rightColumn.push(chalk_1.default.white(' plazbot whatsapp send-message')); } else { rightColumn.push(chalk_1.default.bold.hex('#FFA726')('No conectado')); rightColumn.push(''); rightColumn.push(chalk_1.default.bold.hex('#4CAF50')('Para comenzar')); rightColumn.push(chalk_1.default.white(' plazbot init -e <email> -k <key> -w <workspace> -z <zone>')); rightColumn.push(''); rightColumn.push(chalk_1.default.hex('#4CAF50')('─'.repeat(35))); rightColumn.push(''); rightColumn.push(chalk_1.default.bold.hex('#4CAF50')('Documentacion')); rightColumn.push(chalk_1.default.gray(' https://docs.plazbot.com')); } // Imprimir título console.log(title); console.log(); // Imprimir logo + info lado a lado const maxLines = Math.max(coloredLogo.length, rightColumn.length); for (let i = 0; i < maxLines; i++) { const left = i < coloredLogo.length ? coloredLogo[i] : ' '.repeat(leftWidth); const right = i < rightColumn.length ? rightColumn[i] : ''; // Pad left column const paddedLeft = left.replace(/\x1b\[[0-9;]*m/g, ''); const padding = ' '.repeat(Math.max(0, leftWidth - paddedLeft.length)); console.log(`${left}${padding} ${right}`); } console.log(); console.log(chalk_1.default.hex('#4CAF50')('─'.repeat(width))); console.log(); } function showMiniHeader(command) { console.log(chalk_1.default.hex('#4CAF50')(`\n Plazbot`) + chalk_1.default.gray(` > ${command}\n`)); }