Reputation: 1059
Lerna is overall quite a powerfull tool for managing monorepoes in JavaScript with a lot of nice features.
However one thing that I really struggle to find recently - is an ability to gain more controll on the changes lerna applies, specifically when running lerna version
command.
lerna version
generates CHANGELOG.md
changes based on commits, bumps up packages versions and creates a new commit (or with certain flags updates the current commit).
I would like to find a way to prevent changes from being commited to customize my CHANGELOG.md
based on what lerna has generated - Is there a way to do so?
I'm using [email protected]
Upvotes: 2
Views: 591
Reputation: 13214
Lerna is using external dependencies to do the conventional changelog stuff, for example the bump is created by the conventional-changelog-recommend-bump
dependency and the changelog, you could guess, is produced by using the conventional-changelog
dependency.
You can customize how the changelog is created by defining a changelogPreset
with the conventionalcommits
name and passing and defining a types
object in Lerna and in that object you can provide an array of type
rules to follow which follows the spec defined in conventional-changelog-config-spec
For example you can see below a config with emojis and different conventional titles
Note that the example shown below was copied from this public repo, which is not mine, and they use Lerna-Lite which uses the same config as Lerna, you can also take a look at their changelog.md to see what it produces
{
"$schema": "node_modules/@lerna-lite/cli/schemas/lerna-schema.json",
"version": "0.0.1"
"packages": [
"packages/*"
],
"changelogPreset": {
"name": "conventionalcommits",
"types": [
{
"type": "feat",
"section": "✨ Features"
},
{
"type": "fix",
"section": "🐛 Bug Fixes"
},
{
"type": "chore",
"section": "🚀 Chore",
"hidden": true
},
{
"type": "docs",
"section": "📝 Documentation"
},
{
"type": "style",
"section": "💄 Styles"
},
{
"type": "refactor",
"section": "♻️ Code Refactoring"
},
{
"type": "perf",
"section": "⚡ Performance Improvements"
},
{
"type": "test",
"section": "✅ Tests",
"hidden": true
},
{
"type": "revert",
"section": "⏪ Revert",
"hidden": true
},
{
"type": "build",
"section": "📦 Build System"
},
{
"type": "ci",
"section": "👷 Continuous Integration"
}
],
"issuePrefixes": [
"#"
],
"issueUrlFormat": "{{host}}/{{owner}}/{{repository}}/issues/{{id}}",
"commitUrlFormat": "{{host}}/{{owner}}/{{repository}}/commit/{{hash}}",
"compareUrlFormat": "{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}",
"userUrlFormat": "{{host}}/{{user}}"
}
}
You can see some of that have been tagged as hidden
which mean that they won't show up in the changelog.
Also note that in lerna.json
, you could also add a ignoreChanges
array of files to ignore so that it doesn't bump for irrelevant files like spec files or fixtures, for example in Lerna-Lite we use this config
{
"$schema": "node_modules/@lerna-lite/cli/schemas/lerna-schema.json",
"version": "0.0.1"
"ignoreChanges": [
"**/__fixtures__/**",
"**/__tests__/**",
"**/helpers/**",
"**/*.md"
]
}
Upvotes: 2