Lerna Changelog 자동화
아래 글에서 lerna를 이용한 monorepo 구축하는 방법에 대해 이전에 소개한 바있다.
lerna를 이용한 NPM Workspace 구축기 확인
오픈소스를 보았을 때 CHANGLOG.md라는 파일이 있는데 직접 일일히 처리하기보다는 commit msg를 이용하여 CHANGELOG를 처리하는 방법을 택하는 것이 좋을 것 같았다.
lerna version이라는 CLI 명령어가 있지만 commitlint에 따르는 옵션을 추가함으로서 CHANGELOG를 정리하는 방법에 대해 정리하고자 한다.
Installment.
commitlint를 적용하기 위해 library를 설치하고 config파일을 생성한다.
// npm
$ npm install -DW @commitlint/config-conventional @commitlint/cli
// yarn
$ yarn add -DW @commitlint/config-conventional @commitlint/cli
-D 옵션은 devDependencies 패키지 옵션입니다.
-W옵션은 monorepo root에 설치할 패키지 옵션입니다.
module.exports = {
extends: ['@commitlint/config-conventional'],
};
Lerna.json
{
"packages": ["packages/*"],
"version": "1.0.0",
// 여기부터 추가
"command": {
"version": {
"allowBranch": "main",
"conventionalCommits": true,
"changelogPreset": {
"name": "conventional-changelog-conventionalcommits",
"types": [
{
"type": "feat",
"section": ":rocket: New Features",
"hidden": false
},
{
"type": "fix",
"section": ":bug: Bug Fix",
"hidden": false
},
{
"type": "docs",
"section": ":memo: Documentation",
"hidden": false
},
{
"type": "style",
"section": ":sparkles: Styling",
"hidden": false
},
{
"type": "refactor",
"section": ":house: Code Refactoring",
"hidden": false
},
{
"type": "build",
"section": ":hammer: Build System",
"hidden": false
},
{
"type": "chore",
"section": ":mega: Other",
"hidden": false
}
]
}
},
"publish": {
"conventionalCommits": true
}
}
}
lerna version
명령어를 실행하면 변경된 package파일의 changelog가 push까지 이루어진다.
Preview
위의 lerna.json파일을 적용 후 CHANGELOG.md
Change Log
All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.
1.0.0 (2023-12-31)
🚀 New Features
react: Configure common validators (git ref)
:memo: Documentation
Rename template (git ref)
📣 Other
Configure git hook (git ref)
출처
Last updated