From d2e39b0baa94f0c7b5b55f2d547c24cc18c18db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=99=93=E6=99=A8?= <825316969@qq.com> Date: Mon, 31 May 2021 13:36:16 +0800 Subject: [PATCH 1/4] [Add::doc] add chinese document --- README.md | 20 +++++++--- doc/README-zh.md | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 110 insertions(+), 5 deletions(-) create mode 100644 doc/README-zh.md diff --git a/README.md b/README.md index 065e77c..3a6e1f0 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,27 @@ # commitlint-wizardoc + +English | [中文文档](doc/README-zh.md) + commitlint-wizardoc is a configuration package for [commitlint](https://github.com/conventional-changelog/commitlint) that contain some rules and plugins to check that your commit message conform to the `Wizardoc` convention. ## Usage + If you have never used commitlint before, you can visit [commitlint document](https://commitlint.js.org/) for more detail. ### Install + You can install `commitlint-wizardoc` using NPM and YARN as well. ```shell # NPM -npm i commitlint-wizardoc -D +npm i commitlint-config-wizardoc -D # YARN -yarn add commitlint-wizardoc -D +yarn add commitlint-config-wizardoc -D ``` ### Configuration + Create a [commitlint](https://github.com/conventional-changelog/commitlint) config in the root path of your project, and you can extends the `wizardoc` config to do all configuration work. For instance, create `.commitlintrc.js` that looks like: @@ -23,14 +29,16 @@ For instance, create `.commitlintrc.js` that looks like: ```js module.exports = { // This line config will read the NPM package named "commitlint-config-wizardoc", so please make sure you have installed it before config this line. - extends: 'wizardoc' -} + extends: "wizardoc", +}; ``` Now, that's all you need to do. ## Convention + The commit message should consists of four parts: + ``` ![Feat::scope] some sentence ^ ^ ^ ^ @@ -62,9 +70,10 @@ The commit message should consists of four parts: - Stub - Chore - `Scope`: scope of modification -- `Subject`: description of the commit +- `Subject`: description of the commit ## Override configs + You can also override `Wizardoc` config to create your own configuration as well. ```js @@ -78,4 +87,5 @@ module.exports = { ``` ## LICENSE + MIT. diff --git a/doc/README-zh.md b/doc/README-zh.md new file mode 100644 index 0000000..0bef4c3 --- /dev/null +++ b/doc/README-zh.md @@ -0,0 +1,95 @@ +# commitlint-wizardoc + +[English](/README.md) | 中文文档 + +commitlint-wizardoc 是 [commitlint](https://github.com/conventional-changelog/commitlint) 的配置包,其中包含某些规则和插件,以检查您的提交`commit-message`是否符合 `Wizardoc` 约定。 + +## 用法 + +如果你之前没有使用过 commitlint,你可以前往[commitlint document](https://commitlint.js.org/)来查看更多详情。 + +### 安装 + +你可以使用`npm`和`yarn`来安装`commitlint-wizardoc`。 + +```shell +# NPM +npm i commitlint-config-wizardoc -D + +# YARN +yarn add commitlint-config-wizardoc -D +``` + +### 配置 + +在你项目的根目录下创建一个[commitlint](https://github.com/conventional-changelog/commitlint)的配置文件,你能通过`extends` `wizardoc`的`config`文件来完成配置。 + +例如,将以下代码加入到`.commitlintrc.js`文件。 + +```js +module.exports = { + // This line config will read the NPM package named "commitlint-config-wizardoc", so please make sure you have installed it before config this line. + extends: "wizardoc", +}; +``` + +只需要做这些,你就可以使用`commitlint-wizardow`的`commit-message`的校验了。 + +## 规则 + +git 的`commit-message`由以下四部分组成: + +``` +![Feat::scope] some sentence +^ ^ ^ ^ +| | | | +| | | | +| | | |- Subject(required) +| | | +| | |- Scope(optional) +| | +| |- Type(required) +| +|- Break change symbol(optional) +``` + +- `Break change symbol`:在提交破坏性更改的时候,需要使用时候用`Break change symbol`。 +- `Type`:`commit-message`的`Type`必须是以下类型之一。 + + | 规范名 | 描述 | + | -------- | ------------------------------------ | + | Feat | 新增新功能 | + | Init | 新建项目时,对项目的初始化 | + | Remove | 小面积的文件删除 | + | Delete | 大面积的文件删除 | + | Update | 对原有功能的修改 | + | Refactor | 代码重构 | + | Move | 移动文件位置 | + | New | 规模较大的新增 | + | Add | 规模较小的新增 | + | Patch | 对公共方法的完善或者优化 | + | Fix | 修复 bug | + | Test | 测试用例,包括单元测试、集成测试等 | + | Stub | mock 的数据 | + | Chore | 改变构建流程、或者增加依赖库、工具等 | + +- `Scope`: 修改的模块。 +- `Subject`: 提交的具体描述信息。 + +## 覆盖配置 + +你可以覆盖 `Wizardoc` 的配置,来创建自己的配置 + +```js +module.exports = { + extends: 'wizardoc', + rules: [ + // Set the $ as the third parameter if you wanna change break symbol to $ + "break-change-prefix": [2, "always", '$'], + ] +} +``` + +## LICENSE + +MIT. From 20a235c64c7098d15bf49a82f4e5de2e9b02619d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=99=93=E6=99=A8?= <825316969@qq.com> Date: Mon, 31 May 2021 13:48:07 +0800 Subject: [PATCH 2/4] [Update] commit type add Doc Perf and delete New in config readme --- README.md | 3 ++- doc/README-zh.md | 3 ++- packages/commitlint-config-wizardoc/src/constants.ts | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3a6e1f0..d892fb6 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,8 @@ The commit message should consists of four parts: - Update - Refactor - Move - - New + - Perf + - Doc - Add - Patch - Fix diff --git a/doc/README-zh.md b/doc/README-zh.md index 0bef4c3..611cbad 100644 --- a/doc/README-zh.md +++ b/doc/README-zh.md @@ -65,7 +65,8 @@ git 的`commit-message`由以下四部分组成: | Update | 对原有功能的修改 | | Refactor | 代码重构 | | Move | 移动文件位置 | - | New | 规模较大的新增 | + | Perf | 优化相关,比如提升性能、体验 | + | Doc | 修改了文档,比如 README | | Add | 规模较小的新增 | | Patch | 对公共方法的完善或者优化 | | Fix | 修复 bug | diff --git a/packages/commitlint-config-wizardoc/src/constants.ts b/packages/commitlint-config-wizardoc/src/constants.ts index 9be4791..7190071 100644 --- a/packages/commitlint-config-wizardoc/src/constants.ts +++ b/packages/commitlint-config-wizardoc/src/constants.ts @@ -14,13 +14,14 @@ export enum CommitType { UPDATE = "Update", REFACTOR = "Refactor", MOVE = "Move", - NEW = "New", ADD = "Add", PATCH = "Patch", FIX = "Fix", TEST = "Test", STUB = "Stub", CHORE = "Chore", + PERF = "Perf", + DOC = "Doc", } export const CONVERSION_MATCH_REGEX = /^(.?)\[(\w+?)(?:\:\:(\w*))?\]\s(.*)$/; From 1b7b2f78939674b9fbd4ec03b2b6449ce6f4d09b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=99=93=E6=99=A8?= <825316969@qq.com> Date: Mon, 31 May 2021 14:24:53 +0800 Subject: [PATCH 3/4] [Update::readme] update type description --- doc/README-zh.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/doc/README-zh.md b/doc/README-zh.md index 611cbad..8fbce19 100644 --- a/doc/README-zh.md +++ b/doc/README-zh.md @@ -56,23 +56,23 @@ git 的`commit-message`由以下四部分组成: - `Break change symbol`:在提交破坏性更改的时候,需要使用时候用`Break change symbol`。 - `Type`:`commit-message`的`Type`必须是以下类型之一。 - | 规范名 | 描述 | - | -------- | ------------------------------------ | - | Feat | 新增新功能 | - | Init | 新建项目时,对项目的初始化 | - | Remove | 小面积的文件删除 | - | Delete | 大面积的文件删除 | - | Update | 对原有功能的修改 | - | Refactor | 代码重构 | - | Move | 移动文件位置 | - | Perf | 优化相关,比如提升性能、体验 | - | Doc | 修改了文档,比如 README | - | Add | 规模较小的新增 | - | Patch | 对公共方法的完善或者优化 | - | Fix | 修复 bug | - | Test | 测试用例,包括单元测试、集成测试等 | - | Stub | mock 的数据 | - | Chore | 改变构建流程、或者增加依赖库、工具等 | + | 规范名 | 描述 | + | -------- | -------------------------------- | + | Feat | 新增新功能 | + | Init | 新建项目时,对项目的初始化 | + | Remove | 代码的改动(删除),粒度较小 | + | Delete | 文件的改动(删除),粒度较小 | + | Update | 代码块的修改 | + | Refactor | 代码重构 | + | Move | 移动文件位置 | + | Perf | 优化相关,比如提升性能、体验 | + | Doc | 修改了文档,比如 README | + | Add | 规模较小的新增 | + | Patch | 增加逻辑块为了修复某一个逻辑错误 | + | Fix | 修复 bug | + | Test | 覆盖测试用例 | + | Stub | 桩代码用于临时测试 | + | Chore | 小修改,修复,一些琐碎的小事情 | - `Scope`: 修改的模块。 - `Subject`: 提交的具体描述信息。 From cce50ce678cc9849c3e0c178aabba7fc9c9a2123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=99=93=E6=99=A8?= <825316969@qq.com> Date: Mon, 31 May 2021 19:36:22 +0800 Subject: [PATCH 4/4] [Fix::readme] update type description --- doc/README-zh.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/README-zh.md b/doc/README-zh.md index 8fbce19..1da0f15 100644 --- a/doc/README-zh.md +++ b/doc/README-zh.md @@ -61,12 +61,12 @@ git 的`commit-message`由以下四部分组成: | Feat | 新增新功能 | | Init | 新建项目时,对项目的初始化 | | Remove | 代码的改动(删除),粒度较小 | - | Delete | 文件的改动(删除),粒度较小 | + | Delete | 文件的改动(删除),粒度较大 | | Update | 代码块的修改 | | Refactor | 代码重构 | | Move | 移动文件位置 | | Perf | 优化相关,比如提升性能、体验 | - | Doc | 修改了文档,比如 README | + | Doc | 文档相关的修改 | | Add | 规模较小的新增 | | Patch | 增加逻辑块为了修复某一个逻辑错误 | | Fix | 修复 bug |