feat: parser sortie apt-get -s full-upgrade -> AptPackage[]
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// server/services/aptParse.ts
|
||||
import type { AptPackage } from "@shared/types.js";
|
||||
|
||||
// Exemple de ligne:
|
||||
// Inst pve-manager [8.4-1] (8.4-3 Proxmox VE:8.x [amd64])
|
||||
// Inst newpkg (1.0.0 Debian:11.6/stable [all])
|
||||
const INST_RE = /^Inst (\S+) (?:\[([^\]]+)\] )?\((\S+) (.+?) \[[^\]]+\]\)\s*$/;
|
||||
|
||||
export function parseAptSimulate(raw: string): AptPackage[] {
|
||||
const out: AptPackage[] = [];
|
||||
for (const line of raw.split("\n")) {
|
||||
const m = INST_RE.exec(line.trimEnd());
|
||||
if (!m) continue;
|
||||
out.push({
|
||||
name: m[1]!,
|
||||
currentVersion: m[2] ?? null,
|
||||
targetVersion: m[3]!,
|
||||
origin: (m[4] ?? "").trim() || null,
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
export function parseRebootRequired(raw: string): boolean {
|
||||
return /REBOOT_REQUIRED=1/.test(raw);
|
||||
}
|
||||
Reference in New Issue
Block a user