sealos-cli 0.1.0 → 1.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 +77 -76
- package/dist/bin/cli.cjs +5120 -775
- package/dist/bin/cli.mjs +5120 -775
- package/dist/main.cjs +5116 -775
- package/dist/main.mjs +5120 -775
- package/package.json +6 -5
- package/src/commands/app/index.ts +5 -4
- package/src/commands/database/index.ts +12 -12
- package/src/commands/devbox/index.ts +676 -183
- package/src/commands/quota/index.ts +4 -3
- package/src/commands/s3/index.ts +5 -5
- package/src/commands/template/index.ts +107 -41
- 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 +19 -1
- package/src/lib/auth.ts +17 -8
- package/src/lib/errors.ts +1 -1
- package/src/lib/output.ts +5 -6
- package/src/main.ts +4 -11
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Sealos CLI
|
|
2
2
|
|
|
3
|
-
Official CLI tool for Sealos Cloud - Manage
|
|
3
|
+
Official CLI tool for Sealos Cloud - Manage auth, workspaces, devboxes, databases, and templates.
|
|
4
4
|
|
|
5
5
|
## Project Structure
|
|
6
6
|
|
|
@@ -18,21 +18,13 @@ src/
|
|
|
18
18
|
│ │ └── index.ts
|
|
19
19
|
│ ├── devbox/ # Devbox management
|
|
20
20
|
│ │ └── index.ts
|
|
21
|
-
│ ├── s3/ # S3 object storage
|
|
22
|
-
│ │ └── index.ts
|
|
23
21
|
│ ├── database/ # Database management
|
|
24
22
|
│ │ └── index.ts
|
|
25
23
|
│ ├── template/ # Template management
|
|
26
24
|
│ │ └── index.ts
|
|
27
|
-
│ ├── quota/ # Resource quotas
|
|
28
|
-
│ │ └── index.ts
|
|
29
|
-
│ ├── app/ # Application management
|
|
30
|
-
│ │ └── index.ts
|
|
31
|
-
│ └── config/ # CLI configuration
|
|
32
|
-
│ └── index.ts
|
|
33
25
|
├── lib/ # Shared libraries
|
|
34
|
-
│ ├── api.ts
|
|
35
|
-
│ ├──
|
|
26
|
+
│ ├── api-client.ts # OpenAPI client factories
|
|
27
|
+
│ ├── auth.ts # Sealos auth and kubeconfig headers
|
|
36
28
|
│ ├── errors.ts # Error handling
|
|
37
29
|
│ └── output.ts # Output formatting
|
|
38
30
|
├── types/ # TypeScript type definitions
|
|
@@ -42,22 +34,22 @@ src/
|
|
|
42
34
|
|
|
43
35
|
## Architecture
|
|
44
36
|
|
|
45
|
-
###
|
|
37
|
+
### Authentication (`lib/auth.ts`)
|
|
46
38
|
|
|
47
|
-
- Manages
|
|
48
|
-
-
|
|
49
|
-
-
|
|
39
|
+
- Manages Sealos auth state at `~/.sealos/auth.json`
|
|
40
|
+
- Stores current workspace kubeconfig at `~/.sealos/kubeconfig`
|
|
41
|
+
- Builds provider API headers with URL-encoded kubeconfig content
|
|
50
42
|
|
|
51
|
-
###
|
|
43
|
+
### OpenAPI Clients (`lib/api-client.ts`)
|
|
52
44
|
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
45
|
+
- Type-safe clients generated from `src/docs/*_openapi.json`
|
|
46
|
+
- Routes template calls to `template.<region>/api/v2alpha`
|
|
47
|
+
- Routes database calls to `dbprovider.<region>/api/v2alpha`
|
|
48
|
+
- Routes devbox calls to `devbox.<region>/api/v2alpha`
|
|
57
49
|
|
|
58
50
|
### Output Formatting (`lib/output.ts`)
|
|
59
51
|
|
|
60
|
-
-
|
|
52
|
+
- JSON and table output helpers for command responses
|
|
61
53
|
- Colored terminal output using chalk
|
|
62
54
|
- Loading spinners using ora
|
|
63
55
|
- Table formatting using table
|
|
@@ -104,118 +96,128 @@ npm test
|
|
|
104
96
|
### Authentication
|
|
105
97
|
|
|
106
98
|
```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)"
|
|
99
|
+
# Login in browser and exchange for regional token + kubeconfig automatically
|
|
100
|
+
sealos-cli login https://usw-1.sealos.io
|
|
112
101
|
|
|
113
102
|
# Check current user
|
|
114
|
-
sealos whoami
|
|
103
|
+
sealos-cli whoami
|
|
104
|
+
|
|
105
|
+
# Inspect auth and switch workspace
|
|
106
|
+
sealos-cli auth info
|
|
107
|
+
sealos-cli auth list
|
|
108
|
+
sealos-cli auth switch <workspace-id-or-team-name>
|
|
115
109
|
|
|
116
110
|
# Logout
|
|
117
|
-
sealos logout
|
|
111
|
+
sealos-cli logout
|
|
118
112
|
```
|
|
119
113
|
|
|
120
114
|
### Template Management
|
|
121
115
|
|
|
122
116
|
```bash
|
|
123
117
|
# Deploy from the catalog
|
|
124
|
-
sealos template deploy perplexica --name my-app --set OPENAI_API_KEY=xxx
|
|
118
|
+
sealos-cli template deploy perplexica --name my-app --set OPENAI_API_KEY=xxx
|
|
125
119
|
|
|
126
120
|
# Validate raw template YAML without creating resources
|
|
127
|
-
sealos template deploy --file ./template.yaml --dry-run
|
|
121
|
+
sealos-cli template deploy --file ./template.yaml --dry-run
|
|
128
122
|
```
|
|
129
123
|
|
|
130
124
|
### Workspace Management
|
|
131
125
|
|
|
132
126
|
```bash
|
|
133
127
|
# List workspaces
|
|
134
|
-
sealos workspace list
|
|
128
|
+
sealos-cli workspace list
|
|
135
129
|
|
|
136
130
|
# Switch workspace
|
|
137
|
-
sealos workspace switch production
|
|
131
|
+
sealos-cli workspace switch production
|
|
138
132
|
|
|
139
133
|
# Show current workspace
|
|
140
|
-
sealos workspace current
|
|
134
|
+
sealos-cli workspace current
|
|
141
135
|
```
|
|
142
136
|
|
|
143
137
|
### Devbox Management
|
|
144
138
|
|
|
145
139
|
```bash
|
|
146
140
|
# Create a devbox
|
|
147
|
-
sealos devbox create --name my-devbox --
|
|
141
|
+
sealos-cli devbox create --name my-devbox --runtime next.js --cpu 2c --memory 4g --port 3000:http:public
|
|
148
142
|
|
|
149
143
|
# List devboxes
|
|
150
|
-
sealos devbox list
|
|
151
|
-
sealos devbox list --output json
|
|
144
|
+
sealos-cli devbox list
|
|
145
|
+
sealos-cli devbox list --output json
|
|
152
146
|
|
|
153
147
|
# Get devbox details
|
|
154
|
-
sealos devbox get my-devbox
|
|
148
|
+
sealos-cli devbox get my-devbox
|
|
149
|
+
|
|
150
|
+
# Update resources or ports
|
|
151
|
+
sealos-cli devbox update my-devbox --cpu 4 --memory 8 --port portName=web,number=3000,protocol=http,isPublic=true
|
|
155
152
|
|
|
156
|
-
#
|
|
157
|
-
sealos devbox
|
|
153
|
+
# Start/Pause/Shutdown/Restart
|
|
154
|
+
sealos-cli devbox start my-devbox
|
|
155
|
+
sealos-cli devbox pause my-devbox
|
|
156
|
+
sealos-cli devbox shutdown my-devbox
|
|
157
|
+
sealos-cli devbox restart my-devbox
|
|
158
158
|
|
|
159
|
-
#
|
|
160
|
-
sealos devbox
|
|
161
|
-
sealos devbox
|
|
162
|
-
|
|
159
|
+
# Configure autostart and inspect monitor data
|
|
160
|
+
sealos-cli devbox autostart my-devbox --exec-command "npm start"
|
|
161
|
+
sealos-cli devbox monitor my-devbox --step 2m
|
|
162
|
+
|
|
163
|
+
# Templates, releases, and deployments
|
|
164
|
+
sealos-cli devbox templates
|
|
165
|
+
sealos-cli devbox releases list my-devbox
|
|
166
|
+
sealos-cli devbox releases create my-devbox --tag v1-0-0 --description "First release"
|
|
167
|
+
sealos-cli devbox releases deploy my-devbox v1-0-0
|
|
168
|
+
sealos-cli devbox deployments my-devbox
|
|
163
169
|
|
|
164
170
|
# Delete devbox
|
|
165
|
-
sealos devbox delete my-devbox
|
|
171
|
+
sealos-cli devbox delete my-devbox
|
|
166
172
|
```
|
|
167
173
|
|
|
174
|
+
Implementation: `src/commands/devbox/index.ts`, backed by `src/docs/devbox_openapi.json`.
|
|
175
|
+
|
|
168
176
|
### Database Management
|
|
169
177
|
|
|
170
178
|
```bash
|
|
171
179
|
# List databases
|
|
172
|
-
sealos database list
|
|
180
|
+
sealos-cli database list
|
|
173
181
|
|
|
174
182
|
# Get database details
|
|
175
|
-
sealos database get my-db
|
|
183
|
+
sealos-cli database get my-db
|
|
176
184
|
|
|
177
185
|
# Create a database
|
|
178
|
-
sealos database create postgresql --name my-db --cpu 1 --memory 2 --storage 5 --replicas 1
|
|
186
|
+
sealos-cli database create postgresql --name my-db --cpu 1 --memory 2 --storage 5 --replicas 1
|
|
179
187
|
|
|
180
188
|
# Show connection details
|
|
181
|
-
sealos database connection my-db
|
|
189
|
+
sealos-cli database connection my-db
|
|
182
190
|
|
|
183
191
|
# More commands
|
|
184
|
-
sealos database --help
|
|
185
|
-
sealos database <subcommand> --help
|
|
192
|
+
sealos-cli database --help
|
|
193
|
+
sealos-cli database <subcommand> --help
|
|
194
|
+
|
|
195
|
+
# Operational commands backed by src/docs/database_openapi.json
|
|
196
|
+
sealos-cli database update my-db --cpu 2 --memory 4
|
|
197
|
+
sealos-cli database start my-db
|
|
198
|
+
sealos-cli database pause my-db
|
|
199
|
+
sealos-cli database restart my-db
|
|
200
|
+
sealos-cli database backup my-db --name manual-backup
|
|
201
|
+
sealos-cli database backups my-db
|
|
202
|
+
sealos-cli database restore my-db --from manual-backup --name restored-db
|
|
203
|
+
sealos-cli database enable-public my-db
|
|
204
|
+
sealos-cli database disable-public my-db
|
|
205
|
+
sealos-cli database log-files <pod-name> --db-type postgresql --log-type runtimeLog
|
|
206
|
+
sealos-cli database logs <pod-name> --db-type postgresql --log-type runtimeLog --log-path /path/to/log
|
|
186
207
|
```
|
|
187
208
|
|
|
188
209
|
Implementation: `src/commands/database/index.ts`
|
|
189
210
|
|
|
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
211
|
## Environment Variables
|
|
204
212
|
|
|
205
|
-
- `
|
|
213
|
+
- `SEALOS_REGION`: Default Sealos region URL for auth and public provider endpoints
|
|
214
|
+
- `SEALOS_DATABASE_HOST`: Override database provider host for database commands
|
|
215
|
+
- `SEALOS_DEVBOX_HOST`: Override devbox provider host for devbox commands
|
|
206
216
|
- `DEBUG`: Enable debug mode for verbose error output
|
|
207
217
|
|
|
208
|
-
##
|
|
209
|
-
|
|
210
|
-
Most command implementations contain TODO comments indicating where API integration is needed. Key areas:
|
|
218
|
+
## v1 Scope
|
|
211
219
|
|
|
212
|
-
|
|
213
|
-
2. **API Integration**: Connect all commands to actual Sealos API endpoints
|
|
214
|
-
3. **S3 Operations**: File upload/download with progress tracking
|
|
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
|
|
220
|
+
The v1 command surface is limited to auth, workspace, template, database, and devbox operations. Future modules such as S3/object storage, quota inspection, and application management are intentionally not registered or documented as available commands.
|
|
219
221
|
|
|
220
222
|
## Best Practices Implemented
|
|
221
223
|
|
|
@@ -223,9 +225,8 @@ Most command implementations contain TODO comments indicating where API integrat
|
|
|
223
225
|
- TypeScript for type safety
|
|
224
226
|
- Shared utilities for common operations
|
|
225
227
|
- Consistent error handling
|
|
226
|
-
-
|
|
228
|
+
- JSON and table output formats
|
|
227
229
|
- Environment variable support
|
|
228
|
-
- Configuration file management
|
|
229
230
|
- Loading indicators for async operations
|
|
230
231
|
- Color-coded terminal output
|
|
231
232
|
|