@pilatos/bitbucket-cli 1.5.0 → 1.7.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 (3) hide show
  1. package/README.md +35 -166
  2. package/dist/index.js +1203 -766
  3. package/package.json +8 -1
package/dist/index.js CHANGED
@@ -10901,6 +10901,17 @@ var require_db = __commonJS((exports, module) => {
10901
10901
  };
10902
10902
  });
10903
10903
 
10904
+ // node_modules/mime-db/index.js
10905
+ var require_mime_db = __commonJS((exports, module) => {
10906
+ /*!
10907
+ * mime-db
10908
+ * Copyright(c) 2014 Jonathan Ong
10909
+ * Copyright(c) 2015-2022 Douglas Christopher Wilson
10910
+ * MIT Licensed
10911
+ */
10912
+ module.exports = require_db();
10913
+ });
10914
+
10904
10915
  // node_modules/mime-types/index.js
10905
10916
  var require_mime_types = __commonJS((exports) => {
10906
10917
  /*!
@@ -10909,7 +10920,7 @@ var require_mime_types = __commonJS((exports) => {
10909
10920
  * Copyright(c) 2015 Douglas Christopher Wilson
10910
10921
  * MIT Licensed
10911
10922
  */
10912
- var db = require_db();
10923
+ var db = require_mime_db();
10913
10924
  var extname = __require("path").extname;
10914
10925
  var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
10915
10926
  var TEXT_TYPE_REGEXP = /^text\//i;
@@ -11256,7 +11267,7 @@ var require_round = __commonJS((exports, module) => {
11256
11267
 
11257
11268
  // node_modules/math-intrinsics/isNaN.js
11258
11269
  var require_isNaN = __commonJS((exports, module) => {
11259
- module.exports = Number.isNaN || function isNaN2(a) {
11270
+ module.exports = Number.isNaN || function isNaN(a) {
11260
11271
  return a !== a;
11261
11272
  };
11262
11273
  });
@@ -11390,7 +11401,7 @@ var require_implementation = __commonJS((exports, module) => {
11390
11401
  var toStr = Object.prototype.toString;
11391
11402
  var max = Math.max;
11392
11403
  var funcType = "[object Function]";
11393
- var concatty = function concatty2(a, b) {
11404
+ var concatty = function concatty(a, b) {
11394
11405
  var arr = [];
11395
11406
  for (var i = 0;i < a.length; i += 1) {
11396
11407
  arr[i] = a[i];
@@ -11400,7 +11411,7 @@ var require_implementation = __commonJS((exports, module) => {
11400
11411
  }
11401
11412
  return arr;
11402
11413
  };
11403
- var slicy = function slicy2(arrLike, offset) {
11414
+ var slicy = function slicy(arrLike, offset) {
11404
11415
  var arr = [];
11405
11416
  for (var i = offset || 0, j = 0;i < arrLike.length; i += 1, j += 1) {
11406
11417
  arr[j] = arrLike[i];
@@ -11417,7 +11428,7 @@ var require_implementation = __commonJS((exports, module) => {
11417
11428
  }
11418
11429
  return str;
11419
11430
  };
11420
- module.exports = function bind2(that) {
11431
+ module.exports = function bind(that) {
11421
11432
  var target = this;
11422
11433
  if (typeof target !== "function" || toStr.apply(target) !== funcType) {
11423
11434
  throw new TypeError(ERROR_MESSAGE + target);
@@ -11441,7 +11452,7 @@ var require_implementation = __commonJS((exports, module) => {
11441
11452
  }
11442
11453
  bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
11443
11454
  if (target.prototype) {
11444
- var Empty = function Empty2() {};
11455
+ var Empty = function Empty() {};
11445
11456
  Empty.prototype = target.prototype;
11446
11457
  bound.prototype = new Empty;
11447
11458
  Empty.prototype = null;
@@ -11680,7 +11691,7 @@ var require_get_intrinsic = __commonJS((exports, module) => {
11680
11691
  }
11681
11692
  }
11682
11693
  var errorProto;
11683
- var doEval = function doEval2(name) {
11694
+ var doEval = function doEval(name) {
11684
11695
  var value;
11685
11696
  if (name === "%AsyncFunction%") {
11686
11697
  value = getEvalledConstructor("async function () {}");
@@ -11689,12 +11700,12 @@ var require_get_intrinsic = __commonJS((exports, module) => {
11689
11700
  } else if (name === "%AsyncGeneratorFunction%") {
11690
11701
  value = getEvalledConstructor("async function* () {}");
11691
11702
  } else if (name === "%AsyncGenerator%") {
11692
- var fn = doEval2("%AsyncGeneratorFunction%");
11703
+ var fn = doEval("%AsyncGeneratorFunction%");
11693
11704
  if (fn) {
11694
11705
  value = fn.prototype;
11695
11706
  }
11696
11707
  } else if (name === "%AsyncIteratorPrototype%") {
11697
- var gen = doEval2("%AsyncGenerator%");
11708
+ var gen = doEval("%AsyncGenerator%");
11698
11709
  if (gen && getProto) {
11699
11710
  value = getProto(gen.prototype);
11700
11711
  }
@@ -11765,7 +11776,7 @@ var require_get_intrinsic = __commonJS((exports, module) => {
11765
11776
  var $exec = bind2.call($call, RegExp.prototype.exec);
11766
11777
  var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
11767
11778
  var reEscapeChar = /\\(\\)?/g;
11768
- var stringToPath = function stringToPath2(string) {
11779
+ var stringToPath = function stringToPath(string) {
11769
11780
  var first = $strSlice(string, 0, 1);
11770
11781
  var last = $strSlice(string, -1);
11771
11782
  if (first === "%" && last !== "%") {
@@ -11779,7 +11790,7 @@ var require_get_intrinsic = __commonJS((exports, module) => {
11779
11790
  });
11780
11791
  return result;
11781
11792
  };
11782
- var getBaseIntrinsic = function getBaseIntrinsic2(name, allowMissing) {
11793
+ var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
11783
11794
  var intrinsicName = name;
11784
11795
  var alias;
11785
11796
  if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
@@ -15954,7 +15965,7 @@ var require_lodash = __commonJS((exports, module) => {
15954
15965
  function unicodeWords(string) {
15955
15966
  return string.match(reUnicodeWord) || [];
15956
15967
  }
15957
- var runInContext = function runInContext2(context) {
15968
+ var runInContext = function runInContext(context) {
15958
15969
  context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
15959
15970
  var { Array: Array2, Date: Date2, Error: Error2, Function: Function2, Math: Math2, Object: Object2, RegExp: RegExp2, String: String2, TypeError: TypeError2 } = context;
15960
15971
  var arrayProto = Array2.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
@@ -20467,7 +20478,7 @@ __p += '`;
20467
20478
  lodash.replace = replace;
20468
20479
  lodash.result = result;
20469
20480
  lodash.round = round;
20470
- lodash.runInContext = runInContext2;
20481
+ lodash.runInContext = runInContext;
20471
20482
  lodash.sample = sample2;
20472
20483
  lodash.size = size;
20473
20484
  lodash.snakeCase = snakeCase;
@@ -29121,7 +29132,7 @@ var require_multicast = __commonJS((exports) => {
29121
29132
  if (typeof subjectOrSubjectFactory === "function") {
29122
29133
  subjectFactory = subjectOrSubjectFactory;
29123
29134
  } else {
29124
- subjectFactory = function subjectFactory2() {
29135
+ subjectFactory = function subjectFactory() {
29125
29136
  return subjectOrSubjectFactory;
29126
29137
  };
29127
29138
  }
@@ -32592,7 +32603,7 @@ var require_signal_exit = __commonJS((exports, module) => {
32592
32603
  emitter.on(ev, cb);
32593
32604
  return remove;
32594
32605
  };
32595
- unload = function unload2() {
32606
+ unload = function unload() {
32596
32607
  if (!loaded || !processOk(global.process)) {
32597
32608
  return;
32598
32609
  }
@@ -32607,7 +32618,7 @@ var require_signal_exit = __commonJS((exports, module) => {
32607
32618
  emitter.count -= 1;
32608
32619
  };
32609
32620
  module.exports.unload = unload;
32610
- emit = function emit2(event, code, signal) {
32621
+ emit = function emit(event, code, signal) {
32611
32622
  if (emitter.emitted[event]) {
32612
32623
  return;
32613
32624
  }
@@ -32636,7 +32647,7 @@ var require_signal_exit = __commonJS((exports, module) => {
32636
32647
  return signals;
32637
32648
  };
32638
32649
  loaded = false;
32639
- load = function load2() {
32650
+ load = function load() {
32640
32651
  if (loaded || !processOk(global.process)) {
32641
32652
  return;
32642
32653
  }
@@ -32655,7 +32666,7 @@ var require_signal_exit = __commonJS((exports, module) => {
32655
32666
  };
32656
32667
  module.exports.load = load;
32657
32668
  originalProcessReallyExit = process3.reallyExit;
32658
- processReallyExit = function processReallyExit2(code) {
32669
+ processReallyExit = function processReallyExit(code) {
32659
32670
  if (!processOk(global.process)) {
32660
32671
  return;
32661
32672
  }
@@ -32665,7 +32676,7 @@ var require_signal_exit = __commonJS((exports, module) => {
32665
32676
  originalProcessReallyExit.call(process3, process3.exitCode);
32666
32677
  };
32667
32678
  originalProcessEmit = process3.emit;
32668
- processEmit = function processEmit2(ev, arg) {
32679
+ processEmit = function processEmit(ev, arg) {
32669
32680
  if (ev === "exit" && processOk(global.process)) {
32670
32681
  if (arg !== undefined) {
32671
32682
  process3.exitCode = arg;
@@ -42622,7 +42633,7 @@ var require_lib = __commonJS((exports, module) => {
42622
42633
  iconv.encodings = null;
42623
42634
  iconv.defaultCharUnicode = "\uFFFD";
42624
42635
  iconv.defaultCharSingleByte = "?";
42625
- iconv.encode = function encode3(str, encoding, options) {
42636
+ iconv.encode = function encode(str, encoding, options) {
42626
42637
  str = "" + (str || "");
42627
42638
  var encoder = iconv.getEncoder(encoding, options);
42628
42639
  var res = encoder.write(str);
@@ -44099,9 +44110,7 @@ class Container {
44099
44110
  services = new Map;
44100
44111
  static instance = null;
44101
44112
  static getInstance() {
44102
- if (!Container.instance) {
44103
- Container.instance = new Container;
44104
- }
44113
+ Container.instance ??= new Container;
44105
44114
  return Container.instance;
44106
44115
  }
44107
44116
  static reset() {
@@ -44165,6 +44174,7 @@ var ServiceTokens = {
44165
44174
  PullrequestsApi: "PullrequestsApi",
44166
44175
  RepositoriesApi: "RepositoriesApi",
44167
44176
  UsersApi: "UsersApi",
44177
+ CommitStatusesApi: "CommitStatusesApi",
44168
44178
  LoginCommand: "LoginCommand",
44169
44179
  LogoutCommand: "LogoutCommand",
44170
44180
  StatusCommand: "StatusCommand",
@@ -44185,6 +44195,7 @@ var ServiceTokens = {
44185
44195
  CheckoutPRCommand: "CheckoutPRCommand",
44186
44196
  DiffPRCommand: "DiffPRCommand",
44187
44197
  ActivityPRCommand: "ActivityPRCommand",
44198
+ ChecksPRCommand: "ChecksPRCommand",
44188
44199
  CommentPRCommand: "CommentPRCommand",
44189
44200
  ListCommentsPRCommand: "ListCommentsPRCommand",
44190
44201
  EditCommentPRCommand: "EditCommentPRCommand",
@@ -44444,14 +44455,14 @@ class ContextService {
44444
44455
  this.configService = configService;
44445
44456
  }
44446
44457
  parseRemoteUrl(url) {
44447
- const sshMatch = url.match(/git@bitbucket\.org:([^/]+)\/([^.]+)(?:\.git)?/);
44458
+ const sshMatch = new RegExp(/git@bitbucket\.org:([^/]+)\/([^.]+)(?:\.git)?/).exec(url);
44448
44459
  if (sshMatch) {
44449
44460
  return {
44450
44461
  workspace: sshMatch[1],
44451
44462
  repoSlug: sshMatch[2]
44452
44463
  };
44453
44464
  }
44454
- const httpsMatch = url.match(/https?:\/\/(?:[^@]+@)?bitbucket\.org\/([^/]+)\/([^/.]+)(?:\.git)?/);
44465
+ const httpsMatch = new RegExp(/https?:\/\/(?:[^@]+@)?bitbucket\.org\/([^/]+)\/([^/.]+)(?:\.git)?/).exec(url);
44455
44466
  if (httpsMatch) {
44456
44467
  return {
44457
44468
  workspace: httpsMatch[1],
@@ -45067,6 +45078,30 @@ class OutputService {
45067
45078
  bold(text) {
45068
45079
  return this.format(text, source_default.bold);
45069
45080
  }
45081
+ red(text) {
45082
+ return this.format(text, source_default.red);
45083
+ }
45084
+ green(text) {
45085
+ return this.format(text, source_default.green);
45086
+ }
45087
+ yellow(text) {
45088
+ return this.format(text, source_default.yellow);
45089
+ }
45090
+ cyan(text) {
45091
+ return this.format(text, source_default.cyan);
45092
+ }
45093
+ magenta(text) {
45094
+ return this.format(text, source_default.magenta);
45095
+ }
45096
+ gray(text) {
45097
+ return this.format(text, source_default.gray);
45098
+ }
45099
+ blue(text) {
45100
+ return this.format(text, source_default.blue);
45101
+ }
45102
+ underline(text) {
45103
+ return this.format(text, source_default.underline);
45104
+ }
45070
45105
  }
45071
45106
  // src/services/version.service.ts
45072
45107
  var NPM_REGISTRY_URL = "https://registry.npmjs.org/@pilatos/bitbucket-cli";
@@ -45156,7 +45191,7 @@ class VersionService {
45156
45191
  const cleanVersion = version.replace(/^v/, "");
45157
45192
  return cleanVersion.split(".").map((part) => {
45158
45193
  const numPart = part.split("-")[0];
45159
- return parseInt(numPart, 10) || 0;
45194
+ return Number.parseInt(numPart, 10) || 0;
45160
45195
  });
45161
45196
  };
45162
45197
  const newParts = parseVersion(newVersion);
@@ -48746,6 +48781,208 @@ var createRequestFunction = function(axiosArgs, globalAxios, BASE_PATH2, configu
48746
48781
  };
48747
48782
 
48748
48783
  // src/generated/api.ts
48784
+ var CommitStatusesApiAxiosParamCreator = function(configuration) {
48785
+ return {
48786
+ repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyGet: async (commit, key, repoSlug, workspace, options = {}) => {
48787
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyGet", "commit", commit);
48788
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyGet", "key", key);
48789
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyGet", "repoSlug", repoSlug);
48790
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyGet", "workspace", workspace);
48791
+ const localVarPath = `/repositories/{workspace}/{repo_slug}/commit/{commit}/statuses/build/{key}`.replace(`{${"commit"}}`, encodeURIComponent(String(commit))).replace(`{${"key"}}`, encodeURIComponent(String(key))).replace(`{${"repo_slug"}}`, encodeURIComponent(String(repoSlug))).replace(`{${"workspace"}}`, encodeURIComponent(String(workspace)));
48792
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
48793
+ let baseOptions;
48794
+ if (configuration) {
48795
+ baseOptions = configuration.baseOptions;
48796
+ }
48797
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
48798
+ const localVarHeaderParameter = {};
48799
+ const localVarQueryParameter = {};
48800
+ await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration);
48801
+ await setOAuthToObject(localVarHeaderParameter, "oauth2", ["repository"], configuration);
48802
+ setBasicAuthToObject(localVarRequestOptions, configuration);
48803
+ localVarHeaderParameter["Accept"] = "application/json";
48804
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
48805
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
48806
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
48807
+ return {
48808
+ url: toPathString(localVarUrlObj),
48809
+ options: localVarRequestOptions
48810
+ };
48811
+ },
48812
+ repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyPut: async (commit, key, repoSlug, workspace, body, options = {}) => {
48813
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyPut", "commit", commit);
48814
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyPut", "key", key);
48815
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyPut", "repoSlug", repoSlug);
48816
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyPut", "workspace", workspace);
48817
+ const localVarPath = `/repositories/{workspace}/{repo_slug}/commit/{commit}/statuses/build/{key}`.replace(`{${"commit"}}`, encodeURIComponent(String(commit))).replace(`{${"key"}}`, encodeURIComponent(String(key))).replace(`{${"repo_slug"}}`, encodeURIComponent(String(repoSlug))).replace(`{${"workspace"}}`, encodeURIComponent(String(workspace)));
48818
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
48819
+ let baseOptions;
48820
+ if (configuration) {
48821
+ baseOptions = configuration.baseOptions;
48822
+ }
48823
+ const localVarRequestOptions = { method: "PUT", ...baseOptions, ...options };
48824
+ const localVarHeaderParameter = {};
48825
+ const localVarQueryParameter = {};
48826
+ await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration);
48827
+ await setOAuthToObject(localVarHeaderParameter, "oauth2", ["repository"], configuration);
48828
+ setBasicAuthToObject(localVarRequestOptions, configuration);
48829
+ localVarHeaderParameter["Content-Type"] = "application/json";
48830
+ localVarHeaderParameter["Accept"] = "application/json";
48831
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
48832
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
48833
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
48834
+ localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration);
48835
+ return {
48836
+ url: toPathString(localVarUrlObj),
48837
+ options: localVarRequestOptions
48838
+ };
48839
+ },
48840
+ repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildPost: async (commit, repoSlug, workspace, body, options = {}) => {
48841
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildPost", "commit", commit);
48842
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildPost", "repoSlug", repoSlug);
48843
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildPost", "workspace", workspace);
48844
+ const localVarPath = `/repositories/{workspace}/{repo_slug}/commit/{commit}/statuses/build`.replace(`{${"commit"}}`, encodeURIComponent(String(commit))).replace(`{${"repo_slug"}}`, encodeURIComponent(String(repoSlug))).replace(`{${"workspace"}}`, encodeURIComponent(String(workspace)));
48845
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
48846
+ let baseOptions;
48847
+ if (configuration) {
48848
+ baseOptions = configuration.baseOptions;
48849
+ }
48850
+ const localVarRequestOptions = { method: "POST", ...baseOptions, ...options };
48851
+ const localVarHeaderParameter = {};
48852
+ const localVarQueryParameter = {};
48853
+ await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration);
48854
+ await setOAuthToObject(localVarHeaderParameter, "oauth2", ["repository"], configuration);
48855
+ setBasicAuthToObject(localVarRequestOptions, configuration);
48856
+ localVarHeaderParameter["Content-Type"] = "application/json";
48857
+ localVarHeaderParameter["Accept"] = "application/json";
48858
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
48859
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
48860
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
48861
+ localVarRequestOptions.data = serializeDataIfNeeded(body, localVarRequestOptions, configuration);
48862
+ return {
48863
+ url: toPathString(localVarUrlObj),
48864
+ options: localVarRequestOptions
48865
+ };
48866
+ },
48867
+ repositoriesWorkspaceRepoSlugCommitCommitStatusesGet: async (commit, repoSlug, workspace, refname, q, sort, options = {}) => {
48868
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesGet", "commit", commit);
48869
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesGet", "repoSlug", repoSlug);
48870
+ assertParamExists("repositoriesWorkspaceRepoSlugCommitCommitStatusesGet", "workspace", workspace);
48871
+ const localVarPath = `/repositories/{workspace}/{repo_slug}/commit/{commit}/statuses`.replace(`{${"commit"}}`, encodeURIComponent(String(commit))).replace(`{${"repo_slug"}}`, encodeURIComponent(String(repoSlug))).replace(`{${"workspace"}}`, encodeURIComponent(String(workspace)));
48872
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
48873
+ let baseOptions;
48874
+ if (configuration) {
48875
+ baseOptions = configuration.baseOptions;
48876
+ }
48877
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
48878
+ const localVarHeaderParameter = {};
48879
+ const localVarQueryParameter = {};
48880
+ await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration);
48881
+ await setOAuthToObject(localVarHeaderParameter, "oauth2", ["repository"], configuration);
48882
+ setBasicAuthToObject(localVarRequestOptions, configuration);
48883
+ if (refname !== undefined) {
48884
+ localVarQueryParameter["refname"] = refname;
48885
+ }
48886
+ if (q !== undefined) {
48887
+ localVarQueryParameter["q"] = q;
48888
+ }
48889
+ if (sort !== undefined) {
48890
+ localVarQueryParameter["sort"] = sort;
48891
+ }
48892
+ localVarHeaderParameter["Accept"] = "application/json";
48893
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
48894
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
48895
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
48896
+ return {
48897
+ url: toPathString(localVarUrlObj),
48898
+ options: localVarRequestOptions
48899
+ };
48900
+ },
48901
+ repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdStatusesGet: async (pullRequestId, repoSlug, workspace, q, sort, options = {}) => {
48902
+ assertParamExists("repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdStatusesGet", "pullRequestId", pullRequestId);
48903
+ assertParamExists("repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdStatusesGet", "repoSlug", repoSlug);
48904
+ assertParamExists("repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdStatusesGet", "workspace", workspace);
48905
+ const localVarPath = `/repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/statuses`.replace(`{${"pull_request_id"}}`, encodeURIComponent(String(pullRequestId))).replace(`{${"repo_slug"}}`, encodeURIComponent(String(repoSlug))).replace(`{${"workspace"}}`, encodeURIComponent(String(workspace)));
48906
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
48907
+ let baseOptions;
48908
+ if (configuration) {
48909
+ baseOptions = configuration.baseOptions;
48910
+ }
48911
+ const localVarRequestOptions = { method: "GET", ...baseOptions, ...options };
48912
+ const localVarHeaderParameter = {};
48913
+ const localVarQueryParameter = {};
48914
+ await setApiKeyToObject(localVarHeaderParameter, "Authorization", configuration);
48915
+ await setOAuthToObject(localVarHeaderParameter, "oauth2", ["pullrequest"], configuration);
48916
+ setBasicAuthToObject(localVarRequestOptions, configuration);
48917
+ if (q !== undefined) {
48918
+ localVarQueryParameter["q"] = q;
48919
+ }
48920
+ if (sort !== undefined) {
48921
+ localVarQueryParameter["sort"] = sort;
48922
+ }
48923
+ localVarHeaderParameter["Accept"] = "application/json";
48924
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
48925
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
48926
+ localVarRequestOptions.headers = { ...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers };
48927
+ return {
48928
+ url: toPathString(localVarUrlObj),
48929
+ options: localVarRequestOptions
48930
+ };
48931
+ }
48932
+ };
48933
+ };
48934
+ var CommitStatusesApiFp = function(configuration) {
48935
+ const localVarAxiosParamCreator = CommitStatusesApiAxiosParamCreator(configuration);
48936
+ return {
48937
+ async repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyGet(commit, key, repoSlug, workspace, options) {
48938
+ const localVarAxiosArgs = await localVarAxiosParamCreator.repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyGet(commit, key, repoSlug, workspace, options);
48939
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
48940
+ const localVarOperationServerBasePath = operationServerMap["CommitStatusesApi.repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyGet"]?.[localVarOperationServerIndex]?.url;
48941
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, axios_default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
48942
+ },
48943
+ async repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyPut(commit, key, repoSlug, workspace, body, options) {
48944
+ const localVarAxiosArgs = await localVarAxiosParamCreator.repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyPut(commit, key, repoSlug, workspace, body, options);
48945
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
48946
+ const localVarOperationServerBasePath = operationServerMap["CommitStatusesApi.repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyPut"]?.[localVarOperationServerIndex]?.url;
48947
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, axios_default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
48948
+ },
48949
+ async repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildPost(commit, repoSlug, workspace, body, options) {
48950
+ const localVarAxiosArgs = await localVarAxiosParamCreator.repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildPost(commit, repoSlug, workspace, body, options);
48951
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
48952
+ const localVarOperationServerBasePath = operationServerMap["CommitStatusesApi.repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildPost"]?.[localVarOperationServerIndex]?.url;
48953
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, axios_default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
48954
+ },
48955
+ async repositoriesWorkspaceRepoSlugCommitCommitStatusesGet(commit, repoSlug, workspace, refname, q, sort, options) {
48956
+ const localVarAxiosArgs = await localVarAxiosParamCreator.repositoriesWorkspaceRepoSlugCommitCommitStatusesGet(commit, repoSlug, workspace, refname, q, sort, options);
48957
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
48958
+ const localVarOperationServerBasePath = operationServerMap["CommitStatusesApi.repositoriesWorkspaceRepoSlugCommitCommitStatusesGet"]?.[localVarOperationServerIndex]?.url;
48959
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, axios_default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
48960
+ },
48961
+ async repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdStatusesGet(pullRequestId, repoSlug, workspace, q, sort, options) {
48962
+ const localVarAxiosArgs = await localVarAxiosParamCreator.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdStatusesGet(pullRequestId, repoSlug, workspace, q, sort, options);
48963
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
48964
+ const localVarOperationServerBasePath = operationServerMap["CommitStatusesApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdStatusesGet"]?.[localVarOperationServerIndex]?.url;
48965
+ return (axios2, basePath) => createRequestFunction(localVarAxiosArgs, axios_default, BASE_PATH, configuration)(axios2, localVarOperationServerBasePath || basePath);
48966
+ }
48967
+ };
48968
+ };
48969
+ class CommitStatusesApi extends BaseAPI {
48970
+ repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyGet(requestParameters, options) {
48971
+ return CommitStatusesApiFp(this.configuration).repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyGet(requestParameters.commit, requestParameters.key, requestParameters.repoSlug, requestParameters.workspace, options).then((request) => request(this.axios, this.basePath));
48972
+ }
48973
+ repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyPut(requestParameters, options) {
48974
+ return CommitStatusesApiFp(this.configuration).repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildKeyPut(requestParameters.commit, requestParameters.key, requestParameters.repoSlug, requestParameters.workspace, requestParameters.body, options).then((request) => request(this.axios, this.basePath));
48975
+ }
48976
+ repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildPost(requestParameters, options) {
48977
+ return CommitStatusesApiFp(this.configuration).repositoriesWorkspaceRepoSlugCommitCommitStatusesBuildPost(requestParameters.commit, requestParameters.repoSlug, requestParameters.workspace, requestParameters.body, options).then((request) => request(this.axios, this.basePath));
48978
+ }
48979
+ repositoriesWorkspaceRepoSlugCommitCommitStatusesGet(requestParameters, options) {
48980
+ return CommitStatusesApiFp(this.configuration).repositoriesWorkspaceRepoSlugCommitCommitStatusesGet(requestParameters.commit, requestParameters.repoSlug, requestParameters.workspace, requestParameters.refname, requestParameters.q, requestParameters.sort, options).then((request) => request(this.axios, this.basePath));
48981
+ }
48982
+ repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdStatusesGet(requestParameters, options) {
48983
+ return CommitStatusesApiFp(this.configuration).repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdStatusesGet(requestParameters.pullRequestId, requestParameters.repoSlug, requestParameters.workspace, requestParameters.q, requestParameters.sort, options).then((request) => request(this.axios, this.basePath));
48984
+ }
48985
+ }
48749
48986
  var PullrequestsApiAxiosParamCreator = function(configuration) {
48750
48987
  return {
48751
48988
  getPullrequestsForCommit: async (workspace, repoSlug, commit, page, pagelen, options = {}) => {
@@ -51272,6 +51509,14 @@ class BaseCommand {
51272
51509
  constructor(output) {
51273
51510
  this.output = output;
51274
51511
  }
51512
+ async run(options, context) {
51513
+ try {
51514
+ return await this.execute(options, context);
51515
+ } catch (error) {
51516
+ this.handleError(error, context);
51517
+ throw error;
51518
+ }
51519
+ }
51275
51520
  handleError(error, context) {
51276
51521
  if (error instanceof Error) {
51277
51522
  this.output.error(error.message);
@@ -51308,24 +51553,30 @@ class LoginCommand extends BaseCommand {
51308
51553
  const username = options.username || process.env.BB_USERNAME;
51309
51554
  const apiToken = options.password || process.env.BB_API_TOKEN;
51310
51555
  if (!username) {
51311
- const error = new Error("Username is required. Use --username option or set BB_USERNAME environment variable.");
51312
- this.output.error(error.message);
51313
- throw error;
51556
+ throw new Error("Username is required. Use --username option or set BB_USERNAME environment variable.");
51314
51557
  }
51315
51558
  if (!apiToken) {
51316
- const error = new Error("API token is required. Use --password option or set BB_API_TOKEN environment variable.");
51317
- this.output.error(error.message);
51318
- throw error;
51559
+ throw new Error("API token is required. Use --password option or set BB_API_TOKEN environment variable.");
51319
51560
  }
51320
51561
  await this.configService.setCredentials({ username, apiToken });
51321
51562
  try {
51322
51563
  const response = await this.usersApi.userGet();
51323
51564
  const user = response.data;
51565
+ if (context.globalOptions.json) {
51566
+ this.output.json({
51567
+ authenticated: true,
51568
+ user: {
51569
+ username: user.username,
51570
+ displayName: user.display_name,
51571
+ accountId: user.account_id
51572
+ }
51573
+ });
51574
+ return;
51575
+ }
51324
51576
  this.output.success(`Logged in as ${user.display_name} (${user.username})`);
51325
51577
  } catch (error) {
51326
51578
  await this.configService.clearConfig();
51327
- this.output.error(`Authentication failed: ${error instanceof Error ? error.message : String(error)}`);
51328
- throw error;
51579
+ throw new Error(`Authentication failed: ${error instanceof Error ? error.message : String(error)}`);
51329
51580
  }
51330
51581
  }
51331
51582
  }
@@ -51339,8 +51590,12 @@ class LogoutCommand extends BaseCommand {
51339
51590
  super(output);
51340
51591
  this.configService = configService;
51341
51592
  }
51342
- async execute(_options, _context) {
51593
+ async execute(_options, context) {
51343
51594
  await this.configService.clearConfig();
51595
+ if (context.globalOptions.json) {
51596
+ this.output.json({ authenticated: false, success: true });
51597
+ return;
51598
+ }
51344
51599
  this.output.success("Logged out of Bitbucket");
51345
51600
  }
51346
51601
  }
@@ -51359,24 +51614,38 @@ class StatusCommand extends BaseCommand {
51359
51614
  async execute(_options, context) {
51360
51615
  const config = await this.configService.getConfig();
51361
51616
  if (!config.username || !config.apiToken) {
51617
+ if (context.globalOptions.json) {
51618
+ this.output.json({ authenticated: false });
51619
+ return;
51620
+ }
51362
51621
  this.output.info("Not logged in");
51363
- this.output.text(`Run ${source_default.cyan("bb auth login")} to authenticate.`);
51622
+ this.output.text(`Run ${this.output.highlight("bb auth login")} to authenticate.`);
51364
51623
  return;
51365
51624
  }
51366
51625
  try {
51367
51626
  const response = await this.usersApi.userGet();
51368
51627
  const user = response.data;
51628
+ if (context.globalOptions.json) {
51629
+ this.output.json({
51630
+ authenticated: true,
51631
+ user: {
51632
+ username: user.username,
51633
+ displayName: user.display_name,
51634
+ accountId: user.account_id
51635
+ },
51636
+ defaultWorkspace: config.defaultWorkspace
51637
+ });
51638
+ return;
51639
+ }
51369
51640
  this.output.success("Logged in to Bitbucket");
51370
- this.output.text(` Username: ${source_default.cyan(user.username)}`);
51641
+ this.output.text(` Username: ${this.output.highlight(user.username ?? "")}`);
51371
51642
  this.output.text(` Display name: ${user.display_name}`);
51372
51643
  this.output.text(` Account ID: ${user.account_id}`);
51373
51644
  if (config.defaultWorkspace) {
51374
- this.output.text(` Default workspace: ${source_default.cyan(config.defaultWorkspace)}`);
51645
+ this.output.text(` Default workspace: ${this.output.highlight(config.defaultWorkspace)}`);
51375
51646
  }
51376
51647
  } catch (error) {
51377
- this.output.error("Authentication is invalid or expired");
51378
- this.output.text(`Run ${source_default.cyan("bb auth login")} to re-authenticate.`);
51379
- throw error;
51648
+ throw new Error(`Authentication is invalid or expired. Run ${this.output.highlight("bb auth login")} to re-authenticate.`);
51380
51649
  }
51381
51650
  }
51382
51651
  }
@@ -51390,14 +51659,16 @@ class TokenCommand extends BaseCommand {
51390
51659
  super(output);
51391
51660
  this.configService = configService;
51392
51661
  }
51393
- async execute(_options, _context) {
51662
+ async execute(_options, context) {
51394
51663
  const credentials = await this.configService.getCredentials();
51395
51664
  if (!credentials.username || !credentials.apiToken) {
51396
- const error = new Error("Not authenticated. Run 'bb auth login' first.");
51397
- this.output.error(error.message);
51398
- throw error;
51665
+ throw new Error("Not authenticated. Run 'bb auth login' first.");
51399
51666
  }
51400
51667
  const token = Buffer.from(`${credentials.username}:${credentials.apiToken}`).toString("base64");
51668
+ if (context.globalOptions.json) {
51669
+ this.output.json({ token });
51670
+ return;
51671
+ }
51401
51672
  this.output.text(token);
51402
51673
  }
51403
51674
  }
@@ -51418,6 +51689,15 @@ class CloneCommand extends BaseCommand {
51418
51689
  const repoUrl = await this.resolveRepositoryUrl(repository);
51419
51690
  await this.gitService.clone(repoUrl, directory);
51420
51691
  const targetDir = directory || this.extractRepoName(repository);
51692
+ if (context.globalOptions.json) {
51693
+ this.output.json({
51694
+ success: true,
51695
+ repository,
51696
+ path: targetDir,
51697
+ cloneUrl: repoUrl
51698
+ });
51699
+ return;
51700
+ }
51421
51701
  this.output.success(`Cloned ${repository} into ${targetDir}`);
51422
51702
  }
51423
51703
  async resolveRepositoryUrl(repository) {
@@ -51444,7 +51724,10 @@ class CloneCommand extends BaseCommand {
51444
51724
  }
51445
51725
  extractRepoName(repository) {
51446
51726
  const parts = repository.split("/");
51447
- const lastPart = parts[parts.length - 1];
51727
+ const lastPart = parts.at(-1);
51728
+ if (!lastPart) {
51729
+ throw new Error("Invalid repository format.");
51730
+ }
51448
51731
  return lastPart.replace(".git", "");
51449
51732
  }
51450
51733
  }
@@ -51476,22 +51759,21 @@ class CreateRepoCommand extends BaseCommand {
51476
51759
  if (project) {
51477
51760
  request.project = { type: "project", key: project };
51478
51761
  }
51479
- try {
51480
- const response = await this.repositoriesApi.repositoriesWorkspaceRepoSlugPost({
51481
- workspace,
51482
- repoSlug: name,
51483
- body: request
51484
- });
51485
- const repo = response.data;
51486
- this.output.success(`Created repository ${repo.full_name}`);
51487
- this.output.text(` ${source_default.dim("URL:")} ${repo.links?.html?.href}`);
51488
- const sshClone = Array.from(repo.links?.clone ?? []).find((c) => c.name === "ssh");
51489
- if (sshClone?.href) {
51490
- this.output.text(` ${source_default.dim("Clone:")} git clone ${sshClone.href}`);
51491
- }
51492
- } catch (error) {
51493
- this.handleError(error, context);
51494
- throw error;
51762
+ const response = await this.repositoriesApi.repositoriesWorkspaceRepoSlugPost({
51763
+ workspace,
51764
+ repoSlug: name,
51765
+ body: request
51766
+ });
51767
+ const repo = response.data;
51768
+ if (context.globalOptions.json) {
51769
+ this.output.json(repo);
51770
+ return;
51771
+ }
51772
+ this.output.success(`Created repository ${repo.full_name}`);
51773
+ this.output.text(` ${this.output.dim("URL:")} ${repo.links?.html?.href}`);
51774
+ const sshClone = Array.from(repo.links?.clone ?? []).find((c) => c.name === "ssh");
51775
+ if (sshClone?.href) {
51776
+ this.output.text(` ${this.output.dim("Clone:")} git clone ${sshClone.href}`);
51495
51777
  }
51496
51778
  }
51497
51779
  async resolveWorkspace(workspace) {
@@ -51518,27 +51800,30 @@ class ListReposCommand extends BaseCommand {
51518
51800
  this.configService = configService;
51519
51801
  }
51520
51802
  async execute(options, context) {
51521
- const workspace = await this.resolveWorkspace(options.workspace);
51522
- const limit = parseInt(options.limit || "25", 10);
51523
- try {
51524
- const response = await this.repositoriesApi.repositoriesWorkspaceGet({
51525
- workspace
51803
+ const workspace = await this.resolveWorkspace(options.workspace ?? context.globalOptions.workspace);
51804
+ const limit = Number.parseInt(options.limit || "25", 10);
51805
+ const response = await this.repositoriesApi.repositoriesWorkspaceGet({
51806
+ workspace
51807
+ });
51808
+ const repos = Array.from(response.data.values ?? []).slice(0, limit);
51809
+ if (context.globalOptions.json) {
51810
+ this.output.json({
51811
+ workspace,
51812
+ count: repos.length,
51813
+ repositories: repos
51526
51814
  });
51527
- const repos = Array.from(response.data.values ?? []).slice(0, limit);
51528
- if (repos.length === 0) {
51529
- this.output.text("No repositories found");
51530
- return;
51531
- }
51532
- const rows = repos.map((repo) => [
51533
- repo.full_name ?? "",
51534
- repo.is_private ? "private" : "public",
51535
- (repo.description || "").substring(0, 50)
51536
- ]);
51537
- this.output.table(["REPOSITORY", "VISIBILITY", "DESCRIPTION"], rows);
51538
- } catch (error) {
51539
- this.handleError(error, context);
51540
- throw error;
51815
+ return;
51816
+ }
51817
+ if (repos.length === 0) {
51818
+ this.output.text("No repositories found");
51819
+ return;
51541
51820
  }
51821
+ const rows = repos.map((repo) => [
51822
+ repo.full_name ?? "",
51823
+ repo.is_private ? "private" : "public",
51824
+ (repo.description || "").substring(0, 50)
51825
+ ]);
51826
+ this.output.table(["REPOSITORY", "VISIBILITY", "DESCRIPTION"], rows);
51542
51827
  }
51543
51828
  async resolveWorkspace(workspace) {
51544
51829
  if (workspace) {
@@ -51575,36 +51860,35 @@ class ViewRepoCommand extends BaseCommand {
51575
51860
  }
51576
51861
  }
51577
51862
  const repoContext = await this.contextService.requireRepoContext(contextOptions);
51578
- try {
51579
- const response = await this.repositoriesApi.repositoriesWorkspaceRepoSlugGet({
51580
- workspace: repoContext.workspace,
51581
- repoSlug: repoContext.repoSlug
51582
- });
51583
- const repo = response.data;
51584
- this.output.text(source_default.bold(repo.full_name ?? ""));
51585
- if (repo.description) {
51586
- this.output.text(source_default.dim(repo.description));
51587
- }
51588
- this.output.text("");
51589
- this.output.text(` ${source_default.dim("Visibility:")} ${repo.is_private ? "Private" : "Public"}`);
51590
- this.output.text(` ${source_default.dim("Owner:")} ${repo.owner?.display_name ?? "Unknown"}`);
51591
- if (repo.language) {
51592
- this.output.text(` ${source_default.dim("Language:")} ${repo.language}`);
51593
- }
51594
- if (repo.mainbranch) {
51595
- this.output.text(` ${source_default.dim("Default branch:")} ${repo.mainbranch.name}`);
51596
- }
51597
- this.output.text(` ${source_default.dim("Created:")} ${this.output.formatDate(repo.created_on ?? "")}`);
51598
- this.output.text(` ${source_default.dim("Updated:")} ${this.output.formatDate(repo.updated_on ?? "")}`);
51599
- this.output.text("");
51600
- this.output.text(` ${source_default.dim("URL:")} ${repo.links?.html?.href}`);
51601
- const sshClone = Array.from(repo.links?.clone ?? []).find((c) => c.name === "ssh");
51602
- if (sshClone?.href) {
51603
- this.output.text(` ${source_default.dim("SSH:")} ${sshClone.href}`);
51604
- }
51605
- } catch (error) {
51606
- this.handleError(error, context);
51607
- throw error;
51863
+ const response = await this.repositoriesApi.repositoriesWorkspaceRepoSlugGet({
51864
+ workspace: repoContext.workspace,
51865
+ repoSlug: repoContext.repoSlug
51866
+ });
51867
+ const repo = response.data;
51868
+ if (context.globalOptions.json) {
51869
+ this.output.json(repo);
51870
+ return;
51871
+ }
51872
+ this.output.text(this.output.bold(repo.full_name ?? ""));
51873
+ if (repo.description) {
51874
+ this.output.text(this.output.dim(repo.description));
51875
+ }
51876
+ this.output.text("");
51877
+ this.output.text(` ${this.output.dim("Visibility:")} ${repo.is_private ? "Private" : "Public"}`);
51878
+ this.output.text(` ${this.output.dim("Owner:")} ${repo.owner?.display_name ?? "Unknown"}`);
51879
+ if (repo.language) {
51880
+ this.output.text(` ${this.output.dim("Language:")} ${repo.language}`);
51881
+ }
51882
+ if (repo.mainbranch) {
51883
+ this.output.text(` ${this.output.dim("Default branch:")} ${repo.mainbranch.name}`);
51884
+ }
51885
+ this.output.text(` ${this.output.dim("Created:")} ${this.output.formatDate(repo.created_on ?? "")}`);
51886
+ this.output.text(` ${this.output.dim("Updated:")} ${this.output.formatDate(repo.updated_on ?? "")}`);
51887
+ this.output.text("");
51888
+ this.output.text(` ${this.output.dim("URL:")} ${repo.links?.html?.href}`);
51889
+ const sshClone = Array.from(repo.links?.clone ?? []).find((c) => c.name === "ssh");
51890
+ if (sshClone?.href) {
51891
+ this.output.text(` ${this.output.dim("SSH:")} ${sshClone.href}`);
51608
51892
  }
51609
51893
  }
51610
51894
  }
@@ -51632,24 +51916,22 @@ class DeleteRepoCommand extends BaseCommand {
51632
51916
  }
51633
51917
  const repoContext = await this.contextService.requireRepoContext(contextOptions);
51634
51918
  if (!yes) {
51635
- const error = new Error(`This will permanently delete ${repoContext.workspace}/${repoContext.repoSlug}.
51919
+ throw new Error(`This will permanently delete ${repoContext.workspace}/${repoContext.repoSlug}.
51636
51920
  ` + "Use --yes to confirm deletion.");
51637
- this.output.error(error.message);
51638
- if (true) {
51639
- process.exitCode = 1;
51640
- }
51641
- throw error;
51642
51921
  }
51643
- try {
51644
- await this.repositoriesApi.repositoriesWorkspaceRepoSlugDelete({
51922
+ await this.repositoriesApi.repositoriesWorkspaceRepoSlugDelete({
51923
+ workspace: repoContext.workspace,
51924
+ repoSlug: repoContext.repoSlug
51925
+ });
51926
+ if (context.globalOptions.json) {
51927
+ this.output.json({
51928
+ success: true,
51645
51929
  workspace: repoContext.workspace,
51646
51930
  repoSlug: repoContext.repoSlug
51647
51931
  });
51648
- this.output.success(`Deleted repository ${repoContext.workspace}/${repoContext.repoSlug}`);
51649
- } catch (error) {
51650
- this.handleError(error, context);
51651
- throw error;
51932
+ return;
51652
51933
  }
51934
+ this.output.success(`Deleted repository ${repoContext.workspace}/${repoContext.repoSlug}`);
51653
51935
  }
51654
51936
  }
51655
51937
 
@@ -51668,11 +51950,7 @@ class CreatePRCommand extends BaseCommand {
51668
51950
  }
51669
51951
  async execute(options, context) {
51670
51952
  if (!options.title) {
51671
- this.output.error("Pull request title is required. Use --title option.");
51672
- if (true) {
51673
- process.exitCode = 1;
51674
- }
51675
- throw new Error("Pull request title is required");
51953
+ throw new Error("Pull request title is required. Use --title option.");
51676
51954
  }
51677
51955
  const repoContext = await this.contextService.requireRepoContext({
51678
51956
  ...context.globalOptions,
@@ -51702,21 +51980,20 @@ class CreatePRCommand extends BaseCommand {
51702
51980
  if (options.draft) {
51703
51981
  request.draft = true;
51704
51982
  }
51705
- try {
51706
- const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPost({
51707
- workspace: repoContext.workspace,
51708
- repoSlug: repoContext.repoSlug,
51709
- body: request
51710
- });
51711
- const pr = response.data;
51712
- const links = pr.links;
51713
- this.output.success(`Created pull request #${pr.id}`);
51714
- this.output.text(` ${source_default.dim("Title:")} ${pr.title}`);
51715
- this.output.text(` ${source_default.dim("URL:")} ${links?.html?.href}`);
51716
- } catch (error) {
51717
- this.handleError(error, context);
51718
- throw error;
51983
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPost({
51984
+ workspace: repoContext.workspace,
51985
+ repoSlug: repoContext.repoSlug,
51986
+ body: request
51987
+ });
51988
+ const pr = response.data;
51989
+ const links = pr.links;
51990
+ if (context.globalOptions.json) {
51991
+ this.output.json(pr);
51992
+ return;
51719
51993
  }
51994
+ this.output.success(`Created pull request #${pr.id}`);
51995
+ this.output.text(` ${this.output.dim("Title:")} ${pr.title}`);
51996
+ this.output.text(` ${this.output.dim("URL:")} ${links?.html?.href}`);
51720
51997
  }
51721
51998
  }
51722
51999
 
@@ -51737,34 +52014,39 @@ class ListPRsCommand extends BaseCommand {
51737
52014
  ...options
51738
52015
  });
51739
52016
  const state = options.state || "OPEN";
51740
- try {
51741
- const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsGet({
52017
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsGet({
52018
+ workspace: repoContext.workspace,
52019
+ repoSlug: repoContext.repoSlug,
52020
+ state
52021
+ });
52022
+ const data = response.data;
52023
+ const values = data.values ? Array.from(data.values) : [];
52024
+ if (context.globalOptions.json) {
52025
+ this.output.json({
51742
52026
  workspace: repoContext.workspace,
51743
52027
  repoSlug: repoContext.repoSlug,
51744
- state
52028
+ state,
52029
+ count: values.length,
52030
+ pullRequests: values
51745
52031
  });
51746
- const data = response.data;
51747
- const values = data.values ? Array.from(data.values) : [];
51748
- if (values.length === 0) {
51749
- this.output.text(`No ${state.toLowerCase()} pull requests found`);
51750
- return;
51751
- }
51752
- const rows = values.map((pr) => {
51753
- const title = pr.draft ? `[DRAFT] ${pr.title}` : pr.title;
51754
- const source = pr.source;
51755
- const destination = pr.destination;
51756
- return [
51757
- `#${pr.id}`,
51758
- this.truncate(title ?? "", 50),
51759
- pr.author?.display_name ?? "Unknown",
51760
- `${source?.branch?.name ?? "unknown"} \u2192 ${destination?.branch?.name ?? "unknown"}`
51761
- ];
51762
- });
51763
- this.output.table(["ID", "TITLE", "AUTHOR", "BRANCHES"], rows);
51764
- } catch (error) {
51765
- this.handleError(error, context);
51766
- throw error;
52032
+ return;
51767
52033
  }
52034
+ if (values.length === 0) {
52035
+ this.output.text(`No ${state.toLowerCase()} pull requests found`);
52036
+ return;
52037
+ }
52038
+ const rows = values.map((pr) => {
52039
+ const title = pr.draft ? `[DRAFT] ${pr.title}` : pr.title;
52040
+ const source = pr.source;
52041
+ const destination = pr.destination;
52042
+ return [
52043
+ `#${pr.id}`,
52044
+ this.truncate(title ?? "", 50),
52045
+ pr.author?.display_name ?? "Unknown",
52046
+ `${source?.branch?.name ?? "unknown"} \u2192 ${destination?.branch?.name ?? "unknown"}`
52047
+ ];
52048
+ });
52049
+ this.output.table(["ID", "TITLE", "AUTHOR", "BRANCHES"], rows);
51768
52050
  }
51769
52051
  truncate(text, maxLength) {
51770
52052
  if (text.length <= maxLength) {
@@ -51790,31 +52072,30 @@ class ViewPRCommand extends BaseCommand {
51790
52072
  ...context.globalOptions,
51791
52073
  ...options
51792
52074
  });
51793
- const prId = parseInt(options.id, 10);
51794
- try {
51795
- const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
51796
- workspace: repoContext.workspace,
51797
- repoSlug: repoContext.repoSlug,
51798
- pullRequestId: prId
51799
- });
51800
- const pr = response.data;
51801
- this.renderHeader(pr);
51802
- this.renderDescription(pr);
51803
- this.renderBranchInfo(pr);
51804
- this.renderMetadata(pr);
51805
- this.renderReviewers(pr);
51806
- this.renderFooter(pr);
51807
- } catch (error) {
51808
- this.handleError(error, context);
51809
- throw error;
52075
+ const prId = Number.parseInt(options.id, 10);
52076
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
52077
+ workspace: repoContext.workspace,
52078
+ repoSlug: repoContext.repoSlug,
52079
+ pullRequestId: prId
52080
+ });
52081
+ const pr = response.data;
52082
+ if (context.globalOptions.json) {
52083
+ this.output.json(pr);
52084
+ return;
51810
52085
  }
52086
+ this.renderHeader(pr);
52087
+ this.renderDescription(pr);
52088
+ this.renderBranchInfo(pr);
52089
+ this.renderMetadata(pr);
52090
+ this.renderReviewers(pr);
52091
+ this.renderFooter(pr);
51811
52092
  }
51812
52093
  renderHeader(pr) {
51813
52094
  const stateColor = this.getStateColor(pr.state);
51814
- const draftLabel = pr.draft ? source_default.yellow(" [DRAFT]") : "";
52095
+ const draftLabel = pr.draft ? this.output.yellow(" [DRAFT]") : "";
51815
52096
  this.output.text("");
51816
- this.output.text(`${source_default.bold(`#${pr.id}`)} ${pr.title}${draftLabel} ${stateColor(`[${pr.state}]`)}`);
51817
- this.output.text(source_default.gray("\u2500".repeat(60)));
52097
+ this.output.text(`${this.output.bold(`#${pr.id}`)} ${pr.title}${draftLabel} ${stateColor(`[${pr.state}]`)}`);
52098
+ this.output.text(this.output.gray("\u2500".repeat(60)));
51818
52099
  }
51819
52100
  renderDescription(pr) {
51820
52101
  if (pr.description) {
@@ -51825,75 +52106,75 @@ class ViewPRCommand extends BaseCommand {
51825
52106
  renderBranchInfo(pr) {
51826
52107
  const source = pr.source;
51827
52108
  const destination = pr.destination;
51828
- const sourceBranch = source_default.cyan(source?.branch?.name ?? "unknown");
51829
- const destBranch = source_default.cyan(destination?.branch?.name ?? "unknown");
51830
- const arrow = source_default.gray(" \u2192 ");
51831
- this.output.text(`${source_default.dim("Branch:")} ${sourceBranch}${arrow}${destBranch}`);
52109
+ const sourceBranch = this.output.cyan(source?.branch?.name ?? "unknown");
52110
+ const destBranch = this.output.cyan(destination?.branch?.name ?? "unknown");
52111
+ const arrow = this.output.gray(" \u2192 ");
52112
+ this.output.text(`${this.output.dim("Branch:")} ${sourceBranch}${arrow}${destBranch}`);
51832
52113
  if (source?.commit?.hash || destination?.commit?.hash) {
51833
- const sourceHash = source?.commit?.hash ? source_default.gray(source.commit.hash.slice(0, 7)) : source_default.gray("unknown");
51834
- const destHash = destination?.commit?.hash ? source_default.gray(destination.commit.hash.slice(0, 7)) : source_default.gray("unknown");
51835
- this.output.text(`${source_default.dim("Commits:")} ${sourceHash}${arrow}${destHash}`);
52114
+ const sourceHash = source?.commit?.hash ? this.output.gray(source.commit.hash.slice(0, 7)) : this.output.gray("unknown");
52115
+ const destHash = destination?.commit?.hash ? this.output.gray(destination.commit.hash.slice(0, 7)) : this.output.gray("unknown");
52116
+ this.output.text(`${this.output.dim("Commits:")} ${sourceHash}${arrow}${destHash}`);
51836
52117
  }
51837
52118
  }
51838
52119
  renderMetadata(pr) {
51839
- this.output.text(`${source_default.dim("Author:")} ${pr.author?.display_name ?? "Unknown"}`);
52120
+ this.output.text(`${this.output.dim("Author:")} ${pr.author?.display_name ?? "Unknown"}`);
51840
52121
  if (pr.closed_by) {
51841
52122
  const action = pr.state === "MERGED" ? "Merged" : "Closed";
51842
- this.output.text(`${source_default.dim(action + ":")} ${pr.closed_by.display_name}`);
52123
+ this.output.text(`${this.output.dim(action + ":")} ${pr.closed_by.display_name}`);
51843
52124
  }
51844
52125
  const createdOn = pr.created_on ? this.output.formatDate(pr.created_on) : "Unknown";
51845
52126
  const updatedOn = pr.updated_on ? this.output.formatDate(pr.updated_on) : "Unknown";
51846
- this.output.text(`${source_default.dim("Created:")} ${createdOn}`);
51847
- this.output.text(`${source_default.dim("Updated:")} ${updatedOn}`);
52127
+ this.output.text(`${this.output.dim("Created:")} ${createdOn}`);
52128
+ this.output.text(`${this.output.dim("Updated:")} ${updatedOn}`);
51848
52129
  const mergeCommit = pr.merge_commit;
51849
52130
  if (mergeCommit?.hash) {
51850
- this.output.text(`${source_default.dim("Merge:")} ${source_default.magenta(mergeCommit.hash.slice(0, 7))}`);
52131
+ this.output.text(`${this.output.dim("Merge:")} ${this.output.magenta(mergeCommit.hash.slice(0, 7))}`);
51851
52132
  }
51852
- const closeBranchIndicator = pr.close_source_branch ? source_default.green("\u2713") : source_default.gray("\u2717");
51853
- this.output.text(`${source_default.dim("Close Src:")} ${closeBranchIndicator} ${source_default.gray("(close source branch on merge)")}`);
51854
- this.output.text(`${source_default.dim("Activity:")} ${pr.comment_count ?? 0} comments \xB7 ${pr.task_count ?? 0} tasks`);
52133
+ const closeBranchIndicator = pr.close_source_branch ? this.output.green("\u2713") : this.output.gray("\u2717");
52134
+ this.output.text(`${this.output.dim("Close Src:")} ${closeBranchIndicator} ${this.output.gray("(close source branch on merge)")}`);
52135
+ this.output.text(`${this.output.dim("Activity:")} ${pr.comment_count ?? 0} comments \xB7 ${pr.task_count ?? 0} tasks`);
51855
52136
  }
51856
52137
  renderReviewers(pr) {
51857
52138
  const participants = pr.participants ? Array.from(pr.participants) : [];
51858
52139
  const reviewers = participants.filter((p) => p.role === "REVIEWER");
51859
52140
  if (reviewers.length === 0) {
51860
52141
  this.output.text("");
51861
- this.output.text(source_default.gray("No reviewers assigned"));
52142
+ this.output.text(this.output.gray("No reviewers assigned"));
51862
52143
  return;
51863
52144
  }
51864
52145
  this.output.text("");
51865
- this.output.text(source_default.dim("Reviewers:"));
52146
+ this.output.text(this.output.dim("Reviewers:"));
51866
52147
  for (const reviewer of reviewers) {
51867
52148
  const status = this.getReviewerStatus(reviewer);
51868
- this.output.text(` ${status.icon} ${reviewer.user?.display_name ?? "Unknown"} ${source_default.gray(status.label)}`);
52149
+ this.output.text(` ${status.icon} ${reviewer.user?.display_name ?? "Unknown"} ${this.output.gray(status.label)}`);
51869
52150
  }
51870
52151
  }
51871
52152
  getReviewerStatus(reviewer) {
51872
52153
  if (reviewer.approved) {
51873
- return { icon: source_default.green("\u2713"), label: "approved" };
52154
+ return { icon: this.output.green("\u2713"), label: "approved" };
51874
52155
  }
51875
52156
  if (reviewer.state === "changes_requested") {
51876
- return { icon: source_default.red("\u2717"), label: "changes requested" };
52157
+ return { icon: this.output.red("\u2717"), label: "changes requested" };
51877
52158
  }
51878
- return { icon: source_default.yellow("\u25CB"), label: "pending" };
52159
+ return { icon: this.output.yellow("\u25CB"), label: "pending" };
51879
52160
  }
51880
52161
  renderFooter(pr) {
51881
52162
  const links = pr.links;
51882
52163
  this.output.text("");
51883
- this.output.text(source_default.gray("\u2500".repeat(60)));
51884
- this.output.text(`${source_default.dim("URL:")} ${source_default.blue.underline(links?.html?.href ?? "")}`);
52164
+ this.output.text(this.output.gray("\u2500".repeat(60)));
52165
+ this.output.text(`${this.output.dim("URL:")} ${this.output.underline(this.output.blue(links?.html?.href ?? ""))}`);
51885
52166
  this.output.text("");
51886
52167
  }
51887
52168
  getStateColor(state) {
51888
52169
  switch (state) {
51889
52170
  case "OPEN":
51890
- return source_default.green;
52171
+ return (text) => this.output.green(text);
51891
52172
  case "MERGED":
51892
- return source_default.magenta;
52173
+ return (text) => this.output.magenta(text);
51893
52174
  case "DECLINED":
51894
- return source_default.red;
52175
+ return (text) => this.output.red(text);
51895
52176
  default:
51896
- return source_default.gray;
52177
+ return (text) => this.output.gray(text);
51897
52178
  }
51898
52179
  }
51899
52180
  }
@@ -51919,7 +52200,7 @@ class EditPRCommand extends BaseCommand {
51919
52200
  });
51920
52201
  let prId;
51921
52202
  if (options.id) {
51922
- prId = parseInt(options.id, 10);
52203
+ prId = Number.parseInt(options.id, 10);
51923
52204
  } else {
51924
52205
  const currentBranch = await this.gitService.getCurrentBranch();
51925
52206
  const prsResponse = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsGet({
@@ -51928,17 +52209,12 @@ class EditPRCommand extends BaseCommand {
51928
52209
  state: "OPEN"
51929
52210
  });
51930
52211
  const values = prsResponse.data.values ? Array.from(prsResponse.data.values) : [];
51931
- const matchingPR = values.find((pr) => {
51932
- const source = pr.source;
52212
+ const matchingPR = values.find((pr2) => {
52213
+ const source = pr2.source;
51933
52214
  return source?.branch?.name === currentBranch;
51934
52215
  });
51935
52216
  if (!matchingPR) {
51936
- const error = new Error(`No open pull request found for current branch '${currentBranch}'. Specify a PR ID explicitly.`);
51937
- this.output.error(error.message);
51938
- if (true) {
51939
- process.exitCode = 1;
51940
- }
51941
- throw error;
52217
+ throw new Error(`No open pull request found for current branch '${currentBranch}'. Specify a PR ID explicitly.`);
51942
52218
  }
51943
52219
  prId = matchingPR.id;
51944
52220
  }
@@ -51947,21 +52223,11 @@ class EditPRCommand extends BaseCommand {
51947
52223
  try {
51948
52224
  body = fs.readFileSync(options.bodyFile, "utf-8");
51949
52225
  } catch (err) {
51950
- const error = new Error(`Failed to read file '${options.bodyFile}': ${err instanceof Error ? err.message : "Unknown error"}`);
51951
- this.output.error(error.message);
51952
- if (true) {
51953
- process.exitCode = 1;
51954
- }
51955
- throw error;
52226
+ throw new Error(`Failed to read file '${options.bodyFile}': ${err instanceof Error ? err.message : "Unknown error"}`);
51956
52227
  }
51957
52228
  }
51958
52229
  if (!options.title && !body) {
51959
- const error = new Error("At least one of --title or --body (or --body-file) is required.");
51960
- this.output.error(error.message);
51961
- if (true) {
51962
- process.exitCode = 1;
51963
- }
51964
- throw error;
52230
+ throw new Error("At least one of --title or --body (or --body-file) is required.");
51965
52231
  }
51966
52232
  const request = {
51967
52233
  type: "pullrequest"
@@ -51972,26 +52238,25 @@ class EditPRCommand extends BaseCommand {
51972
52238
  if (body) {
51973
52239
  request.description = body;
51974
52240
  }
51975
- try {
51976
- const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdPut({
51977
- workspace: repoContext.workspace,
51978
- repoSlug: repoContext.repoSlug,
51979
- pullRequestId: prId,
51980
- body: request
51981
- });
51982
- const pr = response.data;
51983
- const links = pr.links;
51984
- this.output.success(`Updated pull request #${pr.id}`);
51985
- this.output.text(` ${source_default.dim("Title:")} ${pr.title}`);
51986
- if (pr.description) {
51987
- const truncatedDesc = pr.description.length > 100 ? pr.description.substring(0, 100) + "..." : pr.description;
51988
- this.output.text(` ${source_default.dim("Description:")} ${truncatedDesc}`);
51989
- }
51990
- this.output.text(` ${source_default.dim("URL:")} ${links?.html?.href}`);
51991
- } catch (error) {
51992
- this.handleError(error, context);
51993
- throw error;
52241
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdPut({
52242
+ workspace: repoContext.workspace,
52243
+ repoSlug: repoContext.repoSlug,
52244
+ pullRequestId: prId,
52245
+ body: request
52246
+ });
52247
+ const pr = response.data;
52248
+ const links = pr.links;
52249
+ if (context.globalOptions.json) {
52250
+ this.output.json(pr);
52251
+ return;
52252
+ }
52253
+ this.output.success(`Updated pull request #${pr.id}`);
52254
+ this.output.text(` ${this.output.dim("Title:")} ${pr.title}`);
52255
+ if (pr.description) {
52256
+ const truncatedDesc = pr.description.length > 100 ? pr.description.substring(0, 100) + "..." : pr.description;
52257
+ this.output.text(` ${this.output.dim("Description:")} ${truncatedDesc}`);
51994
52258
  }
52259
+ this.output.text(` ${this.output.dim("URL:")} ${links?.html?.href}`);
51995
52260
  }
51996
52261
  }
51997
52262
 
@@ -52011,7 +52276,7 @@ class MergePRCommand extends BaseCommand {
52011
52276
  ...context.globalOptions,
52012
52277
  ...options
52013
52278
  });
52014
- const prId = parseInt(options.id, 10);
52279
+ const prId = Number.parseInt(options.id, 10);
52015
52280
  const request = {
52016
52281
  type: "pullrequest_merge_parameters"
52017
52282
  };
@@ -52024,19 +52289,22 @@ class MergePRCommand extends BaseCommand {
52024
52289
  if (options.strategy) {
52025
52290
  request.merge_strategy = options.strategy;
52026
52291
  }
52027
- try {
52028
- const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdMergePost({
52029
- workspace: repoContext.workspace,
52030
- repoSlug: repoContext.repoSlug,
52292
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdMergePost({
52293
+ workspace: repoContext.workspace,
52294
+ repoSlug: repoContext.repoSlug,
52295
+ pullRequestId: prId,
52296
+ body: request
52297
+ });
52298
+ const pr = response.data;
52299
+ if (context.globalOptions.json) {
52300
+ this.output.json({
52301
+ success: true,
52031
52302
  pullRequestId: prId,
52032
- body: request
52303
+ pullRequest: pr
52033
52304
  });
52034
- const pr = response.data;
52035
- this.output.success(`Merged pull request #${prId}: ${pr.title}`);
52036
- } catch (error) {
52037
- this.handleError(error, context);
52038
- throw error;
52305
+ return;
52039
52306
  }
52307
+ this.output.success(`Merged pull request #${prId}: ${pr.title}`);
52040
52308
  }
52041
52309
  }
52042
52310
 
@@ -52056,18 +52324,20 @@ class ApprovePRCommand extends BaseCommand {
52056
52324
  ...context.globalOptions,
52057
52325
  ...options
52058
52326
  });
52059
- const prId = parseInt(options.id, 10);
52060
- try {
52061
- await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdApprovePost({
52062
- workspace: repoContext.workspace,
52063
- repoSlug: repoContext.repoSlug,
52327
+ const prId = Number.parseInt(options.id, 10);
52328
+ await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdApprovePost({
52329
+ workspace: repoContext.workspace,
52330
+ repoSlug: repoContext.repoSlug,
52331
+ pullRequestId: prId
52332
+ });
52333
+ if (context.globalOptions.json) {
52334
+ this.output.json({
52335
+ success: true,
52064
52336
  pullRequestId: prId
52065
52337
  });
52066
- this.output.success(`Approved pull request #${prId}`);
52067
- } catch (error) {
52068
- this.handleError(error, context);
52069
- throw error;
52338
+ return;
52070
52339
  }
52340
+ this.output.success(`Approved pull request #${prId}`);
52071
52341
  }
52072
52342
  }
52073
52343
 
@@ -52087,19 +52357,22 @@ class DeclinePRCommand extends BaseCommand {
52087
52357
  ...context.globalOptions,
52088
52358
  ...options
52089
52359
  });
52090
- const prId = parseInt(options.id, 10);
52091
- try {
52092
- const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdDeclinePost({
52093
- workspace: repoContext.workspace,
52094
- repoSlug: repoContext.repoSlug,
52095
- pullRequestId: prId
52360
+ const prId = Number.parseInt(options.id, 10);
52361
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdDeclinePost({
52362
+ workspace: repoContext.workspace,
52363
+ repoSlug: repoContext.repoSlug,
52364
+ pullRequestId: prId
52365
+ });
52366
+ const pr = response.data;
52367
+ if (context.globalOptions.json) {
52368
+ this.output.json({
52369
+ success: true,
52370
+ pullRequestId: prId,
52371
+ pullRequest: pr
52096
52372
  });
52097
- const pr = response.data;
52098
- this.output.success(`Declined pull request #${prId}: ${pr.title}`);
52099
- } catch (error) {
52100
- this.handleError(error, context);
52101
- throw error;
52373
+ return;
52102
52374
  }
52375
+ this.output.success(`Declined pull request #${prId}: ${pr.title}`);
52103
52376
  }
52104
52377
  }
52105
52378
 
@@ -52119,24 +52392,27 @@ class ReadyPRCommand extends BaseCommand {
52119
52392
  ...context.globalOptions,
52120
52393
  ...options
52121
52394
  });
52122
- const prId = parseInt(options.id, 10);
52123
- try {
52124
- const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdPut({
52125
- workspace: repoContext.workspace,
52126
- repoSlug: repoContext.repoSlug,
52395
+ const prId = Number.parseInt(options.id, 10);
52396
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdPut({
52397
+ workspace: repoContext.workspace,
52398
+ repoSlug: repoContext.repoSlug,
52399
+ pullRequestId: prId,
52400
+ body: {
52401
+ type: "pullrequest",
52402
+ draft: false
52403
+ }
52404
+ });
52405
+ const pr = response.data;
52406
+ if (context.globalOptions.json) {
52407
+ this.output.json({
52408
+ success: true,
52127
52409
  pullRequestId: prId,
52128
- body: {
52129
- type: "pullrequest",
52130
- draft: false
52131
- }
52410
+ pullRequest: pr
52132
52411
  });
52133
- const pr = response.data;
52134
- this.output.success(`Marked pull request #${prId} as ready for review`);
52135
- this.output.text(` ${pr.title}`);
52136
- } catch (error) {
52137
- this.handleError(error, context);
52138
- throw error;
52412
+ return;
52139
52413
  }
52414
+ this.output.success(`Marked pull request #${prId} as ready for review`);
52415
+ this.output.text(` ${pr.title}`);
52140
52416
  }
52141
52417
  }
52142
52418
 
@@ -52158,32 +52434,48 @@ class CheckoutPRCommand extends BaseCommand {
52158
52434
  ...context.globalOptions,
52159
52435
  ...options
52160
52436
  });
52161
- const prId = parseInt(options.id, 10);
52437
+ const prId = Number.parseInt(options.id, 10);
52438
+ const prResponse = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
52439
+ workspace: repoContext.workspace,
52440
+ repoSlug: repoContext.repoSlug,
52441
+ pullRequestId: prId
52442
+ });
52443
+ const pr = prResponse.data;
52444
+ const branchName = pr.source?.branch?.name;
52445
+ const localBranchName = `pr-${prId}`;
52446
+ if (!branchName) {
52447
+ throw new Error("Pull request source branch not found");
52448
+ }
52449
+ await this.gitService.fetch();
52450
+ let checkedOutBranch;
52162
52451
  try {
52163
- const prResponse = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
52164
- workspace: repoContext.workspace,
52165
- repoSlug: repoContext.repoSlug,
52166
- pullRequestId: prId
52167
- });
52168
- const pr = prResponse.data;
52169
- const branchName = pr.source?.branch?.name;
52170
- const localBranchName = `pr-${prId}`;
52171
- if (!branchName) {
52172
- throw new Error("Pull request source branch not found");
52452
+ await this.gitService.checkout(branchName);
52453
+ checkedOutBranch = branchName;
52454
+ if (context.globalOptions.json) {
52455
+ this.output.json({
52456
+ success: true,
52457
+ pullRequestId: prId,
52458
+ branch: checkedOutBranch,
52459
+ pullRequest: pr
52460
+ });
52461
+ return;
52173
52462
  }
52174
- await this.gitService.fetch();
52175
- try {
52176
- await this.gitService.checkout(branchName);
52177
- this.output.success(`Checked out PR #${prId} as '${branchName}'`);
52178
- } catch {
52179
- await this.gitService.checkoutNewBranch(localBranchName, `origin/${branchName}`);
52180
- this.output.success(`Checked out PR #${prId} as '${localBranchName}'`);
52463
+ this.output.success(`Checked out PR #${prId} as '${branchName}'`);
52464
+ } catch {
52465
+ await this.gitService.checkoutNewBranch(localBranchName, `origin/${branchName}`);
52466
+ checkedOutBranch = localBranchName;
52467
+ if (context.globalOptions.json) {
52468
+ this.output.json({
52469
+ success: true,
52470
+ pullRequestId: prId,
52471
+ branch: checkedOutBranch,
52472
+ pullRequest: pr
52473
+ });
52474
+ return;
52181
52475
  }
52182
- this.output.text(` Title: ${pr.title}`);
52183
- } catch (error) {
52184
- this.handleError(error, context);
52185
- throw error;
52476
+ this.output.success(`Checked out PR #${prId} as '${localBranchName}'`);
52186
52477
  }
52478
+ this.output.text(` Title: ${pr.title}`);
52187
52479
  }
52188
52480
  }
52189
52481
 
@@ -52211,9 +52503,9 @@ class DiffPRCommand extends BaseCommand {
52211
52503
  });
52212
52504
  let prId;
52213
52505
  if (options.id) {
52214
- prId = parseInt(options.id, 10);
52215
- if (isNaN(prId)) {
52216
- throw new Error("Invalid PR ID");
52506
+ prId = Number.parseInt(options.id, 10);
52507
+ if (Number.isNaN(prId)) {
52508
+ throw new TypeError("Invalid PR ID");
52217
52509
  }
52218
52510
  } else {
52219
52511
  const currentBranch = await this.gitService.getCurrentBranch();
@@ -52229,34 +52521,58 @@ class DiffPRCommand extends BaseCommand {
52229
52521
  prId = pr.id;
52230
52522
  }
52231
52523
  if (options.web) {
52232
- const prResponse = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
52233
- workspace: repoContext.workspace,
52234
- repoSlug: repoContext.repoSlug,
52235
- pullRequestId: prId
52236
- });
52237
- const diffUrl = prResponse.data.links?.diff?.href;
52238
- if (!diffUrl) {
52239
- throw new Error("Could not get diff URL");
52524
+ const webUrl = await this.getWebDiffUrl(repoContext.workspace, repoContext.repoSlug, prId);
52525
+ if (context.globalOptions.json) {
52526
+ this.output.json({
52527
+ workspace: repoContext.workspace,
52528
+ repoSlug: repoContext.repoSlug,
52529
+ pullRequestId: prId,
52530
+ mode: "web",
52531
+ url: webUrl
52532
+ });
52533
+ return;
52240
52534
  }
52241
- const webUrl = diffUrl.replace(/api\.bitbucket\.org\/2\.0\/repositories\/(.*?)\/pullrequests\/(\d+)\/diff/, "bitbucket.org/$1/pull-requests/$2/diff");
52242
- await this.openInBrowser(webUrl, context);
52535
+ await this.openInBrowser(webUrl);
52243
52536
  return;
52244
52537
  }
52245
52538
  if (options.stat) {
52246
- await this.showStat(repoContext.workspace, repoContext.repoSlug, prId, context);
52539
+ const statResult = await this.showStat(repoContext.workspace, repoContext.repoSlug, prId, Boolean(context.globalOptions.json));
52540
+ if (context.globalOptions.json) {
52541
+ this.output.json({
52542
+ workspace: repoContext.workspace,
52543
+ repoSlug: repoContext.repoSlug,
52544
+ pullRequestId: prId,
52545
+ mode: "stat",
52546
+ ...statResult
52547
+ });
52548
+ }
52247
52549
  return;
52248
52550
  }
52249
52551
  if (options.nameOnly) {
52250
- await this.showNameOnly(repoContext.workspace, repoContext.repoSlug, prId, context);
52552
+ const files = await this.showNameOnly(repoContext.workspace, repoContext.repoSlug, prId, Boolean(context.globalOptions.json));
52553
+ if (context.globalOptions.json) {
52554
+ this.output.json({
52555
+ workspace: repoContext.workspace,
52556
+ repoSlug: repoContext.repoSlug,
52557
+ pullRequestId: prId,
52558
+ mode: "name-only",
52559
+ files
52560
+ });
52561
+ }
52251
52562
  return;
52252
52563
  }
52253
- await this.showDiff(repoContext.workspace, repoContext.repoSlug, prId, options, context);
52254
- }
52255
- async openInBrowser(url2, context) {
52564
+ const diff = await this.showDiff(repoContext.workspace, repoContext.repoSlug, prId, options, Boolean(context.globalOptions.json));
52256
52565
  if (context.globalOptions.json) {
52257
- this.output.json({ url: url2 });
52258
- return;
52566
+ this.output.json({
52567
+ workspace: repoContext.workspace,
52568
+ repoSlug: repoContext.repoSlug,
52569
+ pullRequestId: prId,
52570
+ mode: "diff",
52571
+ diff
52572
+ });
52259
52573
  }
52574
+ }
52575
+ async openInBrowser(url2) {
52260
52576
  this.output.info(`Opening ${url2} in your browser...`);
52261
52577
  const platform = process.platform;
52262
52578
  let command;
@@ -52269,7 +52585,19 @@ class DiffPRCommand extends BaseCommand {
52269
52585
  }
52270
52586
  await execAsync(command);
52271
52587
  }
52272
- async showStat(workspace, repoSlug, prId, context) {
52588
+ async getWebDiffUrl(workspace, repoSlug, prId) {
52589
+ const prResponse = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
52590
+ workspace,
52591
+ repoSlug,
52592
+ pullRequestId: prId
52593
+ });
52594
+ const diffUrl = prResponse.data.links?.diff?.href;
52595
+ if (!diffUrl) {
52596
+ throw new Error("Could not get diff URL");
52597
+ }
52598
+ return diffUrl.replace(/api\.bitbucket\.org\/2\.0\/repositories\/(.*?)\/pullrequests\/(\d+)\/diff/, "bitbucket.org/$1/pull-requests/$2/diff");
52599
+ }
52600
+ async showStat(workspace, repoSlug, prId, useJson) {
52273
52601
  const diffstatResponse = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdDiffstatGet({
52274
52602
  workspace,
52275
52603
  repoSlug,
@@ -52287,21 +52615,35 @@ class DiffPRCommand extends BaseCommand {
52287
52615
  const totalAdditions = files.reduce((sum, f) => sum + f.additions, 0);
52288
52616
  const totalDeletions = files.reduce((sum, f) => sum + f.deletions, 0);
52289
52617
  const filesChanged = files.length;
52618
+ if (useJson) {
52619
+ return {
52620
+ files,
52621
+ filesChanged,
52622
+ totalAdditions,
52623
+ totalDeletions
52624
+ };
52625
+ }
52290
52626
  for (const file of files) {
52291
- const additions = file.additions > 0 ? source_default.green(`+${file.additions}`) : "";
52292
- const deletions = file.deletions > 0 ? source_default.red(`-${file.deletions}`) : "";
52627
+ const additions = file.additions > 0 ? this.output.green(`+${file.additions}`) : "";
52628
+ const deletions = file.deletions > 0 ? this.output.red(`-${file.deletions}`) : "";
52293
52629
  const stats = [additions, deletions].filter(Boolean).join(" ");
52294
52630
  this.output.text(`${file.path} ${stats ? `| ${stats}` : ""}`);
52295
52631
  }
52296
52632
  this.output.text("");
52297
52633
  const summary = [
52298
- `${filesChanged} file${filesChanged !== 1 ? "s" : ""} changed`,
52299
- totalAdditions > 0 ? source_default.green(`${totalAdditions} insertion${totalAdditions !== 1 ? "s" : ""}(+)`) : null,
52300
- totalDeletions > 0 ? source_default.red(`${totalDeletions} deletion${totalDeletions !== 1 ? "s" : ""}(-)`) : null
52634
+ `${filesChanged} file${filesChanged === 1 ? "" : "s"} changed`,
52635
+ totalAdditions > 0 ? this.output.green(`${totalAdditions} insertion${totalAdditions === 1 ? "" : "s"}(+)`) : null,
52636
+ totalDeletions > 0 ? this.output.red(`${totalDeletions} deletion${totalDeletions === 1 ? "" : "s"}(-)`) : null
52301
52637
  ].filter(Boolean).join(", ");
52302
52638
  this.output.text(summary);
52639
+ return {
52640
+ files,
52641
+ filesChanged,
52642
+ totalAdditions,
52643
+ totalDeletions
52644
+ };
52303
52645
  }
52304
- async showNameOnly(workspace, repoSlug, prId, context) {
52646
+ async showNameOnly(workspace, repoSlug, prId, useJson) {
52305
52647
  const diffstatResponse = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdDiffstatGet({
52306
52648
  workspace,
52307
52649
  repoSlug,
@@ -52309,11 +52651,15 @@ class DiffPRCommand extends BaseCommand {
52309
52651
  });
52310
52652
  const diffstat = diffstatResponse.data;
52311
52653
  const fileNames = Array.from(diffstat.values ?? []).map((file) => file.new?.path || file.old?.path || "unknown");
52654
+ if (useJson) {
52655
+ return fileNames;
52656
+ }
52312
52657
  for (const fileName of fileNames) {
52313
52658
  this.output.text(fileName);
52314
52659
  }
52660
+ return fileNames;
52315
52661
  }
52316
- async showDiff(workspace, repoSlug, prId, options, context) {
52662
+ async showDiff(workspace, repoSlug, prId, options, useJson) {
52317
52663
  const diffResponse = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdDiffGet({
52318
52664
  workspace,
52319
52665
  repoSlug,
@@ -52321,8 +52667,12 @@ class DiffPRCommand extends BaseCommand {
52321
52667
  });
52322
52668
  const diff = diffResponse.data;
52323
52669
  const shouldColorize = this.shouldColorize(options.color);
52670
+ if (useJson) {
52671
+ return String(diff);
52672
+ }
52324
52673
  const colorizedDiff = shouldColorize ? this.colorizeDiff(String(diff)) : String(diff);
52325
52674
  this.output.text(colorizedDiff);
52675
+ return String(diff);
52326
52676
  }
52327
52677
  shouldColorize(colorOption) {
52328
52678
  if (!colorOption || colorOption === "auto") {
@@ -52335,15 +52685,15 @@ class DiffPRCommand extends BaseCommand {
52335
52685
  `);
52336
52686
  return lines.map((line) => {
52337
52687
  if (line.startsWith("+") && !line.startsWith("+++")) {
52338
- return source_default.green(line);
52688
+ return this.output.green(line);
52339
52689
  } else if (line.startsWith("-") && !line.startsWith("---")) {
52340
- return source_default.red(line);
52690
+ return this.output.red(line);
52341
52691
  } else if (line.startsWith("@@")) {
52342
- return source_default.cyan(line);
52692
+ return this.output.cyan(line);
52343
52693
  } else if (line.startsWith("diff --git")) {
52344
- return source_default.bold(line);
52694
+ return this.output.bold(line);
52345
52695
  } else if (line.startsWith("index ") || line.startsWith("---") || line.startsWith("+++")) {
52346
- return source_default.dim(line);
52696
+ return this.output.dim(line);
52347
52697
  }
52348
52698
  return line;
52349
52699
  }).join(`
@@ -52367,40 +52717,47 @@ class ActivityPRCommand extends BaseCommand {
52367
52717
  ...context.globalOptions,
52368
52718
  ...options
52369
52719
  });
52370
- const prId = parseInt(options.id, 10);
52371
- const limit = options.limit ? parseInt(options.limit, 10) : 25;
52372
- try {
52373
- const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdActivityGet({
52720
+ const prId = Number.parseInt(options.id, 10);
52721
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdActivityGet({
52722
+ workspace: repoContext.workspace,
52723
+ repoSlug: repoContext.repoSlug,
52724
+ pullRequestId: prId
52725
+ });
52726
+ const data = response.data;
52727
+ const values = data?.values ? Array.from(data.values) : [];
52728
+ const filterTypes = this.parseTypeFilter(options.type);
52729
+ const activities = filterTypes.length > 0 ? values.filter((activity) => filterTypes.includes(this.getActivityType(activity))) : values;
52730
+ if (context.globalOptions.json) {
52731
+ this.output.json({
52374
52732
  workspace: repoContext.workspace,
52375
52733
  repoSlug: repoContext.repoSlug,
52376
- pullRequestId: prId
52734
+ pullRequestId: prId,
52735
+ filters: {
52736
+ types: filterTypes
52737
+ },
52738
+ count: activities.length,
52739
+ activities
52377
52740
  });
52378
- const data = response.data;
52379
- const values = data?.values ? Array.from(data.values) : [];
52380
- const filterTypes = this.parseTypeFilter(options.type);
52381
- const activities = filterTypes.length > 0 ? values.filter((activity) => filterTypes.includes(this.getActivityType(activity))) : values;
52382
- if (activities.length === 0) {
52383
- if (filterTypes.length > 0) {
52384
- this.output.info("No activity entries matched the requested filter");
52385
- } else {
52386
- this.output.info("No activity found on this pull request");
52387
- }
52388
- return;
52741
+ return;
52742
+ }
52743
+ if (activities.length === 0) {
52744
+ if (filterTypes.length > 0) {
52745
+ this.output.info("No activity entries matched the requested filter");
52746
+ } else {
52747
+ this.output.info("No activity found on this pull request");
52389
52748
  }
52390
- const rows = activities.map((activity) => {
52391
- const activityType = this.getActivityType(activity);
52392
- return [
52393
- activityType.toUpperCase(),
52394
- this.getActorName(activity),
52395
- this.formatActivityDate(activity),
52396
- this.buildActivityDetails(activity, activityType)
52397
- ];
52398
- });
52399
- this.output.table(["TYPE", "ACTOR", "DATE", "DETAILS"], rows);
52400
- } catch (error) {
52401
- this.handleError(error, context);
52402
- throw error;
52749
+ return;
52403
52750
  }
52751
+ const rows = activities.map((activity) => {
52752
+ const activityType = this.getActivityType(activity);
52753
+ return [
52754
+ activityType.toUpperCase(),
52755
+ this.getActorName(activity),
52756
+ this.formatActivityDate(activity),
52757
+ this.buildActivityDetails(activity, activityType)
52758
+ ];
52759
+ });
52760
+ this.output.table(["TYPE", "ACTOR", "DATE", "DETAILS"], rows);
52404
52761
  }
52405
52762
  parseTypeFilter(typeOption) {
52406
52763
  if (!typeOption) {
@@ -52513,24 +52870,27 @@ class CommentPRCommand extends BaseCommand {
52513
52870
  ...context.globalOptions,
52514
52871
  ...options
52515
52872
  });
52516
- const prId = parseInt(options.id, 10);
52517
- try {
52518
- await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdCommentsPost({
52519
- workspace: repoContext.workspace,
52520
- repoSlug: repoContext.repoSlug,
52521
- pullRequestId: prId,
52522
- body: {
52523
- type: "pullrequest_comment",
52524
- content: {
52525
- raw: options.message
52526
- }
52873
+ const prId = Number.parseInt(options.id, 10);
52874
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdCommentsPost({
52875
+ workspace: repoContext.workspace,
52876
+ repoSlug: repoContext.repoSlug,
52877
+ pullRequestId: prId,
52878
+ body: {
52879
+ type: "pullrequest_comment",
52880
+ content: {
52881
+ raw: options.message
52527
52882
  }
52883
+ }
52884
+ });
52885
+ if (context.globalOptions.json) {
52886
+ this.output.json({
52887
+ success: true,
52888
+ pullRequestId: prId,
52889
+ comment: response.data
52528
52890
  });
52529
- this.output.success(`Added comment to pull request #${prId}`);
52530
- } catch (error) {
52531
- this.handleError(error, context);
52532
- throw error;
52891
+ return;
52533
52892
  }
52893
+ this.output.success(`Added comment to pull request #${prId}`);
52534
52894
  }
52535
52895
  }
52536
52896
 
@@ -52550,34 +52910,36 @@ class ListCommentsPRCommand extends BaseCommand {
52550
52910
  ...context.globalOptions,
52551
52911
  ...options
52552
52912
  });
52553
- const prId = parseInt(options.id, 10);
52554
- const limit = options.limit ? parseInt(options.limit, 10) : 25;
52555
- try {
52556
- const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdCommentsGet({
52557
- workspace: repoContext.workspace,
52558
- repoSlug: repoContext.repoSlug,
52559
- pullRequestId: prId
52560
- });
52561
- const data = response.data;
52562
- const values = data.values ? Array.from(data.values) : [];
52563
- if (values.length === 0) {
52564
- this.output.info("No comments found on this pull request");
52565
- return;
52566
- }
52567
- const rows = values.map((comment) => {
52568
- const content = comment.content?.raw ?? "";
52569
- return [
52570
- comment.id?.toString() ?? "",
52571
- comment.user?.nickname ?? comment.user?.display_name ?? "Unknown",
52572
- comment.deleted ? "[deleted]" : options.truncate === false ? content : content.slice(0, 60) + (content.length > 60 ? "..." : ""),
52573
- this.output.formatDate(comment.created_on ?? "")
52574
- ];
52913
+ const prId = Number.parseInt(options.id, 10);
52914
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdCommentsGet({
52915
+ workspace: repoContext.workspace,
52916
+ repoSlug: repoContext.repoSlug,
52917
+ pullRequestId: prId
52918
+ });
52919
+ const data = response.data;
52920
+ const values = data.values ? Array.from(data.values) : [];
52921
+ if (context.globalOptions.json) {
52922
+ this.output.json({
52923
+ pullRequestId: prId,
52924
+ count: values.length,
52925
+ comments: values
52575
52926
  });
52576
- this.output.table(["ID", "Author", "Content", "Date"], rows);
52577
- } catch (error) {
52578
- this.handleError(error, context);
52579
- throw error;
52927
+ return;
52928
+ }
52929
+ if (values.length === 0) {
52930
+ this.output.info("No comments found on this pull request");
52931
+ return;
52580
52932
  }
52933
+ const rows = values.map((comment) => {
52934
+ const content = comment.content?.raw ?? "";
52935
+ return [
52936
+ comment.id?.toString() ?? "",
52937
+ comment.user?.nickname ?? comment.user?.display_name ?? "Unknown",
52938
+ comment.deleted ? "[deleted]" : options.truncate === false ? content : content.slice(0, 60) + (content.length > 60 ? "..." : ""),
52939
+ this.output.formatDate(comment.created_on ?? "")
52940
+ ];
52941
+ });
52942
+ this.output.table(["ID", "Author", "Content", "Date"], rows);
52581
52943
  }
52582
52944
  }
52583
52945
 
@@ -52597,26 +52959,30 @@ class EditCommentPRCommand extends BaseCommand {
52597
52959
  ...context.globalOptions,
52598
52960
  ...options
52599
52961
  });
52600
- const prId = parseInt(options.prId, 10);
52601
- const commentId = parseInt(options.commentId, 10);
52602
- try {
52603
- await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdCommentsCommentIdPut({
52604
- workspace: repoContext.workspace,
52605
- repoSlug: repoContext.repoSlug,
52962
+ const prId = Number.parseInt(options.prId, 10);
52963
+ const commentId = Number.parseInt(options.commentId, 10);
52964
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdCommentsCommentIdPut({
52965
+ workspace: repoContext.workspace,
52966
+ repoSlug: repoContext.repoSlug,
52967
+ pullRequestId: prId,
52968
+ commentId,
52969
+ body: {
52970
+ type: "pullrequest_comment",
52971
+ content: {
52972
+ raw: options.message
52973
+ }
52974
+ }
52975
+ });
52976
+ if (context.globalOptions.json) {
52977
+ this.output.json({
52978
+ success: true,
52606
52979
  pullRequestId: prId,
52607
52980
  commentId,
52608
- body: {
52609
- type: "pullrequest_comment",
52610
- content: {
52611
- raw: options.message
52612
- }
52613
- }
52981
+ comment: response.data
52614
52982
  });
52615
- this.output.success(`Updated comment #${commentId}`);
52616
- } catch (error) {
52617
- this.handleError(error, context);
52618
- throw error;
52983
+ return;
52619
52984
  }
52985
+ this.output.success(`Updated comment #${commentId} on PR #${prId}`);
52620
52986
  }
52621
52987
  }
52622
52988
 
@@ -52636,20 +53002,23 @@ class DeleteCommentPRCommand extends BaseCommand {
52636
53002
  ...context.globalOptions,
52637
53003
  ...options
52638
53004
  });
52639
- const prId = parseInt(options.prId, 10);
52640
- const commentId = parseInt(options.commentId, 10);
52641
- try {
52642
- await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdCommentsCommentIdDelete({
52643
- workspace: repoContext.workspace,
52644
- repoSlug: repoContext.repoSlug,
53005
+ const prId = Number.parseInt(options.prId, 10);
53006
+ const commentId = Number.parseInt(options.commentId, 10);
53007
+ await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdCommentsCommentIdDelete({
53008
+ workspace: repoContext.workspace,
53009
+ repoSlug: repoContext.repoSlug,
53010
+ pullRequestId: prId,
53011
+ commentId
53012
+ });
53013
+ if (context.globalOptions.json) {
53014
+ this.output.json({
53015
+ success: true,
52645
53016
  pullRequestId: prId,
52646
53017
  commentId
52647
53018
  });
52648
- this.output.success(`Deleted comment #${commentId} from PR #${prId}`);
52649
- } catch (error) {
52650
- this.handleError(error, context);
52651
- throw error;
53019
+ return;
52652
53020
  }
53021
+ this.output.success(`Deleted comment #${commentId} from PR #${prId}`);
52653
53022
  }
52654
53023
  }
52655
53024
 
@@ -52671,37 +53040,44 @@ class AddReviewerPRCommand extends BaseCommand {
52671
53040
  ...context.globalOptions,
52672
53041
  ...options
52673
53042
  });
52674
- const prId = parseInt(options.id, 10);
52675
- try {
52676
- const userResponse = await this.usersApi.usersSelectedUserGet({
52677
- selectedUser: options.username
52678
- });
52679
- const user = userResponse.data;
52680
- const prResponse = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
52681
- workspace: repoContext.workspace,
52682
- repoSlug: repoContext.repoSlug,
52683
- pullRequestId: prId
52684
- });
52685
- const pr = prResponse.data;
52686
- const existingReviewers = pr.reviewers ? Array.from(pr.reviewers) : [];
52687
- const reviewerUuids = existingReviewers.map((r) => r.uuid).filter(Boolean);
52688
- if (!reviewerUuids.includes(user.uuid)) {
52689
- reviewerUuids.push(user.uuid);
53043
+ const prId = Number.parseInt(options.id, 10);
53044
+ const userResponse = await this.usersApi.usersSelectedUserGet({
53045
+ selectedUser: options.username
53046
+ });
53047
+ const user = userResponse.data;
53048
+ const prResponse = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
53049
+ workspace: repoContext.workspace,
53050
+ repoSlug: repoContext.repoSlug,
53051
+ pullRequestId: prId
53052
+ });
53053
+ const pr = prResponse.data;
53054
+ const existingReviewers = pr.reviewers ? Array.from(pr.reviewers) : [];
53055
+ const reviewerUuids = existingReviewers.map((r) => r.uuid).filter(Boolean);
53056
+ if (!reviewerUuids.includes(user.uuid)) {
53057
+ reviewerUuids.push(user.uuid);
53058
+ }
53059
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdPut({
53060
+ workspace: repoContext.workspace,
53061
+ repoSlug: repoContext.repoSlug,
53062
+ pullRequestId: prId,
53063
+ body: {
53064
+ type: "pullrequest",
53065
+ reviewers: reviewerUuids.map((uuid) => ({ uuid }))
52690
53066
  }
52691
- await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdPut({
52692
- workspace: repoContext.workspace,
52693
- repoSlug: repoContext.repoSlug,
53067
+ });
53068
+ if (context.globalOptions.json) {
53069
+ this.output.json({
53070
+ success: true,
52694
53071
  pullRequestId: prId,
52695
- body: {
52696
- type: "pullrequest",
52697
- reviewers: reviewerUuids.map((uuid) => ({ uuid }))
52698
- }
53072
+ reviewer: {
53073
+ username: options.username,
53074
+ uuid: user.uuid
53075
+ },
53076
+ pullRequest: response.data
52699
53077
  });
52700
- this.output.success(`Added ${options.username} as reviewer to pull request #${prId}`);
52701
- } catch (error) {
52702
- this.handleError(error, context);
52703
- throw error;
53078
+ return;
52704
53079
  }
53080
+ this.output.success(`Added ${options.username} as reviewer to pull request #${prId}`);
52705
53081
  }
52706
53082
  }
52707
53083
 
@@ -52723,34 +53099,41 @@ class RemoveReviewerPRCommand extends BaseCommand {
52723
53099
  ...context.globalOptions,
52724
53100
  ...options
52725
53101
  });
52726
- const prId = parseInt(options.id, 10);
52727
- try {
52728
- const userResponse = await this.usersApi.usersSelectedUserGet({
52729
- selectedUser: options.username
52730
- });
52731
- const user = userResponse.data;
52732
- const prResponse = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
52733
- workspace: repoContext.workspace,
52734
- repoSlug: repoContext.repoSlug,
52735
- pullRequestId: prId
52736
- });
52737
- const pr = prResponse.data;
52738
- const existingReviewers = pr.reviewers ? Array.from(pr.reviewers) : [];
52739
- const reviewerUuids = existingReviewers.map((r) => r.uuid).filter((uuid) => uuid && uuid !== user.uuid);
52740
- await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdPut({
52741
- workspace: repoContext.workspace,
52742
- repoSlug: repoContext.repoSlug,
53102
+ const prId = Number.parseInt(options.id, 10);
53103
+ const userResponse = await this.usersApi.usersSelectedUserGet({
53104
+ selectedUser: options.username
53105
+ });
53106
+ const user = userResponse.data;
53107
+ const prResponse = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
53108
+ workspace: repoContext.workspace,
53109
+ repoSlug: repoContext.repoSlug,
53110
+ pullRequestId: prId
53111
+ });
53112
+ const pr = prResponse.data;
53113
+ const existingReviewers = pr.reviewers ? Array.from(pr.reviewers) : [];
53114
+ const reviewerUuids = existingReviewers.map((r) => r.uuid).filter((uuid) => uuid && uuid !== user.uuid);
53115
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdPut({
53116
+ workspace: repoContext.workspace,
53117
+ repoSlug: repoContext.repoSlug,
53118
+ pullRequestId: prId,
53119
+ body: {
53120
+ type: "pullrequest",
53121
+ reviewers: reviewerUuids.map((uuid) => ({ uuid }))
53122
+ }
53123
+ });
53124
+ if (context.globalOptions.json) {
53125
+ this.output.json({
53126
+ success: true,
52743
53127
  pullRequestId: prId,
52744
- body: {
52745
- type: "pullrequest",
52746
- reviewers: reviewerUuids.map((uuid) => ({ uuid }))
52747
- }
53128
+ reviewer: {
53129
+ username: options.username,
53130
+ uuid: user.uuid
53131
+ },
53132
+ pullRequest: response.data
52748
53133
  });
52749
- this.output.success(`Removed ${options.username} as reviewer from pull request #${prId}`);
52750
- } catch (error) {
52751
- this.handleError(error, context);
52752
- throw error;
53134
+ return;
52753
53135
  }
53136
+ this.output.success(`Removed ${options.username} as reviewer from pull request #${prId}`);
52754
53137
  }
52755
53138
  }
52756
53139
 
@@ -52770,32 +53153,171 @@ class ListReviewersPRCommand extends BaseCommand {
52770
53153
  ...context.globalOptions,
52771
53154
  ...options
52772
53155
  });
52773
- const prId = parseInt(options.id, 10);
52774
- try {
52775
- const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
53156
+ const prId = Number.parseInt(options.id, 10);
53157
+ const response = await this.pullrequestsApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdGet({
53158
+ workspace: repoContext.workspace,
53159
+ repoSlug: repoContext.repoSlug,
53160
+ pullRequestId: prId
53161
+ });
53162
+ const pr = response.data;
53163
+ const reviewers = Array.from(pr.reviewers ?? []);
53164
+ if (context.globalOptions.json) {
53165
+ this.output.json({
53166
+ pullRequestId: prId,
53167
+ count: reviewers.length,
53168
+ reviewers
53169
+ });
53170
+ return;
53171
+ }
53172
+ if (reviewers.length === 0) {
53173
+ this.output.info("No reviewers assigned to this pull request");
53174
+ } else {
53175
+ this.output.table(["Display Name", "Account ID"], reviewers.map((r) => [r.display_name ?? "Unknown", r.account_id ?? ""]));
53176
+ }
53177
+ }
53178
+ }
53179
+
53180
+ // src/commands/pr/checks.command.ts
53181
+ class ChecksPRCommand extends BaseCommand {
53182
+ commitStatusesApi;
53183
+ contextService;
53184
+ name = "checks";
53185
+ description = "Show CI/CD checks and build status for a pull request";
53186
+ constructor(commitStatusesApi, contextService, output) {
53187
+ super(output);
53188
+ this.commitStatusesApi = commitStatusesApi;
53189
+ this.contextService = contextService;
53190
+ }
53191
+ async execute(options, context) {
53192
+ const repoContext = await this.contextService.requireRepoContext({
53193
+ ...context.globalOptions,
53194
+ ...options
53195
+ });
53196
+ const prId = Number.parseInt(options.id, 10);
53197
+ const response = await this.commitStatusesApi.repositoriesWorkspaceRepoSlugPullrequestsPullRequestIdStatusesGet({
53198
+ workspace: repoContext.workspace,
53199
+ repoSlug: repoContext.repoSlug,
53200
+ pullRequestId: prId
53201
+ });
53202
+ const data = response.data;
53203
+ const statuses = data?.values ? Array.from(data.values) : [];
53204
+ const summary = this.getSummary(statuses);
53205
+ const useJson = options.json || context.globalOptions.json;
53206
+ if (useJson) {
53207
+ this.output.json({
53208
+ pullRequestId: prId,
52776
53209
  workspace: repoContext.workspace,
52777
53210
  repoSlug: repoContext.repoSlug,
52778
- pullRequestId: prId
53211
+ summary,
53212
+ statuses: statuses.map((status) => this.formatStatusForJson(status))
52779
53213
  });
52780
- const pr = response.data;
52781
- const reviewers = pr.reviewers ?? [];
52782
- if (context.globalOptions.json) {
52783
- this.output.json(reviewers);
52784
- } else if (reviewers.length === 0) {
52785
- this.output.info("No reviewers assigned to this pull request");
52786
- } else {
52787
- this.output.table(["Display Name", "Account ID"], reviewers.map((r) => [r.display_name ?? "Unknown", r.account_id ?? ""]));
53214
+ return;
53215
+ }
53216
+ if (statuses.length === 0) {
53217
+ this.output.info("No CI/CD checks found for this pull request");
53218
+ return;
53219
+ }
53220
+ this.renderHeader(prId, statuses.length);
53221
+ this.renderStatuses(statuses, summary);
53222
+ }
53223
+ formatStatusForJson(status) {
53224
+ return {
53225
+ key: status.key,
53226
+ name: status.name,
53227
+ state: status.state,
53228
+ description: status.description,
53229
+ url: status.url,
53230
+ refname: status.refname,
53231
+ createdOn: status.created_on,
53232
+ updatedOn: status.updated_on,
53233
+ uuid: status.uuid
53234
+ };
53235
+ }
53236
+ renderHeader(prId, count) {
53237
+ this.output.text("");
53238
+ const title = this.output.bold("Pull Request #" + prId);
53239
+ this.output.text(`${title} - ${count} check${count === 1 ? "" : "s"}`);
53240
+ this.output.text(this.output.gray("-".repeat(60)));
53241
+ }
53242
+ renderStatuses(statuses, summary) {
53243
+ const rows = statuses.map((status) => {
53244
+ const stateIcon = this.getStateIcon(status.state);
53245
+ const stateLabel = this.getStateLabel(status.state);
53246
+ const name = status.name ?? status.key ?? "Unknown";
53247
+ const description = status.description ?? "-";
53248
+ return [
53249
+ `${stateIcon} ${stateLabel}`,
53250
+ this.output.bold(name),
53251
+ this.truncate(description, 40),
53252
+ status.updated_on ? this.output.formatDate(status.updated_on) : "-"
53253
+ ];
53254
+ });
53255
+ this.output.table(["STATUS", "NAME", "DESCRIPTION", "UPDATED"], rows);
53256
+ this.output.text("");
53257
+ this.output.text(`${this.output.green("OK")} ${summary.successful} successful, ${this.output.red("FAIL")} ${summary.failed} failed, ${this.output.yellow("RUN")} ${summary.pending} pending`);
53258
+ this.output.text("");
53259
+ }
53260
+ getStateIcon(state) {
53261
+ switch (state?.toUpperCase()) {
53262
+ case "SUCCESSFUL":
53263
+ return this.output.green("OK");
53264
+ case "FAILED":
53265
+ return this.output.red("FAIL");
53266
+ case "INPROGRESS":
53267
+ return this.output.yellow("RUN");
53268
+ case "STOPPED":
53269
+ return this.output.gray("STOP");
53270
+ default:
53271
+ return this.output.gray("?");
53272
+ }
53273
+ }
53274
+ getStateLabel(state) {
53275
+ switch (state?.toUpperCase()) {
53276
+ case "SUCCESSFUL":
53277
+ return "passed";
53278
+ case "FAILED":
53279
+ return "failed";
53280
+ case "INPROGRESS":
53281
+ return "running";
53282
+ case "STOPPED":
53283
+ return "stopped";
53284
+ default:
53285
+ return state?.toLowerCase() ?? "unknown";
53286
+ }
53287
+ }
53288
+ getSummary(statuses) {
53289
+ return statuses.reduce((acc, status) => {
53290
+ const state = status.state?.toUpperCase();
53291
+ if (state === "SUCCESSFUL") {
53292
+ acc.successful++;
53293
+ } else if (state === "FAILED") {
53294
+ acc.failed++;
53295
+ } else if (state === "INPROGRESS") {
53296
+ acc.pending++;
52788
53297
  }
52789
- } catch (error) {
52790
- this.handleError(error, context);
52791
- throw error;
53298
+ return acc;
53299
+ }, { successful: 0, failed: 0, pending: 0 });
53300
+ }
53301
+ truncate(text, maxLength) {
53302
+ if (text.length <= maxLength) {
53303
+ return text;
52792
53304
  }
53305
+ return text.substring(0, maxLength - 3) + "...";
52793
53306
  }
52794
53307
  }
52795
53308
 
52796
53309
  // src/types/config.ts
52797
- var SETTABLE_CONFIG_KEYS = ["defaultWorkspace", "skipVersionCheck", "versionCheckInterval"];
52798
- var READABLE_CONFIG_KEYS = ["username", "defaultWorkspace", "skipVersionCheck", "versionCheckInterval"];
53310
+ var SETTABLE_CONFIG_KEYS = [
53311
+ "defaultWorkspace",
53312
+ "skipVersionCheck",
53313
+ "versionCheckInterval"
53314
+ ];
53315
+ var READABLE_CONFIG_KEYS = [
53316
+ "username",
53317
+ "defaultWorkspace",
53318
+ "skipVersionCheck",
53319
+ "versionCheckInterval"
53320
+ ];
52799
53321
  function isSettableConfigKey(key) {
52800
53322
  return SETTABLE_CONFIG_KEYS.includes(key);
52801
53323
  }
@@ -52813,19 +53335,22 @@ class GetConfigCommand extends BaseCommand {
52813
53335
  super(output);
52814
53336
  this.configService = configService;
52815
53337
  }
52816
- async execute(options, _context) {
53338
+ async execute(options, context) {
52817
53339
  const { key } = options;
52818
53340
  if (GetConfigCommand.HIDDEN_KEYS.includes(key)) {
52819
- const error = new Error(`Cannot display '${key}' - use 'bb auth token' to get authentication credentials`);
52820
- this.output.error(error.message);
52821
- throw error;
53341
+ throw new Error(`Cannot display '${key}' - use 'bb auth token' to get authentication credentials`);
52822
53342
  }
52823
53343
  if (!isReadableConfigKey(key)) {
52824
- const error = new Error(`Unknown config key '${key}'. Valid keys: username, defaultWorkspace`);
52825
- this.output.error(error.message);
52826
- throw error;
53344
+ throw new Error(`Unknown config key '${key}'. Valid keys: username, defaultWorkspace`);
52827
53345
  }
52828
53346
  const value = await this.configService.getValue(key);
53347
+ if (context.globalOptions.json) {
53348
+ this.output.json({
53349
+ key,
53350
+ value: value ?? null
53351
+ });
53352
+ return;
53353
+ }
52829
53354
  this.output.text(String(value || ""));
52830
53355
  }
52831
53356
  }
@@ -52840,19 +53365,23 @@ class SetConfigCommand extends BaseCommand {
52840
53365
  super(output);
52841
53366
  this.configService = configService;
52842
53367
  }
52843
- async execute(options, _context) {
53368
+ async execute(options, context) {
52844
53369
  const { key, value } = options;
52845
53370
  if (SetConfigCommand.PROTECTED_KEYS.includes(key)) {
52846
- const error = new Error(`Cannot set '${key}' directly. Use 'bb auth login' to configure authentication.`);
52847
- this.output.error(error.message);
52848
- throw error;
53371
+ throw new Error(`Cannot set '${key}' directly. Use 'bb auth login' to configure authentication.`);
52849
53372
  }
52850
53373
  if (!isSettableConfigKey(key)) {
52851
- const error = new Error(`Unknown config key '${key}'. Valid keys: defaultWorkspace`);
52852
- this.output.error(error.message);
52853
- throw error;
53374
+ throw new Error(`Unknown config key '${key}'. Valid keys: defaultWorkspace`);
52854
53375
  }
52855
53376
  await this.configService.setValue(key, value);
53377
+ if (context.globalOptions.json) {
53378
+ this.output.json({
53379
+ success: true,
53380
+ key,
53381
+ value
53382
+ });
53383
+ return;
53384
+ }
52856
53385
  this.output.success(`Set ${key} = ${value}`);
52857
53386
  }
52858
53387
  }
@@ -52866,14 +53395,21 @@ class ListConfigCommand extends BaseCommand {
52866
53395
  super(output);
52867
53396
  this.configService = configService;
52868
53397
  }
52869
- async execute(_options, _context) {
53398
+ async execute(_options, context) {
52870
53399
  const config = await this.configService.getConfig();
52871
53400
  const displayConfig = {
52872
53401
  username: config.username || "",
52873
53402
  defaultWorkspace: config.defaultWorkspace || "",
52874
53403
  apiToken: config.apiToken ? "********" : ""
52875
53404
  };
52876
- this.output.text(source_default.dim(`Config file: ${this.configService.getConfigPath()}`));
53405
+ if (context.globalOptions.json) {
53406
+ this.output.json({
53407
+ configPath: this.configService.getConfigPath(),
53408
+ config: Object.fromEntries(Object.entries(displayConfig).filter(([, value]) => value !== ""))
53409
+ });
53410
+ return;
53411
+ }
53412
+ this.output.text(this.output.dim(`Config file: ${this.configService.getConfigPath()}`));
52877
53413
  this.output.text("");
52878
53414
  const rows = Object.entries(displayConfig).filter(([, value]) => value !== "").map(([key, value]) => [key, value]);
52879
53415
  if (rows.length === 0) {
@@ -52893,17 +53429,26 @@ class InstallCompletionCommand extends BaseCommand {
52893
53429
  constructor(output) {
52894
53430
  super(output);
52895
53431
  }
52896
- async execute(_options, _context) {
53432
+ async execute(_options, context) {
52897
53433
  try {
52898
53434
  await import_tabtab.default.install({
52899
53435
  name: "bb",
52900
53436
  completer: "bb"
52901
53437
  });
53438
+ if (context.globalOptions.json) {
53439
+ this.output.json({
53440
+ success: true,
53441
+ shellCompletion: {
53442
+ command: "bb",
53443
+ installed: true
53444
+ }
53445
+ });
53446
+ return;
53447
+ }
52902
53448
  this.output.success("Shell completions installed successfully!");
52903
53449
  this.output.text("Restart your shell or source your profile to enable completions.");
52904
53450
  } catch (error) {
52905
- this.output.error(`Failed to install completions: ${error}`);
52906
- throw error;
53451
+ throw new Error(`Failed to install completions: ${error}`);
52907
53452
  }
52908
53453
  }
52909
53454
  }
@@ -52917,15 +53462,24 @@ class UninstallCompletionCommand extends BaseCommand {
52917
53462
  constructor(output) {
52918
53463
  super(output);
52919
53464
  }
52920
- async execute(_options, _context) {
53465
+ async execute(_options, context) {
52921
53466
  try {
52922
53467
  await import_tabtab2.default.uninstall({
52923
53468
  name: "bb"
52924
53469
  });
53470
+ if (context.globalOptions.json) {
53471
+ this.output.json({
53472
+ success: true,
53473
+ shellCompletion: {
53474
+ command: "bb",
53475
+ installed: false
53476
+ }
53477
+ });
53478
+ return;
53479
+ }
52925
53480
  this.output.success("Shell completions uninstalled successfully!");
52926
53481
  } catch (error) {
52927
- this.output.error(`Failed to uninstall completions: ${error}`);
52928
- throw error;
53482
+ throw new Error(`Failed to uninstall completions: ${error}`);
52929
53483
  }
52930
53484
  }
52931
53485
  }
@@ -52933,11 +53487,11 @@ class UninstallCompletionCommand extends BaseCommand {
52933
53487
  // src/bootstrap.ts
52934
53488
  var require2 = createRequire(import.meta.url);
52935
53489
  var pkg = require2("../package.json");
52936
- function bootstrap() {
53490
+ function bootstrap(options = {}) {
52937
53491
  const container = Container.getInstance();
52938
53492
  container.register(ServiceTokens.ConfigService, () => new ConfigService);
52939
53493
  container.register(ServiceTokens.GitService, () => new GitService);
52940
- container.register(ServiceTokens.OutputService, () => new OutputService);
53494
+ container.register(ServiceTokens.OutputService, () => new OutputService({ noColor: options.noColor }));
52941
53495
  container.register(ServiceTokens.PullrequestsApi, () => {
52942
53496
  const configService = container.resolve(ServiceTokens.ConfigService);
52943
53497
  const axiosInstance = createApiClient(configService);
@@ -52953,6 +53507,11 @@ function bootstrap() {
52953
53507
  const axiosInstance = createApiClient(configService);
52954
53508
  return new UsersApi(undefined, undefined, axiosInstance);
52955
53509
  });
53510
+ container.register(ServiceTokens.CommitStatusesApi, () => {
53511
+ const configService = container.resolve(ServiceTokens.ConfigService);
53512
+ const axiosInstance = createApiClient(configService);
53513
+ return new CommitStatusesApi(undefined, undefined, axiosInstance);
53514
+ });
52956
53515
  container.register(ServiceTokens.ContextService, () => {
52957
53516
  const gitService = container.resolve(ServiceTokens.GitService);
52958
53517
  const configService = container.resolve(ServiceTokens.ConfigService);
@@ -53124,6 +53683,12 @@ function bootstrap() {
53124
53683
  const output = container.resolve(ServiceTokens.OutputService);
53125
53684
  return new ListReviewersPRCommand(pullrequestsApi, contextService, output);
53126
53685
  });
53686
+ container.register(ServiceTokens.ChecksPRCommand, () => {
53687
+ const commitStatusesApi = container.resolve(ServiceTokens.CommitStatusesApi);
53688
+ const contextService = container.resolve(ServiceTokens.ContextService);
53689
+ const output = container.resolve(ServiceTokens.OutputService);
53690
+ return new ChecksPRCommand(commitStatusesApi, contextService, output);
53691
+ });
53127
53692
  container.register(ServiceTokens.GetConfigCommand, () => {
53128
53693
  const configService = container.resolve(ServiceTokens.ConfigService);
53129
53694
  const output = container.resolve(ServiceTokens.OutputService);
@@ -53170,6 +53735,7 @@ if (process.argv.includes("--get-yargs-completions") || process.env.COMP_LINE) {
53170
53735
  "--help",
53171
53736
  "--version",
53172
53737
  "--json",
53738
+ "--no-color",
53173
53739
  "--workspace",
53174
53740
  "--repo"
53175
53741
  ];
@@ -53178,7 +53744,7 @@ if (process.argv.includes("--get-yargs-completions") || process.env.COMP_LINE) {
53178
53744
  } else if (env2.prev === "repo") {
53179
53745
  completions.push("clone", "create", "list", "view", "delete");
53180
53746
  } else if (env2.prev === "pr") {
53181
- completions.push("create", "list", "view", "activity", "edit", "merge", "approve", "decline", "ready", "checkout", "diff", "comments", "reviewers");
53747
+ completions.push("create", "list", "view", "activity", "checks", "edit", "merge", "approve", "decline", "ready", "checkout", "diff", "comments", "reviewers");
53182
53748
  } else if (env2.prev === "reviewers") {
53183
53749
  completions.push("list", "add", "remove");
53184
53750
  } else if (env2.prev === "config") {
@@ -53190,17 +53756,44 @@ if (process.argv.includes("--get-yargs-completions") || process.env.COMP_LINE) {
53190
53756
  process.exit(0);
53191
53757
  }
53192
53758
  }
53193
- var container = bootstrap();
53759
+ function resolveNoColorSetting(argv, env2) {
53760
+ const hasColorArg = argv.includes("--color");
53761
+ const hasNoColorArg = argv.includes("--no-color");
53762
+ const hasForceColorEnv = env2.FORCE_COLOR !== undefined && env2.FORCE_COLOR !== "0";
53763
+ const hasNoColorEnv = env2.NO_COLOR !== undefined;
53764
+ if (hasColorArg) {
53765
+ return false;
53766
+ }
53767
+ if (hasForceColorEnv) {
53768
+ return false;
53769
+ }
53770
+ if (hasNoColorArg) {
53771
+ return true;
53772
+ }
53773
+ return hasNoColorEnv;
53774
+ }
53775
+ var noColor = resolveNoColorSetting(process.argv, process.env);
53776
+ var container = bootstrap({ noColor });
53194
53777
  function createContext(program2) {
53195
53778
  const opts = program2.opts();
53196
53779
  return {
53197
53780
  globalOptions: {
53198
53781
  json: opts.json,
53782
+ noColor: opts.color === false,
53199
53783
  workspace: opts.workspace,
53200
53784
  repo: opts.repo
53201
53785
  }
53202
53786
  };
53203
53787
  }
53788
+ async function runCommand(token, options, program2, context) {
53789
+ const cmd = container.resolve(token);
53790
+ const resolvedContext = context ?? createContext(program2);
53791
+ try {
53792
+ return await cmd.run(options, resolvedContext);
53793
+ } catch {
53794
+ return;
53795
+ }
53796
+ }
53204
53797
  function withGlobalOptions(options, context) {
53205
53798
  return {
53206
53799
  ...options,
@@ -53209,312 +53802,156 @@ function withGlobalOptions(options, context) {
53209
53802
  };
53210
53803
  }
53211
53804
  var cli = new Command;
53212
- cli.name("bb").description("A command-line interface for Bitbucket Cloud").version(pkg2.version).option("--json", "Output as JSON").option("-w, --workspace <workspace>", "Specify workspace").option("-r, --repo <repo>", "Specify repository").action(async () => {
53805
+ cli.name("bb").description("A command-line interface for Bitbucket Cloud").version(pkg2.version).option("--json", "Output as JSON").option("--no-color", "Disable color output").option("-w, --workspace <workspace>", "Specify workspace").option("-r, --repo <repo>", "Specify repository").action(async () => {
53213
53806
  cli.outputHelp();
53214
53807
  const versionService = container.resolve(ServiceTokens.VersionService);
53215
53808
  const output = container.resolve(ServiceTokens.OutputService);
53216
53809
  try {
53217
53810
  const result = await versionService.checkForUpdate();
53218
53811
  if (result?.updateAvailable) {
53219
- console.log("");
53220
- console.log("\u2500".repeat(50));
53221
- console.log(`\u26A0 A new version is available: ${result.latestVersion} (you have ${result.currentVersion})`);
53222
- console.log(` Run '${versionService.getInstallCommand()}' to update`);
53223
- console.log(` Or disable with 'bb config set skipVersionCheck true'`);
53224
- console.log("\u2500".repeat(50));
53812
+ output.text("");
53813
+ output.text("\u2500".repeat(50));
53814
+ output.text(`\u26A0 A new version is available: ${result.latestVersion} (you have ${result.currentVersion})`);
53815
+ output.text(` Run '${versionService.getInstallCommand()}' to update`);
53816
+ output.text(` Or disable with 'bb config set skipVersionCheck true'`);
53817
+ output.text("\u2500".repeat(50));
53225
53818
  }
53226
53819
  } catch {}
53227
53820
  });
53228
53821
  var authCmd = new Command("auth").description("Authenticate with Bitbucket");
53229
53822
  authCmd.command("login").description("Authenticate with Bitbucket using an API token").option("-u, --username <username>", "Bitbucket username").option("-p, --password <password>", "Bitbucket API token").action(async (options) => {
53230
- try {
53231
- const cmd = container.resolve(ServiceTokens.LoginCommand);
53232
- await cmd.execute(options, createContext(cli));
53233
- } catch {
53234
- process.exit(1);
53235
- }
53823
+ await runCommand(ServiceTokens.LoginCommand, options, cli);
53236
53824
  });
53237
53825
  authCmd.command("logout").description("Log out of Bitbucket").action(async () => {
53238
- try {
53239
- const cmd = container.resolve(ServiceTokens.LogoutCommand);
53240
- await cmd.execute(undefined, createContext(cli));
53241
- } catch {
53242
- process.exit(1);
53243
- }
53826
+ await runCommand(ServiceTokens.LogoutCommand, undefined, cli);
53244
53827
  });
53245
53828
  authCmd.command("status").description("Show authentication status").action(async () => {
53246
- try {
53247
- const cmd = container.resolve(ServiceTokens.StatusCommand);
53248
- await cmd.execute(undefined, createContext(cli));
53249
- } catch {
53250
- process.exit(1);
53251
- }
53829
+ await runCommand(ServiceTokens.StatusCommand, undefined, cli);
53252
53830
  });
53253
53831
  authCmd.command("token").description("Print the current access token").action(async () => {
53254
- try {
53255
- const cmd = container.resolve(ServiceTokens.TokenCommand);
53256
- await cmd.execute(undefined, createContext(cli));
53257
- } catch {
53258
- process.exit(1);
53259
- }
53832
+ await runCommand(ServiceTokens.TokenCommand, undefined, cli);
53260
53833
  });
53261
53834
  cli.addCommand(authCmd);
53262
53835
  var repoCmd = new Command("repo").description("Manage repositories");
53263
53836
  repoCmd.command("clone <repository>").description("Clone a Bitbucket repository").option("-d, --directory <dir>", "Directory to clone into").action(async (repository, options) => {
53264
- try {
53265
- const cmd = container.resolve(ServiceTokens.CloneCommand);
53266
- await cmd.execute({ repository, ...options }, createContext(cli));
53267
- } catch {
53268
- process.exit(1);
53269
- }
53837
+ await runCommand(ServiceTokens.CloneCommand, { repository, ...options }, cli);
53270
53838
  });
53271
53839
  repoCmd.command("create <name>").description("Create a new repository").option("-d, --description <description>", "Repository description").option("--private", "Create a private repository (default)").option("--public", "Create a public repository").option("-p, --project <project>", "Project key").action(async (name, options) => {
53272
- try {
53273
- const cmd = container.resolve(ServiceTokens.CreateRepoCommand);
53274
- const context = createContext(cli);
53275
- await cmd.execute(withGlobalOptions({ name, ...options }, context), context);
53276
- } catch {
53277
- process.exit(1);
53278
- }
53840
+ const context = createContext(cli);
53841
+ await runCommand(ServiceTokens.CreateRepoCommand, withGlobalOptions({ name, ...options }, context), cli, context);
53279
53842
  });
53280
53843
  repoCmd.command("list").description("List repositories").option("--limit <number>", "Maximum number of repositories to list", "25").action(async (options) => {
53281
- try {
53282
- const cmd = container.resolve(ServiceTokens.ListReposCommand);
53283
- const context = createContext(cli);
53284
- await cmd.execute(withGlobalOptions(options, context), context);
53285
- } catch {
53286
- process.exit(1);
53287
- }
53844
+ const context = createContext(cli);
53845
+ await runCommand(ServiceTokens.ListReposCommand, withGlobalOptions(options, context), cli, context);
53288
53846
  });
53289
53847
  repoCmd.command("view [repository]").description("View repository details").action(async (repository, options) => {
53290
- try {
53291
- const cmd = container.resolve(ServiceTokens.ViewRepoCommand);
53292
- const context = createContext(cli);
53293
- await cmd.execute(withGlobalOptions({ repository, ...options }, context), context);
53294
- } catch {
53295
- process.exit(1);
53296
- }
53848
+ const context = createContext(cli);
53849
+ await runCommand(ServiceTokens.ViewRepoCommand, withGlobalOptions({ repository, ...options }, context), cli, context);
53297
53850
  });
53298
53851
  repoCmd.command("delete <repository>").description("Delete a repository").option("-y, --yes", "Skip confirmation prompt").action(async (repository, options) => {
53299
- try {
53300
- const cmd = container.resolve(ServiceTokens.DeleteRepoCommand);
53301
- const context = createContext(cli);
53302
- await cmd.execute(withGlobalOptions({ repository, ...options }, context), context);
53303
- } catch {
53304
- process.exit(1);
53305
- }
53852
+ const context = createContext(cli);
53853
+ await runCommand(ServiceTokens.DeleteRepoCommand, withGlobalOptions({ repository, ...options }, context), cli, context);
53306
53854
  });
53307
53855
  cli.addCommand(repoCmd);
53308
53856
  var prCmd = new Command("pr").description("Manage pull requests");
53309
53857
  prCmd.command("create").description("Create a pull request").option("-t, --title <title>", "Pull request title").option("-b, --body <body>", "Pull request description").option("-s, --source <branch>", "Source branch (default: current branch)").option("-d, --destination <branch>", "Destination branch (default: main)").option("--close-source-branch", "Close source branch after merge").option("--draft", "Create the pull request as draft").action(async (options) => {
53310
- try {
53311
- const cmd = container.resolve(ServiceTokens.CreatePRCommand);
53312
- const context = createContext(cli);
53313
- await cmd.execute(withGlobalOptions(options, context), context);
53314
- } catch {
53315
- process.exit(1);
53316
- }
53858
+ const context = createContext(cli);
53859
+ await runCommand(ServiceTokens.CreatePRCommand, withGlobalOptions(options, context), cli, context);
53317
53860
  });
53318
53861
  prCmd.command("list").description("List pull requests").option("-s, --state <state>", "Filter by state (OPEN, MERGED, DECLINED, SUPERSEDED)", "OPEN").option("--limit <number>", "Maximum number of PRs to list", "25").action(async (options) => {
53319
- try {
53320
- const cmd = container.resolve(ServiceTokens.ListPRsCommand);
53321
- const context = createContext(cli);
53322
- await cmd.execute(withGlobalOptions(options, context), context);
53323
- } catch {
53324
- process.exit(1);
53325
- }
53862
+ const context = createContext(cli);
53863
+ await runCommand(ServiceTokens.ListPRsCommand, withGlobalOptions(options, context), cli, context);
53326
53864
  });
53327
53865
  prCmd.command("view <id>").description("View pull request details").action(async (id, options) => {
53328
- try {
53329
- const cmd = container.resolve(ServiceTokens.ViewPRCommand);
53330
- const context = createContext(cli);
53331
- await cmd.execute(withGlobalOptions({ id, ...options }, context), context);
53332
- } catch {
53333
- process.exit(1);
53334
- }
53866
+ const context = createContext(cli);
53867
+ await runCommand(ServiceTokens.ViewPRCommand, withGlobalOptions({ id, ...options }, context), cli, context);
53335
53868
  });
53336
53869
  prCmd.command("activity <id>").description("Show pull request activity log").option("--limit <number>", "Maximum number of activity entries", "25").option("--type <types>", "Filter activity by type (comma-separated)").action(async (id, options) => {
53337
- try {
53338
- const cmd = container.resolve(ServiceTokens.ActivityPRCommand);
53339
- const context = createContext(cli);
53340
- await cmd.execute(withGlobalOptions({ id, ...options }, context), context);
53341
- } catch {
53342
- process.exit(1);
53343
- }
53870
+ const context = createContext(cli);
53871
+ await runCommand(ServiceTokens.ActivityPRCommand, withGlobalOptions({ id, ...options }, context), cli, context);
53872
+ });
53873
+ prCmd.command("checks <id>").description("Show CI/CD checks and build status for a pull request").option("--json", "Output as JSON").action(async (id, options) => {
53874
+ const context = createContext(cli);
53875
+ await runCommand(ServiceTokens.ChecksPRCommand, withGlobalOptions({ id, ...options }, context), cli, context);
53344
53876
  });
53345
53877
  prCmd.command("edit [id]").description("Edit a pull request").option("-t, --title <title>", "New pull request title").option("-b, --body <body>", "New pull request description").option("-F, --body-file <file>", "Read description from file").action(async (id, options) => {
53346
- try {
53347
- const cmd = container.resolve(ServiceTokens.EditPRCommand);
53348
- const context = createContext(cli);
53349
- await cmd.execute(withGlobalOptions({ id, ...options }, context), context);
53350
- } catch {
53351
- process.exit(1);
53352
- }
53878
+ const context = createContext(cli);
53879
+ await runCommand(ServiceTokens.EditPRCommand, withGlobalOptions({ id, ...options }, context), cli, context);
53353
53880
  });
53354
53881
  prCmd.command("merge <id>").description("Merge a pull request").option("-m, --message <message>", "Merge commit message").option("--close-source-branch", "Delete the source branch after merging").option("--strategy <strategy>", "Merge strategy (merge_commit, squash, fast_forward)").action(async (id, options) => {
53355
- try {
53356
- const cmd = container.resolve(ServiceTokens.MergePRCommand);
53357
- const context = createContext(cli);
53358
- await cmd.execute(withGlobalOptions({ id, ...options }, context), context);
53359
- } catch {
53360
- process.exit(1);
53361
- }
53882
+ const context = createContext(cli);
53883
+ await runCommand(ServiceTokens.MergePRCommand, withGlobalOptions({ id, ...options }, context), cli, context);
53362
53884
  });
53363
53885
  prCmd.command("approve <id>").description("Approve a pull request").action(async (id, options) => {
53364
- try {
53365
- const cmd = container.resolve(ServiceTokens.ApprovePRCommand);
53366
- const context = createContext(cli);
53367
- await cmd.execute(withGlobalOptions({ id, ...options }, context), context);
53368
- } catch {
53369
- process.exit(1);
53370
- }
53886
+ const context = createContext(cli);
53887
+ await runCommand(ServiceTokens.ApprovePRCommand, withGlobalOptions({ id, ...options }, context), cli, context);
53371
53888
  });
53372
53889
  prCmd.command("decline <id>").description("Decline a pull request").action(async (id, options) => {
53373
- try {
53374
- const cmd = container.resolve(ServiceTokens.DeclinePRCommand);
53375
- const context = createContext(cli);
53376
- await cmd.execute(withGlobalOptions({ id, ...options }, context), context);
53377
- } catch {
53378
- process.exit(1);
53379
- }
53890
+ const context = createContext(cli);
53891
+ await runCommand(ServiceTokens.DeclinePRCommand, withGlobalOptions({ id, ...options }, context), cli, context);
53380
53892
  });
53381
53893
  prCmd.command("ready <id>").description("Mark a draft pull request as ready for review").action(async (id, options) => {
53382
- try {
53383
- const cmd = container.resolve(ServiceTokens.ReadyPRCommand);
53384
- const context = createContext(cli);
53385
- await cmd.execute(withGlobalOptions({ id, ...options }, context), context);
53386
- } catch {
53387
- process.exit(1);
53388
- }
53894
+ const context = createContext(cli);
53895
+ await runCommand(ServiceTokens.ReadyPRCommand, withGlobalOptions({ id, ...options }, context), cli, context);
53389
53896
  });
53390
53897
  prCmd.command("checkout <id>").description("Checkout a pull request locally").action(async (id, options) => {
53391
- try {
53392
- const cmd = container.resolve(ServiceTokens.CheckoutPRCommand);
53393
- const context = createContext(cli);
53394
- await cmd.execute(withGlobalOptions({ id, ...options }, context), context);
53395
- } catch {
53396
- process.exit(1);
53397
- }
53898
+ const context = createContext(cli);
53899
+ await runCommand(ServiceTokens.CheckoutPRCommand, withGlobalOptions({ id, ...options }, context), cli, context);
53398
53900
  });
53399
53901
  prCmd.command("diff [id]").description("View pull request diff").option("--color <when>", "Colorize output (auto, always, never)", "auto").option("--name-only", "Show only names of changed files").option("--stat", "Show diffstat").option("-w, --web", "Open diff in web browser").action(async (id, options) => {
53400
- try {
53401
- const cmd = container.resolve(ServiceTokens.DiffPRCommand);
53402
- const context = createContext(cli);
53403
- await cmd.execute(withGlobalOptions({ id, ...options }, context), context);
53404
- } catch {
53405
- process.exit(1);
53406
- }
53902
+ const context = createContext(cli);
53903
+ await runCommand(ServiceTokens.DiffPRCommand, withGlobalOptions({ id, ...options }, context), cli, context);
53407
53904
  });
53408
53905
  var prCommentsCmd = new Command("comments").description("Manage pull request comments");
53409
53906
  prCommentsCmd.command("list <id>").description("List comments on a pull request").option("--limit <number>", "Maximum number of comments (default: 25)").option("--no-truncate", "Show full comment content without truncation").action(async (id, options) => {
53410
- try {
53411
- const cmd = container.resolve(ServiceTokens.ListCommentsPRCommand);
53412
- const context = createContext(cli);
53413
- await cmd.execute(withGlobalOptions({ id, ...options }, context), context);
53414
- } catch {
53415
- process.exit(1);
53416
- }
53907
+ const context = createContext(cli);
53908
+ await runCommand(ServiceTokens.ListCommentsPRCommand, withGlobalOptions({ id, ...options }, context), cli, context);
53417
53909
  });
53418
53910
  prCommentsCmd.command("add <id> <message>").description("Add a comment to a pull request").action(async (id, message, options) => {
53419
- try {
53420
- const cmd = container.resolve(ServiceTokens.CommentPRCommand);
53421
- const context = createContext(cli);
53422
- await cmd.execute(withGlobalOptions({ id, message }, context), context);
53423
- } catch {
53424
- process.exit(1);
53425
- }
53911
+ const context = createContext(cli);
53912
+ await runCommand(ServiceTokens.CommentPRCommand, withGlobalOptions({ id, message }, context), cli, context);
53426
53913
  });
53427
53914
  prCommentsCmd.command("edit <pr-id> <comment-id> <message>").description("Edit a comment on a pull request").action(async (prId, commentId, message, options) => {
53428
- try {
53429
- const cmd = container.resolve(ServiceTokens.EditCommentPRCommand);
53430
- const context = createContext(cli);
53431
- await cmd.execute(withGlobalOptions({ prId, commentId, message }, context), context);
53432
- } catch {
53433
- process.exit(1);
53434
- }
53915
+ const context = createContext(cli);
53916
+ await runCommand(ServiceTokens.EditCommentPRCommand, withGlobalOptions({ prId, commentId, message }, context), cli, context);
53435
53917
  });
53436
53918
  prCommentsCmd.command("delete <pr-id> <comment-id>").description("Delete a comment on a pull request").action(async (prId, commentId, options) => {
53437
- try {
53438
- const cmd = container.resolve(ServiceTokens.DeleteCommentPRCommand);
53439
- const context = createContext(cli);
53440
- await cmd.execute(withGlobalOptions({ prId, commentId }, context), context);
53441
- } catch {
53442
- process.exit(1);
53443
- }
53919
+ const context = createContext(cli);
53920
+ await runCommand(ServiceTokens.DeleteCommentPRCommand, withGlobalOptions({ prId, commentId }, context), cli, context);
53444
53921
  });
53445
53922
  var prReviewersCmd = new Command("reviewers").description("Manage pull request reviewers");
53446
53923
  prReviewersCmd.command("list <id>").description("List reviewers on a pull request").action(async (id, options) => {
53447
- try {
53448
- const cmd = container.resolve(ServiceTokens.ListReviewersPRCommand);
53449
- const context = createContext(cli);
53450
- await cmd.execute(withGlobalOptions({ id, ...options }, context), context);
53451
- } catch {
53452
- process.exit(1);
53453
- }
53924
+ const context = createContext(cli);
53925
+ await runCommand(ServiceTokens.ListReviewersPRCommand, withGlobalOptions({ id, ...options }, context), cli, context);
53454
53926
  });
53455
53927
  prReviewersCmd.command("add <id> <username>").description("Add a reviewer to a pull request").action(async (id, username, options) => {
53456
- try {
53457
- const cmd = container.resolve(ServiceTokens.AddReviewerPRCommand);
53458
- const context = createContext(cli);
53459
- await cmd.execute(withGlobalOptions({ id, username, ...options }, context), context);
53460
- } catch {
53461
- process.exit(1);
53462
- }
53928
+ const context = createContext(cli);
53929
+ await runCommand(ServiceTokens.AddReviewerPRCommand, withGlobalOptions({ id, username, ...options }, context), cli, context);
53463
53930
  });
53464
53931
  prReviewersCmd.command("remove <id> <username>").description("Remove a reviewer from a pull request").action(async (id, username, options) => {
53465
- try {
53466
- const cmd = container.resolve(ServiceTokens.RemoveReviewerPRCommand);
53467
- const context = createContext(cli);
53468
- await cmd.execute(withGlobalOptions({ id, username, ...options }, context), context);
53469
- } catch {
53470
- process.exit(1);
53471
- }
53932
+ const context = createContext(cli);
53933
+ await runCommand(ServiceTokens.RemoveReviewerPRCommand, withGlobalOptions({ id, username, ...options }, context), cli, context);
53472
53934
  });
53473
53935
  cli.addCommand(prCmd);
53474
53936
  prCmd.addCommand(prCommentsCmd);
53475
53937
  prCmd.addCommand(prReviewersCmd);
53476
53938
  var configCmd = new Command("config").description("Manage configuration");
53477
53939
  configCmd.command("get <key>").description("Get a configuration value").action(async (key) => {
53478
- try {
53479
- const cmd = container.resolve(ServiceTokens.GetConfigCommand);
53480
- await cmd.execute({ key }, createContext(cli));
53481
- } catch {
53482
- process.exit(1);
53483
- }
53940
+ await runCommand(ServiceTokens.GetConfigCommand, { key }, cli);
53484
53941
  });
53485
53942
  configCmd.command("set <key> <value>").description("Set a configuration value").action(async (key, value) => {
53486
- try {
53487
- const cmd = container.resolve(ServiceTokens.SetConfigCommand);
53488
- await cmd.execute({ key, value }, createContext(cli));
53489
- } catch {
53490
- process.exit(1);
53491
- }
53943
+ await runCommand(ServiceTokens.SetConfigCommand, { key, value }, cli);
53492
53944
  });
53493
53945
  configCmd.command("list").description("List all configuration values").action(async () => {
53494
- try {
53495
- const cmd = container.resolve(ServiceTokens.ListConfigCommand);
53496
- await cmd.execute(undefined, createContext(cli));
53497
- } catch {
53498
- process.exit(1);
53499
- }
53946
+ await runCommand(ServiceTokens.ListConfigCommand, undefined, cli);
53500
53947
  });
53501
53948
  cli.addCommand(configCmd);
53502
53949
  var completionCmd = new Command("completion").description("Shell completion utilities");
53503
53950
  completionCmd.command("install").description("Install shell completions for bash, zsh, or fish").action(async () => {
53504
- try {
53505
- const cmd = container.resolve(ServiceTokens.InstallCompletionCommand);
53506
- await cmd.execute(undefined, createContext(cli));
53507
- } catch {
53508
- process.exit(1);
53509
- }
53951
+ await runCommand(ServiceTokens.InstallCompletionCommand, undefined, cli);
53510
53952
  });
53511
53953
  completionCmd.command("uninstall").description("Uninstall shell completions").action(async () => {
53512
- try {
53513
- const cmd = container.resolve(ServiceTokens.UninstallCompletionCommand);
53514
- await cmd.execute(undefined, createContext(cli));
53515
- } catch {
53516
- process.exit(1);
53517
- }
53954
+ await runCommand(ServiceTokens.UninstallCompletionCommand, undefined, cli);
53518
53955
  });
53519
53956
  cli.addCommand(completionCmd);
53520
53957