mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 16:13:12 +09:00
scripts/prepare_release.mts takes a version, sets it in the package.json files under packages/ and plugins/, adds the pr_to_changelog.mts output to the top of CHANGELOG.md, then commits "Prepare <version>" and tags it v<version>. It does not push. pr_to_changelog.mts now exports generateReleaseNotes() so the output can be reused. The template comment in CHANGELOG.md is removed so the first "## " heading is always the latest release. Closes #1240 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
import assert from "node:assert/strict";
|
|
|
|
import { addChangelogEntry, setPackageVersion } from "../scripts/prepare_release.mts";
|
|
|
|
|
|
describe("scripts/prepare_release", function() {
|
|
describe("setPackageVersion()", function() {
|
|
it("replaces only the package version", function() {
|
|
const text = (version) => `${JSON.stringify({
|
|
name: "@clusterio/lib",
|
|
version,
|
|
dependencies: { a: "2.1.1" },
|
|
}, null, "\t")}\n`;
|
|
assert.equal(setPackageVersion(text("2.1.1"), "2.2.0"), text("2.2.0"));
|
|
});
|
|
it("throws if there is no version", function() {
|
|
assert.throws(() => setPackageVersion('{\n\t"name": "x"\n}\n', "2.2.0"), /No version field/);
|
|
});
|
|
});
|
|
|
|
describe("addChangelogEntry()", function() {
|
|
const changelog = "# Changelog\n\n## Version 2.1.1\n\n### Fixes\n\n- Old fix.\n";
|
|
|
|
it("adds the entry above the previous release", function() {
|
|
assert.equal(
|
|
addChangelogEntry(changelog, "2.1.2", "### Fixes\n\n- New fix.\n"),
|
|
"# Changelog\n\n## Version 2.1.2\n\n### Fixes\n\n- New fix.\n\n\n" +
|
|
"## Version 2.1.1\n\n### Fixes\n\n- Old fix.\n",
|
|
);
|
|
});
|
|
it("throws if the version already has an entry", function() {
|
|
assert.throws(() => addChangelogEntry(changelog, "2.1.1", "- Fix."), /already has an entry/);
|
|
});
|
|
});
|
|
});
|