Skip to content

Commit

Permalink
🔧 chore(config): 完善项目配置文件
Browse files Browse the repository at this point in the history
- 添加 .versionrc 配置自定义更新记录格式
- 添加 commitlint.config.mjs 规范提交信息格式
- 调整 package.json 版本号,移动到0.0.8分支
- 增加 pnpm-lock.yaml 依赖锁定文件
- 新增 README 配置文档表格说明
- 添加 .husky 目录配置Git钩子进行提交信息和代码规范校验
  • Loading branch information
littleCareless committed Dec 9, 2024
1 parent f728680 commit f9bd1e2
Show file tree
Hide file tree
Showing 9 changed files with 6,035 additions and 20 deletions.
64 changes: 64 additions & 0 deletions .cz-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module.exports = {
types: [
{
value: ":zap: feat",
name: "feat: 新功能",
},
{
value: ":zap: fix",
name: "fix: 修复bug",
},
{
value: ":zap: init",
name: "init: 初始化",
},
{
value: ":zap: :pencil2: docs",
name: "docs: 文档变更",
},
{
value: ":zap: style",
name: "style: 代码的样式美化",
},
{
value: ":zap: refactor",
name: "refactor: 重构",
},
{
value: ":zap: perf",
name: "perf: 性能优化",
},
{
value: ":zap: test",
name: "test: 测试",
},
{
value: ":zap: revert",
name: "revert: 回退",
},
{
value: ":zap: build",
name: "build: 打包",
},
{
value: ":zap: chore",
name: "chore: 构建/工程依赖/工具",
},
{
value: ":zap: ci",
name: "ci: CI related changes",
},
],
messages: {
type: "请选择提交类型(必填)",
customScope: "请输入文件修改范围(可选)",
subject: "请简要描述提交(必填)",
body: "请输入详细描述(可选)",
breaking: "列出任何BREAKING CHANGES(可选)",
footer: "请输入要关闭的issue(可选)",
confirmCommit: "确定提交此说明吗?",
},
allowCustomScopes: true,
allowBreakingChanges: ["feat", "fix"], // 当提交类型为feat、fix时才有破坏性修改选项
subjectLimit: 72,
};
5 changes: 5 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo "\033[33m ------------------- 正在校验提交信息格式 -------------------- \033[0m"
npx --no-install commitlint --edit ${1}
7 changes: 7 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo "\033[33m ------------------- 正在执行eslint校验 -------------------- \033[0m"
npx --no-install lint-staged

pnpm run lint
61 changes: 61 additions & 0 deletions .versionrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"header": "# 更新记录 \n\n",
"types": [
{
"type": "feat",
"section": "✨ Features | 新功能"
},
{
"type": "fix",
"section": "🐛 Bug Fixes | Bug 修复"
},
{
"type": "init",
"section": "🎉 Init | 初始化"
},
{
"type": "docs",
"section": "📝 Documentation | 文档"
},
{
"type": "style",
"section": "💄 Styles | 风格",
"hidden": true
},
{
"type": "refactor",
"section": "♻️ Code Refactoring | 代码重构"
},
{
"type": "perf",
"section": "⚡ Performance Improvements | 性能优化"
},
{
"type": "test",
"section": "✅ Tests | 测试"
},
{
"type": "revert",
"section": "⏪ Revert | 回退",
"hidden": true
},
{
"type": "build",
"section": "📦‍ Build System | 打包构建"
},
{
"type": "chore",
"section": "🚀 Chore | 部署相关"
},
{
"type": "ci",
"section": "👷 Continuous Integration | CI/CD 配置"
}
],
"skip": {
"bump": false,
"changelog": false,
"commit": false,
"tag": false
}
}
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,19 @@ Supports 19 languages including:

### Configuration

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

### Commands

Expand Down
22 changes: 13 additions & 9 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,19 @@

### 配置项

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

### 命令

Expand Down
25 changes: 25 additions & 0 deletions commitlint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export default {
extends: ["gitmoji"],
rules: {
"header-max-length": [2, "always", 108],
"type-empty": [2, "never"],
"type-enum": [
2,
"always",
[
"✨ feat",
"🐛 fix",
"🎉 init",
"📚 docs",
"🎨 style",
"♻️ refactor",
"⚡ perf",
"✅ test",
"⏪ revert",
"🔧 chore",
"🔨 build",
"⚙️ ci",
],
],
},
};
44 changes: 42 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dish-ai-commit",
"displayName": "Dish AI Commit Gen",
"description": "",
"version": "0.0.10",
"version": "0.0.8",
"engines": {
"vscode": "^1.95.0"
},
Expand Down Expand Up @@ -220,9 +220,12 @@
"@vscode/test-cli": "^0.0.9",
"@vscode/test-electron": "^2.4.0",
"commitizen": "^4.3.1",
"commitlint-config-gitmoji": "^2.3.1",
"cz-conventional-changelog": "^3.3.0",
"cz-customizable": "^7.3.0",
"eslint": "^8.57.0",
"husky": "^8.0.0",
"lint-staged": "^15.2.10",
"standard-version": "^9.5.0",
"typescript": "^5.4.5"
},
Expand All @@ -237,7 +240,44 @@
"license": "MIT",
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
"path": "node_modules/cz-customizable"
}
},
"lint-staged": {
"src/**/*.{ts}": "npm run lint"
},
"commitlint": {
"extends": [
"gitmoji"
],
"rules": {
"header-max-length": [
2,
"always",
108
],
"type-empty": [
2,
"never"
],
"type-enum": [
2,
"always",
[
"✨ feat",
"🐛 fix",
"🎉 init",
"📚 docs",
"🎨 style",
"♻️ refactor",
"⚡ perf",
"✅ test",
"⏪ revert",
"🔧 chore",
"🔨 build",
"⚙️ ci"
]
]
}
}
}
Loading

0 comments on commit f9bd1e2

Please sign in to comment.