开箱即用的代码提交规范
结合 commitizen
commitlint
conventional-changelog-cli
husky
,进行封装,一键安装,开箱即用的 git commit
规范。
vue add commitlint
npm i vue-cli-plugin-commitlint commitizen commitlint conventional-changelog-cli husky -D
{
"scripts": {
"log": "conventional-changelog --config ./node_modules/vue-cli-plugin-commitlint/lib/log -i CHANGELOG.md -s -r 0",
"cz": "npm run log && git add . && git cz"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"config": {
"commitizen": {
"path": "./node_modules/vue-cli-plugin-commitlint/lib/cz"
}
}
}
增加 commitlint.config.js 文件
module.exports = {
extends: ['./node_modules/vue-cli-plugin-commitlint/lib/lint']
};
npm run cz # git add . && git commit -m 'feat:(xxx): xxx'
npm run log # 生成 CHANGELOG
选择一个类型会自动询问
规范名 | 描述 |
---|---|
docs | 仅仅修改了文档,比如 README, CHANGELOG, CONTRIBUTE 等等 |
chore | 改变构建流程、或者增加依赖库、工具等 |
feat | 新增 feature |
fix | 修复 bug |
merge | 合并分之 |
perf | 优化相关,比如提升性能、体验 |
refactor | 代码重构,没有加新功能或者修复 bug |
revert | 回滚到上一个版本 |
style | 仅仅修改了空格、格式缩进、都好等等,不改变代码逻辑 |
test | 测试用例,包括单元测试、集成测试等 |