1.说明
在VbenAdmin
项目的脚本命令和根目录中还有CHANGELOG.md
这么个文件,这是记录我们项目变更记录的MD。明显不是手写出来的,那么怎么生成?
参考链接:
2.安装
要全局安装。按照官网说的做就行。
yarn add global conventional-changelog-cli --dev
3.配置脚本
package.json
文件中的scripts
字段。
"log": "conventional-changelog -p angular -i CHANGELOG.md -s",
4.测试
4.1.测试1
yarn log
可以看见生成了CHANGELOG.md
文件,但是没有之前build
的记录,具体记录哪些等级的变更不太清楚。
# 0.0.0 (2021-03-14)
### Features
- 我们成功的规范了 Git 提交! ([6c61fc5](https://gitee.com/kuxiaoxin/vben3/commits/6c61fc5c0bc9d0ed551117eb00349ce82e35deea))
4.2.测试2
因为CHANGELOG.md
本身就是变更文件。
git add .
yarn cz
# feat: 我们添加了变更日志!
yarn log
结果是从上追加,同一天,看来是要我们手动删除下面的记录。
# 0.0.0 (2021-03-14)
### Features
- 我们成功的规范了 Git 提交! ([6c61fc5](https://gitee.com/kuxiaoxin/vben3/commits/6c61fc5c0bc9d0ed551117eb00349ce82e35deea))
- 我们添加了变更日志! ([b03e385](https://gitee.com/kuxiaoxin/vben3/commits/b03e3851df45db390e3f801f81660690560d41d1))
# 0.0.0 (2021-03-14)
### Features
- 我们成功的规范了 Git 提交! ([6c61fc5](https://gitee.com/kuxiaoxin/vben3/commits/6c61fc5c0bc9d0ed551117eb00349ce82e35deea))
4.3.测试3
再来一次:
git add .
yarn cz
# fix: 假设我们修复了一个Bug
yarn log
结果如期:
# 0.0.0 (2021-03-14)
### Bug Fixes
* 假设我们修复了一个Bug ([bc9266a](https://gitee.com/kuxiaoxin/vben3/commits/bc9266a14077c8006115dd9beaf2fe7b90964f56))
### Features
* 我们成功的规范了Git提交! ([6c61fc5](https://gitee.com/kuxiaoxin/vben3/commits/6c61fc5c0bc9d0ed551117eb00349ce82e35deea))
* 我们添加了变更日志! ([b03e385](https://gitee.com/kuxiaoxin/vben3/commits/b03e3851df45db390e3f801f81660690560d41d1))
# 0.0.0 (2021-03-14)
### Features
- 我们成功的规范了 Git 提交! ([6c61fc5](https://gitee.com/kuxiaoxin/vben3/commits/6c61fc5c0bc9d0ed551117eb00349ce82e35deea))
- 我们添加了变更日志! ([b03e385](https://gitee.com/kuxiaoxin/vben3/commits/b03e3851df45db390e3f801f81660690560d41d1))
# 0.0.0 (2021-03-14)
### Features
- 我们成功的规范了 Git 提交! ([6c61fc5](https://gitee.com/kuxiaoxin/vben3/commits/6c61fc5c0bc9d0ed551117eb00349ce82e35deea))
5.命令行参数
> conventional-changelog --help
Generate a changelog from git metadata
Usage
conventional-changelog
Example
conventional-changelog -i CHANGELOG.md --same-file
Options
-i, --infile Read the CHANGELOG from this file
# 从这个文件中读取CHANGELOG。
-o, --outfile Write the CHANGELOG to this file
If unspecified, it prints to stdout
# 将CHANGELOG写入这个文件。
# 如果没有指定,则打印到stdout。
-s, --same-file Outputting to the infile so you don't need to specify the same file as outfile
# 输出到infile,所以你不需要指定与outfile相同的文件。
-p, --preset Name of the preset you want to use. Must be one of the following:
angular, atom, codemirror, ember, eslint, express, jquery, jscs or jshint
# 您要使用的预设名称。必须是下列之一。
# angular, atom, codemirror,
# ember, eslint, express,
# jquery, jscs, jshint。
-k, --pkg A filepath of where your package.json is located
Default is the closest package.json from cwd
# 您的 package.json 所在的文件路径。
# 默认为cwd中最接近的package.json。
-a, --append Should the newer release be appended to the older release
Default: false
# 是否应将较新的版本附加到较旧的版本上?
# 默认:不追加
-r, --release-count How many releases to be generated from the latest
If 0, the whole changelog will be regenerated and the outfile will be overwritten
Default: 1
# 将从最新的版本中生成多少个版本。
# 如果为0,整个变更日志将被重新生成,并且输出文件将被覆盖。
# 默认值: 1
--skip-unstable If given, unstable tags will be skipped, e.g., x.x.x-alpha.1, x.x.x-rc.2
# 如果给定,将跳过不稳定的标签,例如,x.x.x-alpha.1, x.x.x-rc.2。
-u, --output-unreleased Output unreleased changelog
# 输出未发布的变更日志。
-v, --verbose Verbose output. Use this for debugging
Default: false
# Verbose 输出。用来调试
# 默认:不输出
-n, --config A filepath of your config script
Example of a config script: https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-changelog-cli/test/fixtures/config.js
# 配置脚本的文件路径。
# 配置脚本的例子:
# https://github.com/conventional-changelog
# /conventional-changelog/blob/master/packages
# /conventional-changelog-cli/test/fixtures/config.js
-c, --context A filepath of a json that is used to define template variables
# 一个用于定义模板变量的json文件路径。
-l, --lerna-package Generate a changelog for a specific lerna package (:pkg-name@1.0.0)
# 为一个特定的lerna包生成一个变更日志(:pkg-name@1.0.0)
-t, --tag-prefix Tag prefix to consider when reading the tags
# 读取标签时要考虑的标签前缀。
--commit-path Generate a changelog scoped to a specific directory
# 生成一个特定目录下的变更日志。
上一章
第二十章-使用commitizen询问式commit消息
下一章
第二十二章-准备配置Vite