ya-git-jira 1.2.0 → 1.3.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.
@@ -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_, program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help;
1798
- var init_esm = __esm(() => {
1799
- import_ = __toESM(require_commander(), 1);
1800
- ({
1801
- program,
1802
- createCommand,
1803
- createArgument,
1804
- createOption,
1805
- CommanderError,
1806
- InvalidArgumentError,
1807
- InvalidOptionArgumentError,
1808
- Command,
1809
- Argument,
1810
- Option,
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 doCommand(args) {
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.trim();
1821
+ return out;
1824
1822
  }
1825
- var init_spawn = __esm(() => {
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
- var init_git = __esm(() => {
1846
- init_spawn();
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(issue.self);
1908
+ console.log(`https://${host}/browse/${issueId}`);
1921
1909
  }
1922
1910
  });
1923
1911
  return program2;
1924
1912
  }
1925
- var git_jira_issue_default;
1926
- var init_git_jira_issue = __esm(() => {
1927
- init_esm();
1928
- init_jira();
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
@@ -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) => {
@@ -646,7 +636,7 @@ var require_command = __commonJS((exports) => {
646
636
  var childProcess = import.meta.require("child_process");
647
637
  var path = import.meta.require("path");
648
638
  var fs = import.meta.require("fs");
649
- var process2 = import.meta.require("process");
639
+ var process = import.meta.require("process");
650
640
  var { Argument, humanReadableArgName } = require_argument();
651
641
  var { CommanderError } = require_error();
652
642
  var { Help } = require_help();
@@ -687,10 +677,10 @@ var require_command = __commonJS((exports) => {
687
677
  this._showHelpAfterError = false;
688
678
  this._showSuggestionAfterError = true;
689
679
  this._outputConfiguration = {
690
- writeOut: (str) => process2.stdout.write(str),
691
- writeErr: (str) => process2.stderr.write(str),
692
- getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : undefined,
693
- getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : undefined,
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,
694
684
  outputError: (str, write) => write(str)
695
685
  };
696
686
  this._hidden = false;
@@ -873,7 +863,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
873
863
  if (this._exitCallback) {
874
864
  this._exitCallback(new CommanderError(exitCode, code, message));
875
865
  }
876
- process2.exit(exitCode);
866
+ process.exit(exitCode);
877
867
  }
878
868
  action(fn) {
879
869
  const listener = (args) => {
@@ -1038,8 +1028,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1038
1028
  }
1039
1029
  parseOptions = parseOptions || {};
1040
1030
  if (argv === undefined) {
1041
- argv = process2.argv;
1042
- if (process2.versions && process2.versions.electron) {
1031
+ argv = process.argv;
1032
+ if (process.versions && process.versions.electron) {
1043
1033
  parseOptions.from = "electron";
1044
1034
  }
1045
1035
  }
@@ -1052,7 +1042,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1052
1042
  userArgs = argv.slice(2);
1053
1043
  break;
1054
1044
  case "electron":
1055
- if (process2.defaultApp) {
1045
+ if (process.defaultApp) {
1056
1046
  this._scriptPath = argv[1];
1057
1047
  userArgs = argv.slice(2);
1058
1048
  } else {
@@ -1120,23 +1110,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
1120
1110
  }
1121
1111
  launchWithNode = sourceExt.includes(path.extname(executableFile));
1122
1112
  let proc;
1123
- if (process2.platform !== "win32") {
1113
+ if (process.platform !== "win32") {
1124
1114
  if (launchWithNode) {
1125
1115
  args.unshift(executableFile);
1126
- args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1127
- proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" });
1116
+ args = incrementNodeInspectorPort(process.execArgv).concat(args);
1117
+ proc = childProcess.spawn(process.argv[0], args, { stdio: "inherit" });
1128
1118
  } else {
1129
1119
  proc = childProcess.spawn(executableFile, args, { stdio: "inherit" });
1130
1120
  }
1131
1121
  } else {
1132
1122
  args.unshift(executableFile);
1133
- args = incrementNodeInspectorPort(process2.execArgv).concat(args);
1134
- proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" });
1123
+ args = incrementNodeInspectorPort(process.execArgv).concat(args);
1124
+ proc = childProcess.spawn(process.execPath, args, { stdio: "inherit" });
1135
1125
  }
1136
1126
  if (!proc.killed) {
1137
1127
  const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"];
1138
1128
  signals.forEach((signal) => {
1139
- process2.on(signal, () => {
1129
+ process.on(signal, () => {
1140
1130
  if (proc.killed === false && proc.exitCode === null) {
1141
1131
  proc.kill(signal);
1142
1132
  }
@@ -1145,10 +1135,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
1145
1135
  }
1146
1136
  const exitCallback = this._exitCallback;
1147
1137
  if (!exitCallback) {
1148
- proc.on("close", process2.exit.bind(process2));
1138
+ proc.on("close", process.exit.bind(process));
1149
1139
  } else {
1150
1140
  proc.on("close", () => {
1151
- exitCallback(new CommanderError(process2.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
1141
+ exitCallback(new CommanderError(process.exitCode || 0, "commander.executeSubCommandAsync", "(close)"));
1152
1142
  });
1153
1143
  }
1154
1144
  proc.on("error", (err) => {
@@ -1163,7 +1153,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1163
1153
  throw new Error(`'${executableFile}' not executable`);
1164
1154
  }
1165
1155
  if (!exitCallback) {
1166
- process2.exit(1);
1156
+ process.exit(1);
1167
1157
  } else {
1168
1158
  const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)");
1169
1159
  wrappedError.nestedError = err;
@@ -1515,11 +1505,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1515
1505
  }
1516
1506
  _parseOptionsEnv() {
1517
1507
  this.options.forEach((option) => {
1518
- if (option.envVar && (option.envVar in process2.env)) {
1508
+ if (option.envVar && (option.envVar in process.env)) {
1519
1509
  const optionKey = option.attributeName();
1520
1510
  if (this.getOptionValue(optionKey) === undefined || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) {
1521
1511
  if (option.required || option.optional) {
1522
- this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]);
1512
+ this.emit(`optionEnv:${option.name()}`, process.env[option.envVar]);
1523
1513
  } else {
1524
1514
  this.emit(`optionEnv:${option.name()}`);
1525
1515
  }
@@ -1745,7 +1735,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1745
1735
  }
1746
1736
  help(contextOptions) {
1747
1737
  this.outputHelp(contextOptions);
1748
- let exitCode = process2.exitCode || 0;
1738
+ let exitCode = process.exitCode || 0;
1749
1739
  if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) {
1750
1740
  exitCode = 1;
1751
1741
  }
@@ -1794,59 +1784,74 @@ var require_commander = __commonJS((exports, module) => {
1794
1784
  });
1795
1785
 
1796
1786
  // node_modules/commander/esm.mjs
1797
- var import_, program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help;
1798
- var init_esm = __esm(() => {
1799
- import_ = __toESM(require_commander(), 1);
1800
- ({
1801
- program,
1802
- createCommand,
1803
- createArgument,
1804
- createOption,
1805
- CommanderError,
1806
- InvalidArgumentError,
1807
- InvalidOptionArgumentError,
1808
- Command,
1809
- Argument,
1810
- Option,
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 doCommand(args) {
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.trim();
1821
+ return out;
1824
1822
  }
1825
- var init_spawn = __esm(() => {
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
- var init_git = __esm(() => {
1846
- init_spawn();
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,11 @@ 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-issues.ts
1894
- var exports_git_jira_issues = {};
1895
- __export(exports_git_jira_issues, {
1896
- default: () => {
1897
- {
1898
- return git_jira_issues_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("issues").action(async (options) => {
1896
+ program2.name("issues").description("List your unresolved issues").action(async (options) => {
1910
1897
  const issues = await myUnresolvedIssues();
1911
1898
  console.log(`You have ${issues.length} unresolved issues`);
1912
1899
  issues.forEach((issue) => {
@@ -1915,18 +1902,10 @@ function create() {
1915
1902
  });
1916
1903
  return program2;
1917
1904
  }
1918
- var git_jira_issues_default;
1919
- var init_git_jira_issues = __esm(() => {
1920
- init_esm();
1921
- init_jira();
1922
- init_is_main();
1923
- if (isMain("git-jira-issues")) {
1924
- create().parse(process.argv);
1925
- }
1926
- git_jira_issues_default = create;
1927
- });
1928
- init_git_jira_issues();
1929
-
1905
+ if (isMain("git-jira-issues")) {
1906
+ await create().parseAsync(Bun.argv);
1907
+ }
1908
+ var git_jira_issues_default = create;
1930
1909
  export {
1931
1910
  git_jira_issues_default as default,
1932
1911
  create