Refuse a 0.x minor mismatch, and republish the overview from the named release's tree
CI / full-gate (push) Successful in 2m50s

This commit is contained in:
2026-08-22 12:13:41 +02:00
parent d8b7a2d64a
commit 2d62553a10
4 changed files with 23 additions and 7 deletions
+3
View File
@@ -86,6 +86,9 @@ test("checkApiVersion: semver compat — equal/patch ok, older minor warns, newe
assert.equal(checkApiVersion("1.3.0", "1.2.0").level, "refuse"); // needs features a newer host has
assert.equal(checkApiVersion("2.0.0", "1.5.0").level, "refuse"); // incompatible major (newer)
assert.equal(checkApiVersion("1.0.0", "2.0.0").level, "refuse"); // incompatible major (older)
assert.equal(checkApiVersion("0.1.0", "0.1.9").level, "ok"); // pre-1.0 patch is still ignored
assert.equal(checkApiVersion("0.1.0", "0.2.0").level, "refuse"); // pre-1.0 the minor IS the breaking slot
assert.equal(checkApiVersion("0.2.0", "0.1.0").level, "refuse");
for (const bad of ["1", "1.2", "v1.2.3", "01.2.3", "1.2.x", "", 1, undefined, null]) {
assert.equal(checkApiVersion(bad).level, "refuse", `${String(bad)} must refuse`);
}
+6
View File
@@ -156,6 +156,12 @@ export function checkApiVersion(pluginVersion: unknown, hostVersion: string = HO
if (plugin.major !== host.major) {
return { level: "refuse", message: `plugin targets apiVersion ${pluginVersion}; host is ${hostVersion} — incompatible major` };
}
// Pre-1.0 the major is pinned at 0 until the 1.0.0 milestone, so a breaking change can only land
// as a minor (release-tooling/next-version.ts shifts every level down). Treating that as additive
// would let a stale plugin boot and fail at runtime instead of at discovery.
if (host.major === 0 && plugin.minor !== host.minor) {
return { level: "refuse", message: `plugin targets apiVersion ${pluginVersion}; host is ${hostVersion} — pre-1.0 a minor is a contract break, rebuild against ${hostVersion}` };
}
if (plugin.minor > host.minor) {
return { level: "refuse", message: `plugin targets apiVersion ${pluginVersion} but host is ${hostVersion}; upgrade the host` };
}