@geekmidas/cli 1.10.20 → 1.10.22

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.
@@ -94,10 +94,12 @@ export abstract class ConstructGenerator<T extends Construct, R = void> {
94
94
  }
95
95
  }
96
96
  } catch (error) {
97
- logger.warn(`Failed to load ${f}:`, (error as Error).message);
98
- throw new Error(
99
- 'Failed to load constructs. Please check the logs for details.',
100
- );
97
+ const err = error as Error;
98
+ logger.error(`Failed to load ${f}: ${err.message}`);
99
+ if (err.stack) {
100
+ logger.error(err.stack);
101
+ }
102
+ throw error;
101
103
  }
102
104
  }
103
105
 
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ import { Command } from 'commander';
4
4
  import pkg from '../package.json';
5
5
  import { loginCommand, logoutCommand, whoamiCommand } from './auth';
6
6
  import { buildCommand } from './build/index';
7
+ import { enableDebug, formatError } from './debug';
7
8
  import { type DeployProvider, deployCommand } from './deploy/index';
8
9
  import { deployInitCommand, deployListCommand } from './deploy/init';
9
10
  import {
@@ -35,7 +36,12 @@ program
35
36
  .name('gkm')
36
37
  .description('GeekMidas backend framework CLI')
37
38
  .version(pkg.version)
38
- .option('--cwd <path>', 'Change working directory');
39
+ .option('--cwd <path>', 'Change working directory')
40
+ .option('--debug', 'Enable debug mode (verbose errors with stack traces)')
41
+ .hook('preAction', () => {
42
+ const opts = program.opts();
43
+ if (opts.debug) enableDebug();
44
+ });
39
45
 
40
46
  program
41
47
  .command('init')
@@ -58,7 +64,7 @@ program
58
64
  }
59
65
  await initCommand(name, options);
60
66
  } catch (error) {
61
- console.error(error instanceof Error ? error.message : 'Command failed');
67
+ console.error(formatError(error));
62
68
  process.exit(1);
63
69
  }
64
70
  });
@@ -78,7 +84,7 @@ program
78
84
  }
79
85
  await setupCommand(options);
80
86
  } catch (error) {
81
- console.error(error instanceof Error ? error.message : 'Command failed');
87
+ console.error(formatError(error));
82
88
  process.exit(1);
83
89
  }
84
90
  });
@@ -152,9 +158,7 @@ program
152
158
  });
153
159
  }
154
160
  } catch (error) {
155
- console.error(
156
- error instanceof Error ? error.message : 'Command failed',
157
- );
161
+ console.error(formatError(error));
158
162
  process.exit(1);
159
163
  }
160
164
  },
@@ -193,9 +197,7 @@ program
193
197
  watch: options.watch,
194
198
  });
195
199
  } catch (error) {
196
- console.error(
197
- error instanceof Error ? error.message : 'Command failed',
198
- );
200
+ console.error(formatError(error));
199
201
  process.exit(1);
200
202
  }
201
203
  },
@@ -213,7 +215,7 @@ program
213
215
  }
214
216
  await execCommand(commandArgs);
215
217
  } catch (error) {
216
- console.error(error instanceof Error ? error.message : 'Command failed');
218
+ console.error(formatError(error));
217
219
  process.exit(1);
218
220
  }
219
221
  });
@@ -235,7 +237,7 @@ program
235
237
  }
236
238
  await testCommand({ ...options, pattern });
237
239
  } catch (error) {
238
- console.error(error instanceof Error ? error.message : 'Command failed');
240
+ console.error(formatError(error));
239
241
  process.exit(1);
240
242
  }
241
243
  });
@@ -284,7 +286,7 @@ program
284
286
  }
285
287
  await openapiCommand({});
286
288
  } catch (error) {
287
- console.error(error instanceof Error ? error.message : 'Command failed');
289
+ console.error(formatError(error));
288
290
  process.exit(1);
289
291
  }
290
292
  });
@@ -308,9 +310,7 @@ program
308
310
  }
309
311
  await generateReactQueryCommand(options);
310
312
  } catch (error) {
311
- console.error(
312
- error instanceof Error ? error.message : 'Command failed',
313
- );
313
+ console.error(formatError(error));
314
314
  process.exit(1);
315
315
  }
316
316
  },
@@ -334,7 +334,7 @@ program
334
334
  }
335
335
  await dockerCommand(options);
336
336
  } catch (error) {
337
- console.error(error instanceof Error ? error.message : 'Command failed');
337
+ console.error(formatError(error));
338
338
  process.exit(1);
339
339
  }
340
340
  });
@@ -393,9 +393,7 @@ program
393
393
  const _imageRef = registry ? `${registry}/api:${tag}` : `api:${tag}`;
394
394
  }
395
395
  } catch (error) {
396
- console.error(
397
- error instanceof Error ? error.message : 'Command failed',
398
- );
396
+ console.error(formatError(error));
399
397
  process.exit(1);
400
398
  }
401
399
  },
@@ -415,7 +413,7 @@ program
415
413
  }
416
414
  await secretsInitCommand(options);
417
415
  } catch (error) {
418
- console.error(error instanceof Error ? error.message : 'Command failed');
416
+ console.error(formatError(error));
419
417
  process.exit(1);
420
418
  }
421
419
  });
@@ -439,9 +437,7 @@ program
439
437
  }
440
438
  await secretsSetCommand(key, value, options);
441
439
  } catch (error) {
442
- console.error(
443
- error instanceof Error ? error.message : 'Command failed',
444
- );
440
+ console.error(formatError(error));
445
441
  process.exit(1);
446
442
  }
447
443
  },
@@ -460,7 +456,7 @@ program
460
456
  }
461
457
  await secretsShowCommand(options);
462
458
  } catch (error) {
463
- console.error(error instanceof Error ? error.message : 'Command failed');
459
+ console.error(formatError(error));
464
460
  process.exit(1);
465
461
  }
466
462
  });
@@ -481,7 +477,7 @@ program
481
477
  }
482
478
  await secretsRotateCommand(options);
483
479
  } catch (error) {
484
- console.error(error instanceof Error ? error.message : 'Command failed');
480
+ console.error(formatError(error));
485
481
  process.exit(1);
486
482
  }
487
483
  });
@@ -500,7 +496,7 @@ program
500
496
  }
501
497
  await secretsImportCommand(file, options);
502
498
  } catch (error) {
503
- console.error(error instanceof Error ? error.message : 'Command failed');
499
+ console.error(formatError(error));
504
500
  process.exit(1);
505
501
  }
506
502
  });
@@ -542,7 +538,7 @@ program
542
538
  await pushSecrets(options.stage, workspace);
543
539
  console.log(`\n✓ Secrets pushed for stage "${options.stage}"`);
544
540
  } catch (error) {
545
- console.error(error instanceof Error ? error.message : 'Command failed');
541
+ console.error(formatError(error));
546
542
  process.exit(1);
547
543
  }
548
544
  });
@@ -585,7 +581,7 @@ program
585
581
  await writeStageSecrets(secrets, workspace.root);
586
582
  console.log(`\n✓ Secrets pulled for stage "${options.stage}"`);
587
583
  } catch (error) {
588
- console.error(error instanceof Error ? error.message : 'Command failed');
584
+ console.error(formatError(error));
589
585
  process.exit(1);
590
586
  }
591
587
  });
@@ -632,7 +628,7 @@ program
632
628
  console.log(` + ${key}`);
633
629
  }
634
630
  } catch (error) {
635
- console.error(error instanceof Error ? error.message : 'Command failed');
631
+ console.error(formatError(error));
636
632
  process.exit(1);
637
633
  }
638
634
  });
@@ -683,7 +679,7 @@ program
683
679
  skipBuild: options.skipBuild,
684
680
  });
685
681
  } catch (error) {
686
- console.error(error instanceof Error ? error.message : 'Deploy failed');
682
+ console.error(formatError(error));
687
683
  process.exit(1);
688
684
  }
689
685
  },
@@ -723,11 +719,7 @@ program
723
719
  registryId: options.registryId,
724
720
  });
725
721
  } catch (error) {
726
- console.error(
727
- error instanceof Error
728
- ? error.message
729
- : 'Failed to initialize deployment',
730
- );
722
+ console.error(formatError(error));
731
723
  process.exit(1);
732
724
  }
733
725
  },
@@ -779,9 +771,7 @@ program
779
771
  });
780
772
  }
781
773
  } catch (error) {
782
- console.error(
783
- error instanceof Error ? error.message : 'Failed to list resources',
784
- );
774
+ console.error(formatError(error));
785
775
  process.exit(1);
786
776
  }
787
777
  },
@@ -815,9 +805,7 @@ program
815
805
  endpoint: options.endpoint,
816
806
  });
817
807
  } catch (error) {
818
- console.error(
819
- error instanceof Error ? error.message : 'Failed to login',
820
- );
808
+ console.error(formatError(error));
821
809
  process.exit(1);
822
810
  }
823
811
  },
@@ -843,9 +831,7 @@ program
843
831
  service: options.service as 'dokploy' | 'all',
844
832
  });
845
833
  } catch (error) {
846
- console.error(
847
- error instanceof Error ? error.message : 'Failed to logout',
848
- );
834
+ console.error(formatError(error));
849
835
  process.exit(1);
850
836
  }
851
837
  });
@@ -863,9 +849,7 @@ program
863
849
 
864
850
  await whoamiCommand();
865
851
  } catch (error) {
866
- console.error(
867
- error instanceof Error ? error.message : 'Failed to get status',
868
- );
852
+ console.error(formatError(error));
869
853
  process.exit(1);
870
854
  }
871
855
  });
@@ -886,7 +870,7 @@ program
886
870
  }
887
871
  await statePullCommand(options);
888
872
  } catch (error) {
889
- console.error(error instanceof Error ? error.message : 'Command failed');
873
+ console.error(formatError(error));
890
874
  process.exit(1);
891
875
  }
892
876
  });
@@ -906,7 +890,7 @@ program
906
890
  }
907
891
  await statePushCommand(options);
908
892
  } catch (error) {
909
- console.error(error instanceof Error ? error.message : 'Command failed');
893
+ console.error(formatError(error));
910
894
  process.exit(1);
911
895
  }
912
896
  });
@@ -927,7 +911,7 @@ program
927
911
  }
928
912
  await stateShowCommand(options);
929
913
  } catch (error) {
930
- console.error(error instanceof Error ? error.message : 'Command failed');
914
+ console.error(formatError(error));
931
915
  process.exit(1);
932
916
  }
933
917
  });
@@ -947,7 +931,7 @@ program
947
931
  }
948
932
  await stateDiffCommand(options);
949
933
  } catch (error) {
950
- console.error(error instanceof Error ? error.message : 'Command failed');
934
+ console.error(formatError(error));
951
935
  process.exit(1);
952
936
  }
953
937
  });
@@ -964,7 +948,7 @@ program
964
948
  }
965
949
  await upgradeCommand(options);
966
950
  } catch (error) {
967
- console.error(error instanceof Error ? error.message : 'Command failed');
951
+ console.error(formatError(error));
968
952
  process.exit(1);
969
953
  }
970
954
  });
@@ -30,9 +30,9 @@ export const GEEKMIDAS_VERSIONS = {
30
30
  '@geekmidas/audit': '~2.0.0',
31
31
  '@geekmidas/auth': '~2.0.0',
32
32
  '@geekmidas/cache': '~1.1.0',
33
- '@geekmidas/client': '~4.0.0',
33
+ '@geekmidas/client': '~4.0.1',
34
34
  '@geekmidas/cloud': '~1.0.0',
35
- '@geekmidas/constructs': '~3.0.2',
35
+ '@geekmidas/constructs': '~3.0.3',
36
36
  '@geekmidas/db': '~1.0.1',
37
37
  '@geekmidas/emailkit': '~1.0.0',
38
38
  '@geekmidas/envkit': '~1.0.4',