Skip to content

Commit 7b1c8db

Browse files
authored
feat: support more configure file | add scopeFilter and typesDefault
* feat: add .cz.js and cz.config.js config file * feat: add scopeFilters options * feat: add defaultType options * feat: support custom define config file * feat: support get promise Func options
2 parents 6515dce + 1d4c013 commit 7b1c8db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+651
-139
lines changed

.commitlintrc.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
const fs = require('fs')
2-
const path = require('path')
3-
const { execSync } = require('child_process');
1+
const fs = require("fs");
2+
const path = require("path");
3+
const { execSync } = require("child_process");
44

55
// @description: git branch name = feature/issue_33 => auto get defaultIssues = #33
6-
const issue = execSync('git rev-parse --abbrev-ref HEAD')
6+
const issue = execSync("git rev-parse --abbrev-ref HEAD")
77
.toString()
88
.trim()
9-
.split("_")[1]
9+
.split("_")[1];
1010
// @description: monorepo dynamic get name
11-
const packages = fs.readdirSync(path.resolve(__dirname, 'packages/@cz-git'));
11+
const packages = fs.readdirSync(path.resolve(__dirname, "packages/@cz-git"));
1212

1313
/** @type {import('cz-git').UserConfig} */
1414
module.exports = {
1515
extends: ["@commitlint/config-conventional"],
1616
rules: {
17-
"scope-enum": [2, "always", [ "cz-git", "guide", ...packages ]],
18-
"subject-min-length": [2, 'always', 2],
19-
"subject-empty": [2, "never"],
17+
"scope-enum": [2, "always", ["cz-git", "guide", ...packages]],
18+
"subject-min-length": [2, "always", 2],
19+
"subject-empty": [2, "never"]
2020
},
2121
prompt: {
2222
// @see: https://github.com/Zhengqbbb/cz-git#options

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@typescript-eslint/no-unused-vars": "error",
1919
"@typescript-eslint/no-explicit-any": "off",
2020
"@typescript-eslint/no-var-requires": "off",
21-
"@typescript-eslint/ban-ts-comment": "off"
21+
"@typescript-eslint/ban-ts-comment": "off",
22+
"@typescript-eslint/no-non-null-assertion": "off"
2223
}
2324
}

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"volar.autoCompleteRefs": true,
23
"github-actions.workflows.pinned.workflows": [
34
".github/workflows/nodejs.yml",
45
".github/workflows/docs.yml"

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ A more engineered, lightweight, customizable, standard output format [commitizen
5858

5959
```bash
6060
$ npm i -D cz-git
61-
+ cz-git (1.8 MB)
62-
added 1 package in 0.47s
61+
+ cz-git (1.7 MB)
62+
added 1 package in 0.461s
6363
```
6464

6565
## Usage
@@ -89,6 +89,7 @@ added 1 package in 0.47s
8989

9090
- [tdesign-vue-next](https://github.com/Tencent/tdesign-vue-next)
9191
- [vue3-antd-admin](https://github.com/buqiyuan/vue3-antd-admin)
92+
- [Geeker-Admin](https://github.com/HalseySpicy/Geeker-Admin)
9293
- [vuepress-theme-hope](https://github.com/vuepress-theme-hope/vuepress-theme-hope)
9394
- [vuepress-theme-gungnir](https://github.com/Renovamen/vuepress-theme-gungnir)
9495

docs/.vuepress/components/FeatureCN.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ import Emoji from "./Emoji.vue";
2929
$ npm install -D cz-git<br />
3030
+ cz-git
3131
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
32-
(<span class="token number"> 1.8 MB </span>) <br />added &nbsp;<span class="token number"
32+
(<span class="token number"> 1.7 MB </span>) <br />added &nbsp;<span class="token number"
3333
>1</span
34-
>&nbsp; package in &nbsp;<span class="token number">0.47s</span>
34+
>&nbsp; package in &nbsp;<span class="token number">0.461s</span>
3535
</p>
3636
</div>
3737
<div class="feature">

docs/.vuepress/components/FeatureEN.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ import Emoji from "./Emoji.vue";
3131
$ npm install -D cz-git<br />
3232
+ cz-git
3333
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
34-
(<span class="token number"> 1.8 MB </span>) <br />added &nbsp;<span class="token number"
34+
(<span class="token number"> 1.7 MB </span>) <br />added &nbsp;<span class="token number"
3535
>1</span
36-
>&nbsp; package in &nbsp;<span class="token number">0.47s</span>
36+
>&nbsp; package in &nbsp;<span class="token number">0.461s</span>
3737
</p>
3838
</div>
3939
<div class="feature">

docs/guide/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ A more engineered, lightweight, customizable, standard output format [commitizen
6464

6565
```bash
6666
$ npm i -D cz-git
67-
+ cz-git (1.8 MB)
68-
added 1 package in 0.47s
67+
+ cz-git (1.7 MB)
68+
added 1 package in 0.461s
6969
```
7070

7171
[⇒ Why cz-git](/guide/why.html)
@@ -74,6 +74,7 @@ added 1 package in 0.47s
7474

7575
- [tdesign-vue-next](https://github.com/Tencent/tdesign-vue-next)
7676
- [vue3-antd-admin](https://github.com/buqiyuan/vue3-antd-admin)
77+
- [Geeker-Admin](https://github.com/HalseySpicy/Geeker-Admin)
7778
- [vuepress-theme-hope](https://github.com/vuepress-theme-hope/vuepress-theme-hope)
7879
- [vuepress-theme-gungnir](https://github.com/Renovamen/vuepress-theme-gungnir)
7980

docs/guide/configuration.md

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ sitemap:
88

99
# Configure Template
1010

11-
## Default template
11+
## Javascript template
1212

1313
- `.commitlintrc.js`
1414
- `.commitlintrc.cjs`
1515
- `commitlint.config.js`
1616
- `commitlint.config.cjs`
1717

1818
::: details Click to expand .commitlintrc.js complete default configuration template
19+
1920
```js
2021
// commitlint.config.js | .commitlintrc.js
2122
/** @type {import('cz-git').UserConfig} */
@@ -80,8 +81,96 @@ module.exports = {
8081
}
8182
};
8283
```
84+
85+
:::
86+
87+
<Badge type="tip" text="Tip" vertical="middle" />
88+
89+
> If your project does not use commitlint, you can use the following configuration items
90+
91+
- `.cz.js`
92+
- `cz.config.js`
93+
94+
:::details Click to expand cz.config.js complete default configuration template
95+
96+
```js
97+
// cz.config.js
98+
/** @type {import('cz-git').CommitizenGitOptions} */
99+
module.exports = {
100+
messages: {
101+
type: "Select the type of change that you're committing:",
102+
scope: "Denote the SCOPE of this change (optional):",
103+
customScope: "Denote the SCOPE of this change:",
104+
subject: "Write a SHORT, IMPERATIVE tense description of the change:\n",
105+
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
106+
breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
107+
footerPrefixsSelect: "Select the ISSUES type of changeList by this change (optional):",
108+
customFooterPrefixs: "Input ISSUES prefix:",
109+
footer: "List any ISSUES by this change. E.g.: #31, #34:\n",
110+
confirmCommit: "Are you sure you want to proceed with the commit above?"
111+
},
112+
types: [
113+
{ value: "feat", name: "feat: A new feature", emoji: ":sparkles:" },
114+
{ value: "fix", name: "fix: A bug fix", emoji: ":bug:" },
115+
{ value: "docs", name: "docs: Documentation only changes", emoji: ":memo:" },
116+
{ value: "style", name: "style: Changes that do not affect the meaning of the code", emoji: ":lipstick:" },
117+
{ value: "refactor", name: "refactor: A code change that neither fixes a bug nor adds a feature", emoji: ":recycle:" },
118+
{ value: "perf", name: "perf: A code change that improves performance", emoji: ":zap:" },
119+
{ value: "test", name: "test: Adding missing tests or correcting existing tests", emoji: ":white_check_mark:" },
120+
{ value: "build", name: "build: Changes that affect the build system or external dependencies", emoji: ":package:" },
121+
{ value: "ci", name: "ci: Changes to our CI configuration files and scripts", emoji: ":ferris_wheel:" },
122+
{ value: "chore", name: "chore: Other changes that don't modify src or test files", emoji: ":hammer:" },
123+
{ value: "revert", name: "revert: Reverts a previous commit", emoji: ":rewind:" }
124+
],
125+
useEmoji: false,
126+
themeColorCode: "",
127+
scopes: [],
128+
allowCustomScopes: true,
129+
allowEmptyScopes: true,
130+
customScopesAlign: "bottom",
131+
customScopesAlias: "custom",
132+
emptyScopesAlias: "empty",
133+
upperCaseSubject: false,
134+
allowBreakingChanges: ['feat', 'fix'],
135+
breaklineNumber: 100,
136+
breaklineChar: "|",
137+
skipQuestions: [],
138+
issuePrefixs: [{ value: "closed", name: "closed: ISSUES has been processed" }],
139+
customIssuePrefixsAlign: "top",
140+
emptyIssuePrefixsAlias: "skip",
141+
customIssuePrefixsAlias: "custom",
142+
allowCustomIssuePrefixs: true,
143+
allowEmptyIssuePrefixs: true,
144+
confirmColorize: true,
145+
maxHeaderLength: Infinity,
146+
maxSubjectLength: Infinity,
147+
minSubjectLength: 0,
148+
scopeOverrides: undefined,
149+
defaultBody: "",
150+
defaultIssues: "",
151+
defaultScope: "",
152+
defaultSubject: ""
153+
};
154+
```
155+
83156
:::
84157

158+
<Badge type="tip" text="Tip" vertical="middle" /> You can also optionally custom configuration file path in package.json
159+
160+
```json{8}
161+
{
162+
"scripts": {
163+
"commit": "git cz"
164+
},
165+
"config": {
166+
"commitizen": {
167+
"path": "node_modules/cz-git",
168+
"czConfig": "./config/cz.config.js"
169+
}
170+
}
171+
}
172+
```
173+
85174
## Emoji template
86175

87176
::: details Click to expand .commitlintrc.js complete emoji template template

docs/guide/option-engineer.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,19 @@ If you define a `scope-enum` using the [commitlint](https://github.com/conventio
2323
- **description** : After customizing a specific **type**, **override module scope** command line display information
2424
- **type** : <br>`{ [type: string]: string[] | Array<{ name: string, value?: string }> } | undefined`
2525
- **default** : `undefined`
26-
- **example** : `scopeOverrides: { "test": ['e2eTest, 'unitTest'] }`
26+
- **example** : `scopeOverrides: { "test": ["e2eTest", "unitTest"] }`
2727
- **use** : Displays custom module scope selection when selecting module scope after selecting ==specific== commit **type** : `type`
2828

2929
:::tip
3030
If you define `scopeOverrides` then define generic `scopes`
3131
:::
3232

33+
## scopeFilters
34+
35+
- **description** : Filter select of prompt to select module scopes by the scope.value
36+
- **type** : string[]
37+
- **default** : `[".DS_Store"]`
38+
3339
## enableMultipleScopes
3440

3541
- **description** : Whether to enable the use of **multiple scopes mode**
@@ -72,7 +78,7 @@ It will automatically detect whether the definition of the [commitlint](https://
7278

7379
- **description** : a specific **type** that allows BREAKING CHANGES
7480
- **type** : `string[]`
75-
- **default** : `['feat', 'fix']`
81+
- **default** : `["feat", "fix"]`
7682

7783
## upperCaseSubject
7884

docs/guide/options-show.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,27 @@ Try running `emoji=1 cz` to **enable output emoji mode in the current session**
104104

105105
---
106106

107+
<br/>
108+
<br/>
109+
<br/>
110+
107111
:::tip
108112
Using ==default value== can produce many ways to make the tool more suitable for you or your team's habits, [⇒ see the recipes](/guide/recipes.html#default)
109113
:::
110114

115+
## defaultType
116+
117+
- **description** : pin type item the top of the types list (match item value)
118+
- **type** : `string`
119+
- **default** : `""`
120+
111121
## defaultScope
112122

113123
- **description** : Whether to use display default value in **custom scope**
114124
- **type** : `string`
115125
- **default** : `""`
116126
- **use** : when you want the default value to appear on the command line just press the "Enter" key
117-
118-
:::tip
119-
If `defaultScope` matches the scope list item `value`.
120-
It will be pinned to the top of scope list.
121-
:::
127+
<Badge type="tip" text="Tip" vertical="middle" /> pin scope item the top of the scope list (match item value)
122128

123129
## defaultSubject
124130

docs/guide/recipes.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ module.exports = {
152152
};
153153
```
154154

155-
![demo-gif](https://user-images.githubusercontent.com/40693636/169853818-a13ab13a-3b2d-4386-a833-2f3558b2c138.gif)
155+
![demo-gif](https://user-images.githubusercontent.com/40693636/170404847-bc1a76d5-f7bb-4ec6-9c1f-5476ba7fceee.gif)
156156

157157
<br>
158158
<br>
@@ -166,7 +166,9 @@ module.exports = {
166166
- Then we use `defaultIssues`
167167
- When using, we only need to press the ==\<Enter\>== key to output the `Issue Number`, so that we can easily intercept the `Issue Number` to reduce repetitive work.
168168

169-
- <Badge type="tip" text="Tip" vertical="middle" /> Of course, we can also combine the `customIssuePrefixsAlign` configuration item to dynamically change the position of the issue prefix option.
169+
<Badge type="tip" text="Tip" vertical="middle" />
170+
171+
We can also combine the `customIssuePrefixsAlign` configuration item to dynamically change the position of the issue prefix option.
170172

171173
```js{5-8,13-14}
172174
// .commitlintrc.js

docs/guide/why.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ $ npm i -D cz-conventional-changelog
2525
added 147 packages in 21s
2626
2727
$ npm install -D cz-git
28-
added 1 package in 0.47s
28+
added 1 package in 0.461s
2929
```
3030

3131
---
@@ -37,5 +37,5 @@ added 1 package in 0.47s
3737
```sh{3}
3838
$ du -sh node_modules/*
3939
148 MB node_modules/git-cz
40-
1.8 MB node_modules/cz-git
40+
1.7 MB node_modules/cz-git
4141
```

docs/zh/guide/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ sitemap:
6464

6565
```bash
6666
$ npm install -D cz-git
67-
+ cz-git (1.8 MB)
68-
added 1 package in 0.47s
67+
+ cz-git (1.7 MB)
68+
added 1 package in 0.461s
6969
```
7070

7171
[⇒ 为什么是 cz-git](/zh/guide/why.html)

0 commit comments

Comments
 (0)