@globio/cli 0.2.0 → 0.2.2

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
@@ -56,72 +56,103 @@ program
56
56
  .command('login')
57
57
  .description('Log in to your Globio account')
58
58
  .option('-p, --profile <name>', 'Profile name', 'default')
59
- .option('--token', 'Use a personal access token')
59
+ .option('--token <pat>', 'Personal access token (non-interactive)')
60
+ .option('--json', 'Output as JSON')
60
61
  .action(login);
61
62
  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);
63
+ program.command('whoami').description('Show current account and project').option('--profile <name>', 'Use a specific profile').option('--json', 'Output as JSON').action(whoami);
63
64
  program.command('use <profile>').description('Switch active profile').action(useProfile);
64
65
 
65
- program.command('init').description('Initialize a Globio project').option('--profile <name>', 'Use a specific profile').action(init);
66
+ program
67
+ .command('init')
68
+ .description('Initialize a Globio project')
69
+ .option('-p, --profile <name>', 'Profile name')
70
+ .option('--name <name>', 'Project name')
71
+ .option('--slug <slug>', 'Project slug')
72
+ .option('--org <orgId>', 'Organization ID')
73
+ .option('--env <environment>', 'Environment (development|staging|production)', 'development')
74
+ .option('--no-migrate', 'Skip Firebase migration prompt')
75
+ .option('--from <path>', 'Firebase service account path (triggers migration)')
76
+ .option('--json', 'Output as JSON')
77
+ .action(init);
66
78
 
67
79
  const profiles = program
68
80
  .command('profiles')
69
81
  .description('Manage login profiles')
70
- .action(profilesList);
82
+ .option('--json', 'Output as JSON')
83
+ .action(function (this: Command) {
84
+ return profilesList(this.opts());
85
+ });
71
86
 
72
87
  profiles
73
88
  .command('list')
74
89
  .description('List all profiles')
75
- .action(profilesList);
90
+ .option('--json', 'Output as JSON')
91
+ .action(function (this: Command) {
92
+ return profilesList(this.opts());
93
+ });
76
94
 
77
95
  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);
81
-
82
- program.command('services').description('List available Globio services').option('--profile <name>', 'Use a specific profile').action(servicesList);
96
+ projects.command('list').description('List projects').option('--profile <name>', 'Use a specific profile').option('--json', 'Output as JSON').action(projectsList);
97
+ projects
98
+ .command('create')
99
+ .description('Create a project')
100
+ .option('--name <name>', 'Project name')
101
+ .option('--org <orgId>', 'Organization ID')
102
+ .option('--env <environment>', 'Environment', 'development')
103
+ .option('-p, --profile <name>', 'Profile name')
104
+ .option('--json', 'Output as JSON')
105
+ .action(projectsCreate);
106
+ projects.command('use <projectId>').description('Set active project').option('--profile <name>', 'Use a specific profile').option('--json', 'Output as JSON').action(projectsUse);
107
+
108
+ program.command('services').description('List available Globio services').option('--profile <name>', 'Use a specific profile').option('--json', 'Output as JSON').action(servicesList);
83
109
 
84
110
  const functions = program
85
111
  .command('functions')
86
112
  .alias('fn')
87
113
  .description('Manage GlobalCode edge functions');
88
114
 
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);
115
+ functions.command('list').description('List all functions').option('--profile <name>', 'Use a specific profile').option('--json', 'Output as JSON').action(functionsList);
116
+ 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
117
  functions
92
118
  .command('deploy <slug>')
93
119
  .description('Deploy a function to GlobalCode')
94
120
  .option('-f, --file <path>', 'Path to function file')
95
121
  .option('-n, --name <name>', 'Display name')
96
122
  .option('--profile <name>', 'Use a specific profile')
123
+ .option('--json', 'Output as JSON')
97
124
  .action(functionsDeploy);
98
125
  functions
99
126
  .command('invoke <slug>')
100
127
  .description('Invoke a function')
101
128
  .option('-i, --input <json>', 'JSON input payload')
102
129
  .option('--profile <name>', 'Use a specific profile')
130
+ .option('--json', 'Output as JSON')
103
131
  .action(functionsInvoke);
104
132
  functions
105
133
  .command('logs <slug>')
106
134
  .description('Show invocation history')
107
135
  .option('-l, --limit <n>', 'Number of entries', '20')
108
136
  .option('--profile <name>', 'Use a specific profile')
137
+ .option('--json', 'Output as JSON')
109
138
  .action(functionsLogs);
110
139
  functions
111
140
  .command('watch <slug>')
112
141
  .description('Stream live function execution logs')
113
142
  .option('--profile <name>', 'Use a specific profile')
114
143
  .action(functionsWatch);
115
- functions.command('delete <slug>').description('Delete a function').option('--profile <name>', 'Use a specific profile').action(functionsDelete);
144
+ functions.command('delete <slug>').description('Delete a function').option('--profile <name>', 'Use a specific profile').option('--json', 'Output as JSON').action(functionsDelete);
116
145
  functions
117
146
  .command('enable <slug>')
118
147
  .description('Enable a function')
119
148
  .option('--profile <name>', 'Use a specific profile')
149
+ .option('--json', 'Output as JSON')
120
150
  .action((slug, options) => functionsToggle(slug, true, options));
121
151
  functions
122
152
  .command('disable <slug>')
123
153
  .description('Disable a function')
124
154
  .option('--profile <name>', 'Use a specific profile')
155
+ .option('--json', 'Output as JSON')
125
156
  .action((slug, options) => functionsToggle(slug, false, options));
126
157
 
127
158
  const migrate = program
@@ -135,6 +166,7 @@ migrate
135
166
  .option('--collection <name>', 'Migrate a specific collection')
136
167
  .option('--all', 'Migrate all collections')
137
168
  .option('--profile <name>', 'Use a specific profile')
169
+ .option('--json', 'Output as JSON')
138
170
  .action(migrateFirestore);
139
171
 
140
172
  migrate
@@ -145,6 +177,7 @@ migrate
145
177
  .option('--folder <path>', 'Migrate a specific folder')
146
178
  .option('--all', 'Migrate all files')
147
179
  .option('--profile <name>', 'Use a specific profile')
180
+ .option('--json', 'Output as JSON')
148
181
  .action(migrateFirebaseStorage);
149
182
 
150
183
  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
+ }