/** * Build logs command for CLI. * * Shows deployment/build logs for a specific deployment. * * @module */ import { isErr } from "@mks2508/no-throw"; import chalk from "chalk"; import { getCoolifyService } from "../../coolify/index.js"; /** * Build logs command handler. * * @param deploymentUuid - Deployment UUID * @param options - Build logs options */ export async function buildLogsCommand( deploymentUuid: string, options: { lines?: number }, ) { const coolify = getCoolifyService(); const initResult = await coolify.init(); if (isErr(initResult)) { console.error(chalk.red(`Error: ${initResult.error.message}`)); return; } const result = await coolify.getDeploymentLogs(deploymentUuid); if (isErr(result)) { console.error(chalk.red(`Error: ${result.error.message}`)); return; } const { status, logs } = result.value; console.log(chalk.cyan("Deployment:") + " " + chalk.white(deploymentUuid)); console.log(chalk.cyan("Status: ") + " " + chalk.white(status)); console.log(""); if (!logs || logs.length === 0) { console.log(chalk.yellow("No build logs available")); return; } const lines = logs.split("\n"); const tail = options.lines || lines.length; const output = lines.slice(-tail); console.log(chalk.gray(`Build logs (${output.length} lines):\n`)); for (const line of output) { console.log(line); } }