UNPKG

superjolt

Version:

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

155 lines 7.28 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.DomainListCommand = void 0; const nest_commander_1 = require("nest-commander"); const api_service_1 = require("../services/api.service"); const auth_service_1 = require("../services/auth.service"); const logger_service_1 = require("../services/logger.service"); const common_1 = require("@nestjs/common"); const authenticated_command_1 = require("./authenticated.command"); const table_utils_1 = require("../utils/table.utils"); const chalk_1 = __importDefault(require("chalk")); let DomainListCommand = class DomainListCommand extends authenticated_command_1.AuthenticatedCommand { apiService; authService; logger; constructor(apiService, authService, logger) { super(); this.apiService = apiService; this.authService = authService; this.logger = logger; } async execute(passedParams, options) { try { const serviceId = options.serviceId || passedParams[0]; if (serviceId) { this.logger.log(chalk_1.default.dim(`Fetching custom domains for service: ${serviceId}...`)); } else { this.logger.log(chalk_1.default.dim('Fetching all custom domains...')); } const response = await this.apiService.listCustomDomains(serviceId); if (response.total === 0) { this.logger.log(chalk_1.default.yellow('\nNo custom domains found.')); this.logger.log(chalk_1.default.dim('\nAdd a custom domain with:')); this.logger.log(chalk_1.default.cyan(' superjolt domain:add <domain> <serviceId>')); return; } if (serviceId) { this.logger.log(chalk_1.default.cyan(`\nCustom domains for service ${serviceId}:`)); } else { this.logger.log(chalk_1.default.cyan('\nCustom domains:')); } const table = (0, table_utils_1.createResourceTable)(['Domain', 'Service', 'Status', 'SSL', 'Primary', 'Created'], { wordWrap: true, wrapOnWordBoundary: false, }); const sortedDomains = [...response.domains].sort((a, b) => { if (a.isPrimary && !b.isPrimary) return -1; if (!a.isPrimary && b.isPrimary) return 1; const aActive = a.status === 'active' ? 0 : 1; const bActive = b.status === 'active' ? 0 : 1; if (aActive !== bActive) return aActive - bActive; return (new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()); }); sortedDomains.forEach((domain) => { const domainDisplay = domain.isPrimary ? `${domain.domain} ${chalk_1.default.green('★')}` : domain.domain; table.push([ domainDisplay, domain.serviceId, this.formatStatus(domain.status), this.formatStatus(domain.sslStatus), domain.isPrimary ? chalk_1.default.green('Yes') : chalk_1.default.gray('No'), (0, table_utils_1.formatDate)(domain.createdAt), ]); }); this.logger.log(table.toString()); const statusCounts = response.domains.reduce((acc, d) => { acc[d.status] = (acc[d.status] || 0) + 1; return acc; }, {}); let summary = chalk_1.default.dim(`\nTotal: ${response.total} domain${response.total === 1 ? '' : 's'}`); const statusParts = []; if (statusCounts.active) statusParts.push(`${statusCounts.active} active`); if (statusCounts.pending_validation) statusParts.push(`${statusCounts.pending_validation} pending`); if (statusCounts.failed) statusParts.push(`${statusCounts.failed} failed`); if (statusCounts.expired) statusParts.push(`${statusCounts.expired} expired`); if (statusParts.length > 0) { summary += chalk_1.default.dim(` (${statusParts.join(', ')})`); } this.logger.log(summary); const pendingDomains = response.domains.filter((d) => d.status === 'pending_validation'); if (pendingDomains.length > 0) { this.logger.log(''); this.logger.log(chalk_1.default.yellow('⚠️ Some domains are pending validation')); this.logger.log(chalk_1.default.dim('Check domain status with:')); this.logger.log(chalk_1.default.cyan(' superjolt domain:status <domain>')); } } catch (error) { this.logger.error(`\n${error.message}`); process.exit(1); } } parseServiceId(val) { return val; } formatStatus(status) { switch (status) { case 'active': return chalk_1.default.green('● Active'); case 'pending_validation': return chalk_1.default.yellow('● Pending'); case 'failed': return chalk_1.default.red('● Failed'); case 'expired': return chalk_1.default.red('● Expired'); default: return chalk_1.default.gray(`● ${status}`); } } }; exports.DomainListCommand = DomainListCommand; __decorate([ (0, nest_commander_1.Option)({ flags: '-s, --serviceId <serviceId>', description: 'Filter domains by service ID', }), __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", String) ], DomainListCommand.prototype, "parseServiceId", null); exports.DomainListCommand = DomainListCommand = __decorate([ (0, common_1.Injectable)(), (0, nest_commander_1.Command)({ name: 'domain:list', aliases: ['domains'], description: 'List custom domains', }), __metadata("design:paramtypes", [api_service_1.ApiService, auth_service_1.AuthService, logger_service_1.LoggerService]) ], DomainListCommand); //# sourceMappingURL=domain-list.command.js.map