@zrhsh/wukong-cli 0.4.19 → 0.4.20
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/README.md +234 -234
- package/dist/cli.js +15 -7
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/scripts/install.js +83 -83
- package/wukong-cli.json.template +25 -25
package/README.md
CHANGED
|
@@ -1,234 +1,234 @@
|
|
|
1
|
-
# Wukong CLI
|
|
2
|
-
|
|
3
|
-
用于 Oceanet/NRP 系统的 TypeScript CLI 工具,支持 OAuth Device PKCE Flow 认证和自动 token 刷新。
|
|
4
|
-
|
|
5
|
-
## 功能特性
|
|
6
|
-
|
|
7
|
-
- 🔐 **安全认证** - OAuth Device PKCE Flow,无需输入密码
|
|
8
|
-
- 🔄 **自动刷新** - Token 过期前自动刷新
|
|
9
|
-
- 🌍 **多环境支持** - 支持 dev、beta、uat 和 prod 环境
|
|
10
|
-
- 🐛 **调试模式** - 使用 `--debug` 标志显示 HTTP 请求和响应
|
|
11
|
-
- 💾 **安全存储** - 使用平台原生凭据管理器,支持文件回退
|
|
12
|
-
- 🛠️ **HTTP 客户端** - 内置 HTTP 客户端,自动处理认证
|
|
13
|
-
- ⚙️ **智能配置** - 内置默认配置,支持用户自定义
|
|
14
|
-
- 🔍 **结构化错误** - 清晰的错误消息和可操作的修复建议
|
|
15
|
-
|
|
16
|
-
## 快速开始
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
# 安装
|
|
20
|
-
npm install -g @zrhsh/wukong-cli
|
|
21
|
-
|
|
22
|
-
# 初始化配置
|
|
23
|
-
wukong-cli init
|
|
24
|
-
|
|
25
|
-
# 登录
|
|
26
|
-
wukong-cli auth login
|
|
27
|
-
|
|
28
|
-
# 查看状态
|
|
29
|
-
wukong-cli auth status
|
|
30
|
-
|
|
31
|
-
# 发送 API 请求
|
|
32
|
-
wukong-cli http get "/oceanet-auth/web/userInfo"
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## 开发
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
# 克隆仓库
|
|
39
|
-
git clone <repository-url>
|
|
40
|
-
cd wukong-ts-cli
|
|
41
|
-
|
|
42
|
-
# 安装依赖(自动构建项目)
|
|
43
|
-
npm install
|
|
44
|
-
|
|
45
|
-
# 开发模式(直接运行 TypeScript)
|
|
46
|
-
npm run dev <args>
|
|
47
|
-
|
|
48
|
-
# 生产环境构建
|
|
49
|
-
npm run build
|
|
50
|
-
|
|
51
|
-
# 全局链接用于测试
|
|
52
|
-
npm run link
|
|
53
|
-
|
|
54
|
-
# 运行测试
|
|
55
|
-
npm test
|
|
56
|
-
|
|
57
|
-
# 发布前验证
|
|
58
|
-
npm run verify
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
**注意**:项目配置了自动构建脚本(`prepare` 和 `prepack`),在 `npm install` 和 `npm publish` 时会自动构建。如果遇到 `MODULE_NOT_FOUND` 错误,请运行 `npm run build` 手动构建。
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
## 命令
|
|
65
|
-
|
|
66
|
-
### 配置命令
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
wukong-cli init # 初始化配置文件
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
### 更新命令
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
wukong-cli update # 更新到 npm latest 版本
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### 认证命令
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
wukong-cli auth login # OAuth Device PKCE Flow 登录
|
|
82
|
-
wukong-cli auth status # 显示认证状态
|
|
83
|
-
wukong-cli auth refresh # 刷新访问令牌
|
|
84
|
-
wukong-cli auth logout # 登出并清除令牌
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### HTTP 命令
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
wukong-cli http get "/endpoint" # GET 请求
|
|
91
|
-
wukong-cli http post "/endpoint" -d '{"key":"value"}' # POST 请求
|
|
92
|
-
wukong-cli http put "/endpoint" -d '{"key":"value"}' # PUT 请求
|
|
93
|
-
wukong-cli http delete "/endpoint" # DELETE 请求
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### 全局选项
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
--debug # 启用调试模式(显示 HTTP 请求)
|
|
100
|
-
-V, --version # 显示版本号
|
|
101
|
-
-h, --help # 显示帮助信息
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## 环境切换
|
|
105
|
-
|
|
106
|
-
```bash
|
|
107
|
-
# PowerShell
|
|
108
|
-
$env:WUKONG_CLI_ENV="beta"
|
|
109
|
-
wukong-cli auth login
|
|
110
|
-
|
|
111
|
-
# Bash/Zsh
|
|
112
|
-
export WUKONG_CLI_ENV="beta"
|
|
113
|
-
wukong-cli auth login
|
|
114
|
-
|
|
115
|
-
# CMD
|
|
116
|
-
set WUKONG_CLI_ENV=beta
|
|
117
|
-
wukong-cli auth login
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## 配置
|
|
121
|
-
|
|
122
|
-
Wukong CLI 使用智能配置,内置默认值:
|
|
123
|
-
|
|
124
|
-
- **无需配置**:CLI 开箱即用,使用内置的环境默认配置
|
|
125
|
-
- **自定义配置**:可选的 `wukong-cli.json` 用于自定义端点
|
|
126
|
-
- **智能回退**:环境未配置时使用内置默认值
|
|
127
|
-
- **清晰错误**:结构化错误消息指导您修复配置问题
|
|
128
|
-
|
|
129
|
-
### 配置文件位置
|
|
130
|
-
|
|
131
|
-
```bash
|
|
132
|
-
~/wukong-cli.json # 用户主目录
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### 初始化配置
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
wukong-cli init # 创建或重置配置文件
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### 配置示例
|
|
142
|
-
|
|
143
|
-
```json
|
|
144
|
-
{
|
|
145
|
-
"defaultEnv": "prod",
|
|
146
|
-
"environments": {
|
|
147
|
-
"prod": {
|
|
148
|
-
"authBaseUrl": "https://portal.zrhsh.com",
|
|
149
|
-
"apiBaseUrl": "https://nrp.zrhsh.com",
|
|
150
|
-
"clientId": "wukong-cli-prod"
|
|
151
|
-
},
|
|
152
|
-
"dev": {
|
|
153
|
-
"authBaseUrl": "https://portal-dev.zrhsh.com",
|
|
154
|
-
"apiBaseUrl": "https://nrp-dev.zrhsh.com",
|
|
155
|
-
"clientId": "wukong-cli-dev"
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### 配置错误
|
|
162
|
-
|
|
163
|
-
如果配置不完整,您会看到结构化错误消息:
|
|
164
|
-
|
|
165
|
-
```
|
|
166
|
-
[ERROR] Configuration Error
|
|
167
|
-
|
|
168
|
-
Incomplete configuration for environment 'prod'
|
|
169
|
-
Environment: prod
|
|
170
|
-
Missing fields: apiBaseUrl, clientId
|
|
171
|
-
|
|
172
|
-
Edit your wukong-cli.json or run 'wukong-cli init' to reset
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
## 文档
|
|
176
|
-
|
|
177
|
-
### 入门指南
|
|
178
|
-
- 📖 [快速开始](docs/getting-started/quick-start.md) - 5分钟快速上手
|
|
179
|
-
- 📖 [完整安装配置指南](docs/getting-started/complete-guide.md) - 详细安装和配置步骤
|
|
180
|
-
|
|
181
|
-
### 用户指南
|
|
182
|
-
- 📖 [命令参考](docs/user-guide/commands.md) - 完整命令参考
|
|
183
|
-
- 📖 [认证详解](docs/user-guide/authentication.md) - OAuth Device PKCE Flow 详情
|
|
184
|
-
- 📖 [环境配置](docs/user-guide/environments.md) - 多环境配置
|
|
185
|
-
- 📖 [故障排查](docs/user-guide/troubleshooting.md) - 常见问题和解决方案
|
|
186
|
-
|
|
187
|
-
### 开发指南
|
|
188
|
-
- 📖 [开发环境设置](docs/development/setup.md) - 开发环境配置
|
|
189
|
-
- 📖 [编码规范](docs/development/coding-standards.md) - 编码规范和最佳实践
|
|
190
|
-
- 📖 [测试指南](docs/development/testing.md) - 测试策略
|
|
191
|
-
- 📖 [贡献指南](docs/development/contributing.md) - 贡献指南
|
|
192
|
-
|
|
193
|
-
### 架构设计
|
|
194
|
-
- 📖 [架构概览](docs/architecture/README.md) - 系统架构文档
|
|
195
|
-
- 📖 [SOLID 改进](docs/architecture/solid-improvements.md) - SOLID 原则应用
|
|
196
|
-
- 📖 [配置系统架构](docs/architecture/configuration.md) - 配置系统设计
|
|
197
|
-
- 📖 [HTTP 客户端](docs/architecture/http-client.md) - HTTP 客户端架构
|
|
198
|
-
|
|
199
|
-
### 发布管理
|
|
200
|
-
- 📖 [发布指南](docs/publishing/README.md) - 版本管理和发布流程
|
|
201
|
-
- 📖 [发布说明](docs/publishing/release-notes.md) - 版本更新记录
|
|
202
|
-
|
|
203
|
-
## 项目信息
|
|
204
|
-
|
|
205
|
-
- **版本**: 0.3.0
|
|
206
|
-
- **包名**: @zrhsh/wukong-cli
|
|
207
|
-
- **组织**: @zrhsh
|
|
208
|
-
- **许可证**: MIT
|
|
209
|
-
- **Node.js**: v18+
|
|
210
|
-
- **TypeScript**: 5.x+
|
|
211
|
-
|
|
212
|
-
## 贡献
|
|
213
|
-
|
|
214
|
-
欢迎贡献!请参阅:
|
|
215
|
-
- 📖 [贡献指南](docs/development/contributing.md)
|
|
216
|
-
- 📖 [编码规范](docs/development/coding-standards.md)
|
|
217
|
-
|
|
218
|
-
## 许可证
|
|
219
|
-
|
|
220
|
-
MIT License - 详见 [LICENSE](LICENSE) 文件
|
|
221
|
-
|
|
222
|
-
## 支持
|
|
223
|
-
|
|
224
|
-
- **问题反馈**: (GitHub Issues URL)
|
|
225
|
-
- **文档**: (docs/ 目录)
|
|
226
|
-
- **调试模式**: 使用 `--debug` 标志查看详细日志
|
|
227
|
-
|
|
228
|
-
## 版本历史
|
|
229
|
-
|
|
230
|
-
详见 [发布说明](docs/publishing/release-notes.md)。
|
|
231
|
-
|
|
232
|
-
---
|
|
233
|
-
|
|
234
|
-
**当前版本**: 0.3.0 | **包名**: @zrhsh/wukong-cli | **组织**: @zrhsh
|
|
1
|
+
# Wukong CLI
|
|
2
|
+
|
|
3
|
+
用于 Oceanet/NRP 系统的 TypeScript CLI 工具,支持 OAuth Device PKCE Flow 认证和自动 token 刷新。
|
|
4
|
+
|
|
5
|
+
## 功能特性
|
|
6
|
+
|
|
7
|
+
- 🔐 **安全认证** - OAuth Device PKCE Flow,无需输入密码
|
|
8
|
+
- 🔄 **自动刷新** - Token 过期前自动刷新
|
|
9
|
+
- 🌍 **多环境支持** - 支持 dev、beta、uat 和 prod 环境
|
|
10
|
+
- 🐛 **调试模式** - 使用 `--debug` 标志显示 HTTP 请求和响应
|
|
11
|
+
- 💾 **安全存储** - 使用平台原生凭据管理器,支持文件回退
|
|
12
|
+
- 🛠️ **HTTP 客户端** - 内置 HTTP 客户端,自动处理认证
|
|
13
|
+
- ⚙️ **智能配置** - 内置默认配置,支持用户自定义
|
|
14
|
+
- 🔍 **结构化错误** - 清晰的错误消息和可操作的修复建议
|
|
15
|
+
|
|
16
|
+
## 快速开始
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# 安装
|
|
20
|
+
npm install -g @zrhsh/wukong-cli
|
|
21
|
+
|
|
22
|
+
# 初始化配置
|
|
23
|
+
wukong-cli init
|
|
24
|
+
|
|
25
|
+
# 登录
|
|
26
|
+
wukong-cli auth login
|
|
27
|
+
|
|
28
|
+
# 查看状态
|
|
29
|
+
wukong-cli auth status
|
|
30
|
+
|
|
31
|
+
# 发送 API 请求
|
|
32
|
+
wukong-cli http get "/oceanet-auth/web/userInfo"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 开发
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# 克隆仓库
|
|
39
|
+
git clone <repository-url>
|
|
40
|
+
cd wukong-ts-cli
|
|
41
|
+
|
|
42
|
+
# 安装依赖(自动构建项目)
|
|
43
|
+
npm install
|
|
44
|
+
|
|
45
|
+
# 开发模式(直接运行 TypeScript)
|
|
46
|
+
npm run dev <args>
|
|
47
|
+
|
|
48
|
+
# 生产环境构建
|
|
49
|
+
npm run build
|
|
50
|
+
|
|
51
|
+
# 全局链接用于测试
|
|
52
|
+
npm run link
|
|
53
|
+
|
|
54
|
+
# 运行测试
|
|
55
|
+
npm test
|
|
56
|
+
|
|
57
|
+
# 发布前验证
|
|
58
|
+
npm run verify
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**注意**:项目配置了自动构建脚本(`prepare` 和 `prepack`),在 `npm install` 和 `npm publish` 时会自动构建。如果遇到 `MODULE_NOT_FOUND` 错误,请运行 `npm run build` 手动构建。
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## 命令
|
|
65
|
+
|
|
66
|
+
### 配置命令
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
wukong-cli init # 初始化配置文件
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 更新命令
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
wukong-cli update # 更新到 npm latest 版本
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 认证命令
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
wukong-cli auth login # OAuth Device PKCE Flow 登录
|
|
82
|
+
wukong-cli auth status # 显示认证状态
|
|
83
|
+
wukong-cli auth refresh # 刷新访问令牌
|
|
84
|
+
wukong-cli auth logout # 登出并清除令牌
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### HTTP 命令
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
wukong-cli http get "/endpoint" # GET 请求
|
|
91
|
+
wukong-cli http post "/endpoint" -d '{"key":"value"}' # POST 请求
|
|
92
|
+
wukong-cli http put "/endpoint" -d '{"key":"value"}' # PUT 请求
|
|
93
|
+
wukong-cli http delete "/endpoint" # DELETE 请求
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 全局选项
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
--debug # 启用调试模式(显示 HTTP 请求)
|
|
100
|
+
-V, --version # 显示版本号
|
|
101
|
+
-h, --help # 显示帮助信息
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 环境切换
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# PowerShell
|
|
108
|
+
$env:WUKONG_CLI_ENV="beta"
|
|
109
|
+
wukong-cli auth login
|
|
110
|
+
|
|
111
|
+
# Bash/Zsh
|
|
112
|
+
export WUKONG_CLI_ENV="beta"
|
|
113
|
+
wukong-cli auth login
|
|
114
|
+
|
|
115
|
+
# CMD
|
|
116
|
+
set WUKONG_CLI_ENV=beta
|
|
117
|
+
wukong-cli auth login
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## 配置
|
|
121
|
+
|
|
122
|
+
Wukong CLI 使用智能配置,内置默认值:
|
|
123
|
+
|
|
124
|
+
- **无需配置**:CLI 开箱即用,使用内置的环境默认配置
|
|
125
|
+
- **自定义配置**:可选的 `wukong-cli.json` 用于自定义端点
|
|
126
|
+
- **智能回退**:环境未配置时使用内置默认值
|
|
127
|
+
- **清晰错误**:结构化错误消息指导您修复配置问题
|
|
128
|
+
|
|
129
|
+
### 配置文件位置
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
~/wukong-cli.json # 用户主目录
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 初始化配置
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
wukong-cli init # 创建或重置配置文件
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 配置示例
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"defaultEnv": "prod",
|
|
146
|
+
"environments": {
|
|
147
|
+
"prod": {
|
|
148
|
+
"authBaseUrl": "https://portal.zrhsh.com",
|
|
149
|
+
"apiBaseUrl": "https://nrp.zrhsh.com",
|
|
150
|
+
"clientId": "wukong-cli-prod"
|
|
151
|
+
},
|
|
152
|
+
"dev": {
|
|
153
|
+
"authBaseUrl": "https://portal-dev.zrhsh.com",
|
|
154
|
+
"apiBaseUrl": "https://nrp-dev.zrhsh.com",
|
|
155
|
+
"clientId": "wukong-cli-dev"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 配置错误
|
|
162
|
+
|
|
163
|
+
如果配置不完整,您会看到结构化错误消息:
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
[ERROR] Configuration Error
|
|
167
|
+
|
|
168
|
+
Incomplete configuration for environment 'prod'
|
|
169
|
+
Environment: prod
|
|
170
|
+
Missing fields: apiBaseUrl, clientId
|
|
171
|
+
|
|
172
|
+
Edit your wukong-cli.json or run 'wukong-cli init' to reset
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## 文档
|
|
176
|
+
|
|
177
|
+
### 入门指南
|
|
178
|
+
- 📖 [快速开始](docs/getting-started/quick-start.md) - 5分钟快速上手
|
|
179
|
+
- 📖 [完整安装配置指南](docs/getting-started/complete-guide.md) - 详细安装和配置步骤
|
|
180
|
+
|
|
181
|
+
### 用户指南
|
|
182
|
+
- 📖 [命令参考](docs/user-guide/commands.md) - 完整命令参考
|
|
183
|
+
- 📖 [认证详解](docs/user-guide/authentication.md) - OAuth Device PKCE Flow 详情
|
|
184
|
+
- 📖 [环境配置](docs/user-guide/environments.md) - 多环境配置
|
|
185
|
+
- 📖 [故障排查](docs/user-guide/troubleshooting.md) - 常见问题和解决方案
|
|
186
|
+
|
|
187
|
+
### 开发指南
|
|
188
|
+
- 📖 [开发环境设置](docs/development/setup.md) - 开发环境配置
|
|
189
|
+
- 📖 [编码规范](docs/development/coding-standards.md) - 编码规范和最佳实践
|
|
190
|
+
- 📖 [测试指南](docs/development/testing.md) - 测试策略
|
|
191
|
+
- 📖 [贡献指南](docs/development/contributing.md) - 贡献指南
|
|
192
|
+
|
|
193
|
+
### 架构设计
|
|
194
|
+
- 📖 [架构概览](docs/architecture/README.md) - 系统架构文档
|
|
195
|
+
- 📖 [SOLID 改进](docs/architecture/solid-improvements.md) - SOLID 原则应用
|
|
196
|
+
- 📖 [配置系统架构](docs/architecture/configuration.md) - 配置系统设计
|
|
197
|
+
- 📖 [HTTP 客户端](docs/architecture/http-client.md) - HTTP 客户端架构
|
|
198
|
+
|
|
199
|
+
### 发布管理
|
|
200
|
+
- 📖 [发布指南](docs/publishing/README.md) - 版本管理和发布流程
|
|
201
|
+
- 📖 [发布说明](docs/publishing/release-notes.md) - 版本更新记录
|
|
202
|
+
|
|
203
|
+
## 项目信息
|
|
204
|
+
|
|
205
|
+
- **版本**: 0.3.0
|
|
206
|
+
- **包名**: @zrhsh/wukong-cli
|
|
207
|
+
- **组织**: @zrhsh
|
|
208
|
+
- **许可证**: MIT
|
|
209
|
+
- **Node.js**: v18+
|
|
210
|
+
- **TypeScript**: 5.x+
|
|
211
|
+
|
|
212
|
+
## 贡献
|
|
213
|
+
|
|
214
|
+
欢迎贡献!请参阅:
|
|
215
|
+
- 📖 [贡献指南](docs/development/contributing.md)
|
|
216
|
+
- 📖 [编码规范](docs/development/coding-standards.md)
|
|
217
|
+
|
|
218
|
+
## 许可证
|
|
219
|
+
|
|
220
|
+
MIT License - 详见 [LICENSE](LICENSE) 文件
|
|
221
|
+
|
|
222
|
+
## 支持
|
|
223
|
+
|
|
224
|
+
- **问题反馈**: (GitHub Issues URL)
|
|
225
|
+
- **文档**: (docs/ 目录)
|
|
226
|
+
- **调试模式**: 使用 `--debug` 标志查看详细日志
|
|
227
|
+
|
|
228
|
+
## 版本历史
|
|
229
|
+
|
|
230
|
+
详见 [发布说明](docs/publishing/release-notes.md)。
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
**当前版本**: 0.3.0 | **包名**: @zrhsh/wukong-cli | **组织**: @zrhsh
|
package/dist/cli.js
CHANGED
|
@@ -1873,7 +1873,7 @@ var AuthenticatingHttpClient = class {
|
|
|
1873
1873
|
}
|
|
1874
1874
|
const errorHandler = getApiErrorHandler();
|
|
1875
1875
|
errorHandler.handle(data);
|
|
1876
|
-
return data.result;
|
|
1876
|
+
return data.result ?? data.data;
|
|
1877
1877
|
}
|
|
1878
1878
|
/**
|
|
1879
1879
|
* GET 请求
|
|
@@ -2458,7 +2458,16 @@ async function executeRequest(method, url, options) {
|
|
|
2458
2458
|
if (requestData) {
|
|
2459
2459
|
fetchOptions.body = JSON.stringify(requestData);
|
|
2460
2460
|
}
|
|
2461
|
-
const
|
|
2461
|
+
const finalUrl = fullUrl + parseParams(options.params);
|
|
2462
|
+
let response;
|
|
2463
|
+
try {
|
|
2464
|
+
response = await fetch(finalUrl, fetchOptions);
|
|
2465
|
+
} catch (fetchError) {
|
|
2466
|
+
spinner.fail(`Request failed`);
|
|
2467
|
+
console.error(chalk6.red(`URL: ${finalUrl}`));
|
|
2468
|
+
console.error(chalk6.red(`Error: ${JSON.stringify(fetchError.cause) || fetchError.message}`));
|
|
2469
|
+
process.exit(1);
|
|
2470
|
+
}
|
|
2462
2471
|
const duration2 = Date.now() - startTime2;
|
|
2463
2472
|
if (!response.ok) {
|
|
2464
2473
|
const errText = await response.text().catch(() => "");
|
|
@@ -2634,8 +2643,7 @@ var NpmUpdater = class {
|
|
|
2634
2643
|
if (platform === "win32") {
|
|
2635
2644
|
return {
|
|
2636
2645
|
shell: true,
|
|
2637
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
2638
|
-
env: { ...process.env, NODE_NO_WARNINGS: "1" }
|
|
2646
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
2639
2647
|
};
|
|
2640
2648
|
}
|
|
2641
2649
|
return { stdio: ["ignore", "pipe", "pipe"] };
|
|
@@ -2727,7 +2735,7 @@ async function runUpdateCommand({
|
|
|
2727
2735
|
}
|
|
2728
2736
|
var updateCommand = new Command4("update").description("Update wukong-cli to the latest npm version").action(async () => {
|
|
2729
2737
|
const exitCode = await runUpdateCommand({
|
|
2730
|
-
currentVersion: "0.4.
|
|
2738
|
+
currentVersion: "0.4.20",
|
|
2731
2739
|
versionProvider: new NpmVersionProvider(
|
|
2732
2740
|
"@zrhsh/wukong-cli",
|
|
2733
2741
|
"https://registry.npmjs.org"
|
|
@@ -2742,7 +2750,7 @@ var updateCommand = new Command4("update").description("Update wukong-cli to the
|
|
|
2742
2750
|
|
|
2743
2751
|
// src/cli.ts
|
|
2744
2752
|
var program = new Command5();
|
|
2745
|
-
program.name("wukong-cli").description("Wukong CLI - TypeScript implementation").version("0.4.
|
|
2753
|
+
program.name("wukong-cli").description("Wukong CLI - TypeScript implementation").version("0.4.20").option("--debug", "Enable debug mode (show HTTP requests)").hook("preAction", (thisCommand) => {
|
|
2746
2754
|
const options = thisCommand.opts();
|
|
2747
2755
|
if (options.debug === true) {
|
|
2748
2756
|
setDebugMode(true, true);
|
|
@@ -2760,7 +2768,7 @@ if (process.argv.length === 2) {
|
|
|
2760
2768
|
program.parse();
|
|
2761
2769
|
setImmediate(() => {
|
|
2762
2770
|
try {
|
|
2763
|
-
const versionChecker = getVersionChecker("0.4.
|
|
2771
|
+
const versionChecker = getVersionChecker("0.4.20");
|
|
2764
2772
|
const notifier = new ConsoleNotifier();
|
|
2765
2773
|
versionChecker.checkInBackground(notifier).catch(() => {
|
|
2766
2774
|
});
|