Skip to content

Commit f9bd1e2

Browse files
🔧 chore(config): 完善项目配置文件
- 添加 .versionrc 配置自定义更新记录格式 - 添加 commitlint.config.mjs 规范提交信息格式 - 调整 package.json 版本号,移动到0.0.8分支 - 增加 pnpm-lock.yaml 依赖锁定文件 - 新增 README 配置文档表格说明 - 添加 .husky 目录配置Git钩子进行提交信息和代码规范校验
1 parent f728680 commit f9bd1e2

9 files changed

+6035
-20
lines changed

.cz-config.js

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
module.exports = {
2+
types: [
3+
{
4+
value: ":zap: feat",
5+
name: "feat: 新功能",
6+
},
7+
{
8+
value: ":zap: fix",
9+
name: "fix: 修复bug",
10+
},
11+
{
12+
value: ":zap: init",
13+
name: "init: 初始化",
14+
},
15+
{
16+
value: ":zap: :pencil2: docs",
17+
name: "docs: 文档变更",
18+
},
19+
{
20+
value: ":zap: style",
21+
name: "style: 代码的样式美化",
22+
},
23+
{
24+
value: ":zap: refactor",
25+
name: "refactor: 重构",
26+
},
27+
{
28+
value: ":zap: perf",
29+
name: "perf: 性能优化",
30+
},
31+
{
32+
value: ":zap: test",
33+
name: "test: 测试",
34+
},
35+
{
36+
value: ":zap: revert",
37+
name: "revert: 回退",
38+
},
39+
{
40+
value: ":zap: build",
41+
name: "build: 打包",
42+
},
43+
{
44+
value: ":zap: chore",
45+
name: "chore: 构建/工程依赖/工具",
46+
},
47+
{
48+
value: ":zap: ci",
49+
name: "ci: CI related changes",
50+
},
51+
],
52+
messages: {
53+
type: "请选择提交类型(必填)",
54+
customScope: "请输入文件修改范围(可选)",
55+
subject: "请简要描述提交(必填)",
56+
body: "请输入详细描述(可选)",
57+
breaking: "列出任何BREAKING CHANGES(可选)",
58+
footer: "请输入要关闭的issue(可选)",
59+
confirmCommit: "确定提交此说明吗?",
60+
},
61+
allowCustomScopes: true,
62+
allowBreakingChanges: ["feat", "fix"], // 当提交类型为feat、fix时才有破坏性修改选项
63+
subjectLimit: 72,
64+
};

.husky/commit-msg

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
echo "\033[33m ------------------- 正在校验提交信息格式 -------------------- \033[0m"
5+
npx --no-install commitlint --edit ${1}

.husky/pre-commit

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
echo "\033[33m ------------------- 正在执行eslint校验 -------------------- \033[0m"
5+
npx --no-install lint-staged
6+
7+
pnpm run lint

.versionrc

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"header": "# 更新记录 \n\n",
3+
"types": [
4+
{
5+
"type": "feat",
6+
"section": "✨ Features | 新功能"
7+
},
8+
{
9+
"type": "fix",
10+
"section": "🐛 Bug Fixes | Bug 修复"
11+
},
12+
{
13+
"type": "init",
14+
"section": "🎉 Init | 初始化"
15+
},
16+
{
17+
"type": "docs",
18+
"section": "📝 Documentation | 文档"
19+
},
20+
{
21+
"type": "style",
22+
"section": "💄 Styles | 风格",
23+
"hidden": true
24+
},
25+
{
26+
"type": "refactor",
27+
"section": "♻️ Code Refactoring | 代码重构"
28+
},
29+
{
30+
"type": "perf",
31+
"section": "⚡ Performance Improvements | 性能优化"
32+
},
33+
{
34+
"type": "test",
35+
"section": "✅ Tests | 测试"
36+
},
37+
{
38+
"type": "revert",
39+
"section": "⏪ Revert | 回退",
40+
"hidden": true
41+
},
42+
{
43+
"type": "build",
44+
"section": "📦‍ Build System | 打包构建"
45+
},
46+
{
47+
"type": "chore",
48+
"section": "🚀 Chore | 部署相关"
49+
},
50+
{
51+
"type": "ci",
52+
"section": "👷 Continuous Integration | CI/CD 配置"
53+
}
54+
],
55+
"skip": {
56+
"bump": false,
57+
"changelog": false,
58+
"commit": false,
59+
"tag": false
60+
}
61+
}

README.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,19 @@ Supports 19 languages including:
6161

6262
### Configuration
6363

64-
| Configuration | Type | Default | Required |
65-
| ----------------------------- | ------ | ------------------------- | -------- |
66-
| dish-ai-commit.commitLanguage | string | Simplified Chinese | Yes |
67-
| dish-ai-commit.systemPrompt | string | "" | No |
68-
| dish-ai-commit.provider | string | OpenAI | Yes |
69-
| dish-ai-commit.model | string | gpt-3.5-turbo | Yes |
70-
| dish-ai-commit.openai.apiKey | string | - | Yes |
71-
| dish-ai-commit.openai.baseUrl | string | https://api.openai.com/v1 | No |
72-
| dish-ai-commit.ollama.baseUrl | string | http://localhost:11434 | No |
64+
| Configuration | Type | Default | Description |
65+
| ----------------------------------------------- | ------- | ------------------------- | --------------------------------------------------- |
66+
| dish-ai-commit.commitLanguage | string | Simplified Chinese | Commit message language |
67+
| dish-ai-commit.systemPrompt | string | "" | Custom system prompt for generating commit messages |
68+
| dish-ai-commit.provider | string | OpenAI | Default AI provider |
69+
| dish-ai-commit.model | string | gpt-3.5-turbo | AI model selection |
70+
| dish-ai-commit.openai.apiKey | string | - | OpenAI API key |
71+
| dish-ai-commit.openai.baseUrl | string | https://api.openai.com/v1 | OpenAI API base URL |
72+
| dish-ai-commit.ollama.baseUrl | string | http://localhost:11434 | Ollama API base URL |
73+
| dish-ai-commit.enableDiffSimplification | boolean | false | Enable diff content simplification |
74+
| dish-ai-commit.diffSimplification.maxLineLength | number | 120 | Maximum line length after simplification |
75+
| dish-ai-commit.diffSimplification.contextLines | number | 3 | Number of context lines to preserve |
76+
| dish-ai-commit.allowMergeCommits | boolean | false | Allow merging multiple file changes into one commit |
7377

7478
### Commands
7579

README.zh-CN.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,19 @@
5353

5454
### 配置项
5555

56-
| 配置项 | 类型 | 默认值 | 必填 |
57-
| ----------------------------- | ------ | ------------------------- | ---- |
58-
| dish-ai-commit.commitLanguage | string | Simplified Chinese ||
59-
| dish-ai-commit.systemPrompt | string | "" ||
60-
| dish-ai-commit.provider | string | OpenAI ||
61-
| dish-ai-commit.model | string | gpt-3.5-turbo ||
62-
| dish-ai-commit.openai.apiKey | string | - ||
63-
| dish-ai-commit.openai.baseUrl | string | https://api.openai.com/v1 ||
64-
| dish-ai-commit.ollama.baseUrl | string | http://localhost:11434 ||
56+
| 配置项 | 类型 | 默认值 | 说明 |
57+
| ----------------------------------------------- | ------- | ------------------------- | ------------------------------------------ |
58+
| dish-ai-commit.commitLanguage | string | Simplified Chinese | 提交信息语言 |
59+
| dish-ai-commit.systemPrompt | string | "" | 自定义生成提交信息的系统提示 |
60+
| dish-ai-commit.provider | string | OpenAI | 默认的 AI 提供商 |
61+
| dish-ai-commit.model | string | gpt-3.5-turbo | AI 模型选择 |
62+
| dish-ai-commit.openai.apiKey | string | - | OpenAI API 密钥 |
63+
| dish-ai-commit.openai.baseUrl | string | https://api.openai.com/v1 | OpenAI API 基础 URL |
64+
| dish-ai-commit.ollama.baseUrl | string | http://localhost:11434 | Ollama API 基础 URL |
65+
| dish-ai-commit.enableDiffSimplification | boolean | false | 启用 diff 内容简化功能 |
66+
| dish-ai-commit.diffSimplification.maxLineLength | number | 120 | 简化后每行的最大长度 |
67+
| dish-ai-commit.diffSimplification.contextLines | number | 3 | 保留上下文行数 |
68+
| dish-ai-commit.allowMergeCommits | boolean | false | 是否允许将多个文件的变更合并为一条提交信息 |
6569

6670
### 命令
6771

commitlint.config.mjs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export default {
2+
extends: ["gitmoji"],
3+
rules: {
4+
"header-max-length": [2, "always", 108],
5+
"type-empty": [2, "never"],
6+
"type-enum": [
7+
2,
8+
"always",
9+
[
10+
"✨ feat",
11+
"🐛 fix",
12+
"🎉 init",
13+
"📚 docs",
14+
"🎨 style",
15+
"♻️ refactor",
16+
"⚡ perf",
17+
"✅ test",
18+
"⏪ revert",
19+
"🔧 chore",
20+
"🔨 build",
21+
"⚙️ ci",
22+
],
23+
],
24+
},
25+
};

package.json

+42-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "dish-ai-commit",
33
"displayName": "Dish AI Commit Gen",
44
"description": "",
5-
"version": "0.0.10",
5+
"version": "0.0.8",
66
"engines": {
77
"vscode": "^1.95.0"
88
},
@@ -220,9 +220,12 @@
220220
"@vscode/test-cli": "^0.0.9",
221221
"@vscode/test-electron": "^2.4.0",
222222
"commitizen": "^4.3.1",
223+
"commitlint-config-gitmoji": "^2.3.1",
223224
"cz-conventional-changelog": "^3.3.0",
225+
"cz-customizable": "^7.3.0",
224226
"eslint": "^8.57.0",
225227
"husky": "^8.0.0",
228+
"lint-staged": "^15.2.10",
226229
"standard-version": "^9.5.0",
227230
"typescript": "^5.4.5"
228231
},
@@ -237,7 +240,44 @@
237240
"license": "MIT",
238241
"config": {
239242
"commitizen": {
240-
"path": "./node_modules/cz-conventional-changelog"
243+
"path": "node_modules/cz-customizable"
244+
}
245+
},
246+
"lint-staged": {
247+
"src/**/*.{ts}": "npm run lint"
248+
},
249+
"commitlint": {
250+
"extends": [
251+
"gitmoji"
252+
],
253+
"rules": {
254+
"header-max-length": [
255+
2,
256+
"always",
257+
108
258+
],
259+
"type-empty": [
260+
2,
261+
"never"
262+
],
263+
"type-enum": [
264+
2,
265+
"always",
266+
[
267+
"✨ feat",
268+
"🐛 fix",
269+
"🎉 init",
270+
"📚 docs",
271+
"🎨 style",
272+
"♻️ refactor",
273+
"⚡ perf",
274+
"✅ test",
275+
"⏪ revert",
276+
"🔧 chore",
277+
"🔨 build",
278+
"⚙️ ci"
279+
]
280+
]
241281
}
242282
}
243283
}

0 commit comments

Comments
 (0)