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.
- package/.opencode/skills/architecture/SKILL.md +45 -0
- package/.opencode/skills/code-style/SKILL.md +76 -0
- package/.opencode/skills/git-confluence/SKILL.md +82 -0
- package/.opencode/skills/git-jira/SKILL.md +63 -0
- package/.opencode/skills/git-lab/SKILL.md +102 -0
- package/AGENTS.md +50 -0
- package/README.md +106 -106
- package/bin/git-api.ts +70 -0
- package/bin/git-confluence-page-search.ts +58 -0
- package/bin/git-confluence-page-show.ts +61 -0
- package/bin/git-confluence-page-update.ts +77 -0
- package/bin/git-confluence-page.ts +28 -0
- package/bin/git-confluence-space-list.ts +34 -0
- package/bin/git-confluence-space.ts +24 -0
- package/bin/git-confluence-whoami.ts +33 -0
- package/bin/git-confluence.ts +27 -0
- package/bin/git-jira-start.ts +1 -1
- package/bin/git-jira-whoami.ts +32 -0
- package/bin/git-jira.ts +2 -0
- package/bin/git-lab-project-mr-list.ts +57 -0
- package/bin/git-lab-project-mr.ts +24 -0
- package/bin/git-lab-project-pipeline-jobs.ts +46 -0
- package/bin/git-lab-project-pipeline-latest.ts +47 -0
- package/bin/git-lab-project-pipeline-log.ts +49 -0
- package/bin/git-lab-project-pipeline.ts +6 -0
- package/bin/git-lab-project.ts +5 -1
- package/bin/gitj-install-skills.ts +126 -0
- package/bin/gitj.ts +12 -0
- package/dist/bin/git-api.js +2156 -0
- package/dist/bin/git-bump.js +132 -121
- package/dist/bin/git-confluence-page-search.js +2079 -0
- package/dist/bin/git-confluence-page-show.js +2082 -0
- package/dist/bin/git-confluence-page-update.js +2093 -0
- package/dist/bin/git-confluence-page.js +2186 -0
- package/dist/bin/git-confluence-space-list.js +2061 -0
- package/dist/bin/git-confluence-space.js +2073 -0
- package/dist/bin/git-confluence-whoami.js +2060 -0
- package/dist/bin/git-confluence.js +2251 -0
- package/dist/bin/git-jira-issue-list.js +136 -125
- package/dist/bin/git-jira-issue-show.js +136 -125
- package/dist/bin/git-jira-issue.js +140 -129
- package/dist/bin/git-jira-start.js +138 -127
- package/dist/bin/git-jira-whoami.js +1972 -0
- package/dist/bin/git-jira.js +170 -139
- package/dist/bin/git-lab-group-list.js +321 -279
- package/dist/bin/git-lab-group.js +323 -281
- package/dist/bin/git-lab-merge-active.js +321 -279
- package/dist/bin/git-lab-merge-todo.js +321 -279
- package/dist/bin/git-lab-merge-train-list.js +289 -273
- package/dist/bin/git-lab-merge-train.js +291 -275
- package/dist/bin/git-lab-merge.js +330 -288
- package/dist/bin/git-lab-namespace-list.js +138 -127
- package/dist/bin/git-lab-namespace.js +140 -129
- package/dist/bin/git-lab-project-list.js +288 -272
- package/dist/bin/git-lab-project-mr-list.js +2740 -0
- package/dist/bin/git-lab-project-mr.js +2752 -0
- package/dist/bin/git-lab-project-pipeline-jobs.js +2734 -0
- package/dist/bin/git-lab-project-pipeline-latest.js +2736 -0
- package/dist/bin/git-lab-project-pipeline-list.js +323 -281
- package/dist/bin/git-lab-project-pipeline-log.js +2739 -0
- package/dist/bin/git-lab-project-pipeline.js +437 -292
- package/dist/bin/git-lab-project-whereami.js +292 -276
- package/dist/bin/git-lab-project.js +563 -288
- package/dist/bin/git-lab-whoami.js +142 -131
- package/dist/bin/git-lab.js +575 -338
- package/dist/bin/gitj-install-skills.js +1954 -0
- package/dist/bin/gitj.js +1385 -473
- package/dist/index.js +371 -187
- package/index.ts +1 -0
- package/lib/api.ts +177 -0
- package/lib/confluence/api.ts +132 -0
- package/lib/confluence/config.ts +25 -0
- package/lib/confluence/index.ts +3 -0
- package/lib/confluence/types.ts +59 -0
- package/lib/gitlab/index.ts +1 -0
- package/lib/gitlab/job.ts +31 -0
- package/lib/gitlab/merge-request.ts +20 -0
- package/lib/gitlab/pipeline.ts +28 -1
- package/lib/gitlab/project.ts +14 -5
- package/lib/help.ts +40 -0
- package/lib/jira.ts +2 -2
- package/package.json +18 -2
- package/tests/all-help.test.ts +6 -1
- package/tests/gitj.test.ts +1 -1
- package/tests/help-all.test.ts +29 -0
- package/bun.lockb +0 -0
package/dist/bin/gitj.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
3
|
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getProtoOf = Object.getPrototypeOf;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __toESM = (mod, isNodeMode, target) => {
|
|
@@ -17,11 +17,9 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
20
|
-
var __require =
|
|
21
|
-
return import.meta.require(id);
|
|
22
|
-
};
|
|
20
|
+
var __require = import.meta.require;
|
|
23
21
|
|
|
24
|
-
//
|
|
22
|
+
// node_modules/commander/lib/error.js
|
|
25
23
|
var require_error = __commonJS((exports) => {
|
|
26
24
|
class CommanderError extends Error {
|
|
27
25
|
constructor(exitCode, code, message) {
|
|
@@ -45,12 +43,8 @@ var require_error = __commonJS((exports) => {
|
|
|
45
43
|
exports.InvalidArgumentError = InvalidArgumentError;
|
|
46
44
|
});
|
|
47
45
|
|
|
48
|
-
//
|
|
46
|
+
// node_modules/commander/lib/argument.js
|
|
49
47
|
var require_argument = __commonJS((exports) => {
|
|
50
|
-
var humanReadableArgName = function(arg) {
|
|
51
|
-
const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
|
|
52
|
-
return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
|
|
53
|
-
};
|
|
54
48
|
var { InvalidArgumentError } = require_error();
|
|
55
49
|
|
|
56
50
|
class Argument {
|
|
@@ -120,11 +114,15 @@ var require_argument = __commonJS((exports) => {
|
|
|
120
114
|
return this;
|
|
121
115
|
}
|
|
122
116
|
}
|
|
117
|
+
function humanReadableArgName(arg) {
|
|
118
|
+
const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
|
|
119
|
+
return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]";
|
|
120
|
+
}
|
|
123
121
|
exports.Argument = Argument;
|
|
124
122
|
exports.humanReadableArgName = humanReadableArgName;
|
|
125
123
|
});
|
|
126
124
|
|
|
127
|
-
//
|
|
125
|
+
// node_modules/commander/lib/help.js
|
|
128
126
|
var require_help = __commonJS((exports) => {
|
|
129
127
|
var { humanReadableArgName } = require_argument();
|
|
130
128
|
|
|
@@ -301,7 +299,8 @@ var require_help = __commonJS((exports) => {
|
|
|
301
299
|
return term;
|
|
302
300
|
}
|
|
303
301
|
function formatList(textArray) {
|
|
304
|
-
return textArray.join(
|
|
302
|
+
return textArray.join(`
|
|
303
|
+
`).replace(/^/gm, " ".repeat(itemIndentWidth));
|
|
305
304
|
}
|
|
306
305
|
let output = [`Usage: ${helper.commandUsage(cmd)}`, ""];
|
|
307
306
|
const commandDescription = helper.commandDescription(cmd);
|
|
@@ -334,7 +333,8 @@ var require_help = __commonJS((exports) => {
|
|
|
334
333
|
if (commandList.length > 0) {
|
|
335
334
|
output = output.concat(["Commands:", formatList(commandList), ""]);
|
|
336
335
|
}
|
|
337
|
-
return output.join(
|
|
336
|
+
return output.join(`
|
|
337
|
+
`);
|
|
338
338
|
}
|
|
339
339
|
padWidth(cmd, helper) {
|
|
340
340
|
return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper));
|
|
@@ -348,42 +348,29 @@ var require_help = __commonJS((exports) => {
|
|
|
348
348
|
if (columnWidth < minColumnWidth)
|
|
349
349
|
return str;
|
|
350
350
|
const leadingStr = str.slice(0, indent);
|
|
351
|
-
const columnText = str.slice(indent).replace(
|
|
351
|
+
const columnText = str.slice(indent).replace(`\r
|
|
352
|
+
`, `
|
|
353
|
+
`);
|
|
352
354
|
const indentString = " ".repeat(indent);
|
|
353
355
|
const zeroWidthSpace = "\u200B";
|
|
354
356
|
const breaks = `\\s${zeroWidthSpace}`;
|
|
355
|
-
const regex = new RegExp(
|
|
357
|
+
const regex = new RegExp(`
|
|
358
|
+
|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, "g");
|
|
356
359
|
const lines = columnText.match(regex) || [];
|
|
357
360
|
return leadingStr + lines.map((line, i) => {
|
|
358
|
-
if (line ===
|
|
361
|
+
if (line === `
|
|
362
|
+
`)
|
|
359
363
|
return "";
|
|
360
364
|
return (i > 0 ? indentString : "") + line.trimEnd();
|
|
361
|
-
}).join(
|
|
365
|
+
}).join(`
|
|
366
|
+
`);
|
|
362
367
|
}
|
|
363
368
|
}
|
|
364
369
|
exports.Help = Help;
|
|
365
370
|
});
|
|
366
371
|
|
|
367
|
-
//
|
|
372
|
+
// node_modules/commander/lib/option.js
|
|
368
373
|
var require_option = __commonJS((exports) => {
|
|
369
|
-
var camelcase = function(str) {
|
|
370
|
-
return str.split("-").reduce((str2, word) => {
|
|
371
|
-
return str2 + word[0].toUpperCase() + word.slice(1);
|
|
372
|
-
});
|
|
373
|
-
};
|
|
374
|
-
var splitOptionFlags = function(flags) {
|
|
375
|
-
let shortFlag;
|
|
376
|
-
let longFlag;
|
|
377
|
-
const flagParts = flags.split(/[ |,]+/);
|
|
378
|
-
if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
|
|
379
|
-
shortFlag = flagParts.shift();
|
|
380
|
-
longFlag = flagParts.shift();
|
|
381
|
-
if (!shortFlag && /^-[^-]$/.test(longFlag)) {
|
|
382
|
-
shortFlag = longFlag;
|
|
383
|
-
longFlag = undefined;
|
|
384
|
-
}
|
|
385
|
-
return { shortFlag, longFlag };
|
|
386
|
-
};
|
|
387
374
|
var { InvalidArgumentError } = require_error();
|
|
388
375
|
|
|
389
376
|
class Option {
|
|
@@ -511,14 +498,33 @@ var require_option = __commonJS((exports) => {
|
|
|
511
498
|
return option.negate === (negativeValue === value);
|
|
512
499
|
}
|
|
513
500
|
}
|
|
501
|
+
function camelcase(str) {
|
|
502
|
+
return str.split("-").reduce((str2, word) => {
|
|
503
|
+
return str2 + word[0].toUpperCase() + word.slice(1);
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
function splitOptionFlags(flags) {
|
|
507
|
+
let shortFlag;
|
|
508
|
+
let longFlag;
|
|
509
|
+
const flagParts = flags.split(/[ |,]+/);
|
|
510
|
+
if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
|
|
511
|
+
shortFlag = flagParts.shift();
|
|
512
|
+
longFlag = flagParts.shift();
|
|
513
|
+
if (!shortFlag && /^-[^-]$/.test(longFlag)) {
|
|
514
|
+
shortFlag = longFlag;
|
|
515
|
+
longFlag = undefined;
|
|
516
|
+
}
|
|
517
|
+
return { shortFlag, longFlag };
|
|
518
|
+
}
|
|
514
519
|
exports.Option = Option;
|
|
515
520
|
exports.splitOptionFlags = splitOptionFlags;
|
|
516
521
|
exports.DualOptions = DualOptions;
|
|
517
522
|
});
|
|
518
523
|
|
|
519
|
-
//
|
|
524
|
+
// node_modules/commander/lib/suggestSimilar.js
|
|
520
525
|
var require_suggestSimilar = __commonJS((exports) => {
|
|
521
|
-
var
|
|
526
|
+
var maxDistance = 3;
|
|
527
|
+
function editDistance(a, b) {
|
|
522
528
|
if (Math.abs(a.length - b.length) > maxDistance)
|
|
523
529
|
return Math.max(a.length, b.length);
|
|
524
530
|
const d = [];
|
|
@@ -543,8 +549,8 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
543
549
|
}
|
|
544
550
|
}
|
|
545
551
|
return d[a.length][b.length];
|
|
546
|
-
}
|
|
547
|
-
|
|
552
|
+
}
|
|
553
|
+
function suggestSimilar(word, candidates) {
|
|
548
554
|
if (!candidates || candidates.length === 0)
|
|
549
555
|
return "";
|
|
550
556
|
candidates = Array.from(new Set(candidates));
|
|
@@ -576,67 +582,25 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
576
582
|
similar = similar.map((candidate) => `--${candidate}`);
|
|
577
583
|
}
|
|
578
584
|
if (similar.length > 1) {
|
|
579
|
-
return
|
|
585
|
+
return `
|
|
586
|
+
(Did you mean one of ${similar.join(", ")}?)`;
|
|
580
587
|
}
|
|
581
588
|
if (similar.length === 1) {
|
|
582
|
-
return
|
|
589
|
+
return `
|
|
590
|
+
(Did you mean ${similar[0]}?)`;
|
|
583
591
|
}
|
|
584
592
|
return "";
|
|
585
|
-
}
|
|
586
|
-
var maxDistance = 3;
|
|
593
|
+
}
|
|
587
594
|
exports.suggestSimilar = suggestSimilar;
|
|
588
595
|
});
|
|
589
596
|
|
|
590
|
-
//
|
|
597
|
+
// node_modules/commander/lib/command.js
|
|
591
598
|
var require_command = __commonJS((exports) => {
|
|
592
|
-
var
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
}
|
|
598
|
-
};
|
|
599
|
-
var incrementNodeInspectorPort = function(args) {
|
|
600
|
-
return args.map((arg) => {
|
|
601
|
-
if (!arg.startsWith("--inspect")) {
|
|
602
|
-
return arg;
|
|
603
|
-
}
|
|
604
|
-
let debugOption;
|
|
605
|
-
let debugHost = "127.0.0.1";
|
|
606
|
-
let debugPort = "9229";
|
|
607
|
-
let match;
|
|
608
|
-
if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
|
|
609
|
-
debugOption = match[1];
|
|
610
|
-
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
|
|
611
|
-
debugOption = match[1];
|
|
612
|
-
if (/^\d+$/.test(match[3])) {
|
|
613
|
-
debugPort = match[3];
|
|
614
|
-
} else {
|
|
615
|
-
debugHost = match[3];
|
|
616
|
-
}
|
|
617
|
-
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
|
|
618
|
-
debugOption = match[1];
|
|
619
|
-
debugHost = match[3];
|
|
620
|
-
debugPort = match[4];
|
|
621
|
-
}
|
|
622
|
-
if (debugOption && debugPort !== "0") {
|
|
623
|
-
return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
|
|
624
|
-
}
|
|
625
|
-
return arg;
|
|
626
|
-
});
|
|
627
|
-
};
|
|
628
|
-
var getCommandAndParents = function(startCommand) {
|
|
629
|
-
const result = [];
|
|
630
|
-
for (let command = startCommand;command; command = command.parent) {
|
|
631
|
-
result.push(command);
|
|
632
|
-
}
|
|
633
|
-
return result;
|
|
634
|
-
};
|
|
635
|
-
var EventEmitter = import.meta.require("events").EventEmitter;
|
|
636
|
-
var childProcess = import.meta.require("child_process");
|
|
637
|
-
var path = import.meta.require("path");
|
|
638
|
-
var fs = import.meta.require("fs");
|
|
639
|
-
var process2 = import.meta.require("process");
|
|
599
|
+
var EventEmitter = __require("events").EventEmitter;
|
|
600
|
+
var childProcess = __require("child_process");
|
|
601
|
+
var path = __require("path");
|
|
602
|
+
var fs = __require("fs");
|
|
603
|
+
var process2 = __require("process");
|
|
640
604
|
var { Argument, humanReadableArgName } = require_argument();
|
|
641
605
|
var { CommanderError } = require_error();
|
|
642
606
|
var { Help } = require_help();
|
|
@@ -853,8 +817,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
853
817
|
this._exitCallback = (err) => {
|
|
854
818
|
if (err.code !== "commander.executeSubCommandAsync") {
|
|
855
819
|
throw err;
|
|
856
|
-
} else {
|
|
857
|
-
}
|
|
820
|
+
} else {}
|
|
858
821
|
};
|
|
859
822
|
}
|
|
860
823
|
return this;
|
|
@@ -1491,11 +1454,14 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1491
1454
|
return getCommandAndParents(this).reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {});
|
|
1492
1455
|
}
|
|
1493
1456
|
error(message, errorOptions) {
|
|
1494
|
-
this._outputConfiguration.outputError(`${message}
|
|
1457
|
+
this._outputConfiguration.outputError(`${message}
|
|
1458
|
+
`, this._outputConfiguration.writeErr);
|
|
1495
1459
|
if (typeof this._showHelpAfterError === "string") {
|
|
1496
|
-
this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
1460
|
+
this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
1461
|
+
`);
|
|
1497
1462
|
} else if (this._showHelpAfterError) {
|
|
1498
|
-
this._outputConfiguration.writeErr(
|
|
1463
|
+
this._outputConfiguration.writeErr(`
|
|
1464
|
+
`);
|
|
1499
1465
|
this.outputHelp({ error: true });
|
|
1500
1466
|
}
|
|
1501
1467
|
const config = errorOptions || {};
|
|
@@ -1505,7 +1471,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1505
1471
|
}
|
|
1506
1472
|
_parseOptionsEnv() {
|
|
1507
1473
|
this.options.forEach((option) => {
|
|
1508
|
-
if (option.envVar &&
|
|
1474
|
+
if (option.envVar && option.envVar in process2.env) {
|
|
1509
1475
|
const optionKey = option.attributeName();
|
|
1510
1476
|
if (this.getOptionValue(optionKey) === undefined || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
|
|
1511
1477
|
if (option.required || option.optional) {
|
|
@@ -1614,7 +1580,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1614
1580
|
this._versionOptionName = versionOption.attributeName();
|
|
1615
1581
|
this.options.push(versionOption);
|
|
1616
1582
|
this.on("option:" + versionOption.name(), () => {
|
|
1617
|
-
this._outputConfiguration.writeOut(`${str}
|
|
1583
|
+
this._outputConfiguration.writeOut(`${str}
|
|
1584
|
+
`);
|
|
1618
1585
|
this._exit(0, "commander.version", str);
|
|
1619
1586
|
});
|
|
1620
1587
|
return this;
|
|
@@ -1642,7 +1609,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1642
1609
|
command = this.commands[this.commands.length - 1];
|
|
1643
1610
|
}
|
|
1644
1611
|
if (alias === command._name)
|
|
1645
|
-
throw new Error("Command alias can
|
|
1612
|
+
throw new Error("Command alias can't be the same as its name");
|
|
1646
1613
|
command._aliases.push(alias);
|
|
1647
1614
|
return this;
|
|
1648
1615
|
}
|
|
@@ -1756,16 +1723,60 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1756
1723
|
helpStr = text;
|
|
1757
1724
|
}
|
|
1758
1725
|
if (helpStr) {
|
|
1759
|
-
context.write(`${helpStr}
|
|
1726
|
+
context.write(`${helpStr}
|
|
1727
|
+
`);
|
|
1760
1728
|
}
|
|
1761
1729
|
});
|
|
1762
1730
|
return this;
|
|
1763
1731
|
}
|
|
1764
1732
|
}
|
|
1733
|
+
function outputHelpIfRequested(cmd, args) {
|
|
1734
|
+
const helpOption = cmd._hasHelpOption && args.find((arg) => arg === cmd._helpLongFlag || arg === cmd._helpShortFlag);
|
|
1735
|
+
if (helpOption) {
|
|
1736
|
+
cmd.outputHelp();
|
|
1737
|
+
cmd._exit(0, "commander.helpDisplayed", "(outputHelp)");
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
function incrementNodeInspectorPort(args) {
|
|
1741
|
+
return args.map((arg) => {
|
|
1742
|
+
if (!arg.startsWith("--inspect")) {
|
|
1743
|
+
return arg;
|
|
1744
|
+
}
|
|
1745
|
+
let debugOption;
|
|
1746
|
+
let debugHost = "127.0.0.1";
|
|
1747
|
+
let debugPort = "9229";
|
|
1748
|
+
let match;
|
|
1749
|
+
if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) {
|
|
1750
|
+
debugOption = match[1];
|
|
1751
|
+
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) {
|
|
1752
|
+
debugOption = match[1];
|
|
1753
|
+
if (/^\d+$/.test(match[3])) {
|
|
1754
|
+
debugPort = match[3];
|
|
1755
|
+
} else {
|
|
1756
|
+
debugHost = match[3];
|
|
1757
|
+
}
|
|
1758
|
+
} else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) {
|
|
1759
|
+
debugOption = match[1];
|
|
1760
|
+
debugHost = match[3];
|
|
1761
|
+
debugPort = match[4];
|
|
1762
|
+
}
|
|
1763
|
+
if (debugOption && debugPort !== "0") {
|
|
1764
|
+
return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`;
|
|
1765
|
+
}
|
|
1766
|
+
return arg;
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
function getCommandAndParents(startCommand) {
|
|
1770
|
+
const result = [];
|
|
1771
|
+
for (let command = startCommand;command; command = command.parent) {
|
|
1772
|
+
result.push(command);
|
|
1773
|
+
}
|
|
1774
|
+
return result;
|
|
1775
|
+
}
|
|
1765
1776
|
exports.Command = Command;
|
|
1766
1777
|
});
|
|
1767
1778
|
|
|
1768
|
-
//
|
|
1779
|
+
// node_modules/commander/index.js
|
|
1769
1780
|
var require_commander = __commonJS((exports, module) => {
|
|
1770
1781
|
var { Argument } = require_argument();
|
|
1771
1782
|
var { Command } = require_command();
|
|
@@ -1783,9 +1794,25 @@ var require_commander = __commonJS((exports, module) => {
|
|
|
1783
1794
|
exports.Option = Option;
|
|
1784
1795
|
});
|
|
1785
1796
|
|
|
1786
|
-
//
|
|
1797
|
+
// node_modules/ms/index.js
|
|
1787
1798
|
var require_ms = __commonJS((exports, module) => {
|
|
1788
|
-
var
|
|
1799
|
+
var s = 1000;
|
|
1800
|
+
var m = s * 60;
|
|
1801
|
+
var h = m * 60;
|
|
1802
|
+
var d = h * 24;
|
|
1803
|
+
var w = d * 7;
|
|
1804
|
+
var y = d * 365.25;
|
|
1805
|
+
module.exports = function(val, options) {
|
|
1806
|
+
options = options || {};
|
|
1807
|
+
var type = typeof val;
|
|
1808
|
+
if (type === "string" && val.length > 0) {
|
|
1809
|
+
return parse(val);
|
|
1810
|
+
} else if (type === "number" && isFinite(val)) {
|
|
1811
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
1812
|
+
}
|
|
1813
|
+
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
|
|
1814
|
+
};
|
|
1815
|
+
function parse(str) {
|
|
1789
1816
|
str = String(str);
|
|
1790
1817
|
if (str.length > 100) {
|
|
1791
1818
|
return;
|
|
@@ -1838,8 +1865,8 @@ var require_ms = __commonJS((exports, module) => {
|
|
|
1838
1865
|
default:
|
|
1839
1866
|
return;
|
|
1840
1867
|
}
|
|
1841
|
-
}
|
|
1842
|
-
|
|
1868
|
+
}
|
|
1869
|
+
function fmtShort(ms) {
|
|
1843
1870
|
var msAbs = Math.abs(ms);
|
|
1844
1871
|
if (msAbs >= d) {
|
|
1845
1872
|
return Math.round(ms / d) + "d";
|
|
@@ -1854,8 +1881,8 @@ var require_ms = __commonJS((exports, module) => {
|
|
|
1854
1881
|
return Math.round(ms / s) + "s";
|
|
1855
1882
|
}
|
|
1856
1883
|
return ms + "ms";
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1884
|
+
}
|
|
1885
|
+
function fmtLong(ms) {
|
|
1859
1886
|
var msAbs = Math.abs(ms);
|
|
1860
1887
|
if (msAbs >= d) {
|
|
1861
1888
|
return plural(ms, msAbs, d, "day");
|
|
@@ -1870,32 +1897,16 @@ var require_ms = __commonJS((exports, module) => {
|
|
|
1870
1897
|
return plural(ms, msAbs, s, "second");
|
|
1871
1898
|
}
|
|
1872
1899
|
return ms + " ms";
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1900
|
+
}
|
|
1901
|
+
function plural(ms, msAbs, n, name) {
|
|
1875
1902
|
var isPlural = msAbs >= n * 1.5;
|
|
1876
1903
|
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
1877
|
-
}
|
|
1878
|
-
var s = 1000;
|
|
1879
|
-
var m = s * 60;
|
|
1880
|
-
var h = m * 60;
|
|
1881
|
-
var d = h * 24;
|
|
1882
|
-
var w = d * 7;
|
|
1883
|
-
var y = d * 365.25;
|
|
1884
|
-
module.exports = function(val, options) {
|
|
1885
|
-
options = options || {};
|
|
1886
|
-
var type = typeof val;
|
|
1887
|
-
if (type === "string" && val.length > 0) {
|
|
1888
|
-
return parse(val);
|
|
1889
|
-
} else if (type === "number" && isFinite(val)) {
|
|
1890
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
1891
|
-
}
|
|
1892
|
-
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
|
|
1893
|
-
};
|
|
1904
|
+
}
|
|
1894
1905
|
});
|
|
1895
1906
|
|
|
1896
|
-
//
|
|
1907
|
+
// node_modules/debug/src/common.js
|
|
1897
1908
|
var require_common = __commonJS((exports, module) => {
|
|
1898
|
-
|
|
1909
|
+
function setup(env) {
|
|
1899
1910
|
createDebug.debug = createDebug;
|
|
1900
1911
|
createDebug.default = createDebug;
|
|
1901
1912
|
createDebug.coerce = coerce;
|
|
@@ -2050,68 +2061,12 @@ var require_common = __commonJS((exports, module) => {
|
|
|
2050
2061
|
}
|
|
2051
2062
|
createDebug.enable(createDebug.load());
|
|
2052
2063
|
return createDebug;
|
|
2053
|
-
}
|
|
2064
|
+
}
|
|
2054
2065
|
module.exports = setup;
|
|
2055
2066
|
});
|
|
2056
2067
|
|
|
2057
|
-
//
|
|
2068
|
+
// node_modules/debug/src/browser.js
|
|
2058
2069
|
var require_browser = __commonJS((exports, module) => {
|
|
2059
|
-
var useColors = function() {
|
|
2060
|
-
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
2061
|
-
return true;
|
|
2062
|
-
}
|
|
2063
|
-
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
2064
|
-
return false;
|
|
2065
|
-
}
|
|
2066
|
-
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+)/);
|
|
2067
|
-
};
|
|
2068
|
-
var formatArgs = function(args) {
|
|
2069
|
-
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + exports.humanize(this.diff);
|
|
2070
|
-
if (!this.useColors) {
|
|
2071
|
-
return;
|
|
2072
|
-
}
|
|
2073
|
-
const c = "color: " + this.color;
|
|
2074
|
-
args.splice(1, 0, c, "color: inherit");
|
|
2075
|
-
let index = 0;
|
|
2076
|
-
let lastC = 0;
|
|
2077
|
-
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
2078
|
-
if (match === "%%") {
|
|
2079
|
-
return;
|
|
2080
|
-
}
|
|
2081
|
-
index++;
|
|
2082
|
-
if (match === "%c") {
|
|
2083
|
-
lastC = index;
|
|
2084
|
-
}
|
|
2085
|
-
});
|
|
2086
|
-
args.splice(lastC, 0, c);
|
|
2087
|
-
};
|
|
2088
|
-
var save = function(namespaces) {
|
|
2089
|
-
try {
|
|
2090
|
-
if (namespaces) {
|
|
2091
|
-
exports.storage.setItem("debug", namespaces);
|
|
2092
|
-
} else {
|
|
2093
|
-
exports.storage.removeItem("debug");
|
|
2094
|
-
}
|
|
2095
|
-
} catch (error) {
|
|
2096
|
-
}
|
|
2097
|
-
};
|
|
2098
|
-
var load = function() {
|
|
2099
|
-
let r;
|
|
2100
|
-
try {
|
|
2101
|
-
r = exports.storage.getItem("debug");
|
|
2102
|
-
} catch (error) {
|
|
2103
|
-
}
|
|
2104
|
-
if (!r && typeof process !== "undefined" && ("env" in process)) {
|
|
2105
|
-
r = process.env.DEBUG;
|
|
2106
|
-
}
|
|
2107
|
-
return r;
|
|
2108
|
-
};
|
|
2109
|
-
var localstorage = function() {
|
|
2110
|
-
try {
|
|
2111
|
-
return localStorage;
|
|
2112
|
-
} catch (error) {
|
|
2113
|
-
}
|
|
2114
|
-
};
|
|
2115
2070
|
exports.formatArgs = formatArgs;
|
|
2116
2071
|
exports.save = save;
|
|
2117
2072
|
exports.load = load;
|
|
@@ -2204,75 +2159,85 @@ var require_browser = __commonJS((exports, module) => {
|
|
|
2204
2159
|
"#FFCC00",
|
|
2205
2160
|
"#FFCC33"
|
|
2206
2161
|
];
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
var { formatters } = module.exports;
|
|
2211
|
-
formatters.j = function(v) {
|
|
2212
|
-
try {
|
|
2213
|
-
return JSON.stringify(v);
|
|
2214
|
-
} catch (error) {
|
|
2215
|
-
return "[UnexpectedJSONParseError]: " + error.message;
|
|
2162
|
+
function useColors() {
|
|
2163
|
+
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
2164
|
+
return true;
|
|
2216
2165
|
}
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
// bine_modules/commander/lib/sug
|
|
2221
|
-
var require_node = __commonJS((exports, module) => {
|
|
2222
|
-
var useColors = function() {
|
|
2223
|
-
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
2224
|
-
};
|
|
2225
|
-
var formatArgs = function(args) {
|
|
2226
|
-
const { namespace: name, useColors: useColors2 } = this;
|
|
2227
|
-
if (useColors2) {
|
|
2228
|
-
const c = this.color;
|
|
2229
|
-
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
|
|
2230
|
-
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
|
|
2231
|
-
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
|
|
2232
|
-
args.push(colorCode + "m+" + exports.humanize(this.diff) + "\x1B[0m");
|
|
2233
|
-
} else {
|
|
2234
|
-
args[0] = getDate() + name + " " + args[0];
|
|
2166
|
+
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
2167
|
+
return false;
|
|
2235
2168
|
}
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2169
|
+
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+)/);
|
|
2170
|
+
}
|
|
2171
|
+
function formatArgs(args) {
|
|
2172
|
+
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
2173
|
+
if (!this.useColors) {
|
|
2174
|
+
return;
|
|
2240
2175
|
}
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2176
|
+
const c = "color: " + this.color;
|
|
2177
|
+
args.splice(1, 0, c, "color: inherit");
|
|
2178
|
+
let index = 0;
|
|
2179
|
+
let lastC = 0;
|
|
2180
|
+
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
2181
|
+
if (match === "%%") {
|
|
2182
|
+
return;
|
|
2183
|
+
}
|
|
2184
|
+
index++;
|
|
2185
|
+
if (match === "%c") {
|
|
2186
|
+
lastC = index;
|
|
2187
|
+
}
|
|
2188
|
+
});
|
|
2189
|
+
args.splice(lastC, 0, c);
|
|
2190
|
+
}
|
|
2191
|
+
exports.log = console.debug || console.log || (() => {});
|
|
2192
|
+
function save(namespaces) {
|
|
2193
|
+
try {
|
|
2194
|
+
if (namespaces) {
|
|
2195
|
+
exports.storage.setItem("debug", namespaces);
|
|
2196
|
+
} else {
|
|
2197
|
+
exports.storage.removeItem("debug");
|
|
2198
|
+
}
|
|
2199
|
+
} catch (error) {}
|
|
2200
|
+
}
|
|
2201
|
+
function load() {
|
|
2202
|
+
let r;
|
|
2203
|
+
try {
|
|
2204
|
+
r = exports.storage.getItem("debug");
|
|
2205
|
+
} catch (error) {}
|
|
2206
|
+
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
2207
|
+
r = process.env.DEBUG;
|
|
2251
2208
|
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2209
|
+
return r;
|
|
2210
|
+
}
|
|
2211
|
+
function localstorage() {
|
|
2212
|
+
try {
|
|
2213
|
+
return localStorage;
|
|
2214
|
+
} catch (error) {}
|
|
2215
|
+
}
|
|
2216
|
+
module.exports = require_common()(exports);
|
|
2217
|
+
var { formatters } = module.exports;
|
|
2218
|
+
formatters.j = function(v) {
|
|
2219
|
+
try {
|
|
2220
|
+
return JSON.stringify(v);
|
|
2221
|
+
} catch (error) {
|
|
2222
|
+
return "[UnexpectedJSONParseError]: " + error.message;
|
|
2261
2223
|
}
|
|
2262
2224
|
};
|
|
2263
|
-
|
|
2264
|
-
|
|
2225
|
+
});
|
|
2226
|
+
|
|
2227
|
+
// node_modules/debug/src/node.js
|
|
2228
|
+
var require_node = __commonJS((exports, module) => {
|
|
2229
|
+
var tty = __require("tty");
|
|
2230
|
+
var util = __require("util");
|
|
2265
2231
|
exports.init = init;
|
|
2266
2232
|
exports.log = log;
|
|
2267
2233
|
exports.formatArgs = formatArgs;
|
|
2268
2234
|
exports.save = save;
|
|
2269
2235
|
exports.load = load;
|
|
2270
2236
|
exports.useColors = useColors;
|
|
2271
|
-
exports.destroy = util.deprecate(() => {
|
|
2272
|
-
}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
2237
|
+
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`.");
|
|
2273
2238
|
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
2274
2239
|
try {
|
|
2275
|
-
const supportsColor = (()=>{
|
|
2240
|
+
const supportsColor = (()=>{throw new Error("Cannot require module "+"supports-color");})();
|
|
2276
2241
|
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
2277
2242
|
exports.colors = [
|
|
2278
2243
|
20,
|
|
@@ -2353,8 +2318,7 @@ var require_node = __commonJS((exports, module) => {
|
|
|
2353
2318
|
221
|
|
2354
2319
|
];
|
|
2355
2320
|
}
|
|
2356
|
-
} catch (error) {
|
|
2357
|
-
}
|
|
2321
|
+
} catch (error) {}
|
|
2358
2322
|
exports.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
2359
2323
|
return /^debug_/i.test(key);
|
|
2360
2324
|
}).reduce((obj, key) => {
|
|
@@ -2374,11 +2338,56 @@ var require_node = __commonJS((exports, module) => {
|
|
|
2374
2338
|
obj[prop] = val;
|
|
2375
2339
|
return obj;
|
|
2376
2340
|
}, {});
|
|
2341
|
+
function useColors() {
|
|
2342
|
+
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
2343
|
+
}
|
|
2344
|
+
function formatArgs(args) {
|
|
2345
|
+
const { namespace: name, useColors: useColors2 } = this;
|
|
2346
|
+
if (useColors2) {
|
|
2347
|
+
const c = this.color;
|
|
2348
|
+
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
|
|
2349
|
+
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
|
|
2350
|
+
args[0] = prefix + args[0].split(`
|
|
2351
|
+
`).join(`
|
|
2352
|
+
` + prefix);
|
|
2353
|
+
args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
|
|
2354
|
+
} else {
|
|
2355
|
+
args[0] = getDate() + name + " " + args[0];
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
function getDate() {
|
|
2359
|
+
if (exports.inspectOpts.hideDate) {
|
|
2360
|
+
return "";
|
|
2361
|
+
}
|
|
2362
|
+
return new Date().toISOString() + " ";
|
|
2363
|
+
}
|
|
2364
|
+
function log(...args) {
|
|
2365
|
+
return process.stderr.write(util.format(...args) + `
|
|
2366
|
+
`);
|
|
2367
|
+
}
|
|
2368
|
+
function save(namespaces) {
|
|
2369
|
+
if (namespaces) {
|
|
2370
|
+
process.env.DEBUG = namespaces;
|
|
2371
|
+
} else {
|
|
2372
|
+
delete process.env.DEBUG;
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
function load() {
|
|
2376
|
+
return process.env.DEBUG;
|
|
2377
|
+
}
|
|
2378
|
+
function init(debug) {
|
|
2379
|
+
debug.inspectOpts = {};
|
|
2380
|
+
const keys = Object.keys(exports.inspectOpts);
|
|
2381
|
+
for (let i = 0;i < keys.length; i++) {
|
|
2382
|
+
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2377
2385
|
module.exports = require_common()(exports);
|
|
2378
2386
|
var { formatters } = module.exports;
|
|
2379
2387
|
formatters.o = function(v) {
|
|
2380
2388
|
this.inspectOpts.colors = this.useColors;
|
|
2381
|
-
return util.inspect(v, this.inspectOpts).split(
|
|
2389
|
+
return util.inspect(v, this.inspectOpts).split(`
|
|
2390
|
+
`).map((str) => str.trim()).join(" ");
|
|
2382
2391
|
};
|
|
2383
2392
|
formatters.O = function(v) {
|
|
2384
2393
|
this.inspectOpts.colors = this.useColors;
|
|
@@ -2386,7 +2395,7 @@ var require_node = __commonJS((exports, module) => {
|
|
|
2386
2395
|
};
|
|
2387
2396
|
});
|
|
2388
2397
|
|
|
2389
|
-
//
|
|
2398
|
+
// node_modules/debug/src/index.js
|
|
2390
2399
|
var require_src = __commonJS((exports, module) => {
|
|
2391
2400
|
if (typeof process === "undefined" || process.type === "renderer" || false || process.__nwjs) {
|
|
2392
2401
|
module.exports = require_browser();
|
|
@@ -2395,8 +2404,8 @@ var require_src = __commonJS((exports, module) => {
|
|
|
2395
2404
|
}
|
|
2396
2405
|
});
|
|
2397
2406
|
|
|
2398
|
-
//
|
|
2399
|
-
var
|
|
2407
|
+
// node_modules/commander/esm.mjs
|
|
2408
|
+
var import__ = __toESM(require_commander(), 1);
|
|
2400
2409
|
var {
|
|
2401
2410
|
program,
|
|
2402
2411
|
createCommand,
|
|
@@ -2409,9 +2418,9 @@ var {
|
|
|
2409
2418
|
Argument,
|
|
2410
2419
|
Option,
|
|
2411
2420
|
Help
|
|
2412
|
-
} =
|
|
2421
|
+
} = import__.default;
|
|
2413
2422
|
|
|
2414
|
-
//
|
|
2423
|
+
// lib/package.ts
|
|
2415
2424
|
import path from "path";
|
|
2416
2425
|
import fs from "fs";
|
|
2417
2426
|
function findPackageJson() {
|
|
@@ -2434,13 +2443,16 @@ async function getPackageJson() {
|
|
|
2434
2443
|
const packageJsonText = fs.readFileSync(packagePath, "utf8");
|
|
2435
2444
|
return JSON.parse(packageJsonText);
|
|
2436
2445
|
}
|
|
2446
|
+
var packageJsonPromise = getPackageJson();
|
|
2437
2447
|
async function getPackageVersion() {
|
|
2438
2448
|
const packageJson = await packageJsonPromise;
|
|
2439
2449
|
return packageJson.version;
|
|
2440
2450
|
}
|
|
2441
|
-
var packageJsonPromise = getPackageJson();
|
|
2442
2451
|
|
|
2443
|
-
//
|
|
2452
|
+
// lib/spawn.ts
|
|
2453
|
+
var defaultOptions = {
|
|
2454
|
+
expectQuiet: false
|
|
2455
|
+
};
|
|
2444
2456
|
async function spawn(args, options = defaultOptions) {
|
|
2445
2457
|
const proc = Bun.spawn(args, { stdout: "pipe", stderr: "pipe" });
|
|
2446
2458
|
const stdout = new Response(proc.stdout);
|
|
@@ -2461,11 +2473,8 @@ async function doCommand(args, options = defaultOptions) {
|
|
|
2461
2473
|
console.error(err);
|
|
2462
2474
|
return out;
|
|
2463
2475
|
}
|
|
2464
|
-
var defaultOptions = {
|
|
2465
|
-
expectQuiet: false
|
|
2466
|
-
};
|
|
2467
2476
|
|
|
2468
|
-
//
|
|
2477
|
+
// lib/git.ts
|
|
2469
2478
|
async function getConfig(key, options = defaultOptions) {
|
|
2470
2479
|
return doCommand(["git", "config", "--get", key], options);
|
|
2471
2480
|
}
|
|
@@ -2479,7 +2488,11 @@ async function getRemote() {
|
|
|
2479
2488
|
return doCommand(["git", "ls-remote", "--get-url", "origin"]);
|
|
2480
2489
|
}
|
|
2481
2490
|
|
|
2482
|
-
//
|
|
2491
|
+
// lib/gitlab/config.ts
|
|
2492
|
+
var gitEmailP = getConfig("user.email");
|
|
2493
|
+
var gitlabEmailP = getConfig("gitlab.user", { expectQuiet: true });
|
|
2494
|
+
var hostP = getConfig("gitlab.host");
|
|
2495
|
+
var tokenP = getConfig("gitlab.token");
|
|
2483
2496
|
async function getGitlabConfig() {
|
|
2484
2497
|
const host = await hostP || "gitlab.com";
|
|
2485
2498
|
const user = await gitEmailP || await gitlabEmailP;
|
|
@@ -2490,13 +2503,9 @@ async function getGitlabConfig() {
|
|
|
2490
2503
|
throw new Error("gitlab.token not in git config");
|
|
2491
2504
|
return { host, user, token };
|
|
2492
2505
|
}
|
|
2493
|
-
var gitEmailP = getConfig("user.email");
|
|
2494
|
-
var gitlabEmailP = getConfig("gitlab.user", { expectQuiet: true });
|
|
2495
|
-
var hostP = getConfig("gitlab.host");
|
|
2496
|
-
var tokenP = getConfig("gitlab.token");
|
|
2497
2506
|
|
|
2498
|
-
//
|
|
2499
|
-
|
|
2507
|
+
// lib/gitlab/api.ts
|
|
2508
|
+
function getNextLink(link) {
|
|
2500
2509
|
if (!link) {
|
|
2501
2510
|
return;
|
|
2502
2511
|
}
|
|
@@ -2504,7 +2513,7 @@ var getNextLink = function(link) {
|
|
|
2504
2513
|
const match = link.match(regex);
|
|
2505
2514
|
const next = match ? match[1] : undefined;
|
|
2506
2515
|
return next;
|
|
2507
|
-
}
|
|
2516
|
+
}
|
|
2508
2517
|
async function gitlabApi(endpoint) {
|
|
2509
2518
|
if (endpoint.startsWith("/")) {
|
|
2510
2519
|
console.warn(`gitlabApi: endpoint ${endpoint} starts with /, removing it`);
|
|
@@ -2537,18 +2546,16 @@ async function gitlabApi(endpoint) {
|
|
|
2537
2546
|
}
|
|
2538
2547
|
return result;
|
|
2539
2548
|
}
|
|
2540
|
-
//
|
|
2549
|
+
// lib/gitlab/group.ts
|
|
2541
2550
|
async function getGroups() {
|
|
2542
2551
|
return await gitlabApi(`groups`);
|
|
2543
2552
|
}
|
|
2544
|
-
//
|
|
2545
|
-
import path2 from "path";
|
|
2546
|
-
|
|
2547
|
-
// bine_modules/comma
|
|
2553
|
+
// lib/gitlab/dlog.ts
|
|
2548
2554
|
var import_debug = __toESM(require_src(), 1);
|
|
2549
2555
|
var dlog = import_debug.default("gitlab");
|
|
2550
2556
|
|
|
2551
|
-
//
|
|
2557
|
+
// lib/gitlab/project.ts
|
|
2558
|
+
import path2 from "path";
|
|
2552
2559
|
async function getProjects(match) {
|
|
2553
2560
|
let search = "";
|
|
2554
2561
|
if (match) {
|
|
@@ -2580,7 +2587,7 @@ async function findProject(ssh_url) {
|
|
|
2580
2587
|
});
|
|
2581
2588
|
return project;
|
|
2582
2589
|
}
|
|
2583
|
-
async function
|
|
2590
|
+
async function projectScopedRequest(endpoint) {
|
|
2584
2591
|
if (endpoint.startsWith("/")) {
|
|
2585
2592
|
console.warn(`gitlabApi: endpoint ${endpoint} starts with /, removing it`);
|
|
2586
2593
|
endpoint = endpoint.slice(1);
|
|
@@ -2593,26 +2600,46 @@ async function projectScopedGet(endpoint) {
|
|
|
2593
2600
|
throw new Error(`Could not find project for remote ${remote}`);
|
|
2594
2601
|
}
|
|
2595
2602
|
const base = `https://${host}/api/v4/projects/${project.id}`;
|
|
2596
|
-
const
|
|
2597
|
-
|
|
2603
|
+
const sep = endpoint.includes("?") ? "&" : "?";
|
|
2604
|
+
const uri = `${base}/${endpoint}${sep}per_page=100`;
|
|
2605
|
+
dlog(`projectScopedRequest uri: ${uri}`);
|
|
2598
2606
|
const headers = new Headers;
|
|
2599
|
-
headers.append("Accept", "application/json");
|
|
2600
2607
|
headers.append("Private-Token", token);
|
|
2601
2608
|
const options = {
|
|
2602
2609
|
method,
|
|
2603
2610
|
headers
|
|
2604
2611
|
};
|
|
2605
2612
|
const request = new Request(uri, options);
|
|
2606
|
-
|
|
2613
|
+
return await fetch(request);
|
|
2614
|
+
}
|
|
2615
|
+
async function projectScopedGet(endpoint) {
|
|
2616
|
+
const response = await projectScopedRequest(endpoint);
|
|
2607
2617
|
return await response.json();
|
|
2608
2618
|
}
|
|
2619
|
+
async function projectScopedGetText(endpoint) {
|
|
2620
|
+
const response = await projectScopedRequest(endpoint);
|
|
2621
|
+
return await response.text();
|
|
2622
|
+
}
|
|
2609
2623
|
|
|
2610
|
-
//
|
|
2624
|
+
// lib/gitlab/job.ts
|
|
2625
|
+
async function getPipelineJobs(pipelineId) {
|
|
2626
|
+
dlog(`getPipelineJobs pipelineId: ${pipelineId}`);
|
|
2627
|
+
return await projectScopedGet(`pipelines/${pipelineId}/jobs`);
|
|
2628
|
+
}
|
|
2629
|
+
async function getJob(jobId) {
|
|
2630
|
+
dlog(`getJob jobId: ${jobId}`);
|
|
2631
|
+
return await projectScopedGet(`jobs/${jobId}`);
|
|
2632
|
+
}
|
|
2633
|
+
async function getJobLog(jobId) {
|
|
2634
|
+
dlog(`getJobLog jobId: ${jobId}`);
|
|
2635
|
+
return await projectScopedGetText(`jobs/${jobId}/trace`);
|
|
2636
|
+
}
|
|
2637
|
+
// lib/gitlab/user.ts
|
|
2611
2638
|
async function whoami() {
|
|
2612
2639
|
return await gitlabApi("user");
|
|
2613
2640
|
}
|
|
2614
2641
|
|
|
2615
|
-
//
|
|
2642
|
+
// lib/gitlab/merge-request.ts
|
|
2616
2643
|
async function getMergeRequest(id) {
|
|
2617
2644
|
return await projectScopedGet(`merge_requests/${id}`);
|
|
2618
2645
|
}
|
|
@@ -2624,11 +2651,16 @@ async function getMyMergeRequestsToReview() {
|
|
|
2624
2651
|
const me = await whoami();
|
|
2625
2652
|
return await gitlabApi(`merge_requests?state=opened&reviewer_id=${me.id}`);
|
|
2626
2653
|
}
|
|
2627
|
-
|
|
2654
|
+
async function getMergeRequestsByBranch(projectPath, sourceBranch) {
|
|
2655
|
+
const project = encodeURIComponent(projectPath);
|
|
2656
|
+
const branch = encodeURIComponent(sourceBranch);
|
|
2657
|
+
return await gitlabApi(`projects/${project}/merge_requests?state=opened&source_branch=${branch}`);
|
|
2658
|
+
}
|
|
2659
|
+
// lib/gitlab/namespace.ts
|
|
2628
2660
|
async function getNamespaces() {
|
|
2629
2661
|
return await gitlabApi(`namespaces`);
|
|
2630
2662
|
}
|
|
2631
|
-
//
|
|
2663
|
+
// lib/gitlab/pipeline.ts
|
|
2632
2664
|
async function getProjectPipelines(options) {
|
|
2633
2665
|
const { days, status } = options;
|
|
2634
2666
|
const me = await whoami();
|
|
@@ -2640,13 +2672,23 @@ async function getProjectPipelines(options) {
|
|
|
2640
2672
|
dlog(`updated: ${updated}`);
|
|
2641
2673
|
return await projectScopedGet(`pipelines?status=${status}&username=${username}&updated_after=${updated}`);
|
|
2642
2674
|
}
|
|
2643
|
-
|
|
2675
|
+
async function getMergeRequestPipelines(projectPath, mrIid) {
|
|
2676
|
+
const project = encodeURIComponent(projectPath);
|
|
2677
|
+
return await gitlabApi(`projects/${project}/merge_requests/${mrIid}/pipelines`);
|
|
2678
|
+
}
|
|
2679
|
+
async function getLatestPipeline() {
|
|
2680
|
+
const ref = await getCurrentBranch();
|
|
2681
|
+
dlog(`getLatestPipeline ref: ${ref}`);
|
|
2682
|
+
const pipelines = await projectScopedGet(`pipelines?ref=${encodeURIComponent(ref)}&per_page=1&order_by=id&sort=desc`);
|
|
2683
|
+
return pipelines.length > 0 ? pipelines[0] : undefined;
|
|
2684
|
+
}
|
|
2685
|
+
// lib/is_main.ts
|
|
2644
2686
|
import path3 from "path";
|
|
2645
|
-
|
|
2687
|
+
function justBase(filename) {
|
|
2646
2688
|
const ext = path3.extname(filename);
|
|
2647
2689
|
const base = path3.basename(filename, ext);
|
|
2648
2690
|
return base;
|
|
2649
|
-
}
|
|
2691
|
+
}
|
|
2650
2692
|
function isMain(self) {
|
|
2651
2693
|
const arg1 = Bun.argv[1];
|
|
2652
2694
|
const argv1Base = justBase(arg1);
|
|
@@ -2655,7 +2697,8 @@ function isMain(self) {
|
|
|
2655
2697
|
return result;
|
|
2656
2698
|
}
|
|
2657
2699
|
|
|
2658
|
-
//
|
|
2700
|
+
// bin/git-lab-merge-active.ts
|
|
2701
|
+
var version = await getPackageVersion();
|
|
2659
2702
|
function create() {
|
|
2660
2703
|
const program2 = new Command;
|
|
2661
2704
|
program2.version(version).name("active").description("List my MRs in progress").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
@@ -2677,13 +2720,13 @@ function create() {
|
|
|
2677
2720
|
});
|
|
2678
2721
|
return program2;
|
|
2679
2722
|
}
|
|
2680
|
-
var version = await getPackageVersion();
|
|
2681
2723
|
var git_lab_merge_active_default = create;
|
|
2682
2724
|
if (isMain("git-lab-merge-active")) {
|
|
2683
2725
|
await create().parseAsync(Bun.argv);
|
|
2684
2726
|
}
|
|
2685
2727
|
|
|
2686
|
-
//
|
|
2728
|
+
// bin/git-lab-merge-todo.ts
|
|
2729
|
+
var version2 = await getPackageVersion();
|
|
2687
2730
|
function create2() {
|
|
2688
2731
|
const program2 = new Command;
|
|
2689
2732
|
program2.version(version2).name("todo").description("MRs needing my review").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
@@ -2700,18 +2743,18 @@ function create2() {
|
|
|
2700
2743
|
});
|
|
2701
2744
|
return program2;
|
|
2702
2745
|
}
|
|
2703
|
-
var version2 = await getPackageVersion();
|
|
2704
2746
|
var git_lab_merge_todo_default = create2;
|
|
2705
2747
|
if (isMain("git-lab-merge-todo")) {
|
|
2706
2748
|
await create2().parseAsync(Bun.argv);
|
|
2707
2749
|
}
|
|
2708
2750
|
|
|
2709
|
-
//
|
|
2751
|
+
// lib/gitlab/merge-trains.ts
|
|
2710
2752
|
async function getMergeTrains() {
|
|
2711
2753
|
return await projectScopedGet(`merge_trains`);
|
|
2712
2754
|
}
|
|
2713
2755
|
|
|
2714
|
-
//
|
|
2756
|
+
// bin/git-lab-merge-train-list.ts
|
|
2757
|
+
var version3 = await getPackageVersion();
|
|
2715
2758
|
function create3() {
|
|
2716
2759
|
const program2 = new Command;
|
|
2717
2760
|
program2.version(version3).name("list").description("List merge trains for the current project").action(async () => {
|
|
@@ -2720,37 +2763,37 @@ function create3() {
|
|
|
2720
2763
|
});
|
|
2721
2764
|
return program2;
|
|
2722
2765
|
}
|
|
2723
|
-
var version3 = await getPackageVersion();
|
|
2724
2766
|
var git_lab_merge_train_list_default = create3;
|
|
2725
2767
|
if (isMain("git-lab-merge-train-list")) {
|
|
2726
2768
|
await create3().parseAsync(Bun.argv);
|
|
2727
2769
|
}
|
|
2728
2770
|
|
|
2729
|
-
//
|
|
2771
|
+
// bin/git-lab-merge-train.ts
|
|
2772
|
+
var version4 = await getPackageVersion();
|
|
2730
2773
|
function create4() {
|
|
2731
2774
|
const program2 = new Command;
|
|
2732
2775
|
program2.version(version4).name("train").description("Commands for working with GitLab merge trains.").addCommand(git_lab_merge_train_list_default()).action(() => program2.help());
|
|
2733
2776
|
return program2;
|
|
2734
2777
|
}
|
|
2735
|
-
var version4 = await getPackageVersion();
|
|
2736
2778
|
var git_lab_merge_train_default = create4;
|
|
2737
2779
|
if (isMain("git-lab-merge-train")) {
|
|
2738
2780
|
await create4().parseAsync(Bun.argv);
|
|
2739
2781
|
}
|
|
2740
2782
|
|
|
2741
|
-
//
|
|
2783
|
+
// bin/git-lab-merge.ts
|
|
2784
|
+
var version5 = await getPackageVersion();
|
|
2742
2785
|
function create5() {
|
|
2743
2786
|
const program2 = new Command;
|
|
2744
2787
|
program2.version(version5).name("merge").description("Commands for working with GitLab merge requests").addCommand(git_lab_merge_active_default()).addCommand(git_lab_merge_todo_default()).addCommand(git_lab_merge_train_default()).action(() => program2.help());
|
|
2745
2788
|
return program2;
|
|
2746
2789
|
}
|
|
2747
|
-
var version5 = await getPackageVersion();
|
|
2748
2790
|
var git_lab_merge_default = create5;
|
|
2749
2791
|
if (isMain("git-lab-merge")) {
|
|
2750
2792
|
await create5().parseAsync(Bun.argv);
|
|
2751
2793
|
}
|
|
2752
2794
|
|
|
2753
|
-
//
|
|
2795
|
+
// bin/git-lab-namespace-list.ts
|
|
2796
|
+
var version6 = await getPackageVersion();
|
|
2754
2797
|
function create6() {
|
|
2755
2798
|
const program2 = new Command;
|
|
2756
2799
|
program2.version(version6).name("list").description("List namespaces for the current user").action(async () => {
|
|
@@ -2759,25 +2802,25 @@ function create6() {
|
|
|
2759
2802
|
});
|
|
2760
2803
|
return program2;
|
|
2761
2804
|
}
|
|
2762
|
-
var version6 = await getPackageVersion();
|
|
2763
2805
|
var git_lab_namespace_list_default = create6;
|
|
2764
2806
|
if (isMain("git-lab-namespace-list")) {
|
|
2765
2807
|
await create6().parseAsync(Bun.argv);
|
|
2766
2808
|
}
|
|
2767
2809
|
|
|
2768
|
-
//
|
|
2810
|
+
// bin/git-lab-namespace.ts
|
|
2811
|
+
var version7 = await getPackageVersion();
|
|
2769
2812
|
function create7() {
|
|
2770
2813
|
const program2 = new Command;
|
|
2771
2814
|
program2.version(version7).name("namespace").description("Commands for working with GitLab namespaces").addCommand(git_lab_namespace_list_default()).action(() => program2.help());
|
|
2772
2815
|
return program2;
|
|
2773
2816
|
}
|
|
2774
|
-
var version7 = await getPackageVersion();
|
|
2775
2817
|
var git_lab_namespace_default = create7;
|
|
2776
2818
|
if (isMain("git-lab-namespace")) {
|
|
2777
2819
|
await create7().parseAsync(Bun.argv);
|
|
2778
2820
|
}
|
|
2779
2821
|
|
|
2780
|
-
//
|
|
2822
|
+
// bin/git-lab-project-list.ts
|
|
2823
|
+
var version8 = await getPackageVersion();
|
|
2781
2824
|
function create8() {
|
|
2782
2825
|
const program2 = new Command;
|
|
2783
2826
|
program2.version(version8).name("list").description("List projects for current user").option("-v, --verbose", "Verbose output").option("-m, --match <match>", "Match projects with paths containing <match>").action(async (options) => {
|
|
@@ -2798,202 +2841,718 @@ function create8() {
|
|
|
2798
2841
|
});
|
|
2799
2842
|
return program2;
|
|
2800
2843
|
}
|
|
2801
|
-
var version8 = await getPackageVersion();
|
|
2802
2844
|
var git_lab_project_list_default = create8;
|
|
2803
2845
|
if (isMain("git-lab-project-list")) {
|
|
2804
2846
|
await create8().parseAsync(Bun.argv);
|
|
2805
2847
|
}
|
|
2806
2848
|
|
|
2807
|
-
//
|
|
2849
|
+
// bin/git-lab-project-mr-list.ts
|
|
2850
|
+
var version9 = await getPackageVersion();
|
|
2808
2851
|
function create9() {
|
|
2809
2852
|
const program2 = new Command;
|
|
2810
|
-
program2.version(version9).name("
|
|
2811
|
-
|
|
2812
|
-
if (!
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2853
|
+
program2.version(version9).name("list").description("List open merge requests for a project and branch").option("-v, --verbose", "Verbose output").option("-p, --project <path>", "Project path (e.g. etagen-internal/eta-lib/base). Defaults to current directory remote.").option("-b, --branch <branch>", "Source branch to filter on. Defaults to current branch.").action(async (options) => {
|
|
2854
|
+
let projectPath = options.project;
|
|
2855
|
+
if (!projectPath) {
|
|
2856
|
+
const remote = await getRemote();
|
|
2857
|
+
const project2 = await findProject(remote);
|
|
2858
|
+
if (!project2) {
|
|
2859
|
+
console.error(`Could not resolve project from remote: ${remote}`);
|
|
2860
|
+
process.exit(1);
|
|
2861
|
+
}
|
|
2862
|
+
projectPath = project2.path_with_namespace;
|
|
2863
|
+
}
|
|
2864
|
+
const branch = options.branch || await getCurrentBranch();
|
|
2865
|
+
const mrs = await getMergeRequestsByBranch(projectPath, branch);
|
|
2866
|
+
if (!mrs.length) {
|
|
2867
|
+
console.error(`No open MRs for branch '${branch}' in ${projectPath}`);
|
|
2868
|
+
process.exit(0);
|
|
2821
2869
|
}
|
|
2822
2870
|
if (options.verbose) {
|
|
2823
|
-
console.log(
|
|
2871
|
+
console.log(mrs);
|
|
2824
2872
|
} else {
|
|
2825
|
-
const
|
|
2826
|
-
|
|
2873
|
+
const filtered = mrs.map((m) => {
|
|
2874
|
+
const { iid, title, web_url, source_branch, target_branch, state, draft } = m;
|
|
2875
|
+
return { iid, title, web_url, source_branch, target_branch, state, draft };
|
|
2876
|
+
});
|
|
2877
|
+
console.log(filtered);
|
|
2827
2878
|
}
|
|
2828
2879
|
});
|
|
2829
2880
|
return program2;
|
|
2830
2881
|
}
|
|
2831
|
-
var
|
|
2832
|
-
|
|
2833
|
-
if (isMain("git-lab-project-whereami")) {
|
|
2882
|
+
var git_lab_project_mr_list_default = create9;
|
|
2883
|
+
if (isMain("git-lab-project-mr-list")) {
|
|
2834
2884
|
await create9().parseAsync(Bun.argv);
|
|
2835
2885
|
}
|
|
2836
2886
|
|
|
2837
|
-
//
|
|
2887
|
+
// bin/git-lab-project-mr.ts
|
|
2888
|
+
var version10 = await getPackageVersion();
|
|
2838
2889
|
function create10() {
|
|
2839
2890
|
const program2 = new Command;
|
|
2840
|
-
program2.version(version10).name("
|
|
2841
|
-
program2.help();
|
|
2842
|
-
});
|
|
2891
|
+
program2.version(version10).name("mr").description("Commands for working with merge requests").addCommand(git_lab_project_mr_list_default()).action(() => program2.help());
|
|
2843
2892
|
return program2;
|
|
2844
2893
|
}
|
|
2845
|
-
var
|
|
2846
|
-
|
|
2847
|
-
if (isMain("git-lab-project")) {
|
|
2894
|
+
var git_lab_project_mr_default = create10;
|
|
2895
|
+
if (isMain("git-lab-project-mr")) {
|
|
2848
2896
|
await create10().parseAsync(Bun.argv);
|
|
2849
2897
|
}
|
|
2850
2898
|
|
|
2851
|
-
//
|
|
2899
|
+
// bin/git-lab-project-pipeline-jobs.ts
|
|
2900
|
+
var version11 = await getPackageVersion();
|
|
2852
2901
|
function create11() {
|
|
2853
2902
|
const program2 = new Command;
|
|
2854
|
-
program2.version(version11).name("
|
|
2855
|
-
const
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2903
|
+
program2.version(version11).name("jobs").description("List jobs for a pipeline").requiredOption("-p, --pipeline <id>", "Pipeline ID").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
2904
|
+
const pipelineId = parseInt(options.pipeline, 10);
|
|
2905
|
+
if (isNaN(pipelineId)) {
|
|
2906
|
+
console.error(`Invalid pipeline ID: ${options.pipeline}`);
|
|
2907
|
+
process.exit(1);
|
|
2908
|
+
}
|
|
2909
|
+
const jobs = await getPipelineJobs(pipelineId);
|
|
2910
|
+
if (!jobs || jobs.length === 0) {
|
|
2911
|
+
console.error(`No jobs found for pipeline ${pipelineId}`);
|
|
2912
|
+
process.exit(1);
|
|
2913
|
+
}
|
|
2914
|
+
if (options.verbose) {
|
|
2915
|
+
console.log(JSON.stringify(jobs, null, 2));
|
|
2916
|
+
} else {
|
|
2917
|
+
const filtered = jobs.map((j) => {
|
|
2918
|
+
const { id, name, stage, status, duration, failure_reason } = j;
|
|
2919
|
+
return { id, name, stage, status, duration, failure_reason };
|
|
2920
|
+
});
|
|
2921
|
+
console.log(JSON.stringify(filtered, null, 2));
|
|
2862
2922
|
}
|
|
2863
|
-
const nextBranch = `${stem}.v${version11}`;
|
|
2864
|
-
await createBranch(nextBranch);
|
|
2865
2923
|
});
|
|
2866
2924
|
return program2;
|
|
2867
2925
|
}
|
|
2868
|
-
var
|
|
2869
|
-
|
|
2870
|
-
if (isMain("git-bump")) {
|
|
2926
|
+
var git_lab_project_pipeline_jobs_default = create11;
|
|
2927
|
+
if (isMain("git-lab-project-pipeline-jobs")) {
|
|
2871
2928
|
await create11().parseAsync(Bun.argv);
|
|
2872
2929
|
}
|
|
2873
2930
|
|
|
2874
|
-
//
|
|
2875
|
-
|
|
2876
|
-
const host = await hostP2;
|
|
2877
|
-
if (!host)
|
|
2878
|
-
throw new Error("jira.host not in git config");
|
|
2879
|
-
const user4 = await jiraEmailP || await gitEmailP2;
|
|
2880
|
-
if (!user4)
|
|
2881
|
-
throw new Error("jira.user or user.email not in git config");
|
|
2882
|
-
const pat = await tokenP2;
|
|
2883
|
-
if (!pat)
|
|
2884
|
-
throw new Error("jira.token not in git config");
|
|
2885
|
-
const token = Buffer.from(`${user4}:${pat}`).toString("base64");
|
|
2886
|
-
return { host, token };
|
|
2887
|
-
}
|
|
2888
|
-
async function jiraApi(endpoint) {
|
|
2889
|
-
if (endpoint.startsWith("/")) {
|
|
2890
|
-
console.warn(`jiraApi: endpoint ${endpoint} starts with /`);
|
|
2891
|
-
endpoint = endpoint.slice(1);
|
|
2892
|
-
}
|
|
2893
|
-
const method = "GET";
|
|
2894
|
-
const { host, token } = await getJiraConfig();
|
|
2895
|
-
const uri = `https://${host}/rest/api/3/${endpoint}`;
|
|
2896
|
-
const auth = `Basic ${token}`;
|
|
2897
|
-
const headers = new Headers;
|
|
2898
|
-
headers.append("Authorization", auth);
|
|
2899
|
-
headers.append("Accept", "application/json");
|
|
2900
|
-
const options = {
|
|
2901
|
-
method,
|
|
2902
|
-
headers
|
|
2903
|
-
};
|
|
2904
|
-
const request = new Request(uri, options);
|
|
2905
|
-
const response = await fetch(request);
|
|
2906
|
-
const result = await response.json();
|
|
2907
|
-
return result;
|
|
2908
|
-
}
|
|
2909
|
-
async function getIssue(issue) {
|
|
2910
|
-
const result = await jiraApi(`issue/${issue}`);
|
|
2911
|
-
return result;
|
|
2912
|
-
}
|
|
2913
|
-
async function getMyself() {
|
|
2914
|
-
return await jiraApi("/myself");
|
|
2915
|
-
}
|
|
2916
|
-
async function myUnresolvedIssues() {
|
|
2917
|
-
const myself = await getMyself();
|
|
2918
|
-
const myselfId = myself.accountId;
|
|
2919
|
-
const jql = `assignee = ${myselfId} AND resolution = Unresolved`;
|
|
2920
|
-
const issues = await jiraApi(`/search?jql=${encodeURIComponent(jql)}`);
|
|
2921
|
-
return issues.issues;
|
|
2922
|
-
}
|
|
2923
|
-
var gitEmailP2 = getConfig("user.email");
|
|
2924
|
-
var jiraEmailP = getConfig("jira.user");
|
|
2925
|
-
var hostP2 = getConfig("jira.host");
|
|
2926
|
-
var tokenP2 = getConfig("jira.token");
|
|
2927
|
-
|
|
2928
|
-
// bine_modules/commande
|
|
2929
|
-
var toKebab = function(s) {
|
|
2930
|
-
return s.replace(/([a-z]+)([A-Z]+)/g, "$1_2").toLowerCase().replace(/(\W+)/g, "-").replace(/-$/, "");
|
|
2931
|
-
};
|
|
2931
|
+
// bin/git-lab-project-pipeline-latest.ts
|
|
2932
|
+
var version12 = await getPackageVersion();
|
|
2932
2933
|
function create12() {
|
|
2933
2934
|
const program2 = new Command;
|
|
2934
|
-
program2.version(version12).name("
|
|
2935
|
-
const
|
|
2936
|
-
if (!
|
|
2937
|
-
console.error(
|
|
2935
|
+
program2.version(version12).name("latest").description("Show jobs for the latest pipeline on the current branch").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
2936
|
+
const pipeline2 = await getLatestPipeline();
|
|
2937
|
+
if (!pipeline2) {
|
|
2938
|
+
console.error("No pipeline found for the current branch");
|
|
2938
2939
|
process.exit(1);
|
|
2939
2940
|
}
|
|
2940
|
-
const
|
|
2941
|
-
|
|
2942
|
-
await
|
|
2941
|
+
const { id, status, ref, web_url } = pipeline2;
|
|
2942
|
+
console.log(JSON.stringify({ id, status, ref, web_url }, null, 2));
|
|
2943
|
+
const jobs = await getPipelineJobs(pipeline2.id);
|
|
2944
|
+
if (!jobs || jobs.length === 0) {
|
|
2945
|
+
console.error(`No jobs found for pipeline ${pipeline2.id}`);
|
|
2946
|
+
process.exit(1);
|
|
2947
|
+
}
|
|
2948
|
+
if (options.verbose) {
|
|
2949
|
+
console.log(JSON.stringify(jobs, null, 2));
|
|
2950
|
+
} else {
|
|
2951
|
+
const filtered = jobs.map((j) => {
|
|
2952
|
+
const { id: id2, name, stage, status: status2, duration, failure_reason } = j;
|
|
2953
|
+
return { id: id2, name, stage, status: status2, duration, failure_reason };
|
|
2954
|
+
});
|
|
2955
|
+
console.log(JSON.stringify(filtered, null, 2));
|
|
2956
|
+
}
|
|
2943
2957
|
});
|
|
2944
2958
|
return program2;
|
|
2945
2959
|
}
|
|
2946
|
-
var
|
|
2947
|
-
|
|
2948
|
-
if (isMain("git-jira-start")) {
|
|
2960
|
+
var git_lab_project_pipeline_latest_default = create12;
|
|
2961
|
+
if (isMain("git-lab-project-pipeline-latest")) {
|
|
2949
2962
|
await create12().parseAsync(Bun.argv);
|
|
2950
2963
|
}
|
|
2951
2964
|
|
|
2952
|
-
//
|
|
2965
|
+
// bin/git-lab-project-pipeline-list.ts
|
|
2966
|
+
var import_debug2 = __toESM(require_src(), 1);
|
|
2967
|
+
var version13 = await getPackageVersion();
|
|
2968
|
+
var dlog2 = import_debug2.default("git-lab-project-pipeline-list");
|
|
2953
2969
|
function create13() {
|
|
2954
2970
|
const program2 = new Command;
|
|
2955
|
-
program2.version(version13).name("list").description("List
|
|
2956
|
-
const
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2971
|
+
program2.version(version13).name("list").description("List recent successful pipelines").option("-v, --verbose", "Verbose output").option("-d, --days <days>", "Number of days to look back", "7").option("-s, --status <status>", "Status of pipelines to list: success | runnning | ", "success").action(async (options) => {
|
|
2972
|
+
const pipelines = await getProjectPipelines(options);
|
|
2973
|
+
dlog2(`pipelines:`, pipelines);
|
|
2974
|
+
if (!pipelines) {
|
|
2975
|
+
console.error(`No pipelines!`);
|
|
2976
|
+
process.exit(1);
|
|
2977
|
+
}
|
|
2978
|
+
if (options.verbose) {
|
|
2979
|
+
console.log(pipelines);
|
|
2980
|
+
} else {
|
|
2981
|
+
let filtered = pipelines.map((p) => {
|
|
2982
|
+
const { id, web_url, updated_at, ref, sha } = p;
|
|
2983
|
+
return { id, web_url, updated_at, ref, sha };
|
|
2963
2984
|
});
|
|
2964
2985
|
console.log(filtered);
|
|
2965
2986
|
}
|
|
2966
2987
|
});
|
|
2967
2988
|
return program2;
|
|
2968
2989
|
}
|
|
2969
|
-
var
|
|
2970
|
-
|
|
2971
|
-
if (isMain("git-lab-group-list")) {
|
|
2990
|
+
var git_lab_project_pipeline_list_default = create13;
|
|
2991
|
+
if (isMain("git-lab-project-pipeline-list")) {
|
|
2972
2992
|
await create13().parseAsync(Bun.argv);
|
|
2973
2993
|
}
|
|
2974
2994
|
|
|
2975
|
-
//
|
|
2995
|
+
// bin/git-lab-project-pipeline-log.ts
|
|
2996
|
+
var version14 = await getPackageVersion();
|
|
2976
2997
|
function create14() {
|
|
2977
2998
|
const program2 = new Command;
|
|
2978
|
-
program2.version(version14).name("
|
|
2979
|
-
const
|
|
2980
|
-
|
|
2981
|
-
|
|
2999
|
+
program2.version(version14).name("log").description("Download a job log").requiredOption("-j, --job <id>", "Job ID").option("-t, --tail <lines>", "Show only the last N lines").action(async (options) => {
|
|
3000
|
+
const jobId = parseInt(options.job, 10);
|
|
3001
|
+
if (isNaN(jobId)) {
|
|
3002
|
+
console.error(`Invalid job ID: ${options.job}`);
|
|
3003
|
+
process.exit(1);
|
|
3004
|
+
}
|
|
3005
|
+
const log = await getJobLog(jobId);
|
|
3006
|
+
if (!log) {
|
|
3007
|
+
console.error(`No log output for job ${jobId}`);
|
|
3008
|
+
process.exit(1);
|
|
3009
|
+
}
|
|
3010
|
+
if (options.tail) {
|
|
3011
|
+
const n = parseInt(options.tail, 10);
|
|
3012
|
+
if (isNaN(n)) {
|
|
3013
|
+
console.error(`Invalid --tail value: ${options.tail}`);
|
|
3014
|
+
process.exit(1);
|
|
3015
|
+
}
|
|
3016
|
+
const lines = log.split(`
|
|
3017
|
+
`);
|
|
3018
|
+
const tail = lines.slice(-n);
|
|
3019
|
+
process.stdout.write(tail.join(`
|
|
3020
|
+
`));
|
|
3021
|
+
} else {
|
|
3022
|
+
process.stdout.write(log);
|
|
3023
|
+
}
|
|
3024
|
+
});
|
|
3025
|
+
return program2;
|
|
3026
|
+
}
|
|
3027
|
+
var git_lab_project_pipeline_log_default = create14;
|
|
3028
|
+
if (isMain("git-lab-project-pipeline-log")) {
|
|
3029
|
+
await create14().parseAsync(Bun.argv);
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
// bin/git-lab-project-pipeline.ts
|
|
3033
|
+
var version15 = await getPackageVersion();
|
|
3034
|
+
function create15() {
|
|
3035
|
+
const program2 = new Command;
|
|
3036
|
+
program2.version(version15).name("pipeline").description("Commands for working with GitLab pipelines").addCommand(git_lab_project_pipeline_jobs_default()).addCommand(git_lab_project_pipeline_latest_default()).addCommand(git_lab_project_pipeline_list_default()).addCommand(git_lab_project_pipeline_log_default()).action(() => program2.help());
|
|
3037
|
+
return program2;
|
|
3038
|
+
}
|
|
3039
|
+
var git_lab_project_pipeline_default = create15;
|
|
3040
|
+
if (isMain("git-lab-project-pipeline")) {
|
|
3041
|
+
await create15().parseAsync(Bun.argv);
|
|
3042
|
+
}
|
|
3043
|
+
|
|
3044
|
+
// bin/git-lab-project-whereami.ts
|
|
3045
|
+
var version16 = await getPackageVersion();
|
|
3046
|
+
function create16() {
|
|
3047
|
+
const program2 = new Command;
|
|
3048
|
+
program2.version(version16).name("whereami").description("Show current project based on current directory").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
3049
|
+
const ssh_url = await getRemote();
|
|
3050
|
+
if (!ssh_url) {
|
|
3051
|
+
console.error(`No remote!`);
|
|
3052
|
+
process.exit(1);
|
|
3053
|
+
}
|
|
3054
|
+
console.log(`Remote: ${ssh_url}`);
|
|
3055
|
+
const project2 = await findProject(ssh_url);
|
|
3056
|
+
if (!project2) {
|
|
3057
|
+
console.error(`No project!`);
|
|
3058
|
+
process.exit(1);
|
|
3059
|
+
}
|
|
3060
|
+
if (options.verbose) {
|
|
3061
|
+
console.log(project2);
|
|
3062
|
+
} else {
|
|
3063
|
+
const { id, name, path_with_namespace, ssh_url_to_repo } = project2;
|
|
3064
|
+
console.log({ id, name, path_with_namespace, ssh_url_to_repo });
|
|
3065
|
+
}
|
|
3066
|
+
});
|
|
3067
|
+
return program2;
|
|
3068
|
+
}
|
|
3069
|
+
var git_lab_project_whereami_default = create16;
|
|
3070
|
+
if (isMain("git-lab-project-whereami")) {
|
|
3071
|
+
await create16().parseAsync(Bun.argv);
|
|
3072
|
+
}
|
|
3073
|
+
|
|
3074
|
+
// bin/git-lab-project.ts
|
|
3075
|
+
var version17 = await getPackageVersion();
|
|
3076
|
+
function create17() {
|
|
3077
|
+
const program2 = new Command;
|
|
3078
|
+
program2.version(version17).name("project").description("Commands for working with GitLab projects").addCommand(git_lab_project_list_default()).addCommand(git_lab_project_mr_default()).addCommand(git_lab_project_pipeline_default()).addCommand(git_lab_project_whereami_default()).action(() => {
|
|
3079
|
+
program2.help();
|
|
3080
|
+
});
|
|
3081
|
+
return program2;
|
|
3082
|
+
}
|
|
3083
|
+
var git_lab_project_default = create17;
|
|
3084
|
+
if (isMain("git-lab-project")) {
|
|
3085
|
+
await create17().parseAsync(Bun.argv);
|
|
3086
|
+
}
|
|
3087
|
+
|
|
3088
|
+
// lib/confluence/config.ts
|
|
3089
|
+
var gitEmailP2 = getConfig("user.email");
|
|
3090
|
+
var jiraEmailP = getConfig("jira.user");
|
|
3091
|
+
var confluenceEmailP = getConfig("confluence.user", { expectQuiet: true });
|
|
3092
|
+
var jiraHostP = getConfig("jira.host");
|
|
3093
|
+
var confluenceHostP = getConfig("confluence.host", { expectQuiet: true });
|
|
3094
|
+
var jiraTokenP = getConfig("jira.token");
|
|
3095
|
+
var confluenceTokenP = getConfig("confluence.token", { expectQuiet: true });
|
|
3096
|
+
async function getConfluenceConfig() {
|
|
3097
|
+
const host = await confluenceHostP || await jiraHostP;
|
|
3098
|
+
if (!host)
|
|
3099
|
+
throw new Error("confluence.host or jira.host not in git config");
|
|
3100
|
+
const user2 = await confluenceEmailP || await jiraEmailP || await gitEmailP2;
|
|
3101
|
+
if (!user2)
|
|
3102
|
+
throw new Error("confluence.user, jira.user, or user.email not in git config");
|
|
3103
|
+
const pat = await confluenceTokenP || await jiraTokenP;
|
|
3104
|
+
if (!pat)
|
|
3105
|
+
throw new Error("confluence.token or jira.token not in git config");
|
|
3106
|
+
const token = Buffer.from(`${user2}:${pat}`).toString("base64");
|
|
3107
|
+
return { host, token };
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
|
+
// lib/confluence/api.ts
|
|
3111
|
+
function getNextLink2(link) {
|
|
3112
|
+
if (!link) {
|
|
3113
|
+
return;
|
|
3114
|
+
}
|
|
3115
|
+
const regex = /<([^>]+)>; rel="next"/;
|
|
3116
|
+
const match = link.match(regex);
|
|
3117
|
+
const next = match ? match[1] : undefined;
|
|
3118
|
+
return next;
|
|
3119
|
+
}
|
|
3120
|
+
async function confluenceApi(endpoint) {
|
|
3121
|
+
if (endpoint.startsWith("/")) {
|
|
3122
|
+
console.warn(`confluenceApi: endpoint ${endpoint} starts with /, removing it`);
|
|
3123
|
+
endpoint = endpoint.slice(1);
|
|
3124
|
+
}
|
|
3125
|
+
const method = "GET";
|
|
3126
|
+
const { host, token } = await getConfluenceConfig();
|
|
3127
|
+
const base = `https://${host}/wiki/api/v2`;
|
|
3128
|
+
const uri = `${base}/${endpoint}`;
|
|
3129
|
+
const auth = `Basic ${token}`;
|
|
3130
|
+
const headers = new Headers;
|
|
3131
|
+
headers.append("Authorization", auth);
|
|
3132
|
+
headers.append("Accept", "application/json");
|
|
3133
|
+
const options = {
|
|
3134
|
+
method,
|
|
3135
|
+
headers
|
|
3136
|
+
};
|
|
3137
|
+
let request = new Request(uri, options);
|
|
3138
|
+
const response = await fetch(request);
|
|
3139
|
+
let link = getNextLink2(response.headers.get("Link"));
|
|
3140
|
+
const body = await response.json();
|
|
3141
|
+
if (!body.results) {
|
|
3142
|
+
return body;
|
|
3143
|
+
}
|
|
3144
|
+
let result = body.results;
|
|
3145
|
+
const origin = `https://${host}`;
|
|
3146
|
+
while (link) {
|
|
3147
|
+
const url = link.startsWith("/") ? `${origin}${link}` : link;
|
|
3148
|
+
let request2 = new Request(url, options);
|
|
3149
|
+
const next_response = await fetch(request2);
|
|
3150
|
+
link = getNextLink2(next_response.headers.get("Link"));
|
|
3151
|
+
const next_body = await next_response.json();
|
|
3152
|
+
if (next_body.results) {
|
|
3153
|
+
result = result.concat(next_body.results);
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
return result;
|
|
3157
|
+
}
|
|
3158
|
+
async function confluenceApiWrite(endpoint, method, body) {
|
|
3159
|
+
if (endpoint.startsWith("/")) {
|
|
3160
|
+
console.warn(`confluenceApiWrite: endpoint ${endpoint} starts with /, removing it`);
|
|
3161
|
+
endpoint = endpoint.slice(1);
|
|
3162
|
+
}
|
|
3163
|
+
const { host, token } = await getConfluenceConfig();
|
|
3164
|
+
const base = `https://${host}/wiki/api/v2`;
|
|
3165
|
+
const uri = `${base}/${endpoint}`;
|
|
3166
|
+
const auth = `Basic ${token}`;
|
|
3167
|
+
const headers = new Headers;
|
|
3168
|
+
headers.append("Authorization", auth);
|
|
3169
|
+
headers.append("Accept", "application/json");
|
|
3170
|
+
headers.append("Content-Type", "application/json");
|
|
3171
|
+
const options = {
|
|
3172
|
+
method,
|
|
3173
|
+
headers,
|
|
3174
|
+
body: JSON.stringify(body)
|
|
3175
|
+
};
|
|
3176
|
+
const request = new Request(uri, options);
|
|
3177
|
+
const response = await fetch(request);
|
|
3178
|
+
if (!response.ok) {
|
|
3179
|
+
const text = await response.text();
|
|
3180
|
+
throw new Error(`Confluence API ${method} ${endpoint} failed (${response.status}): ${text}`);
|
|
3181
|
+
}
|
|
3182
|
+
const result = await response.json();
|
|
3183
|
+
return result;
|
|
3184
|
+
}
|
|
3185
|
+
async function confluenceSearch(cql) {
|
|
3186
|
+
const { host, token } = await getConfluenceConfig();
|
|
3187
|
+
const base = `https://${host}/wiki/rest/api`;
|
|
3188
|
+
const auth = `Basic ${token}`;
|
|
3189
|
+
const headers = new Headers;
|
|
3190
|
+
headers.append("Authorization", auth);
|
|
3191
|
+
headers.append("Accept", "application/json");
|
|
3192
|
+
const options = { method: "GET", headers };
|
|
3193
|
+
const origin = `https://${host}`;
|
|
3194
|
+
let uri = `${base}/search?cql=${encodeURIComponent(cql)}&limit=25`;
|
|
3195
|
+
let allResults = [];
|
|
3196
|
+
while (uri) {
|
|
3197
|
+
const request = new Request(uri, options);
|
|
3198
|
+
const response = await fetch(request);
|
|
3199
|
+
const body = await response.json();
|
|
3200
|
+
if (body.results) {
|
|
3201
|
+
allResults = allResults.concat(body.results);
|
|
3202
|
+
}
|
|
3203
|
+
const next = body._links?.next;
|
|
3204
|
+
uri = next ? next.startsWith("/") ? `${origin}${next}` : next : "";
|
|
3205
|
+
}
|
|
3206
|
+
return allResults;
|
|
3207
|
+
}
|
|
3208
|
+
async function confluenceApiV1(endpoint) {
|
|
3209
|
+
if (endpoint.startsWith("/")) {
|
|
3210
|
+
console.warn(`confluenceApiV1: endpoint ${endpoint} starts with /, removing it`);
|
|
3211
|
+
endpoint = endpoint.slice(1);
|
|
3212
|
+
}
|
|
3213
|
+
const method = "GET";
|
|
3214
|
+
const { host, token } = await getConfluenceConfig();
|
|
3215
|
+
const base = `https://${host}/wiki/rest/api`;
|
|
3216
|
+
const uri = `${base}/${endpoint}`;
|
|
3217
|
+
const auth = `Basic ${token}`;
|
|
3218
|
+
const headers = new Headers;
|
|
3219
|
+
headers.append("Authorization", auth);
|
|
3220
|
+
headers.append("Accept", "application/json");
|
|
3221
|
+
const options = {
|
|
3222
|
+
method,
|
|
3223
|
+
headers
|
|
3224
|
+
};
|
|
3225
|
+
const request = new Request(uri, options);
|
|
3226
|
+
const response = await fetch(request);
|
|
3227
|
+
const result = await response.json();
|
|
3228
|
+
return result;
|
|
3229
|
+
}
|
|
3230
|
+
// bin/git-confluence-space-list.ts
|
|
3231
|
+
var version18 = await getPackageVersion();
|
|
3232
|
+
function create18() {
|
|
3233
|
+
const program2 = new Command;
|
|
3234
|
+
program2.version(version18).name("list").description("List Confluence spaces").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
3235
|
+
const spaces = await confluenceApi("spaces");
|
|
3236
|
+
if (options.verbose) {
|
|
3237
|
+
console.log(spaces);
|
|
3238
|
+
} else {
|
|
3239
|
+
for (const space of spaces) {
|
|
3240
|
+
console.log(`${space.key} ${space.name}`);
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
3243
|
+
});
|
|
3244
|
+
return program2;
|
|
3245
|
+
}
|
|
3246
|
+
var git_confluence_space_list_default = create18;
|
|
3247
|
+
if (isMain("git-confluence-space-list")) {
|
|
3248
|
+
await create18().parseAsync(Bun.argv);
|
|
3249
|
+
}
|
|
3250
|
+
|
|
3251
|
+
// bin/git-confluence-page-search.ts
|
|
3252
|
+
var version19 = await getPackageVersion();
|
|
3253
|
+
function create19() {
|
|
3254
|
+
const program2 = new Command;
|
|
3255
|
+
program2.version(version19).name("search").description("Search for Confluence pages by title (fuzzy by default)").argument("query", "Search query").option("-v, --verbose", "Verbose output").option("--exact", "Exact title match (uses v2 API)").option("--full-text", "Search page body content in addition to title").action(async (query, options) => {
|
|
3256
|
+
const { host } = await getConfluenceConfig();
|
|
3257
|
+
if (options.exact) {
|
|
3258
|
+
const pages = await confluenceApi(`pages?title=${encodeURIComponent(query)}`);
|
|
3259
|
+
if (options.verbose) {
|
|
3260
|
+
console.log(pages);
|
|
3261
|
+
} else {
|
|
3262
|
+
for (const page of pages) {
|
|
3263
|
+
const url = `https://${host}/wiki/spaces/${page.spaceId}/pages/${page.id}`;
|
|
3264
|
+
console.log(`${page.id} ${page.title} ${url}`);
|
|
3265
|
+
}
|
|
3266
|
+
}
|
|
3267
|
+
return;
|
|
3268
|
+
}
|
|
3269
|
+
const field = options.fullText ? "text" : "title";
|
|
3270
|
+
const cql = `type=page AND ${field} ~ "${query}"`;
|
|
3271
|
+
const results = await confluenceSearch(cql);
|
|
3272
|
+
if (options.verbose) {
|
|
3273
|
+
console.log(results);
|
|
3274
|
+
} else {
|
|
3275
|
+
for (const result of results) {
|
|
3276
|
+
const id = result.content.id;
|
|
3277
|
+
const title = result.content.title;
|
|
3278
|
+
const url = `https://${host}${result.url}`;
|
|
3279
|
+
console.log(`${id} ${title} ${url}`);
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
});
|
|
3283
|
+
return program2;
|
|
3284
|
+
}
|
|
3285
|
+
var git_confluence_page_search_default = create19;
|
|
3286
|
+
if (isMain("git-confluence-page-search")) {
|
|
3287
|
+
await create19().parseAsync(Bun.argv);
|
|
3288
|
+
}
|
|
3289
|
+
|
|
3290
|
+
// bin/git-confluence-page-show.ts
|
|
3291
|
+
var version20 = await getPackageVersion();
|
|
3292
|
+
function create20() {
|
|
3293
|
+
const program2 = new Command;
|
|
3294
|
+
program2.version(version20).name("show").description("Show information about a Confluence page").argument("id", "Page ID").option("-v, --verbose", "Verbose output").option("-b, --body-format <format>", "Include page body (storage or atlas_doc_format)").option("--body-only", "Output only the body content value (requires --body-format)").action(async (id, options) => {
|
|
3295
|
+
let endpoint = `pages/${id}`;
|
|
3296
|
+
if (options.bodyFormat) {
|
|
3297
|
+
endpoint += `?body-format=${options.bodyFormat}`;
|
|
3298
|
+
}
|
|
3299
|
+
const page = await confluenceApi(endpoint);
|
|
3300
|
+
if (options.bodyOnly) {
|
|
3301
|
+
if (!options.bodyFormat) {
|
|
3302
|
+
console.error("--body-only requires --body-format");
|
|
3303
|
+
process.exit(1);
|
|
3304
|
+
}
|
|
3305
|
+
const body = page.body;
|
|
3306
|
+
const content = options.bodyFormat === "storage" ? body?.storage?.value : body?.atlas_doc_format?.value;
|
|
3307
|
+
if (content) {
|
|
3308
|
+
console.log(content);
|
|
3309
|
+
} else {
|
|
3310
|
+
console.error("No body content returned");
|
|
3311
|
+
process.exit(1);
|
|
3312
|
+
}
|
|
3313
|
+
} else if (options.verbose) {
|
|
3314
|
+
console.log(page);
|
|
3315
|
+
} else {
|
|
3316
|
+
const { host } = await getConfluenceConfig();
|
|
3317
|
+
const url = `https://${host}/wiki/spaces/${page.spaceId}/pages/${page.id}`;
|
|
3318
|
+
const result = { id: page.id, title: page.title, spaceId: page.spaceId, url };
|
|
3319
|
+
if (page.body?.storage?.value) {
|
|
3320
|
+
result.bodyLength = page.body.storage.value.length;
|
|
3321
|
+
}
|
|
3322
|
+
console.log(result);
|
|
3323
|
+
}
|
|
3324
|
+
});
|
|
3325
|
+
return program2;
|
|
3326
|
+
}
|
|
3327
|
+
var git_confluence_page_show_default = create20;
|
|
3328
|
+
if (isMain("git-confluence-page-show")) {
|
|
3329
|
+
await create20().parseAsync(Bun.argv);
|
|
3330
|
+
}
|
|
3331
|
+
|
|
3332
|
+
// bin/git-confluence-page-update.ts
|
|
3333
|
+
var version21 = await getPackageVersion();
|
|
3334
|
+
async function readStdin() {
|
|
3335
|
+
const chunks = [];
|
|
3336
|
+
for await (const chunk of Bun.stdin.stream()) {
|
|
3337
|
+
chunks.push(Buffer.from(chunk));
|
|
3338
|
+
}
|
|
3339
|
+
return Buffer.concat(chunks).toString("utf-8");
|
|
3340
|
+
}
|
|
3341
|
+
function create21() {
|
|
3342
|
+
const program2 = new Command;
|
|
3343
|
+
program2.version(version21).name("update").description("Update a Confluence page").argument("id", "Page ID").option("-t, --title <title>", "New page title (defaults to current title)").option("-f, --file <path>", "Read body content from file (default: stdin)").option("-m, --message <message>", "Version message").option("-v, --verbose", "Verbose output").action(async (id, options) => {
|
|
3344
|
+
const current = await confluenceApi(`pages/${id}`);
|
|
3345
|
+
let content;
|
|
3346
|
+
if (options.file) {
|
|
3347
|
+
const file = Bun.file(options.file);
|
|
3348
|
+
content = await file.text();
|
|
3349
|
+
} else {
|
|
3350
|
+
content = await readStdin();
|
|
3351
|
+
}
|
|
3352
|
+
if (!content.trim()) {
|
|
3353
|
+
console.error("No content provided. Pipe content via stdin or use --file.");
|
|
3354
|
+
process.exit(1);
|
|
3355
|
+
}
|
|
3356
|
+
const title = options.title || current.title;
|
|
3357
|
+
const nextVersion = current.version.number + 1;
|
|
3358
|
+
const body = {
|
|
3359
|
+
id,
|
|
3360
|
+
status: "current",
|
|
3361
|
+
title,
|
|
3362
|
+
body: {
|
|
3363
|
+
representation: "storage",
|
|
3364
|
+
value: content
|
|
3365
|
+
},
|
|
3366
|
+
version: {
|
|
3367
|
+
number: nextVersion,
|
|
3368
|
+
message: options.message || ""
|
|
3369
|
+
}
|
|
3370
|
+
};
|
|
3371
|
+
const result = await confluenceApiWrite(`pages/${id}`, "PUT", body);
|
|
3372
|
+
if (options.verbose) {
|
|
3373
|
+
console.log(result);
|
|
3374
|
+
} else {
|
|
3375
|
+
console.log(`Updated page ${result.id} "${result.title}" to version ${result.version.number}`);
|
|
3376
|
+
}
|
|
3377
|
+
});
|
|
3378
|
+
return program2;
|
|
3379
|
+
}
|
|
3380
|
+
var git_confluence_page_update_default = create21;
|
|
3381
|
+
if (isMain("git-confluence-page-update")) {
|
|
3382
|
+
await create21().parseAsync(Bun.argv);
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3385
|
+
// bin/git-confluence-page.ts
|
|
3386
|
+
var version22 = await getPackageVersion();
|
|
3387
|
+
function create22() {
|
|
3388
|
+
const program2 = new Command;
|
|
3389
|
+
program2.version(version22).name("page").description("Commands for working with Confluence pages").addCommand(git_confluence_page_search_default()).addCommand(git_confluence_page_show_default()).addCommand(git_confluence_page_update_default()).action(() => program2.help());
|
|
3390
|
+
return program2;
|
|
3391
|
+
}
|
|
3392
|
+
var git_confluence_page_default = create22;
|
|
3393
|
+
if (isMain("git-confluence-page")) {
|
|
3394
|
+
await create22().parseAsync(Bun.argv);
|
|
3395
|
+
}
|
|
3396
|
+
|
|
3397
|
+
// bin/git-bump.ts
|
|
3398
|
+
var version23 = await getPackageVersion();
|
|
3399
|
+
function create23() {
|
|
3400
|
+
const program2 = new Command;
|
|
3401
|
+
program2.version(version23).name("bump").description("Bump the version number in the current branch").action(async () => {
|
|
3402
|
+
const currentBranch = await getCurrentBranch();
|
|
3403
|
+
let stem = currentBranch;
|
|
3404
|
+
let version24 = 1;
|
|
3405
|
+
const match = currentBranch.match(/^(.+)[-\.]v(\d+)$/);
|
|
3406
|
+
if (match) {
|
|
3407
|
+
stem = match[1];
|
|
3408
|
+
version24 = parseInt(match[2]) + 1;
|
|
3409
|
+
}
|
|
3410
|
+
const nextBranch = `${stem}.v${version24}`;
|
|
3411
|
+
await createBranch(nextBranch);
|
|
3412
|
+
});
|
|
3413
|
+
return program2;
|
|
3414
|
+
}
|
|
3415
|
+
var git_bump_default = create23;
|
|
3416
|
+
if (isMain("git-bump")) {
|
|
3417
|
+
await create23().parseAsync(Bun.argv);
|
|
3418
|
+
}
|
|
3419
|
+
|
|
3420
|
+
// lib/jira.ts
|
|
3421
|
+
var gitEmailP3 = getConfig("user.email");
|
|
3422
|
+
var jiraEmailP2 = getConfig("jira.user");
|
|
3423
|
+
var hostP2 = getConfig("jira.host");
|
|
3424
|
+
var tokenP2 = getConfig("jira.token");
|
|
3425
|
+
async function getJiraConfig() {
|
|
3426
|
+
const host = await hostP2;
|
|
3427
|
+
if (!host)
|
|
3428
|
+
throw new Error("jira.host not in git config");
|
|
3429
|
+
const user2 = await jiraEmailP2 || await gitEmailP3;
|
|
3430
|
+
if (!user2)
|
|
3431
|
+
throw new Error("jira.user or user.email not in git config");
|
|
3432
|
+
const pat = await tokenP2;
|
|
3433
|
+
if (!pat)
|
|
3434
|
+
throw new Error("jira.token not in git config");
|
|
3435
|
+
const token = Buffer.from(`${user2}:${pat}`).toString("base64");
|
|
3436
|
+
return { host, token };
|
|
3437
|
+
}
|
|
3438
|
+
async function jiraApi(endpoint) {
|
|
3439
|
+
if (endpoint.startsWith("/")) {
|
|
3440
|
+
console.warn(`jiraApi: endpoint ${endpoint} starts with /`);
|
|
3441
|
+
endpoint = endpoint.slice(1);
|
|
3442
|
+
}
|
|
3443
|
+
const method = "GET";
|
|
3444
|
+
const { host, token } = await getJiraConfig();
|
|
3445
|
+
const uri = `https://${host}/rest/api/3/${endpoint}`;
|
|
3446
|
+
const auth = `Basic ${token}`;
|
|
3447
|
+
const headers = new Headers;
|
|
3448
|
+
headers.append("Authorization", auth);
|
|
3449
|
+
headers.append("Accept", "application/json");
|
|
3450
|
+
const options = {
|
|
3451
|
+
method,
|
|
3452
|
+
headers
|
|
3453
|
+
};
|
|
3454
|
+
const request = new Request(uri, options);
|
|
3455
|
+
const response = await fetch(request);
|
|
3456
|
+
const result = await response.json();
|
|
3457
|
+
return result;
|
|
3458
|
+
}
|
|
3459
|
+
async function getIssue(issue) {
|
|
3460
|
+
const result = await jiraApi(`issue/${issue}`);
|
|
3461
|
+
return result;
|
|
3462
|
+
}
|
|
3463
|
+
async function getMyself() {
|
|
3464
|
+
return await jiraApi("myself");
|
|
3465
|
+
}
|
|
3466
|
+
async function myUnresolvedIssues() {
|
|
3467
|
+
const myself = await getMyself();
|
|
3468
|
+
const myselfId = myself.accountId;
|
|
3469
|
+
const jql = `assignee = ${myselfId} AND resolution = Unresolved`;
|
|
3470
|
+
const issues = await jiraApi(`search/jql?jql=${encodeURIComponent(jql)}&fields=summary`);
|
|
3471
|
+
return issues.issues;
|
|
3472
|
+
}
|
|
3473
|
+
|
|
3474
|
+
// bin/git-jira-start.ts
|
|
3475
|
+
var version24 = await getPackageVersion();
|
|
3476
|
+
function toKebab(s) {
|
|
3477
|
+
return s.replace(/([a-z]+)([A-Z]+)/g, "$1_2").toLowerCase().replace(/(\W+)/g, "-").replace(/-$/, "");
|
|
3478
|
+
}
|
|
3479
|
+
function create24() {
|
|
3480
|
+
const program2 = new Command;
|
|
3481
|
+
program2.version(version24).name("start").description("Start working on an issue by creating a branch").argument("issue", "Issue ID").action(async (issueId) => {
|
|
3482
|
+
const issue = await getIssue(issueId);
|
|
3483
|
+
if (!issue) {
|
|
3484
|
+
console.error(`Issue ${issueId} not found`);
|
|
3485
|
+
process.exit(1);
|
|
3486
|
+
}
|
|
3487
|
+
const summary = issue.fields.summary;
|
|
3488
|
+
const branchName = `${issueId}-${toKebab(summary)}`;
|
|
3489
|
+
await createBranch(branchName);
|
|
3490
|
+
});
|
|
3491
|
+
return program2;
|
|
3492
|
+
}
|
|
3493
|
+
var git_jira_start_default = create24;
|
|
3494
|
+
if (isMain("git-jira-start")) {
|
|
3495
|
+
await create24().parseAsync(Bun.argv);
|
|
3496
|
+
}
|
|
3497
|
+
|
|
3498
|
+
// bin/git-lab-group-list.ts
|
|
3499
|
+
var version25 = await getPackageVersion();
|
|
3500
|
+
function create25() {
|
|
3501
|
+
const program2 = new Command;
|
|
3502
|
+
program2.version(version25).name("list").description("List groups for the current user").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
3503
|
+
const groups = await getGroups();
|
|
3504
|
+
if (options.verbose)
|
|
3505
|
+
console.log(groups);
|
|
3506
|
+
else {
|
|
3507
|
+
const filtered = groups.map((g) => {
|
|
3508
|
+
const { id, name, full_path } = g;
|
|
3509
|
+
return { id, name, full_path };
|
|
3510
|
+
});
|
|
3511
|
+
console.log(filtered);
|
|
3512
|
+
}
|
|
3513
|
+
});
|
|
3514
|
+
return program2;
|
|
3515
|
+
}
|
|
3516
|
+
var git_lab_group_list_default = create25;
|
|
3517
|
+
if (isMain("git-lab-group-list")) {
|
|
3518
|
+
await create25().parseAsync(Bun.argv);
|
|
3519
|
+
}
|
|
3520
|
+
|
|
3521
|
+
// bin/git-confluence-space.ts
|
|
3522
|
+
var version26 = await getPackageVersion();
|
|
3523
|
+
function create26() {
|
|
3524
|
+
const program2 = new Command;
|
|
3525
|
+
program2.version(version26).name("space").description("Commands for working with Confluence spaces").addCommand(git_confluence_space_list_default()).action(() => program2.help());
|
|
3526
|
+
return program2;
|
|
3527
|
+
}
|
|
3528
|
+
var git_confluence_space_default = create26;
|
|
3529
|
+
if (isMain("git-confluence-space")) {
|
|
3530
|
+
await create26().parseAsync(Bun.argv);
|
|
3531
|
+
}
|
|
3532
|
+
|
|
3533
|
+
// bin/git-jira-issue-list.ts
|
|
3534
|
+
var version27 = await getPackageVersion();
|
|
3535
|
+
function create27() {
|
|
3536
|
+
const program2 = new Command;
|
|
3537
|
+
program2.version(version27).name("list").description("List your unresolved issues").action(async () => {
|
|
3538
|
+
const issues = await myUnresolvedIssues();
|
|
3539
|
+
console.log(`You have ${issues.length} unresolved issues`);
|
|
3540
|
+
issues.forEach((issue) => {
|
|
2982
3541
|
console.log(`${issue.key}: ${issue.fields.summary}`);
|
|
2983
3542
|
});
|
|
2984
3543
|
});
|
|
2985
3544
|
return program2;
|
|
2986
3545
|
}
|
|
2987
|
-
var
|
|
2988
|
-
var git_jira_issue_list_default = create14;
|
|
3546
|
+
var git_jira_issue_list_default = create27;
|
|
2989
3547
|
if (isMain("git-jira-issue-list")) {
|
|
2990
|
-
await
|
|
3548
|
+
await create27().parseAsync(Bun.argv);
|
|
2991
3549
|
}
|
|
2992
3550
|
|
|
2993
|
-
//
|
|
2994
|
-
|
|
3551
|
+
// bin/git-jira-issue-show.ts
|
|
3552
|
+
var version28 = await getPackageVersion();
|
|
3553
|
+
function create28() {
|
|
2995
3554
|
const program2 = new Command;
|
|
2996
|
-
program2.version(
|
|
3555
|
+
program2.version(version28).name("show").description("Show information about one issue").argument("issue", "Issue ID").option("-v, --verbose", "Verbose output").action(async (issueId, options) => {
|
|
2997
3556
|
const issue = await getIssue(issueId);
|
|
2998
3557
|
if (!issue) {
|
|
2999
3558
|
console.error(`Issue ${issueId} not found`);
|
|
@@ -3010,95 +3569,448 @@ function create15() {
|
|
|
3010
3569
|
});
|
|
3011
3570
|
return program2;
|
|
3012
3571
|
}
|
|
3013
|
-
var
|
|
3014
|
-
var git_jira_issue_show_default = create15;
|
|
3572
|
+
var git_jira_issue_show_default = create28;
|
|
3015
3573
|
if (isMain("git-jira-issue-show")) {
|
|
3016
|
-
await
|
|
3574
|
+
await create28().parseAsync(Bun.argv);
|
|
3017
3575
|
}
|
|
3018
3576
|
|
|
3019
|
-
//
|
|
3020
|
-
|
|
3577
|
+
// bin/git-jira-issue.ts
|
|
3578
|
+
var version29 = await getPackageVersion();
|
|
3579
|
+
function create29() {
|
|
3021
3580
|
const program2 = new Command;
|
|
3022
|
-
program2.version(
|
|
3581
|
+
program2.version(version29).name("issue").description("Commands for working with issues").addCommand(git_jira_issue_list_default()).addCommand(git_jira_issue_show_default()).action(() => program2.help());
|
|
3023
3582
|
return program2;
|
|
3024
3583
|
}
|
|
3025
|
-
var
|
|
3026
|
-
var git_jira_issue_default = create16;
|
|
3584
|
+
var git_jira_issue_default = create29;
|
|
3027
3585
|
if (isMain("git-jira-issue")) {
|
|
3028
|
-
await
|
|
3586
|
+
await create29().parseAsync(Bun.argv);
|
|
3029
3587
|
}
|
|
3030
3588
|
|
|
3031
|
-
//
|
|
3032
|
-
|
|
3589
|
+
// bin/git-jira-whoami.ts
|
|
3590
|
+
var version30 = await getPackageVersion();
|
|
3591
|
+
function create30() {
|
|
3033
3592
|
const program2 = new Command;
|
|
3034
|
-
program2.version(
|
|
3593
|
+
program2.version(version30).name("whoami").description("Show the current Jira user").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
3594
|
+
const myself = await getMyself();
|
|
3595
|
+
if (options.verbose) {
|
|
3596
|
+
console.log(myself);
|
|
3597
|
+
} else {
|
|
3598
|
+
const { displayName, emailAddress, accountId } = myself;
|
|
3599
|
+
console.log({ displayName, emailAddress, accountId });
|
|
3600
|
+
}
|
|
3601
|
+
});
|
|
3035
3602
|
return program2;
|
|
3036
3603
|
}
|
|
3037
|
-
var
|
|
3038
|
-
|
|
3604
|
+
var git_jira_whoami_default = create30;
|
|
3605
|
+
if (isMain("git-jira-whoami")) {
|
|
3606
|
+
await create30().parseAsync(Bun.argv);
|
|
3607
|
+
}
|
|
3608
|
+
|
|
3609
|
+
// bin/git-lab-group.ts
|
|
3610
|
+
var version31 = await getPackageVersion();
|
|
3611
|
+
function create31() {
|
|
3612
|
+
const program2 = new Command;
|
|
3613
|
+
program2.version(version31).name("group").description("Commands for working with GitLab groups").addCommand(git_lab_group_list_default()).action(() => program2.help());
|
|
3614
|
+
return program2;
|
|
3615
|
+
}
|
|
3616
|
+
var git_lab_group_default = create31;
|
|
3039
3617
|
if (isMain("git-lab-group")) {
|
|
3040
|
-
await
|
|
3618
|
+
await create31().parseAsync(Bun.argv);
|
|
3041
3619
|
}
|
|
3042
3620
|
|
|
3043
|
-
//
|
|
3044
|
-
|
|
3621
|
+
// bin/git-lab-whoami.ts
|
|
3622
|
+
var version32 = await getPackageVersion();
|
|
3623
|
+
function create32() {
|
|
3045
3624
|
const program2 = new Command;
|
|
3046
|
-
program2.version(
|
|
3047
|
-
const
|
|
3048
|
-
if (!
|
|
3625
|
+
program2.version(version32).name("whoami").description("get GitLab user information for current user").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
3626
|
+
const user2 = await whoami();
|
|
3627
|
+
if (!user2) {
|
|
3049
3628
|
console.error(`No user!`);
|
|
3050
3629
|
process.exit(1);
|
|
3051
3630
|
}
|
|
3052
3631
|
if (options.verbose) {
|
|
3053
|
-
console.log(
|
|
3632
|
+
console.log(user2);
|
|
3054
3633
|
process.exit(0);
|
|
3055
3634
|
} else {
|
|
3056
|
-
console.log(
|
|
3635
|
+
console.log(user2.username);
|
|
3057
3636
|
}
|
|
3058
3637
|
});
|
|
3059
3638
|
return program2;
|
|
3060
3639
|
}
|
|
3061
|
-
var
|
|
3062
|
-
var git_lab_whoami_default = create18;
|
|
3640
|
+
var git_lab_whoami_default = create32;
|
|
3063
3641
|
if (isMain("git-lab-whoami")) {
|
|
3064
|
-
await
|
|
3642
|
+
await create32().parseAsync(Bun.argv);
|
|
3065
3643
|
}
|
|
3066
3644
|
|
|
3067
|
-
//
|
|
3068
|
-
|
|
3645
|
+
// bin/git-lab.ts
|
|
3646
|
+
var version33 = await getPackageVersion();
|
|
3647
|
+
function create33() {
|
|
3069
3648
|
const program2 = new Command;
|
|
3070
|
-
program2.version(
|
|
3649
|
+
program2.version(version33).name("lab").description("Commands for working with GitLab").addCommand(git_lab_group_default()).addCommand(git_lab_merge_default()).addCommand(git_lab_namespace_default()).addCommand(git_lab_project_default()).addCommand(git_lab_whoami_default()).action(() => program2.help());
|
|
3071
3650
|
return program2;
|
|
3072
3651
|
}
|
|
3073
|
-
var
|
|
3074
|
-
var git_lab_default = create19;
|
|
3652
|
+
var git_lab_default = create33;
|
|
3075
3653
|
if (isMain("git-lab")) {
|
|
3076
|
-
await
|
|
3654
|
+
await create33().parseAsync(Bun.argv);
|
|
3077
3655
|
}
|
|
3078
3656
|
|
|
3079
|
-
//
|
|
3080
|
-
|
|
3657
|
+
// bin/git-confluence-whoami.ts
|
|
3658
|
+
var version34 = await getPackageVersion();
|
|
3659
|
+
function create34() {
|
|
3081
3660
|
const program2 = new Command;
|
|
3082
|
-
program2.version(
|
|
3661
|
+
program2.version(version34).name("whoami").description("Show the current Confluence user").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
3662
|
+
const myself = await confluenceApiV1("user/current");
|
|
3663
|
+
if (options.verbose) {
|
|
3664
|
+
console.log(myself);
|
|
3665
|
+
} else {
|
|
3666
|
+
const { displayName, email, accountId } = myself;
|
|
3667
|
+
console.log({ displayName, email, accountId });
|
|
3668
|
+
}
|
|
3669
|
+
});
|
|
3083
3670
|
return program2;
|
|
3084
3671
|
}
|
|
3085
|
-
var
|
|
3086
|
-
|
|
3672
|
+
var git_confluence_whoami_default = create34;
|
|
3673
|
+
if (isMain("git-confluence-whoami")) {
|
|
3674
|
+
await create34().parseAsync(Bun.argv);
|
|
3675
|
+
}
|
|
3676
|
+
|
|
3677
|
+
// bin/git-jira.ts
|
|
3678
|
+
var version35 = await getPackageVersion();
|
|
3679
|
+
function create35() {
|
|
3680
|
+
const program2 = new Command;
|
|
3681
|
+
program2.version(version35).name("jira").description("Commands for working with Jira").addCommand(git_jira_start_default()).addCommand(git_jira_issue_default()).addCommand(git_jira_issue_list_default()).addCommand(git_jira_whoami_default());
|
|
3682
|
+
return program2;
|
|
3683
|
+
}
|
|
3684
|
+
var git_jira_default = create35;
|
|
3087
3685
|
if (isMain("git-jira")) {
|
|
3088
|
-
await
|
|
3686
|
+
await create35().parseAsync(Bun.argv);
|
|
3089
3687
|
}
|
|
3090
3688
|
|
|
3091
|
-
//
|
|
3092
|
-
|
|
3689
|
+
// lib/api.ts
|
|
3690
|
+
var services = {
|
|
3691
|
+
gitlab: {
|
|
3692
|
+
getConfig: getGitlabConfig,
|
|
3693
|
+
basePath: "/api/v4",
|
|
3694
|
+
authHeader: (token) => ["Private-Token", token]
|
|
3695
|
+
},
|
|
3696
|
+
jira: {
|
|
3697
|
+
getConfig: getJiraConfig,
|
|
3698
|
+
basePath: "/rest/api/3",
|
|
3699
|
+
authHeader: (token) => ["Authorization", `Basic ${token}`]
|
|
3700
|
+
},
|
|
3701
|
+
confluence: {
|
|
3702
|
+
getConfig: getConfluenceConfig,
|
|
3703
|
+
basePath: "/wiki/api/v2",
|
|
3704
|
+
authHeader: (token) => ["Authorization", `Basic ${token}`]
|
|
3705
|
+
}
|
|
3706
|
+
};
|
|
3707
|
+
var serviceNames = Object.keys(services);
|
|
3708
|
+
function getService(name) {
|
|
3709
|
+
const svc = services[name];
|
|
3710
|
+
if (!svc) {
|
|
3711
|
+
throw new Error(`Unknown service: ${name}. Expected one of: ${serviceNames.join(", ")}`);
|
|
3712
|
+
}
|
|
3713
|
+
return svc;
|
|
3714
|
+
}
|
|
3715
|
+
async function apiRequest(serviceName, method, endpoint, options) {
|
|
3716
|
+
const svc = getService(serviceName);
|
|
3717
|
+
const { host, token } = await svc.getConfig();
|
|
3718
|
+
const [headerName, headerValue] = svc.authHeader(token);
|
|
3719
|
+
let path4 = endpoint;
|
|
3720
|
+
if (path4.startsWith("/")) {
|
|
3721
|
+
path4 = path4.slice(1);
|
|
3722
|
+
}
|
|
3723
|
+
let url;
|
|
3724
|
+
if (options?.raw) {
|
|
3725
|
+
url = `https://${host}/${path4}`;
|
|
3726
|
+
} else {
|
|
3727
|
+
url = `https://${host}${svc.basePath}/${path4}`;
|
|
3728
|
+
}
|
|
3729
|
+
const headers = new Headers;
|
|
3730
|
+
headers.append(headerName, headerValue);
|
|
3731
|
+
headers.append("Accept", "application/json");
|
|
3732
|
+
const fetchOptions = { method, headers };
|
|
3733
|
+
if (options?.data) {
|
|
3734
|
+
headers.append("Content-Type", "application/json");
|
|
3735
|
+
fetchOptions.body = options.data;
|
|
3736
|
+
}
|
|
3737
|
+
const request = new Request(url, fetchOptions);
|
|
3738
|
+
const response = await fetch(request);
|
|
3739
|
+
const body = await response.json();
|
|
3740
|
+
return {
|
|
3741
|
+
status: response.status,
|
|
3742
|
+
headers: response.headers,
|
|
3743
|
+
body
|
|
3744
|
+
};
|
|
3745
|
+
}
|
|
3746
|
+
function getNextLink3(link) {
|
|
3747
|
+
if (!link) {
|
|
3748
|
+
return;
|
|
3749
|
+
}
|
|
3750
|
+
const regex = /<([^>]+)>; rel="next"/;
|
|
3751
|
+
const match = link.match(regex);
|
|
3752
|
+
return match ? match[1] : undefined;
|
|
3753
|
+
}
|
|
3754
|
+
async function apiPaginate(serviceName, endpoint, options) {
|
|
3755
|
+
const svc = getService(serviceName);
|
|
3756
|
+
const { host, token } = await svc.getConfig();
|
|
3757
|
+
const [headerName, headerValue] = svc.authHeader(token);
|
|
3758
|
+
let path4 = endpoint;
|
|
3759
|
+
if (path4.startsWith("/")) {
|
|
3760
|
+
path4 = path4.slice(1);
|
|
3761
|
+
}
|
|
3762
|
+
let url;
|
|
3763
|
+
if (options?.raw) {
|
|
3764
|
+
url = `https://${host}/${path4}`;
|
|
3765
|
+
} else {
|
|
3766
|
+
url = `https://${host}${svc.basePath}/${path4}`;
|
|
3767
|
+
}
|
|
3768
|
+
const headers = new Headers;
|
|
3769
|
+
headers.append(headerName, headerValue);
|
|
3770
|
+
headers.append("Accept", "application/json");
|
|
3771
|
+
const fetchOptions = { method: "GET", headers };
|
|
3772
|
+
const origin = `https://${host}`;
|
|
3773
|
+
let allResults = [];
|
|
3774
|
+
let lastStatus = 0;
|
|
3775
|
+
let lastHeaders = new Headers;
|
|
3776
|
+
while (url) {
|
|
3777
|
+
const request = new Request(url, fetchOptions);
|
|
3778
|
+
const response = await fetch(request);
|
|
3779
|
+
lastStatus = response.status;
|
|
3780
|
+
lastHeaders = response.headers;
|
|
3781
|
+
if (!response.ok) {
|
|
3782
|
+
const body2 = await response.json();
|
|
3783
|
+
return { status: response.status, headers: response.headers, body: body2 };
|
|
3784
|
+
}
|
|
3785
|
+
const body = await response.json();
|
|
3786
|
+
if (Array.isArray(body)) {
|
|
3787
|
+
allResults = allResults.concat(body);
|
|
3788
|
+
} else if (body && typeof body === "object" && "results" in body) {
|
|
3789
|
+
const envelope = body;
|
|
3790
|
+
if (Array.isArray(envelope.results)) {
|
|
3791
|
+
allResults = allResults.concat(envelope.results);
|
|
3792
|
+
}
|
|
3793
|
+
const linksNext = envelope._links?.next;
|
|
3794
|
+
if (linksNext) {
|
|
3795
|
+
url = linksNext.startsWith("/") ? `${origin}${linksNext}` : linksNext;
|
|
3796
|
+
continue;
|
|
3797
|
+
}
|
|
3798
|
+
} else {
|
|
3799
|
+
return { status: response.status, headers: response.headers, body };
|
|
3800
|
+
}
|
|
3801
|
+
const nextLink = getNextLink3(response.headers.get("Link"));
|
|
3802
|
+
if (nextLink) {
|
|
3803
|
+
url = nextLink.startsWith("/") ? `${origin}${nextLink}` : nextLink;
|
|
3804
|
+
} else {
|
|
3805
|
+
url = "";
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
return { status: lastStatus, headers: lastHeaders, body: allResults };
|
|
3809
|
+
}
|
|
3810
|
+
|
|
3811
|
+
// bin/git-api.ts
|
|
3812
|
+
var version36 = await getPackageVersion();
|
|
3813
|
+
var httpMethods = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
|
|
3814
|
+
function create36() {
|
|
3815
|
+
const program2 = new Command;
|
|
3816
|
+
program2.version(version36).name("api").description("make an authenticated API request").argument("<service>", `service name (${serviceNames.join(", ")})`).argument("<endpoint>", "API endpoint path (e.g. /user, /myself)").option("-X, --method <method>", "HTTP method (default: GET, auto-promotes to POST with --data)").option("-d, --data <json>", "request body as JSON string").option("--raw", "don't prepend the default base path").option("--paginate", "follow pagination links and return all results").option("-v, --verbose", "show response status and headers on stderr").action(async (service, endpoint, options) => {
|
|
3817
|
+
let method = options.method?.toUpperCase() ?? (options.data ? "POST" : "GET");
|
|
3818
|
+
if (!httpMethods.includes(method)) {
|
|
3819
|
+
console.error(`Unknown HTTP method: ${method}`);
|
|
3820
|
+
process.exit(1);
|
|
3821
|
+
}
|
|
3822
|
+
if (options.paginate && method !== "GET") {
|
|
3823
|
+
console.error("--paginate only works with GET requests");
|
|
3824
|
+
process.exit(1);
|
|
3825
|
+
}
|
|
3826
|
+
const requestOptions = {
|
|
3827
|
+
raw: options.raw,
|
|
3828
|
+
data: options.data
|
|
3829
|
+
};
|
|
3830
|
+
let result;
|
|
3831
|
+
if (options.paginate) {
|
|
3832
|
+
result = await apiPaginate(service, endpoint, requestOptions);
|
|
3833
|
+
} else {
|
|
3834
|
+
result = await apiRequest(service, method, endpoint, requestOptions);
|
|
3835
|
+
}
|
|
3836
|
+
if (options.verbose) {
|
|
3837
|
+
console.error(`HTTP ${result.status}`);
|
|
3838
|
+
result.headers.forEach((value, key) => {
|
|
3839
|
+
console.error(`${key}: ${value}`);
|
|
3840
|
+
});
|
|
3841
|
+
console.error("");
|
|
3842
|
+
}
|
|
3843
|
+
console.log(JSON.stringify(result.body, null, 2));
|
|
3844
|
+
if (result.status >= 400) {
|
|
3845
|
+
process.exit(1);
|
|
3846
|
+
}
|
|
3847
|
+
});
|
|
3848
|
+
return program2;
|
|
3849
|
+
}
|
|
3850
|
+
var git_api_default = create36;
|
|
3851
|
+
if (isMain("git-api")) {
|
|
3852
|
+
await create36().parseAsync(Bun.argv);
|
|
3853
|
+
}
|
|
3854
|
+
|
|
3855
|
+
// bin/git-confluence.ts
|
|
3856
|
+
var version37 = await getPackageVersion();
|
|
3857
|
+
function create37() {
|
|
3093
3858
|
const program2 = new Command;
|
|
3094
|
-
program2.version(
|
|
3859
|
+
program2.version(version37).name("confluence").description("Commands for working with Confluence").addCommand(git_confluence_whoami_default()).addCommand(git_confluence_space_default()).addCommand(git_confluence_page_default());
|
|
3860
|
+
return program2;
|
|
3861
|
+
}
|
|
3862
|
+
var git_confluence_default = create37;
|
|
3863
|
+
if (isMain("git-confluence")) {
|
|
3864
|
+
await create37().parseAsync(Bun.argv);
|
|
3865
|
+
}
|
|
3866
|
+
|
|
3867
|
+
// bin/gitj-install-skills.ts
|
|
3868
|
+
import fs2 from "fs";
|
|
3869
|
+
import path4 from "path";
|
|
3870
|
+
import os from "os";
|
|
3871
|
+
var version38 = await getPackageVersion();
|
|
3872
|
+
var frameworks = ["opencode", "copilot", "claude"];
|
|
3873
|
+
var skillNames = ["git-jira", "git-lab", "git-confluence"];
|
|
3874
|
+
function getSkillsSourceDir() {
|
|
3875
|
+
const packageJsonPath = findPackageJson();
|
|
3876
|
+
if (!packageJsonPath) {
|
|
3877
|
+
throw new Error("Cannot find package.json for ya-git-jira");
|
|
3878
|
+
}
|
|
3879
|
+
const packageRoot = path4.dirname(packageJsonPath);
|
|
3880
|
+
const skillsDir = path4.join(packageRoot, ".opencode", "skills");
|
|
3881
|
+
if (!fs2.existsSync(skillsDir)) {
|
|
3882
|
+
throw new Error(`Skills directory not found: ${skillsDir}`);
|
|
3883
|
+
}
|
|
3884
|
+
return skillsDir;
|
|
3885
|
+
}
|
|
3886
|
+
function getTargetDir(framework) {
|
|
3887
|
+
const home = os.homedir();
|
|
3888
|
+
switch (framework) {
|
|
3889
|
+
case "opencode":
|
|
3890
|
+
return path4.join(home, ".config", "opencode", "skills");
|
|
3891
|
+
case "copilot":
|
|
3892
|
+
return path4.join(home, ".copilot", "skills");
|
|
3893
|
+
case "claude":
|
|
3894
|
+
return path4.join(process.cwd(), ".claude", "skills");
|
|
3895
|
+
}
|
|
3896
|
+
}
|
|
3897
|
+
function installSkills(framework, copy) {
|
|
3898
|
+
const sourceDir = getSkillsSourceDir();
|
|
3899
|
+
const targetDir = getTargetDir(framework);
|
|
3900
|
+
fs2.mkdirSync(targetDir, { recursive: true });
|
|
3901
|
+
for (const name of skillNames) {
|
|
3902
|
+
const source = path4.join(sourceDir, name);
|
|
3903
|
+
const target = path4.join(targetDir, name);
|
|
3904
|
+
if (fs2.existsSync(target)) {
|
|
3905
|
+
const stat = fs2.lstatSync(target);
|
|
3906
|
+
if (stat.isSymbolicLink()) {
|
|
3907
|
+
fs2.unlinkSync(target);
|
|
3908
|
+
} else if (stat.isDirectory()) {
|
|
3909
|
+
console.error(`${target} already exists as a directory -- skipping (use --force to overwrite)`);
|
|
3910
|
+
continue;
|
|
3911
|
+
}
|
|
3912
|
+
}
|
|
3913
|
+
if (copy) {
|
|
3914
|
+
fs2.cpSync(source, target, { recursive: true });
|
|
3915
|
+
console.log(`copied ${name} -> ${target}`);
|
|
3916
|
+
} else {
|
|
3917
|
+
fs2.symlinkSync(source, target);
|
|
3918
|
+
console.log(`linked ${name} -> ${target}`);
|
|
3919
|
+
}
|
|
3920
|
+
}
|
|
3921
|
+
}
|
|
3922
|
+
function forceInstallSkills(framework, copy) {
|
|
3923
|
+
const sourceDir = getSkillsSourceDir();
|
|
3924
|
+
const targetDir = getTargetDir(framework);
|
|
3925
|
+
fs2.mkdirSync(targetDir, { recursive: true });
|
|
3926
|
+
for (const name of skillNames) {
|
|
3927
|
+
const source = path4.join(sourceDir, name);
|
|
3928
|
+
const target = path4.join(targetDir, name);
|
|
3929
|
+
if (fs2.existsSync(target) || fs2.lstatSync(target).isSymbolicLink()) {
|
|
3930
|
+
fs2.rmSync(target, { recursive: true, force: true });
|
|
3931
|
+
}
|
|
3932
|
+
if (copy) {
|
|
3933
|
+
fs2.cpSync(source, target, { recursive: true });
|
|
3934
|
+
console.log(`copied ${name} -> ${target}`);
|
|
3935
|
+
} else {
|
|
3936
|
+
fs2.symlinkSync(source, target);
|
|
3937
|
+
console.log(`linked ${name} -> ${target}`);
|
|
3938
|
+
}
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
function create38() {
|
|
3942
|
+
const program2 = new Command;
|
|
3943
|
+
program2.version(version38).name("install-skills").description("Install AI agent skills for a coding framework").argument("<framework>", `framework to install for (${frameworks.join(", ")})`).option("--copy", "copy files instead of creating symlinks").option("--force", "overwrite existing skill directories").action(async (framework, options) => {
|
|
3944
|
+
if (!frameworks.includes(framework)) {
|
|
3945
|
+
console.error(`Unknown framework: ${framework}`);
|
|
3946
|
+
console.error(`Supported frameworks: ${frameworks.join(", ")}`);
|
|
3947
|
+
process.exit(1);
|
|
3948
|
+
}
|
|
3949
|
+
if (options.force) {
|
|
3950
|
+
forceInstallSkills(framework, !!options.copy);
|
|
3951
|
+
} else {
|
|
3952
|
+
installSkills(framework, !!options.copy);
|
|
3953
|
+
}
|
|
3954
|
+
});
|
|
3955
|
+
return program2;
|
|
3956
|
+
}
|
|
3957
|
+
var gitj_install_skills_default = create38;
|
|
3958
|
+
if (isMain("gitj-install-skills")) {
|
|
3959
|
+
await create38().parseAsync(Bun.argv);
|
|
3960
|
+
}
|
|
3961
|
+
|
|
3962
|
+
// lib/help.ts
|
|
3963
|
+
function formatCommandTree(cmd) {
|
|
3964
|
+
const lines = [];
|
|
3965
|
+
const name = cmd.name() || "gitj";
|
|
3966
|
+
lines.push(name);
|
|
3967
|
+
appendChildren(lines, cmd, "");
|
|
3968
|
+
return lines.join(`
|
|
3969
|
+
`);
|
|
3970
|
+
}
|
|
3971
|
+
function appendChildren(lines, cmd, prefix) {
|
|
3972
|
+
const children = cmd.commands;
|
|
3973
|
+
if (!children || children.length === 0)
|
|
3974
|
+
return;
|
|
3975
|
+
const descWidth = longestNameChain(children);
|
|
3976
|
+
for (let i = 0;i < children.length; i++) {
|
|
3977
|
+
const child = children[i];
|
|
3978
|
+
const isLast = i === children.length - 1;
|
|
3979
|
+
const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
|
|
3980
|
+
const childPrefix = isLast ? " " : "\u2502 ";
|
|
3981
|
+
const name = child.name();
|
|
3982
|
+
const desc = child.description();
|
|
3983
|
+
const padding = desc ? " ".repeat(Math.max(1, descWidth - name.length + 2)) : "";
|
|
3984
|
+
const descPart = desc ? padding + desc : "";
|
|
3985
|
+
lines.push(`${prefix}${connector}${name}${descPart}`);
|
|
3986
|
+
appendChildren(lines, child, prefix + childPrefix);
|
|
3987
|
+
}
|
|
3988
|
+
}
|
|
3989
|
+
function longestNameChain(commands) {
|
|
3990
|
+
let max = 0;
|
|
3991
|
+
for (const cmd of commands) {
|
|
3992
|
+
const len = cmd.name().length;
|
|
3993
|
+
if (len > max)
|
|
3994
|
+
max = len;
|
|
3995
|
+
}
|
|
3996
|
+
return max;
|
|
3997
|
+
}
|
|
3998
|
+
|
|
3999
|
+
// bin/gitj.ts
|
|
4000
|
+
var version39 = await getPackageVersion();
|
|
4001
|
+
function create39() {
|
|
4002
|
+
const program2 = new Command;
|
|
4003
|
+
program2.version(version39).option("--help-all", "Show full command tree").addCommand(git_api_default()).addCommand(git_bump_default()).addCommand(git_confluence_default()).addCommand(gitj_install_skills_default()).addCommand(git_jira_default()).addCommand(git_lab_default()).action(() => {
|
|
4004
|
+
if (program2.opts().helpAll) {
|
|
4005
|
+
console.log(formatCommandTree(program2));
|
|
4006
|
+
return;
|
|
4007
|
+
}
|
|
3095
4008
|
program2.help();
|
|
3096
4009
|
});
|
|
3097
4010
|
return program2;
|
|
3098
4011
|
}
|
|
3099
|
-
var
|
|
3100
|
-
var command = create21();
|
|
4012
|
+
var command = create39();
|
|
3101
4013
|
await command.parseAsync(Bun.argv);
|
|
3102
4014
|
export {
|
|
3103
|
-
|
|
4015
|
+
create39 as create
|
|
3104
4016
|
};
|