@startanaicompany/cli 1.3.0 → 1.4.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 +85 -2
- package/README.md +103 -3
- package/bin/saac.js +22 -0
- package/git_auth.md +961 -0
- package/package.json +4 -3
- package/src/commands/create.js +53 -6
- package/src/commands/git.js +254 -0
- package/src/commands/init.js +160 -4
- package/src/commands/list.js +109 -4
- package/src/lib/oauth.js +205 -0
package/CLAUDE.md
CHANGED
|
@@ -313,11 +313,94 @@ saac update --restart on-failure
|
|
|
313
313
|
- Warns if tier limits were applied (resource caps)
|
|
314
314
|
- Reminds user to redeploy for changes to take effect
|
|
315
315
|
|
|
316
|
+
### Git OAuth Commands (NEW in 1.4.0)
|
|
317
|
+
|
|
318
|
+
The `git` command manages Git account OAuth connections, allowing users to deploy applications without providing tokens repeatedly.
|
|
319
|
+
|
|
320
|
+
**Subcommands:**
|
|
321
|
+
1. `saac git connect [host]` - Connect Git account via OAuth
|
|
322
|
+
2. `saac git list` - List all connected Git accounts
|
|
323
|
+
3. `saac git disconnect <host>` - Disconnect a Git account
|
|
324
|
+
|
|
325
|
+
**OAuth Flow:**
|
|
326
|
+
1. User runs `saac git connect` or creates app without token
|
|
327
|
+
2. Browser opens to OAuth authorization page
|
|
328
|
+
3. User authorizes on Git provider (Gitea, GitHub, GitLab)
|
|
329
|
+
4. CLI polls for completion every 2 seconds (max 5 minutes)
|
|
330
|
+
5. Connection saved on server (encrypted AES-256-GCM)
|
|
331
|
+
6. Future app creations use OAuth token automatically
|
|
332
|
+
|
|
333
|
+
**Usage Examples:**
|
|
334
|
+
```bash
|
|
335
|
+
# Connect to default Gitea instance
|
|
336
|
+
saac git connect git.startanaicompany.com
|
|
337
|
+
|
|
338
|
+
# Connect from repository URL
|
|
339
|
+
saac git connect git@git.startanaicompany.com:user/repo.git
|
|
340
|
+
|
|
341
|
+
# Interactive mode - select provider
|
|
342
|
+
saac git connect
|
|
343
|
+
|
|
344
|
+
# List connections
|
|
345
|
+
saac git list
|
|
346
|
+
|
|
347
|
+
# Disconnect
|
|
348
|
+
saac git disconnect git.startanaicompany.com
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**Integration with Create Command:**
|
|
352
|
+
- If Git account connected → Uses OAuth automatically
|
|
353
|
+
- If NOT connected and no `--git-token` → Prompts to connect
|
|
354
|
+
- If `--git-token` provided → Uses manual token (fallback)
|
|
355
|
+
|
|
356
|
+
**Benefits:**
|
|
357
|
+
- ✅ Connect once, deploy unlimited apps
|
|
358
|
+
- ✅ No need to copy/paste tokens repeatedly
|
|
359
|
+
- ✅ Tokens stored encrypted on server
|
|
360
|
+
- ✅ Auto-refresh for expired tokens
|
|
361
|
+
- ✅ Supports multiple Git providers
|
|
362
|
+
|
|
363
|
+
**Implementation Files:**
|
|
364
|
+
- `src/lib/oauth.js` - OAuth helper functions
|
|
365
|
+
- `src/commands/git.js` - Git command implementation
|
|
366
|
+
- Updated `src/commands/create.js` - OAuth integration
|
|
367
|
+
|
|
368
|
+
### Init Command Implementation
|
|
369
|
+
|
|
370
|
+
The `init` command links an existing SAAC application to the current directory.
|
|
371
|
+
|
|
372
|
+
**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.
|
|
373
|
+
|
|
374
|
+
**How It Works:**
|
|
375
|
+
1. Checks if directory is already initialized (has `.saac/config.json`)
|
|
376
|
+
2. Fetches all user applications from the API
|
|
377
|
+
3. Shows interactive list to select which application to link
|
|
378
|
+
4. Saves selected application info to `.saac/config.json`
|
|
379
|
+
|
|
380
|
+
**Usage:**
|
|
381
|
+
```bash
|
|
382
|
+
# Interactive mode - select from existing applications
|
|
383
|
+
cd my-project
|
|
384
|
+
saac init
|
|
385
|
+
# Select application from list
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
**Behavior:**
|
|
389
|
+
- If directory is already initialized, asks for confirmation to re-link
|
|
390
|
+
- If user has no applications, suggests using `saac create`
|
|
391
|
+
- After initialization, shows available commands (deploy, logs, status, update)
|
|
392
|
+
|
|
393
|
+
**Note:** The `init` command options (`-n, --name`, etc.) are currently not implemented. To create a new application, use `saac create` instead.
|
|
394
|
+
|
|
316
395
|
### Incomplete Commands
|
|
317
396
|
|
|
318
397
|
Several commands still need implementation:
|
|
319
|
-
- `src/commands/
|
|
320
|
-
- `src/commands/
|
|
398
|
+
- `src/commands/env.js` - Not implemented (partial stub)
|
|
399
|
+
- `src/commands/domain.js` - Not implemented (partial stub)
|
|
400
|
+
- `src/commands/logs.js` - Not implemented (partial stub)
|
|
401
|
+
- `src/commands/delete.js` - Not implemented (partial stub)
|
|
402
|
+
- `src/commands/list.js` - Not implemented (partial stub)
|
|
403
|
+
- `src/commands/whoami.js` - Not implemented (partial stub)
|
|
321
404
|
|
|
322
405
|
These need full implementation following the pattern from completed commands like `create.js` or `login.js`.
|
|
323
406
|
|
package/README.md
CHANGED
|
@@ -38,6 +38,58 @@ saac deploy
|
|
|
38
38
|
|
|
39
39
|
## Commands
|
|
40
40
|
|
|
41
|
+
## Git Authentication
|
|
42
|
+
|
|
43
|
+
SAAC CLI supports two methods for Git authentication:
|
|
44
|
+
|
|
45
|
+
### Method 1: OAuth (Recommended ✨ NEW in 1.4.0)
|
|
46
|
+
|
|
47
|
+
Connect your Git account once, deploy unlimited applications without providing tokens:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Connect Git account (interactive)
|
|
51
|
+
saac git connect
|
|
52
|
+
|
|
53
|
+
# Or specify host directly
|
|
54
|
+
saac git connect git.startanaicompany.com
|
|
55
|
+
|
|
56
|
+
# List connected accounts
|
|
57
|
+
saac git list
|
|
58
|
+
|
|
59
|
+
# Disconnect account
|
|
60
|
+
saac git disconnect git.startanaicompany.com
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Benefits:**
|
|
64
|
+
- ✅ Connect once, deploy unlimited apps
|
|
65
|
+
- ✅ No need to remember or copy tokens
|
|
66
|
+
- ✅ Tokens stored encrypted on server
|
|
67
|
+
- ✅ Supports Gitea, GitHub, and GitLab
|
|
68
|
+
|
|
69
|
+
**Creating apps with OAuth:**
|
|
70
|
+
```bash
|
|
71
|
+
# No token needed if OAuth connected!
|
|
72
|
+
saac create my-app -s myapp -r git@git.startanaicompany.com:user/repo.git
|
|
73
|
+
|
|
74
|
+
# CLI automatically uses your connected account
|
|
75
|
+
# ✅ Using connected account: username@git.startanaicompany.com
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Method 2: Manual Token (Fallback)
|
|
79
|
+
|
|
80
|
+
Provide Git API token for each application:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
saac create my-app \
|
|
84
|
+
-s myapp \
|
|
85
|
+
-r git@git.startanaicompany.com:user/repo.git \
|
|
86
|
+
-t your_gitea_token_here
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Note:** OAuth automatically takes precedence. Manual tokens are only used as fallback if no OAuth connection exists.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
41
93
|
### Authentication
|
|
42
94
|
|
|
43
95
|
#### `saac register`
|
|
@@ -102,16 +154,64 @@ saac sessions
|
|
|
102
154
|
|
|
103
155
|
Shows all devices where you're currently logged in with creation date, last used time, IP address, and expiration date.
|
|
104
156
|
|
|
157
|
+
#### `saac git connect [host]`
|
|
158
|
+
Connect a Git account via OAuth
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Interactive mode - select from providers
|
|
162
|
+
saac git connect
|
|
163
|
+
|
|
164
|
+
# Connect to specific host
|
|
165
|
+
saac git connect git.startanaicompany.com
|
|
166
|
+
|
|
167
|
+
# Connect from repository URL
|
|
168
|
+
saac git connect git@git.startanaicompany.com:user/repo.git
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**What happens:**
|
|
172
|
+
1. Browser opens to OAuth authorization page
|
|
173
|
+
2. You authorize on the Git provider
|
|
174
|
+
3. Connection saved (encrypted on server)
|
|
175
|
+
4. Future app creations use this connection automatically
|
|
176
|
+
|
|
177
|
+
#### `saac git list`
|
|
178
|
+
List all connected Git accounts
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
saac git list
|
|
182
|
+
saac git ls # Alias
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Shows host, username, provider, expiration date, and last used time.
|
|
186
|
+
|
|
187
|
+
#### `saac git disconnect <host>`
|
|
188
|
+
Disconnect a Git account
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
saac git disconnect git.startanaicompany.com
|
|
192
|
+
```
|
|
193
|
+
|
|
105
194
|
### Application Management
|
|
106
195
|
|
|
107
196
|
#### `saac init`
|
|
108
|
-
|
|
197
|
+
Link an existing SAAC application to the current directory
|
|
109
198
|
|
|
110
199
|
```bash
|
|
200
|
+
# Interactive mode - select from your applications
|
|
201
|
+
cd my-project
|
|
111
202
|
saac init
|
|
112
|
-
saac init --name myapp --subdomain myapp
|
|
113
203
|
```
|
|
114
204
|
|
|
205
|
+
**Use Case:** When you clone a Git repository or have an existing project and want to link it to a SAAC application.
|
|
206
|
+
|
|
207
|
+
**What it does:**
|
|
208
|
+
1. Shows all your SAAC applications
|
|
209
|
+
2. Let you select which one to link to this directory
|
|
210
|
+
3. Saves the link to `.saac/config.json`
|
|
211
|
+
4. Now you can use `saac deploy`, `saac logs`, etc.
|
|
212
|
+
|
|
213
|
+
**Note:** To create a new application, use `saac create` instead.
|
|
214
|
+
|
|
115
215
|
#### `saac create <name>`
|
|
116
216
|
Create a new application
|
|
117
217
|
|
|
@@ -133,7 +233,7 @@ saac create api -s api -r git@git... -t abc123 \
|
|
|
133
233
|
- `<name>` - Application name
|
|
134
234
|
- `-s, --subdomain <subdomain>` - Subdomain for your app
|
|
135
235
|
- `-r, --repository <url>` - Git repository URL (SSH format)
|
|
136
|
-
- `-t, --git-token <token>` - Git API token
|
|
236
|
+
- `-t, --git-token <token>` - Git API token (optional if OAuth connected)
|
|
137
237
|
|
|
138
238
|
**Optional:**
|
|
139
239
|
- `-b, --branch <branch>` - Git branch (default: master)
|
package/bin/saac.js
CHANGED
|
@@ -16,6 +16,7 @@ const verify = require('../src/commands/verify');
|
|
|
16
16
|
const logout = require('../src/commands/logout');
|
|
17
17
|
const logoutAll = require('../src/commands/logoutAll');
|
|
18
18
|
const sessions = require('../src/commands/sessions');
|
|
19
|
+
const git = require('../src/commands/git');
|
|
19
20
|
const init = require('../src/commands/init');
|
|
20
21
|
const create = require('../src/commands/create');
|
|
21
22
|
const update = require('../src/commands/update');
|
|
@@ -71,6 +72,27 @@ program
|
|
|
71
72
|
.description('List all active sessions')
|
|
72
73
|
.action(sessions);
|
|
73
74
|
|
|
75
|
+
// Git OAuth commands
|
|
76
|
+
const gitCommand = program
|
|
77
|
+
.command('git')
|
|
78
|
+
.description('Manage Git account connections (OAuth)');
|
|
79
|
+
|
|
80
|
+
gitCommand
|
|
81
|
+
.command('connect [host]')
|
|
82
|
+
.description('Connect a Git account via OAuth')
|
|
83
|
+
.action(git.connect);
|
|
84
|
+
|
|
85
|
+
gitCommand
|
|
86
|
+
.command('list')
|
|
87
|
+
.alias('ls')
|
|
88
|
+
.description('List connected Git accounts')
|
|
89
|
+
.action(git.list);
|
|
90
|
+
|
|
91
|
+
gitCommand
|
|
92
|
+
.command('disconnect <host>')
|
|
93
|
+
.description('Disconnect a Git account')
|
|
94
|
+
.action(git.disconnect);
|
|
95
|
+
|
|
74
96
|
// Application management
|
|
75
97
|
program
|
|
76
98
|
.command('init')
|