@chidchanun/bcp 0.1.21 → 0.1.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.
@@ -71,6 +71,20 @@ switch (cliOptions.command) {
71
71
  break;
72
72
  }
73
73
 
74
+ case "doctor": {
75
+ await runDeveloperCommand(
76
+ "doctor"
77
+ );
78
+ break;
79
+ }
80
+
81
+ case "inspect": {
82
+ await runDeveloperCommand(
83
+ "inspect"
84
+ );
85
+ break;
86
+ }
87
+
74
88
  case "help": {
75
89
  printHelp();
76
90
  break;
@@ -466,6 +480,59 @@ async function runDatabaseCommand() {
466
480
  }
467
481
  }
468
482
 
483
+ async function runDeveloperCommand(
484
+ command:
485
+ "doctor" |
486
+ "inspect"
487
+ ): Promise<void> {
488
+ const rootDirectory =
489
+ resolveProjectRoot(
490
+ cliOptions.rootDirectory
491
+ );
492
+
493
+ const {
494
+ runDoctor,
495
+ runInspect,
496
+ } =
497
+ await import(
498
+ "./developer-tools.js"
499
+ );
500
+
501
+ const options = {
502
+ rootDirectory,
503
+ frameworkVersion:
504
+ FRAMEWORK_VERSION,
505
+ json:
506
+ cliOptions.json,
507
+ };
508
+
509
+ if (
510
+ command === "doctor"
511
+ ) {
512
+ await runDoctor(
513
+ options
514
+ );
515
+ return;
516
+ }
517
+
518
+ try {
519
+ await runInspect(
520
+ options
521
+ );
522
+ } catch (error) {
523
+ if (
524
+ cliOptions.json &&
525
+ error instanceof Error &&
526
+ error.name ===
527
+ "DeveloperToolJsonError"
528
+ ) {
529
+ return;
530
+ }
531
+
532
+ throw error;
533
+ }
534
+ }
535
+
469
536
  function installShutdownHandlers(
470
537
  server: {
471
538
  stop(): Promise<void>;
@@ -642,6 +709,8 @@ Commands:
642
709
  routes Print discovered page and API routes
643
710
  update [target] Update BCP Framework (default target: latest)
644
711
  db <command> Manage database migrations
712
+ doctor Run project/runtime health diagnostics
713
+ inspect Print resolved env, config, dependencies and routes
645
714
  help Show this help message
646
715
  version Show framework version
647
716
 
@@ -652,6 +721,7 @@ Options:
652
721
  --host <host> Alias for --hostname
653
722
  --check Check for a BCP update without changing files
654
723
  --dry-run Preview a BCP update without changing files
724
+ --json JSON output for doctor/inspect
655
725
  -h, --help Show help
656
726
  -v, --version Show version
657
727
 
@@ -664,6 +734,10 @@ Examples:
664
734
  bcp build
665
735
  bcp start
666
736
  bcp routes
737
+ bcp doctor
738
+ bcp doctor --json
739
+ bcp inspect
740
+ bcp inspect --json
667
741
  bcp update
668
742
  bcp update --check
669
743
  bcp db create create_users