sealos-cli 0.1.0 → 1.0.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 +58 -47
- package/dist/bin/cli.cjs +4988 -767
- package/dist/bin/cli.mjs +4988 -767
- package/dist/main.cjs +4984 -767
- package/dist/main.mjs +4988 -767
- package/package.json +2 -2
- package/src/commands/database/index.ts +11 -11
- package/src/commands/devbox/index.ts +676 -183
- package/src/commands/template/index.ts +103 -37
- package/src/commands/workspace/index.ts +49 -39
- package/src/docs/database_openapi.json +21 -38
- package/src/docs/devbox_openapi.json +5760 -0
- package/src/docs/template_openapi.json +2661 -1
- package/src/generated/database.ts +1 -5
- package/src/generated/devbox.ts +2500 -0
- package/src/generated/template.ts +228 -0
- package/src/lib/api-client.ts +18 -0
- package/src/lib/auth.ts +12 -3
- package/src/main.ts +1 -9
- package/src/types/index.ts +0 -12
- package/src/commands/config/index.ts +0 -54
- package/src/lib/api.ts +0 -83
- package/src/lib/config.ts +0 -134
package/README.md
CHANGED
|
@@ -27,12 +27,10 @@ src/
|
|
|
27
27
|
│ ├── quota/ # Resource quotas
|
|
28
28
|
│ │ └── index.ts
|
|
29
29
|
│ ├── app/ # Application management
|
|
30
|
-
│ │ └── index.ts
|
|
31
|
-
│ └── config/ # CLI configuration
|
|
32
30
|
│ └── index.ts
|
|
33
31
|
├── lib/ # Shared libraries
|
|
34
|
-
│ ├── api.ts
|
|
35
|
-
│ ├──
|
|
32
|
+
│ ├── api-client.ts # OpenAPI client factories
|
|
33
|
+
│ ├── auth.ts # Sealos auth and kubeconfig headers
|
|
36
34
|
│ ├── errors.ts # Error handling
|
|
37
35
|
│ └── output.ts # Output formatting
|
|
38
36
|
├── types/ # TypeScript type definitions
|
|
@@ -42,18 +40,18 @@ src/
|
|
|
42
40
|
|
|
43
41
|
## Architecture
|
|
44
42
|
|
|
45
|
-
###
|
|
43
|
+
### Authentication (`lib/auth.ts`)
|
|
46
44
|
|
|
47
|
-
- Manages
|
|
48
|
-
-
|
|
49
|
-
-
|
|
45
|
+
- Manages Sealos auth state at `~/.sealos/auth.json`
|
|
46
|
+
- Stores current workspace kubeconfig at `~/.sealos/kubeconfig`
|
|
47
|
+
- Builds provider API headers with URL-encoded kubeconfig content
|
|
50
48
|
|
|
51
|
-
###
|
|
49
|
+
### OpenAPI Clients (`lib/api-client.ts`)
|
|
52
50
|
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
51
|
+
- Type-safe clients generated from `src/docs/*_openapi.json`
|
|
52
|
+
- Routes template calls to `template.<region>/api/v2alpha`
|
|
53
|
+
- Routes database calls to `dbprovider.<region>/api/v2alpha`
|
|
54
|
+
- Routes devbox calls to `devbox.<region>/api/v2alpha`
|
|
57
55
|
|
|
58
56
|
### Output Formatting (`lib/output.ts`)
|
|
59
57
|
|
|
@@ -104,15 +102,17 @@ npm test
|
|
|
104
102
|
### Authentication
|
|
105
103
|
|
|
106
104
|
```bash
|
|
107
|
-
# Login in browser and exchange for kubeconfig automatically
|
|
108
|
-
sealos login
|
|
109
|
-
|
|
110
|
-
# Login with kubeconfig content
|
|
111
|
-
sealos login hzh.sealos.run --token "$(cat ~/.kube/config)"
|
|
105
|
+
# Login in browser and exchange for regional token + kubeconfig automatically
|
|
106
|
+
sealos login https://usw-1.sealos.io
|
|
112
107
|
|
|
113
108
|
# Check current user
|
|
114
109
|
sealos whoami
|
|
115
110
|
|
|
111
|
+
# Inspect auth and switch workspace
|
|
112
|
+
sealos auth info
|
|
113
|
+
sealos auth list
|
|
114
|
+
sealos auth switch <workspace-id-or-team-name>
|
|
115
|
+
|
|
116
116
|
# Logout
|
|
117
117
|
sealos logout
|
|
118
118
|
```
|
|
@@ -144,7 +144,7 @@ sealos workspace current
|
|
|
144
144
|
|
|
145
145
|
```bash
|
|
146
146
|
# Create a devbox
|
|
147
|
-
sealos devbox create --name my-devbox --
|
|
147
|
+
sealos devbox create --name my-devbox --runtime next.js --cpu 2c --memory 4g --port 3000:http:public
|
|
148
148
|
|
|
149
149
|
# List devboxes
|
|
150
150
|
sealos devbox list
|
|
@@ -153,18 +153,32 @@ sealos devbox list --output json
|
|
|
153
153
|
# Get devbox details
|
|
154
154
|
sealos devbox get my-devbox
|
|
155
155
|
|
|
156
|
-
#
|
|
157
|
-
sealos devbox
|
|
156
|
+
# Update resources or ports
|
|
157
|
+
sealos devbox update my-devbox --cpu 4 --memory 8 --port portName=web,number=3000,protocol=http,isPublic=true
|
|
158
158
|
|
|
159
|
-
# Start/
|
|
159
|
+
# Start/Pause/Shutdown/Restart
|
|
160
160
|
sealos devbox start my-devbox
|
|
161
|
-
sealos devbox
|
|
161
|
+
sealos devbox pause my-devbox
|
|
162
|
+
sealos devbox shutdown my-devbox
|
|
162
163
|
sealos devbox restart my-devbox
|
|
163
164
|
|
|
165
|
+
# Configure autostart and inspect monitor data
|
|
166
|
+
sealos devbox autostart my-devbox --exec-command "npm start"
|
|
167
|
+
sealos devbox monitor my-devbox --step 2m
|
|
168
|
+
|
|
169
|
+
# Templates, releases, and deployments
|
|
170
|
+
sealos devbox templates
|
|
171
|
+
sealos devbox releases list my-devbox
|
|
172
|
+
sealos devbox releases create my-devbox --tag v1-0-0 --description "First release"
|
|
173
|
+
sealos devbox releases deploy my-devbox v1-0-0
|
|
174
|
+
sealos devbox deployments my-devbox
|
|
175
|
+
|
|
164
176
|
# Delete devbox
|
|
165
|
-
sealos devbox delete my-devbox
|
|
177
|
+
sealos devbox delete my-devbox
|
|
166
178
|
```
|
|
167
179
|
|
|
180
|
+
Implementation: `src/commands/devbox/index.ts`, backed by `src/docs/devbox_openapi.json`.
|
|
181
|
+
|
|
168
182
|
### Database Management
|
|
169
183
|
|
|
170
184
|
```bash
|
|
@@ -183,39 +197,37 @@ sealos database connection my-db
|
|
|
183
197
|
# More commands
|
|
184
198
|
sealos database --help
|
|
185
199
|
sealos database <subcommand> --help
|
|
200
|
+
|
|
201
|
+
# Operational commands backed by src/docs/database_openapi.json
|
|
202
|
+
sealos database update my-db --cpu 2 --memory 4
|
|
203
|
+
sealos database start my-db
|
|
204
|
+
sealos database pause my-db
|
|
205
|
+
sealos database restart my-db
|
|
206
|
+
sealos database backup my-db --name manual-backup
|
|
207
|
+
sealos database backups my-db
|
|
208
|
+
sealos database restore my-db --from manual-backup --name restored-db
|
|
209
|
+
sealos database enable-public my-db
|
|
210
|
+
sealos database disable-public my-db
|
|
211
|
+
sealos database log-files <pod-name> --db-type postgresql --log-type runtimeLog
|
|
212
|
+
sealos database logs <pod-name> --db-type postgresql --log-type runtimeLog --log-path /path/to/log
|
|
186
213
|
```
|
|
187
214
|
|
|
188
215
|
Implementation: `src/commands/database/index.ts`
|
|
189
216
|
|
|
190
|
-
### Configuration
|
|
191
|
-
|
|
192
|
-
```bash
|
|
193
|
-
# List all config
|
|
194
|
-
sealos config list
|
|
195
|
-
|
|
196
|
-
# Get config value
|
|
197
|
-
sealos config get currentContext
|
|
198
|
-
|
|
199
|
-
# Set config value
|
|
200
|
-
sealos config set key value
|
|
201
|
-
```
|
|
202
|
-
|
|
203
217
|
## Environment Variables
|
|
204
218
|
|
|
205
|
-
- `
|
|
219
|
+
- `SEALOS_REGION`: Default Sealos region URL for auth and public provider endpoints
|
|
220
|
+
- `SEALOS_DATABASE_HOST`: Override database provider host for database commands
|
|
221
|
+
- `SEALOS_DEVBOX_HOST`: Override devbox provider host for devbox commands
|
|
206
222
|
- `DEBUG`: Enable debug mode for verbose error output
|
|
207
223
|
|
|
208
224
|
## TODO
|
|
209
225
|
|
|
210
|
-
|
|
226
|
+
Some command implementations still contain TODO comments where API integration is needed. Key areas:
|
|
211
227
|
|
|
212
|
-
1. **
|
|
213
|
-
2. **
|
|
214
|
-
3. **
|
|
215
|
-
4. **Devbox Management**: Connect devbox commands to actual Sealos API endpoints
|
|
216
|
-
5. **Interactive Prompts**: Use inquirer for confirmations
|
|
217
|
-
6. **YAML Support**: Add YAML output formatting
|
|
218
|
-
7. **Config Nesting**: Support nested config key access
|
|
228
|
+
1. **S3 Operations**: File upload/download with progress tracking
|
|
229
|
+
2. **Interactive Prompts**: Use inquirer for confirmations
|
|
230
|
+
3. **YAML Support**: Add YAML output formatting
|
|
219
231
|
|
|
220
232
|
## Best Practices Implemented
|
|
221
233
|
|
|
@@ -225,7 +237,6 @@ Most command implementations contain TODO comments indicating where API integrat
|
|
|
225
237
|
- Consistent error handling
|
|
226
238
|
- Multiple output formats
|
|
227
239
|
- Environment variable support
|
|
228
|
-
- Configuration file management
|
|
229
240
|
- Loading indicators for async operations
|
|
230
241
|
- Color-coded terminal output
|
|
231
242
|
|