Skip to content

Commit 86a92f9

Browse files
naman485NamanclaudeBhautikChudasama
authored
feat: CLI expansion — init, env, status, open, scale, templates + --output json (#13)
* feat: add init, env, status, open, scale, templates commands + --output json + logs --follow + domains improvements New commands: - `createos init` — link local directory to a CreateOS project via .createos.json - `createos env set/list/rm/pull/push` — full environment variable management - `createos status` — consolidated project health dashboard - `createos open` — open project URL or dashboard in browser - `createos scale` — adjust replicas, CPU, and memory - `createos templates list/info/use` — browse and scaffold from project templates Enhancements: - `--output json` / `-o json` global flag for machine-readable output (auto-detects non-TTY) - `createos deployments logs --follow` / `-f` for real-time log tailing - `createos domains add` now shows DNS setup instructions - `createos domains list` now shows status icons (✓/⏳/✗) - `createos domains verify` new subcommand with DNS polling Infrastructure: - internal/config/project.go — .createos.json project linking with directory walk-up - internal/output/render.go — JSON/table output format helper - internal/browser/browser.go — cross-platform browser opening (extracted from oauth) - 8 new API methods in internal/api/methods.go Bug fixes: - Fixed wrong command paths in domains delete/refresh error messages - Signal handlers properly cleaned up in follow/verify polling loops Closes #3, #4, #5, #6, #7, #8, #9, #10, #11, #12 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: init impl * fix: added domain, and env stuff * feat: fix commands * chore: fix lint * docs: updated README * chore: oauth facility * feat: added cj, and missing command * feat: added oauth delete command * feat: added oauth delete command * chore: fix lint * fix: resolve 3 CRITICAL panics + 3 HIGH security vulnerabilities CRITICAL fixes: - Guard all `d.ID[:8]` with length checks to prevent panic on short IDs (cmd/deployments/helpers.go, cmd/open/open.go) - Guard `(*d.EnvironmentID)[:8]` with length check (cmd/domains/domains_list.go) - Fix PaginatedResponse.Pagination nesting — was always zero-valued because Pagination was a sibling of Data instead of nested inside it. Skills catalog TUI pagination (total count, hasNextPage) was silently broken. Security fixes: - Validate --api-url is HTTPS to prevent credential theft via attacker-controlled server (localhost/127.0.0.1 allowed for development) - Reject absolute paths and '..' traversal in env pull/push --file flag to prevent writing to or reading from arbitrary filesystem locations - Sanitize template name with filepath.Base() when used as directory name to prevent path traversal via malicious template names Closes #14 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * chore: removed unwnated clo * fix: lint --------- Co-authored-by: Naman <naman307@Namans-MacBook-Pro.local> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Bhautik <bhautikrchudasama@gmail.com>
1 parent 49c8f13 commit 86a92f9

78 files changed

Lines changed: 4332 additions & 457 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
.claude
2+
.createos.json
3+
.env.*

README.md

Lines changed: 138 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ Or run `createos login` interactively and select "Sign in with API token" when p
5454
createos whoami
5555
```
5656

57-
**3. Explore commands**
57+
**3. Link your project**
58+
59+
```bash
60+
createos init
61+
```
62+
63+
**4. Explore commands**
5864

5965
```bash
6066
createos --help
@@ -64,92 +70,167 @@ createos --help
6470

6571
### Authentication
6672

67-
| Command | Description |
68-
| -------------------- | ---------------------------------- |
69-
| `createos login` | Sign in with your API token |
70-
| `createos logout` | Sign out |
71-
| `createos whoami` | Show the currently authenticated user |
73+
| Command | Description |
74+
| ----------------- | ------------------------------------- |
75+
| `createos login` | Sign in with browser or API token |
76+
| `createos logout` | Sign out |
77+
| `createos whoami` | Show the currently authenticated user |
7278

7379
### Projects
7480

75-
| Command | Description |
76-
| ------------------------- | ------------------------ |
77-
| `createos projects list` | List all projects |
78-
| `createos projects get` | Get a project by ID |
79-
| `createos projects delete`| Delete a project |
81+
| Command | Description |
82+
| -------------------------- | ---------------- |
83+
| `createos projects list` | List all projects |
84+
| `createos projects get` | Get project details |
85+
| `createos projects delete` | Delete a project |
8086

8187
### Deployments
8288

83-
| Command | Description |
84-
| ----------------------------------- | ------------------------------------ |
85-
| `createos deployments list` | List deployments for a project |
86-
| `createos deployments logs` | Stream runtime logs for a deployment |
87-
| `createos deployments build-logs` | Stream build logs for a deployment |
88-
| `createos deployments retrigger` | Retrigger a deployment |
89-
| `createos deployments wakeup` | Wake up a sleeping deployment |
90-
| `createos deployments delete` | Delete a deployment |
89+
| Command | Description |
90+
| --------------------------------- | ------------------------------------ |
91+
| `createos deployments list` | List deployments for a project |
92+
| `createos deployments logs` | Stream runtime logs for a deployment |
93+
| `createos deployments build-logs` | Stream build logs for a deployment |
94+
| `createos deployments retrigger` | Retrigger a deployment |
95+
| `createos deployments wakeup` | Wake up a sleeping deployment |
96+
| `createos deployments cancel` | Cancel a deployment |
9197

9298
### Environments
9399

94-
| Command | Description |
95-
| -------------------------------- | --------------------------------- |
96-
| `createos environments list` | List environments for a project |
97-
| `createos environments delete` | Delete an environment |
100+
| Command | Description |
101+
| ------------------------------ | ------------------------------- |
102+
| `createos environments list` | List environments for a project |
103+
| `createos environments delete` | Delete an environment |
104+
105+
### Environment Variables
106+
107+
| Command | Description |
108+
| ---------------------- | ------------------------------------------------- |
109+
| `createos env list` | List environment variables for a project |
110+
| `createos env set` | Set one or more environment variables |
111+
| `createos env rm` | Remove an environment variable |
112+
| `createos env pull` | Download environment variables to a local `.env` file |
113+
| `createos env push` | Upload environment variables from a local `.env` file |
98114

99115
### Domains
100116

101-
| Command | Description |
102-
| ---------------------------- | ---------------------------------- |
103-
| `createos domains list` | List custom domains for a project |
104-
| `createos domains add` | Add a custom domain |
105-
| `createos domains refresh` | Refresh domain DNS verification |
106-
| `createos domains delete` | Remove a custom domain |
117+
| Command | Description |
118+
| -------------------------- | --------------------------------- |
119+
| `createos domains list` | List custom domains for a project |
120+
| `createos domains add` | Add a custom domain |
121+
| `createos domains verify` | Check DNS propagation and wait for verification |
122+
| `createos domains delete` | Remove a custom domain |
123+
124+
### Templates
125+
126+
| Command | Description |
127+
| -------------------------- | --------------------------------------------- |
128+
| `createos templates list` | Browse available project templates |
129+
| `createos templates info` | Show details about a template |
130+
| `createos templates use` | Download and scaffold a project from a template |
107131

108132
### VMs
109133

110-
| Command | Description |
111-
| ------------------------ | ------------------------------------ |
112-
| `createos vms list` | List VM instances |
113-
| `createos vms get` | Get details of a VM |
114-
| `createos vms deploy` | Deploy a new VM |
115-
| `createos vms ssh` | Connect to a VM via SSH |
116-
| `createos vms reboot` | Reboot a VM |
117-
| `createos vms resize` | Resize a VM to a different plan |
118-
| `createos vms terminate` | Terminate a VM |
134+
| Command | Description |
135+
| ------------------------ | ------------------------------- |
136+
| `createos vms list` | List VM instances |
137+
| `createos vms get` | Get details of a VM |
138+
| `createos vms deploy` | Deploy a new VM |
139+
| `createos vms ssh` | Connect to a VM via SSH |
140+
| `createos vms reboot` | Reboot a VM |
141+
| `createos vms resize` | Resize a VM to a different plan |
142+
| `createos vms terminate` | Permanently destroy a VM |
119143

120144
### Skills
121145

122-
| Command | Description |
123-
| -------------------------- | ---------------------------- |
124-
| `createos skills catalog` | Browse the skills catalog |
125-
| `createos skills purchased`| List your purchased skills |
146+
| Command | Description |
147+
| --------------------------- | -------------------------- |
148+
| `createos skills catalog` | Browse the skills catalog |
149+
| `createos skills purchased` | List your purchased skills |
126150

127-
### OAuth
151+
### Quick Actions
128152

129-
| Command | Description |
130-
| -------------------------------- | ---------------------------------- |
131-
| `createos oauth clients list` | List OAuth clients |
132-
| `createos oauth clients create` | Create a new OAuth client |
153+
| Command | Description |
154+
| ----------------- | ------------------------------------------------- |
155+
| `createos init` | Link the current directory to a CreateOS project |
156+
| `createos status` | Show a project's health and deployment status |
157+
| `createos open` | Open a project's live URL in your browser |
158+
| `createos scale` | Adjust replicas and resources for an environment |
133159

134-
### Users
160+
### OAuth Clients
135161

136-
| Command | Description |
137-
| --------------------------------------- | ---------------------------------- |
138-
| `createos users oauth-consents list` | List OAuth consents |
139-
| `createos users oauth-consents revoke` | Revoke an OAuth consent |
162+
| Command | Description |
163+
| -------------------------------------- | ------------------------------------- |
164+
| `createos oauth-clients list` | List your OAuth clients |
165+
| `createos oauth-clients create` | Create a new OAuth client |
166+
| `createos oauth-clients instructions` | Show setup instructions for a client |
167+
168+
### Me
169+
170+
| Command | Description |
171+
| ----------------------------------- | ----------------------- |
172+
| `createos me oauth-consents list` | List OAuth consents |
173+
| `createos me oauth-consents revoke` | Revoke an OAuth consent |
140174

141175
### Other
142176

143-
| Command | Description |
144-
| ----------------------------- | -------------------------------------------- |
145-
| `createos ask` | Ask the AI assistant to help manage your infrastructure |
146-
| `createos completion` | Generate shell completion script (bash/zsh/fish/powershell) |
147-
| `createos version` | Print the current version |
177+
| Command | Description |
178+
| --------------------- | ------------------------------------------------------- |
179+
| `createos ask` | Ask the AI assistant to help manage your infrastructure |
180+
| `createos completion` | Generate shell completion script (bash/zsh/fish/powershell) |
181+
| `createos version` | Print the current version |
182+
183+
## Non-interactive / CI usage
184+
185+
All commands that would normally show an interactive prompt accept flags instead:
186+
187+
```bash
188+
# OAuth clients
189+
createos oauth-clients instructions --client <client-id>
190+
createos oauth-clients create \
191+
--name "My App" \
192+
--redirect-uri https://myapp.com/callback \
193+
--app-url https://myapp.com \
194+
--policy-url https://myapp.com/privacy \
195+
--tos-url https://myapp.com/tos \
196+
--logo-url https://myapp.com/logo.png
197+
198+
# Projects
199+
createos projects get --project <id>
200+
201+
# Deployments
202+
createos deployments logs --project <id> --deployment <id>
203+
createos deployments retrigger --project <id> --deployment <id>
204+
205+
# Environments
206+
createos environments delete --project <id> --environment <id>
207+
208+
# Environment variables
209+
createos env list --project <id> --environment <id>
210+
createos env set KEY=value --project <id> --environment <id>
211+
createos env pull --project <id> --environment <id> --force
212+
213+
# Domains
214+
createos domains add example.com --project <id>
215+
createos domains verify --project <id> --domain <id> --no-wait
216+
createos domains delete --project <id> --domain <id>
217+
218+
# Templates
219+
createos templates use --template <id> --yes
220+
221+
# VMs
222+
createos vms get --vm <id>
223+
createos vms reboot --vm <id> --force
224+
createos vms terminate --vm <id> --force
225+
createos vms resize --vm <id> --size 1
226+
createos vms deploy --zone nyc3 --size 1
227+
```
148228

149229
## Options
150230

151231
| Flag | Description |
152232
| ------------- | ----------------------------------------------------- |
233+
| `--output json` | Output results as JSON (supported on most list/get commands) |
153234
| `--debug, -d` | Print HTTP request/response details (token is masked) |
154235
| `--api-url` | Override the API base URL |
155236

cmd/auth/login.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func NewLoginCommand() *cli.Command {
3636
if err := config.SaveToken(token); err != nil {
3737
return fmt.Errorf("could not save your token: %w", err)
3838
}
39-
pterm.Success.Println("You're now signed in! Run 'createos whoami' to confirm your account.")
39+
pterm.Success.Println("You're signed in.")
4040
return nil
4141
}
4242

@@ -66,16 +66,14 @@ func NewLoginCommand() *cli.Command {
6666
}
6767

6868
func loginWithAPIToken() error {
69-
pterm.Println(pterm.Gray(" You can find your API token in your CreateOS dashboard."))
70-
fmt.Println()
7169
token, err := pterm.DefaultInteractiveTextInput.WithMask("*").Show("Paste your API token")
7270
if err != nil || token == "" {
7371
return fmt.Errorf("sign in cancelled")
7472
}
7573
if err := config.SaveToken(token); err != nil {
7674
return fmt.Errorf("could not save your token: %w", err)
7775
}
78-
pterm.Success.Println("You're now signed in! Run 'createos whoami' to confirm your account.")
76+
pterm.Success.Println("You're signed in.")
7977
return nil
8078
}
8179

@@ -156,6 +154,6 @@ func loginWithBrowser() error {
156154
}
157155

158156
fmt.Println()
159-
pterm.Success.Println("You're signed in! Run 'createos whoami' to confirm your account.")
157+
pterm.Success.Println("You're signed in.")
160158
return nil
161159
}

cmd/auth/logout.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package auth
33
import (
44
"fmt"
55

6-
"github.com/pterm/pterm"
76
"github.com/urfave/cli/v2"
87

98
"github.com/NodeOps-app/createos-cli/internal/config"
@@ -27,9 +26,6 @@ func NewLogoutCommand() *cli.Command {
2726
}
2827

2928
fmt.Println("You've been signed out successfully.")
30-
fmt.Println()
31-
pterm.Println(pterm.Gray(" Tip: To sign back in, run:"))
32-
pterm.Println(pterm.Gray(" createos login"))
3329
return nil
3430
},
3531
}

cmd/auth/whoami.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ func NewWhoamiCommand() *cli.Command {
4444
pterm.Printfln(" %s %s", pterm.Gray("ID "), u.ID)
4545
pterm.Printfln(" %s %s", pterm.Gray("Member since "), memberSince)
4646
fmt.Println()
47-
pterm.Println(pterm.Gray(" Tip: To see your projects, run:"))
48-
pterm.Println(pterm.Gray(" createos projects list"))
49-
fmt.Println()
5047

5148
return nil
5249
},

cmd/cronjobs/cronjobs.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Package cronjobs provides cron job management commands.
2+
package cronjobs
3+
4+
import "github.com/urfave/cli/v2"
5+
6+
// NewCronjobsCommand returns the cronjobs command group.
7+
func NewCronjobsCommand() *cli.Command {
8+
return &cli.Command{
9+
Name: "cronjobs",
10+
Usage: "Manage cron jobs for a project",
11+
Subcommands: []*cli.Command{
12+
newCronjobsActivitiesCommand(),
13+
newCronjobsCreateCommand(),
14+
newCronjobsDeleteCommand(),
15+
newCronjobsGetCommand(),
16+
newCronjobsListCommand(),
17+
newCronjobsSuspendCommand(),
18+
newCronjobsUnsuspendCommand(),
19+
newCronjobsUpdateCommand(),
20+
},
21+
}
22+
}

0 commit comments

Comments
 (0)