@startanaicompany/cli 1.1.0 → 1.3.1
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/CLAUDE.md +145 -9
- package/README.md +75 -10
- package/bin/saac.js +59 -2
- package/create-application-update.md +759 -0
- package/package.json +2 -2
- package/src/commands/create.js +278 -4
- package/src/commands/init.js +160 -4
- package/src/commands/status.js +164 -4
- package/src/commands/update.js +284 -0
- package/src/lib/api.js +10 -0
- package/src/lib/config.js +8 -7
package/CLAUDE.md
CHANGED
|
@@ -33,11 +33,12 @@ saac login
|
|
|
33
33
|
|
|
34
34
|
The CLI maintains two separate configuration files:
|
|
35
35
|
|
|
36
|
-
1. **Global Config** (`~/.
|
|
37
|
-
- Managed by the `conf` package
|
|
38
|
-
- Stores user credentials (email, userId,
|
|
39
|
-
- Stores API URLs (wrapper API,
|
|
36
|
+
1. **Global Config** (`~/.config/startanaicompany/config.json`)
|
|
37
|
+
- Managed by the `conf` package with custom cwd path
|
|
38
|
+
- Stores user credentials (email, userId, sessionToken, expiresAt)
|
|
39
|
+
- Stores API URLs (wrapper API, Git server)
|
|
40
40
|
- Persists across all projects
|
|
41
|
+
- Note: Uses explicit path to avoid `-nodejs` suffix that Conf adds by default
|
|
41
42
|
|
|
42
43
|
2. **Project Config** (`.saac/config.json` in project directory)
|
|
43
44
|
- Manually managed via fs operations
|
|
@@ -207,14 +208,149 @@ The CLI now uses session tokens instead of storing permanent API keys:
|
|
|
207
208
|
- Middleware must accept both `X-Session-Token` and `X-API-Key` headers
|
|
208
209
|
- Session tokens expire after 1 year
|
|
209
210
|
|
|
211
|
+
### Create Command Implementation
|
|
212
|
+
|
|
213
|
+
The `create` command is fully implemented with ALL backend features:
|
|
214
|
+
|
|
215
|
+
**Required Options:**
|
|
216
|
+
- `-s, --subdomain` - Subdomain for the application
|
|
217
|
+
- `-r, --repository` - Git repository URL (SSH format)
|
|
218
|
+
- `-t, --git-token` - Git API token for repository access
|
|
219
|
+
|
|
220
|
+
**Optional Basic Configuration:**
|
|
221
|
+
- `-b, --branch` - Git branch (default: master)
|
|
222
|
+
- `-d, --domain-suffix` - Domain suffix (default: startanaicompany.com)
|
|
223
|
+
- `-p, --port` - Port to expose (default: 3000)
|
|
224
|
+
|
|
225
|
+
**Build Pack Options:**
|
|
226
|
+
- `--build-pack` - Build system: dockercompose, nixpacks, dockerfile, static
|
|
227
|
+
- `--install-cmd` - Custom install command (e.g., "pnpm install")
|
|
228
|
+
- `--build-cmd` - Custom build command (e.g., "npm run build")
|
|
229
|
+
- `--start-cmd` - Custom start command (e.g., "node server.js")
|
|
230
|
+
- `--pre-deploy-cmd` - Pre-deployment hook (e.g., "npm run migrate")
|
|
231
|
+
- `--post-deploy-cmd` - Post-deployment hook (e.g., "npm run seed")
|
|
232
|
+
|
|
233
|
+
**Resource Limits:**
|
|
234
|
+
- `--cpu-limit` - CPU limit (e.g., "1", "2.5")
|
|
235
|
+
- `--memory-limit` - Memory limit (e.g., "512M", "2G")
|
|
236
|
+
- Note: Free tier limited to 1 vCPU, 1024M RAM
|
|
237
|
+
|
|
238
|
+
**Health Checks:**
|
|
239
|
+
- `--health-check` - Enable health checks
|
|
240
|
+
- `--health-path` - Health check endpoint (default: /health)
|
|
241
|
+
- `--health-interval` - Check interval in seconds
|
|
242
|
+
- `--health-timeout` - Check timeout in seconds
|
|
243
|
+
- `--health-retries` - Number of retries (1-10)
|
|
244
|
+
|
|
245
|
+
**Environment Variables:**
|
|
246
|
+
- `--env KEY=VALUE` - Can be used multiple times (max 50 variables)
|
|
247
|
+
|
|
248
|
+
**Examples:**
|
|
249
|
+
```bash
|
|
250
|
+
# Basic application
|
|
251
|
+
saac create my-app -s myapp -r git@git.startanaicompany.com:user/repo.git -t abc123
|
|
252
|
+
|
|
253
|
+
# With build pack and custom port
|
|
254
|
+
saac create api -s api -r git@git... -t abc123 --build-pack nixpacks --port 8080
|
|
255
|
+
|
|
256
|
+
# With health checks and pre-deployment migration
|
|
257
|
+
saac create web -s web -r git@git... -t abc123 \
|
|
258
|
+
--health-check \
|
|
259
|
+
--pre-deploy-cmd "npm run migrate" \
|
|
260
|
+
--env NODE_ENV=production \
|
|
261
|
+
--env LOG_LEVEL=info
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Implementation Details:**
|
|
265
|
+
- Validates all required fields before API call
|
|
266
|
+
- Shows configuration summary before creation
|
|
267
|
+
- Handles tier-based quota errors (403)
|
|
268
|
+
- Handles validation errors (400) with field-specific messages
|
|
269
|
+
- Saves project config to `.saac/config.json` after successful creation
|
|
270
|
+
- Displays next steps and useful commands
|
|
271
|
+
|
|
272
|
+
### Update Command Implementation
|
|
273
|
+
|
|
274
|
+
The `update` command allows modifying application configuration after deployment using `PATCH /api/v1/applications/:uuid`.
|
|
275
|
+
|
|
276
|
+
**All Configuration Fields Can Be Updated:**
|
|
277
|
+
- Basic: name, branch, port
|
|
278
|
+
- Build pack and custom commands
|
|
279
|
+
- Resource limits (CPU, memory) - capped at tier limits
|
|
280
|
+
- Health checks (enable/disable, path, interval, timeout, retries)
|
|
281
|
+
- Restart policy (always, on-failure, unless-stopped, no)
|
|
282
|
+
- Environment variables
|
|
283
|
+
|
|
284
|
+
**Important Notes:**
|
|
285
|
+
- Only fields you specify will be updated (partial updates)
|
|
286
|
+
- Resource limits are enforced by user tier (free: 1 vCPU, 1GB RAM)
|
|
287
|
+
- Changes require redeployment to take effect: `saac deploy`
|
|
288
|
+
- Requires project config (`.saac/config.json`)
|
|
289
|
+
|
|
290
|
+
**Examples:**
|
|
291
|
+
```bash
|
|
292
|
+
# Update port and enable health checks
|
|
293
|
+
saac update --port 8080 --health-check --health-path /api/health
|
|
294
|
+
|
|
295
|
+
# Switch to Nixpacks and update resource limits
|
|
296
|
+
saac update --build-pack nixpacks --cpu-limit 2 --memory-limit 2G
|
|
297
|
+
|
|
298
|
+
# Update custom commands
|
|
299
|
+
saac update --pre-deploy-cmd "npm run migrate" --start-cmd "node dist/server.js"
|
|
300
|
+
|
|
301
|
+
# Disable health checks
|
|
302
|
+
saac update --no-health-check
|
|
303
|
+
|
|
304
|
+
# Update environment variables
|
|
305
|
+
saac update --env NODE_ENV=production --env LOG_LEVEL=debug
|
|
306
|
+
|
|
307
|
+
# Change restart policy
|
|
308
|
+
saac update --restart on-failure
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
**Response Behavior:**
|
|
312
|
+
- Shows which fields were updated
|
|
313
|
+
- Warns if tier limits were applied (resource caps)
|
|
314
|
+
- Reminds user to redeploy for changes to take effect
|
|
315
|
+
|
|
316
|
+
### Init Command Implementation
|
|
317
|
+
|
|
318
|
+
The `init` command links an existing SAAC application to the current directory.
|
|
319
|
+
|
|
320
|
+
**Primary Use Case:** When you clone a Git repository or have an existing project and want to link it to a SAAC application for deployment.
|
|
321
|
+
|
|
322
|
+
**How It Works:**
|
|
323
|
+
1. Checks if directory is already initialized (has `.saac/config.json`)
|
|
324
|
+
2. Fetches all user applications from the API
|
|
325
|
+
3. Shows interactive list to select which application to link
|
|
326
|
+
4. Saves selected application info to `.saac/config.json`
|
|
327
|
+
|
|
328
|
+
**Usage:**
|
|
329
|
+
```bash
|
|
330
|
+
# Interactive mode - select from existing applications
|
|
331
|
+
cd my-project
|
|
332
|
+
saac init
|
|
333
|
+
# Select application from list
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**Behavior:**
|
|
337
|
+
- If directory is already initialized, asks for confirmation to re-link
|
|
338
|
+
- If user has no applications, suggests using `saac create`
|
|
339
|
+
- After initialization, shows available commands (deploy, logs, status, update)
|
|
340
|
+
|
|
341
|
+
**Note:** The `init` command options (`-n, --name`, etc.) are currently not implemented. To create a new application, use `saac create` instead.
|
|
342
|
+
|
|
210
343
|
### Incomplete Commands
|
|
211
344
|
|
|
212
|
-
Several commands
|
|
213
|
-
- `src/commands/
|
|
214
|
-
- `src/commands/
|
|
215
|
-
- `src/commands/
|
|
345
|
+
Several commands still need implementation:
|
|
346
|
+
- `src/commands/env.js` - Not implemented (partial stub)
|
|
347
|
+
- `src/commands/domain.js` - Not implemented (partial stub)
|
|
348
|
+
- `src/commands/logs.js` - Not implemented (partial stub)
|
|
349
|
+
- `src/commands/delete.js` - Not implemented (partial stub)
|
|
350
|
+
- `src/commands/list.js` - Not implemented (partial stub)
|
|
351
|
+
- `src/commands/whoami.js` - Not implemented (partial stub)
|
|
216
352
|
|
|
217
|
-
These need full implementation following the pattern from completed commands like `
|
|
353
|
+
These need full implementation following the pattern from completed commands like `create.js` or `login.js`.
|
|
218
354
|
|
|
219
355
|
**Implementation Pattern for New Commands:**
|
|
220
356
|
1. Require flags, no interactive prompts
|
package/README.md
CHANGED
|
@@ -105,26 +105,91 @@ Shows all devices where you're currently logged in with creation date, last used
|
|
|
105
105
|
### Application Management
|
|
106
106
|
|
|
107
107
|
#### `saac init`
|
|
108
|
-
|
|
108
|
+
Link an existing SAAC application to the current directory
|
|
109
109
|
|
|
110
110
|
```bash
|
|
111
|
+
# Interactive mode - select from your applications
|
|
112
|
+
cd my-project
|
|
111
113
|
saac init
|
|
112
|
-
saac init --name myapp --subdomain myapp
|
|
113
114
|
```
|
|
114
115
|
|
|
115
|
-
|
|
116
|
+
**Use Case:** When you clone a Git repository or have an existing project and want to link it to a SAAC application.
|
|
117
|
+
|
|
118
|
+
**What it does:**
|
|
119
|
+
1. Shows all your SAAC applications
|
|
120
|
+
2. Let you select which one to link to this directory
|
|
121
|
+
3. Saves the link to `.saac/config.json`
|
|
122
|
+
4. Now you can use `saac deploy`, `saac logs`, etc.
|
|
123
|
+
|
|
124
|
+
**Note:** To create a new application, use `saac create` instead.
|
|
125
|
+
|
|
126
|
+
#### `saac create <name>`
|
|
116
127
|
Create a new application
|
|
117
128
|
|
|
118
129
|
```bash
|
|
119
|
-
|
|
120
|
-
saac create my-
|
|
130
|
+
# Basic application
|
|
131
|
+
saac create my-app -s myapp -r git@git.startanaicompany.com:user/repo.git -t abc123
|
|
132
|
+
|
|
133
|
+
# Advanced with health checks and migration
|
|
134
|
+
saac create api -s api -r git@git... -t abc123 \
|
|
135
|
+
--build-pack nixpacks \
|
|
136
|
+
--port 8080 \
|
|
137
|
+
--pre-deploy-cmd "npm run migrate" \
|
|
138
|
+
--health-check \
|
|
139
|
+
--health-path /api/health \
|
|
140
|
+
--env NODE_ENV=production
|
|
121
141
|
```
|
|
122
142
|
|
|
123
|
-
|
|
124
|
-
-
|
|
125
|
-
- `-
|
|
126
|
-
- `-r, --repository <url>` - Git repository URL
|
|
143
|
+
**Required:**
|
|
144
|
+
- `<name>` - Application name
|
|
145
|
+
- `-s, --subdomain <subdomain>` - Subdomain for your app
|
|
146
|
+
- `-r, --repository <url>` - Git repository URL (SSH format)
|
|
147
|
+
- `-t, --git-token <token>` - Git API token
|
|
148
|
+
|
|
149
|
+
**Optional:**
|
|
127
150
|
- `-b, --branch <branch>` - Git branch (default: master)
|
|
151
|
+
- `-d, --domain-suffix <suffix>` - Domain suffix (default: startanaicompany.com)
|
|
152
|
+
- `-p, --port <port>` - Port to expose (default: 3000)
|
|
153
|
+
- `--build-pack <pack>` - Build pack: dockercompose, nixpacks, dockerfile, static
|
|
154
|
+
- `--install-cmd <command>` - Install command
|
|
155
|
+
- `--build-cmd <command>` - Build command
|
|
156
|
+
- `--start-cmd <command>` - Start command
|
|
157
|
+
- `--pre-deploy-cmd <command>` - Pre-deployment command (e.g., migrations)
|
|
158
|
+
- `--post-deploy-cmd <command>` - Post-deployment command (e.g., seeding)
|
|
159
|
+
- `--cpu-limit <limit>` - CPU limit (e.g., "1", "2.5")
|
|
160
|
+
- `--memory-limit <limit>` - Memory limit (e.g., "512M", "2G")
|
|
161
|
+
- `--health-check` - Enable health checks
|
|
162
|
+
- `--health-path <path>` - Health check path (default: /health)
|
|
163
|
+
- `--health-interval <seconds>` - Health check interval in seconds
|
|
164
|
+
- `--health-timeout <seconds>` - Health check timeout in seconds
|
|
165
|
+
- `--health-retries <count>` - Health check retries (1-10)
|
|
166
|
+
- `--env <KEY=VALUE>` - Environment variable (can be used multiple times)
|
|
167
|
+
|
|
168
|
+
**Note:** Free tier limited to 1 vCPU, 1024M RAM
|
|
169
|
+
|
|
170
|
+
#### `saac update`
|
|
171
|
+
Update application configuration
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
# Update port and enable health checks
|
|
175
|
+
saac update --port 8080 --health-check --health-path /api/health
|
|
176
|
+
|
|
177
|
+
# Switch to Nixpacks and update resource limits
|
|
178
|
+
saac update --build-pack nixpacks --cpu-limit 2 --memory-limit 2G
|
|
179
|
+
|
|
180
|
+
# Update custom commands
|
|
181
|
+
saac update --pre-deploy-cmd "npm run migrate"
|
|
182
|
+
|
|
183
|
+
# Disable health checks
|
|
184
|
+
saac update --no-health-check
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Options:** All options from `create` command can be updated individually
|
|
188
|
+
|
|
189
|
+
**Important:** Configuration changes require redeployment to take effect:
|
|
190
|
+
```bash
|
|
191
|
+
saac deploy
|
|
192
|
+
```
|
|
128
193
|
|
|
129
194
|
#### `saac deploy`
|
|
130
195
|
Deploy your application
|
|
@@ -223,7 +288,7 @@ saac rm # Alias
|
|
|
223
288
|
|
|
224
289
|
### Global Configuration
|
|
225
290
|
|
|
226
|
-
Stored in `~/.
|
|
291
|
+
Stored in `~/.config/startanaicompany/config.json`:
|
|
227
292
|
|
|
228
293
|
```json
|
|
229
294
|
{
|
package/bin/saac.js
CHANGED
|
@@ -18,6 +18,7 @@ const logoutAll = require('../src/commands/logoutAll');
|
|
|
18
18
|
const sessions = require('../src/commands/sessions');
|
|
19
19
|
const init = require('../src/commands/init');
|
|
20
20
|
const create = require('../src/commands/create');
|
|
21
|
+
const update = require('../src/commands/update');
|
|
21
22
|
const deploy = require('../src/commands/deploy');
|
|
22
23
|
const logs = require('../src/commands/logs');
|
|
23
24
|
const env = require('../src/commands/env');
|
|
@@ -83,12 +84,68 @@ program
|
|
|
83
84
|
program
|
|
84
85
|
.command('create [name]')
|
|
85
86
|
.description('Create a new application')
|
|
87
|
+
// Required options
|
|
86
88
|
.option('-s, --subdomain <subdomain>', 'Subdomain')
|
|
87
|
-
.option('-
|
|
88
|
-
.option('-
|
|
89
|
+
.option('-r, --repository <url>', 'Git repository URL (SSH format)')
|
|
90
|
+
.option('-t, --git-token <token>', 'Git API token')
|
|
91
|
+
// Basic options
|
|
89
92
|
.option('-b, --branch <branch>', 'Git branch', 'master')
|
|
93
|
+
.option('-d, --domain-suffix <suffix>', 'Domain suffix', 'startanaicompany.com')
|
|
94
|
+
.option('-p, --port <port>', 'Port to expose (default: 3000)')
|
|
95
|
+
// Build configuration
|
|
96
|
+
.option('--build-pack <pack>', 'Build pack: dockercompose, nixpacks, dockerfile, static')
|
|
97
|
+
.option('--install-cmd <command>', 'Install command')
|
|
98
|
+
.option('--build-cmd <command>', 'Build command')
|
|
99
|
+
.option('--start-cmd <command>', 'Start command')
|
|
100
|
+
.option('--pre-deploy-cmd <command>', 'Pre-deployment command')
|
|
101
|
+
.option('--post-deploy-cmd <command>', 'Post-deployment command')
|
|
102
|
+
// Resource limits
|
|
103
|
+
.option('--cpu-limit <limit>', 'CPU limit (e.g., "1", "2.5")')
|
|
104
|
+
.option('--memory-limit <limit>', 'Memory limit (e.g., "512M", "2G")')
|
|
105
|
+
// Health checks
|
|
106
|
+
.option('--health-check', 'Enable health checks')
|
|
107
|
+
.option('--health-path <path>', 'Health check path')
|
|
108
|
+
.option('--health-interval <seconds>', 'Health check interval in seconds')
|
|
109
|
+
.option('--health-timeout <seconds>', 'Health check timeout in seconds')
|
|
110
|
+
.option('--health-retries <count>', 'Health check retries (1-10)')
|
|
111
|
+
// Environment variables
|
|
112
|
+
.option('--env <KEY=VALUE>', 'Environment variable (can be used multiple times)', (val, prev) => {
|
|
113
|
+
return prev ? [...prev, val] : [val];
|
|
114
|
+
}, [])
|
|
90
115
|
.action(create);
|
|
91
116
|
|
|
117
|
+
program
|
|
118
|
+
.command('update')
|
|
119
|
+
.description('Update application configuration')
|
|
120
|
+
// Basic options
|
|
121
|
+
.option('-n, --name <name>', 'Application name')
|
|
122
|
+
.option('-b, --branch <branch>', 'Git branch')
|
|
123
|
+
.option('-p, --port <port>', 'Port to expose')
|
|
124
|
+
// Build configuration
|
|
125
|
+
.option('--build-pack <pack>', 'Build pack: dockercompose, nixpacks, dockerfile, static')
|
|
126
|
+
.option('--install-cmd <command>', 'Install command')
|
|
127
|
+
.option('--build-cmd <command>', 'Build command')
|
|
128
|
+
.option('--start-cmd <command>', 'Start command')
|
|
129
|
+
.option('--pre-deploy-cmd <command>', 'Pre-deployment command')
|
|
130
|
+
.option('--post-deploy-cmd <command>', 'Post-deployment command')
|
|
131
|
+
// Resource limits
|
|
132
|
+
.option('--cpu-limit <limit>', 'CPU limit (e.g., "1", "2.5")')
|
|
133
|
+
.option('--memory-limit <limit>', 'Memory limit (e.g., "512M", "2G")')
|
|
134
|
+
// Health checks
|
|
135
|
+
.option('--health-check', 'Enable health checks')
|
|
136
|
+
.option('--no-health-check', 'Disable health checks')
|
|
137
|
+
.option('--health-path <path>', 'Health check path')
|
|
138
|
+
.option('--health-interval <seconds>', 'Health check interval in seconds')
|
|
139
|
+
.option('--health-timeout <seconds>', 'Health check timeout in seconds')
|
|
140
|
+
.option('--health-retries <count>', 'Health check retries (1-10)')
|
|
141
|
+
// Restart policy
|
|
142
|
+
.option('--restart <policy>', 'Restart policy: always, on-failure, unless-stopped, no')
|
|
143
|
+
// Environment variables
|
|
144
|
+
.option('--env <KEY=VALUE>', 'Environment variable (can be used multiple times)', (val, prev) => {
|
|
145
|
+
return prev ? [...prev, val] : [val];
|
|
146
|
+
}, [])
|
|
147
|
+
.action(update);
|
|
148
|
+
|
|
92
149
|
program
|
|
93
150
|
.command('deploy')
|
|
94
151
|
.description('Deploy current application')
|