feat(cli): migrate child json recovery callers
This commit is contained in:
@@ -2,6 +2,7 @@ import { randomBytes } from "node:crypto";
|
||||
import { basename, join, resolve } from "node:path";
|
||||
import { repoRoot } from "./config";
|
||||
import { runCommand, type CommandResult } from "./command";
|
||||
import { resolveCliChildJsonCommandResult } from "./cli-child-json-recovery";
|
||||
|
||||
export interface WebProbeRemoteArtifactJobOptions {
|
||||
route: string;
|
||||
@@ -99,7 +100,12 @@ export function runWebProbeRemoteArtifactJob(options: WebProbeRemoteArtifactJobO
|
||||
const download = runCommand(downloadArgs, repoRoot, { timeoutMs: commandTimeoutMs });
|
||||
commandResults.push(download);
|
||||
lastDownload = download;
|
||||
const parsed = parseJsonObject(download.stdout);
|
||||
const downloadJson = resolveCliChildJsonCommandResult({
|
||||
result: download,
|
||||
requestedStdoutType: "trans download verification JSON",
|
||||
acceptParsed: (value) => typeof value.ok === "boolean" || typeof value.verified === "boolean" || typeof value.bytes === "number" || typeof value.sha256 === "string",
|
||||
});
|
||||
const parsed = downloadJson.parsed ?? {};
|
||||
if (download.exitCode === 0 && parsed.ok === true && parsed.verified === true) {
|
||||
artifacts.push({
|
||||
remotePath: artifact.remotePath,
|
||||
@@ -109,6 +115,7 @@ export function runWebProbeRemoteArtifactJob(options: WebProbeRemoteArtifactJobO
|
||||
verified: true,
|
||||
verification: parsed.verification ?? null,
|
||||
transfer: parsed.transfer ?? null,
|
||||
stdoutRecovery: downloadJson.diagnostics,
|
||||
manifestBytes: artifact.bytes,
|
||||
manifestSha256: artifact.sha256,
|
||||
});
|
||||
@@ -124,6 +131,11 @@ export function runWebProbeRemoteArtifactJob(options: WebProbeRemoteArtifactJobO
|
||||
exitCode: lastDownload?.exitCode ?? null,
|
||||
stdoutTail: lastDownload?.stdout.slice(-1000) ?? "",
|
||||
stderrTail: lastDownload?.stderr.slice(-1000) ?? "",
|
||||
stdoutRecovery: lastDownload === null ? null : resolveCliChildJsonCommandResult({
|
||||
result: lastDownload,
|
||||
requestedStdoutType: "trans download verification JSON",
|
||||
acceptParsed: (value) => typeof value.ok === "boolean" || typeof value.verified === "boolean" || typeof value.bytes === "number" || typeof value.sha256 === "string",
|
||||
}).diagnostics,
|
||||
};
|
||||
break;
|
||||
}
|
||||
@@ -468,17 +480,6 @@ function wrapBase64(value: string): string {
|
||||
return value.replace(/.{1,76}/gu, "$&\n").trimEnd();
|
||||
}
|
||||
|
||||
function parseJsonObject(text: string): Record<string, unknown> {
|
||||
const trimmed = text.trim();
|
||||
if (trimmed.length === 0) return {};
|
||||
try {
|
||||
const parsed = JSON.parse(trimmed) as unknown;
|
||||
return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed as Record<string, unknown> : {};
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function parseTabStatus(text: string): Record<string, string> {
|
||||
const out: Record<string, string> = {};
|
||||
for (const rawLine of text.split(/\r?\n/u)) {
|
||||
|
||||
Reference in New Issue
Block a user