git commit message specification and constraint

The Commitizen, Commitlint, Husky, Standard-version program to install and use

First, create package.json file in the root directory of the project
  npm init --yes
Second, the installation configuration Commitizen
  • Command to install
  npm install -D commitizen 
  npm install -D cz-conventional-changelog
  • In the configuration in package.json
  "script": {
    ...,
    "commit": "git-cz",
  },
  "config": {
    "commitizen": {
      "path": "node_modules/cz-conventional-changelog"
    }
  }

After configuration is complete ready to use, and global command when installing git czdifferent, use the command after installation within the project are:

  npm run commit
Three, Commitlint installation and configuration
  • Command to install
  npm i -D @commitlint/config-conventional 
  npm i -D @commitlint/cli
  • Configuration: commitlint.config.js create a configuration file in the root directory of the project, and writes:
 module.exports = {
  extends: [
    ''@commitlint/config-conventional''
  ],
  rules: {
  }
};
Fourth, the installation configuration Husky
  • Command to install
  npm i -D husky
  • In package.json configure:
  "husky": {
    "hooks": {
      ...,
      "commit-msg": "commitlint -e $GIT_PARAMS"
    }
  }

This configuration will .git / hooks creating a commit-msg file

Five, Standadr-version Installation and Configuration
  • Command to install
  npm install -D standard-version
  • In the configuration in package.json
  "script": {
    ...,
    "release": "standard-version",
  }
  • use
  npm run release
  npm run release -- -f

VI Summary

  • The final use: the project will be configured package.json and commitlint.config.js file. When using only need to enter the project implementation npm installcan be.

  • npm install instructions:

    1. npm installThat npm insatll -sis npm install --save, use this command to install dependencies, it is written to dependenciesa block in.
    2. npm install -DThat npm insatll -dis npm install --save-dev, use this command to install dependencies, it is written to devDependenciesa block in.
    3. In package.json file, devDependencies inside the plug-in is used only for development environments, not in production environments, and dependencies are required to publish to the production environment.

Guess you like

Origin www.cnblogs.com/wangyingblock/p/12091465.html