fix(core): keep modern writer template when preset ships a legacy writer guard - #4415
Open
lazerg wants to merge 2 commits into
Open
fix(core): keep modern writer template when preset ships a legacy writer guard#4415lazerg wants to merge 2 commits into
lazerg wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
normalizeLegacyWriterOptionscompiles any stringwriter.mainTemplateit finds and assigns the result towriter.template. Presets built on@conventional-changelog/templateship 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-basedtemplate. 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.templateis already a function.Motivation and Context
lerna version --conventional-commitswithconventional-changelog-conventionalcommits@10.4.0fails with:Fixes #4414
How Has This Been Tested?
Added a unit test with a fixture preset that carries both a guard
mainTemplateand a moderntemplate. It reproduces the error onmainand passes here. Also rannx test core,nx test commands-version,nx test commands-publish, lint andformat:check.Types of changes
Checklist:
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 functionwriter.templateand a stringwriter.mainTemplatemeant only as a pre-v9 writer guard.normalizeLegacyWriterOptionsinget-changelog-config.tsno longer compilesmainTemplateintotemplatewhenwriter.templateis 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.jsfixture and anupdateChangelogtest 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.