内容简介:该工具针对一些需要手动输入更新日志的项目,实现自动化输出更新日志,并且对更新日志进行内容格式化,便于后期维护,目前主要有以下几个功能模块。按照提示正确输出 commit 信息内容,如下示例:git.png
该 工具 针对一些需要手动输入更新日志的项目,实现自动化输出更新日志,并且对更新日志进行内容格式化,便于后期维护,目前主要有以下几个功能模块。
- cz -- 定制化 git 提交
- log -- 自动生成CHANGELOG.MD 日志文件
- lint -- 校验 commit 信息
一、cz 模块
1. 安装 commitizen 依赖包
cnpm i commitizen --save-dev
2. 在 package.json 中加入以下内容
{
...
"config": {
"commitizen": {
"path": "./node_modules/jimi-web-changelog/lib/cz"
}
},
}
复制代码
3. 在 package.json 中创建以下 script 命令
{
"cz": "git add . && git cz"
}
复制代码
按照提示正确输出 commit 信息内容,如下示例:
git.png
二、log 模块
1. 安装 conventional-changelog-cli 依赖包
cnpm i conventional-changelog-cli --save-dev 复制代码
2. 创建以下命令
{
...
"script": {
"log": "conventional-changelog --config node_modules/jimi-web-changelog/lib/log -i CHANGELOG.md -s -r 0",
}
}
> 结尾数字若为 1 ,生成当前版本的变化情况,若为 0, 生成所有的日志文件。
复制代码
3. 示例
md.png
三、lint 模块
1. 安装 husky commitlint 依赖
cnpm i husky commitlint --save-dev 复制代码
2. 在 package.json 中引入以下配置。
{
...
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
}
复制代码
3. 在项目根路径下创建 .commitlint.js 或者 commitlint.config.js
具体配置可以参考 commitlint 官方,例子:
module.exports = Object.assign({}, require('jimi-web-changelog/lib/lint'), {
rules: {
'subject-empty': [2, 'never'],
'type-empty': [2, 'never'],
'type-enum': [2, 'always',
[
'新功能',
'修复',
...
]
]
}
}
复制代码
建议
可以搭配 husky 和 lint-stage 效果更佳。它能在你每次提交代码前校验你的代码格式并修复错误的代码格式,具体配置可以参考当前根目录下的 package.json 和 .eslintrc.
Q&A
1. No files added to staging! Did you forget to run git add?
应该没有文件内容变动还执行 git add . 提交导致的。试着对项目进行更改再保存试试。
2. 提交后,输入更新日志命令,CHANGELOG.MD 内容没有更新?
只有每次版本迭代的的时候才会更新这一次的日志信息。可以尝试打个标签最为封版。
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- 如何实现一行命令自动生成 Flutter 插件
- pinpoint agent 插件自动生成工具 v1.0.5 发布
- pinpoint agent 插件自动生成工具v1.0.5发布
- 10个 解放双手的 IDEA 插件,能自动生成的绝不手写
- Springboot 系列(十一)使用 Mybatis(自动生成插件) 访问数据库
- Generate Api Plus v1.0.6 发布,自动生成接口文档的 IDEA 插件
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Flow-Based Programming (2nd Edition)
CreateSpace / 2010-5-14 / $69.95
Written by a pioneer in the field, this is a thorough guide to the cost- and time-saving advantages of Flow-Based Programming. It explains the theoretical underpinnings and application of this program......一起来看看 《Flow-Based Programming (2nd Edition)》 这本书的介绍吧!
JS 压缩/解压工具
在线压缩/解压 JS 代码
SHA 加密
SHA 加密工具