superjolt
Version:
AI-powered deployment platform with MCP support - Deploy JavaScript apps using natural language with Claude Desktop
95 lines • 5.01 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);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MeCommand = 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 MeCommand = class MeCommand extends authenticated_command_1.AuthenticatedCommand {
apiService;
authService;
logger;
constructor(apiService, authService, logger) {
super();
this.apiService = apiService;
this.authService = authService;
this.logger = logger;
}
async execute() {
try {
const response = await this.apiService.getCurrentUser();
this.logger.log(chalk_1.default.cyan('\n👤 User Profile\n'));
const userTable = (0, table_utils_1.createInfoTable)();
userTable.push([chalk_1.default.bold('Name'), response.name], [chalk_1.default.bold('Email'), response.email]);
if (response.githubUsername) {
userTable.push([
chalk_1.default.bold('GitHub'),
chalk_1.default.blue(`@${response.githubUsername}`),
]);
}
if (response.avatarUrl) {
userTable.push([chalk_1.default.bold('Avatar'), chalk_1.default.dim(response.avatarUrl)]);
}
userTable.push([chalk_1.default.bold('User ID'), chalk_1.default.dim(response.id)]);
this.logger.log(userTable.toString());
if (response.tenant) {
this.logger.log(chalk_1.default.cyan('\n🏢 Organization\n'));
const orgTable = (0, table_utils_1.createInfoTable)();
orgTable.push([chalk_1.default.bold('Name'), response.tenant.name], [chalk_1.default.bold('Tenant ID'), chalk_1.default.dim(response.tenantId)]);
const { machineCount, maxMachines } = response.tenant;
const progressBar = (0, table_utils_1.createProgressBar)(machineCount, maxMachines, 15);
orgTable.push([
chalk_1.default.bold('Machine Usage'),
`${machineCount}/${maxMachines} ${progressBar}`,
]);
this.logger.log(orgTable.toString());
const percentUsed = (machineCount / maxMachines) * 100;
if (percentUsed >= 100) {
this.logger.log(chalk_1.default.red('\n⚠️ Machine limit reached! Delete unused machines to continue.'));
}
else if (percentUsed >= 80) {
this.logger.log(chalk_1.default.yellow(`\n⚠️ Approaching machine limit (${Math.round(percentUsed)}% used)`));
}
}
if (response.lastUsedMachineId) {
this.logger.log(chalk_1.default.dim(`\n📍 Last Used Machine: ${chalk_1.default.blue(response.lastUsedMachineId)}`));
}
this.logger.log(chalk_1.default.dim('\nQuick actions:'));
this.logger.log(chalk_1.default.dim(' superjolt machines - List all machines'));
this.logger.log(chalk_1.default.dim(' superjolt deploy - Deploy an application'));
this.logger.log(chalk_1.default.dim(' superjolt logout - Sign out'));
}
catch (error) {
this.logger.error(`\n${error.message}`);
process.exit(1);
}
}
};
exports.MeCommand = MeCommand;
exports.MeCommand = MeCommand = __decorate([
(0, common_1.Injectable)(),
(0, nest_commander_1.Command)({
name: 'me',
description: 'Show current user information',
}),
__metadata("design:paramtypes", [api_service_1.ApiService,
auth_service_1.AuthService,
logger_service_1.LoggerService])
], MeCommand);
//# sourceMappingURL=me.command.js.map