安装 commitizen 后,进行初始化
npm install -g commitizen or yarn global add commitizen
commitizen init cz-conventional-changelog --save-dev --save-exact
格式校验工具 commitlint
yarn add @commitlint/{config-conventional,cli} --dev
同时需要在项目目录下创建配置文件 .commitlintrc.js
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {},
};
安装husky
yarn add husky@next -D
配置 package.json
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"src/**/*.{ts,tsx,jsx}": [
"eslint --fix",
"git add"
]
},
生成 Changelog 工具 Conventional Changelog
yarn add standard-version --dev
然后配置package.json配置执行的脚本
{
"scripts": {
"release": "standard-version"
}
}