使用插件standard-version
和conventional-changelog
生成 changelog 文档的方法。git
在 package.json 文件中补充添加以下内容:github
"scripts": { "commit": "git-cz", "release": "standard-version", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", "eslint": "eslint --fix --format codeframe 'src/**.js'", "log": "conventional-changelog" }, "devDependencies": { "@commitlint/cli": "^8.3.5", "@commitlint/config-angular": "^8.3.4", "@commitlint/config-conventional": "^8.2.0", "cz-conventional-changelog": "^3.1.0", "husky": "^3.1.0", "lint-staged": "^10.1.1", "standard-version": "^7.0.1" }, "husky": { "hooks": { "pre-commit": "lint-staged", "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } }, "commitlint": { "extends": [ "@commitlint/config-conventional" ] }, "lint-staged": { "src/**.js": [ "eslint --fix" ] }
而后 npm run install
安装插件。web
连接:npm
npm run commit
npm run release
npm run changelog
npm run eslint
npm run log
若是想知道更多的指令,能够在终端输入: standard-version --help
和conventional-changelog --help
。json
目前使用最广的是基于 Angular 约定提交,用于说明 commit 的类别,只容许使用下面 7 个标识:ide
feat:新功能(feature)svg
fix:修补 bug工具
docs:文档(documentation)测试
style: 格式(不影响代码运行的变更)ui
refactor:重构(即不是新增功能,也不是修改 bug 的代码变更)
test:增长测试
chore:构建过程或辅助工具的变更
若是 type 为 feat 和 fix,则该 commit 将确定出如今 Change log 之中。其余状况(docs、chore、style、refactor、test)能够本身定义。
生成changelog文档如图: