Author: jettmin 2023-08-04

Git相关规范管理工具

1.前提#

已安装pnpm

2.安装husky#

🐶 husky | 🐶 husky (typicode.github.io)

  1. pnpm install husky –save-dev
  2. npx husky install
  3. 在package.json中添加
    "scripts": {
            "prepare": "husky install",
        },

3.安装commitlint#

commitlint - Lint commit messages

  1. pnpm add @commitlint/cli @commitlint/config-conventional -D
  2. 在项目根目录下添加配置文件commitlint.config.js
    touch commitlint.config.js
    // commitlint.config.js
    module.exports = {
    extends: ["@commitlint/config-conventional"],
    };

4.安装release-it#

release-it

  1. pnpm add release-it @release-it/conventional-changelog -D
  2. 在项目根目录下添加 .release-it.json
    touch .release-it.json
    //.release-it.json
    {
    "plugins": {
    "@release-it/conventional-changelog": {
    "preset": "angular",
    "infile": "CHANGELOG.md"
    }
    },
    "git": {
    "commitMessage": "chore: release v${version}",
    "push": false,
    "requireUpstream": false
    },
    "github": {
    "release": false,
    "draft": false
    },
    "npm": {
    "publish": false
    }
    }
  3. 在package.json添加
    {
    "scripts": {
    "release": "release-it"
    }
    }
  4. pnpm release

5.reference#

https://zhuanlan.zhihu.com/p/396636794
https://zhuanlan.zhihu.com/p/619659218
https://www.conventionalcommits.org/zh-hans/v1.0.0/
https://www.cnblogs.com/linhuiy/p/15896611.html
约定式提交 (conventionalcommits.org)
Commit Message 规范 - 她微笑的脸 - 博客园 (cnblogs.com)