Skip to content

Commit 54bd3ab

Browse files
committed
feat(plugin-loader): add more configure file to enhance js define
can see more detail https://cz-git.qbenben.com/guide/configuration.html link #30
1 parent 7304d2d commit 54bd3ab

3 files changed

Lines changed: 163 additions & 7 deletions

File tree

‎docs/guide/configuration.md‎

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

85160
## Emoji template

‎docs/zh/guide/configuration.md‎

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sitemap:
77
---
88

99
# 配置模板
10-
## 默认模板
10+
## Javascript 模板
1111

1212
- `.commitlintrc.js`
1313
- `.commitlintrc.cjs`
@@ -83,6 +83,79 @@ module.exports = {
8383

8484
:::
8585

86+
<Badge type="tip" text="提示" vertical="middle" />
87+
88+
> 如果你的项目未使用 commitlint,可以使用下列配置项
89+
90+
- `.cz.js`
91+
- `cz.js`
92+
- `cz.config.js`
93+
- `cz.cjs`
94+
95+
:::details 点击展开 cz.config.js 完整 默认 配置模板
96+
97+
```js
98+
// cz.config.js
99+
/** @type {import('cz-git').CommitizenGitOptions} */
100+
module.exports = {
101+
messages: {
102+
type: "Select the type of change that you're committing:",
103+
scope: "Denote the SCOPE of this change (optional):",
104+
customScope: "Denote the SCOPE of this change:",
105+
subject: "Write a SHORT, IMPERATIVE tense description of the change:\n",
106+
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
107+
breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
108+
footerPrefixsSelect: "Select the ISSUES type of changeList by this change (optional):",
109+
customFooterPrefixs: "Input ISSUES prefix:",
110+
footer: "List any ISSUES by this change. E.g.: #31, #34:\n",
111+
confirmCommit: "Are you sure you want to proceed with the commit above?"
112+
},
113+
types: [
114+
{ value: "feat", name: "feat: A new feature", emoji: ":sparkles:" },
115+
{ value: "fix", name: "fix: A bug fix", emoji: ":bug:" },
116+
{ value: "docs", name: "docs: Documentation only changes", emoji: ":memo:" },
117+
{ value: "style", name: "style: Changes that do not affect the meaning of the code", emoji: ":lipstick:" },
118+
{ value: "refactor", name: "refactor: A code change that neither fixes a bug nor adds a feature", emoji: ":recycle:" },
119+
{ value: "perf", name: "perf: A code change that improves performance", emoji: ":zap:" },
120+
{ value: "test", name: "test: Adding missing tests or correcting existing tests", emoji: ":white_check_mark:" },
121+
{ value: "build", name: "build: Changes that affect the build system or external dependencies", emoji: ":package:" },
122+
{ value: "ci", name: "ci: Changes to our CI configuration files and scripts", emoji: ":ferris_wheel:" },
123+
{ value: "chore", name: "chore: Other changes that don't modify src or test files", emoji: ":hammer:" },
124+
{ value: "revert", name: "revert: Reverts a previous commit", emoji: ":rewind:" }
125+
],
126+
useEmoji: false,
127+
themeColorCode: "",
128+
scopes: [],
129+
allowCustomScopes: true,
130+
allowEmptyScopes: true,
131+
customScopesAlign: "bottom",
132+
customScopesAlias: "custom",
133+
emptyScopesAlias: "empty",
134+
upperCaseSubject: false,
135+
allowBreakingChanges: ['feat', 'fix'],
136+
breaklineNumber: 100,
137+
breaklineChar: "|",
138+
skipQuestions: [],
139+
issuePrefixs: [{ value: "closed", name: "closed: ISSUES has been processed" }],
140+
customIssuePrefixsAlign: "top",
141+
emptyIssuePrefixsAlias: "skip",
142+
customIssuePrefixsAlias: "custom",
143+
allowCustomIssuePrefixs: true,
144+
allowEmptyIssuePrefixs: true,
145+
confirmColorize: true,
146+
maxHeaderLength: Infinity,
147+
maxSubjectLength: Infinity,
148+
minSubjectLength: 0,
149+
scopeOverrides: undefined,
150+
defaultBody: "",
151+
defaultIssues: "",
152+
defaultScope: "",
153+
defaultSubject: ""
154+
};
155+
```
156+
157+
:::
158+
86159
## 中英文对照模板
87160

88161
::: details 点击展开 .commitlintrc.js 完整 中英文 配置模板
@@ -238,7 +311,7 @@ module.exports = {
238311

239312
:::
240313

241-
## Emoji模板
314+
## Emoji 模板
242315

243316
::: details 点击展开 .commitlintrc.js 完整 emoji 配置模板
244317

@@ -309,7 +382,7 @@ module.exports = {
309382

310383
:::
311384

312-
## JSON模板
385+
## JSON 模板
313386

314387
- `.czrc`
315388
- `.commitlintrc`
@@ -380,7 +453,7 @@ module.exports = {
380453
```
381454
:::
382455

383-
## TypeScript模板
456+
## TypeScript 模板
384457

385458
:::danger
386459
从 v1.3.0 开始,将不再支持 TypeScript 配置文件。例如(commitlint.config.ts)

‎packages/@cz-git/plugin-loader/src/index.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,18 @@ export const clLoader = async () => {
9494
};
9595

9696
export const czLoader = async () => {
97-
const moduleName = "commitizen";
97+
const moduleName = "cz";
9898
const options = {
9999
moduleName,
100-
searchPlaces: ["package.json", ".czrc", ".cz.json"],
100+
searchPlaces: [
101+
`.${moduleName}rc`,
102+
`.${moduleName}.json`,
103+
`.${moduleName}.js`,
104+
`${moduleName}.js`,
105+
`${moduleName}.config.js`,
106+
`${moduleName}.cjs`,
107+
"package.json"
108+
],
101109
packageProp: ["config", "commitizen"]
102110
};
103111
const data = await loader(options);

0 commit comments

Comments
 (0)