feat: add dev update channel

This commit is contained in:
Peter Steinberger
2026-01-20 13:33:31 +00:00
parent cc24ede586
commit 4ebf55f1db
14 changed files with 378 additions and 123 deletions

View File

@@ -5,6 +5,11 @@ import type { loadConfig } from "../config/config.js";
import { resolveStateDir } from "../config/paths.js";
import { resolveClawdbotPackageRoot } from "./clawdbot-root.js";
import { compareSemverStrings, fetchNpmTagVersion, checkUpdateStatus } from "./update-check.js";
import {
channelToNpmTag,
normalizeUpdateChannel,
DEFAULT_PACKAGE_CHANNEL,
} from "./update-channels.js";
import { VERSION } from "../version.js";
import { formatCliCommand } from "../cli/command-format.js";
@@ -17,17 +22,6 @@ type UpdateCheckState = {
const UPDATE_CHECK_FILENAME = "update-check.json";
const UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
function normalizeChannel(value?: string | null): "stable" | "beta" | null {
if (!value) return null;
const normalized = value.trim().toLowerCase();
if (normalized === "stable" || normalized === "beta") return normalized;
return null;
}
function channelToTag(channel: "stable" | "beta"): string {
return channel === "beta" ? "beta" : "latest";
}
function shouldSkipCheck(allowInTests: boolean): boolean {
if (allowInTests) return false;
if (process.env.VITEST || process.env.NODE_ENV === "test") return true;
@@ -89,8 +83,8 @@ export async function runGatewayUpdateCheck(params: {
return;
}
const channel = normalizeChannel(params.cfg.update?.channel) ?? "stable";
const tag = channelToTag(channel);
const channel = normalizeUpdateChannel(params.cfg.update?.channel) ?? DEFAULT_PACKAGE_CHANNEL;
const tag = channelToNpmTag(channel);
const tagStatus = await fetchNpmTagVersion({ tag, timeoutMs: 2500 });
if (!tagStatus.version) {
await writeState(statePath, nextState);