ya-git-jira 1.2.0 → 1.4.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/README.md +22 -3
- package/bin/git-bump.ts +5 -4
- package/bin/{git-jira-issues.ts → git-jira-issue-list.ts} +8 -7
- package/bin/git-jira-issue-show.ts +37 -0
- package/bin/git-jira-issue.ts +13 -23
- package/bin/git-jira-start.ts +6 -5
- package/bin/git-jira.ts +12 -15
- package/bin/git-lab-group-list.ts +32 -0
- package/bin/git-lab-group.ts +22 -0
- package/bin/git-lab-merge-active.ts +35 -0
- package/bin/git-lab-merge-todo.ts +33 -0
- package/bin/git-lab-merge-train.ts +19 -0
- package/bin/git-lab-merge.ts +22 -0
- package/bin/git-lab-namespace-list.ts +23 -0
- package/bin/git-lab-namespace.ts +22 -0
- package/bin/git-lab-project-list.ts +38 -0
- package/bin/git-lab-project-pipeline-list.ts +40 -0
- package/bin/git-lab-project-pipeline.ts +22 -0
- package/bin/git-lab-project-whereami.ts +40 -0
- package/bin/git-lab-project.ts +26 -0
- package/bin/git-lab-whoami.ts +34 -0
- package/bin/git-lab.ts +30 -0
- package/bin/gitj.ts +17 -14
- package/build.ts +17 -0
- package/bun.lockb +0 -0
- package/dist/bin/git-bump.js +79 -110
- package/dist/bin/git-jira-issue.js +55 -75
- package/dist/bin/git-jira-issues.js +74 -95
- package/dist/bin/git-jira-start.js +56 -78
- package/dist/bin/git-jira.js +82 -146
- package/dist/bin/git-lab-mergetrain.js +1906 -0
- package/dist/bin/git-lab-projects.js +1935 -0
- package/dist/bin/git-lab-whoami.js +1932 -0
- package/dist/bin/git-lab.js +1969 -0
- package/dist/bin/gitj.js +306 -93
- package/dist/index.js +106 -47
- package/index.ts +2 -0
- package/lib/git.ts +4 -13
- package/lib/gitlab.ts +209 -0
- package/lib/is_main.ts +21 -2
- package/lib/jira.ts +36 -22
- package/lib/json.ts +6 -0
- package/lib/spawn.ts +30 -4
- package/package.json +27 -8
- package/tests/all-help.test.ts +19 -0
- package/tests/git.test.ts +25 -0
- package/tests/gitj.test.ts +43 -0
- package/dist/bin/bundo.js +0 -45
package/bin/git-lab.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { Command } from 'commander'
|
|
4
|
+
import { isMain } from '../lib/is_main'
|
|
5
|
+
|
|
6
|
+
import groups from './git-lab-group'
|
|
7
|
+
import merges from './git-lab-merge'
|
|
8
|
+
import namespaces from './git-lab-namespace'
|
|
9
|
+
import projects from './git-lab-project'
|
|
10
|
+
import whoami from './git-lab-whoami'
|
|
11
|
+
|
|
12
|
+
export function create(): Command {
|
|
13
|
+
const program = new Command()
|
|
14
|
+
program
|
|
15
|
+
.name('lab')
|
|
16
|
+
.description('Commands for working with GitLab')
|
|
17
|
+
.addCommand(groups())
|
|
18
|
+
.addCommand(merges())
|
|
19
|
+
.addCommand(namespaces())
|
|
20
|
+
.addCommand(projects())
|
|
21
|
+
.addCommand(whoami())
|
|
22
|
+
.action(() => program.help())
|
|
23
|
+
return program
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default create
|
|
27
|
+
|
|
28
|
+
if (isMain('git-lab')) {
|
|
29
|
+
await create().parseAsync(Bun.argv)
|
|
30
|
+
}
|
package/bin/gitj.ts
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import bump from './git-bump'
|
|
4
|
+
import jira from './git-jira'
|
|
5
|
+
import lab from './git-lab'
|
|
6
|
+
|
|
7
|
+
// This is the root of the CLI. It's a proxy for git and not strictly
|
|
8
|
+
// necessary, but it's useful to have for testing
|
|
9
|
+
// It's job is to parse the first command
|
|
4
10
|
// from the command line and then call the appropriate subcommand.
|
|
5
11
|
|
|
6
12
|
import { Command } from 'commander'
|
|
7
|
-
import { isMain } from '../lib/is_main'
|
|
8
|
-
|
|
9
|
-
if (isMain('gitj')) {
|
|
10
|
-
|
|
11
|
-
const program = new Command()
|
|
12
|
-
const bump = (await import('./git-bump')).create()
|
|
13
|
-
|
|
14
|
-
program
|
|
15
|
-
.executableDir('./bin')
|
|
16
|
-
.addCommand(bump)
|
|
17
|
-
.command('jira', 'A collection of jira utility commands', { executableFile: 'git-jira' })
|
|
18
13
|
|
|
14
|
+
export function create(): Command {
|
|
15
|
+
const program: Command = new Command()
|
|
19
16
|
program
|
|
17
|
+
.addCommand(bump())
|
|
18
|
+
.addCommand(jira())
|
|
19
|
+
.addCommand(lab())
|
|
20
20
|
.action(() => {
|
|
21
21
|
program.help()
|
|
22
22
|
})
|
|
23
|
-
|
|
23
|
+
return program
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
const command = create()
|
|
27
|
+
await command.parseAsync(Bun.argv)
|
package/build.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BuildOutput } from 'bun'
|
|
2
|
+
import { glob } from 'glob'
|
|
3
|
+
|
|
4
|
+
const result: BuildOutput = await Bun.build({
|
|
5
|
+
entrypoints: ['./index.ts', ...glob.sync('./bin/*.ts')],
|
|
6
|
+
outdir: './dist',
|
|
7
|
+
target: 'bun',
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
if (result.success) {
|
|
11
|
+
console.log('Build succeeded')
|
|
12
|
+
process.exit(0)
|
|
13
|
+
} else {
|
|
14
|
+
console.error('Build failed')
|
|
15
|
+
console.log(result)
|
|
16
|
+
process.exit(1)
|
|
17
|
+
}
|
package/bun.lockb
CHANGED
|
Binary file
|
package/dist/bin/git-bump.js
CHANGED
|
@@ -20,50 +20,6 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
|
|
|
20
20
|
var __require = (id) => {
|
|
21
21
|
return import.meta.require(id);
|
|
22
22
|
};
|
|
23
|
-
var __export = (target, all) => {
|
|
24
|
-
for (var name in all)
|
|
25
|
-
__defProp(target, name, {
|
|
26
|
-
get: all[name],
|
|
27
|
-
enumerable: true,
|
|
28
|
-
configurable: true,
|
|
29
|
-
set: (newValue) => all[name] = () => newValue
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
33
|
-
|
|
34
|
-
// lib/spawn.ts
|
|
35
|
-
async function doCommand(args) {
|
|
36
|
-
const proc = Bun.spawn(args);
|
|
37
|
-
const stdout = new Response(proc.stdout);
|
|
38
|
-
const stderr = new Response(proc.stderr);
|
|
39
|
-
const [out, err] = await Promise.all([stdout.text(), stderr.text()]);
|
|
40
|
-
if (err)
|
|
41
|
-
console.error(err);
|
|
42
|
-
return out.trim();
|
|
43
|
-
}
|
|
44
|
-
var init_spawn = __esm(() => {
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// lib/git.ts
|
|
48
|
-
async function getConfig(key) {
|
|
49
|
-
return doCommand(["git", "config", "--get", key]);
|
|
50
|
-
}
|
|
51
|
-
async function getJiraConfig() {
|
|
52
|
-
const host = await getConfig("jira.host");
|
|
53
|
-
const user = await getConfig("jira.user") || await getConfig("user.email");
|
|
54
|
-
const pat = await getConfig("jira.pat");
|
|
55
|
-
const token = Buffer.from(`${user}:${pat}`).toString("base64");
|
|
56
|
-
return { host, token };
|
|
57
|
-
}
|
|
58
|
-
async function createBranch(name) {
|
|
59
|
-
return doCommand(["git", "checkout", "-b", name]);
|
|
60
|
-
}
|
|
61
|
-
async function getCurrentBranch() {
|
|
62
|
-
return doCommand(["git", "rev-parse", "--abbrev-ref", "HEAD"]);
|
|
63
|
-
}
|
|
64
|
-
var init_git = __esm(() => {
|
|
65
|
-
init_spawn();
|
|
66
|
-
});
|
|
67
23
|
|
|
68
24
|
// node_modules/commander/lib/error.js
|
|
69
25
|
var require_error = __commonJS((exports) => {
|
|
@@ -680,7 +636,7 @@ var require_command = __commonJS((exports) => {
|
|
|
680
636
|
var childProcess = import.meta.require("child_process");
|
|
681
637
|
var path = import.meta.require("path");
|
|
682
638
|
var fs = import.meta.require("fs");
|
|
683
|
-
var
|
|
639
|
+
var process = import.meta.require("process");
|
|
684
640
|
var { Argument, humanReadableArgName } = require_argument();
|
|
685
641
|
var { CommanderError } = require_error();
|
|
686
642
|
var { Help } = require_help();
|
|
@@ -721,10 +677,10 @@ var require_command = __commonJS((exports) => {
|
|
|
721
677
|
this._showHelpAfterError = false;
|
|
722
678
|
this._showSuggestionAfterError = true;
|
|
723
679
|
this._outputConfiguration = {
|
|
724
|
-
writeOut: (str) =>
|
|
725
|
-
writeErr: (str) =>
|
|
726
|
-
getOutHelpWidth: () =>
|
|
727
|
-
getErrHelpWidth: () =>
|
|
680
|
+
writeOut: (str) => process.stdout.write(str),
|
|
681
|
+
writeErr: (str) => process.stderr.write(str),
|
|
682
|
+
getOutHelpWidth: () => process.stdout.isTTY ? process.stdout.columns : undefined,
|
|
683
|
+
getErrHelpWidth: () => process.stderr.isTTY ? process.stderr.columns : undefined,
|
|
728
684
|
outputError: (str, write) => write(str)
|
|
729
685
|
};
|
|
730
686
|
this._hidden = false;
|
|
@@ -907,7 +863,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
907
863
|
if (this._exitCallback) {
|
|
908
864
|
this._exitCallback(new CommanderError(exitCode, code, message));
|
|
909
865
|
}
|
|
910
|
-
|
|
866
|
+
process.exit(exitCode);
|
|
911
867
|
}
|
|
912
868
|
action(fn) {
|
|
913
869
|
const listener = (args) => {
|
|
@@ -1072,8 +1028,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1072
1028
|
}
|
|
1073
1029
|
parseOptions = parseOptions || {};
|
|
1074
1030
|
if (argv === undefined) {
|
|
1075
|
-
argv =
|
|
1076
|
-
if (
|
|
1031
|
+
argv = process.argv;
|
|
1032
|
+
if (process.versions && process.versions.electron) {
|
|
1077
1033
|
parseOptions.from = "electron";
|
|
1078
1034
|
}
|
|
1079
1035
|
}
|
|
@@ -1086,7 +1042,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1086
1042
|
userArgs = argv.slice(2);
|
|
1087
1043
|
break;
|
|
1088
1044
|
case "electron":
|
|
1089
|
-
if (
|
|
1045
|
+
if (process.defaultApp) {
|
|
1090
1046
|
this._scriptPath = argv[1];
|
|
1091
1047
|
userArgs = argv.slice(2);
|
|
1092
1048
|
} else {
|
|
@@ -1154,23 +1110,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1154
1110
|
}
|
|
1155
1111
|
launchWithNode = sourceExt.includes(path.extname(executableFile));
|
|
1156
1112
|
let proc;
|
|
1157
|
-
if (
|
|
1113
|
+
if (process.platform !== "win32") {
|
|
1158
1114
|
if (launchWithNode) {
|
|
1159
1115
|
args.unshift(executableFile);
|
|
1160
|
-
args = incrementNodeInspectorPort(
|
|
1161
|
-
proc = childProcess.spawn(
|
|
1116
|
+
args = incrementNodeInspectorPort(process.execArgv).concat(args);
|
|
1117
|
+
proc = childProcess.spawn(process.argv[0], args, { stdio: "inherit" });
|
|
1162
1118
|
} else {
|
|
1163
1119
|
proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
|
|
1164
1120
|
}
|
|
1165
1121
|
} else {
|
|
1166
1122
|
args.unshift(executableFile);
|
|
1167
|
-
args = incrementNodeInspectorPort(
|
|
1168
|
-
proc = childProcess.spawn(
|
|
1123
|
+
args = incrementNodeInspectorPort(process.execArgv).concat(args);
|
|
1124
|
+
proc = childProcess.spawn(process.execPath, args, { stdio: "inherit" });
|
|
1169
1125
|
}
|
|
1170
1126
|
if (!proc.killed) {
|
|
1171
1127
|
const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
|
|
1172
1128
|
signals.forEach((signal) => {
|
|
1173
|
-
|
|
1129
|
+
process.on(signal, () => {
|
|
1174
1130
|
if (proc.killed === false && proc.exitCode === null) {
|
|
1175
1131
|
proc.kill(signal);
|
|
1176
1132
|
}
|
|
@@ -1179,10 +1135,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1179
1135
|
}
|
|
1180
1136
|
const exitCallback = this._exitCallback;
|
|
1181
1137
|
if (!exitCallback) {
|
|
1182
|
-
proc.on("close",
|
|
1138
|
+
proc.on("close", process.exit.bind(process));
|
|
1183
1139
|
} else {
|
|
1184
1140
|
proc.on("close", () => {
|
|
1185
|
-
exitCallback(new CommanderError(
|
|
1141
|
+
exitCallback(new CommanderError(process.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
|
|
1186
1142
|
});
|
|
1187
1143
|
}
|
|
1188
1144
|
proc.on("error", (err) => {
|
|
@@ -1197,7 +1153,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1197
1153
|
throw new Error(`'${executableFile}' not executable`);
|
|
1198
1154
|
}
|
|
1199
1155
|
if (!exitCallback) {
|
|
1200
|
-
|
|
1156
|
+
process.exit(1);
|
|
1201
1157
|
} else {
|
|
1202
1158
|
const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
|
|
1203
1159
|
wrappedError.nestedError = err;
|
|
@@ -1549,11 +1505,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1549
1505
|
}
|
|
1550
1506
|
_parseOptionsEnv() {
|
|
1551
1507
|
this.options.forEach((option) => {
|
|
1552
|
-
if (option.envVar && (option.envVar in
|
|
1508
|
+
if (option.envVar && (option.envVar in process.env)) {
|
|
1553
1509
|
const optionKey = option.attributeName();
|
|
1554
1510
|
if (this.getOptionValue(optionKey) === undefined || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
|
|
1555
1511
|
if (option.required || option.optional) {
|
|
1556
|
-
this.emit(`optionEnv:${option.name()}`,
|
|
1512
|
+
this.emit(`optionEnv:${option.name()}`, process.env[option.envVar]);
|
|
1557
1513
|
} else {
|
|
1558
1514
|
this.emit(`optionEnv:${option.name()}`);
|
|
1559
1515
|
}
|
|
@@ -1779,7 +1735,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1779
1735
|
}
|
|
1780
1736
|
help(contextOptions) {
|
|
1781
1737
|
this.outputHelp(contextOptions);
|
|
1782
|
-
let exitCode =
|
|
1738
|
+
let exitCode = process.exitCode || 0;
|
|
1783
1739
|
if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
|
|
1784
1740
|
exitCode = 1;
|
|
1785
1741
|
}
|
|
@@ -1827,24 +1783,60 @@ var require_commander = __commonJS((exports, module) => {
|
|
|
1827
1783
|
exports.Option = Option;
|
|
1828
1784
|
});
|
|
1829
1785
|
|
|
1786
|
+
// lib/spawn.ts
|
|
1787
|
+
async function spawn(args, options = defaultOptions) {
|
|
1788
|
+
const proc = Bun.spawn(args, { stdout: "pipe", stderr: "pipe" });
|
|
1789
|
+
const stdout = new Response(proc.stdout);
|
|
1790
|
+
const stderr = new Response(proc.stderr);
|
|
1791
|
+
const [out, err, exitCode, signal] = await Promise.all([stdout.text(), stderr.text(), proc.exitCode, proc.signalCode]);
|
|
1792
|
+
let code = 0;
|
|
1793
|
+
if (exitCode !== null) {
|
|
1794
|
+
code = exitCode;
|
|
1795
|
+
}
|
|
1796
|
+
if (!out && !err && !options.expectQuiet) {
|
|
1797
|
+
console.warn(`No output from ${args.join(" ")}`);
|
|
1798
|
+
}
|
|
1799
|
+
return { out: out.trim(), err: err.trim(), code };
|
|
1800
|
+
}
|
|
1801
|
+
async function doCommand(args) {
|
|
1802
|
+
const { out, err } = await spawn(args);
|
|
1803
|
+
if (err)
|
|
1804
|
+
console.error(err);
|
|
1805
|
+
return out;
|
|
1806
|
+
}
|
|
1807
|
+
var defaultOptions = {
|
|
1808
|
+
expectQuiet: false
|
|
1809
|
+
};
|
|
1810
|
+
|
|
1811
|
+
// lib/git.ts
|
|
1812
|
+
async function getConfig(key) {
|
|
1813
|
+
return doCommand(["git", "config", "--get", key]);
|
|
1814
|
+
}
|
|
1815
|
+
async function createBranch(name) {
|
|
1816
|
+
return doCommand(["git", "checkout", "-b", name]);
|
|
1817
|
+
}
|
|
1818
|
+
async function getCurrentBranch() {
|
|
1819
|
+
return doCommand(["git", "rev-parse", "--abbrev-ref", "HEAD"]);
|
|
1820
|
+
}
|
|
1821
|
+
async function getRemote() {
|
|
1822
|
+
return doCommand(["git", "ls-remote", "--get-url", "origin"]);
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1830
1825
|
// node_modules/commander/esm.mjs
|
|
1831
|
-
var import_
|
|
1832
|
-
var
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
Help
|
|
1846
|
-
} = import_.default);
|
|
1847
|
-
});
|
|
1826
|
+
var import_ = __toESM(require_commander(), 1);
|
|
1827
|
+
var {
|
|
1828
|
+
program,
|
|
1829
|
+
createCommand,
|
|
1830
|
+
createArgument,
|
|
1831
|
+
createOption,
|
|
1832
|
+
CommanderError,
|
|
1833
|
+
InvalidArgumentError,
|
|
1834
|
+
InvalidOptionArgumentError,
|
|
1835
|
+
Command,
|
|
1836
|
+
Argument,
|
|
1837
|
+
Option,
|
|
1838
|
+
Help
|
|
1839
|
+
} = import_.default;
|
|
1848
1840
|
|
|
1849
1841
|
// lib/is_main.ts
|
|
1850
1842
|
import path from "path";
|
|
@@ -1852,26 +1844,11 @@ function isMain(self) {
|
|
|
1852
1844
|
const exe = path.basename(Bun.argv[1]).split(".")[0];
|
|
1853
1845
|
return exe == self || import.meta.main;
|
|
1854
1846
|
}
|
|
1855
|
-
var init_is_main = __esm(() => {
|
|
1856
|
-
});
|
|
1857
1847
|
|
|
1858
1848
|
// bin/git-bump.ts
|
|
1859
|
-
var exports_git_bump = {};
|
|
1860
|
-
__export(exports_git_bump, {
|
|
1861
|
-
default: () => {
|
|
1862
|
-
{
|
|
1863
|
-
return git_bump_default;
|
|
1864
|
-
}
|
|
1865
|
-
},
|
|
1866
|
-
create: () => {
|
|
1867
|
-
{
|
|
1868
|
-
return create;
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
});
|
|
1872
1849
|
function create() {
|
|
1873
1850
|
const program2 = new Command;
|
|
1874
|
-
program2.name("bump").action(async () => {
|
|
1851
|
+
program2.name("bump").description("Bump the version number in the current branch").action(async () => {
|
|
1875
1852
|
const currentBranch = await getCurrentBranch();
|
|
1876
1853
|
let stem = currentBranch;
|
|
1877
1854
|
let version = 1;
|
|
@@ -1885,18 +1862,10 @@ function create() {
|
|
|
1885
1862
|
});
|
|
1886
1863
|
return program2;
|
|
1887
1864
|
}
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
init_is_main();
|
|
1893
|
-
if (isMain("git-bump")) {
|
|
1894
|
-
create().parse(process.argv);
|
|
1895
|
-
}
|
|
1896
|
-
git_bump_default = create;
|
|
1897
|
-
});
|
|
1898
|
-
init_git_bump();
|
|
1899
|
-
|
|
1865
|
+
if (isMain("git-bump")) {
|
|
1866
|
+
await create().parseAsync(Bun.argv);
|
|
1867
|
+
}
|
|
1868
|
+
var git_bump_default = create;
|
|
1900
1869
|
export {
|
|
1901
1870
|
git_bump_default as default,
|
|
1902
1871
|
create
|
|
@@ -20,16 +20,6 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
|
|
|
20
20
|
var __require = (id) => {
|
|
21
21
|
return import.meta.require(id);
|
|
22
22
|
};
|
|
23
|
-
var __export = (target, all) => {
|
|
24
|
-
for (var name in all)
|
|
25
|
-
__defProp(target, name, {
|
|
26
|
-
get: all[name],
|
|
27
|
-
enumerable: true,
|
|
28
|
-
configurable: true,
|
|
29
|
-
set: (newValue) => all[name] = () => newValue
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
33
23
|
|
|
34
24
|
// node_modules/commander/lib/error.js
|
|
35
25
|
var require_error = __commonJS((exports) => {
|
|
@@ -1794,59 +1784,74 @@ var require_commander = __commonJS((exports, module) => {
|
|
|
1794
1784
|
});
|
|
1795
1785
|
|
|
1796
1786
|
// node_modules/commander/esm.mjs
|
|
1797
|
-
var import_
|
|
1798
|
-
var
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
Help
|
|
1812
|
-
} = import_.default);
|
|
1813
|
-
});
|
|
1787
|
+
var import_ = __toESM(require_commander(), 1);
|
|
1788
|
+
var {
|
|
1789
|
+
program,
|
|
1790
|
+
createCommand,
|
|
1791
|
+
createArgument,
|
|
1792
|
+
createOption,
|
|
1793
|
+
CommanderError,
|
|
1794
|
+
InvalidArgumentError,
|
|
1795
|
+
InvalidOptionArgumentError,
|
|
1796
|
+
Command,
|
|
1797
|
+
Argument,
|
|
1798
|
+
Option,
|
|
1799
|
+
Help
|
|
1800
|
+
} = import_.default;
|
|
1814
1801
|
|
|
1815
1802
|
// lib/spawn.ts
|
|
1816
|
-
async function
|
|
1817
|
-
const proc = Bun.spawn(args);
|
|
1803
|
+
async function spawn(args, options = defaultOptions) {
|
|
1804
|
+
const proc = Bun.spawn(args, { stdout: "pipe", stderr: "pipe" });
|
|
1818
1805
|
const stdout = new Response(proc.stdout);
|
|
1819
1806
|
const stderr = new Response(proc.stderr);
|
|
1820
|
-
const [out, err] = await Promise.all([stdout.text(), stderr.text()]);
|
|
1807
|
+
const [out, err, exitCode, signal] = await Promise.all([stdout.text(), stderr.text(), proc.exitCode, proc.signalCode]);
|
|
1808
|
+
let code = 0;
|
|
1809
|
+
if (exitCode !== null) {
|
|
1810
|
+
code = exitCode;
|
|
1811
|
+
}
|
|
1812
|
+
if (!out && !err && !options.expectQuiet) {
|
|
1813
|
+
console.warn(`No output from ${args.join(" ")}`);
|
|
1814
|
+
}
|
|
1815
|
+
return { out: out.trim(), err: err.trim(), code };
|
|
1816
|
+
}
|
|
1817
|
+
async function doCommand(args) {
|
|
1818
|
+
const { out, err } = await spawn(args);
|
|
1821
1819
|
if (err)
|
|
1822
1820
|
console.error(err);
|
|
1823
|
-
return out
|
|
1821
|
+
return out;
|
|
1824
1822
|
}
|
|
1825
|
-
var
|
|
1826
|
-
|
|
1823
|
+
var defaultOptions = {
|
|
1824
|
+
expectQuiet: false
|
|
1825
|
+
};
|
|
1827
1826
|
|
|
1828
1827
|
// lib/git.ts
|
|
1829
1828
|
async function getConfig(key) {
|
|
1830
1829
|
return doCommand(["git", "config", "--get", key]);
|
|
1831
1830
|
}
|
|
1832
|
-
async function getJiraConfig() {
|
|
1833
|
-
const host = await getConfig("jira.host");
|
|
1834
|
-
const user = await getConfig("jira.user") || await getConfig("user.email");
|
|
1835
|
-
const pat = await getConfig("jira.pat");
|
|
1836
|
-
const token = Buffer.from(`${user}:${pat}`).toString("base64");
|
|
1837
|
-
return { host, token };
|
|
1838
|
-
}
|
|
1839
1831
|
async function createBranch(name) {
|
|
1840
1832
|
return doCommand(["git", "checkout", "-b", name]);
|
|
1841
1833
|
}
|
|
1842
1834
|
async function getCurrentBranch() {
|
|
1843
1835
|
return doCommand(["git", "rev-parse", "--abbrev-ref", "HEAD"]);
|
|
1844
1836
|
}
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
}
|
|
1837
|
+
async function getRemote() {
|
|
1838
|
+
return doCommand(["git", "ls-remote", "--get-url", "origin"]);
|
|
1839
|
+
}
|
|
1848
1840
|
|
|
1849
1841
|
// lib/jira.ts
|
|
1842
|
+
async function getJiraConfig() {
|
|
1843
|
+
const host = await getConfig("jira.host");
|
|
1844
|
+
if (!host)
|
|
1845
|
+
throw new Error("jira.host not in git config");
|
|
1846
|
+
const user = await getConfig("jira.user") || await getConfig("user.email");
|
|
1847
|
+
if (!user)
|
|
1848
|
+
throw new Error("jira.user or user.email not in git config");
|
|
1849
|
+
const pat = await getConfig("jira.pat");
|
|
1850
|
+
if (!pat)
|
|
1851
|
+
throw new Error("jira.pat not in git config");
|
|
1852
|
+
const token = Buffer.from(`${user}:${pat}`).toString("base64");
|
|
1853
|
+
return { host, token };
|
|
1854
|
+
}
|
|
1850
1855
|
async function get(endpoint) {
|
|
1851
1856
|
const method = "GET";
|
|
1852
1857
|
const { host, token } = await getJiraConfig();
|
|
@@ -1877,9 +1882,6 @@ async function myUnresolvedIssues() {
|
|
|
1877
1882
|
const issues = await get(`/search?jql=${encodeURIComponent(jql)}`);
|
|
1878
1883
|
return issues.issues;
|
|
1879
1884
|
}
|
|
1880
|
-
var init_jira = __esm(() => {
|
|
1881
|
-
init_git();
|
|
1882
|
-
});
|
|
1883
1885
|
|
|
1884
1886
|
// lib/is_main.ts
|
|
1885
1887
|
import path from "path";
|
|
@@ -1887,26 +1889,12 @@ function isMain(self) {
|
|
|
1887
1889
|
const exe = path.basename(Bun.argv[1]).split(".")[0];
|
|
1888
1890
|
return exe == self || import.meta.main;
|
|
1889
1891
|
}
|
|
1890
|
-
var init_is_main = __esm(() => {
|
|
1891
|
-
});
|
|
1892
1892
|
|
|
1893
1893
|
// bin/git-jira-issue.ts
|
|
1894
|
-
var exports_git_jira_issue = {};
|
|
1895
|
-
__export(exports_git_jira_issue, {
|
|
1896
|
-
default: () => {
|
|
1897
|
-
{
|
|
1898
|
-
return git_jira_issue_default;
|
|
1899
|
-
}
|
|
1900
|
-
},
|
|
1901
|
-
create: () => {
|
|
1902
|
-
{
|
|
1903
|
-
return create;
|
|
1904
|
-
}
|
|
1905
|
-
}
|
|
1906
|
-
});
|
|
1907
1894
|
function create() {
|
|
1908
1895
|
const program2 = new Command;
|
|
1909
|
-
program2.name("issue").argument("issue", "Issue ID").option("-v, --verbose", "Verbose output").option("-u, --url", "Show the URL of the issue").action(async (issueId, options) => {
|
|
1896
|
+
program2.name("issue").description("Get information about an issue").argument("issue", "Issue ID").option("-v, --verbose", "Verbose output").option("-u, --url", "Show the URL of the issue").action(async (issueId, options) => {
|
|
1897
|
+
const { host } = await getJiraConfig();
|
|
1910
1898
|
const issue = await getIssue(issueId);
|
|
1911
1899
|
if (!issue) {
|
|
1912
1900
|
console.error(`Issue ${issueId} not found`);
|
|
@@ -1917,23 +1905,15 @@ function create() {
|
|
|
1917
1905
|
process.exit(0);
|
|
1918
1906
|
}
|
|
1919
1907
|
if (options.url) {
|
|
1920
|
-
console.log(
|
|
1908
|
+
console.log(`https://${host}/browse/${issueId}`);
|
|
1921
1909
|
}
|
|
1922
1910
|
});
|
|
1923
1911
|
return program2;
|
|
1924
1912
|
}
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
init_is_main();
|
|
1930
|
-
if (isMain("git-jira-issue")) {
|
|
1931
|
-
create().parse(process.argv);
|
|
1932
|
-
}
|
|
1933
|
-
git_jira_issue_default = create;
|
|
1934
|
-
});
|
|
1935
|
-
init_git_jira_issue();
|
|
1936
|
-
|
|
1913
|
+
if (isMain("git-jira-issue")) {
|
|
1914
|
+
await create().parseAsync(Bun.argv);
|
|
1915
|
+
}
|
|
1916
|
+
var git_jira_issue_default = create;
|
|
1937
1917
|
export {
|
|
1938
1918
|
git_jira_issue_default as default,
|
|
1939
1919
|
create
|