/** * `upgrade` — update the discovered CLI package, omp plugin, Herdr recovery plugin and brief as one pinned release. * * Moved out of cli.ts's switch by the per-verb module split (#462); * only the case wrapper, the injected `ctx` lookups and the imports * changed from the original bodies. */ import type { CommandContext } from "./context.ts"; import { upgradeConductor } from "../upgrade.ts"; export async function upgradeCommand(ctx: CommandContext): Promise { // `--bootstrap SHA --source PATH` installs an exact source/build identity // instead of a published semver (#908): the path that exists because a // reliability release cannot be cut when the installed conductor is what is // broken. Both flags or neither — a sha with no source has nothing to run the // package's own checks against, and a source with no sha is not an identity. const sha = ctx.flag("bootstrap"); const source = ctx.flag("source"); if ((sha === undefined) !== (source === undefined)) { process.stderr.write( "upgrade: --bootstrap SHA and --source PATH go together — the sha is the identity, the source is " + "the tree its checks run against\n", ); process.exitCode = 1; return; } const result = await upgradeConductor({ version: ctx.flag("to"), ...(sha === undefined || source === undefined ? {} : { bootstrap: { sha, source } }), project: ctx.projectFlag, }); const spec = sha === undefined ? `omp-conductor@${result.version}` : `${result.version} @ ${result.gitHead.slice(0, 12)}`; process.stdout.write( `${result.alreadyCurrent ? "already current" : sha === undefined ? "upgrade complete" : "bootstrap complete"}:\n` + ` omp-conductor CLI ${spec}\n` + ` omp plugin ${spec}\n` + ` Herdr plugin herdr-conductor@${result.gitHead}\n` + ` orchestrator brief managed ORCHESTRATOR.md floor current; POLICY.md preserved\n` + ` dispatch ${result.dispatch}${result.alreadyCurrent ? "" : " restored"}\n`, ); }