UNPKG

superjolt

Version:

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

87 lines 4.42 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.MachineRenameCommand = 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 chalk_1 = __importDefault(require("chalk")); let MachineRenameCommand = class MachineRenameCommand 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) { try { if (passedParams.length === 0) { this.logger.error('Error: New name is required'); this.logger.log('Usage: superjolt machine:rename <machineId> <newName>'); this.logger.log(' or: superjolt machine:rename <newName> (uses default machine)'); process.exit(1); } let machineId; let newName; if (passedParams.length === 1) { const currentUser = await this.apiService.getCurrentUser(); if (!currentUser.lastUsedMachineId) { this.logger.error('Error: No default machine found'); this.logger.log('Create a machine first with: superjolt machine:create'); this.logger.log('Or specify machine ID: superjolt machine:rename <machineId> <newName>'); process.exit(1); } machineId = currentUser.lastUsedMachineId; newName = passedParams[0]; this.logger.log(`Using default machine: ${machineId}`); } else { machineId = passedParams[0]; newName = passedParams[1]; } const nameRegex = /^[a-z0-9][a-z0-9-._]*$/; if (!nameRegex.test(newName)) { this.logger.error('Error: Machine name must start with a lowercase letter or number, and can only contain lowercase letters, numbers, hyphens, periods, and underscores.'); process.exit(1); } this.logger.log(`Renaming machine ${chalk_1.default.cyan(machineId)} to ${chalk_1.default.cyan(newName)}...`); const response = await this.apiService.renameMachine(machineId, newName); this.logger.log(chalk_1.default.green(`✅ ${response.message}`)); this.logger.log(`Machine ${chalk_1.default.cyan(machineId)} renamed to ${chalk_1.default.cyan(response.name)}`); } catch (error) { this.logger.error(`\n${error.message}`); process.exit(1); } } }; exports.MachineRenameCommand = MachineRenameCommand; exports.MachineRenameCommand = MachineRenameCommand = __decorate([ (0, common_1.Injectable)(), (0, nest_commander_1.Command)({ name: 'machine:rename', arguments: '[machineId] [newName]', description: 'Rename a machine', }), __metadata("design:paramtypes", [api_service_1.ApiService, auth_service_1.AuthService, logger_service_1.LoggerService]) ], MachineRenameCommand); //# sourceMappingURL=machine-rename.command.js.map