@zrhsh/wukong-cli 0.1.5 → 0.1.7
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 +140 -120
- package/dist/cli.js +248 -175
- package/dist/cli.js.map +1 -1
- package/package.json +18 -2
package/README.md
CHANGED
|
@@ -1,172 +1,192 @@
|
|
|
1
1
|
# Wukong CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript CLI tool for Oceanet/NRP system with OAuth Device PKCE Flow authentication and automatic token refresh.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔐 **Secure Authentication** - OAuth Device PKCE Flow without password input
|
|
8
|
+
- 🔄 **Auto Token Refresh** - Automatic token refresh before expiration
|
|
9
|
+
- 🌍 **Multi-Environment** - Support for dev, beta, uat, and prod environments
|
|
10
|
+
- 🐛 **Debug Mode** - Show HTTP requests and responses with `--debug` flag
|
|
11
|
+
- 💾 **Secure Storage** - Platform native credential managers with file fallback
|
|
12
|
+
- 🛠️ **HTTP Client** - Built-in HTTP client with automatic authentication
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
6
15
|
|
|
7
16
|
```bash
|
|
8
|
-
#
|
|
9
|
-
npm install -g @
|
|
17
|
+
# Install
|
|
18
|
+
npm install -g @zrhsh/wukong-cli
|
|
10
19
|
|
|
11
|
-
#
|
|
20
|
+
# Initialize configuration
|
|
21
|
+
wukong-cli init
|
|
22
|
+
|
|
23
|
+
# Login
|
|
12
24
|
wukong-cli auth login
|
|
13
25
|
|
|
14
|
-
#
|
|
26
|
+
# Check status
|
|
15
27
|
wukong-cli auth status
|
|
16
|
-
```
|
|
17
28
|
|
|
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
|
-
}
|
|
29
|
+
# Make API request
|
|
30
|
+
wukong-cli http get "/oceanet-auth/web/userInfo"
|
|
47
31
|
```
|
|
48
32
|
|
|
49
|
-
##
|
|
33
|
+
## Commands
|
|
50
34
|
|
|
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
|
-
```
|
|
35
|
+
### Configuration Commands
|
|
65
36
|
|
|
66
|
-
|
|
37
|
+
```bash
|
|
38
|
+
wukong-cli init # Initialize configuration file
|
|
39
|
+
```
|
|
67
40
|
|
|
68
|
-
|
|
69
|
-
# PowerShell
|
|
70
|
-
$env:WUKONG_CLI_ENV="prod"
|
|
71
|
-
wukong-cli auth status
|
|
41
|
+
### Authentication Commands
|
|
72
42
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
wukong-cli auth status
|
|
43
|
+
```bash
|
|
44
|
+
wukong-cli auth login # OAuth Device PKCE Flow login
|
|
45
|
+
wukong-cli auth status # Show authentication status
|
|
46
|
+
wukong-cli auth refresh # Refresh access token
|
|
47
|
+
wukong-cli auth logout # Logout and clear tokens
|
|
76
48
|
```
|
|
77
49
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
```powershell
|
|
81
|
-
# 方式 1:命令行参数
|
|
82
|
-
wukong-cli auth status --debug
|
|
50
|
+
### HTTP Commands
|
|
83
51
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
wukong-cli
|
|
52
|
+
```bash
|
|
53
|
+
wukong-cli http get "/endpoint" # GET request
|
|
54
|
+
wukong-cli http post "/endpoint" -d '{"key":"value"}' # POST request
|
|
55
|
+
wukong-cli http put "/endpoint" -d '{"key":"value"}' # PUT request
|
|
56
|
+
wukong-cli http delete "/endpoint" # DELETE request
|
|
87
57
|
```
|
|
88
58
|
|
|
89
|
-
|
|
59
|
+
### Global Options
|
|
90
60
|
|
|
91
61
|
```bash
|
|
92
|
-
#
|
|
93
|
-
|
|
94
|
-
|
|
62
|
+
--debug # Enable debug mode (show HTTP requests)
|
|
63
|
+
-V, --version # Show version number
|
|
64
|
+
-h, --help # Show help information
|
|
65
|
+
```
|
|
95
66
|
|
|
96
|
-
|
|
97
|
-
npm install
|
|
67
|
+
## Environment Switching
|
|
98
68
|
|
|
99
|
-
|
|
100
|
-
|
|
69
|
+
```bash
|
|
70
|
+
# PowerShell
|
|
71
|
+
$env:WUKONG_CLI_ENV="beta"
|
|
72
|
+
wukong-cli auth login
|
|
101
73
|
|
|
102
|
-
#
|
|
103
|
-
|
|
74
|
+
# Bash/Zsh
|
|
75
|
+
export WUKONG_CLI_ENV="beta"
|
|
76
|
+
wukong-cli auth login
|
|
104
77
|
|
|
105
|
-
#
|
|
106
|
-
|
|
78
|
+
# CMD
|
|
79
|
+
set WUKONG_CLI_ENV=beta
|
|
80
|
+
wukong-cli auth login
|
|
107
81
|
```
|
|
108
82
|
|
|
109
|
-
##
|
|
83
|
+
## Documentation
|
|
110
84
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
85
|
+
### Getting Started
|
|
86
|
+
- 📖 [Installation Guide](docs/getting-started/installation.md) - Detailed installation steps
|
|
87
|
+
- 📖 [Quick Start](docs/getting-started/quick-start.md) - 5-minute quick start guide
|
|
88
|
+
- 📖 [Configuration](docs/getting-started/configuration.md) - Environment configuration
|
|
114
89
|
|
|
115
|
-
|
|
90
|
+
### User Guide
|
|
91
|
+
- 📖 [Command Reference](docs/user-guide/commands.md) - Complete command reference
|
|
92
|
+
- 📖 [Authentication](docs/user-guide/authentication.md) - OAuth Device PKCE Flow details
|
|
93
|
+
- 📖 [Environments](docs/user-guide/environments.md) - Multi-environment configuration
|
|
94
|
+
- 📖 [Troubleshooting](docs/user-guide/troubleshooting.md) - Common issues and solutions
|
|
116
95
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
96
|
+
### Development
|
|
97
|
+
- 📖 [Development Setup](docs/development/setup.md) - Development environment setup
|
|
98
|
+
- 📖 [Coding Standards](docs/development/coding-standards.md) - Coding standards and best practices
|
|
99
|
+
- 📖 [Testing Guide](docs/development/testing.md) - Testing strategies
|
|
100
|
+
- 📖 [Contributing](docs/development/contributing.md) - Contribution guide
|
|
120
101
|
|
|
121
|
-
|
|
122
|
-
|
|
102
|
+
### Architecture
|
|
103
|
+
- 📖 [Architecture Overview](docs/architecture/README.md) - System architecture documentation
|
|
104
|
+
- 📖 [Design Patterns](docs/architecture/solid-improvements.md) - SOLID principles application
|
|
105
|
+
- 📖 [HTTP Client](docs/architecture/http-client.md) - HTTP client architecture
|
|
106
|
+
|
|
107
|
+
### Publishing
|
|
108
|
+
- 📖 [Publishing Guide](docs/publishing/README.md) - Version management and publishing
|
|
109
|
+
|
|
110
|
+
## Project Information
|
|
123
111
|
|
|
124
|
-
|
|
125
|
-
wukong-cli
|
|
112
|
+
- **Version**: 0.1.6
|
|
113
|
+
- **Package**: @zrhsh/wukong-cli
|
|
114
|
+
- **Organization**: @zrhsh
|
|
115
|
+
- **License**: MIT
|
|
116
|
+
- **Node.js**: v18+
|
|
117
|
+
- **TypeScript**: 5.x+
|
|
126
118
|
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
## Installation
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Global installation from npm
|
|
123
|
+
npm install -g @zzhsh/wukong-cli
|
|
124
|
+
|
|
125
|
+
# Development installation from source
|
|
126
|
+
git clone <repository-url>
|
|
127
|
+
cd wukong-ts-cli
|
|
128
|
+
npm install
|
|
129
|
+
npm run build
|
|
130
|
+
npm run link
|
|
129
131
|
```
|
|
130
132
|
|
|
131
|
-
##
|
|
133
|
+
## Development
|
|
132
134
|
|
|
133
135
|
```bash
|
|
134
|
-
#
|
|
136
|
+
# Clone repository
|
|
137
|
+
git clone <repository-url>
|
|
138
|
+
cd wukong-ts-cli
|
|
139
|
+
|
|
140
|
+
# Install dependencies
|
|
135
141
|
npm install
|
|
136
142
|
|
|
137
|
-
#
|
|
138
|
-
npm run dev login
|
|
143
|
+
# Development mode
|
|
144
|
+
npm run dev auth login
|
|
139
145
|
|
|
140
|
-
#
|
|
146
|
+
# Build
|
|
141
147
|
npm run build
|
|
142
148
|
|
|
143
|
-
#
|
|
149
|
+
# Test
|
|
144
150
|
npm run link
|
|
145
|
-
wukong-cli --
|
|
151
|
+
wukong-cli --version
|
|
152
|
+
|
|
153
|
+
# Unit tests
|
|
154
|
+
npm test
|
|
155
|
+
|
|
156
|
+
# E2E tests - Automated (无需用户交互,CI/CD 推荐)
|
|
157
|
+
npm run test:e2e:automated # 默认环境自动化测试
|
|
158
|
+
npm run test:e2e:automated:dev # 开发环境自动化测试
|
|
159
|
+
npm run test:e2e:automated:beta # 测试环境自动化测试
|
|
160
|
+
npm run test:e2e:automated:prod # 生产环境自动化测试
|
|
161
|
+
|
|
162
|
+
# E2E tests - Interactive (需要用户OAuth授权)
|
|
163
|
+
npm run test:e2e:interactive # 默认环境交互式测试
|
|
164
|
+
npm run test:e2e:interactive:dev # 开发环境交互式测试
|
|
165
|
+
npm run test:e2e:interactive:beta # 测试环境交互式测试
|
|
166
|
+
npm run test:e2e:interactive:prod # 生产环境交互式测试
|
|
167
|
+
npm run test:e2e:interactive:run # 带用户引导的交互式测试
|
|
146
168
|
```
|
|
147
169
|
|
|
148
|
-
##
|
|
170
|
+
## Contributing
|
|
149
171
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
```
|
|
172
|
+
Contributions are welcome! Please see:
|
|
173
|
+
- 📖 [Contributing Guide](docs/development/contributing.md)
|
|
174
|
+
- 📖 [Coding Standards](docs/development/coding-standards.md)
|
|
154
175
|
|
|
155
|
-
##
|
|
176
|
+
## License
|
|
156
177
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
178
|
+
MIT License - see [LICENSE](LICENSE) file for details
|
|
179
|
+
|
|
180
|
+
## Support
|
|
181
|
+
|
|
182
|
+
- **Issues**: (GitHub Issues URL)
|
|
183
|
+
- **Documentation**: (in docs/ directory)
|
|
184
|
+
- **Debug Mode**: Use `--debug` flag for detailed logs
|
|
185
|
+
|
|
186
|
+
## Version History
|
|
187
|
+
|
|
188
|
+
See [Release Notes](docs/publishing/release-notes.md) for version history and changes.
|
|
166
189
|
|
|
167
|
-
|
|
190
|
+
---
|
|
168
191
|
|
|
169
|
-
|
|
|
170
|
-
|--------|--------|
|
|
171
|
-
| `lark-cli` | `wukong-cli` |
|
|
172
|
-
| `@larksuite/ts-cli` | `@wukong/ts-cli` |
|
|
192
|
+
**Current Version**: 0.1.6 | **Package**: @zrhsh/wukong-cli | **Organization**: @zrhsh
|