fix(release): accept prerelease plugin min host floors

This commit is contained in:
Peter Steinberger
2026-05-02 03:37:58 +01:00
parent 535eae73e9
commit d43b985f9f
3 changed files with 9 additions and 4 deletions

View File

@@ -62,6 +62,10 @@ describe("min-host-version", () => {
it("parses semver floors", () => {
expect(parseMinHostVersionRequirement(">=2026.3.22")).toEqual(MIN_HOST_REQUIREMENT);
expect(parseMinHostVersionRequirement(">=2026.5.1-beta.1")).toEqual(BETA_MIN_HOST_REQUIREMENT);
expect(parseMinHostVersionRequirement(">=2026.5.1+20260501")).toEqual({
raw: ">=2026.5.1+20260501",
minimumLabel: "2026.5.1+20260501",
});
});
it("can parse legacy bare semver floors for runtime upgrade compatibility", () => {

View File

@@ -1,8 +1,9 @@
import { isAtLeast, parseSemver } from "../infra/runtime-guard.js";
export const MIN_HOST_VERSION_FORMAT =
'openclaw.install.minHostVersion must use a semver floor in the form ">=x.y.z" or ">=x.y.z-prerelease"';
const MIN_HOST_VERSION_RE = /^>=(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z.-]+)?$/;
'openclaw.install.minHostVersion must use a semver floor in the form ">=x.y.z[-prerelease][+build]"';
const SEMVER_LABEL_RE = String.raw`\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?`;
const MIN_HOST_VERSION_RE = new RegExp(`^>=(${SEMVER_LABEL_RE})$`);
const LEGACY_MIN_HOST_VERSION_RE = /^(\d+)\.(\d+)\.(\d+)$/;
export type MinHostVersionRequirement = {
@@ -40,7 +41,7 @@ export function parseMinHostVersionRequirement(
if (!match) {
return null;
}
const minimumLabel = `${match[1]}.${match[2]}.${match[3]}${match[4] ?? ""}`;
const minimumLabel = match.length >= 4 ? `${match[1]}.${match[2]}.${match[3]}` : (match[1] ?? "");
if (!parseSemver(minimumLabel)) {
return null;
}

View File

@@ -211,7 +211,7 @@ describe("collectBundledExtensionManifestErrors", () => {
},
]),
).toEqual([
"bundled extension 'broken' manifest invalid | openclaw.install.minHostVersion must use a semver floor in the form \">=x.y.z\"",
"bundled extension 'broken' manifest invalid | openclaw.install.minHostVersion must use a semver floor in the form \">=x.y.z[-prerelease][+build]\"",
]);
});