From a1685f9d84e7e36c6d2c1cc6426b454228ddf15d Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Thu, 17 Sep 2026 14:59:27 +0200 Subject: [PATCH 1/2] maint: Migrate handlebars changelog template to JavaScript render functions. Co-authored-by: Codex --- .release-it.js | 11 +-- release-it/conventional-changelog-commit.hbs | 72 -------------------- release-it/conventional-changelog-commit.js | 45 ++++++++++++ 3 files changed, 47 insertions(+), 81 deletions(-) delete mode 100644 release-it/conventional-changelog-commit.hbs create mode 100644 release-it/conventional-changelog-commit.js diff --git a/.release-it.js b/.release-it.js index 60035ed..e99df83 100644 --- a/.release-it.js +++ b/.release-it.js @@ -1,11 +1,4 @@ -const fs = require("fs"); -const path = require("path"); - -const commits_template = fs - .readFileSync( - path.resolve(__dirname, "release-it", "conventional-changelog-commit.hbs"), - ) - .toString(); +const commitPartial = require("./release-it/conventional-changelog-commit.js"); module.exports = { npm: { @@ -47,7 +40,7 @@ module.exports = { ], }, writerOpts: { - commitPartial: commits_template, + commitPartial, }, }, }, diff --git a/release-it/conventional-changelog-commit.hbs b/release-it/conventional-changelog-commit.hbs deleted file mode 100644 index d3fc3a0..0000000 --- a/release-it/conventional-changelog-commit.hbs +++ /dev/null @@ -1,72 +0,0 @@ - -*{{#if scope}} **{{scope}}:** -{{~/if}} {{#if subject}} - {{~subject}} -{{~else}} - {{~header}} -{{~/if}} - -{{~!-- commit link --}} {{#if @root.linkReferences~}} - ([{{shortHash}}]( - {{~#if @root.repository}} - {{~#if @root.host}} - {{~@root.host}}/ - {{~/if}} - {{~#if @root.owner}} - {{~@root.owner}}/ - {{~/if}} - {{~@root.repository}} - {{~else}} - {{~@root.repoUrl}} - {{~/if}}/ - {{~@root.commit}}/{{hash}})) -{{~else}} - {{~hash}} -{{~/if}} - -{{#if body}} - - {{body}} -{{/if}} -{{#if footer}} - - {{footer}} -{{/if}} - -{{~!-- commit references --}} -{{~#if references~}} - -closes - {{~#each references}} {{#if @root.linkReferences~}} - [ - {{~#if this.owner}} - {{~this.owner}}/ - {{~/if}} - {{~this.repository}}#{{this.issue}}]( - {{~#if @root.repository}} - {{~#if @root.host}} - {{~@root.host}}/ - {{~/if}} - {{~#if this.repository}} - {{~#if this.owner}} - {{~this.owner}}/ - {{~/if}} - {{~this.repository}} - {{~else}} - {{~#if @root.owner}} - {{~@root.owner}}/ - {{~/if}} - {{~@root.repository}} - {{~/if}} - {{~else}} - {{~@root.repoUrl}} - {{~/if}}/ - {{~@root.issue}}/{{this.issue}}) - {{~else}} - {{~#if this.owner}} - {{~this.owner}}/ - {{~/if}} - {{~this.repository}}#{{this.issue}} - {{~/if}}{{/each}} -{{~/if}} - diff --git a/release-it/conventional-changelog-commit.js b/release-it/conventional-changelog-commit.js new file mode 100644 index 0000000..da0694d --- /dev/null +++ b/release-it/conventional-changelog-commit.js @@ -0,0 +1,45 @@ +// The preset adds the list marker and indents continuation lines. +module.exports = function commitPartial(context, commit) { + const repoUrl = context.repository + ? [context.host, context.owner, context.repository].filter(Boolean).join("/") + : context.repoUrl; + const summary = [ + commit.scope && `**${commit.scope}:**`, + commit.subject || commit.header, + commit.hash && + (context.linkReferences + ? `([${commit.shortHash}](${repoUrl}/${context.commit}/${commit.hash}))` + : commit.hash), + ] + .filter(Boolean) + .join(" "); + + const references = (commit.references || []).map((reference) => { + const label = `${reference.owner ? `${reference.owner}/` : ""}${reference.repository || ""}#${reference.issue}`; + if (!context.linkReferences) { + return label; + } + + const referenceUrl = context.repository + ? [ + context.host, + reference.repository + ? reference.owner || context.owner + : context.owner, + reference.repository || context.repository, + ] + .filter(Boolean) + .join("/") + : context.repoUrl; + return `[${label}](${referenceUrl}/${context.issue}/${reference.issue})`; + }); + + return [ + summary, + commit.body, + commit.footer, + references.length && `closes ${references.join(" ")}`, + ] + .filter(Boolean) + .join("\n\n"); +}; From 8477b721dfd7db18aeeefe9e9c5ce2620bbeed89 Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Thu, 17 Sep 2026 15:04:01 +0200 Subject: [PATCH 2/2] feat: Format the changelog after generation. Use prettier to format the changelog after changelog generation. Co-authored-by: Codex --- .release-it.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.release-it.js b/.release-it.js index e99df83..5a6eb88 100644 --- a/.release-it.js +++ b/.release-it.js @@ -45,6 +45,9 @@ module.exports = { }, }, hooks: { + // Format the changelog after it is written, before Git stages it. + "after:@release-it/conventional-changelog:beforeRelease": + "npx prettier --write CHANGES.md", // Run `make bundle` after the version is bumped to get a build with // the new version number comment in the entry scripts. // Use the make target which does a check to not build if the package