Skip to content

Commit c6589de

Browse files
authored
feat(cz-git): provide config file type helper fn defineConfig and definePrompt (#196)
link #193
1 parent 4cffb1a commit c6589de

29 files changed

Lines changed: 916 additions & 798 deletions

‎docs/.vitepress/theme/style/main.css‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,13 @@ img.error::after {
286286

287287
.code-group .code-group__nav {
288288
margin-top: 0.85rem;
289-
margin-bottom: calc(-1.7rem - 6px);
289+
margin-bottom: calc(-1.6rem - 6px);
290290
padding-bottom: calc(1.7rem - 10px);
291291
padding-left: 10px;
292292
padding-top: 10px;
293293
border-top-left-radius: 6px;
294294
border-top-right-radius: 6px;
295+
border-bottom: 1px solid var(--vp-code-block-border);
295296
background-color: var(--vp-code-block-bg);
296297
}
297298

‎docs/.vitepress/theme/style/vars.css‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
--vp-custom-block-danger-text: rgb(196, 46, 46);
3838
--vp-custom-block-danger-text-deep: rgba(220, 38, 38, 1);
3939
--vp-code-block-bg: rgba(232, 232, 232, 0.3);
40+
--vp-code-block-border: rgba(232, 232, 232, 1);
4041
--vp-term-block-bg: hsl(0, 1%, 92%);
4142
--vp-c-text-dark-1: rgb(240, 238, 238);
4243
--vp-c-text-dark-3: rgb(111, 111, 111);
@@ -80,6 +81,7 @@
8081
--vp-custom-block-danger-text: rgba(248, 113, 113, 1);
8182
--vp-custom-block-danger-text-deep: rgba(248, 113, 113, 1);
8283
--vp-code-block-bg: rgba(0, 0, 0, 0.3);
84+
--vp-code-block-border: rgba(0, 0, 0);
8385
--vp-term-block-bg: hsl(0, 1%, 5%);
8486
--vp-c-gutter: rgba(84, 84, 84, .48);
8587
--vp-code-line-highlight-color: rgba(0, 0, 0, 0.5);

‎docs/cli/config.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ e.g `czg --config="./config/cz.js"`
3333

3434
```js
3535
// config/cz.js
36-
/** @type {import('czg').UserConfig['prompt']} */
37-
module.exports = {
36+
const { definePrompt } = require('czg')
37+
38+
module.exports = definePrompt({
3839
maxSubjectLength: 100
3940
// configure ...
40-
}
41+
})
4142
```
4243

4344
:::tip

‎docs/cli/index.md‎

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,58 @@ const v = site.value.themeConfig.nav?.[4]?.text.slice(1)
5454
}
5555
```
5656

57-
:::tip
58-
If you want to write JavaScript configuration, can add `@type` to file
57+
:::::tip
58+
If you want to write JavaScript configuration, can import helper functions from `czg` or add `@type` to file
5959

60+
:::: code-group
61+
::: code-group-item cz.config.js
6062
```js
61-
// .commitlintrc.cjs
62-
/** @type {import('czg').UserConfig} */
63+
const { definePrompt } = require('czg')
64+
65+
module.exports = definePrompt({
66+
scopes: ['hello', 'world'],
67+
})
68+
```
69+
:::
70+
::: code-group-item cz.config.js
71+
```js
72+
/** @type {import('czg').UserConfig['prompt']} */
6373
module.exports = {
64-
rules: {
65-
// @see: https://commitlint.js.org/#/reference-rules
66-
},
67-
prompt: {
6874
scopes: ['hello', 'world'],
69-
},
7075
}
7176
```
77+
:::
78+
::: code-group-item commitlint.config.js
79+
```js
80+
const { defineConfig } = require('czg')
81+
82+
module.exports = defineConfig({
83+
rules: {
84+
// @see: https://commitlint.js.org/#/reference-rules
85+
},
86+
prompt: {
87+
scopes: ['hello', 'world'],
88+
},
89+
})
90+
```
91+
:::
92+
::: code-group-item commitlint.config.js
93+
```js
94+
/** @type {import('czg').UserConfig} */
95+
module.exports = {
96+
rules: {
97+
// @see: https://commitlint.js.org/#/reference-rules
98+
},
99+
prompt: {
100+
scopes: ['hello', 'world'],
101+
},
102+
}
103+
```
104+
:::
105+
::::
72106

73107
More information about configure file and options. See → [Config](/config/)
74-
:::
108+
:::::
75109

76110

77111
## Features and Help

0 commit comments

Comments
 (0)