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,14 @@ 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-start.ts
1894
- var exports_git_jira_start = {};
1895
- __export(exports_git_jira_start, {
1896
- default: () => {
1897
- {
1898
- return git_jira_start_default;
1899
- }
1900
- },
1901
- create: () => {
1902
- {
1903
- return create;
1904
- }
1905
- }
1906
- });
1894
+ var toKebab = function(s) {
1895
+ return s.replace(/([a-z]+)([A-Z]+)/g, "$1_2").toLowerCase().replace(/(\W+)/g, "-").replace(/-$/, "");
1896
+ };
1907
1897
  function create() {
1908
1898
  const program2 = new Command;
1909
- program2.name("start").argument("issue", "Issue ID").action(async (issueId) => {
1899
+ program2.name("start").description("Start working on an issue by creating a branch").argument("issue", "Issue ID").action(async (issueId) => {
1910
1900
  const issue = await getIssue(issueId);
1911
1901
  if (!issue) {
1912
1902
  console.error(`Issue ${issueId} not found`);
@@ -1918,22 +1908,10 @@ function create() {
1918
1908
  });
1919
1909
  return program2;
1920
1910
  }
1921
- var toKebab, git_jira_start_default;
1922
- var init_git_jira_start = __esm(() => {
1923
- init_esm();
1924
- init_git();
1925
- init_jira();
1926
- init_is_main();
1927
- toKebab = function(s) {
1928
- return s.replace(/([a-z]+)([A-Z]+)/g, "$1_2").toLowerCase().replace(/(\W+)/g, "-").replace(/-$/, "");
1929
- };
1930
- if (isMain("git-jira-issues")) {
1931
- create().parse(process.argv);
1932
- }
1933
- git_jira_start_default = create;
1934
- });
1935
- init_git_jira_start();
1936
-
1911
+ if (isMain("git-jira-issues")) {
1912
+ await create().parseAsync(Bun.argv);
1913
+ }
1914
+ var git_jira_start_default = create;
1937
1915
  export {
1938
1916
  git_jira_start_default as default,
1939
1917
  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_, 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,31 @@ 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
- // bin/git-jira-start.ts
1894
- var exports_git_jira_start = {};
1895
- __export(exports_git_jira_start, {
1896
- default: () => {
1897
- {
1898
- return git_jira_start_default;
1899
- }
1900
- },
1901
- create: () => {
1902
- {
1903
- return create;
1904
- }
1905
- }
1906
- });
1893
+ // bin/git-jira-issues.ts
1907
1894
  function create() {
1908
1895
  const program2 = new Command;
1909
- program2.name("start").argument("issue", "Issue ID").action(async (issueId) => {
1896
+ program2.name("issues").description("List your unresolved issues").action(async (options) => {
1897
+ const issues = await myUnresolvedIssues();
1898
+ console.log(`You have ${issues.length} unresolved issues`);
1899
+ issues.forEach((issue) => {
1900
+ console.log(`${issue.key}: ${issue.fields.summary}`);
1901
+ });
1902
+ });
1903
+ return program2;
1904
+ }
1905
+ if (isMain("git-jira-issues")) {
1906
+ await create().parseAsync(Bun.argv);
1907
+ }
1908
+ var git_jira_issues_default = create;
1909
+
1910
+ // bin/git-jira-start.ts
1911
+ var toKebab = function(s) {
1912
+ return s.replace(/([a-z]+)([A-Z]+)/g, "$1_2").toLowerCase().replace(/(\W+)/g, "-").replace(/-$/, "");
1913
+ };
1914
+ function create2() {
1915
+ const program2 = new Command;
1916
+ program2.name("start").description("Start working on an issue by creating a branch").argument("issue", "Issue ID").action(async (issueId) => {
1910
1917
  const issue = await getIssue(issueId);
1911
1918
  if (!issue) {
1912
1919
  console.error(`Issue ${issueId} not found`);
@@ -1918,74 +1925,16 @@ function create() {
1918
1925
  });
1919
1926
  return program2;
1920
1927
  }
1921
- var toKebab, git_jira_start_default;
1922
- var init_git_jira_start = __esm(() => {
1923
- init_esm();
1924
- init_git();
1925
- init_jira();
1926
- init_is_main();
1927
- toKebab = function(s) {
1928
- return s.replace(/([a-z]+)([A-Z]+)/g, "$1_2").toLowerCase().replace(/(\W+)/g, "-").replace(/-$/, "");
1929
- };
1930
- if (isMain("git-jira-issues")) {
1931
- create().parse(process.argv);
1932
- }
1933
- git_jira_start_default = create;
1934
- });
1935
-
1936
- // bin/git-jira-issues.ts
1937
- var exports_git_jira_issues = {};
1938
- __export(exports_git_jira_issues, {
1939
- default: () => {
1940
- {
1941
- return git_jira_issues_default;
1942
- }
1943
- },
1944
- create: () => {
1945
- {
1946
- return create2;
1947
- }
1948
- }
1949
- });
1950
- function create2() {
1951
- const program2 = new Command;
1952
- program2.name("issues").action(async (options) => {
1953
- const issues = await myUnresolvedIssues();
1954
- console.log(`You have ${issues.length} unresolved issues`);
1955
- issues.forEach((issue) => {
1956
- console.log(`${issue.key}: ${issue.fields.summary}`);
1957
- });
1958
- });
1959
- return program2;
1928
+ if (isMain("git-jira-issues")) {
1929
+ await create2().parseAsync(Bun.argv);
1960
1930
  }
1961
- var git_jira_issues_default;
1962
- var init_git_jira_issues = __esm(() => {
1963
- init_esm();
1964
- init_jira();
1965
- init_is_main();
1966
- if (isMain("git-jira-issues")) {
1967
- create2().parse(process.argv);
1968
- }
1969
- git_jira_issues_default = create2;
1970
- });
1931
+ var git_jira_start_default = create2;
1971
1932
 
1972
1933
  // bin/git-jira-issue.ts
1973
- var exports_git_jira_issue = {};
1974
- __export(exports_git_jira_issue, {
1975
- default: () => {
1976
- {
1977
- return git_jira_issue_default;
1978
- }
1979
- },
1980
- create: () => {
1981
- {
1982
- return create3;
1983
- }
1984
- }
1985
- });
1986
1934
  function create3() {
1987
1935
  const program2 = new Command;
1988
- 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) => {
1936
+ 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) => {
1937
+ const { host } = await getJiraConfig();
1989
1938
  const issue = await getIssue(issueId);
1990
1939
  if (!issue) {
1991
1940
  console.error(`Issue ${issueId} not found`);
@@ -1996,37 +1945,24 @@ function create3() {
1996
1945
  process.exit(0);
1997
1946
  }
1998
1947
  if (options.url) {
1999
- console.log(issue.self);
1948
+ console.log(`https://${host}/browse/${issueId}`);
2000
1949
  }
2001
1950
  });
2002
1951
  return program2;
2003
1952
  }
2004
- var git_jira_issue_default;
2005
- var init_git_jira_issue = __esm(() => {
2006
- init_esm();
2007
- init_jira();
2008
- init_is_main();
2009
- if (isMain("git-jira-issue")) {
2010
- create3().parse(process.argv);
2011
- }
2012
- git_jira_issue_default = create3;
2013
- });
1953
+ if (isMain("git-jira-issue")) {
1954
+ await create3().parseAsync(Bun.argv);
1955
+ }
1956
+ var git_jira_issue_default = create3;
2014
1957
 
2015
1958
  // bin/git-jira.ts
2016
- init_esm();
2017
- init_is_main();
2018
1959
  function create4() {
2019
1960
  const program2 = new Command;
2020
- program2.name("jira").addCommand(start).addCommand(issue).addCommand(issues).action(() => {
2021
- program2.help();
2022
- });
1961
+ program2.name("jira").description("A set of commands for working with Jira").addCommand(git_jira_start_default()).addCommand(git_jira_issue_default()).addCommand(git_jira_issues_default());
2023
1962
  return program2;
2024
1963
  }
2025
- var start = (await Promise.resolve().then(() => (init_git_jira_start(), exports_git_jira_start))).create();
2026
- var issue = (await Promise.resolve().then(() => (init_git_jira_issue(), exports_git_jira_issue))).create();
2027
- var issues = (await Promise.resolve().then(() => (init_git_jira_issues(), exports_git_jira_issues))).create();
2028
1964
  if (isMain("git-jira")) {
2029
- create4().parse(process.argv);
1965
+ await create4().parseAsync(Bun.argv);
2030
1966
  }
2031
1967
  var git_jira_default = create4;
2032
1968
  export {