From 6ef6b7c9d8ef55879c90dc5df14d497c2d6d0c7e Mon Sep 17 00:00:00 2001 From: dtzp555 Date: Mon, 11 May 2026 04:04:29 +1000 Subject: [PATCH] chore(upgrade): nit fixes from Bundle 3 code-quality review 3 micro-fixes on 48e9408: 1. Remove unused mkdirSync import 2. snapshot-not-found error message hints "must be inside ~/.ocp/upgrade-snapshot-*" 3. runFreshInstall failure now includes e.stderr (or e.message fallback) in the thrown error and steps[].error so non-interactive callers see the actual reason Co-Authored-By: Claude Opus 4.7 --- scripts/upgrade.mjs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/upgrade.mjs b/scripts/upgrade.mjs index c839f63..dea84bf 100644 --- a/scripts/upgrade.mjs +++ b/scripts/upgrade.mjs @@ -13,7 +13,7 @@ import { runDoctor } from "./doctor.mjs"; import { execSync } from "node:child_process"; import { homedir } from "node:os"; import { join } from "node:path"; -import { existsSync, copyFileSync, mkdirSync } from "node:fs"; +import { existsSync, copyFileSync } from "node:fs"; import { writeSnapshot, listSnapshots, readSnapshot } from "./lib/snapshot.mjs"; export async function runUpgrade(opts = {}) { @@ -180,8 +180,9 @@ async function runFreshInstall({ doctor, opts }) { execSync(cmd, { stdio: "inherit" }); steps.push({ cmd, status: "ok" }); } catch (e) { - steps.push({ cmd, status: "fail", error: String(e.message || e) }); - throw Object.assign(new Error(`fresh_install step failed: ${cmd}`), { steps }); + const detail = e.stderr?.toString().trim() || e.message; + steps.push({ cmd, status: "fail", error: String(detail) }); + throw Object.assign(new Error(`fresh_install step failed: ${cmd} — ${detail}`), { steps }); } } } @@ -202,7 +203,7 @@ async function runRollback(opts) { const target = opts.snapshotPath ? snapshots.find(s => s.path === opts.snapshotPath) : snapshots[snapshots.length - 1]; - if (!target) throw new Error(`snapshot not found: ${opts.snapshotPath}`); + if (!target) throw new Error(`snapshot not found: ${opts.snapshotPath} (must be inside ~/.ocp/upgrade-snapshot-*)`); const meta = opts.mockSnapshotMeta ?? readSnapshot(target.path); if (!meta.fromCommit) throw new Error(`snapshot ${target.path} has no from-commit.txt`);