ya-git-jira 1.6.0 → 2.0.0

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 (86) hide show
  1. package/.opencode/skills/architecture/SKILL.md +45 -0
  2. package/.opencode/skills/code-style/SKILL.md +76 -0
  3. package/.opencode/skills/git-confluence/SKILL.md +82 -0
  4. package/.opencode/skills/git-jira/SKILL.md +63 -0
  5. package/.opencode/skills/git-lab/SKILL.md +102 -0
  6. package/AGENTS.md +50 -0
  7. package/README.md +106 -106
  8. package/bin/git-api.ts +70 -0
  9. package/bin/git-confluence-page-search.ts +58 -0
  10. package/bin/git-confluence-page-show.ts +61 -0
  11. package/bin/git-confluence-page-update.ts +77 -0
  12. package/bin/git-confluence-page.ts +28 -0
  13. package/bin/git-confluence-space-list.ts +34 -0
  14. package/bin/git-confluence-space.ts +24 -0
  15. package/bin/git-confluence-whoami.ts +33 -0
  16. package/bin/git-confluence.ts +27 -0
  17. package/bin/git-jira-start.ts +1 -1
  18. package/bin/git-jira-whoami.ts +32 -0
  19. package/bin/git-jira.ts +2 -0
  20. package/bin/git-lab-project-mr-list.ts +57 -0
  21. package/bin/git-lab-project-mr.ts +24 -0
  22. package/bin/git-lab-project-pipeline-jobs.ts +46 -0
  23. package/bin/git-lab-project-pipeline-latest.ts +47 -0
  24. package/bin/git-lab-project-pipeline-log.ts +49 -0
  25. package/bin/git-lab-project-pipeline.ts +6 -0
  26. package/bin/git-lab-project.ts +5 -1
  27. package/bin/gitj-install-skills.ts +126 -0
  28. package/bin/gitj.ts +12 -0
  29. package/dist/bin/git-api.js +2156 -0
  30. package/dist/bin/git-bump.js +132 -121
  31. package/dist/bin/git-confluence-page-search.js +2079 -0
  32. package/dist/bin/git-confluence-page-show.js +2082 -0
  33. package/dist/bin/git-confluence-page-update.js +2093 -0
  34. package/dist/bin/git-confluence-page.js +2186 -0
  35. package/dist/bin/git-confluence-space-list.js +2061 -0
  36. package/dist/bin/git-confluence-space.js +2073 -0
  37. package/dist/bin/git-confluence-whoami.js +2060 -0
  38. package/dist/bin/git-confluence.js +2251 -0
  39. package/dist/bin/git-jira-issue-list.js +136 -125
  40. package/dist/bin/git-jira-issue-show.js +136 -125
  41. package/dist/bin/git-jira-issue.js +140 -129
  42. package/dist/bin/git-jira-start.js +138 -127
  43. package/dist/bin/git-jira-whoami.js +1972 -0
  44. package/dist/bin/git-jira.js +170 -139
  45. package/dist/bin/git-lab-group-list.js +321 -279
  46. package/dist/bin/git-lab-group.js +323 -281
  47. package/dist/bin/git-lab-merge-active.js +321 -279
  48. package/dist/bin/git-lab-merge-todo.js +321 -279
  49. package/dist/bin/git-lab-merge-train-list.js +289 -273
  50. package/dist/bin/git-lab-merge-train.js +291 -275
  51. package/dist/bin/git-lab-merge.js +330 -288
  52. package/dist/bin/git-lab-namespace-list.js +138 -127
  53. package/dist/bin/git-lab-namespace.js +140 -129
  54. package/dist/bin/git-lab-project-list.js +288 -272
  55. package/dist/bin/git-lab-project-mr-list.js +2740 -0
  56. package/dist/bin/git-lab-project-mr.js +2752 -0
  57. package/dist/bin/git-lab-project-pipeline-jobs.js +2734 -0
  58. package/dist/bin/git-lab-project-pipeline-latest.js +2736 -0
  59. package/dist/bin/git-lab-project-pipeline-list.js +323 -281
  60. package/dist/bin/git-lab-project-pipeline-log.js +2739 -0
  61. package/dist/bin/git-lab-project-pipeline.js +437 -292
  62. package/dist/bin/git-lab-project-whereami.js +292 -276
  63. package/dist/bin/git-lab-project.js +563 -288
  64. package/dist/bin/git-lab-whoami.js +142 -131
  65. package/dist/bin/git-lab.js +575 -338
  66. package/dist/bin/gitj-install-skills.js +1954 -0
  67. package/dist/bin/gitj.js +1385 -473
  68. package/dist/index.js +371 -187
  69. package/index.ts +1 -0
  70. package/lib/api.ts +177 -0
  71. package/lib/confluence/api.ts +132 -0
  72. package/lib/confluence/config.ts +25 -0
  73. package/lib/confluence/index.ts +3 -0
  74. package/lib/confluence/types.ts +59 -0
  75. package/lib/gitlab/index.ts +1 -0
  76. package/lib/gitlab/job.ts +31 -0
  77. package/lib/gitlab/merge-request.ts +20 -0
  78. package/lib/gitlab/pipeline.ts +28 -1
  79. package/lib/gitlab/project.ts +14 -5
  80. package/lib/help.ts +40 -0
  81. package/lib/jira.ts +2 -2
  82. package/package.json +18 -2
  83. package/tests/all-help.test.ts +6 -1
  84. package/tests/gitj.test.ts +1 -1
  85. package/tests/help-all.test.ts +29 -0
  86. package/bun.lockb +0 -0
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
3
  var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __toESM = (mod, isNodeMode, target) => {
@@ -16,13 +16,27 @@ var __toESM = (mod, isNodeMode, target) => {
16
16
  return to;
17
17
  };
18
18
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
- var __require = (id) => {
20
- return import.meta.require(id);
21
- };
19
+ var __require = import.meta.require;
22
20
 
23
- // bine_modules/commander/l
21
+ // node_modules/ms/index.js
24
22
  var require_ms = __commonJS((exports, module) => {
25
- var parse = function(str) {
23
+ var s = 1000;
24
+ var m = s * 60;
25
+ var h = m * 60;
26
+ var d = h * 24;
27
+ var w = d * 7;
28
+ var y = d * 365.25;
29
+ module.exports = function(val, options) {
30
+ options = options || {};
31
+ var type = typeof val;
32
+ if (type === "string" && val.length > 0) {
33
+ return parse(val);
34
+ } else if (type === "number" && isFinite(val)) {
35
+ return options.long ? fmtLong(val) : fmtShort(val);
36
+ }
37
+ throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
38
+ };
39
+ function parse(str) {
26
40
  str = String(str);
27
41
  if (str.length > 100) {
28
42
  return;
@@ -75,8 +89,8 @@ var require_ms = __commonJS((exports, module) => {
75
89
  default:
76
90
  return;
77
91
  }
78
- };
79
- var fmtShort = function(ms) {
92
+ }
93
+ function fmtShort(ms) {
80
94
  var msAbs = Math.abs(ms);
81
95
  if (msAbs >= d) {
82
96
  return Math.round(ms / d) + "d";
@@ -91,8 +105,8 @@ var require_ms = __commonJS((exports, module) => {
91
105
  return Math.round(ms / s) + "s";
92
106
  }
93
107
  return ms + "ms";
94
- };
95
- var fmtLong = function(ms) {
108
+ }
109
+ function fmtLong(ms) {
96
110
  var msAbs = Math.abs(ms);
97
111
  if (msAbs >= d) {
98
112
  return plural(ms, msAbs, d, "day");
@@ -107,32 +121,16 @@ var require_ms = __commonJS((exports, module) => {
107
121
  return plural(ms, msAbs, s, "second");
108
122
  }
109
123
  return ms + " ms";
110
- };
111
- var plural = function(ms, msAbs, n, name) {
124
+ }
125
+ function plural(ms, msAbs, n, name) {
112
126
  var isPlural = msAbs >= n * 1.5;
113
127
  return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
114
- };
115
- var s = 1000;
116
- var m = s * 60;
117
- var h = m * 60;
118
- var d = h * 24;
119
- var w = d * 7;
120
- var y = d * 365.25;
121
- module.exports = function(val, options) {
122
- options = options || {};
123
- var type = typeof val;
124
- if (type === "string" && val.length > 0) {
125
- return parse(val);
126
- } else if (type === "number" && isFinite(val)) {
127
- return options.long ? fmtLong(val) : fmtShort(val);
128
- }
129
- throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
130
- };
128
+ }
131
129
  });
132
130
 
133
- // bine_modules/commander/lib/sugge
131
+ // node_modules/debug/src/common.js
134
132
  var require_common = __commonJS((exports, module) => {
135
- var setup = function(env) {
133
+ function setup(env) {
136
134
  createDebug.debug = createDebug;
137
135
  createDebug.default = createDebug;
138
136
  createDebug.coerce = coerce;
@@ -287,68 +285,12 @@ var require_common = __commonJS((exports, module) => {
287
285
  }
288
286
  createDebug.enable(createDebug.load());
289
287
  return createDebug;
290
- };
288
+ }
291
289
  module.exports = setup;
292
290
  });
293
291
 
294
- // bine_modules/commander/lib/sugges
292
+ // node_modules/debug/src/browser.js
295
293
  var require_browser = __commonJS((exports, module) => {
296
- var useColors = function() {
297
- if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
298
- return true;
299
- }
300
- if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
301
- return false;
302
- }
303
- return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
304
- };
305
- var formatArgs = function(args) {
306
- args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + exports.humanize(this.diff);
307
- if (!this.useColors) {
308
- return;
309
- }
310
- const c = "color: " + this.color;
311
- args.splice(1, 0, c, "color: inherit");
312
- let index = 0;
313
- let lastC = 0;
314
- args[0].replace(/%[a-zA-Z%]/g, (match) => {
315
- if (match === "%%") {
316
- return;
317
- }
318
- index++;
319
- if (match === "%c") {
320
- lastC = index;
321
- }
322
- });
323
- args.splice(lastC, 0, c);
324
- };
325
- var save = function(namespaces) {
326
- try {
327
- if (namespaces) {
328
- exports.storage.setItem("debug", namespaces);
329
- } else {
330
- exports.storage.removeItem("debug");
331
- }
332
- } catch (error) {
333
- }
334
- };
335
- var load = function() {
336
- let r;
337
- try {
338
- r = exports.storage.getItem("debug");
339
- } catch (error) {
340
- }
341
- if (!r && typeof process !== "undefined" && ("env" in process)) {
342
- r = process.env.DEBUG;
343
- }
344
- return r;
345
- };
346
- var localstorage = function() {
347
- try {
348
- return localStorage;
349
- } catch (error) {
350
- }
351
- };
352
294
  exports.formatArgs = formatArgs;
353
295
  exports.save = save;
354
296
  exports.load = load;
@@ -441,8 +383,60 @@ var require_browser = __commonJS((exports, module) => {
441
383
  "#FFCC00",
442
384
  "#FFCC33"
443
385
  ];
444
- exports.log = console.debug || console.log || (() => {
445
- });
386
+ function useColors() {
387
+ if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
388
+ return true;
389
+ }
390
+ if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
391
+ return false;
392
+ }
393
+ return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
394
+ }
395
+ function formatArgs(args) {
396
+ args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
397
+ if (!this.useColors) {
398
+ return;
399
+ }
400
+ const c = "color: " + this.color;
401
+ args.splice(1, 0, c, "color: inherit");
402
+ let index = 0;
403
+ let lastC = 0;
404
+ args[0].replace(/%[a-zA-Z%]/g, (match) => {
405
+ if (match === "%%") {
406
+ return;
407
+ }
408
+ index++;
409
+ if (match === "%c") {
410
+ lastC = index;
411
+ }
412
+ });
413
+ args.splice(lastC, 0, c);
414
+ }
415
+ exports.log = console.debug || console.log || (() => {});
416
+ function save(namespaces) {
417
+ try {
418
+ if (namespaces) {
419
+ exports.storage.setItem("debug", namespaces);
420
+ } else {
421
+ exports.storage.removeItem("debug");
422
+ }
423
+ } catch (error) {}
424
+ }
425
+ function load() {
426
+ let r;
427
+ try {
428
+ r = exports.storage.getItem("debug");
429
+ } catch (error) {}
430
+ if (!r && typeof process !== "undefined" && "env" in process) {
431
+ r = process.env.DEBUG;
432
+ }
433
+ return r;
434
+ }
435
+ function localstorage() {
436
+ try {
437
+ return localStorage;
438
+ } catch (error) {}
439
+ }
446
440
  module.exports = require_common()(exports);
447
441
  var { formatters } = module.exports;
448
442
  formatters.j = function(v) {
@@ -454,62 +448,20 @@ var require_browser = __commonJS((exports, module) => {
454
448
  };
455
449
  });
456
450
 
457
- // bine_modules/commander/lib/sug
451
+ // node_modules/debug/src/node.js
458
452
  var require_node = __commonJS((exports, module) => {
459
- var useColors = function() {
460
- return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
461
- };
462
- var formatArgs = function(args) {
463
- const { namespace: name, useColors: useColors2 } = this;
464
- if (useColors2) {
465
- const c = this.color;
466
- const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
467
- const prefix = ` ${colorCode};1m${name} \x1B[0m`;
468
- args[0] = prefix + args[0].split("\n").join("\n" + prefix);
469
- args.push(colorCode + "m+" + exports.humanize(this.diff) + "\x1B[0m");
470
- } else {
471
- args[0] = getDate() + name + " " + args[0];
472
- }
473
- };
474
- var getDate = function() {
475
- if (exports.inspectOpts.hideDate) {
476
- return "";
477
- }
478
- return new Date().toISOString() + " ";
479
- };
480
- var log = function(...args) {
481
- return process.stderr.write(util.format(...args) + "\n");
482
- };
483
- var save = function(namespaces) {
484
- if (namespaces) {
485
- process.env.DEBUG = namespaces;
486
- } else {
487
- delete process.env.DEBUG;
488
- }
489
- };
490
- var load = function() {
491
- return process.env.DEBUG;
492
- };
493
- var init = function(debug) {
494
- debug.inspectOpts = {};
495
- const keys = Object.keys(exports.inspectOpts);
496
- for (let i = 0;i < keys.length; i++) {
497
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
498
- }
499
- };
500
- var tty = import.meta.require("tty");
501
- var util = import.meta.require("util");
453
+ var tty = __require("tty");
454
+ var util = __require("util");
502
455
  exports.init = init;
503
456
  exports.log = log;
504
457
  exports.formatArgs = formatArgs;
505
458
  exports.save = save;
506
459
  exports.load = load;
507
460
  exports.useColors = useColors;
508
- exports.destroy = util.deprecate(() => {
509
- }, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
461
+ exports.destroy = util.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
510
462
  exports.colors = [6, 2, 3, 4, 5, 1];
511
463
  try {
512
- const supportsColor = (()=>{ throw new Error(`Cannot require module "supports-color"`);})();
464
+ const supportsColor = (()=>{throw new Error("Cannot require module "+"supports-color");})();
513
465
  if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
514
466
  exports.colors = [
515
467
  20,
@@ -590,8 +542,7 @@ var require_node = __commonJS((exports, module) => {
590
542
  221
591
543
  ];
592
544
  }
593
- } catch (error) {
594
- }
545
+ } catch (error) {}
595
546
  exports.inspectOpts = Object.keys(process.env).filter((key) => {
596
547
  return /^debug_/i.test(key);
597
548
  }).reduce((obj, key) => {
@@ -611,11 +562,56 @@ var require_node = __commonJS((exports, module) => {
611
562
  obj[prop] = val;
612
563
  return obj;
613
564
  }, {});
565
+ function useColors() {
566
+ return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
567
+ }
568
+ function formatArgs(args) {
569
+ const { namespace: name, useColors: useColors2 } = this;
570
+ if (useColors2) {
571
+ const c = this.color;
572
+ const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
573
+ const prefix = ` ${colorCode};1m${name} \x1B[0m`;
574
+ args[0] = prefix + args[0].split(`
575
+ `).join(`
576
+ ` + prefix);
577
+ args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
578
+ } else {
579
+ args[0] = getDate() + name + " " + args[0];
580
+ }
581
+ }
582
+ function getDate() {
583
+ if (exports.inspectOpts.hideDate) {
584
+ return "";
585
+ }
586
+ return new Date().toISOString() + " ";
587
+ }
588
+ function log(...args) {
589
+ return process.stderr.write(util.format(...args) + `
590
+ `);
591
+ }
592
+ function save(namespaces) {
593
+ if (namespaces) {
594
+ process.env.DEBUG = namespaces;
595
+ } else {
596
+ delete process.env.DEBUG;
597
+ }
598
+ }
599
+ function load() {
600
+ return process.env.DEBUG;
601
+ }
602
+ function init(debug) {
603
+ debug.inspectOpts = {};
604
+ const keys = Object.keys(exports.inspectOpts);
605
+ for (let i = 0;i < keys.length; i++) {
606
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
607
+ }
608
+ }
614
609
  module.exports = require_common()(exports);
615
610
  var { formatters } = module.exports;
616
611
  formatters.o = function(v) {
617
612
  this.inspectOpts.colors = this.useColors;
618
- return util.inspect(v, this.inspectOpts).split("\n").map((str) => str.trim()).join(" ");
613
+ return util.inspect(v, this.inspectOpts).split(`
614
+ `).map((str) => str.trim()).join(" ");
619
615
  };
620
616
  formatters.O = function(v) {
621
617
  this.inspectOpts.colors = this.useColors;
@@ -623,7 +619,7 @@ var require_node = __commonJS((exports, module) => {
623
619
  };
624
620
  });
625
621
 
626
- // bine_modules/commander/lib/sugg
622
+ // node_modules/debug/src/index.js
627
623
  var require_src = __commonJS((exports, module) => {
628
624
  if (typeof process === "undefined" || process.type === "renderer" || false || process.__nwjs) {
629
625
  module.exports = require_browser();
@@ -631,7 +627,10 @@ var require_src = __commonJS((exports, module) => {
631
627
  module.exports = require_node();
632
628
  }
633
629
  });
634
- // bine_modules
630
+ // lib/spawn.ts
631
+ var defaultOptions = {
632
+ expectQuiet: false
633
+ };
635
634
  async function spawn(args, options = defaultOptions) {
636
635
  const proc = Bun.spawn(args, { stdout: "pipe", stderr: "pipe" });
637
636
  const stdout = new Response(proc.stdout);
@@ -652,11 +651,8 @@ async function doCommand(args, options = defaultOptions) {
652
651
  console.error(err);
653
652
  return out;
654
653
  }
655
- var defaultOptions = {
656
- expectQuiet: false
657
- };
658
654
 
659
- // bine_modul
655
+ // lib/git.ts
660
656
  async function getConfig(key, options = defaultOptions) {
661
657
  return doCommand(["git", "config", "--get", key], options);
662
658
  }
@@ -669,10 +665,157 @@ async function getCurrentBranch() {
669
665
  async function getRemote() {
670
666
  return doCommand(["git", "ls-remote", "--get-url", "origin"]);
671
667
  }
672
- // bine_modules/command
668
+
669
+ // lib/confluence/config.ts
670
+ var gitEmailP = getConfig("user.email");
671
+ var jiraEmailP = getConfig("jira.user");
672
+ var confluenceEmailP = getConfig("confluence.user", { expectQuiet: true });
673
+ var jiraHostP = getConfig("jira.host");
674
+ var confluenceHostP = getConfig("confluence.host", { expectQuiet: true });
675
+ var jiraTokenP = getConfig("jira.token");
676
+ var confluenceTokenP = getConfig("confluence.token", { expectQuiet: true });
677
+ async function getConfluenceConfig() {
678
+ const host = await confluenceHostP || await jiraHostP;
679
+ if (!host)
680
+ throw new Error("confluence.host or jira.host not in git config");
681
+ const user = await confluenceEmailP || await jiraEmailP || await gitEmailP;
682
+ if (!user)
683
+ throw new Error("confluence.user, jira.user, or user.email not in git config");
684
+ const pat = await confluenceTokenP || await jiraTokenP;
685
+ if (!pat)
686
+ throw new Error("confluence.token or jira.token not in git config");
687
+ const token = Buffer.from(`${user}:${pat}`).toString("base64");
688
+ return { host, token };
689
+ }
690
+
691
+ // lib/confluence/api.ts
692
+ function getNextLink(link) {
693
+ if (!link) {
694
+ return;
695
+ }
696
+ const regex = /<([^>]+)>; rel="next"/;
697
+ const match = link.match(regex);
698
+ const next = match ? match[1] : undefined;
699
+ return next;
700
+ }
701
+ async function confluenceApi(endpoint) {
702
+ if (endpoint.startsWith("/")) {
703
+ console.warn(`confluenceApi: endpoint ${endpoint} starts with /, removing it`);
704
+ endpoint = endpoint.slice(1);
705
+ }
706
+ const method = "GET";
707
+ const { host, token } = await getConfluenceConfig();
708
+ const base = `https://${host}/wiki/api/v2`;
709
+ const uri = `${base}/${endpoint}`;
710
+ const auth = `Basic ${token}`;
711
+ const headers = new Headers;
712
+ headers.append("Authorization", auth);
713
+ headers.append("Accept", "application/json");
714
+ const options = {
715
+ method,
716
+ headers
717
+ };
718
+ let request = new Request(uri, options);
719
+ const response = await fetch(request);
720
+ let link = getNextLink(response.headers.get("Link"));
721
+ const body = await response.json();
722
+ if (!body.results) {
723
+ return body;
724
+ }
725
+ let result = body.results;
726
+ const origin = `https://${host}`;
727
+ while (link) {
728
+ const url = link.startsWith("/") ? `${origin}${link}` : link;
729
+ let request2 = new Request(url, options);
730
+ const next_response = await fetch(request2);
731
+ link = getNextLink(next_response.headers.get("Link"));
732
+ const next_body = await next_response.json();
733
+ if (next_body.results) {
734
+ result = result.concat(next_body.results);
735
+ }
736
+ }
737
+ return result;
738
+ }
739
+ async function confluenceApiWrite(endpoint, method, body) {
740
+ if (endpoint.startsWith("/")) {
741
+ console.warn(`confluenceApiWrite: endpoint ${endpoint} starts with /, removing it`);
742
+ endpoint = endpoint.slice(1);
743
+ }
744
+ const { host, token } = await getConfluenceConfig();
745
+ const base = `https://${host}/wiki/api/v2`;
746
+ const uri = `${base}/${endpoint}`;
747
+ const auth = `Basic ${token}`;
748
+ const headers = new Headers;
749
+ headers.append("Authorization", auth);
750
+ headers.append("Accept", "application/json");
751
+ headers.append("Content-Type", "application/json");
752
+ const options = {
753
+ method,
754
+ headers,
755
+ body: JSON.stringify(body)
756
+ };
757
+ const request = new Request(uri, options);
758
+ const response = await fetch(request);
759
+ if (!response.ok) {
760
+ const text = await response.text();
761
+ throw new Error(`Confluence API ${method} ${endpoint} failed (${response.status}): ${text}`);
762
+ }
763
+ const result = await response.json();
764
+ return result;
765
+ }
766
+ async function confluenceSearch(cql) {
767
+ const { host, token } = await getConfluenceConfig();
768
+ const base = `https://${host}/wiki/rest/api`;
769
+ const auth = `Basic ${token}`;
770
+ const headers = new Headers;
771
+ headers.append("Authorization", auth);
772
+ headers.append("Accept", "application/json");
773
+ const options = { method: "GET", headers };
774
+ const origin = `https://${host}`;
775
+ let uri = `${base}/search?cql=${encodeURIComponent(cql)}&limit=25`;
776
+ let allResults = [];
777
+ while (uri) {
778
+ const request = new Request(uri, options);
779
+ const response = await fetch(request);
780
+ const body = await response.json();
781
+ if (body.results) {
782
+ allResults = allResults.concat(body.results);
783
+ }
784
+ const next = body._links?.next;
785
+ uri = next ? next.startsWith("/") ? `${origin}${next}` : next : "";
786
+ }
787
+ return allResults;
788
+ }
789
+ async function confluenceApiV1(endpoint) {
790
+ if (endpoint.startsWith("/")) {
791
+ console.warn(`confluenceApiV1: endpoint ${endpoint} starts with /, removing it`);
792
+ endpoint = endpoint.slice(1);
793
+ }
794
+ const method = "GET";
795
+ const { host, token } = await getConfluenceConfig();
796
+ const base = `https://${host}/wiki/rest/api`;
797
+ const uri = `${base}/${endpoint}`;
798
+ const auth = `Basic ${token}`;
799
+ const headers = new Headers;
800
+ headers.append("Authorization", auth);
801
+ headers.append("Accept", "application/json");
802
+ const options = {
803
+ method,
804
+ headers
805
+ };
806
+ const request = new Request(uri, options);
807
+ const response = await fetch(request);
808
+ const result = await response.json();
809
+ return result;
810
+ }
811
+ // lib/gitlab/config.ts
812
+ var gitEmailP2 = getConfig("user.email");
813
+ var gitlabEmailP = getConfig("gitlab.user", { expectQuiet: true });
814
+ var hostP = getConfig("gitlab.host");
815
+ var tokenP = getConfig("gitlab.token");
673
816
  async function getGitlabConfig() {
674
817
  const host = await hostP || "gitlab.com";
675
- const user = await gitEmailP || await gitlabEmailP;
818
+ const user = await gitEmailP2 || await gitlabEmailP;
676
819
  if (!user)
677
820
  throw new Error("Neither user.email nor gitlab.email in git config");
678
821
  const token = await tokenP;
@@ -680,13 +823,9 @@ async function getGitlabConfig() {
680
823
  throw new Error("gitlab.token not in git config");
681
824
  return { host, user, token };
682
825
  }
683
- var gitEmailP = getConfig("user.email");
684
- var gitlabEmailP = getConfig("gitlab.user", { expectQuiet: true });
685
- var hostP = getConfig("gitlab.host");
686
- var tokenP = getConfig("gitlab.token");
687
826
 
688
- // bine_modules/comm
689
- var getNextLink = function(link) {
827
+ // lib/gitlab/api.ts
828
+ function getNextLink2(link) {
690
829
  if (!link) {
691
830
  return;
692
831
  }
@@ -694,7 +833,7 @@ var getNextLink = function(link) {
694
833
  const match = link.match(regex);
695
834
  const next = match ? match[1] : undefined;
696
835
  return next;
697
- };
836
+ }
698
837
  async function gitlabApi(endpoint) {
699
838
  if (endpoint.startsWith("/")) {
700
839
  console.warn(`gitlabApi: endpoint ${endpoint} starts with /, removing it`);
@@ -715,30 +854,28 @@ async function gitlabApi(endpoint) {
715
854
  };
716
855
  let request = new Request(uri, options);
717
856
  const response = await fetch(request);
718
- let link = getNextLink(response.headers.get("Link"));
857
+ let link = getNextLink2(response.headers.get("Link"));
719
858
  let partial = await response.json();
720
859
  let result = partial;
721
860
  while (partial.length == requested && link) {
722
861
  let request2 = new Request(link, options);
723
862
  const next_response = await fetch(request2);
724
- link = getNextLink(next_response.headers.get("Link"));
863
+ link = getNextLink2(next_response.headers.get("Link"));
725
864
  partial = await next_response.json();
726
865
  result = result.concat(partial);
727
866
  }
728
867
  return result;
729
868
  }
730
- // bine_modules/comman
869
+ // lib/gitlab/group.ts
731
870
  async function getGroups() {
732
871
  return await gitlabApi(`groups`);
733
872
  }
734
- // bine_modules/commande
735
- import path from "path";
736
-
737
- // bine_modules/comma
873
+ // lib/gitlab/dlog.ts
738
874
  var import_debug = __toESM(require_src(), 1);
739
875
  var dlog = import_debug.default("gitlab");
740
876
 
741
- // bine_modules/commande
877
+ // lib/gitlab/project.ts
878
+ import path from "path";
742
879
  async function getProjects(match) {
743
880
  let search = "";
744
881
  if (match) {
@@ -770,7 +907,7 @@ async function findProject(ssh_url) {
770
907
  });
771
908
  return project;
772
909
  }
773
- async function projectScopedGet(endpoint) {
910
+ async function projectScopedRequest(endpoint) {
774
911
  if (endpoint.startsWith("/")) {
775
912
  console.warn(`gitlabApi: endpoint ${endpoint} starts with /, removing it`);
776
913
  endpoint = endpoint.slice(1);
@@ -783,26 +920,46 @@ async function projectScopedGet(endpoint) {
783
920
  throw new Error(`Could not find project for remote ${remote}`);
784
921
  }
785
922
  const base = `https://${host}/api/v4/projects/${project.id}`;
786
- const uri = `${base}/${endpoint}`;
787
- dlog(`projectScopedGet uri: ${uri}`);
923
+ const sep = endpoint.includes("?") ? "&" : "?";
924
+ const uri = `${base}/${endpoint}${sep}per_page=100`;
925
+ dlog(`projectScopedRequest uri: ${uri}`);
788
926
  const headers = new Headers;
789
- headers.append("Accept", "application/json");
790
927
  headers.append("Private-Token", token);
791
928
  const options = {
792
929
  method,
793
930
  headers
794
931
  };
795
932
  const request = new Request(uri, options);
796
- const response = await fetch(request);
933
+ return await fetch(request);
934
+ }
935
+ async function projectScopedGet(endpoint) {
936
+ const response = await projectScopedRequest(endpoint);
797
937
  return await response.json();
798
938
  }
939
+ async function projectScopedGetText(endpoint) {
940
+ const response = await projectScopedRequest(endpoint);
941
+ return await response.text();
942
+ }
799
943
 
800
- // bine_modules/comma
944
+ // lib/gitlab/job.ts
945
+ async function getPipelineJobs(pipelineId) {
946
+ dlog(`getPipelineJobs pipelineId: ${pipelineId}`);
947
+ return await projectScopedGet(`pipelines/${pipelineId}/jobs`);
948
+ }
949
+ async function getJob(jobId) {
950
+ dlog(`getJob jobId: ${jobId}`);
951
+ return await projectScopedGet(`jobs/${jobId}`);
952
+ }
953
+ async function getJobLog(jobId) {
954
+ dlog(`getJobLog jobId: ${jobId}`);
955
+ return await projectScopedGetText(`jobs/${jobId}/trace`);
956
+ }
957
+ // lib/gitlab/user.ts
801
958
  async function whoami() {
802
959
  return await gitlabApi("user");
803
960
  }
804
961
 
805
- // bine_modules/commander/lib/
962
+ // lib/gitlab/merge-request.ts
806
963
  async function getMergeRequest(id) {
807
964
  return await projectScopedGet(`merge_requests/${id}`);
808
965
  }
@@ -814,11 +971,16 @@ async function getMyMergeRequestsToReview() {
814
971
  const me = await whoami();
815
972
  return await gitlabApi(`merge_requests?state=opened&reviewer_id=${me.id}`);
816
973
  }
817
- // bine_modules/commander/
974
+ async function getMergeRequestsByBranch(projectPath, sourceBranch) {
975
+ const project = encodeURIComponent(projectPath);
976
+ const branch = encodeURIComponent(sourceBranch);
977
+ return await gitlabApi(`projects/${project}/merge_requests?state=opened&source_branch=${branch}`);
978
+ }
979
+ // lib/gitlab/namespace.ts
818
980
  async function getNamespaces() {
819
981
  return await gitlabApi(`namespaces`);
820
982
  }
821
- // bine_modules/commander
983
+ // lib/gitlab/pipeline.ts
822
984
  async function getProjectPipelines(options) {
823
985
  const { days, status } = options;
824
986
  const me = await whoami();
@@ -830,13 +992,23 @@ async function getProjectPipelines(options) {
830
992
  dlog(`updated: ${updated}`);
831
993
  return await projectScopedGet(`pipelines?status=${status}&username=${username}&updated_after=${updated}`);
832
994
  }
833
- // bine_modules/c
995
+ async function getMergeRequestPipelines(projectPath, mrIid) {
996
+ const project = encodeURIComponent(projectPath);
997
+ return await gitlabApi(`projects/${project}/merge_requests/${mrIid}/pipelines`);
998
+ }
999
+ async function getLatestPipeline() {
1000
+ const ref = await getCurrentBranch();
1001
+ dlog(`getLatestPipeline ref: ${ref}`);
1002
+ const pipelines = await projectScopedGet(`pipelines?ref=${encodeURIComponent(ref)}&per_page=1&order_by=id&sort=desc`);
1003
+ return pipelines.length > 0 ? pipelines[0] : undefined;
1004
+ }
1005
+ // lib/is_main.ts
834
1006
  import path2 from "path";
835
- var justBase = function(filename) {
1007
+ function justBase(filename) {
836
1008
  const ext = path2.extname(filename);
837
1009
  const base = path2.basename(filename, ext);
838
1010
  return base;
839
- };
1011
+ }
840
1012
  function isMain(self) {
841
1013
  const arg1 = Bun.argv[1];
842
1014
  const argv1Base = justBase(arg1);
@@ -844,18 +1016,22 @@ function isMain(self) {
844
1016
  const result = argv1Base === selfBase;
845
1017
  return result;
846
1018
  }
847
- // bine_module
1019
+ // lib/jira.ts
1020
+ var gitEmailP3 = getConfig("user.email");
1021
+ var jiraEmailP2 = getConfig("jira.user");
1022
+ var hostP2 = getConfig("jira.host");
1023
+ var tokenP2 = getConfig("jira.token");
848
1024
  async function getJiraConfig() {
849
1025
  const host = await hostP2;
850
1026
  if (!host)
851
1027
  throw new Error("jira.host not in git config");
852
- const user4 = await jiraEmailP || await gitEmailP2;
853
- if (!user4)
1028
+ const user2 = await jiraEmailP2 || await gitEmailP3;
1029
+ if (!user2)
854
1030
  throw new Error("jira.user or user.email not in git config");
855
1031
  const pat = await tokenP2;
856
1032
  if (!pat)
857
1033
  throw new Error("jira.token not in git config");
858
- const token = Buffer.from(`${user4}:${pat}`).toString("base64");
1034
+ const token = Buffer.from(`${user2}:${pat}`).toString("base64");
859
1035
  return { host, token };
860
1036
  }
861
1037
  async function jiraApi(endpoint) {
@@ -884,22 +1060,19 @@ async function getIssue(issue) {
884
1060
  return result;
885
1061
  }
886
1062
  async function getMyself() {
887
- return await jiraApi("/myself");
1063
+ return await jiraApi("myself");
888
1064
  }
889
1065
  async function myUnresolvedIssues() {
890
1066
  const myself = await getMyself();
891
1067
  const myselfId = myself.accountId;
892
1068
  const jql = `assignee = ${myselfId} AND resolution = Unresolved`;
893
- const issues = await jiraApi(`/search?jql=${encodeURIComponent(jql)}`);
1069
+ const issues = await jiraApi(`search/jql?jql=${encodeURIComponent(jql)}&fields=summary`);
894
1070
  return issues.issues;
895
1071
  }
896
- var gitEmailP2 = getConfig("user.email");
897
- var jiraEmailP = getConfig("jira.user");
898
- var hostP2 = getConfig("jira.host");
899
- var tokenP2 = getConfig("jira.token");
900
1072
  export {
901
1073
  whoami,
902
1074
  spawn,
1075
+ projectScopedGetText,
903
1076
  projectScopedGet,
904
1077
  myUnresolvedIssues,
905
1078
  jiraApi,
@@ -908,19 +1081,30 @@ export {
908
1081
  getRemote,
909
1082
  getProjects,
910
1083
  getProjectPipelines,
1084
+ getPipelineJobs,
911
1085
  getNamespaces,
912
1086
  getMyself,
913
1087
  getMyMergeRequestsToReview,
914
1088
  getMyMergeRequestsInProgress,
1089
+ getMergeRequestsByBranch,
1090
+ getMergeRequestPipelines,
915
1091
  getMergeRequest,
1092
+ getLatestPipeline,
1093
+ getJobLog,
1094
+ getJob,
916
1095
  getJiraConfig,
917
1096
  getIssue,
918
1097
  getGroups,
919
1098
  getGitlabConfig,
920
1099
  getCurrentBranch,
1100
+ getConfluenceConfig,
921
1101
  getConfig,
922
1102
  findProject,
923
1103
  doCommand,
924
1104
  defaultOptions,
925
- createBranch
1105
+ createBranch,
1106
+ confluenceSearch,
1107
+ confluenceApiWrite,
1108
+ confluenceApiV1,
1109
+ confluenceApi
926
1110
  };