Skip to content

Commit e410465

Browse files
authoredMar 3, 2024··
fix(loader): support commitlint v19 esm plugin extends config (#161)
* fix(plugin-loader): to support commitlint v19 `esm` plugin extends config commitlint update to pure ESM. Include common plugin like `@commitlint/config-conventional` It cause cz-git loader config error link #160
1 parent b091c64 commit e410465

File tree

8 files changed

+253
-382
lines changed

8 files changed

+253
-382
lines changed
 

‎.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"unocss.root": "docs",
2828
"prettier.enable": false,
2929
"editor.codeActionsOnSave": {
30-
"source.fixAll.eslint": true
30+
"source.fixAll.eslint": "explicit"
3131
},
3232
"picgo.picBed.github.path": "cz/",
3333
"editor.formatOnSave": false,

‎README.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,21 @@ Support OpenAI, and more engineered, lightweight, customizable, standard output
6666
- 🔨 [Better for monorepo engineering](https://cz-git.qbb.sh/recipes/#scopes) and **commitlint** project to give relevant verification information to the command line.
6767
- ✅ Support commit with **emoji** | Better linking with [issuePrefix](https://cz-git.qbb.sh/recipes/default-issues.html) **for issue**
6868

69-
[⇒ Why cz-git](https://cz-git.qbb.sh/guide/why.html)
69+
[⇒ Why cz-git](https://cz-git.qbb.sh/cli/why.html)
7070

7171
```bash
7272
$ npm i -D cz-git
7373
+ cz-git (1.9 MB)
7474
added 1 package in 0.582s
7575
```
7676

77+
[⇒ Why czg](https://cz-git.qbb.sh/guide/why.html)
78+
```bash
79+
$ npm i -g czg
80+
+ czg (1.5 MB)
81+
added 1 package in 0.531s
82+
```
83+
7784
## Projects using cz-git
7885

7986
<table>

‎docs/faq/index.md

+19-14
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,18 @@ sitemap:
88

99
# FAQ
1010

11-
## Windows users use
11+
## Error: require() of ES Module ... not supported
1212

13-
- Windows users are advised not to use powershell, cmd for command line use
14-
- because they are not based on the POSIX SHELL specification, i.e. not a standard terminal environment
15-
- It is recommended not to use git-bash, because the terminal is not an interactive terminal, and the selection up and down will be effected
16-
- **It is recommended to use Windows Terminal combined with WSL, you should also do the same in daily development and use**
13+
1. If you are an ESM project (i.e., `"type": "module"` in package.json),
14+
- You can try changing the [configuration name](/config/) from `.js` to `.cjs`.
15+
2. If you are using commitlint version (> 18),
16+
- For example, configuring `extends: ['@commitlint/config-conventional']`,
17+
- Please upgrade cz-git or czg to the latest version.
1718

18-
## Cannot find command after global install
19+
## Can I customize the message format ?
1920

20-
- Enter the command `npm prefix -g` to check whether the path of npm global download is in the root directory
21-
- The high probability is because the global download path prefix of npm has been changed with nvm
22-
- You can open .zshrc or .bashrc to comment out the loading nvm, and then reopen the terminal to check
23-
24-
## Terminal cannot display Emoji symbols
25-
26-
- The terminal cannot Emoji symbols, the high probability is because your terminal has poor support for emoji/unicode characters, but it does not affect the submission
27-
Because the final output is submitted by Emoji Code, you can consider changing the terminal and [font](https://github.com/ryanoasis/nerd-fonts)
21+
1. The configuration contains most of the message format fine-tuning requirements, such as changing the emoji position with [emojiAlign](/config/show#emojialign).
22+
2. [formatMessageCB](/config/engineer#formatmessagecb): It is the final format callback function. You can configure it to achieve the message format you need.
2823

2924
## Configure load not as expected
3025

@@ -37,6 +32,16 @@ CZ_DEBUG=1 cz
3732
CZ_DEBUG=1 czg
3833
```
3934

35+
## Cannot find the command after global install
36+
37+
- Enter the command `npm prefix -g` to check whether the bin folder path of npm's global download is added to the system environment variable `$PATH`.
38+
- Most likely because using nvm changed the npm global download path prefix, but the system environment variable was not recorded.
39+
40+
## Terminal cannot display Emoji symbols
41+
42+
- The terminal cannot Emoji symbols, the high probability is because your terminal has poor support for emoji/unicode characters, but it does not affect the submission
43+
Because the final output is submitted by Emoji Code, you can consider changing the terminal and [font](https://github.com/ryanoasis/nerd-fonts)
44+
4045
## What is different between `cz-git` and `czg`
4146

4247
> See more [Why czg](/cli/why.html)

‎docs/zh/faq/index.md

+19-14
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,21 @@ sitemap:
77
---
88
# 常见问题
99

10-
## Windows 用户使用
10+
## Error: require() of ES Module ... not supported
1111

12-
- Windows用户建议不要使用 powershell, cmd 进行命令行的使用
13-
- 因为他们不是基于 POSIX SHELL 规范,即不是标准终端环境
14-
- 建议也不要使用 git-bash,因为该终端并不是交互型终端,上下选择以及交互体验上会受到很大的使用体验
15-
- **建议使用 Windows Terminal 结合 WSL ,你在日常的开发和使用中也应该如此**
12+
1. 如果你是 ESM 项目 (即 package.json 中有 `"type": "module"`)
13+
- 可以尝试更改 [配置名](/zh/config/) `.js` => `.cjs`
14+
2. 如果你使用了 commitlint 版本(> 18)
15+
- 例如配置 `extends: ['@commitlint/config-conventional']`
16+
- 请升级 cz-git 或 czg 到最新版本
1617

17-
## 全局安装后无法找到命令
18-
19-
- 输入命令 `npm prefix -g` 查看当中npm全局下载的路径是否为根目录下
20-
- 大概率是因为使用 nvm 更改了 npm 的全局下载路径前缀
21-
- 可以打开.zshrc 或者 .bashrc 将加载 nvm 部分先注释掉,重新开启终端检查
22-
23-
## 终端无法显示Emoji符号
18+
## 可以自定义消息格式吗
2419

25-
- 终端无法Emoji符号,大概率是因为你的终端对于 emoji/unicode 字符支持较差,但是不影响提交
26-
因为最终输出提交的是 Emoji Code,可以考虑更换终端与[字体](https://github.com/ryanoasis/nerd-fonts)
20+
1. 配置总含有大部分消息格式的微调需求,例如 [emojiAlign](/zh/config/show#emojialign) 更换 emoji 位置
21+
2. [formatMessageCB](/zh/config/engineer#formatmessagecb): 是最终格式回调函数,你可以配置它来达到你需求的消息格式
2722

2823
## 配置加载不符合预期
24+
2925
可以运行命令查看配置加载的路径
3026

3127
```sh
@@ -35,6 +31,15 @@ CZ_DEBUG=1 cz
3531
CZ_DEBUG=1 czg
3632
```
3733

34+
## 全局安装后无法找到命令
35+
36+
- 输入命令 `npm prefix -g` 查看当中 npm 全局下载的 bin 文件夹路径是否添加到系统环境变量 `$PATH`
37+
- 大概率是因为使用 nvm 更改了 npm 的全局下载路径前缀,但系统环境变量没有记录
38+
39+
## 终端无法显示 Emoji 符号
40+
41+
- 终端无法显示 Emoji 符号,大概率是因为你的终端对于 emoji/unicode 字符支持较差,但是不影响提交,因为最终输出提交的是 Emoji Code,可以考虑更换终端以及终端设置使用的[字体](https://github.com/ryanoasis/nerd-fonts)
42+
3843
## `cz-git``czg` 有什么不同
3944

4045
> 可以查看更多信息 [czg 的动机](/zh/cli/why.html)

‎package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
},
4848
"devDependencies": {
4949
"@antfu/eslint-config": "0.38.6",
50-
"@commitlint/cli": "^17.4.4",
51-
"@commitlint/config-conventional": "^17.4.4",
50+
"@commitlint/cli": "^19.0.3",
51+
"@commitlint/config-conventional": "^19.0.3",
5252
"@cz-git/inquirer": "workspace:*",
5353
"@types/fs-extra": "^11.0.2",
5454
"@types/inquirer": "8.2.3",
@@ -80,7 +80,8 @@
8080
"chalk": "4.1.2",
8181
"color-convert": "2.0.1",
8282
"resolve-from": "5.0.0",
83-
"supports-color": "8.1.1"
83+
"supports-color": "8.1.1",
84+
"@commitlint/config-validator": "npm:@qbbsh/config-validator@19.0.3"
8485
},
8586
"peerDependencyRules": {
8687
"ignoreMissing": [

‎packages/@cz-git/plugin-loader/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"clean": "rimraf lib"
4242
},
4343
"devDependencies": {
44-
"@commitlint/resolve-extends": "^17.4.4",
45-
"@commitlint/types": "^17.4.4",
44+
"@commitlint/resolve-extends": "^19.0.3",
45+
"@commitlint/types": "^19.0.3",
4646
"@types/tmp": "^0.2.3",
4747
"cosmiconfig": "8.2.0",
4848
"pkg-dir": "5.0.0",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export async function clLoader(cwd?: string): Promise<CommitlintOptions> {
8989

9090
// resolve extends
9191
const base = (data && data.filepath) ? path.dirname(data.filepath) : process.cwd()
92-
const extended = resolveExtends(data.config, {
92+
const extended = await resolveExtends(data.config, {
9393
prefix: 'commitlint-config',
9494
cwd: base,
9595
})

‎pnpm-lock.yaml

+199-346
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.