Skip to content

Commit

Permalink
feat(cz-git): lightweight package, refactor configure loader #27(close
Browse files Browse the repository at this point in the history
…#24,#25)

feat(plugin-loader): use cosmiconfig realize cl and cz configure loader
feat(cz-git): bundle cz-git package
  • Loading branch information
Zhengqbbb committed May 14, 2022
2 parents 9efe275 + 6bcca59 commit 87575a2
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 529 deletions.
79 changes: 8 additions & 71 deletions docs/guide/configuration.md
Expand Up @@ -10,7 +10,7 @@ lastUpdated: true

::: details Click to expand .commitlintrc.js complete default configuration template
```js
// .commitlintrc.js
// commitlint.config.js | .commitlintrc.js
/** @type {import('cz-git').UserConfig} */
module.exports = {
rules: {
Expand Down Expand Up @@ -210,76 +210,13 @@ It is recommended to use JavaScript for configuration files in the project. You

## TypeScript template

:::warning
Defining configuration with TypeScript is deprecated as **this affects command line tool startup speed**<br>And using the js configuration file to add the `@type` annotation can be a good way to provide code hints at configuration time
:::

::: details Click to expand .commitlintrc.ts complete default configuration template

```ts
// .commitlintrc.ts
import type { UserConfig } from "cz-git"
const config: UserConfig = {
rules: {
// @see: https://commitlint.js.org/#/reference-rules
},
prompt: {
messages: {
type: "Select the type of change that you're committing:",
scope: "Denote the SCOPE of this change (optional):",
customScope: "Denote the SCOPE of this change:",
subject: "Write a SHORT, IMPERATIVE tense description of the change:\n",
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
footerPrefixsSelect: "Select the ISSUES type of changeList by this change (optional):",
customFooterPrefixs: "Input ISSUES prefix:",
footer: "List any ISSUES by this change. E.g.: #31, #34:\n",
confirmCommit: "Are you sure you want to proceed with the commit above?"
},
types: [
{ value: "feat", name: "feat: A new feature", emoji: ":sparkles:" },
{ value: "fix", name: "fix: A bug fix", emoji: ":bug:" },
{ value: "docs", name: "docs: Documentation only changes", emoji: ":memo:" },
{ value: "style", name: "style: Changes that do not affect the meaning of the code", emoji: ":lipstick:" },
{ value: "refactor", name: "refactor: A code change that neither fixes a bug nor adds a feature", emoji: ":recycle:" },
{ value: "perf", name: "perf: A code change that improves performance", emoji: ":zap:" },
{ value: "test", name: "test: Adding missing tests or correcting existing tests", emoji: ":white_check_mark:" },
{ value: "build", name: "build: Changes that affect the build system or external dependencies", emoji: ":building_construction:" },
{ value: "ci", name: "ci: Changes to our CI configuration files and scripts", emoji: ":ferris_wheel:" },
{ value: "chore", name: "chore: Other changes that don't modify src or test files", emoji: ":hammer:" },
{ value: "revert", name: "revert: Reverts a previous commit", emoji: ":rewind:" }
],
useEmoji: false,
scopes: [],
allowCustomScopes: true,
allowEmptyScopes: true,
customScopesAlign: "bottom",
customScopesAlias: "custom",
emptyScopesAlias: "empty",
upperCaseSubject: false,
allowBreakingChanges: ['feat', 'fix'],
breaklineNumber: 100,
breaklineChar: "|",
skipQuestions: [],
issuePrefixs: [{ value: "closed", name: "closed: ISSUES has been processed" }],
customIssuePrefixsAlign: "top",
emptyIssuePrefixsAlias: "skip",
customIssuePrefixsAlias: "custom",
allowCustomIssuePrefixs: true,
allowEmptyIssuePrefixs: true,
confirmColorize: true,
maxHeaderLength: Infinity,
maxSubjectLength: Infinity,
minSubjectLength: 0,
scopeOverrides: undefined,
defaultBody: "",
defaultIssues: "",
defaultScope: "",
defaultSubject: ""
}
};
:::danger
**Since v1.2.0. The typescript configuration file will no longer be loaded**. e.g(commitlint.config.ts)

export default config
```
- Using the TypeScript configuration file will **affects command line tool startup speed**.
- Increase the package size.
:::

:::tip
Using the js configuration file to add the `@type` annotation can be a good way to provide code hints at configuration time.
:::
77 changes: 8 additions & 69 deletions docs/zh/guide/configuration.md
Expand Up @@ -362,75 +362,14 @@ module.exports = {
:::

## TypeScript模板
:::warning
不推荐使用 TypeScript 定义配置,因为**这会影响命令行工具启动速度** <br>
并且使用 js 配置文件添加`@type` 注释可以很好提供在配置时的代码提示
:::

::: details 点击展开 .commitlintrc.ts 完整 默认 配置模板
```ts
// .commitlintrc.ts
import type { UserConfig } from "cz-git"
const config: UserConfig = {
rules: {
// @see: https://commitlint.js.org/#/reference-rules
},
prompt: {
messages: {
type: "Select the type of change that you're committing:",
scope: "Denote the SCOPE of this change (optional):",
customScope: "Denote the SCOPE of this change:",
subject: "Write a SHORT, IMPERATIVE tense description of the change:\n",
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
breaking: 'List any BREAKING CHANGES (optional). Use "|" to break new line:\n',
footerPrefixsSelect: "Select the ISSUES type of changeList by this change (optional):",
customFooterPrefixs: "Input ISSUES prefix:",
footer: "List any ISSUES by this change. E.g.: #31, #34:\n",
confirmCommit: "Are you sure you want to proceed with the commit above?"
},
types: [
{ value: "feat", name: "feat: A new feature", emoji: ":sparkles:" },
{ value: "fix", name: "fix: A bug fix", emoji: ":bug:" },
{ value: "docs", name: "docs: Documentation only changes", emoji: ":memo:" },
{ value: "style", name: "style: Changes that do not affect the meaning of the code", emoji: ":lipstick:" },
{ value: "refactor", name: "refactor: A code change that neither fixes a bug nor adds a feature", emoji: ":recycle:" },
{ value: "perf", name: "perf: A code change that improves performance", emoji: ":zap:" },
{ value: "test", name: "test: Adding missing tests or correcting existing tests", emoji: ":white_check_mark:" },
{ value: "build", name: "build: Changes that affect the build system or external dependencies", emoji: ":building_construction:" },
{ value: "ci", name: "ci: Changes to our CI configuration files and scripts", emoji: ":ferris_wheel:" },
{ value: "chore", name: "chore: Other changes that don't modify src or test files", emoji: ":hammer:" },
{ value: "revert", name: "revert: Reverts a previous commit", emoji: ":rewind:" }
],
useEmoji: false,
scopes: [],
allowCustomScopes: true,
allowEmptyScopes: true,
customScopesAlign: "bottom",
customScopesAlias: "custom",
emptyScopesAlias: "empty",
allowBreakingChanges: ['feat', 'fix'],
upperCaseSubject: false,
breaklineNumber: 100,
breaklineChar: "|",
skipQuestions: [],
issuePrefixs: [{ value: "closed", name: "closed: ISSUES has been processed" }],
customIssuePrefixsAlign: "top",
emptyIssuePrefixsAlias: "skip",
customIssuePrefixsAlias: "custom",
allowCustomIssuePrefixs: true,
allowEmptyIssuePrefixs: true,
confirmColorize: true,
maxHeaderLength: Infinity,
maxSubjectLength: Infinity,
minSubjectLength: 0,
scopeOverrides: undefined,
defaultBody: "",
defaultIssues: "",
defaultScope: "",
defaultSubject: ""
}
};
:::danger
从 v1.2.0 开始,将不再支持 TypeScript 配置文件。例如(commitlint.config.ts)

export default config
```
- 使用 TypeScript 配置文件会**影响命令行工具的启动速度**
- 增加软件包的依赖项体积
:::

:::tip
使用 js 配置文件添加`@type` 注释可以很好提供在配置时的代码提示.
:::
12 changes: 9 additions & 3 deletions packages/@cz-git/plugin-loader/package.json
Expand Up @@ -28,10 +28,16 @@
"build:dev": "pnpm clean && tsc -b",
"clean": "rimraf *.tsbuildinfo lib dist"
},
"config": {
"commitizen": {
"path": "node_modules/cz-git",
"useEmoji": true
}
},
"devDependencies": {
"@commitlint/load": "16.2.1",
"glob": "^7.1.3",
"strip-json-comments": "3.1.1"
"@commitlint/resolve-extends": "^16.2.1",
"@commitlint/types": "^16.2.1",
"cosmiconfig": "^7.0.1"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 0 additions & 3 deletions packages/@cz-git/plugin-loader/src/commitilint/index.ts

This file was deleted.

0 comments on commit 87575a2

Please sign in to comment.