superjolt
Version:
AI-powered deployment platform with MCP support - Deploy JavaScript apps using natural language with Claude Desktop
92 lines ⢠4.55 kB
JavaScript
;
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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MachineUseCommand = 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");
let MachineUseCommand = class MachineUseCommand 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 {
let machineId = passedParams[0];
if (!machineId) {
const machinesResponse = await this.apiService.listMachines();
if (machinesResponse.machines.length === 0) {
this.logger.error('No machines available. Create a machine first with: superjolt machine:create');
process.exit(1);
}
const currentUser = await this.apiService
.getCurrentUser()
.catch(() => null);
this.logger.log('\nš„ļø Select a machine to set as default:\n');
const chalkModule = require('chalk');
const chalk = chalkModule.default || chalkModule;
machinesResponse.machines.forEach((machine, index) => {
const status = machine.status === 'running' ? chalk.green('ā') : chalk.red('ā');
const isCurrentDefault = currentUser?.lastUsedMachineId === machine.id;
const defaultLabel = isCurrentDefault
? chalk.gray(' (current default)')
: '';
this.logger.log(` ${index + 1}. ${status} ${machine.id} (${machine.name})${defaultLabel}`);
});
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
const selection = await new Promise((resolve) => {
rl.question('\nSelect a machine (enter number): ', (answer) => {
rl.close();
resolve(parseInt(answer));
});
});
if (selection < 1 || selection > machinesResponse.machines.length) {
this.logger.error('Invalid selection');
process.exit(1);
}
machineId = machinesResponse.machines[selection - 1].id;
}
this.logger.log(`\nSetting default machine to: ${machineId}...`);
const response = await this.apiService.setDefaultMachine(machineId);
this.logger.log(`ā
${response.message}`);
}
catch (error) {
this.logger.error(`\n${error.message}`);
process.exit(1);
}
}
};
exports.MachineUseCommand = MachineUseCommand;
exports.MachineUseCommand = MachineUseCommand = __decorate([
(0, common_1.Injectable)(),
(0, nest_commander_1.Command)({
name: 'machine:use',
aliases: ['use'],
arguments: '[machineId]',
description: 'Set the default machine to use for commands',
}),
__metadata("design:paramtypes", [api_service_1.ApiService,
auth_service_1.AuthService,
logger_service_1.LoggerService])
], MachineUseCommand);
//# sourceMappingURL=machine-use.command.js.map