The opening
There are many different styles of git commit on the team, and some people don’t even have the concept of a commit specification, so it can be awkward to go back and find out which version of the code went wrong 😅, and it can be difficult to quickly locate the problem. In order to standardize the project, the code submission specification is very important! Here is my vUE – CLI-plugin-commitlint (modified/packaged from Xconventional – Changelog-Angular) code submission specification. Out of the box!
Vue – cli – plugin – commitlint is introduced
Vue-cli-plugin-commitlint is written as a VUE plug-in. You can run the vue add commitlint command to use it directly. If it is not a VUE project, you can also configure it according to the following configuration.
Commitizen Commitlint Xconvention-Changelog-CLI Husky Xconvention-Changelog-Angular package, one-click installation, out-of-the-box code submission specification.
function
- Automatically checks whether a COMMIT is normal. If it is not, the commit is not allowed
- The commit format is automatically prompted. How to write it without forgetting the specification
- Git add. && Git commit does not require two commands to be executed
- Changelog is automatically generated
configuration
- If you are vuE-CLI3 project can be used directly
vue add commitlint
Copy the code
- If you are not a vuE-CLI3 project
npm i vue-cli-plugin-commitlint commitizen commitlint conventional-changelog-cli husky -D
Copy the code
- Add it in package.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"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"}},"config": {
"commitizen": {
"path": "./node_modules/vue-cli-plugin-commitlint/lib/cz"}}}Copy the code
Add the commitlint.config.js file
module.exports = {
extends: ['./node_modules/vue-cli-plugin-commitlint/lib/lint']};Copy the code
use
npm run cz # git add . && git commit -m 'feat:(xxx): xxx'
npm run log # generate CHANGELOG
Copy the code
- The code is submitted NPM run Cz
-
Selecting a type is automatically asked
- (Optional) Scope of impact of this submitted change
- (Required) Write a short description of the change
- (Optional) Provide a more detailed change description
- (Optional) Is there an incompatible change?
- (Optional) Whether this change affects some open issues
Changelog demo
The rules
The specification of | describe |
---|---|
docs | Only modified documents, such as README, CHANGELOG, CONTRIBUTE, etc |
chore | Change the build process, or add dependent libraries, tools, etc |
feat | The new feature |
fix | Fix the bug |
merge | Merging branches |
perf | Optimization related, such as improved performance, experience |
refactor | Code refactoring, no new features or bug fixes |
revert | Roll back to the previous version |
style | Only whitespace, formatting indentation, all good, etc., not changing the code logic |
test | Test cases, including unit tests, integration tests, and so on |
conclusion
I’m currently using this specification for several projects, and it’s not too fun to use!
Project address: github.com/luoxue-vict…
Welcome to PR, Star