mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 17:53:39 +00:00
* refactor(scripts): deslop scripts/lib Consolidate script lifecycle, scenario, planner, report, release and packaging helpers while retaining CLI and publication contracts. Keep config-boundary source caches within one scan so repeated in-process checks observe edits. Carry extracted helpers through selective fixtures and iOS scope routing. Leave PR tooling and its library import closure intact. * fix(scripts): retain sanitizer fast path after helper cleanup * fix(scripts): model watchdog shell consumer in dead-code checks
28 lines
1 KiB
TypeScript
28 lines
1 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { parseReleaseVersion } from "./release-version.mjs";
|
|
|
|
export function normalizeGatewayVersionToPinnedMobileVersion(rawVersion: string): string {
|
|
const trimmed = rawVersion.trim().replace(/^v/u, "");
|
|
if (!trimmed) {
|
|
throw new Error("Missing root package.json version.");
|
|
}
|
|
|
|
const parsed = parseReleaseVersion(trimmed);
|
|
if (!parsed) {
|
|
throw new Error(
|
|
`Invalid gateway version '${rawVersion}'. Expected YYYY.M.PATCH, YYYY.M.PATCH-alpha.N, YYYY.M.PATCH-beta.N, or YYYY.M.PATCH-N.`,
|
|
);
|
|
}
|
|
return parsed.baseVersion;
|
|
}
|
|
|
|
export function readRootPackageVersion(rootDir: string): string {
|
|
const packageJsonPath = path.join(rootDir, "package.json");
|
|
const parsed = JSON.parse(readFileSync(packageJsonPath, "utf8")) as { version?: unknown };
|
|
const version = typeof parsed.version === "string" ? parsed.version.trim() : "";
|
|
if (!version) {
|
|
throw new Error(`Missing package.json version in ${packageJsonPath}.`);
|
|
}
|
|
return version;
|
|
}
|