@butterbase/cli 0.1.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.
Files changed (59) hide show
  1. package/README.md +255 -0
  2. package/bin/butterbase.ts +137 -0
  3. package/dist/bin/butterbase.d.ts +3 -0
  4. package/dist/bin/butterbase.d.ts.map +1 -0
  5. package/dist/bin/butterbase.js +112 -0
  6. package/dist/bin/butterbase.js.map +1 -0
  7. package/dist/src/commands/apps.d.ts +5 -0
  8. package/dist/src/commands/apps.d.ts.map +1 -0
  9. package/dist/src/commands/apps.js +113 -0
  10. package/dist/src/commands/apps.js.map +1 -0
  11. package/dist/src/commands/config.d.ts +5 -0
  12. package/dist/src/commands/config.d.ts.map +1 -0
  13. package/dist/src/commands/config.js +43 -0
  14. package/dist/src/commands/config.js.map +1 -0
  15. package/dist/src/commands/functions.d.ts +15 -0
  16. package/dist/src/commands/functions.d.ts.map +1 -0
  17. package/dist/src/commands/functions.js +94 -0
  18. package/dist/src/commands/functions.js.map +1 -0
  19. package/dist/src/commands/init.d.ts +2 -0
  20. package/dist/src/commands/init.d.ts.map +1 -0
  21. package/dist/src/commands/init.js +118 -0
  22. package/dist/src/commands/init.js.map +1 -0
  23. package/dist/src/commands/schema.d.ts +10 -0
  24. package/dist/src/commands/schema.d.ts.map +1 -0
  25. package/dist/src/commands/schema.js +69 -0
  26. package/dist/src/commands/schema.js.map +1 -0
  27. package/dist/src/commands/storage.d.ts +10 -0
  28. package/dist/src/commands/storage.d.ts.map +1 -0
  29. package/dist/src/commands/storage.js +105 -0
  30. package/dist/src/commands/storage.js.map +1 -0
  31. package/dist/src/lib/api-client.d.ts +44 -0
  32. package/dist/src/lib/api-client.d.ts.map +1 -0
  33. package/dist/src/lib/api-client.js +129 -0
  34. package/dist/src/lib/api-client.js.map +1 -0
  35. package/dist/src/lib/config.d.ts +47 -0
  36. package/dist/src/lib/config.d.ts.map +1 -0
  37. package/dist/src/lib/config.js +87 -0
  38. package/dist/src/lib/config.js.map +1 -0
  39. package/package.json +35 -0
  40. package/src/commands/apps.ts +130 -0
  41. package/src/commands/config.ts +50 -0
  42. package/src/commands/functions.ts +116 -0
  43. package/src/commands/init.ts +151 -0
  44. package/src/commands/schema.ts +78 -0
  45. package/src/commands/storage.ts +117 -0
  46. package/src/lib/api-client.ts +176 -0
  47. package/src/lib/config.ts +112 -0
  48. package/templates/react-vite/.env.example +2 -0
  49. package/templates/react-vite/README.md +38 -0
  50. package/templates/react-vite/index.html +13 -0
  51. package/templates/react-vite/package.json +25 -0
  52. package/templates/react-vite/src/App.css +33 -0
  53. package/templates/react-vite/src/App.tsx +77 -0
  54. package/templates/react-vite/src/index.css +8 -0
  55. package/templates/react-vite/src/lib.ts +6 -0
  56. package/templates/react-vite/src/main.tsx +10 -0
  57. package/templates/react-vite/tsconfig.json +21 -0
  58. package/templates/react-vite/vite.config.ts +6 -0
  59. package/tsconfig.json +20 -0
package/README.md ADDED
@@ -0,0 +1,255 @@
1
+ # @butterbase/cli
2
+
3
+ Command-line tool for Butterbase project scaffolding and backend management.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @butterbase/cli
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```bash
14
+ # Login with your API key
15
+ butterbase login
16
+
17
+ # Create a new app
18
+ butterbase apps create my-app
19
+
20
+ # Set as current app
21
+ butterbase apps use app_abc123
22
+
23
+ # Get current schema
24
+ butterbase schema get --output schema.json
25
+
26
+ # Apply schema changes
27
+ butterbase schema apply schema.json
28
+
29
+ # Deploy a function
30
+ butterbase functions deploy ./functions/hello.ts
31
+
32
+ # Upload a file
33
+ butterbase storage upload ./image.png
34
+ ```
35
+
36
+ ## Commands
37
+
38
+ ### Authentication
39
+
40
+ ```bash
41
+ # Login
42
+ butterbase login
43
+
44
+ # Logout
45
+ butterbase logout
46
+ ```
47
+
48
+ ### Configuration
49
+
50
+ ```bash
51
+ # Show current config
52
+ butterbase config get
53
+
54
+ # Set endpoint
55
+ butterbase config set endpoint https://api.butterbase.com
56
+
57
+ # Set API key
58
+ butterbase config set apiKey bb_key_...
59
+ ```
60
+
61
+ Configuration is stored in `~/.butterbase/config.json`.
62
+
63
+ ### Apps
64
+
65
+ ```bash
66
+ # List all apps
67
+ butterbase apps list
68
+
69
+ # Create new app
70
+ butterbase apps create my-app
71
+
72
+ # Set current app (used by other commands)
73
+ butterbase apps use app_abc123
74
+
75
+ # Delete app
76
+ butterbase apps delete app_abc123
77
+ ```
78
+
79
+ ### Schema
80
+
81
+ ```bash
82
+ # Get current schema
83
+ butterbase schema get
84
+
85
+ # Save schema to file
86
+ butterbase schema get --output schema.json
87
+
88
+ # Preview schema changes (dry-run)
89
+ butterbase schema apply schema.json --dry-run
90
+
91
+ # Apply schema changes
92
+ butterbase schema apply schema.json
93
+
94
+ # Apply with custom migration name
95
+ butterbase schema apply schema.json --name "add_users_table"
96
+
97
+ # Use specific app
98
+ butterbase schema get --app app_abc123
99
+ ```
100
+
101
+ ### Functions
102
+
103
+ ```bash
104
+ # List deployed functions
105
+ butterbase functions list
106
+
107
+ # Deploy function
108
+ butterbase functions deploy ./functions/hello.ts
109
+
110
+ # Deploy with custom name
111
+ butterbase functions deploy ./functions/hello.ts --name my-function
112
+
113
+ # Deploy with description
114
+ butterbase functions deploy ./functions/hello.ts --description "Hello world function"
115
+
116
+ # Deploy cron function
117
+ butterbase functions deploy ./functions/cleanup.ts --trigger cron
118
+
119
+ # View function logs
120
+ butterbase functions logs my-function
121
+
122
+ # View error logs only
123
+ butterbase functions logs my-function --level error
124
+
125
+ # Limit number of logs
126
+ butterbase functions logs my-function --limit 50
127
+ ```
128
+
129
+ ### Storage
130
+
131
+ ```bash
132
+ # List storage objects
133
+ butterbase storage list
134
+
135
+ # Upload file
136
+ butterbase storage upload ./image.png
137
+
138
+ # Delete object
139
+ butterbase storage delete obj_abc123
140
+ ```
141
+
142
+ ## Global Options
143
+
144
+ Most commands support the `--app` flag to specify an app ID:
145
+
146
+ ```bash
147
+ butterbase schema get --app app_abc123
148
+ butterbase functions list --app app_abc123
149
+ butterbase storage list --app app_abc123
150
+ ```
151
+
152
+ If `--app` is not provided, the CLI uses the current app set with `butterbase apps use`.
153
+
154
+ ## Configuration
155
+
156
+ The CLI stores configuration in two places:
157
+
158
+ 1. **Global config**: `~/.butterbase/config.json`
159
+ - API key
160
+ - Default endpoint
161
+ - Current app
162
+
163
+ 2. **Project config**: `.butterbase/config.json` (in project directory)
164
+ - App ID
165
+ - Endpoint override
166
+
167
+ Project config takes precedence over global config.
168
+
169
+ ## Environment Variables
170
+
171
+ You can also configure the CLI using environment variables:
172
+
173
+ - `BUTTERBASE_API_KEY` - API key
174
+ - `BUTTERBASE_ENDPOINT` - API endpoint URL
175
+
176
+ ## Examples
177
+
178
+ ### Complete Workflow
179
+
180
+ ```bash
181
+ # 1. Login
182
+ butterbase login
183
+
184
+ # 2. Create app
185
+ butterbase apps create my-grocery-app
186
+
187
+ # 3. Set as current
188
+ butterbase apps use app_abc123
189
+
190
+ # 4. Create schema file
191
+ cat > schema.json <<EOF
192
+ {
193
+ "tables": {
194
+ "grocery_items": {
195
+ "columns": {
196
+ "id": { "type": "uuid", "primaryKey": true, "default": "gen_random_uuid()" },
197
+ "name": { "type": "text" },
198
+ "quantity": { "type": "integer", "default": "1" },
199
+ "purchased": { "type": "boolean", "default": "false" },
200
+ "user_id": { "type": "uuid" },
201
+ "created_at": { "type": "timestamptz", "default": "now()" }
202
+ }
203
+ }
204
+ }
205
+ }
206
+ EOF
207
+
208
+ # 5. Apply schema
209
+ butterbase schema apply schema.json
210
+
211
+ # 6. Deploy function
212
+ butterbase functions deploy ./functions/add-item.ts
213
+
214
+ # 7. Upload image
215
+ butterbase storage upload ./logo.png
216
+ ```
217
+
218
+ ### Working with Multiple Apps
219
+
220
+ ```bash
221
+ # Create production app
222
+ butterbase apps create my-app-prod
223
+ # Returns: app_prod123
224
+
225
+ # Create staging app
226
+ butterbase apps create my-app-staging
227
+ # Returns: app_staging456
228
+
229
+ # Deploy to production
230
+ butterbase functions deploy ./functions/api.ts --app app_prod123
231
+
232
+ # Deploy to staging
233
+ butterbase functions deploy ./functions/api.ts --app app_staging456
234
+
235
+ # Switch between apps
236
+ butterbase apps use app_prod123
237
+ butterbase apps use app_staging456
238
+ ```
239
+
240
+ ## Development
241
+
242
+ ```bash
243
+ # Install dependencies
244
+ npm install
245
+
246
+ # Build
247
+ npm run build
248
+
249
+ # Test locally
250
+ node dist/bin/butterbase.js --help
251
+ ```
252
+
253
+ ## License
254
+
255
+ MIT
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import chalk from 'chalk';
4
+ import { initCommand } from '../src/commands/init.js';
5
+ import { loginCommand, logoutCommand, configGetCommand, configSetCommand } from '../src/commands/config.js';
6
+ import { appsListCommand, appsCreateCommand, appsUseCommand, appsDeleteCommand } from '../src/commands/apps.js';
7
+ import { schemaGetCommand, schemaApplyCommand } from '../src/commands/schema.js';
8
+ import { functionsListCommand, functionsDeployCommand, functionsLogsCommand } from '../src/commands/functions.js';
9
+ import { storageListCommand, storageUploadCommand, storageDeleteCommand } from '../src/commands/storage.js';
10
+
11
+ const program = new Command();
12
+
13
+ program
14
+ .name('butterbase')
15
+ .description('Butterbase CLI - Backend as a Service')
16
+ .version('0.1.0');
17
+
18
+ // Init
19
+ program
20
+ .command('init [template]')
21
+ .description('Initialize a new Butterbase project')
22
+ .action(initCommand);
23
+
24
+ // Login/Logout
25
+ program
26
+ .command('login')
27
+ .description('Authenticate with Butterbase')
28
+ .action(loginCommand);
29
+
30
+ program
31
+ .command('logout')
32
+ .description('Clear authentication credentials')
33
+ .action(logoutCommand);
34
+
35
+ // Config
36
+ const config = program.command('config').description('Manage configuration');
37
+
38
+ config
39
+ .command('get')
40
+ .description('Show current configuration')
41
+ .action(configGetCommand);
42
+
43
+ config
44
+ .command('set <key> <value>')
45
+ .description('Set a configuration value')
46
+ .action(configSetCommand);
47
+
48
+ // Apps
49
+ const apps = program.command('apps').description('Manage apps');
50
+
51
+ apps
52
+ .command('list')
53
+ .description('List all apps')
54
+ .action(appsListCommand);
55
+
56
+ apps
57
+ .command('create [name]')
58
+ .description('Create a new app')
59
+ .action(appsCreateCommand);
60
+
61
+ apps
62
+ .command('use <app-id>')
63
+ .description('Set the current app')
64
+ .action(appsUseCommand);
65
+
66
+ apps
67
+ .command('delete <app-id>')
68
+ .description('Delete an app')
69
+ .action(appsDeleteCommand);
70
+
71
+ // Schema
72
+ const schema = program.command('schema').description('Manage database schema');
73
+
74
+ schema
75
+ .command('get')
76
+ .description('Get current schema')
77
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
78
+ .option('--output <file>', 'Save schema to file')
79
+ .action(schemaGetCommand);
80
+
81
+ schema
82
+ .command('apply <file>')
83
+ .description('Apply schema from file')
84
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
85
+ .option('--dry-run', 'Preview changes without applying')
86
+ .option('--name <name>', 'Migration name')
87
+ .action(schemaApplyCommand);
88
+
89
+ // Functions
90
+ const functions = program.command('functions').description('Manage serverless functions');
91
+
92
+ functions
93
+ .command('list')
94
+ .description('List deployed functions')
95
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
96
+ .action(functionsListCommand);
97
+
98
+ functions
99
+ .command('deploy <file>')
100
+ .description('Deploy a function')
101
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
102
+ .option('--name <name>', 'Function name (defaults to filename)')
103
+ .option('--trigger <type>', 'Trigger type (http, cron)', 'http')
104
+ .option('--description <desc>', 'Function description')
105
+ .action(functionsDeployCommand);
106
+
107
+ functions
108
+ .command('logs <function-name>')
109
+ .description('View function logs')
110
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
111
+ .option('--level <level>', 'Filter by log level (error, all)')
112
+ .option('--limit <number>', 'Number of logs to fetch', '100')
113
+ .action(functionsLogsCommand);
114
+
115
+ // Storage
116
+ const storage = program.command('storage').description('Manage file storage');
117
+
118
+ storage
119
+ .command('list')
120
+ .description('List storage objects')
121
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
122
+ .action(storageListCommand);
123
+
124
+ storage
125
+ .command('upload <file>')
126
+ .description('Upload a file')
127
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
128
+ .action(storageUploadCommand);
129
+
130
+ storage
131
+ .command('delete <object-id>')
132
+ .description('Delete a storage object')
133
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
134
+ .action(storageDeleteCommand);
135
+
136
+ // Parse arguments
137
+ program.parse();
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=butterbase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"butterbase.d.ts","sourceRoot":"","sources":["../../bin/butterbase.ts"],"names":[],"mappings":""}
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from 'commander';
3
+ import { initCommand } from '../src/commands/init.js';
4
+ import { loginCommand, logoutCommand, configGetCommand, configSetCommand } from '../src/commands/config.js';
5
+ import { appsListCommand, appsCreateCommand, appsUseCommand, appsDeleteCommand } from '../src/commands/apps.js';
6
+ import { schemaGetCommand, schemaApplyCommand } from '../src/commands/schema.js';
7
+ import { functionsListCommand, functionsDeployCommand, functionsLogsCommand } from '../src/commands/functions.js';
8
+ import { storageListCommand, storageUploadCommand, storageDeleteCommand } from '../src/commands/storage.js';
9
+ const program = new Command();
10
+ program
11
+ .name('butterbase')
12
+ .description('Butterbase CLI - Backend as a Service')
13
+ .version('0.1.0');
14
+ // Init
15
+ program
16
+ .command('init [template]')
17
+ .description('Initialize a new Butterbase project')
18
+ .action(initCommand);
19
+ // Login/Logout
20
+ program
21
+ .command('login')
22
+ .description('Authenticate with Butterbase')
23
+ .action(loginCommand);
24
+ program
25
+ .command('logout')
26
+ .description('Clear authentication credentials')
27
+ .action(logoutCommand);
28
+ // Config
29
+ const config = program.command('config').description('Manage configuration');
30
+ config
31
+ .command('get')
32
+ .description('Show current configuration')
33
+ .action(configGetCommand);
34
+ config
35
+ .command('set <key> <value>')
36
+ .description('Set a configuration value')
37
+ .action(configSetCommand);
38
+ // Apps
39
+ const apps = program.command('apps').description('Manage apps');
40
+ apps
41
+ .command('list')
42
+ .description('List all apps')
43
+ .action(appsListCommand);
44
+ apps
45
+ .command('create [name]')
46
+ .description('Create a new app')
47
+ .action(appsCreateCommand);
48
+ apps
49
+ .command('use <app-id>')
50
+ .description('Set the current app')
51
+ .action(appsUseCommand);
52
+ apps
53
+ .command('delete <app-id>')
54
+ .description('Delete an app')
55
+ .action(appsDeleteCommand);
56
+ // Schema
57
+ const schema = program.command('schema').description('Manage database schema');
58
+ schema
59
+ .command('get')
60
+ .description('Get current schema')
61
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
62
+ .option('--output <file>', 'Save schema to file')
63
+ .action(schemaGetCommand);
64
+ schema
65
+ .command('apply <file>')
66
+ .description('Apply schema from file')
67
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
68
+ .option('--dry-run', 'Preview changes without applying')
69
+ .option('--name <name>', 'Migration name')
70
+ .action(schemaApplyCommand);
71
+ // Functions
72
+ const functions = program.command('functions').description('Manage serverless functions');
73
+ functions
74
+ .command('list')
75
+ .description('List deployed functions')
76
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
77
+ .action(functionsListCommand);
78
+ functions
79
+ .command('deploy <file>')
80
+ .description('Deploy a function')
81
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
82
+ .option('--name <name>', 'Function name (defaults to filename)')
83
+ .option('--trigger <type>', 'Trigger type (http, cron)', 'http')
84
+ .option('--description <desc>', 'Function description')
85
+ .action(functionsDeployCommand);
86
+ functions
87
+ .command('logs <function-name>')
88
+ .description('View function logs')
89
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
90
+ .option('--level <level>', 'Filter by log level (error, all)')
91
+ .option('--limit <number>', 'Number of logs to fetch', '100')
92
+ .action(functionsLogsCommand);
93
+ // Storage
94
+ const storage = program.command('storage').description('Manage file storage');
95
+ storage
96
+ .command('list')
97
+ .description('List storage objects')
98
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
99
+ .action(storageListCommand);
100
+ storage
101
+ .command('upload <file>')
102
+ .description('Upload a file')
103
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
104
+ .action(storageUploadCommand);
105
+ storage
106
+ .command('delete <object-id>')
107
+ .description('Delete a storage object')
108
+ .option('--app <app-id>', 'App ID (uses current app if not specified)')
109
+ .action(storageDeleteCommand);
110
+ // Parse arguments
111
+ program.parse();
112
+ //# sourceMappingURL=butterbase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"butterbase.js","sourceRoot":"","sources":["../../bin/butterbase.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC5G,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAChH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAClH,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAE5G,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,YAAY,CAAC;KAClB,WAAW,CAAC,uCAAuC,CAAC;KACpD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;AACP,OAAO;KACJ,OAAO,CAAC,iBAAiB,CAAC;KAC1B,WAAW,CAAC,qCAAqC,CAAC;KAClD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B,EAAE,kCAAkC,CAAC;KAC7D,MAAM,CAAC,kBAAkB,EAAE,yBAAyB,EAAE,KAAK,CAAC;KAC5D,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAEhC,UAAU;AACV,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;AAE9E,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,sBAAsB,CAAC;KACnC,MAAM,CAAC,gBAAgB,EAAE,4CAA4C,CAAC;KACtE,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAE9B,OAAO;KACJ,OAAO,CAAC,eAAe,CAAC;KACxB,WAAW,CAAC,eAAe,CAAC;KAC5B,MAAM,CAAC,gBAAgB,EAAE,4CAA4C,CAAC;KACtE,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAEhC,OAAO;KACJ,OAAO,CAAC,oBAAoB,CAAC;KAC7B,WAAW,CAAC,yBAAyB,CAAC;KACtC,MAAM,CAAC,gBAAgB,EAAE,4CAA4C,CAAC;KACtE,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAEhC,kBAAkB;AAClB,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare function appsListCommand(): Promise<void>;
2
+ export declare function appsCreateCommand(name: string): Promise<void>;
3
+ export declare function appsUseCommand(appId: string): Promise<void>;
4
+ export declare function appsDeleteCommand(appId: string): Promise<void>;
5
+ //# sourceMappingURL=apps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apps.d.ts","sourceRoot":"","sources":["../../../src/commands/apps.ts"],"names":[],"mappings":"AAMA,wBAAsB,eAAe,kBA4BpC;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,iBA4CnD;AAED,wBAAsB,cAAc,CAAC,KAAK,EAAE,MAAM,iBASjD;AAED,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,MAAM,iBAoCpD"}
@@ -0,0 +1,113 @@
1
+ import chalk from 'chalk';
2
+ import ora from 'ora';
3
+ import prompts from 'prompts';
4
+ import { initApp, listApps, deleteApp } from '../lib/api-client.js';
5
+ import { setCurrentAppId, getCurrentAppId } from '../lib/config.js';
6
+ export async function appsListCommand() {
7
+ const spinner = ora('Fetching apps...').start();
8
+ try {
9
+ const response = await listApps();
10
+ spinner.stop();
11
+ if (!response.apps || response.apps.length === 0) {
12
+ console.log(chalk.yellow('No apps found'));
13
+ return;
14
+ }
15
+ const currentAppId = await getCurrentAppId();
16
+ console.log(chalk.blue('\nYour apps:\n'));
17
+ for (const app of response.apps) {
18
+ const isCurrent = app.id === currentAppId;
19
+ const marker = isCurrent ? chalk.green('→') : ' ';
20
+ console.log(`${marker} ${chalk.bold(app.name)} ${chalk.gray(`(${app.id})`)}`);
21
+ if (isCurrent) {
22
+ console.log(chalk.gray(` Current app`));
23
+ }
24
+ }
25
+ }
26
+ catch (error) {
27
+ spinner.fail('Failed to fetch apps');
28
+ console.error(chalk.red(error.message));
29
+ process.exit(1);
30
+ }
31
+ }
32
+ export async function appsCreateCommand(name) {
33
+ if (!name) {
34
+ const response = await prompts({
35
+ type: 'text',
36
+ name: 'name',
37
+ message: 'App name:',
38
+ validate: (value) => value.length > 0 || 'App name is required',
39
+ });
40
+ if (!response.name) {
41
+ console.log(chalk.yellow('Cancelled'));
42
+ process.exit(0);
43
+ }
44
+ name = response.name;
45
+ }
46
+ const spinner = ora(`Creating app "${name}"...`).start();
47
+ try {
48
+ const response = await initApp(name);
49
+ spinner.succeed(`Created app "${name}"`);
50
+ console.log(chalk.green('\n✓ App created successfully!'));
51
+ console.log(chalk.gray(` App ID: ${response.app_id}`));
52
+ console.log(chalk.gray(` API URL: ${response.api_url}`));
53
+ // Ask if they want to set it as current app
54
+ const { setCurrent } = await prompts({
55
+ type: 'confirm',
56
+ name: 'setCurrent',
57
+ message: 'Set as current app?',
58
+ initial: true,
59
+ });
60
+ if (setCurrent) {
61
+ await setCurrentAppId(response.app_id);
62
+ console.log(chalk.green('✓ Set as current app'));
63
+ }
64
+ }
65
+ catch (error) {
66
+ spinner.fail('Failed to create app');
67
+ console.error(chalk.red(error.message));
68
+ process.exit(1);
69
+ }
70
+ }
71
+ export async function appsUseCommand(appId) {
72
+ if (!appId) {
73
+ console.log(chalk.red('✗ App ID is required'));
74
+ console.log(chalk.gray('Usage: butterbase apps use <app-id>'));
75
+ process.exit(1);
76
+ }
77
+ await setCurrentAppId(appId);
78
+ console.log(chalk.green(`✓ Now using app: ${appId}`));
79
+ }
80
+ export async function appsDeleteCommand(appId) {
81
+ if (!appId) {
82
+ console.log(chalk.red('✗ App ID is required'));
83
+ console.log(chalk.gray('Usage: butterbase apps delete <app-id>'));
84
+ process.exit(1);
85
+ }
86
+ const { confirm } = await prompts({
87
+ type: 'confirm',
88
+ name: 'confirm',
89
+ message: `Are you sure you want to delete app ${appId}? This cannot be undone.`,
90
+ initial: false,
91
+ });
92
+ if (!confirm) {
93
+ console.log(chalk.yellow('Cancelled'));
94
+ return;
95
+ }
96
+ const spinner = ora('Deleting app...').start();
97
+ try {
98
+ await deleteApp(appId);
99
+ spinner.succeed('App deleted');
100
+ // Clear current app if it was deleted
101
+ const currentAppId = await getCurrentAppId();
102
+ if (currentAppId === appId) {
103
+ await setCurrentAppId('');
104
+ console.log(chalk.gray('Cleared current app'));
105
+ }
106
+ }
107
+ catch (error) {
108
+ spinner.fail('Failed to delete app');
109
+ console.error(chalk.red(error.message));
110
+ process.exit(1);
111
+ }
112
+ }
113
+ //# sourceMappingURL=apps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apps.js","sourceRoot":"","sources":["../../../src/commands/apps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAA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
2
+ export declare function logoutCommand(): Promise<void>;
3
+ export declare function configGetCommand(): Promise<void>;
4
+ export declare function configSetCommand(key: string, value: string): Promise<void>;
5
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/commands/config.ts"],"names":[],"mappings":"AAIA,wBAAsB,YAAY,kBAmBjC;AAED,wBAAsB,aAAa,kBAGlC;AAED,wBAAsB,gBAAgB,kBAIrC;AAED,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAahE"}