daodou-command 1.2.3 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.daodourc.example +85 -0
- package/.idea/UniappTool.xml +10 -0
- package/.idea/copilot.data.migration.agent.xml +6 -0
- package/.idea/copilot.data.migration.ask.xml +6 -0
- package/.idea/copilot.data.migration.ask2agent.xml +6 -0
- package/.idea/copilot.data.migration.edit.xml +6 -0
- package/.idea/daodou-command.iml +12 -0
- package/.idea/editorJumperProjectSettings.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +85 -0
- package/CHANGELOG.md +42 -1
- package/README.md +75 -2
- package/bin/daodou.js +79 -0
- package/lib/commands/config.js +372 -0
- package/lib/commands/lang.js +2 -1
- package/lib/translation/TranslationService.js +214 -0
- package/lib/translation/engines/BaseTranslator.js +90 -0
- package/lib/translation/engines/ali/AliTranslator.js +316 -0
- package/lib/translation/engines/ali/index.js +8 -0
- package/lib/translation/engines/baidu/BaiduTranslator.js +209 -0
- package/lib/translation/engines/baidu/index.js +8 -0
- package/lib/translation/engines/deepl/DeeplTranslator.js +234 -0
- package/lib/translation/engines/deepl/index.js +8 -0
- package/lib/translation/engines/google/GoogleTranslator.js +251 -0
- package/lib/translation/engines/google/index.js +8 -0
- package/lib/translation/engines/index.js +69 -0
- package/lib/translation/engines/microsoft/MicrosoftTranslator.js +190 -0
- package/lib/translation/engines/microsoft/index.js +6 -0
- package/lib/translation/engines/microsoft/services/EdgeAuthService.js +166 -0
- package/lib/translation/engines/microsoft/services/HttpClient.js +93 -0
- package/lib/translation/engines/microsoft/services/TranslatorService.js +167 -0
- package/lib/translation/engines/microsoft/types/index.js +147 -0
- package/lib/translation/engines/openai/OpenaiTranslator.js +363 -0
- package/lib/translation/engines/openai/index.js +8 -0
- package/lib/translation/engines/youdao/YoudaoTranslator.js +361 -0
- package/lib/translation/engines/youdao/index.js +8 -0
- package/lib/translation/index.js +10 -0
- package/lib/utils/config.js +98 -4
- package/lib/utils/translation.js +58 -100
- package/package.json +1 -3
- package/.daodourc +0 -28
- package/lib/utils/proxy-manager.js +0 -364
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
// build 命令配置
|
|
3
|
+
build: {
|
|
4
|
+
// Jenkins 基础配置
|
|
5
|
+
// jenkinsUrl: "https://jenkins.example.com/",
|
|
6
|
+
// jenkinsBase: "https://jenkins.example.com/job",
|
|
7
|
+
// jenkinsToken: "your-jenkins-token",
|
|
8
|
+
// jenkinsUsername: "your-username",
|
|
9
|
+
// jenkinsPassword: "your-password",
|
|
10
|
+
|
|
11
|
+
// 构建任务配置(必须配置)
|
|
12
|
+
// jobName: "your-job-name", // 必须配置的任务名称
|
|
13
|
+
|
|
14
|
+
// 构建参数配置
|
|
15
|
+
// buildParams: {
|
|
16
|
+
// token: "your-jenkins-token",
|
|
17
|
+
// BUILD_ENV: "test",
|
|
18
|
+
// version: "0.0.1"
|
|
19
|
+
// }
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
// lang 命令配置
|
|
23
|
+
lang: {
|
|
24
|
+
defaultLang: "en",
|
|
25
|
+
defaultDir: "./public/locales",
|
|
26
|
+
fileName: "common.json",
|
|
27
|
+
|
|
28
|
+
// 翻译引擎配置
|
|
29
|
+
translation: {
|
|
30
|
+
// 默认翻译引擎 (microsoft, google, baidu, ali, youdao, deepl, openai)
|
|
31
|
+
defaultEngine: "microsoft",
|
|
32
|
+
|
|
33
|
+
// 引擎优先级列表(按顺序尝试)
|
|
34
|
+
enginePriority: ["microsoft", "google", "baidu", "ali", "youdao", "deepl", "openai"],
|
|
35
|
+
|
|
36
|
+
// 各引擎API配置
|
|
37
|
+
engines: {
|
|
38
|
+
// 微软翻译(免费,无需配置)
|
|
39
|
+
microsoft: {
|
|
40
|
+
enabled: true
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
// Google翻译(免费,无需配置)
|
|
44
|
+
google: {
|
|
45
|
+
enabled: true
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
// 百度翻译(需要API密钥)
|
|
49
|
+
baidu: {
|
|
50
|
+
enabled: false,
|
|
51
|
+
appId: "", // 百度翻译API App ID
|
|
52
|
+
appKey: "" // 百度翻译API App Key
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
// 阿里云翻译(需要API密钥)
|
|
56
|
+
ali: {
|
|
57
|
+
enabled: false,
|
|
58
|
+
accessKeyId: "", // 阿里云AccessKey ID
|
|
59
|
+
accessKeySecret: "" // 阿里云AccessKey Secret
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// 有道翻译(需要API密钥)
|
|
63
|
+
youdao: {
|
|
64
|
+
enabled: false,
|
|
65
|
+
appId: "", // 有道翻译API App ID
|
|
66
|
+
appKey: "" // 有道翻译API App Key
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
// DeepL翻译(需要API密钥)
|
|
70
|
+
deepl: {
|
|
71
|
+
enabled: false,
|
|
72
|
+
apiKey: "" // DeepL API Key
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
// OpenAI翻译(需要API密钥)
|
|
76
|
+
openai: {
|
|
77
|
+
enabled: false,
|
|
78
|
+
apiKey: "", // OpenAI API Key
|
|
79
|
+
model: "gpt-3.5-turbo", // 使用的模型
|
|
80
|
+
baseUrl: "https://api.openai.com/v1" // API基础URL
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="cn.fjdmy.uniapp.UniappProjectDataService">
|
|
4
|
+
<option name="generalBasePath" value="$PROJECT_DIR$" />
|
|
5
|
+
<option name="manifestPath" value="$PROJECT_DIR$/manifest.json" />
|
|
6
|
+
<option name="pagesPath" value="$PROJECT_DIR$/pages.json" />
|
|
7
|
+
<option name="scanNum" value="1" />
|
|
8
|
+
<option name="type" value="store" />
|
|
9
|
+
</component>
|
|
10
|
+
</project>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/daodou-command.iml" filepath="$PROJECT_DIR$/.idea/daodou-command.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ChangeListManager">
|
|
4
|
+
<list default="true" id="1537cb23-f918-4011-a0ed-24da46bf53bc" name="更改" comment="">
|
|
5
|
+
<change afterPath="$PROJECT_DIR$/lib/translation/TranslationService.js" afterDir="false" />
|
|
6
|
+
<change afterPath="$PROJECT_DIR$/lib/translation/engines/BaseTranslator.js" afterDir="false" />
|
|
7
|
+
<change afterPath="$PROJECT_DIR$/lib/translation/engines/index.js" afterDir="false" />
|
|
8
|
+
<change afterPath="$PROJECT_DIR$/lib/translation/engines/microsoft/MicrosoftTranslator.js" afterDir="false" />
|
|
9
|
+
<change afterPath="$PROJECT_DIR$/lib/translation/engines/microsoft/index.js" afterDir="false" />
|
|
10
|
+
<change afterPath="$PROJECT_DIR$/lib/translation/engines/microsoft/services/EdgeAuthService.js" afterDir="false" />
|
|
11
|
+
<change afterPath="$PROJECT_DIR$/lib/translation/engines/microsoft/services/HttpClient.js" afterDir="false" />
|
|
12
|
+
<change afterPath="$PROJECT_DIR$/lib/translation/engines/microsoft/services/TranslatorService.js" afterDir="false" />
|
|
13
|
+
<change afterPath="$PROJECT_DIR$/lib/translation/engines/microsoft/types/index.js" afterDir="false" />
|
|
14
|
+
<change afterPath="$PROJECT_DIR$/lib/translation/index.js" afterDir="false" />
|
|
15
|
+
<change beforePath="$PROJECT_DIR$/lib/commands/lang.js" beforeDir="false" afterPath="$PROJECT_DIR$/lib/commands/lang.js" afterDir="false" />
|
|
16
|
+
<change beforePath="$PROJECT_DIR$/lib/utils/proxy-manager.js" beforeDir="false" />
|
|
17
|
+
<change beforePath="$PROJECT_DIR$/lib/utils/translation.js" beforeDir="false" afterPath="$PROJECT_DIR$/lib/utils/translation.js" afterDir="false" />
|
|
18
|
+
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
|
|
19
|
+
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
|
|
20
|
+
</list>
|
|
21
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
22
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
23
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
24
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
25
|
+
</component>
|
|
26
|
+
<component name="Git.Settings">
|
|
27
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
28
|
+
</component>
|
|
29
|
+
<component name="GitHubPullRequestSearchHistory"><![CDATA[{
|
|
30
|
+
"lastFilter": {
|
|
31
|
+
"state": "OPEN",
|
|
32
|
+
"assignee": "h025"
|
|
33
|
+
}
|
|
34
|
+
}]]></component>
|
|
35
|
+
<component name="GithubPullRequestsUISettings"><![CDATA[{
|
|
36
|
+
"selectedUrlAndAccountId": {
|
|
37
|
+
"url": "https://github.com/h025/daodou-command.git",
|
|
38
|
+
"accountId": "c8b4f74c-2e36-4aad-b608-940f73fc88db"
|
|
39
|
+
}
|
|
40
|
+
}]]></component>
|
|
41
|
+
<component name="ProjectColorInfo"><![CDATA[{
|
|
42
|
+
"associatedIndex": 6
|
|
43
|
+
}]]></component>
|
|
44
|
+
<component name="ProjectId" id="33EP70DuHXVnueD9LcTKpn8t7Vr" />
|
|
45
|
+
<component name="ProjectViewState">
|
|
46
|
+
<option name="hideEmptyMiddlePackages" value="true" />
|
|
47
|
+
<option name="showLibraryContents" value="true" />
|
|
48
|
+
</component>
|
|
49
|
+
<component name="PropertiesComponent"><![CDATA[{
|
|
50
|
+
"keyToString": {
|
|
51
|
+
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
|
52
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
53
|
+
"RunOnceActivity.git.unshallow": "true",
|
|
54
|
+
"git-widget-placeholder": "main",
|
|
55
|
+
"last_opened_file_path": "/Users/summermr/daodou/daodou-command",
|
|
56
|
+
"node.js.detected.package.eslint": "true",
|
|
57
|
+
"node.js.detected.package.tslint": "true",
|
|
58
|
+
"node.js.selected.package.eslint": "(autodetect)",
|
|
59
|
+
"node.js.selected.package.tslint": "(autodetect)",
|
|
60
|
+
"nodejs_package_manager_path": "npm",
|
|
61
|
+
"vue.rearranger.settings.migration": "true"
|
|
62
|
+
}
|
|
63
|
+
}]]></component>
|
|
64
|
+
<component name="SharedIndexes">
|
|
65
|
+
<attachedChunks>
|
|
66
|
+
<set>
|
|
67
|
+
<option value="bundled-js-predefined-d6986cc7102b-9c94529fcfe0-JavaScript-WS-252.26199.162" />
|
|
68
|
+
</set>
|
|
69
|
+
</attachedChunks>
|
|
70
|
+
</component>
|
|
71
|
+
<component name="TaskManager">
|
|
72
|
+
<task active="true" id="Default" summary="默认任务">
|
|
73
|
+
<changelist id="1537cb23-f918-4011-a0ed-24da46bf53bc" name="更改" comment="" />
|
|
74
|
+
<created>1758879086844</created>
|
|
75
|
+
<option name="number" value="Default" />
|
|
76
|
+
<option name="presentableId" value="Default" />
|
|
77
|
+
<updated>1758879086844</updated>
|
|
78
|
+
<workItem from="1758879088110" duration="434000" />
|
|
79
|
+
</task>
|
|
80
|
+
<servers />
|
|
81
|
+
</component>
|
|
82
|
+
<component name="TypeScriptGeneratedFilesManager">
|
|
83
|
+
<option name="version" value="3" />
|
|
84
|
+
</component>
|
|
85
|
+
</project>
|
package/CHANGELOG.md
CHANGED
|
@@ -5,12 +5,53 @@
|
|
|
5
5
|
格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/),
|
|
6
6
|
并且此项目遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
|
|
7
7
|
|
|
8
|
+
## [1.4.0] - 2025-09-26
|
|
9
|
+
|
|
10
|
+
### 新增
|
|
11
|
+
- 实现7种翻译引擎:微软、Google、百度、阿里云、有道、DeepL、OpenAI
|
|
12
|
+
- 支持多引擎配置和优先级调度
|
|
13
|
+
- HTML文档翻译支持,保持标签结构完整
|
|
14
|
+
- 智能引擎故障转移和重试机制
|
|
15
|
+
- 灵活的API密钥配置管理
|
|
16
|
+
|
|
17
|
+
### 更改
|
|
18
|
+
- 重构翻译服务架构,支持多引擎调度
|
|
19
|
+
- 优化配置文件结构,翻译引擎配置移至lang命令下
|
|
20
|
+
- 简化配置结构,移除重复的priority字段,统一使用enginePriority
|
|
21
|
+
- 自动生成配置时包含完整的翻译引擎配置
|
|
22
|
+
- 提升翻译服务的稳定性和可靠性
|
|
23
|
+
|
|
8
24
|
## [未发布]
|
|
9
25
|
|
|
26
|
+
|
|
27
|
+
## [1.3.0] - 2025-09-16
|
|
28
|
+
|
|
10
29
|
### 新增
|
|
30
|
+
- 添加 `dao config` 全局配置管理命令
|
|
31
|
+
- `dao config init` - 初始化全局配置文件
|
|
32
|
+
- `dao config show` - 显示当前配置信息(全局+项目+合并后)
|
|
33
|
+
- `dao config edit` - 编辑配置文件(支持vim等编辑器)
|
|
34
|
+
- `dao config clear` - 清除配置文件
|
|
35
|
+
- `dao config` - 交互式配置向导
|
|
36
|
+
- 优化配置结构,代理配置提升到全局配置
|
|
37
|
+
- `proxyListUrl` 和 `proxyTestUrl` 移至全局配置
|
|
38
|
+
- 项目配置默认不再生成代理相关配置
|
|
39
|
+
- 简化项目配置,减少重复配置项
|
|
40
|
+
|
|
11
41
|
### 更改
|
|
42
|
+
- 默认编辑器从nano改为vim,提升编辑体验
|
|
43
|
+
- 配置管理更加智能和用户友好
|
|
44
|
+
- 全局配置和项目配置层级更清晰
|
|
45
|
+
|
|
46
|
+
### 技术改进
|
|
47
|
+
- 增强配置管理功能
|
|
48
|
+
- 改进用户交互体验
|
|
49
|
+
- 优化配置文件结构
|
|
50
|
+
|
|
51
|
+
## [1.2.3] - 2025-09-16
|
|
52
|
+
|
|
12
53
|
### 修复
|
|
13
|
-
|
|
54
|
+
- 更新CHANGELOG.md记录1.2.2版本的完整变更内容
|
|
14
55
|
|
|
15
56
|
## [1.2.2] - 2025-09-16
|
|
16
57
|
|
package/README.md
CHANGED
|
@@ -17,14 +17,21 @@ npm install -g daodou-command
|
|
|
17
17
|
|
|
18
18
|
### 🌐 多语言管理
|
|
19
19
|
- 支持多语言文件管理
|
|
20
|
-
-
|
|
21
|
-
-
|
|
20
|
+
- 多引擎翻译支持(微软、Google、百度、阿里云、有道、DeepL、OpenAI)
|
|
21
|
+
- HTML文档翻译支持,保持标签结构
|
|
22
|
+
- 智能引擎调度和故障转移
|
|
23
|
+
- 灵活的引擎配置和优先级设置
|
|
22
24
|
|
|
23
25
|
### 🔄 自动更新
|
|
24
26
|
- 智能版本检查和更新
|
|
25
27
|
- 一键升级到最新版本
|
|
26
28
|
- 支持强制更新和仅检查模式
|
|
27
29
|
|
|
30
|
+
### ⚙️ 配置管理
|
|
31
|
+
- 全局配置和项目配置支持
|
|
32
|
+
- 交互式配置向导
|
|
33
|
+
- 配置文件编辑和管理
|
|
34
|
+
|
|
28
35
|
## 快速开始
|
|
29
36
|
|
|
30
37
|
### 构建项目
|
|
@@ -46,6 +53,62 @@ dao upgrade
|
|
|
46
53
|
dao upgrade --force
|
|
47
54
|
```
|
|
48
55
|
|
|
56
|
+
### 配置管理
|
|
57
|
+
```bash
|
|
58
|
+
# 初始化全局配置
|
|
59
|
+
dao config init
|
|
60
|
+
|
|
61
|
+
# 查看当前配置
|
|
62
|
+
dao config show
|
|
63
|
+
|
|
64
|
+
# 编辑配置文件
|
|
65
|
+
dao config edit
|
|
66
|
+
|
|
67
|
+
# 清除配置文件
|
|
68
|
+
dao config clear
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### 翻译引擎配置
|
|
72
|
+
支持7种翻译引擎,可在lang命令配置中灵活配置:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"lang": {
|
|
77
|
+
"defaultLang": "en",
|
|
78
|
+
"defaultDir": "./public/locales",
|
|
79
|
+
"fileName": "common.json",
|
|
80
|
+
"translation": {
|
|
81
|
+
"defaultEngine": "microsoft",
|
|
82
|
+
"enginePriority": ["microsoft", "google", "baidu", "ali", "youdao", "deepl", "openai"],
|
|
83
|
+
"engines": {
|
|
84
|
+
"microsoft": { "enabled": true },
|
|
85
|
+
"google": { "enabled": true },
|
|
86
|
+
"baidu": { "enabled": false, "appId": "", "appKey": "" },
|
|
87
|
+
"ali": { "enabled": false, "accessKeyId": "", "accessKeySecret": "" },
|
|
88
|
+
"youdao": { "enabled": false, "appId": "", "appKey": "" },
|
|
89
|
+
"deepl": { "enabled": false, "apiKey": "" },
|
|
90
|
+
"openai": { "enabled": false, "apiKey": "", "model": "gpt-3.5-turbo" }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**支持的翻译引擎:**
|
|
98
|
+
- **微软翻译**: 免费,无需配置,支持HTML翻译
|
|
99
|
+
- **Google翻译**: 免费,无需配置,支持HTML翻译
|
|
100
|
+
- **百度翻译**: 需要App ID和App Key
|
|
101
|
+
- **阿里云翻译**: 需要AccessKey ID和AccessKey Secret,支持HTML翻译
|
|
102
|
+
- **有道翻译**: 需要App ID和App Key
|
|
103
|
+
- **DeepL翻译**: 需要API Key
|
|
104
|
+
- **OpenAI翻译**: 需要API Key和模型配置,支持HTML翻译
|
|
105
|
+
|
|
106
|
+
**HTML翻译支持:**
|
|
107
|
+
- 微软翻译:原生支持HTML格式,保持标签结构
|
|
108
|
+
- Google翻译:支持HTML格式翻译
|
|
109
|
+
- 阿里云翻译:支持HTML格式翻译
|
|
110
|
+
- OpenAI翻译:智能识别HTML标签,保持结构完整
|
|
111
|
+
|
|
49
112
|
### 多语言管理
|
|
50
113
|
```bash
|
|
51
114
|
# 添加多语言项(自动翻译)
|
|
@@ -104,6 +167,16 @@ dao upgrade --force # 强制更新到最新版本
|
|
|
104
167
|
dao upgrade --help # 查看帮助
|
|
105
168
|
```
|
|
106
169
|
|
|
170
|
+
### 配置命令
|
|
171
|
+
```bash
|
|
172
|
+
dao config # 配置管理向导
|
|
173
|
+
dao config init # 初始化全局配置
|
|
174
|
+
dao config show # 显示当前配置
|
|
175
|
+
dao config edit # 编辑配置文件
|
|
176
|
+
dao config clear # 清除配置文件
|
|
177
|
+
dao config --help # 查看帮助
|
|
178
|
+
```
|
|
179
|
+
|
|
107
180
|
### 多语言命令
|
|
108
181
|
```bash
|
|
109
182
|
dao lang add "key" "value" # 添加多语言项
|
package/bin/daodou.js
CHANGED
|
@@ -69,6 +69,79 @@ program
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
+
// 添加 config 命令
|
|
73
|
+
const configCmd = program
|
|
74
|
+
.command('config')
|
|
75
|
+
.description('全局配置管理工具');
|
|
76
|
+
|
|
77
|
+
configCmd
|
|
78
|
+
.command('init')
|
|
79
|
+
.description('初始化全局配置文件')
|
|
80
|
+
.action(async () => {
|
|
81
|
+
try {
|
|
82
|
+
const { ConfigCommand } = require('../lib/commands/config');
|
|
83
|
+
const configCommand = new ConfigCommand();
|
|
84
|
+
await configCommand.execute('init');
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.error(chalk.red('初始化失败:'), error.message);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
configCmd
|
|
92
|
+
.command('show')
|
|
93
|
+
.description('显示当前配置信息')
|
|
94
|
+
.action(async () => {
|
|
95
|
+
try {
|
|
96
|
+
const { ConfigCommand } = require('../lib/commands/config');
|
|
97
|
+
const configCommand = new ConfigCommand();
|
|
98
|
+
await configCommand.execute('show');
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.error(chalk.red('显示配置失败:'), error.message);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
configCmd
|
|
106
|
+
.command('edit')
|
|
107
|
+
.description('编辑配置文件')
|
|
108
|
+
.action(async () => {
|
|
109
|
+
try {
|
|
110
|
+
const { ConfigCommand } = require('../lib/commands/config');
|
|
111
|
+
const configCommand = new ConfigCommand();
|
|
112
|
+
await configCommand.execute('edit');
|
|
113
|
+
} catch (error) {
|
|
114
|
+
console.error(chalk.red('编辑失败:'), error.message);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
configCmd
|
|
120
|
+
.command('clear')
|
|
121
|
+
.description('清除配置文件')
|
|
122
|
+
.action(async () => {
|
|
123
|
+
try {
|
|
124
|
+
const { ConfigCommand } = require('../lib/commands/config');
|
|
125
|
+
const configCommand = new ConfigCommand();
|
|
126
|
+
await configCommand.execute('clear');
|
|
127
|
+
} catch (error) {
|
|
128
|
+
console.error(chalk.red('清除失败:'), error.message);
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
configCmd
|
|
134
|
+
.action(async () => {
|
|
135
|
+
try {
|
|
136
|
+
const { ConfigCommand } = require('../lib/commands/config');
|
|
137
|
+
const configCommand = new ConfigCommand();
|
|
138
|
+
await configCommand.execute();
|
|
139
|
+
} catch (error) {
|
|
140
|
+
console.error(chalk.red('配置操作失败:'), error.message);
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
72
145
|
// 添加 lang 命令
|
|
73
146
|
const langCmd = program
|
|
74
147
|
.command('lang')
|
|
@@ -114,6 +187,12 @@ program.addHelpText('after', `
|
|
|
114
187
|
$ dao upgrade --check # 仅检查是否有新版本
|
|
115
188
|
$ dao upgrade --force # 强制更新到最新版本
|
|
116
189
|
|
|
190
|
+
$ dao config # 配置管理向导
|
|
191
|
+
$ dao config init # 初始化全局配置
|
|
192
|
+
$ dao config show # 显示当前配置
|
|
193
|
+
$ dao config edit # 编辑配置文件
|
|
194
|
+
$ dao config clear # 清除配置文件
|
|
195
|
+
|
|
117
196
|
$ dao lang add "hello"
|
|
118
197
|
$ dao lang add "hello" "Hello World"
|
|
119
198
|
$ dao lang add "world" --lang en
|