diff --git a/packages/plugin-sdk/CHANGELOG.md b/packages/plugin-sdk/CHANGELOG.md index fe9090843..39e7550e0 100644 --- a/packages/plugin-sdk/CHANGELOG.md +++ b/packages/plugin-sdk/CHANGELOG.md @@ -9,6 +9,7 @@ - `termix-plugin migrations` loads the table definitions from a path with a `#` or other URL characters in it - Text, json and encrypted columns are `longtext` on MySQL in new migrations, so they are no longer capped at 64KB. Existing migrations keep `text` - `i18next`, `react-dom`, `react-i18next` and `sonner` are optional peer dependencies, so npm stops installing them into backend-only plugins +- `termix-plugin validate` accepts a beta version like `1.1.0-beta.1` when the changelog's newest release is `1.1.0` or older, so beta releases pass ## 1.0.4 diff --git a/packages/plugin-sdk/src/changelog.ts b/packages/plugin-sdk/src/changelog.ts index 446baed42..c59f62c34 100644 --- a/packages/plugin-sdk/src/changelog.ts +++ b/packages/plugin-sdk/src/changelog.ts @@ -194,7 +194,9 @@ export function parseChangelog(markdown: string): { /** * Checks a CHANGELOG.md. With a manifest version, the newest release has to - * be that version, so a release never ships without its notes. + * be that version, so a release never ships without its notes. A beta like + * 1.1.0-beta.2 gets its notes from git, so it only needs the newest release + * to be 1.1.0 or older. */ export function validateChangelog( markdown: string, @@ -206,7 +208,16 @@ export function validateChangelog( return problems; } const newest = changelog.releases[0].version; - if (manifestVersion && newest !== manifestVersion) { + const base = manifestVersion + ? semver.valid(semver.coerce(manifestVersion)) + : null; + const betaOk = + !!manifestVersion && + !!semver.prerelease(manifestVersion) && + !!base && + !!semver.valid(newest) && + semver.lte(newest, base); + if (manifestVersion && newest !== manifestVersion && !betaOk) { problems.push( `the newest release is ${newest}, but the manifest version is ${manifestVersion}`, ); diff --git a/scripts/plugin-changelog.test.ts b/scripts/plugin-changelog.test.ts index 34518c43c..6516b0e14 100644 --- a/scripts/plugin-changelog.test.ts +++ b/scripts/plugin-changelog.test.ts @@ -131,6 +131,17 @@ describe("validateChangelog", () => { ); }); + it("lets a beta through when its notes are not written yet", () => { + expect(validateChangelog(FILE, "1.1.0-beta.1")).toEqual([]); + expect(validateChangelog(FILE, "1.2.0-beta.3")).toEqual([]); + }); + + it("flags a beta older than the newest release", () => { + expect(validateChangelog(FILE, "1.0.1-beta.1")).toContain( + "the newest release is 1.1.0, but the manifest version is 1.0.1-beta.1", + ); + }); + it("flags a file with no releases", () => { expect(validateChangelog("# Changelog\n", "1.0.0")).toEqual([ 'no releases found, add a "## 1.0.0" heading',