智能手机网站开发,设计网站收费,wordpress时间云储存,百度一下1688commit message 是开发的日常操作, 好的 log 不仅有助于他人 review, 还可以有效的输出 CHANGELOG, 对项目的管理实际至关重要, 但是在平时工作时#xff0c;只依赖大致的开发规范和自觉#xff0c;很难形成一种普遍约束。而通过本文#xff0c;对项目进行一些基础配置…commit message 是开发的日常操作, 好的 log 不仅有助于他人 review, 还可以有效的输出 CHANGELOG, 对项目的管理实际至关重要, 但是在平时工作时只依赖大致的开发规范和自觉很难形成一种普遍约束。而通过本文对项目进行一些基础配置让开发者在提交时可以自动对提交作出规范1项目效果代码提交2自动生成commit 日志2配置依赖包npm i vue-cli-plugin-commitlint commitizen commitlint conventional-changelog-cli husky -D配置package.json{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.jsmodule.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 官方文档vue-cli-plugin-commitlintwww.npmjs.com3各个包的作用解释根据上面的配置已经可以给项目配置提交的规范了。如果只是想应用那么后面的各个包的功能解释部分可以选看。huskycommitizencommitlintconventional-changelog-clihusky: git命令时自定义指定一些动作// package.json
{husky: {hooks: {pre-commit: npm test,pre-push: npm test,...: ...}}
}
// commit之前会走 test
// push之前会走 testcommitlint可以帮助我们 lint commit messages, 如果我们提交的不符合指向的规范, 直接拒绝提交, 比较狠.commitizen我们需要借助它提供的 git cz 命令替代我们的 git commit 命令, 帮助我们生成符合规范的 commit messageconventional-changelog-cli根据git的metadata生成changelog所以回看一下刚才的package.json{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}}
}当输入yarn cz时0, 首先生成log1走命令git cz。生成commit message2husky检查commit-msg: commitlint -E HUSKY_GIT_PARAMS3, 校验完成后自动提交