decoupled-cli 2.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 +416 -0
- package/bin/decoupled-cli +3 -0
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +386 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +84 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/content.d.ts +3 -0
- package/dist/commands/content.d.ts.map +1 -0
- package/dist/commands/content.js +199 -0
- package/dist/commands/content.js.map +1 -0
- package/dist/commands/download.d.ts +4 -0
- package/dist/commands/download.d.ts.map +1 -0
- package/dist/commands/download.js +127 -0
- package/dist/commands/download.js.map +1 -0
- package/dist/commands/health.d.ts +3 -0
- package/dist/commands/health.d.ts.map +1 -0
- package/dist/commands/health.js +28 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/org.d.ts +3 -0
- package/dist/commands/org.d.ts.map +1 -0
- package/dist/commands/org.js +73 -0
- package/dist/commands/org.js.map +1 -0
- package/dist/commands/spaces.d.ts +3 -0
- package/dist/commands/spaces.d.ts.map +1 -0
- package/dist/commands/spaces.js +613 -0
- package/dist/commands/spaces.js.map +1 -0
- package/dist/commands/tokens.d.ts +3 -0
- package/dist/commands/tokens.d.ts.map +1 -0
- package/dist/commands/tokens.js +90 -0
- package/dist/commands/tokens.js.map +1 -0
- package/dist/commands/usage.d.ts +3 -0
- package/dist/commands/usage.d.ts.map +1 -0
- package/dist/commands/usage.js +104 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api.d.ts +40 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +162 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/config.d.ts +63 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +317 -0
- package/dist/lib/config.js.map +1 -0
- package/examples/.cursorrules +189 -0
- package/examples/CLAUDE.md +1080 -0
- package/examples/GEMINI.md +1056 -0
- package/examples/content-import-sample.json +114 -0
- package/package.json +55 -0
package/README.md
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
# DrupalCloud CLI (decoupled-cli)
|
|
2
|
+
|
|
3
|
+
A command-line interface for managing DrupalCloud spaces, monitoring usage, and interacting with the DrupalCloud API using personal access tokens.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g decoupled-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Authentication
|
|
12
|
+
|
|
13
|
+
### Initial Setup
|
|
14
|
+
|
|
15
|
+
Before using the CLI, you need to authenticate with your DrupalCloud personal access token:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
decoupled-cli auth login
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This will:
|
|
22
|
+
1. Open your browser to the DrupalCloud authentication page
|
|
23
|
+
2. Allow you to sign in and create a personal access token
|
|
24
|
+
3. Display the token for you to copy
|
|
25
|
+
4. Prompt you to paste the token in the CLI
|
|
26
|
+
|
|
27
|
+
Alternatively, you can use manual token entry:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
decoupled-cli auth login --manual
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This will prompt you for:
|
|
34
|
+
- **API Base URL**: Your DrupalCloud instance URL (e.g., `https://app.drupalcloud.com` or `http://localhost:3333`)
|
|
35
|
+
- **Personal Access Token**: Your personal access token (format: `dc_tok_...`)
|
|
36
|
+
|
|
37
|
+
The CLI will verify the token and store the credentials securely in your system keychain or config directory.
|
|
38
|
+
|
|
39
|
+
### Token Management
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# View current authentication status
|
|
43
|
+
decoupled-cli auth status
|
|
44
|
+
|
|
45
|
+
# Switch to a different token/instance
|
|
46
|
+
decoupled-cli auth login --url https://staging.drupalcloud.com
|
|
47
|
+
|
|
48
|
+
# Logout (remove stored credentials)
|
|
49
|
+
decoupled-cli auth logout
|
|
50
|
+
|
|
51
|
+
# Test authentication
|
|
52
|
+
decoupled-cli auth test
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Note**: Token creation and management must be done through the web interface at `/organization/tokens` for security reasons.
|
|
56
|
+
|
|
57
|
+
### Configuration
|
|
58
|
+
|
|
59
|
+
The CLI stores configuration in `~/.decoupled-cli/config.json`:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"currentProfile": "default",
|
|
64
|
+
"profiles": {
|
|
65
|
+
"default": {
|
|
66
|
+
"baseUrl": "https://app.drupalcloud.com",
|
|
67
|
+
"tokenHash": "sha256_hash_of_token"
|
|
68
|
+
},
|
|
69
|
+
"staging": {
|
|
70
|
+
"baseUrl": "https://staging.drupalcloud.com",
|
|
71
|
+
"tokenHash": "sha256_hash_of_token"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Actual tokens are stored securely using the system keychain (macOS Keychain, Windows Credential Manager, or Linux Secret Service).
|
|
78
|
+
|
|
79
|
+
## Commands
|
|
80
|
+
|
|
81
|
+
### Spaces Management
|
|
82
|
+
|
|
83
|
+
#### List Spaces
|
|
84
|
+
```bash
|
|
85
|
+
# List all spaces
|
|
86
|
+
decoupled-cli spaces list
|
|
87
|
+
|
|
88
|
+
# List with additional details
|
|
89
|
+
decoupled-cli spaces list --detailed
|
|
90
|
+
|
|
91
|
+
# Filter by status
|
|
92
|
+
decoupled-cli spaces list --status active
|
|
93
|
+
decoupled-cli spaces list --status creating
|
|
94
|
+
decoupled-cli spaces list --archived
|
|
95
|
+
|
|
96
|
+
# Output as JSON
|
|
97
|
+
decoupled-cli spaces list --json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### Get Space Details
|
|
101
|
+
```bash
|
|
102
|
+
# Get space by ID
|
|
103
|
+
decoupled-cli spaces get 123
|
|
104
|
+
|
|
105
|
+
# Get space by name
|
|
106
|
+
decoupled-cli spaces get my-space-name
|
|
107
|
+
|
|
108
|
+
# Output as JSON
|
|
109
|
+
decoupled-cli spaces get 123 --json
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Create Space
|
|
113
|
+
```bash
|
|
114
|
+
# Create a new space
|
|
115
|
+
decoupled-cli spaces create "My New Space" --type pro --template dcloud
|
|
116
|
+
|
|
117
|
+
# Available templates: drupal, drupalx, next-drupal, drupalx-decoupled, dcloud
|
|
118
|
+
# Available types: starter, pro, premium
|
|
119
|
+
|
|
120
|
+
# With all options
|
|
121
|
+
decoupled-cli spaces create "E-commerce Site" \
|
|
122
|
+
--type premium \
|
|
123
|
+
--template drupalx-decoupled \
|
|
124
|
+
--description "New e-commerce platform"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### Update Space
|
|
128
|
+
```bash
|
|
129
|
+
# Update space name
|
|
130
|
+
decoupled-cli spaces update 123 --name "Updated Space Name"
|
|
131
|
+
|
|
132
|
+
# Update space type
|
|
133
|
+
decoupled-cli spaces update 123 --type premium
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### Clone Space
|
|
137
|
+
```bash
|
|
138
|
+
# Clone a space
|
|
139
|
+
decoupled-cli spaces clone 123 --name "Cloned Space"
|
|
140
|
+
|
|
141
|
+
# Clone with different type
|
|
142
|
+
decoupled-cli spaces clone 123 --name "Development Copy" --type starter
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### Archive/Unarchive Space
|
|
146
|
+
```bash
|
|
147
|
+
# Archive a space
|
|
148
|
+
decoupled-cli spaces archive 123
|
|
149
|
+
|
|
150
|
+
# Unarchive a space
|
|
151
|
+
decoupled-cli spaces unarchive 123
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
#### Delete Space
|
|
155
|
+
```bash
|
|
156
|
+
# Delete a space (with confirmation)
|
|
157
|
+
decoupled-cli spaces delete 123
|
|
158
|
+
|
|
159
|
+
# Force delete without confirmation
|
|
160
|
+
decoupled-cli spaces delete 123 --force
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
#### Space Operations
|
|
164
|
+
```bash
|
|
165
|
+
# Get Drupal one-time login link
|
|
166
|
+
decoupled-cli spaces login 123
|
|
167
|
+
|
|
168
|
+
# Check if space is ready
|
|
169
|
+
decoupled-cli spaces status 123
|
|
170
|
+
|
|
171
|
+
# Retry space creation (if failed)
|
|
172
|
+
decoupled-cli spaces retry 123
|
|
173
|
+
|
|
174
|
+
# Refresh space usage data
|
|
175
|
+
decoupled-cli spaces refresh-usage 123
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Usage Monitoring
|
|
179
|
+
|
|
180
|
+
#### Organization Usage
|
|
181
|
+
```bash
|
|
182
|
+
# Get overall organization usage
|
|
183
|
+
decoupled-cli usage
|
|
184
|
+
|
|
185
|
+
# Get usage with space breakdown
|
|
186
|
+
decoupled-cli usage --breakdown
|
|
187
|
+
|
|
188
|
+
# Output as JSON
|
|
189
|
+
decoupled-cli usage --json
|
|
190
|
+
|
|
191
|
+
# Get usage for specific date range
|
|
192
|
+
decoupled-cli usage --from 2025-01-01 --to 2025-01-31
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### Space-specific Usage
|
|
196
|
+
```bash
|
|
197
|
+
# Get usage for a specific space
|
|
198
|
+
decoupled-cli usage space 123
|
|
199
|
+
|
|
200
|
+
# Get usage history
|
|
201
|
+
decoupled-cli usage space 123 --history
|
|
202
|
+
|
|
203
|
+
# Export usage data
|
|
204
|
+
decoupled-cli usage export --format csv --output usage-report.csv
|
|
205
|
+
decoupled-cli usage export --format json --output usage-report.json
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Token Management
|
|
209
|
+
|
|
210
|
+
**Token management is not available through the CLI for security reasons.**
|
|
211
|
+
|
|
212
|
+
To create, update, or delete tokens:
|
|
213
|
+
1. Visit the web interface at `/organization/tokens`
|
|
214
|
+
2. Sign in with your account credentials
|
|
215
|
+
3. Use the token management interface
|
|
216
|
+
|
|
217
|
+
This ensures tokens can only be managed through secure, authenticated web sessions.
|
|
218
|
+
|
|
219
|
+
### Organization Management
|
|
220
|
+
|
|
221
|
+
#### Organization Info
|
|
222
|
+
```bash
|
|
223
|
+
# Get organization details
|
|
224
|
+
decoupled-cli org info
|
|
225
|
+
|
|
226
|
+
# Get organization members
|
|
227
|
+
decoupled-cli org members
|
|
228
|
+
|
|
229
|
+
# Get security settings
|
|
230
|
+
decoupled-cli org security
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### User Management
|
|
234
|
+
```bash
|
|
235
|
+
# List organization users
|
|
236
|
+
decoupled-cli users list
|
|
237
|
+
|
|
238
|
+
# Invite new user
|
|
239
|
+
decoupled-cli users invite user@example.com --role developer
|
|
240
|
+
|
|
241
|
+
# Update user role
|
|
242
|
+
decoupled-cli users update 789 --role admin
|
|
243
|
+
|
|
244
|
+
# Available roles: owner, admin, developer, member
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Utility Commands
|
|
248
|
+
|
|
249
|
+
#### Health Check
|
|
250
|
+
```bash
|
|
251
|
+
# Check API connectivity
|
|
252
|
+
decoupled-cli health
|
|
253
|
+
|
|
254
|
+
# Verbose health check
|
|
255
|
+
decoupled-cli health --verbose
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
#### Configuration
|
|
259
|
+
```bash
|
|
260
|
+
# Show current configuration
|
|
261
|
+
decoupled-cli config show
|
|
262
|
+
|
|
263
|
+
# Set configuration values
|
|
264
|
+
decoupled-cli config set output json
|
|
265
|
+
decoupled-cli config set timeout 30
|
|
266
|
+
|
|
267
|
+
# Reset configuration to defaults (with confirmation)
|
|
268
|
+
decoupled-cli config reset
|
|
269
|
+
|
|
270
|
+
# Reset configuration to defaults (skip confirmation)
|
|
271
|
+
decoupled-cli config reset --confirm
|
|
272
|
+
|
|
273
|
+
# Available settings:
|
|
274
|
+
# - output: table, json, yaml
|
|
275
|
+
# - timeout: API request timeout in seconds
|
|
276
|
+
# - color: true, false (enable/disable colored output)
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Global Options
|
|
280
|
+
|
|
281
|
+
All commands support these global options:
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
--profile <name> # Use specific profile instead of default
|
|
285
|
+
--json # Output response as JSON
|
|
286
|
+
--quiet # Suppress non-essential output
|
|
287
|
+
--verbose # Show detailed output and debug information
|
|
288
|
+
--no-color # Disable colored output
|
|
289
|
+
--timeout <seconds> # Override default request timeout
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Examples
|
|
293
|
+
|
|
294
|
+
### Daily Workflows
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
# Check overall status
|
|
298
|
+
decoupled-cli usage && decoupled-cli spaces list --status creating
|
|
299
|
+
|
|
300
|
+
# Create a development environment
|
|
301
|
+
decoupled-cli spaces create "Feature Branch Test" --type starter --template drupal
|
|
302
|
+
|
|
303
|
+
# Get login link for debugging
|
|
304
|
+
decoupled-cli spaces login 123
|
|
305
|
+
|
|
306
|
+
# Monitor space creation
|
|
307
|
+
watch decoupled-cli spaces status 123
|
|
308
|
+
|
|
309
|
+
# Export monthly usage report
|
|
310
|
+
decoupled-cli usage export --format csv --from 2025-01-01 --to 2025-01-31
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### CI/CD Integration
|
|
314
|
+
|
|
315
|
+
```bash
|
|
316
|
+
# Create a dedicated CI token through the web interface at /organization/tokens
|
|
317
|
+
# Then use it in CI scripts:
|
|
318
|
+
export DECOUPLED_TOKEN="dc_tok_..."
|
|
319
|
+
decoupled-cli spaces create "PR-${PR_NUMBER}" --template drupal --type starter
|
|
320
|
+
SPACE_ID=$(decoupled-cli spaces list --json | jq -r '.spaces[] | select(.name=="PR-'${PR_NUMBER}'") | .id')
|
|
321
|
+
decoupled-cli spaces status $SPACE_ID
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Monitoring Scripts
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
# Check for spaces stuck in 'creating' status
|
|
328
|
+
decoupled-cli spaces list --status creating --json | jq -r '.spaces[] | select((.createdAt | fromnow) > 3600) | .name'
|
|
329
|
+
|
|
330
|
+
# Get usage alerts
|
|
331
|
+
decoupled-cli usage --json | jq -r 'select(.usagePercentages.storage > 80) | "Storage usage: " + (.usagePercentages.storage | tostring) + "%"'
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
## Error Handling
|
|
335
|
+
|
|
336
|
+
The CLI returns appropriate exit codes:
|
|
337
|
+
- `0`: Success
|
|
338
|
+
- `1`: General error
|
|
339
|
+
- `2`: Authentication error
|
|
340
|
+
- `3`: Permission error
|
|
341
|
+
- `4`: Not found error
|
|
342
|
+
- `5`: Validation error
|
|
343
|
+
|
|
344
|
+
## Environment Variables
|
|
345
|
+
|
|
346
|
+
- `DECOUPLED_TOKEN`: Override stored token (useful for CI/CD)
|
|
347
|
+
- `DECOUPLED_BASE_URL`: Override base URL
|
|
348
|
+
- `DECOUPLED_PROFILE`: Use specific profile
|
|
349
|
+
- `DECOUPLED_TIMEOUT`: Request timeout in seconds
|
|
350
|
+
- `DECOUPLED_NO_COLOR`: Disable colored output
|
|
351
|
+
|
|
352
|
+
## Security
|
|
353
|
+
|
|
354
|
+
- Tokens are stored securely using the system keychain
|
|
355
|
+
- Sensitive data is never logged or displayed in plain text
|
|
356
|
+
- API requests use HTTPS with proper authentication headers
|
|
357
|
+
- Token permissions are validated on each request
|
|
358
|
+
|
|
359
|
+
## Troubleshooting
|
|
360
|
+
|
|
361
|
+
### Common Issues
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
# Token authentication failed
|
|
365
|
+
decoupled-cli auth test
|
|
366
|
+
decoupled-cli auth login
|
|
367
|
+
|
|
368
|
+
# API connectivity issues
|
|
369
|
+
decoupled-cli health --verbose
|
|
370
|
+
|
|
371
|
+
# Permission denied
|
|
372
|
+
decoupled-cli tokens list # Check your token permissions
|
|
373
|
+
|
|
374
|
+
# Timeout errors
|
|
375
|
+
decoupled-cli config set timeout 60
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### Debug Mode
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
# Enable debug output
|
|
382
|
+
decoupled-cli --verbose spaces list
|
|
383
|
+
|
|
384
|
+
# Check configuration
|
|
385
|
+
decoupled-cli config show
|
|
386
|
+
|
|
387
|
+
# Test token permissions
|
|
388
|
+
decoupled-cli auth test --permissions
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
## API Integration
|
|
392
|
+
|
|
393
|
+
The CLI directly uses the DrupalCloud API with these endpoints:
|
|
394
|
+
|
|
395
|
+
- `GET /api/spaces` - List spaces
|
|
396
|
+
- `POST /api/spaces` - Create space
|
|
397
|
+
- `GET /api/spaces/{id}` - Get space details
|
|
398
|
+
- `PATCH /api/spaces/{id}` - Update space
|
|
399
|
+
- `DELETE /api/spaces/{id}` - Delete space
|
|
400
|
+
- `POST /api/spaces/{id}/clone` - Clone space
|
|
401
|
+
- `POST /api/spaces/{id}/archive` - Archive space
|
|
402
|
+
- `POST /api/spaces/{id}/unarchive` - Unarchive space
|
|
403
|
+
- `GET /api/usage` - Get usage data
|
|
404
|
+
- Token management endpoints (web interface only)
|
|
405
|
+
|
|
406
|
+
## Contributing
|
|
407
|
+
|
|
408
|
+
The CLI is built with:
|
|
409
|
+
- Node.js/TypeScript
|
|
410
|
+
- Commander.js for CLI framework
|
|
411
|
+
- Axios for HTTP requests
|
|
412
|
+
- Keytar for secure credential storage
|
|
413
|
+
- Chalk for colored output
|
|
414
|
+
- CLI-table3 for formatted tables
|
|
415
|
+
|
|
416
|
+
For development and contribution guidelines, see the CLI repository.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2JpC,eAAO,MAAM,WAAW,SACmB,CAAC"}
|