Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions packages/commands/src/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
DEFAULT_INSTALL_PS1_URL,
DEFAULT_INSTALL_SCRIPT_URL,
defineCommand,
ExitCode,
getConfigDir,
getUpdateInstallMethod,
type InstallMethod,
Expand Down Expand Up @@ -121,8 +122,11 @@ export default defineCommand({
const targetVersion = pinnedVersion ?? (await resolveLatest(method, npmPackage));

if (!targetVersion) {
process.stderr.write(`${color.yellow("Could not determine the latest version.")}\n`);
return;
throw new BailianError(
"Could not determine the latest version.",
ExitCode.GENERAL,
"Check network access, or pass --to <version>.",
);
}

if (targetVersion === currentVersion) {
Expand Down Expand Up @@ -155,9 +159,12 @@ export default defineCommand({
error instanceof BailianError && error.hint
? error.hint.replace(/^Re-run:\s*/i, "")
: binaryReinstallHint().trim();
process.stderr.write(`\nAutomatic binary update failed: ${message}\n`);
process.stderr.write("Re-run the install script:\n");
process.stderr.write(` ${reinstall}\n\n`);
throw new BailianError(
"Automatic binary update failed.",
ExitCode.GENERAL,
`Re-run the install script:\n ${reinstall}`,
{ cause: message },
);
}
return;
}
Expand All @@ -179,9 +186,13 @@ export default defineCommand({
process.stderr.write(`\n${color.green("\u2713 Update complete.")}\n`);
}
updateAgentSkill(color);
} catch {
process.stderr.write("\nAutomatic update failed. Please run manually:\n");
process.stderr.write(` ${cmd}\n\n`);
} catch (error) {
throw new BailianError(
"Automatic update failed.",
ExitCode.GENERAL,
`Please run manually:\n ${cmd}`,
{ cause: error },
);
}
},
});
Loading