mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 00:00:43 +00:00
fix(cli): repair legacy config before update channel switch (#77069)
* fix(cli): repair legacy config before update channel switch * docs(changelog): note update channel legacy config repair * fix(update): keep legacy config repair doctor-owned * fix(update): keep dry runs read-only * fix(update): avoid include-flattening legacy repair
This commit is contained in:
@@ -1686,6 +1686,23 @@ function createUpdatedChannelSnapshot(
|
||||
};
|
||||
}
|
||||
|
||||
async function maybeRepairLegacyConfigForUpdateChannel(params: {
|
||||
configSnapshot: Awaited<ReturnType<typeof readConfigFileSnapshot>>;
|
||||
jsonMode: boolean;
|
||||
}): Promise<Awaited<ReturnType<typeof readConfigFileSnapshot>>> {
|
||||
if (params.configSnapshot.valid || params.configSnapshot.legacyIssues.length === 0) {
|
||||
return params.configSnapshot;
|
||||
}
|
||||
|
||||
const { repairLegacyConfigForUpdateChannel } =
|
||||
await import("../../commands/doctor/legacy-config-repair.js");
|
||||
const { snapshot, repaired } = await repairLegacyConfigForUpdateChannel(params);
|
||||
if (!params.jsonMode && repaired) {
|
||||
defaultRuntime.log(theme.muted("Migrated legacy config before changing update channel."));
|
||||
}
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
async function writePostCorePluginUpdateResultFile(
|
||||
filePath: string | undefined,
|
||||
result: PostCorePluginUpdateResult,
|
||||
@@ -1947,17 +1964,24 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
|
||||
includeRegistry: false,
|
||||
});
|
||||
|
||||
const configSnapshot = await readConfigFileSnapshot();
|
||||
const storedChannel = configSnapshot.valid
|
||||
? normalizeUpdateChannel(configSnapshot.config.update?.channel)
|
||||
: null;
|
||||
|
||||
const requestedChannel = normalizeUpdateChannel(opts.channel);
|
||||
if (opts.channel && !requestedChannel) {
|
||||
defaultRuntime.error(`--channel must be "stable", "beta", or "dev" (got "${opts.channel}")`);
|
||||
defaultRuntime.exit(1);
|
||||
return;
|
||||
}
|
||||
|
||||
let configSnapshot = await readConfigFileSnapshot();
|
||||
if (opts.channel && !opts.dryRun && !configSnapshot.valid) {
|
||||
configSnapshot = await maybeRepairLegacyConfigForUpdateChannel({
|
||||
configSnapshot,
|
||||
jsonMode: Boolean(opts.json),
|
||||
});
|
||||
}
|
||||
const storedChannel = configSnapshot.valid
|
||||
? normalizeUpdateChannel(configSnapshot.config.update?.channel)
|
||||
: null;
|
||||
|
||||
if (opts.channel && !configSnapshot.valid) {
|
||||
const issues = formatConfigIssueLines(configSnapshot.issues, "-");
|
||||
defaultRuntime.error(["Config is invalid; cannot set update channel.", ...issues].join("\n"));
|
||||
|
||||
Reference in New Issue
Block a user