Git commit specification with commitizen Commitlint Xcom – Changelog – CLI husky for encapsulation, one-click installation, and out of the box.

In multi-team collaborative development, each developer has different habits and submits different COMMIT information. The COMMIT information is extremely important in a project, which is an intuitive representation of the maintenance status of project iterations at different stages and the best way to choose code View when reviewing. After the team sorted out the commit specifications, the constraint tools were used to provide a set of guidelines for each developer’s commit message, making the commit message in the project look elegant and clear.

Related plug-ins

The main commit constraint plug-in:

  • Commitizen A tool to format commit messages

  • Commitlint checks that the commit message complies with the normal commit format.

  • Convention-changelog – CLI The changelog file is generated after each commit

  • @commitlint/config-conventional Some regular commitlint rules that, if not met, generate a non-zero exit code to exit the currently executing program.

Auxiliary plug-in:

  • Vue-cli-plugin-commitlint Code submission specifications provided by VUE. The prompt messages are mainly in Chinese
  • husky git hooks

Installation:

npm i vue-cli-plugin-commitlint commitizen commitlint conventional-changelog-cli husky -D
Copy the code

Function:

  1. Automatically checks whether a COMMIT is normal. If it is not, the commit is not allowed
  2. The commit format is automatically prompted. How to write it without forgetting the specification
  3. Git add. && Git commit does not require two commands to be executed
  4. Changelog is automatically generated

configuration

  1. pacakge.json

    {
      "scripts": {
        "log": "conventional-changelog --config ./node_modules/vue-cli-plugin-commitlint/lib/log -i CHANGELOG.md -s -r 0"."cz": "npm run log && git add . && git cz",},"config": {
        "commitizen": {
          "path": "./node_modules/vue-cli-plugin-commitlint/lib/cz"}},"husky": {
        "hooks": {
          "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"}}}Copy the code
  2. Added the commitment. Config. js file

    module.exports = {
      extends: [
        './node_modules/vue-cli-plugin-commitlint/lib/lint'.'@commitlint/config-conventional']};Copy the code
  3. use

    #Generate the Changelog file and run git add. && git commit -m"" 
    npm run cz
    
    #The Changelog file is generated
    npm run log
    Copy the code
👇 official account 👇