ya-git-jira 2.1.0 → 2.1.1

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.
Files changed (87) hide show
  1. package/bin/git-api.ts +2 -4
  2. package/bin/git-bump.ts +2 -4
  3. package/bin/git-confluence-page-search.ts +4 -6
  4. package/bin/git-confluence-page-show.ts +3 -5
  5. package/bin/git-confluence-page-update.ts +3 -5
  6. package/bin/git-confluence-page.ts +2 -4
  7. package/bin/git-confluence-space-list.ts +3 -5
  8. package/bin/git-confluence-space.ts +2 -4
  9. package/bin/git-confluence-whoami.ts +3 -5
  10. package/bin/git-confluence.ts +11 -4
  11. package/bin/git-jira-issue-list.ts +2 -4
  12. package/bin/git-jira-issue-show.ts +3 -5
  13. package/bin/git-jira-issue.ts +2 -4
  14. package/bin/git-jira-start.ts +2 -4
  15. package/bin/git-jira-whoami.ts +3 -5
  16. package/bin/git-jira.ts +11 -4
  17. package/bin/git-lab-group-list.ts +4 -6
  18. package/bin/git-lab-group.ts +2 -4
  19. package/bin/git-lab-merge-active.ts +4 -6
  20. package/bin/git-lab-merge-todo.ts +4 -6
  21. package/bin/git-lab-merge-train-list.ts +3 -5
  22. package/bin/git-lab-merge-train.ts +2 -4
  23. package/bin/git-lab-merge.ts +2 -4
  24. package/bin/git-lab-namespace-list.ts +3 -5
  25. package/bin/git-lab-namespace.ts +2 -4
  26. package/bin/git-lab-project-list.ts +4 -6
  27. package/bin/git-lab-project-mr-list.ts +4 -6
  28. package/bin/git-lab-project-mr.ts +2 -4
  29. package/bin/git-lab-project-pipeline-jobs.ts +2 -4
  30. package/bin/git-lab-project-pipeline-latest.ts +2 -4
  31. package/bin/git-lab-project-pipeline-list.ts +4 -6
  32. package/bin/git-lab-project-pipeline-log.ts +2 -4
  33. package/bin/git-lab-project-pipeline.ts +2 -4
  34. package/bin/git-lab-project-whereami.ts +3 -5
  35. package/bin/git-lab-project.ts +2 -4
  36. package/bin/git-lab-whoami.ts +3 -5
  37. package/bin/git-lab.ts +11 -4
  38. package/bin/gitj-install-skills.ts +2 -4
  39. package/bin/gitj.ts +6 -1
  40. package/dist/bin/git-api.js +33 -5
  41. package/dist/bin/git-bump.js +32 -24
  42. package/dist/bin/git-confluence-page-search.js +46 -26
  43. package/dist/bin/git-confluence-page-show.js +24 -4
  44. package/dist/bin/git-confluence-page-update.js +24 -4
  45. package/dist/bin/git-confluence-page.js +30 -16
  46. package/dist/bin/git-confluence-space-list.js +45 -25
  47. package/dist/bin/git-confluence-space.js +46 -28
  48. package/dist/bin/git-confluence-whoami.js +45 -25
  49. package/dist/bin/git-confluence.js +45 -31
  50. package/dist/bin/git-jira-issue-list.js +36 -24
  51. package/dist/bin/git-jira-issue-show.js +16 -4
  52. package/dist/bin/git-jira-issue.js +18 -10
  53. package/dist/bin/git-jira-start.js +16 -4
  54. package/dist/bin/git-jira-whoami.js +37 -25
  55. package/dist/bin/git-jira.js +32 -22
  56. package/dist/bin/git-lab-group-list.js +18 -6
  57. package/dist/bin/git-lab-group.js +19 -9
  58. package/dist/bin/git-lab-merge-active.js +18 -6
  59. package/dist/bin/git-lab-merge-todo.js +18 -6
  60. package/dist/bin/git-lab-merge-train-list.js +17 -5
  61. package/dist/bin/git-lab-merge-train.js +18 -8
  62. package/dist/bin/git-lab-merge.js +25 -21
  63. package/dist/bin/git-lab-namespace-list.js +38 -26
  64. package/dist/bin/git-lab-namespace.js +39 -29
  65. package/dist/bin/git-lab-project-list.js +18 -6
  66. package/dist/bin/git-lab-project-mr-list.js +18 -6
  67. package/dist/bin/git-lab-project-mr.js +19 -9
  68. package/dist/bin/git-lab-project-pipeline-jobs.js +16 -4
  69. package/dist/bin/git-lab-project-pipeline-latest.js +16 -4
  70. package/dist/bin/git-lab-project-pipeline-list.js +18 -6
  71. package/dist/bin/git-lab-project-pipeline-log.js +16 -4
  72. package/dist/bin/git-lab-project-pipeline.js +22 -18
  73. package/dist/bin/git-lab-project-whereami.js +17 -5
  74. package/dist/bin/git-lab-project.js +32 -38
  75. package/dist/bin/git-lab-whoami.js +17 -5
  76. package/dist/bin/git-lab.js +61 -81
  77. package/dist/bin/gitj-install-skills.js +21 -11
  78. package/dist/bin/gitj.js +154 -153
  79. package/dist/index.js +32 -1
  80. package/lib/api.ts +19 -1
  81. package/lib/confluence/api.ts +12 -0
  82. package/lib/confluence/config.ts +3 -3
  83. package/lib/gitlab/api.ts +4 -0
  84. package/lib/gitlab/config.ts +2 -2
  85. package/lib/is_main.ts +11 -0
  86. package/lib/jira.ts +7 -3
  87. package/package.json +1 -1
@@ -2463,6 +2463,16 @@ function isMain(self) {
2463
2463
  const result = argv1Base === selfBase;
2464
2464
  return result;
2465
2465
  }
2466
+ async function runMain(self, create) {
2467
+ if (!isMain(self))
2468
+ return;
2469
+ try {
2470
+ await create().parseAsync(Bun.argv);
2471
+ } catch (err) {
2472
+ console.error(`error: ${err instanceof Error ? err.message : String(err)}`);
2473
+ process.exit(1);
2474
+ }
2475
+ }
2466
2476
 
2467
2477
  // lib/spawn.ts
2468
2478
  var defaultOptions = {
@@ -2512,7 +2522,7 @@ async function getGitlabConfig() {
2512
2522
  const host = await hostP || "gitlab.com";
2513
2523
  const user = await gitEmailP || await gitlabEmailP;
2514
2524
  if (!user)
2515
- throw new Error("Neither user.email nor gitlab.email in git config");
2525
+ throw new Error("Neither user.email nor gitlab.user in git config");
2516
2526
  const token = await tokenP;
2517
2527
  if (!token)
2518
2528
  throw new Error("gitlab.token not in git config");
@@ -2549,6 +2559,10 @@ async function gitlabApi(endpoint) {
2549
2559
  };
2550
2560
  let request = new Request(uri, options);
2551
2561
  const response = await fetch(request);
2562
+ if (!response.ok) {
2563
+ const text = await response.text();
2564
+ throw new Error(`GitLab API ${endpoint} failed (${response.status}): ${text}`);
2565
+ }
2552
2566
  let link = getNextLink(response.headers.get("Link"));
2553
2567
  let partial = await response.json();
2554
2568
  let result = partial;
@@ -2704,21 +2718,19 @@ function create() {
2704
2718
  program2.version(version).name("list").description("List groups for the current user").option("-v, --verbose", "Verbose output").action(async (options) => {
2705
2719
  const groups = await getGroups();
2706
2720
  if (options.verbose)
2707
- console.log(groups);
2721
+ console.log(JSON.stringify(groups, null, 2));
2708
2722
  else {
2709
2723
  const filtered = groups.map((g) => {
2710
2724
  const { id, name, full_path } = g;
2711
2725
  return { id, name, full_path };
2712
2726
  });
2713
- console.log(filtered);
2727
+ console.log(JSON.stringify(filtered, null, 2));
2714
2728
  }
2715
2729
  });
2716
2730
  return program2;
2717
2731
  }
2718
2732
  var git_lab_group_list_default = create;
2719
- if (isMain("git-lab-group-list")) {
2720
- await create().parseAsync(Bun.argv);
2721
- }
2733
+ await runMain("git-lab-group-list", create);
2722
2734
  export {
2723
2735
  git_lab_group_list_default as default,
2724
2736
  create
@@ -2463,6 +2463,16 @@ function isMain(self) {
2463
2463
  const result = argv1Base === selfBase;
2464
2464
  return result;
2465
2465
  }
2466
+ async function runMain(self, create) {
2467
+ if (!isMain(self))
2468
+ return;
2469
+ try {
2470
+ await create().parseAsync(Bun.argv);
2471
+ } catch (err) {
2472
+ console.error(`error: ${err instanceof Error ? err.message : String(err)}`);
2473
+ process.exit(1);
2474
+ }
2475
+ }
2466
2476
 
2467
2477
  // lib/spawn.ts
2468
2478
  var defaultOptions = {
@@ -2512,7 +2522,7 @@ async function getGitlabConfig() {
2512
2522
  const host = await hostP || "gitlab.com";
2513
2523
  const user = await gitEmailP || await gitlabEmailP;
2514
2524
  if (!user)
2515
- throw new Error("Neither user.email nor gitlab.email in git config");
2525
+ throw new Error("Neither user.email nor gitlab.user in git config");
2516
2526
  const token = await tokenP;
2517
2527
  if (!token)
2518
2528
  throw new Error("gitlab.token not in git config");
@@ -2549,6 +2559,10 @@ async function gitlabApi(endpoint) {
2549
2559
  };
2550
2560
  let request = new Request(uri, options);
2551
2561
  const response = await fetch(request);
2562
+ if (!response.ok) {
2563
+ const text = await response.text();
2564
+ throw new Error(`GitLab API ${endpoint} failed (${response.status}): ${text}`);
2565
+ }
2552
2566
  let link = getNextLink(response.headers.get("Link"));
2553
2567
  let partial = await response.json();
2554
2568
  let result = partial;
@@ -2704,21 +2718,19 @@ function create() {
2704
2718
  program2.version(version).name("list").description("List groups for the current user").option("-v, --verbose", "Verbose output").action(async (options) => {
2705
2719
  const groups = await getGroups();
2706
2720
  if (options.verbose)
2707
- console.log(groups);
2721
+ console.log(JSON.stringify(groups, null, 2));
2708
2722
  else {
2709
2723
  const filtered = groups.map((g) => {
2710
2724
  const { id, name, full_path } = g;
2711
2725
  return { id, name, full_path };
2712
2726
  });
2713
- console.log(filtered);
2727
+ console.log(JSON.stringify(filtered, null, 2));
2714
2728
  }
2715
2729
  });
2716
2730
  return program2;
2717
2731
  }
2718
2732
  var git_lab_group_list_default = create;
2719
- if (isMain("git-lab-group-list")) {
2720
- await create().parseAsync(Bun.argv);
2721
- }
2733
+ await runMain("git-lab-group-list", create);
2722
2734
 
2723
2735
  // bin/git-lab-group.ts
2724
2736
  var version2 = await getPackageVersion();
@@ -2728,9 +2740,7 @@ function create2() {
2728
2740
  return program2;
2729
2741
  }
2730
2742
  var git_lab_group_default = create2;
2731
- if (isMain("git-lab-group")) {
2732
- await create2().parseAsync(Bun.argv);
2733
- }
2743
+ await runMain("git-lab-group", create2);
2734
2744
  export {
2735
2745
  git_lab_group_default as default,
2736
2746
  create2 as create
@@ -2497,7 +2497,7 @@ async function getGitlabConfig() {
2497
2497
  const host = await hostP || "gitlab.com";
2498
2498
  const user = await gitEmailP || await gitlabEmailP;
2499
2499
  if (!user)
2500
- throw new Error("Neither user.email nor gitlab.email in git config");
2500
+ throw new Error("Neither user.email nor gitlab.user in git config");
2501
2501
  const token = await tokenP;
2502
2502
  if (!token)
2503
2503
  throw new Error("gitlab.token not in git config");
@@ -2534,6 +2534,10 @@ async function gitlabApi(endpoint) {
2534
2534
  };
2535
2535
  let request = new Request(uri, options);
2536
2536
  const response = await fetch(request);
2537
+ if (!response.ok) {
2538
+ const text = await response.text();
2539
+ throw new Error(`GitLab API ${endpoint} failed (${response.status}): ${text}`);
2540
+ }
2537
2541
  let link = getNextLink(response.headers.get("Link"));
2538
2542
  let partial = await response.json();
2539
2543
  let result = partial;
@@ -2696,6 +2700,16 @@ function isMain(self) {
2696
2700
  const result = argv1Base === selfBase;
2697
2701
  return result;
2698
2702
  }
2703
+ async function runMain(self, create) {
2704
+ if (!isMain(self))
2705
+ return;
2706
+ try {
2707
+ await create().parseAsync(Bun.argv);
2708
+ } catch (err) {
2709
+ console.error(`error: ${err instanceof Error ? err.message : String(err)}`);
2710
+ process.exit(1);
2711
+ }
2712
+ }
2699
2713
 
2700
2714
  // bin/git-lab-merge-active.ts
2701
2715
  var version = await getPackageVersion();
@@ -2708,22 +2722,20 @@ function create() {
2708
2722
  process.exit(1);
2709
2723
  }
2710
2724
  if (options.verbose) {
2711
- console.log(merges);
2725
+ console.log(JSON.stringify(merges, null, 2));
2712
2726
  process.exit(0);
2713
2727
  } else {
2714
2728
  const filtered = merges.map((m) => {
2715
2729
  const { title, web_url, source_branch, target_branch } = m;
2716
2730
  return { title, web_url, source_branch, target_branch };
2717
2731
  });
2718
- console.log(filtered);
2732
+ console.log(JSON.stringify(filtered, null, 2));
2719
2733
  }
2720
2734
  });
2721
2735
  return program2;
2722
2736
  }
2723
2737
  var git_lab_merge_active_default = create;
2724
- if (isMain("git-lab-merge-active")) {
2725
- await create().parseAsync(Bun.argv);
2726
- }
2738
+ await runMain("git-lab-merge-active", create);
2727
2739
  export {
2728
2740
  git_lab_merge_active_default as default,
2729
2741
  create
@@ -2497,7 +2497,7 @@ async function getGitlabConfig() {
2497
2497
  const host = await hostP || "gitlab.com";
2498
2498
  const user = await gitEmailP || await gitlabEmailP;
2499
2499
  if (!user)
2500
- throw new Error("Neither user.email nor gitlab.email in git config");
2500
+ throw new Error("Neither user.email nor gitlab.user in git config");
2501
2501
  const token = await tokenP;
2502
2502
  if (!token)
2503
2503
  throw new Error("gitlab.token not in git config");
@@ -2534,6 +2534,10 @@ async function gitlabApi(endpoint) {
2534
2534
  };
2535
2535
  let request = new Request(uri, options);
2536
2536
  const response = await fetch(request);
2537
+ if (!response.ok) {
2538
+ const text = await response.text();
2539
+ throw new Error(`GitLab API ${endpoint} failed (${response.status}): ${text}`);
2540
+ }
2537
2541
  let link = getNextLink(response.headers.get("Link"));
2538
2542
  let partial = await response.json();
2539
2543
  let result = partial;
@@ -2696,6 +2700,16 @@ function isMain(self) {
2696
2700
  const result = argv1Base === selfBase;
2697
2701
  return result;
2698
2702
  }
2703
+ async function runMain(self, create) {
2704
+ if (!isMain(self))
2705
+ return;
2706
+ try {
2707
+ await create().parseAsync(Bun.argv);
2708
+ } catch (err) {
2709
+ console.error(`error: ${err instanceof Error ? err.message : String(err)}`);
2710
+ process.exit(1);
2711
+ }
2712
+ }
2699
2713
 
2700
2714
  // bin/git-lab-merge-todo.ts
2701
2715
  var version = await getPackageVersion();
@@ -2704,21 +2718,19 @@ function create() {
2704
2718
  program2.version(version).name("todo").description("MRs needing my review").option("-v, --verbose", "Verbose output").action(async (options) => {
2705
2719
  const mrs = await getMyMergeRequestsToReview();
2706
2720
  if (options.verbose) {
2707
- console.log(mrs);
2721
+ console.log(JSON.stringify(mrs, null, 2));
2708
2722
  } else {
2709
2723
  const filtered = mrs.map((mr) => {
2710
2724
  const { title, web_url, source_branch, target_branch } = mr;
2711
2725
  return { title, web_url, source_branch, target_branch };
2712
2726
  });
2713
- console.log(filtered);
2727
+ console.log(JSON.stringify(filtered, null, 2));
2714
2728
  }
2715
2729
  });
2716
2730
  return program2;
2717
2731
  }
2718
2732
  var git_lab_merge_todo_default = create;
2719
- if (isMain("git-lab-merge-todo")) {
2720
- await create().parseAsync(Bun.argv);
2721
- }
2733
+ await runMain("git-lab-merge-todo", create);
2722
2734
  export {
2723
2735
  git_lab_merge_todo_default as default,
2724
2736
  create
@@ -2463,6 +2463,16 @@ function isMain(self) {
2463
2463
  const result = argv1Base === selfBase;
2464
2464
  return result;
2465
2465
  }
2466
+ async function runMain(self, create) {
2467
+ if (!isMain(self))
2468
+ return;
2469
+ try {
2470
+ await create().parseAsync(Bun.argv);
2471
+ } catch (err) {
2472
+ console.error(`error: ${err instanceof Error ? err.message : String(err)}`);
2473
+ process.exit(1);
2474
+ }
2475
+ }
2466
2476
 
2467
2477
  // lib/spawn.ts
2468
2478
  var defaultOptions = {
@@ -2512,7 +2522,7 @@ async function getGitlabConfig() {
2512
2522
  const host = await hostP || "gitlab.com";
2513
2523
  const user = await gitEmailP || await gitlabEmailP;
2514
2524
  if (!user)
2515
- throw new Error("Neither user.email nor gitlab.email in git config");
2525
+ throw new Error("Neither user.email nor gitlab.user in git config");
2516
2526
  const token = await tokenP;
2517
2527
  if (!token)
2518
2528
  throw new Error("gitlab.token not in git config");
@@ -2549,6 +2559,10 @@ async function gitlabApi(endpoint) {
2549
2559
  };
2550
2560
  let request = new Request(uri, options);
2551
2561
  const response = await fetch(request);
2562
+ if (!response.ok) {
2563
+ const text = await response.text();
2564
+ throw new Error(`GitLab API ${endpoint} failed (${response.status}): ${text}`);
2565
+ }
2552
2566
  let link = getNextLink(response.headers.get("Link"));
2553
2567
  let partial = await response.json();
2554
2568
  let result = partial;
@@ -2646,14 +2660,12 @@ function create() {
2646
2660
  const program2 = new Command;
2647
2661
  program2.version(version).name("list").description("List merge trains for the current project").action(async () => {
2648
2662
  const trains = await getMergeTrains();
2649
- console.log(trains);
2663
+ console.log(JSON.stringify(trains, null, 2));
2650
2664
  });
2651
2665
  return program2;
2652
2666
  }
2653
2667
  var git_lab_merge_train_list_default = create;
2654
- if (isMain("git-lab-merge-train-list")) {
2655
- await create().parseAsync(Bun.argv);
2656
- }
2668
+ await runMain("git-lab-merge-train-list", create);
2657
2669
  export {
2658
2670
  git_lab_merge_train_list_default as default,
2659
2671
  create
@@ -2463,6 +2463,16 @@ function isMain(self) {
2463
2463
  const result = argv1Base === selfBase;
2464
2464
  return result;
2465
2465
  }
2466
+ async function runMain(self, create) {
2467
+ if (!isMain(self))
2468
+ return;
2469
+ try {
2470
+ await create().parseAsync(Bun.argv);
2471
+ } catch (err) {
2472
+ console.error(`error: ${err instanceof Error ? err.message : String(err)}`);
2473
+ process.exit(1);
2474
+ }
2475
+ }
2466
2476
 
2467
2477
  // lib/spawn.ts
2468
2478
  var defaultOptions = {
@@ -2512,7 +2522,7 @@ async function getGitlabConfig() {
2512
2522
  const host = await hostP || "gitlab.com";
2513
2523
  const user = await gitEmailP || await gitlabEmailP;
2514
2524
  if (!user)
2515
- throw new Error("Neither user.email nor gitlab.email in git config");
2525
+ throw new Error("Neither user.email nor gitlab.user in git config");
2516
2526
  const token = await tokenP;
2517
2527
  if (!token)
2518
2528
  throw new Error("gitlab.token not in git config");
@@ -2549,6 +2559,10 @@ async function gitlabApi(endpoint) {
2549
2559
  };
2550
2560
  let request = new Request(uri, options);
2551
2561
  const response = await fetch(request);
2562
+ if (!response.ok) {
2563
+ const text = await response.text();
2564
+ throw new Error(`GitLab API ${endpoint} failed (${response.status}): ${text}`);
2565
+ }
2552
2566
  let link = getNextLink(response.headers.get("Link"));
2553
2567
  let partial = await response.json();
2554
2568
  let result = partial;
@@ -2646,14 +2660,12 @@ function create() {
2646
2660
  const program2 = new Command;
2647
2661
  program2.version(version).name("list").description("List merge trains for the current project").action(async () => {
2648
2662
  const trains = await getMergeTrains();
2649
- console.log(trains);
2663
+ console.log(JSON.stringify(trains, null, 2));
2650
2664
  });
2651
2665
  return program2;
2652
2666
  }
2653
2667
  var git_lab_merge_train_list_default = create;
2654
- if (isMain("git-lab-merge-train-list")) {
2655
- await create().parseAsync(Bun.argv);
2656
- }
2668
+ await runMain("git-lab-merge-train-list", create);
2657
2669
 
2658
2670
  // bin/git-lab-merge-train.ts
2659
2671
  var version2 = await getPackageVersion();
@@ -2663,9 +2675,7 @@ function create2() {
2663
2675
  return program2;
2664
2676
  }
2665
2677
  var git_lab_merge_train_default = create2;
2666
- if (isMain("git-lab-merge-train")) {
2667
- await create2().parseAsync(Bun.argv);
2668
- }
2678
+ await runMain("git-lab-merge-train", create2);
2669
2679
  export {
2670
2680
  git_lab_merge_train_default as default,
2671
2681
  create2 as create
@@ -2497,7 +2497,7 @@ async function getGitlabConfig() {
2497
2497
  const host = await hostP || "gitlab.com";
2498
2498
  const user = await gitEmailP || await gitlabEmailP;
2499
2499
  if (!user)
2500
- throw new Error("Neither user.email nor gitlab.email in git config");
2500
+ throw new Error("Neither user.email nor gitlab.user in git config");
2501
2501
  const token = await tokenP;
2502
2502
  if (!token)
2503
2503
  throw new Error("gitlab.token not in git config");
@@ -2534,6 +2534,10 @@ async function gitlabApi(endpoint) {
2534
2534
  };
2535
2535
  let request = new Request(uri, options);
2536
2536
  const response = await fetch(request);
2537
+ if (!response.ok) {
2538
+ const text = await response.text();
2539
+ throw new Error(`GitLab API ${endpoint} failed (${response.status}): ${text}`);
2540
+ }
2537
2541
  let link = getNextLink(response.headers.get("Link"));
2538
2542
  let partial = await response.json();
2539
2543
  let result = partial;
@@ -2696,6 +2700,16 @@ function isMain(self) {
2696
2700
  const result = argv1Base === selfBase;
2697
2701
  return result;
2698
2702
  }
2703
+ async function runMain(self, create) {
2704
+ if (!isMain(self))
2705
+ return;
2706
+ try {
2707
+ await create().parseAsync(Bun.argv);
2708
+ } catch (err) {
2709
+ console.error(`error: ${err instanceof Error ? err.message : String(err)}`);
2710
+ process.exit(1);
2711
+ }
2712
+ }
2699
2713
 
2700
2714
  // bin/git-lab-merge-active.ts
2701
2715
  var version = await getPackageVersion();
@@ -2708,22 +2722,20 @@ function create() {
2708
2722
  process.exit(1);
2709
2723
  }
2710
2724
  if (options.verbose) {
2711
- console.log(merges);
2725
+ console.log(JSON.stringify(merges, null, 2));
2712
2726
  process.exit(0);
2713
2727
  } else {
2714
2728
  const filtered = merges.map((m) => {
2715
2729
  const { title, web_url, source_branch, target_branch } = m;
2716
2730
  return { title, web_url, source_branch, target_branch };
2717
2731
  });
2718
- console.log(filtered);
2732
+ console.log(JSON.stringify(filtered, null, 2));
2719
2733
  }
2720
2734
  });
2721
2735
  return program2;
2722
2736
  }
2723
2737
  var git_lab_merge_active_default = create;
2724
- if (isMain("git-lab-merge-active")) {
2725
- await create().parseAsync(Bun.argv);
2726
- }
2738
+ await runMain("git-lab-merge-active", create);
2727
2739
 
2728
2740
  // bin/git-lab-merge-todo.ts
2729
2741
  var version2 = await getPackageVersion();
@@ -2732,21 +2744,19 @@ function create2() {
2732
2744
  program2.version(version2).name("todo").description("MRs needing my review").option("-v, --verbose", "Verbose output").action(async (options) => {
2733
2745
  const mrs = await getMyMergeRequestsToReview();
2734
2746
  if (options.verbose) {
2735
- console.log(mrs);
2747
+ console.log(JSON.stringify(mrs, null, 2));
2736
2748
  } else {
2737
2749
  const filtered = mrs.map((mr) => {
2738
2750
  const { title, web_url, source_branch, target_branch } = mr;
2739
2751
  return { title, web_url, source_branch, target_branch };
2740
2752
  });
2741
- console.log(filtered);
2753
+ console.log(JSON.stringify(filtered, null, 2));
2742
2754
  }
2743
2755
  });
2744
2756
  return program2;
2745
2757
  }
2746
2758
  var git_lab_merge_todo_default = create2;
2747
- if (isMain("git-lab-merge-todo")) {
2748
- await create2().parseAsync(Bun.argv);
2749
- }
2759
+ await runMain("git-lab-merge-todo", create2);
2750
2760
 
2751
2761
  // lib/gitlab/merge-trains.ts
2752
2762
  async function getMergeTrains() {
@@ -2759,14 +2769,12 @@ function create3() {
2759
2769
  const program2 = new Command;
2760
2770
  program2.version(version3).name("list").description("List merge trains for the current project").action(async () => {
2761
2771
  const trains = await getMergeTrains();
2762
- console.log(trains);
2772
+ console.log(JSON.stringify(trains, null, 2));
2763
2773
  });
2764
2774
  return program2;
2765
2775
  }
2766
2776
  var git_lab_merge_train_list_default = create3;
2767
- if (isMain("git-lab-merge-train-list")) {
2768
- await create3().parseAsync(Bun.argv);
2769
- }
2777
+ await runMain("git-lab-merge-train-list", create3);
2770
2778
 
2771
2779
  // bin/git-lab-merge-train.ts
2772
2780
  var version4 = await getPackageVersion();
@@ -2776,9 +2784,7 @@ function create4() {
2776
2784
  return program2;
2777
2785
  }
2778
2786
  var git_lab_merge_train_default = create4;
2779
- if (isMain("git-lab-merge-train")) {
2780
- await create4().parseAsync(Bun.argv);
2781
- }
2787
+ await runMain("git-lab-merge-train", create4);
2782
2788
 
2783
2789
  // bin/git-lab-merge.ts
2784
2790
  var version5 = await getPackageVersion();
@@ -2788,9 +2794,7 @@ function create5() {
2788
2794
  return program2;
2789
2795
  }
2790
2796
  var git_lab_merge_default = create5;
2791
- if (isMain("git-lab-merge")) {
2792
- await create5().parseAsync(Bun.argv);
2793
- }
2797
+ await runMain("git-lab-merge", create5);
2794
2798
  export {
2795
2799
  git_lab_merge_default as default,
2796
2800
  create5 as create
@@ -600,7 +600,7 @@ var require_command = __commonJS((exports) => {
600
600
  var childProcess = __require("child_process");
601
601
  var path = __require("path");
602
602
  var fs = __require("fs");
603
- var process = __require("process");
603
+ var process2 = __require("process");
604
604
  var { Argument, humanReadableArgName } = require_argument();
605
605
  var { CommanderError } = require_error();
606
606
  var { Help } = require_help();
@@ -641,10 +641,10 @@ var require_command = __commonJS((exports) => {
641
641
  this._showHelpAfterError = false;
642
642
  this._showSuggestionAfterError = true;
643
643
  this._outputConfiguration = {
644
- writeOut: (str) => process.stdout.write(str),
645
- writeErr: (str) => process.stderr.write(str),
646
- getOutHelpWidth: () => process.stdout.isTTY ? process.stdout.columns : undefined,
647
- getErrHelpWidth: () => process.stderr.isTTY ? process.stderr.columns : undefined,
644
+ writeOut: (str) => process2.stdout.write(str),
645
+ writeErr: (str) => process2.stderr.write(str),
646
+ getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : undefined,
647
+ getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : undefined,
648
648
  outputError: (str, write) => write(str)
649
649
  };
650
650
  this._hidden = false;
@@ -826,7 +826,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
826
826
  if (this._exitCallback) {
827
827
  this._exitCallback(new CommanderError(exitCode, code, message));
828
828
  }
829
- process.exit(exitCode);
829
+ process2.exit(exitCode);
830
830
  }
831
831
  action(fn) {
832
832
  const listener = (args) => {
@@ -991,8 +991,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
991
991
  }
992
992
  parseOptions = parseOptions || {};
993
993
  if (argv === undefined) {
994
- argv = process.argv;
995
- if (process.versions && process.versions.electron) {
994
+ argv = process2.argv;
995
+ if (process2.versions && process2.versions.electron) {
996
996
  parseOptions.from = "electron";
997
997
  }
998
998
  }
@@ -1005,7 +1005,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1005
1005
  userArgs = argv.slice(2);
1006
1006
  break;
1007
1007
  case "electron":
1008
- if (process.defaultApp) {
1008
+ if (process2.defaultApp) {
1009
1009
  this._scriptPath = argv[1];
1010
1010
  userArgs = argv.slice(2);
1011
1011
  } else {
@@ -1073,23 +1073,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
1073
1073
  }
1074
1074
  launchWithNode = sourceExt.includes(path.extname(executableFile));
1075
1075
  let proc;
1076
- if (process.platform !== "win32") {
1076
+ if (process2.platform !== "win32") {
1077
1077
  if (launchWithNode) {
1078
1078
  args.unshift(executableFile);
1079
- args = incrementNodeInspectorPort(process.execArgv).concat(args);
1080
- proc = childProcess.spawn(process.argv[0], args, { stdio: "inherit" });
1079
+ args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1080
+ proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" });
1081
1081
  } else {
1082
1082
  proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
1083
1083
  }
1084
1084
  } else {
1085
1085
  args.unshift(executableFile);
1086
- args = incrementNodeInspectorPort(process.execArgv).concat(args);
1087
- proc = childProcess.spawn(process.execPath, args, { stdio: "inherit" });
1086
+ args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1087
+ proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" });
1088
1088
  }
1089
1089
  if (!proc.killed) {
1090
1090
  const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
1091
1091
  signals.forEach((signal) => {
1092
- process.on(signal, () => {
1092
+ process2.on(signal, () => {
1093
1093
  if (proc.killed === false && proc.exitCode === null) {
1094
1094
  proc.kill(signal);
1095
1095
  }
@@ -1098,10 +1098,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
1098
1098
  }
1099
1099
  const exitCallback = this._exitCallback;
1100
1100
  if (!exitCallback) {
1101
- proc.on("close", process.exit.bind(process));
1101
+ proc.on("close", process2.exit.bind(process2));
1102
1102
  } else {
1103
1103
  proc.on("close", () => {
1104
- exitCallback(new CommanderError(process.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
1104
+ exitCallback(new CommanderError(process2.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
1105
1105
  });
1106
1106
  }
1107
1107
  proc.on("error", (err) => {
@@ -1116,7 +1116,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1116
1116
  throw new Error(`'${executableFile}' not executable`);
1117
1117
  }
1118
1118
  if (!exitCallback) {
1119
- process.exit(1);
1119
+ process2.exit(1);
1120
1120
  } else {
1121
1121
  const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
1122
1122
  wrappedError.nestedError = err;
@@ -1471,11 +1471,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1471
1471
  }
1472
1472
  _parseOptionsEnv() {
1473
1473
  this.options.forEach((option) => {
1474
- if (option.envVar && option.envVar in process.env) {
1474
+ if (option.envVar && option.envVar in process2.env) {
1475
1475
  const optionKey = option.attributeName();
1476
1476
  if (this.getOptionValue(optionKey) === undefined || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
1477
1477
  if (option.required || option.optional) {
1478
- this.emit(`optionEnv:${option.name()}`, process.env[option.envVar]);
1478
+ this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
1479
1479
  } else {
1480
1480
  this.emit(`optionEnv:${option.name()}`);
1481
1481
  }
@@ -1702,7 +1702,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1702
1702
  }
1703
1703
  help(contextOptions) {
1704
1704
  this.outputHelp(contextOptions);
1705
- let exitCode = process.exitCode || 0;
1705
+ let exitCode = process2.exitCode || 0;
1706
1706
  if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
1707
1707
  exitCode = 1;
1708
1708
  }
@@ -1853,6 +1853,16 @@ function isMain(self) {
1853
1853
  const result = argv1Base === selfBase;
1854
1854
  return result;
1855
1855
  }
1856
+ async function runMain(self, create) {
1857
+ if (!isMain(self))
1858
+ return;
1859
+ try {
1860
+ await create().parseAsync(Bun.argv);
1861
+ } catch (err) {
1862
+ console.error(`error: ${err instanceof Error ? err.message : String(err)}`);
1863
+ process.exit(1);
1864
+ }
1865
+ }
1856
1866
 
1857
1867
  // lib/spawn.ts
1858
1868
  var defaultOptions = {
@@ -1902,7 +1912,7 @@ async function getGitlabConfig() {
1902
1912
  const host = await hostP || "gitlab.com";
1903
1913
  const user = await gitEmailP || await gitlabEmailP;
1904
1914
  if (!user)
1905
- throw new Error("Neither user.email nor gitlab.email in git config");
1915
+ throw new Error("Neither user.email nor gitlab.user in git config");
1906
1916
  const token = await tokenP;
1907
1917
  if (!token)
1908
1918
  throw new Error("gitlab.token not in git config");
@@ -1939,6 +1949,10 @@ async function gitlabApi(endpoint) {
1939
1949
  };
1940
1950
  let request = new Request(uri, options);
1941
1951
  const response = await fetch(request);
1952
+ if (!response.ok) {
1953
+ const text = await response.text();
1954
+ throw new Error(`GitLab API ${endpoint} failed (${response.status}): ${text}`);
1955
+ }
1942
1956
  let link = getNextLink(response.headers.get("Link"));
1943
1957
  let partial = await response.json();
1944
1958
  let result = partial;
@@ -1963,14 +1977,12 @@ function create() {
1963
1977
  const program2 = new Command;
1964
1978
  program2.version(version).name("list").description("List namespaces for the current user").action(async () => {
1965
1979
  const namespaces = await getNamespaces();
1966
- console.log(namespaces);
1980
+ console.log(JSON.stringify(namespaces, null, 2));
1967
1981
  });
1968
1982
  return program2;
1969
1983
  }
1970
1984
  var git_lab_namespace_list_default = create;
1971
- if (isMain("git-lab-namespace-list")) {
1972
- await create().parseAsync(Bun.argv);
1973
- }
1985
+ await runMain("git-lab-namespace-list", create);
1974
1986
  export {
1975
1987
  git_lab_namespace_list_default as default,
1976
1988
  create