- 使用angular团队的preset
$ yarn global add commitizen cz-conventional-changelog
echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc
- 自定义
$ yarn global add commitizen cz-customizable
echo '{ "path": "cz-customizable" }' > ~/.czrc
自定义方法需copy .cz-config.js
到项目的任何地方
- 使用angular团队的
$ yarn add @commitlint/config-conventional @commitlint/cli -D
# 项目目录下添加.commitlintrc.js,内容如下
module.exports = {
extends: [
'@commitlint/config-conventional'
],
rules: {}
}
- 自定义
$ yarn add commitlint-config-cz @commitlint/cli -D
# 项目目录下添加.commitlintrc.js,内容如下
module.exports = {
extends: [
'cz'
],
rules: {}
}
$ yarn add husky@next -D
# package.json 中添加
"husky": {
"hooks": {
"commit-msg": "commitlint -e $GIT_PARAMS"
}
},
$ yarn add standard-version -D
# package.json 中添加
"scirpt": {
"release": "standard-version"
}