@zrhsh/wukong-cli 0.1.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/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # Wukong CLI
2
+
3
+ 极简的 TypeScript CLI 工具,支持 OAuth Device Flow 认证和自动 token 刷新。
4
+
5
+ ## 快速开始
6
+
7
+ ```bash
8
+ # 全局安装
9
+ npm install -g @yph/wukong-cli
10
+
11
+ # 登录
12
+ wukong-cli auth login
13
+
14
+ # 查看状态
15
+ wukong-cli auth status
16
+ ```
17
+
18
+ ## 配置文件
19
+
20
+ 首次运行时,CLI 会在用户主目录自动创建配置文件:
21
+
22
+ - **Windows**: `C:\Users\你的用户名\wukong-cli.json`
23
+ - **macOS/Linux**: `~/wukong-cli.json`
24
+
25
+ 默认配置:
26
+ ```json
27
+ {
28
+ "defaultEnv": "beta",
29
+ "environments": {
30
+ "beta": {
31
+ "authBaseUrl": "https://portal-beta.zrhsh.com",
32
+ "apiBaseUrl": "https://nrp-recode.zrhsh.com",
33
+ "clientId": "wukong-cli-beta"
34
+ },
35
+ "uat": {
36
+ "authBaseUrl": "https://portal-uat.zrhsh.com",
37
+ "apiBaseUrl": "https://nrp-recode-uat.zrhsh.com",
38
+ "clientId": "wukong-cli-uat"
39
+ },
40
+ "prod": {
41
+ "authBaseUrl": "https://portal.zrhsh.com",
42
+ "apiBaseUrl": "https://nrp-prod.zrhsh.com",
43
+ "clientId": "wukong-cli-prod"
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ ## 命令
50
+
51
+ ```
52
+ wukong-cli
53
+ ├── auth
54
+ │ ├── login # OAuth Device Flow 登录
55
+ │ ├── logout # 登出
56
+ │ ├── refresh # 刷新令牌
57
+ │ └── status # 查看状态
58
+ ├── http
59
+ │ ├── get # GET 请求
60
+ │ ├── post # POST 请求
61
+ │ ├── put # PUT 请求
62
+ │ └── delete # DELETE 请求
63
+ └── test # 测试 API
64
+ ```
65
+
66
+ ## 环境切换
67
+
68
+ ```powershell
69
+ # PowerShell
70
+ $env:WUKONG_CLI_ENV="prod"
71
+ wukong-cli auth status
72
+
73
+ # Bash
74
+ export WUKONG_CLI_ENV=prod
75
+ wukong-cli auth status
76
+ ```
77
+
78
+ ## 调试模式
79
+
80
+ ```powershell
81
+ # 方式 1:命令行参数
82
+ wukong-cli auth status --debug
83
+
84
+ # 方式 2:环境变量
85
+ $env:WUKONG_CLI_DEBUG="true"
86
+ wukong-cli auth status
87
+ ```
88
+
89
+ ## 开发
90
+
91
+ ```bash
92
+ # 克隆仓库
93
+ git clone <repo-url>
94
+ cd wukong-ts-cli
95
+
96
+ # 安装依赖
97
+ npm install
98
+
99
+ # 开发模式
100
+ npm run dev auth login
101
+
102
+ # 构建
103
+ npm run build
104
+
105
+ # 本地测试
106
+ npm run link
107
+ ```
108
+
109
+ ## 环境变量
110
+
111
+ ```bash
112
+ export WUKONG_APP_ID="cli_xxxxxxxxx"
113
+ ```
114
+
115
+ ## 使用示例
116
+
117
+ ```bash
118
+ # 登录
119
+ wukong-cli auth login
120
+
121
+ # 查看状态
122
+ wukong-cli auth status
123
+
124
+ # 测试请求
125
+ wukong-cli test
126
+
127
+ # 登出
128
+ wukong-cli auth logout
129
+ ```
130
+
131
+ ## 开发
132
+
133
+ ```bash
134
+ # 安装依赖
135
+ npm install
136
+
137
+ # 开发模式
138
+ npm run dev login
139
+
140
+ # 构建
141
+ npm run build
142
+
143
+ # 本地测试
144
+ npm run link
145
+ wukong-cli --help
146
+ ```
147
+
148
+ ## 发布
149
+
150
+ ```bash
151
+ npm run verify
152
+ npm run publish:patch
153
+ ```
154
+
155
+ ## 项目结构
156
+
157
+ ```
158
+ @wukong/ts-cli/
159
+ ├── src/
160
+ │ ├── cli.ts # CLI 主入口
161
+ │ ├── auth/ # OAuth 认证
162
+ │ └── http/ # HTTP 客户端
163
+ ├── dist/ # 编译输出
164
+ └── package.json # 包配置
165
+ ```
166
+
167
+ ## 命令对比
168
+
169
+ | 旧命令 | 新命令 |
170
+ |--------|--------|
171
+ | `lark-cli` | `wukong-cli` |
172
+ | `@larksuite/ts-cli` | `@wukong/ts-cli` |