download:DDD(畛域驱动设计)思维解读及优良实际

标准 commit msg 的意义

规范化、格式化的 commit message 能够让咱们更好的追踪需要的演进、回滚时可能疾速的找到提交、最次也能让咱们的仓库显的更业余。

团队如何标准 commit msg呢,靠宣讲、靠文档?当然得靠工具生成和束缚。前端圈轮子那么多,这种工具不在话下。

commitizen 问答式生成 commit msg 格式化commitlint 校验卡控 commit msg 规范化

commitizen

commitizen: simple commit conventions for internet citizens.

commitizen/cz-cli 借助它提供的 git cz 命令代替 git commit 命令,生成符合规范的 commit message。

commitizen 默认的提交标准是 angular 团队强规定的,若想自定义咱们还需配合 Adapter(适配器)此处咱们用cz-customizable。上面咱们间接来介绍我的项目级配置。

进行 commitizen 配置

执行 npm install -D commitizen、npm install -D cz-customizable命令

而后在 package.json文件中 scripts 和 config 字段进行配置

{  "scripts": {    "commit": "cz"  },  "config": {    "commitizen": {      "path": "./node_modules/cz-customizable"    },    "cz-customizable": {      "config": ".cz-configrc.js"    }  }}

增加 .cz-configrc.js文件,可参考 cz-demo

在我的项目的根目录下执行 npm run commit试试吧

后续t npm run commit 替换 git commit