标签:commitizen log -- lint yarn Commit message commitlint cli
项目需要写版本信息时有对除了版本号之外更详细的 changelog 的展示, 于是就需要在平时的 git commit 中进行规范, 才能自动生成CHANGELOG.md.
yarn安装依赖
Husky
首先本地安装 husky yarn add husky -D, 其中 pre-commit就可以对代码进行 lint 检查, 避免 lint 的错误被上传.
{
"scripts": {
"lint": "vue-cli-service lint --fix"
},
"husky": {
"hooks": {
"pre-commit": "yarn lint && git add ."
}
}
}
Commitizen
全局安装 commitizen
yarn global add commitizen
会在使用 git cz开始提交时被触发, 可以按照模板书写适合生成 CHANGELOG 的 commit, 这样才可以通过下面的 commitlint 工具
安装完成后在项目根目录下使用
commitizen init cz-conventional-changelog --yarn --dev --exact
配置commitizen, 会在package.json 中添加commitizen路径
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
}
Commitlint
这是检查 commit-msg 是否符合标准.
yarn add @commitlint/cli @commitlint/config-conventional -D
在项目根目录新建一个文件.commitlintrc.js
module.exports = {
extends: ['@commitlint/config-conventional']
}
我们之后的所有 commit msg 都会符合 commitlint 的标准。
standard-version
standard-version 可以使用脚本生成 CHNAGELOG, 并且更新版本号, 如果有需要还可以创建 tag.
yarn add standard-version -D
{
"script": {
"release": "standard-version"
}
}
在 git status clean 的时候使用
yarn release
就会生成一个 CHANGELOG.md, 并更新版本号.
npm安装依赖
package.json配置和上一致
// 安装全局依赖
npm install --global commitizen
// 安装项目依赖
npm install --save-dev standard-version husky @commitlint/config-conventional @commitlint/cli
// 配置 commitizen
commitizen init cz-conventional-changelog --save-dev --save-exact
// 生成 CHANGELOG
npm run release
package.json scripts配置
"scripts": {
"serve": "vue-cli-service serve --open --mode development",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint --fix",
"changelog": "node scripts/changelog.js",
"dev": "vue-cli-service serve",
"new": "node scripts/new.js",
"release": "standard-version"
},
标签:commitizen,log,--,lint,yarn,Commit,message,commitlint,cli 来源: https://blog.csdn.net/chituZip/article/details/110921232
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。