背景
使用lerna自带的配置生成自定义的日志
--changelog-preset
lerna version --conventional-commits --changelog-preset angular-bitbucket
默认情况下,更改日志预设设置为angular . 在某些情况下,您可能想要更改使用另一个预设或自定义预设。
预设是常规变更日志的内置或可安装配置的名称。Presets 可以作为包的全名或自动扩展的后缀(例如,angular 扩展为conventional-changelog-angular )传递。
此选项也可以在lerna.json 配置中指定:
{
“changelogPreset”:“angular”
}
如果预设导出构建器函数(例如conventional-changelog-conventionalcommits ),您也可以指定预设配置:
{
“changelogPreset”:{
“name”:“ conventionalcommits ”,
“issueUrlFormat”:“ {{host}}/{{owner}}/{{repository}}/issues/{{id}} ”
}
}
package.json
{
...
"scripts": {
...
"release": "lerna publish --conventional-commits",
...
},
...
}
lerna.json
{
...
"changelogPreset": {
"name": "conventionalcommits",
"types": [
{
"type": "feat",
"section": "? Features | 新功能"
},
{
"type": "fix",
"section": "🐛 Bug Fixes | Bug 修复"
},
{
"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 | CI 配置"
}
],
"issuePrefixes": [
"#"
],
"issueUrlFormat": "{{host}}/{{owner}}/{{repository}}/issues/{{id}}",
"commitUrlFormat": "{{host}}/{{owner}}/{{repository}}/commit/{{hash}}",
"compareUrlFormat": "{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}",
"userUrlFormat": "{{host}}/{{user}}"
},
...
}
效果展示
环境信息
lerna : 4.0.0
System:
OS: macOS 12.0.1
CPU: (8) arm64 Apple M1
Binaries:
Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
Yarn: 1.22.15 - ~/.yarn/bin/yarn
npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
Utilities:
Git: 2.30.1 - /usr/bin/git
参考资料
lerna官方文档-changelog-preset
|