[TOC]
## 1. 編譯檢測工具
## 2. git 規范信息提交工具
>[success] 由來: 在多人合作項目中,合并代碼時會因為不規范的信息提交而導致不清楚具體修改的模塊,從而耗時去查找代碼修改源
### 安裝相關依賴
~~~
$ npm install git-cz -g
// ...
$ npm install commitizen cz-customizable --dev
~~~
### 在`package.json`配置快捷腳本
> tips: 可配置可不配,配置后使用`yarn commit`命令即可,不配置使用`git-cz`亦可
> 當項目在硬盤中位置過深時,可能會遇到 `git-cz`報錯找不到 `node_modules/cz-customizable` ,這時只能手動輸入文件目錄
~~~
{
"scripts": {
// ...
"commit": "git-cz"
}
// ...
"config": {
"commitizen": {
"path": "node_modules/cz-customizable"
}
}
}
~~~
### 配置`.cz-config.js`文件,制定`commit`可選擇信息
~~~
/*
* @describe: commit可選擇信息配置
*/
'use strict'
module.exports = {
// 可供選擇類型
types: [
{
value: 'add',
name: 'add: A new feature'
}, {
value: 'fix',
name: 'fix: A bug fix'
},
// ...
],
// 可供選擇模塊區域
scopes: [
'公共模塊',
'全局組件',
'解決沖突',
'更新版本',
// ...
],
// 允許自定義范圍
// allowCustomScopes: true,
// 允許中斷更改
allowBreakingChanges: ['add', 'fix']
}
~~~
### 使用
~~~
$ git checkout
M projectConfig/package.json
M projectConfig/.cz-config.js
$ git add .
// ...
$ yarn commit
// 或者使用 git-cz
// ... 一路選擇或輸入即可
$ git push origin test
~~~