feat: génération de rapport Markdown d'exécution
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// server/services/report.test.ts
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { buildReportMarkdown } from "./report.js";
|
||||
import type { ExecutionResult } from "@shared/types.js";
|
||||
|
||||
const exec: ExecutionResult = {
|
||||
executionId: "exec_1", machineId: "m1", startedAt: "2026-06-04T12:00:00Z",
|
||||
finishedAt: "2026-06-04T12:05:00Z", mode: "manual", action: "apt_full_upgrade",
|
||||
status: "ok", rebootRequiredAfterRun: true,
|
||||
importantLogLines: ["Inst libc6 [2.31-13] (2.31-13+deb11u5 Debian [amd64])"],
|
||||
rawLogRef: "reports/m1/exec_1.log", reportRef: "reports/m1/exec_1.md",
|
||||
};
|
||||
|
||||
describe("buildReportMarkdown", () => {
|
||||
it("contient l'en-tête, le statut et les lignes importantes", () => {
|
||||
const md = buildReportMarkdown(exec, "deb-01");
|
||||
expect(md).toContain("# Rapport d'exécution — deb-01");
|
||||
expect(md).toContain("apt_full_upgrade");
|
||||
expect(md).toContain("Redémarrage requis : oui");
|
||||
expect(md).toContain("Inst libc6");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
// server/services/report.ts
|
||||
import type { ExecutionResult } from "@shared/types.js";
|
||||
|
||||
export function buildReportMarkdown(exec: ExecutionResult, machineName: string): string {
|
||||
const lines = exec.importantLogLines.map((l) => ` ${l}`).join("\n");
|
||||
return `# Rapport d'exécution — ${machineName}
|
||||
|
||||
- Exécution : ${exec.executionId}
|
||||
- Action : ${exec.action}
|
||||
- Statut : ${exec.status}
|
||||
- Début : ${exec.startedAt}
|
||||
- Fin : ${exec.finishedAt}
|
||||
- Redémarrage requis : ${exec.rebootRequiredAfterRun ? "oui" : "non"}
|
||||
|
||||
## Lignes importantes
|
||||
|
||||
\`\`\`
|
||||
${lines || " (aucune)"}
|
||||
\`\`\`
|
||||
|
||||
## Log brut
|
||||
|
||||
Référence : \`${exec.rawLogRef}\`
|
||||
`;
|
||||
}
|
||||
Reference in New Issue
Block a user