@startanaicompany/cli 1.1.0 → 1.3.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/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** (`~/.saac/config.json`)
37
- - Managed by the `conf` package
38
- - Stores user credentials (email, userId, apiKey)
39
- - Stores API URLs (wrapper API, Gitea)
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,118 @@ 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
+
210
316
  ### Incomplete Commands
211
317
 
212
- Several commands are stubbed with TODO comments:
213
- - `src/commands/create.js` - Not implemented
318
+ Several commands still need implementation:
214
319
  - `src/commands/init.js` - Not implemented
215
320
  - `src/commands/env.js` - Not implemented
216
321
 
217
- These need full implementation following the pattern from completed commands like `deploy.js` or `login.js`.
322
+ These need full implementation following the pattern from completed commands like `create.js` or `login.js`.
218
323
 
219
324
  **Implementation Pattern for New Commands:**
220
325
  1. Require flags, no interactive prompts
package/README.md CHANGED
@@ -112,19 +112,73 @@ saac init
112
112
  saac init --name myapp --subdomain myapp
113
113
  ```
114
114
 
115
- #### `saac create [name]`
115
+ #### `saac create <name>`
116
116
  Create a new application
117
117
 
118
118
  ```bash
119
- saac create
120
- saac create my-site --subdomain mysite
119
+ # Basic application
120
+ saac create my-app -s myapp -r git@git.startanaicompany.com:user/repo.git -t abc123
121
+
122
+ # Advanced with health checks and migration
123
+ saac create api -s api -r git@git... -t abc123 \
124
+ --build-pack nixpacks \
125
+ --port 8080 \
126
+ --pre-deploy-cmd "npm run migrate" \
127
+ --health-check \
128
+ --health-path /api/health \
129
+ --env NODE_ENV=production
121
130
  ```
122
131
 
123
- Options:
124
- - `-s, --subdomain <subdomain>` - Subdomain for your site
125
- - `-d, --domain-suffix <suffix>` - Domain suffix (default: startanaicompany.com)
126
- - `-r, --repository <url>` - Git repository URL
132
+ **Required:**
133
+ - `<name>` - Application name
134
+ - `-s, --subdomain <subdomain>` - Subdomain for your app
135
+ - `-r, --repository <url>` - Git repository URL (SSH format)
136
+ - `-t, --git-token <token>` - Git API token
137
+
138
+ **Optional:**
127
139
  - `-b, --branch <branch>` - Git branch (default: master)
140
+ - `-d, --domain-suffix <suffix>` - Domain suffix (default: startanaicompany.com)
141
+ - `-p, --port <port>` - Port to expose (default: 3000)
142
+ - `--build-pack <pack>` - Build pack: dockercompose, nixpacks, dockerfile, static
143
+ - `--install-cmd <command>` - Install command
144
+ - `--build-cmd <command>` - Build command
145
+ - `--start-cmd <command>` - Start command
146
+ - `--pre-deploy-cmd <command>` - Pre-deployment command (e.g., migrations)
147
+ - `--post-deploy-cmd <command>` - Post-deployment command (e.g., seeding)
148
+ - `--cpu-limit <limit>` - CPU limit (e.g., "1", "2.5")
149
+ - `--memory-limit <limit>` - Memory limit (e.g., "512M", "2G")
150
+ - `--health-check` - Enable health checks
151
+ - `--health-path <path>` - Health check path (default: /health)
152
+ - `--health-interval <seconds>` - Health check interval in seconds
153
+ - `--health-timeout <seconds>` - Health check timeout in seconds
154
+ - `--health-retries <count>` - Health check retries (1-10)
155
+ - `--env <KEY=VALUE>` - Environment variable (can be used multiple times)
156
+
157
+ **Note:** Free tier limited to 1 vCPU, 1024M RAM
158
+
159
+ #### `saac update`
160
+ Update application configuration
161
+
162
+ ```bash
163
+ # Update port and enable health checks
164
+ saac update --port 8080 --health-check --health-path /api/health
165
+
166
+ # Switch to Nixpacks and update resource limits
167
+ saac update --build-pack nixpacks --cpu-limit 2 --memory-limit 2G
168
+
169
+ # Update custom commands
170
+ saac update --pre-deploy-cmd "npm run migrate"
171
+
172
+ # Disable health checks
173
+ saac update --no-health-check
174
+ ```
175
+
176
+ **Options:** All options from `create` command can be updated individually
177
+
178
+ **Important:** Configuration changes require redeployment to take effect:
179
+ ```bash
180
+ saac deploy
181
+ ```
128
182
 
129
183
  #### `saac deploy`
130
184
  Deploy your application
@@ -223,7 +277,7 @@ saac rm # Alias
223
277
 
224
278
  ### Global Configuration
225
279
 
226
- Stored in `~/.saac/config.json`:
280
+ Stored in `~/.config/startanaicompany/config.json`:
227
281
 
228
282
  ```json
229
283
  {
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('-d, --domain-suffix <suffix>', 'Domain suffix', 'startanaicompany.com')
88
- .option('-r, --repository <url>', 'Git repository URL')
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')