@globio/cli 0.2.0 → 0.2.3

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/src/index.ts CHANGED
@@ -17,6 +17,14 @@ import {
17
17
  functionsDelete,
18
18
  functionsToggle,
19
19
  } from './commands/functions.js';
20
+ import {
21
+ hooksList,
22
+ hooksCreate,
23
+ hooksDeploy,
24
+ hooksLogs,
25
+ hooksToggle,
26
+ hooksDelete,
27
+ } from './commands/hooks.js';
20
28
  import { functionsWatch } from './commands/watch.js';
21
29
  import {
22
30
  migrateFirestore,
@@ -46,6 +54,8 @@ Examples:
46
54
  $ globio projects list
47
55
  $ globio projects use proj_abc123
48
56
  $ globio functions deploy my-function
57
+ $ globio hooks deploy on-signup --trigger id.onSignup
58
+ $ globio hooks list
49
59
  $ globio migrate firestore --from ./key.json --all
50
60
 
51
61
  Credentials are stored in ~/.globio/profiles/
@@ -56,74 +66,168 @@ program
56
66
  .command('login')
57
67
  .description('Log in to your Globio account')
58
68
  .option('-p, --profile <name>', 'Profile name', 'default')
59
- .option('--token', 'Use a personal access token')
69
+ .option('--token <pat>', 'Personal access token (non-interactive)')
70
+ .option('--json', 'Output as JSON')
60
71
  .action(login);
61
72
  program.command('logout').description('Log out').option('--profile <name>', 'Use a specific profile').action(logout);
62
- program.command('whoami').description('Show current account and project').option('--profile <name>', 'Use a specific profile').action(whoami);
73
+ program.command('whoami').description('Show current account and project').option('--profile <name>', 'Use a specific profile').option('--json', 'Output as JSON').action(whoami);
63
74
  program.command('use <profile>').description('Switch active profile').action(useProfile);
64
75
 
65
- program.command('init').description('Initialize a Globio project').option('--profile <name>', 'Use a specific profile').action(init);
76
+ program
77
+ .command('init')
78
+ .description('Initialize a Globio project')
79
+ .option('-p, --profile <name>', 'Profile name')
80
+ .option('--name <name>', 'Project name')
81
+ .option('--slug <slug>', 'Project slug')
82
+ .option('--org <orgId>', 'Organization ID')
83
+ .option('--env <environment>', 'Environment (development|staging|production)', 'development')
84
+ .option('--no-migrate', 'Skip Firebase migration prompt')
85
+ .option('--from <path>', 'Firebase service account path (triggers migration)')
86
+ .option('--json', 'Output as JSON')
87
+ .action(init);
66
88
 
67
89
  const profiles = program
68
90
  .command('profiles')
69
91
  .description('Manage login profiles')
70
- .action(profilesList);
92
+ .option('--json', 'Output as JSON')
93
+ .action(function (this: Command) {
94
+ return profilesList(this.opts());
95
+ });
71
96
 
72
97
  profiles
73
98
  .command('list')
74
99
  .description('List all profiles')
75
- .action(profilesList);
100
+ .option('--json', 'Output as JSON')
101
+ .action(function (this: Command) {
102
+ return profilesList(this.opts());
103
+ });
76
104
 
77
105
  const projects = program.command('projects').description('Manage projects');
78
- projects.command('list').description('List projects').option('--profile <name>', 'Use a specific profile').action(projectsList);
79
- projects.command('create').description('Create a project').option('--profile <name>', 'Use a specific profile').action(projectsCreate);
80
- projects.command('use <projectId>').description('Set active project').option('--profile <name>', 'Use a specific profile').action(projectsUse);
106
+ projects.command('list').description('List projects').option('--profile <name>', 'Use a specific profile').option('--json', 'Output as JSON').action(projectsList);
107
+ projects
108
+ .command('create')
109
+ .description('Create a project')
110
+ .option('--name <name>', 'Project name')
111
+ .option('--org <orgId>', 'Organization ID')
112
+ .option('--env <environment>', 'Environment', 'development')
113
+ .option('-p, --profile <name>', 'Profile name')
114
+ .option('--json', 'Output as JSON')
115
+ .action(projectsCreate);
116
+ projects.command('use <projectId>').description('Set active project').option('--profile <name>', 'Use a specific profile').option('--json', 'Output as JSON').action(projectsUse);
81
117
 
82
- program.command('services').description('List available Globio services').option('--profile <name>', 'Use a specific profile').action(servicesList);
118
+ program.command('services').description('List available Globio services').option('--profile <name>', 'Use a specific profile').option('--json', 'Output as JSON').action(servicesList);
83
119
 
84
120
  const functions = program
85
121
  .command('functions')
86
122
  .alias('fn')
87
- .description('Manage GlobalCode edge functions');
123
+ .description('Manage edge functions');
88
124
 
89
- functions.command('list').description('List all functions').option('--profile <name>', 'Use a specific profile').action(functionsList);
90
- functions.command('create <slug>').description('Scaffold a new function file locally').option('--profile <name>', 'Use a specific profile').action(functionsCreate);
125
+ functions.command('list').description('List all functions').option('--profile <name>', 'Use a specific profile').option('--json', 'Output as JSON').action(functionsList);
126
+ functions.command('create <slug>').description('Scaffold a new function file locally').option('--profile <name>', 'Use a specific profile').option('--json', 'Output as JSON').action(functionsCreate);
91
127
  functions
92
128
  .command('deploy <slug>')
93
129
  .description('Deploy a function to GlobalCode')
94
130
  .option('-f, --file <path>', 'Path to function file')
95
131
  .option('-n, --name <name>', 'Display name')
96
132
  .option('--profile <name>', 'Use a specific profile')
133
+ .option('--json', 'Output as JSON')
97
134
  .action(functionsDeploy);
98
135
  functions
99
136
  .command('invoke <slug>')
100
137
  .description('Invoke a function')
101
138
  .option('-i, --input <json>', 'JSON input payload')
102
139
  .option('--profile <name>', 'Use a specific profile')
140
+ .option('--json', 'Output as JSON')
103
141
  .action(functionsInvoke);
104
142
  functions
105
143
  .command('logs <slug>')
106
144
  .description('Show invocation history')
107
145
  .option('-l, --limit <n>', 'Number of entries', '20')
108
146
  .option('--profile <name>', 'Use a specific profile')
147
+ .option('--json', 'Output as JSON')
109
148
  .action(functionsLogs);
110
149
  functions
111
150
  .command('watch <slug>')
112
151
  .description('Stream live function execution logs')
113
152
  .option('--profile <name>', 'Use a specific profile')
114
153
  .action(functionsWatch);
115
- functions.command('delete <slug>').description('Delete a function').option('--profile <name>', 'Use a specific profile').action(functionsDelete);
154
+ functions.command('delete <slug>').description('Delete a function').option('--profile <name>', 'Use a specific profile').option('--json', 'Output as JSON').action(functionsDelete);
116
155
  functions
117
156
  .command('enable <slug>')
118
157
  .description('Enable a function')
119
158
  .option('--profile <name>', 'Use a specific profile')
159
+ .option('--json', 'Output as JSON')
120
160
  .action((slug, options) => functionsToggle(slug, true, options));
121
161
  functions
122
162
  .command('disable <slug>')
123
163
  .description('Disable a function')
124
164
  .option('--profile <name>', 'Use a specific profile')
165
+ .option('--json', 'Output as JSON')
125
166
  .action((slug, options) => functionsToggle(slug, false, options));
126
167
 
168
+ const hooks = program
169
+ .command('hooks')
170
+ .description('Manage GC Hooks')
171
+ .action(hooksList);
172
+
173
+ hooks
174
+ .command('list')
175
+ .description('List all hooks')
176
+ .option('-p, --profile <name>', 'Profile name')
177
+ .option('--json', 'Output as JSON')
178
+ .action(hooksList);
179
+
180
+ hooks
181
+ .command('create <slug>')
182
+ .description('Scaffold a new hook file locally')
183
+ .option('--json', 'Output as JSON')
184
+ .action(hooksCreate);
185
+
186
+ hooks
187
+ .command('deploy <slug>')
188
+ .description('Deploy a hook')
189
+ .option('-f, --file <path>', 'Path to hook file')
190
+ .option('-n, --name <name>', 'Display name')
191
+ .option('-t, --trigger <event>', 'Hook trigger event (e.g. id.onSignup)')
192
+ .option('-p, --profile <name>', 'Profile name')
193
+ .option('--json', 'Output as JSON')
194
+ .action(hooksDeploy);
195
+
196
+ hooks
197
+ .command('logs <slug>')
198
+ .description('Show hook invocation history')
199
+ .option('-l, --limit <n>', 'Number of entries', '20')
200
+ .option('-p, --profile <name>', 'Profile name')
201
+ .option('--json', 'Output as JSON')
202
+ .action(hooksLogs);
203
+
204
+ hooks
205
+ .command('watch <slug>')
206
+ .description('Stream live hook execution logs')
207
+ .option('-p, --profile <name>', 'Profile name')
208
+ .action((slug, opts) => functionsWatch(slug, opts));
209
+
210
+ hooks
211
+ .command('enable <slug>')
212
+ .description('Enable a hook')
213
+ .option('-p, --profile <name>', 'Profile name')
214
+ .option('--json', 'Output as JSON')
215
+ .action((slug, opts) => hooksToggle(slug, true, opts));
216
+
217
+ hooks
218
+ .command('disable <slug>')
219
+ .description('Disable a hook')
220
+ .option('-p, --profile <name>', 'Profile name')
221
+ .option('--json', 'Output as JSON')
222
+ .action((slug, opts) => hooksToggle(slug, false, opts));
223
+
224
+ hooks
225
+ .command('delete <slug>')
226
+ .description('Delete a hook')
227
+ .option('-p, --profile <name>', 'Profile name')
228
+ .option('--json', 'Output as JSON')
229
+ .action(hooksDelete);
230
+
127
231
  const migrate = program
128
232
  .command('migrate')
129
233
  .description('Migrate from Firebase to Globio');
@@ -135,6 +239,7 @@ migrate
135
239
  .option('--collection <name>', 'Migrate a specific collection')
136
240
  .option('--all', 'Migrate all collections')
137
241
  .option('--profile <name>', 'Use a specific profile')
242
+ .option('--json', 'Output as JSON')
138
243
  .action(migrateFirestore);
139
244
 
140
245
  migrate
@@ -145,6 +250,7 @@ migrate
145
250
  .option('--folder <path>', 'Migrate a specific folder')
146
251
  .option('--all', 'Migrate all files')
147
252
  .option('--profile <name>', 'Use a specific profile')
253
+ .option('--json', 'Output as JSON')
148
254
  .action(migrateFirebaseStorage);
149
255
 
150
256
  async function main() {
package/src/lib/table.ts CHANGED
@@ -95,3 +95,8 @@ export function header(version: string, subtitle?: string): string {
95
95
  export function footer(text: string): string {
96
96
  return '\n' + dim(' ' + text) + '\n';
97
97
  }
98
+
99
+ export function jsonOutput(data: unknown): void {
100
+ console.log(JSON.stringify(data, null, 2));
101
+ process.exit(0);
102
+ }