Skip to content

fix(core): keep modern writer template when preset ships a legacy writer guard - #4415

Open
lazerg wants to merge 2 commits into
lerna:mainfrom
lazerg:fix/legacy-writer-guard-normalization
Open

fix(core): keep modern writer template when preset ships a legacy writer guard#4415
lazerg wants to merge 2 commits into
lerna:mainfrom
lazerg:fix/legacy-writer-guard-normalization

Conversation

@lazerg

@lazerg lazerg commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Description

normalizeLegacyWriterOptions compiles any string writer.mainTemplate it finds and assigns the result to writer.template. Presets built on @conventional-changelog/template ship such a string on purpose: it is a guard that renders to a "you need conventional-changelog-writer@9 or newer" error, and it sits next to the real function-based template. Since the guard is only meant to be read by an old writer, normalizing it throws away the working template and makes the bundled v9 writer render the error instead.

The normalization now leaves the writer options alone when writer.template is already a function.

Motivation and Context

lerna version --conventional-commits with conventional-changelog-conventionalcommits@10.4.0 fails with:

Missing helper: "conventional-changelog-conventionalcommits requires conventional-changelog-writer@9 or newer (conventional-changelog@8 or newer). Your changelog tooling loaded an older writer which cannot render this preset. Update the tooling or use an older major version of the preset."

Fixes #4414

How Has This Been Tested?

Added a unit test with a fixture preset that carries both a guard mainTemplate and a modern template. It reproduces the error on main and passes here. Also ran nx test core, nx test commands-version, nx test commands-publish, lint and format:check.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (change that has absolutely no effect on users)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Note

Low Risk
Narrow bug fix in preset normalization for conventional changelog; behavior for legacy-only string templates is unchanged, with a dedicated regression test.

Overview
Fixes changelog generation for modern presets (e.g. conventional-changelog-conventionalcommits@10) that ship both a function writer.template and a string writer.mainTemplate meant only as a pre-v9 writer guard.

normalizeLegacyWriterOptions in get-changelog-config.ts no longer compiles mainTemplate into template when writer.template is already a function, so Lerna’s v9 writer keeps the real template instead of rendering the “upgrade your writer” guard message.

Adds a legacy-guard-preset.js fixture and an updateChangelog test that asserts the changelog entry is generated normally with such a preset.

Reviewed by Cursor Bugbot for commit 2040f7c. Bugbot is set up for automated code reviews on this repo. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

normalizeLegacyWriterOptions mis-triggers conventionalcommits@10.4's legacy-writer guard even with a modern writer

1 participant