Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit 7ea916e

Browse files
flyingrobotsclaude
andcommitted
fix(cli): Properly handle errors and fix lint issues
- Add error logging to all catch blocks for better debugging - Log error.message before exiting to provide context - Remove unused 'options' parameters from commands without options - Use _options prefix for commands that receive but don't use options - Ensure all errors are properly surfaced to users Now all lint checks pass and errors provide useful debugging info. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 14ac35e commit 7ea916e

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

starfleet/data-cli/src/index.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ async function cli(argv) {
125125
await command.execute();
126126
} catch (error) {
127127
if (!program.opts().json) {
128+
console.error('Command failed:', error.message);
128129
process.exit(1);
129130
}
130131
}
@@ -137,7 +138,7 @@ async function cli(argv) {
137138

138139
db.command('reset')
139140
.description('Reset the local database')
140-
.action(async (options) => {
141+
.action(async () => {
141142
const parentOpts = program.opts();
142143
const { default: ResetCommand } = await import('./commands/db/ResetCommand.js');
143144
const { default: CliReporter } = await import('./reporters/CliReporter.js');
@@ -158,6 +159,7 @@ async function cli(argv) {
158159
await command.execute();
159160
} catch (error) {
160161
if (!parentOpts.json) {
162+
console.error('Command failed:', error.message);
161163
process.exit(1);
162164
}
163165
}
@@ -185,6 +187,7 @@ async function cli(argv) {
185187
await command.execute(sql, options.file);
186188
} catch (error) {
187189
if (!parentOpts.json) {
190+
console.error('Command failed:', error.message);
188191
process.exit(1);
189192
}
190193
}
@@ -222,6 +225,7 @@ async function cli(argv) {
222225
await command.execute(compileOptions);
223226
} catch (error) {
224227
if (!parentOpts.json) {
228+
console.error('Command failed:', error.message);
225229
process.exit(1);
226230
}
227231
}
@@ -274,6 +278,7 @@ async function cli(argv) {
274278
await command.execute(args);
275279
} catch (error) {
276280
if (!parentOpts.json) {
281+
console.error('Command failed:', error.message);
277282
process.exit(1);
278283
}
279284
}
@@ -300,6 +305,7 @@ async function cli(argv) {
300305
await command.execute(options);
301306
} catch (error) {
302307
if (!parentOpts.json) {
308+
console.error('Command failed:', error.message);
303309
process.exit(1);
304310
}
305311
}
@@ -328,14 +334,15 @@ async function cli(argv) {
328334
await command.execute(functionNames, options);
329335
} catch (error) {
330336
if (!parentOpts.json) {
337+
console.error('Command failed:', error.message);
331338
process.exit(1);
332339
}
333340
}
334341
});
335342

336343
functions.command('validate [functions...]')
337344
.description('Validate Edge Functions without deploying')
338-
.action(async (functionNames, options) => {
345+
.action(async (functionNames, _options) => {
339346
const parentOpts = program.opts();
340347
const { ValidateCommand } = await import('./commands/functions/index.js');
341348
const { default: CliReporter } = await import('./reporters/CliReporter.js');
@@ -353,14 +360,15 @@ async function cli(argv) {
353360
await command.execute(functionNames);
354361
} catch (error) {
355362
if (!parentOpts.json) {
363+
console.error('Command failed:', error.message);
356364
process.exit(1);
357365
}
358366
}
359367
});
360368

361369
functions.command('status [functions...]')
362370
.description('Show Edge Functions deployment status')
363-
.action(async (functionNames, options) => {
371+
.action(async (functionNames, _options) => {
364372
const parentOpts = program.opts();
365373
const { StatusCommand } = await import('./commands/functions/index.js');
366374
const { default: CliReporter } = await import('./reporters/CliReporter.js');
@@ -373,6 +381,7 @@ async function cli(argv) {
373381
await command.execute(functionNames);
374382
} catch (error) {
375383
if (!parentOpts.json) {
384+
console.error('Command failed:', error.message);
376385
process.exit(1);
377386
}
378387
}
@@ -385,7 +394,7 @@ async function cli(argv) {
385394

386395
test.command('compile')
387396
.description('Compile tests for execution')
388-
.action(async (options) => {
397+
.action(async () => {
389398
const parentOpts = program.opts();
390399
const { CompileCommand } = await import('./commands/test/index.js');
391400
const { default: CliReporter } = await import('./reporters/CliReporter.js');
@@ -403,6 +412,7 @@ async function cli(argv) {
403412
await command.execute();
404413
} catch (error) {
405414
if (!parentOpts.json) {
415+
console.error('Command failed:', error.message);
406416
process.exit(1);
407417
}
408418
}
@@ -445,6 +455,7 @@ async function cli(argv) {
445455
}
446456
} catch (error) {
447457
if (!parentOpts.json) {
458+
console.error('Command failed:', error.message);
448459
process.exit(1);
449460
}
450461
}
@@ -485,6 +496,7 @@ async function cli(argv) {
485496
}
486497
} catch (error) {
487498
if (!parentOpts.json) {
499+
console.error('Command failed:', error.message);
488500
process.exit(1);
489501
}
490502
}
@@ -518,6 +530,7 @@ async function cli(argv) {
518530
await command.execute(options);
519531
} catch (error) {
520532
if (!parentOpts.json) {
533+
console.error('Command failed:', error.message);
521534
process.exit(1);
522535
}
523536
}
@@ -547,6 +560,7 @@ async function cli(argv) {
547560
await command.execute(options);
548561
} catch (error) {
549562
if (!parentOpts.json) {
563+
console.error('Command failed:', error.message);
550564
process.exit(1);
551565
}
552566
}
@@ -575,6 +589,7 @@ async function cli(argv) {
575589
await command.execute(options);
576590
} catch (error) {
577591
if (!parentOpts.json) {
592+
console.error('Command failed:', error.message);
578593
process.exit(1);
579594
}
580595
}
@@ -615,6 +630,7 @@ async function cli(argv) {
615630
await command.execute({ type: testType, name: testName });
616631
} catch (error) {
617632
if (!parentOpts.json) {
633+
console.error('Command failed:', error.message);
618634
process.exit(1);
619635
}
620636
}
@@ -648,6 +664,7 @@ async function cli(argv) {
648664
await command.execute(options);
649665
} catch (error) {
650666
if (!parentOpts.json) {
667+
console.error('Command failed:', error.message);
651668
process.exit(1);
652669
}
653670
}
@@ -677,6 +694,7 @@ async function cli(argv) {
677694
await command.execute(options);
678695
} catch (error) {
679696
// CI commands always exit with proper codes
697+
console.error('CI command failed:', error.message);
680698
process.exit(1);
681699
}
682700
});
@@ -711,6 +729,7 @@ async function cli(argv) {
711729
const exitCode = command.getExitCode(results);
712730
process.exit(exitCode);
713731
} catch (error) {
732+
console.error('CI command failed:', error.message);
714733
process.exit(1);
715734
}
716735
});
@@ -740,6 +759,7 @@ async function cli(argv) {
740759
await command.execute(options);
741760
// CI coverage command handles its own exit codes via process.exitCode
742761
} catch (error) {
762+
console.error('CI command failed:', error.message);
743763
process.exit(1);
744764
}
745765
});

0 commit comments

Comments
 (0)