sesterce-cli
Version:
A powerful command-line interface tool for managing Sesterce Cloud services. Sesterce CLI provides easy access to GPU cloud instances, AI inference services, container registries, and SSH key management directly from your terminal.
188 lines • 14.7 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createGpuCloudInstanceDetailsCommand = createGpuCloudInstanceDetailsCommand;
const get_instance_details_1 = require("@/modules/gpu-cloud/use-cases/get-instance-details");
const list_launched_instances_1 = require("@/modules/gpu-cloud/use-cases/list-launched-instances");
const prompts_1 = require("@inquirer/prompts");
const chalk_1 = __importDefault(require("chalk"));
const figlet_1 = __importDefault(require("figlet"));
const luxon_1 = require("luxon");
const getStatusColor = (status) => {
switch (status) {
case "active":
return chalk_1.default.hex("#50FA7B"); // Green
case "pending":
return chalk_1.default.hex("#FFB86C"); // Orange
case "error":
return chalk_1.default.hex("#FF5555"); // Red
case "deleted":
return chalk_1.default.hex("#6272A4"); // Gray
default:
return chalk_1.default.white;
}
};
const printInstance = (instance) => {
return `${instance.name} (${instance.gpuCount} x ${instance.gpuModel}) | ${instance.provider} | ${instance.region.name} | ${instance.status} | ${instance.hourlyPrice.toFixed(2)}`;
};
function createGpuCloudInstanceDetailsCommand(gpuCloudInstanceCommand) {
gpuCloudInstanceCommand
.command("details")
.description("Get details of a launched instance in Sesterce Cloud")
.option("-i, --instance-id <instanceId>", "The ID of the instance to get details of")
.action(async (args) => {
let instanceId = args.instanceId;
if (!instanceId) {
console.log("Loading launched instances...");
const result = await list_launched_instances_1.listLaunchedInstances.execute();
if (result.isLeft()) {
console.error(result.value.message);
return;
}
const instances = result.value;
if (instances.length === 0) {
console.log("No instances found");
return;
}
const instance = await (0, prompts_1.search)({
message: "Select an instance to get details for",
source: async (input) => {
if (!input) {
return instances.map((instance) => ({
name: printInstance(instance),
value: instance,
}));
}
return instances
.filter((instance) => instance.gpuModel
.toLowerCase()
.includes(input.toLowerCase()) ||
instance.gpuCount.toString().includes(input) ||
instance.region.name.toLowerCase().includes(input) ||
instance.provider.toLowerCase().includes(input) ||
instance.status.toLowerCase().includes(input) ||
instance.name.toLowerCase().includes(input) ||
instance.hourlyPrice.toFixed(2).includes(input))
.map((instance) => ({
name: printInstance(instance),
value: instance,
}));
},
});
instanceId = instance._id;
}
const result = await get_instance_details_1.getInstanceDetails.execute(instanceId);
if (result.isLeft()) {
console.error(result.value.message);
return;
}
const instance = result.value;
// Header with instance name
console.log("\n" + "=".repeat(80));
console.log(chalk_1.default.hex("#21C65D")(figlet_1.default.textSync(instance.name, { font: "Standard" })));
console.log("=".repeat(80) + "\n");
// Basic Information Section
console.log(chalk_1.default.hex("#FF6B6B")(chalk_1.default.bold("📋 BASIC INFORMATION")));
console.log(chalk_1.default.hex("#4ECDC4")("┌─" + "─".repeat(78) + "─┐"));
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("ID:")} ${chalk_1.default.white(instance._id)}${" ".repeat(78 - 4 - instance._id.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("Name:")} ${chalk_1.default.white(instance.name)}${" ".repeat(78 - 6 - instance.name.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("Status:")} ${getStatusColor(instance.status)(instance.status)}${" ".repeat(78 - 8 - instance.status.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("Provider:")} ${chalk_1.default.cyan(instance.provider)}${" ".repeat(78 - 10 - instance.provider.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("Region:")} ${chalk_1.default.white(instance.region.name)}${" ".repeat(78 - 8 - instance.region.name.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("IP Address:")} ${instance.ip ? chalk_1.default.cyan(instance.ip) : chalk_1.default.gray("Not assigned")}${" ".repeat(78 - 12 - (instance.ip ? instance.ip.length : 12))}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("└─" + "─".repeat(78) + "─┘\n"));
// Hardware Specifications Section
console.log(chalk_1.default.hex("#FF6B6B")(chalk_1.default.bold("🚀 HARDWARE SPECIFICATIONS")));
console.log(chalk_1.default.hex("#4ECDC4")("┌─" + "─".repeat(78) + "─┐"));
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("GPU Model:")} ${chalk_1.default.hex("#FFE66D")(instance.gpuModel)}${" ".repeat(78 - 11 - instance.gpuModel.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("GPU Count:")} ${chalk_1.default.white(instance.gpuCount)}${" ".repeat(78 - 11 - instance.gpuCount.toString().length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("Total VRAM:")} ${chalk_1.default.hex("#50FA7B")(`${instance.vramPerGpu * instance.gpuCount} GB`)}${" ".repeat(78 - 12 - `${instance.vramPerGpu * instance.gpuCount} GB`.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("RAM:")} ${chalk_1.default.white(`${instance.ram} GB`)}${" ".repeat(78 - 5 - `${instance.ram} GB`.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("Storage:")} ${chalk_1.default.white(`${instance.storage} GB`)}${" ".repeat(78 - 9 - `${instance.storage} GB`.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("vCPUs:")} ${chalk_1.default.white(instance.vcpus)}${" ".repeat(78 - 7 - instance.vcpus.toString().length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("Interconnect:")} ${chalk_1.default.white(instance.interconnect)}${" ".repeat(78 - 13 - instance.interconnect.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("NVLink:")} ${instance.nvlink ? chalk_1.default.hex("#50FA7B")("Yes") : chalk_1.default.red("No")}${" ".repeat(78 - 8 - (instance.nvlink ? 3 : 2))}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("OS:")} ${chalk_1.default.white(instance.os)}${" ".repeat(78 - 4 - instance.os.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("Hourly Price:")} ${chalk_1.default.hex("#50FA7B")(`$${instance.hourlyPrice.toFixed(2)}`)}${" ".repeat(78 - 13 - instance.hourlyPrice.toFixed(2).length - 1)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("└─" + "─".repeat(78) + "─┘\n"));
// SSH Configuration Section
console.log(chalk_1.default.hex("#FF6B6B")(chalk_1.default.bold("🔑 SSH CONFIGURATION")));
console.log(chalk_1.default.hex("#4ECDC4")("┌─" + "─".repeat(78) + "─┐"));
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("SSH Key:")} ${chalk_1.default.white(instance.sshKey.name)}${" ".repeat(78 - 10 - instance.sshKey.name.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("SSH User:")} ${chalk_1.default.white(instance.sshUser)}${" ".repeat(78 - 10 - instance.sshUser.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("SSH Port:")} ${instance.sshPort ? chalk_1.default.white(instance.sshPort) : chalk_1.default.gray("Not assigned")}${" ".repeat(78 - 10 - (instance.sshPort ? instance.sshPort.toString().length : 12))}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("└─" + "─".repeat(78) + "─┘\n"));
// Docker Configuration Section
if (instance.dockerImage || instance.dockerCommand) {
console.log(chalk_1.default.hex("#FF6B6B")(chalk_1.default.bold("🐳 DOCKER CONFIGURATION")));
console.log(chalk_1.default.hex("#4ECDC4")("┌─" + "─".repeat(78) + "─┐"));
if (instance.dockerImage) {
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("Docker Image:")} ${chalk_1.default.white(instance.dockerImage)}${" ".repeat(78 - 14 - instance.dockerImage.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
}
if (instance.dockerCommand) {
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("Docker Command:")} ${chalk_1.default.white(instance.dockerCommand)}${" ".repeat(78 - 16 - instance.dockerCommand.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
}
console.log(chalk_1.default.hex("#4ECDC4")("└─" + "─".repeat(78) + "─┘\n"));
}
// Port Forwards Section
if (instance.portForwards && instance.portForwards.length > 0) {
console.log(chalk_1.default.hex("#FF6B6B")(chalk_1.default.bold("🔌 PORT FORWARDS")));
console.log(chalk_1.default.hex("#4ECDC4")("┌─" + "─".repeat(78) + "─┐"));
instance.portForwards.forEach((port, index) => {
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold(`Port ${index + 1}:`)} ${chalk_1.default.cyan(`${port.internalPort} → ${port.externalPort}`)}${" ".repeat(78 - 9 - `${port.internalPort} → ${port.externalPort}`.length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
});
console.log(chalk_1.default.hex("#4ECDC4")("└─" + "─".repeat(78) + "─┘\n"));
}
// Volumes Section
if (instance.volumes && instance.volumes.length > 0) {
console.log(chalk_1.default.hex("#FF6B6B")(chalk_1.default.bold("💾 MOUNTED VOLUMES")));
console.log(chalk_1.default.hex("#4ECDC4")("┌─" + "─".repeat(78) + "─┐"));
instance.volumes.forEach((volume, index) => {
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold(`Volume ${index + 1}:`)} ${chalk_1.default.white(volume.name)} (${chalk_1.default.hex("#50FA7B")(`${volume.capacity} GB`)} - $${volume.hourlyPrice.toFixed(2)}/hour)${" ".repeat(78 - 12 - volume.name.length - `${volume.capacity} GB`.length - volume.hourlyPrice.toFixed(2).length - 8)}${chalk_1.default.hex("#4ECDC4")("│")}`);
});
console.log(chalk_1.default.hex("#4ECDC4")("└─" + "─".repeat(78) + "─┘\n"));
}
// Timestamps Section
console.log(chalk_1.default.hex("#FF6B6B")(chalk_1.default.bold("⏰ TIMESTAMPS")));
console.log(chalk_1.default.hex("#4ECDC4")("┌─" + "─".repeat(78) + "─┐"));
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("Created:")} ${chalk_1.default.white(luxon_1.DateTime.fromISO(instance.createdAt).toLocaleString(luxon_1.DateTime.DATETIME_FULL))}${" ".repeat(78 - 9 - luxon_1.DateTime.fromISO(instance.createdAt).toLocaleString(luxon_1.DateTime.DATETIME_FULL).length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("Updated:")} ${chalk_1.default.white(luxon_1.DateTime.fromISO(instance.updatedAt).toLocaleString(luxon_1.DateTime.DATETIME_FULL))}${" ".repeat(78 - 9 - luxon_1.DateTime.fromISO(instance.updatedAt).toLocaleString(luxon_1.DateTime.DATETIME_FULL).length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
if (instance.deletedAt) {
console.log(chalk_1.default.hex("#4ECDC4")("│") +
` ${chalk_1.default.bold("Deleted:")} ${chalk_1.default.red(luxon_1.DateTime.fromISO(instance.deletedAt).toLocaleString(luxon_1.DateTime.DATETIME_FULL))}${" ".repeat(78 - 9 - luxon_1.DateTime.fromISO(instance.deletedAt).toLocaleString(luxon_1.DateTime.DATETIME_FULL).length)}${chalk_1.default.hex("#4ECDC4")("│")}`);
}
console.log(chalk_1.default.hex("#4ECDC4")("└─" + "─".repeat(78) + "─┘\n"));
// Footer
console.log(chalk_1.default.hex("#21C65D")("=".repeat(80)));
console.log(chalk_1.default.hex("#21C65D")(chalk_1.default.bold("✨ GPU Cloud instance details displayed successfully!")));
console.log(chalk_1.default.hex("#21C65D")("=".repeat(80)) + "\n");
});
}
//# sourceMappingURL=details.js.map