import { Layout } from "../components/Layout"; import type { Deployment, Command } from "../index"; interface DeploymentDetailProps { deployment: Deployment; commands: Command[]; } function getStatusBadge(status: string): string { const statusClass = status === "success" ? "badge-success" : status === "failed" ? "badge-failed" : status === "pending" ? "badge-pending" : "badge-in_progress"; return `${status}`; } function formatDate(dateString: string | undefined): string { if (!dateString) return "N/A"; const date = new Date(dateString); return date.toLocaleString(); } function escapeHtml(text: string | undefined): string { if (!text) return ""; return text .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """) .replace(/'/g, "'"); } export function DeploymentDetail({ deployment, commands }: DeploymentDetailProps): string { const content = `
${escapeHtml(deployment.repository)}
${escapeHtml(deployment.branch) || "N/A"}
${deployment.commit_hash ?
`${escapeHtml(deployment.commit_hash)}` :
"N/A"}
${getStatusBadge(deployment.status)}
No commands executed.
" : commands.map((command) => `${escapeHtml(command.stdout)}
${escapeHtml(command.stderr)}