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 cz
different, 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 install
can be.npm install instructions:
npm install
Thatnpm insatll -s
isnpm install --save
, use this command to install dependencies, it is written todependencies
a block in.npm install -D
Thatnpm insatll -d
isnpm install --save-dev
, use this command to install dependencies, it is written todevDependencies
a block in.- 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.