ya-git-jira 1.3.0 → 1.5.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/bin/git-bump.ts +7 -4
- package/bin/{git-jira-issues.ts → git-jira-issue-list.ts} +10 -7
- package/bin/git-jira-issue-show.ts +40 -0
- package/bin/git-jira-issue.ts +14 -25
- package/bin/git-jira-start.ts +8 -5
- package/bin/git-jira.ts +9 -6
- package/bin/git-lab-group-list.ts +35 -0
- package/bin/git-lab-group.ts +25 -0
- package/bin/git-lab-merge-active.ts +41 -0
- package/bin/git-lab-merge-todo.ts +36 -0
- package/bin/git-lab-merge-train-list.ts +26 -0
- package/bin/git-lab-merge-train.ts +25 -0
- package/bin/git-lab-merge.ts +29 -0
- package/bin/git-lab-namespace-list.ts +27 -0
- package/bin/git-lab-namespace.ts +24 -0
- package/bin/{git-lab-projects.ts → git-lab-project-list.ts} +13 -10
- package/bin/git-lab-project-pipeline-list.ts +46 -0
- package/bin/git-lab-project-pipeline.ts +24 -0
- package/bin/git-lab-project-whereami.ts +43 -0
- package/bin/git-lab-project.ts +28 -0
- package/bin/git-lab-whoami.ts +8 -5
- package/bin/git-lab.ts +18 -8
- package/bin/gitj.ts +7 -5
- package/build.ts +1 -1
- package/bun.lockb +0 -0
- package/dist/bin/git-bump.js +55 -17
- package/dist/bin/{git-jira-issues.js → git-jira-issue-list.js} +71 -28
- package/dist/bin/{git-lab-mergetrain.js → git-jira-issue-show.js} +100 -43
- package/dist/bin/git-jira-issue.js +106 -33
- package/dist/bin/git-jira-start.js +70 -27
- package/dist/bin/git-jira.js +117 -59
- package/dist/bin/git-lab-group-list.js +2793 -0
- package/dist/bin/git-lab-group.js +2805 -0
- package/dist/bin/git-lab-groups.js +1992 -0
- package/dist/bin/git-lab-merge-active.js +2798 -0
- package/dist/bin/git-lab-merge-todo.js +2793 -0
- package/dist/bin/git-lab-merge-train-list.js +2754 -0
- package/dist/bin/git-lab-merge-train.js +2766 -0
- package/dist/bin/git-lab-merge.js +2865 -0
- package/dist/bin/git-lab-namespace-list.js +1967 -0
- package/dist/bin/git-lab-namespace.js +1979 -0
- package/dist/bin/git-lab-namespaces.js +1984 -0
- package/dist/bin/git-lab-project-list.js +2761 -0
- package/dist/bin/git-lab-project-pipeline-list.js +2800 -0
- package/dist/bin/git-lab-project-pipeline.js +2812 -0
- package/dist/bin/git-lab-project-whereami.js +2764 -0
- package/dist/bin/git-lab-project.js +2805 -0
- package/dist/bin/git-lab-projects-list.js +1996 -0
- package/dist/bin/git-lab-projects-whereami.js +1999 -0
- package/dist/bin/git-lab-projects.js +138 -35
- package/dist/bin/git-lab-whoami.js +100 -56
- package/dist/bin/git-lab.js +1123 -58
- package/dist/bin/gitj.js +1260 -172
- package/dist/index.js +881 -35
- package/index.ts +1 -1
- package/lib/gitlab/api.ts +46 -0
- package/lib/gitlab/config.ts +21 -0
- package/lib/gitlab/dlog.ts +2 -0
- package/lib/gitlab/group.ts +12 -0
- package/lib/gitlab/index.ts +8 -0
- package/lib/gitlab/merge-request.ts +31 -0
- package/lib/gitlab/merge-trains.ts +19 -0
- package/lib/gitlab/namespace.ts +12 -0
- package/lib/gitlab/pipeline.ts +32 -0
- package/lib/gitlab/project.ts +78 -0
- package/lib/gitlab/user.ts +13 -0
- package/lib/is_main.ts +21 -2
- package/lib/jira.ts +12 -7
- package/lib/package.ts +35 -0
- package/package.json +21 -4
- package/tests/all-help.test.ts +46 -0
- package/tests/git.test.ts +8 -7
- package/tests/gitj.test.ts +1 -1
- package/lib/gitlab.ts +0 -86
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -21,7 +21,7 @@ var __require = (id) => {
|
|
|
21
21
|
return import.meta.require(id);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
//
|
|
24
|
+
// bine_modules/commander/lib/suggestS
|
|
25
25
|
var require_error = __commonJS((exports) => {
|
|
26
26
|
class CommanderError extends Error {
|
|
27
27
|
constructor(exitCode, code, message) {
|
|
@@ -45,7 +45,7 @@ var require_error = __commonJS((exports) => {
|
|
|
45
45
|
exports.InvalidArgumentError = InvalidArgumentError;
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
//
|
|
48
|
+
// bine_modules/commander/lib/suggestSimi
|
|
49
49
|
var require_argument = __commonJS((exports) => {
|
|
50
50
|
var humanReadableArgName = function(arg) {
|
|
51
51
|
const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
|
|
@@ -124,7 +124,7 @@ var require_argument = __commonJS((exports) => {
|
|
|
124
124
|
exports.humanReadableArgName = humanReadableArgName;
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
-
//
|
|
127
|
+
// bine_modules/commander/lib/suggest
|
|
128
128
|
var require_help = __commonJS((exports) => {
|
|
129
129
|
var { humanReadableArgName } = require_argument();
|
|
130
130
|
|
|
@@ -364,7 +364,7 @@ var require_help = __commonJS((exports) => {
|
|
|
364
364
|
exports.Help = Help;
|
|
365
365
|
});
|
|
366
366
|
|
|
367
|
-
//
|
|
367
|
+
// bine_modules/commander/lib/suggestSi
|
|
368
368
|
var require_option = __commonJS((exports) => {
|
|
369
369
|
var camelcase = function(str) {
|
|
370
370
|
return str.split("-").reduce((str2, word) => {
|
|
@@ -516,7 +516,7 @@ var require_option = __commonJS((exports) => {
|
|
|
516
516
|
exports.DualOptions = DualOptions;
|
|
517
517
|
});
|
|
518
518
|
|
|
519
|
-
//
|
|
519
|
+
// bine_modules/commander/lib/suggestSimilar.js
|
|
520
520
|
var require_suggestSimilar = __commonJS((exports) => {
|
|
521
521
|
var editDistance = function(a, b) {
|
|
522
522
|
if (Math.abs(a.length - b.length) > maxDistance)
|
|
@@ -587,7 +587,7 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
587
587
|
exports.suggestSimilar = suggestSimilar;
|
|
588
588
|
});
|
|
589
589
|
|
|
590
|
-
//
|
|
590
|
+
// bine_modules/commander/lib/suggestSim
|
|
591
591
|
var require_command = __commonJS((exports) => {
|
|
592
592
|
var outputHelpIfRequested = function(cmd, args) {
|
|
593
593
|
const helpOption = cmd._hasHelpOption && args.find((arg) => arg === cmd._helpLongFlag || arg === cmd._helpShortFlag);
|
|
@@ -1765,7 +1765,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1765
1765
|
exports.Command = Command;
|
|
1766
1766
|
});
|
|
1767
1767
|
|
|
1768
|
-
//
|
|
1768
|
+
// bine_modules/commander/lib/sugg
|
|
1769
1769
|
var require_commander = __commonJS((exports, module) => {
|
|
1770
1770
|
var { Argument } = require_argument();
|
|
1771
1771
|
var { Command } = require_command();
|
|
@@ -1783,7 +1783,7 @@ var require_commander = __commonJS((exports, module) => {
|
|
|
1783
1783
|
exports.Option = Option;
|
|
1784
1784
|
});
|
|
1785
1785
|
|
|
1786
|
-
//
|
|
1786
|
+
// bine_modules/commander/lib/sug
|
|
1787
1787
|
var import_ = __toESM(require_commander(), 1);
|
|
1788
1788
|
var {
|
|
1789
1789
|
program,
|
|
@@ -1799,7 +1799,7 @@ var {
|
|
|
1799
1799
|
Help
|
|
1800
1800
|
} = import_.default;
|
|
1801
1801
|
|
|
1802
|
-
//
|
|
1802
|
+
// bine_modules
|
|
1803
1803
|
async function spawn(args, options = defaultOptions) {
|
|
1804
1804
|
const proc = Bun.spawn(args, { stdout: "pipe", stderr: "pipe" });
|
|
1805
1805
|
const stdout = new Response(proc.stdout);
|
|
@@ -1824,7 +1824,7 @@ var defaultOptions = {
|
|
|
1824
1824
|
expectQuiet: false
|
|
1825
1825
|
};
|
|
1826
1826
|
|
|
1827
|
-
//
|
|
1827
|
+
// bine_modul
|
|
1828
1828
|
async function getConfig(key) {
|
|
1829
1829
|
return doCommand(["git", "config", "--get", key]);
|
|
1830
1830
|
}
|
|
@@ -1838,7 +1838,7 @@ async function getRemote() {
|
|
|
1838
1838
|
return doCommand(["git", "ls-remote", "--get-url", "origin"]);
|
|
1839
1839
|
}
|
|
1840
1840
|
|
|
1841
|
-
//
|
|
1841
|
+
// bine_modules/
|
|
1842
1842
|
import path from "path";
|
|
1843
1843
|
async function getGitlabConfig() {
|
|
1844
1844
|
const host = await getConfig("gitlab.host");
|
|
@@ -1852,11 +1852,22 @@ async function getGitlabConfig() {
|
|
|
1852
1852
|
throw new Error("gitlab.token not in git config");
|
|
1853
1853
|
return { host, user, token };
|
|
1854
1854
|
}
|
|
1855
|
-
|
|
1855
|
+
var getNextLink = function(link) {
|
|
1856
|
+
if (!link) {
|
|
1857
|
+
return;
|
|
1858
|
+
}
|
|
1859
|
+
const regex = /<([^>]+)>; rel="next"/;
|
|
1860
|
+
const match = link.match(regex);
|
|
1861
|
+
const next = match ? match[1] : undefined;
|
|
1862
|
+
return next;
|
|
1863
|
+
};
|
|
1864
|
+
async function gitlabApi(endpoint) {
|
|
1856
1865
|
const method = "GET";
|
|
1857
1866
|
const { host, token } = await getGitlabConfig();
|
|
1858
1867
|
const base = `https://${host}/api/v4`;
|
|
1859
|
-
const
|
|
1868
|
+
const requested = 100;
|
|
1869
|
+
const sep = endpoint.includes("?") ? "&" : "?";
|
|
1870
|
+
const uri = `${base}/${endpoint}${sep}per_page=${requested}`;
|
|
1860
1871
|
const headers = new Headers;
|
|
1861
1872
|
headers.append("Accept", "application/json");
|
|
1862
1873
|
headers.append("Private-Token", token);
|
|
@@ -1864,19 +1875,37 @@ async function get(endpoint) {
|
|
|
1864
1875
|
method,
|
|
1865
1876
|
headers
|
|
1866
1877
|
};
|
|
1867
|
-
|
|
1878
|
+
let request = new Request(uri, options);
|
|
1868
1879
|
const response = await fetch(request);
|
|
1869
|
-
|
|
1880
|
+
let link = getNextLink(response.headers.get("Link"));
|
|
1881
|
+
let partial = await response.json();
|
|
1882
|
+
let result = partial;
|
|
1883
|
+
while (partial.length == requested && link) {
|
|
1884
|
+
let request2 = new Request(link, options);
|
|
1885
|
+
const next_response = await fetch(request2);
|
|
1886
|
+
link = getNextLink(next_response.headers.get("Link"));
|
|
1887
|
+
partial = await next_response.json();
|
|
1888
|
+
result = result.concat(partial);
|
|
1889
|
+
}
|
|
1890
|
+
return result;
|
|
1870
1891
|
}
|
|
1871
1892
|
async function whoami() {
|
|
1872
|
-
return await
|
|
1893
|
+
return await gitlabApi("/user");
|
|
1873
1894
|
}
|
|
1874
|
-
async function getProjects(
|
|
1875
|
-
|
|
1876
|
-
if (
|
|
1877
|
-
|
|
1895
|
+
async function getProjects(match) {
|
|
1896
|
+
const projects = await gitlabApi(`/projects?membership=true&simple=true`);
|
|
1897
|
+
if (!projects) {
|
|
1898
|
+
throw new Error(`No projects!`);
|
|
1899
|
+
} else if (!Array.isArray(projects)) {
|
|
1900
|
+
console.log(projects);
|
|
1901
|
+
throw new Error(`Projects is not an array!`);
|
|
1878
1902
|
}
|
|
1879
|
-
|
|
1903
|
+
const projs = projects;
|
|
1904
|
+
console.log(`Searching within a set of ${projs.length} projects for ${match}`);
|
|
1905
|
+
const filtered = projs.filter((p) => {
|
|
1906
|
+
return p.path_with_namespace.toLowerCase().includes(match.toLowerCase());
|
|
1907
|
+
});
|
|
1908
|
+
return filtered;
|
|
1880
1909
|
}
|
|
1881
1910
|
async function findProject(ssh_url) {
|
|
1882
1911
|
const parts = ssh_url.split(":");
|
|
@@ -1884,31 +1913,63 @@ async function findProject(ssh_url) {
|
|
|
1884
1913
|
throw new Error(`${ssh_url} is invalid, could not be split into two parts at :`);
|
|
1885
1914
|
}
|
|
1886
1915
|
const name = path.basename(parts[1], ".git");
|
|
1887
|
-
const projects = await getProjects(
|
|
1916
|
+
const projects = await getProjects(name);
|
|
1888
1917
|
const project = projects.find((p) => {
|
|
1889
1918
|
return p.ssh_url_to_repo === ssh_url;
|
|
1890
1919
|
});
|
|
1920
|
+
return project;
|
|
1921
|
+
}
|
|
1922
|
+
async function projectScopedGet(endpoint) {
|
|
1923
|
+
const method = "GET";
|
|
1924
|
+
const { host, token } = await getGitlabConfig();
|
|
1925
|
+
const remote = await getRemote();
|
|
1926
|
+
const project = await findProject(remote);
|
|
1891
1927
|
if (!project) {
|
|
1892
|
-
throw new Error(`
|
|
1928
|
+
throw new Error(`Could not find project for remote ${remote}`);
|
|
1893
1929
|
}
|
|
1894
|
-
|
|
1930
|
+
const base = `https://${host}/api/v4/projects/${project.id}`;
|
|
1931
|
+
const uri = `${base}/${endpoint}`;
|
|
1932
|
+
const headers = new Headers;
|
|
1933
|
+
headers.append("Accept", "application/json");
|
|
1934
|
+
headers.append("Private-Token", token);
|
|
1935
|
+
const options = {
|
|
1936
|
+
method,
|
|
1937
|
+
headers
|
|
1938
|
+
};
|
|
1939
|
+
const request = new Request(uri, options);
|
|
1940
|
+
const response = await fetch(request);
|
|
1941
|
+
return await response.json();
|
|
1895
1942
|
}
|
|
1896
1943
|
async function getMergeRequest(id) {
|
|
1897
|
-
return await
|
|
1944
|
+
return await projectScopedGet(`/merge_requests/${id}`);
|
|
1945
|
+
}
|
|
1946
|
+
async function getNamespaces() {
|
|
1947
|
+
return await gitlabApi(`/namespaces`);
|
|
1948
|
+
}
|
|
1949
|
+
async function getGroups() {
|
|
1950
|
+
return await gitlabApi(`/groups`);
|
|
1898
1951
|
}
|
|
1899
1952
|
|
|
1900
|
-
//
|
|
1953
|
+
// bine_modules/c
|
|
1901
1954
|
import path2 from "path";
|
|
1955
|
+
var justBase = function(filename) {
|
|
1956
|
+
const ext = path2.extname(filename);
|
|
1957
|
+
const base = path2.basename(filename, ext);
|
|
1958
|
+
return base;
|
|
1959
|
+
};
|
|
1902
1960
|
function isMain(self) {
|
|
1903
|
-
const
|
|
1904
|
-
|
|
1961
|
+
const arg1 = Bun.argv[1];
|
|
1962
|
+
const argv1Base = justBase(arg1);
|
|
1963
|
+
const selfBase = justBase(self);
|
|
1964
|
+
const result = argv1Base === selfBase;
|
|
1965
|
+
return result;
|
|
1905
1966
|
}
|
|
1906
1967
|
|
|
1907
|
-
//
|
|
1968
|
+
// bine_modules/commander/lib/s
|
|
1908
1969
|
function create() {
|
|
1909
1970
|
const program2 = new Command;
|
|
1910
|
-
program2.name("
|
|
1911
|
-
const projects = await getProjects(
|
|
1971
|
+
program2.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) => {
|
|
1972
|
+
const projects = await getProjects(options.match);
|
|
1912
1973
|
if (!projects) {
|
|
1913
1974
|
console.error(`No projects!`);
|
|
1914
1975
|
process.exit(1);
|
|
@@ -1925,11 +1986,53 @@ function create() {
|
|
|
1925
1986
|
});
|
|
1926
1987
|
return program2;
|
|
1927
1988
|
}
|
|
1928
|
-
|
|
1989
|
+
var git_lab_projects_list_default = create;
|
|
1990
|
+
if (isMain("git-lab-projects-list")) {
|
|
1929
1991
|
await create().parseAsync(Bun.argv);
|
|
1930
1992
|
}
|
|
1931
|
-
|
|
1993
|
+
|
|
1994
|
+
// bine_modules/commander/lib/sugge
|
|
1995
|
+
function create2() {
|
|
1996
|
+
const program2 = new Command;
|
|
1997
|
+
program2.name("whereami").description("Show current project based on current directory").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
1998
|
+
const ssh_url = await getRemote();
|
|
1999
|
+
if (!ssh_url) {
|
|
2000
|
+
console.error(`No remote!`);
|
|
2001
|
+
process.exit(1);
|
|
2002
|
+
}
|
|
2003
|
+
console.log(`Remote: ${ssh_url}`);
|
|
2004
|
+
const project = await findProject(ssh_url);
|
|
2005
|
+
if (!project) {
|
|
2006
|
+
console.error(`No project!`);
|
|
2007
|
+
process.exit(1);
|
|
2008
|
+
}
|
|
2009
|
+
if (options.verbose) {
|
|
2010
|
+
console.log(project);
|
|
2011
|
+
} else {
|
|
2012
|
+
const { id, name, path_with_namespace, ssh_url_to_repo } = project;
|
|
2013
|
+
console.log({ id, name, path_with_namespace, ssh_url_to_repo });
|
|
2014
|
+
}
|
|
2015
|
+
});
|
|
2016
|
+
return program2;
|
|
2017
|
+
}
|
|
2018
|
+
var git_lab_projects_whereami_default = create2;
|
|
2019
|
+
if (isMain("git-lab-projects-whereami")) {
|
|
2020
|
+
await create2().parseAsync(Bun.argv);
|
|
2021
|
+
}
|
|
2022
|
+
|
|
2023
|
+
// bine_modules/commander/
|
|
2024
|
+
function create3() {
|
|
2025
|
+
const program2 = new Command;
|
|
2026
|
+
program2.name("projects").description("Commands for working with GitLab projects").addCommand(git_lab_projects_list_default()).addCommand(git_lab_projects_whereami_default()).action(() => {
|
|
2027
|
+
program2.help();
|
|
2028
|
+
});
|
|
2029
|
+
return program2;
|
|
2030
|
+
}
|
|
2031
|
+
var git_lab_projects_default = create3;
|
|
2032
|
+
if (isMain("git-lab-projects")) {
|
|
2033
|
+
await create3().parseAsync(Bun.argv);
|
|
2034
|
+
}
|
|
1932
2035
|
export {
|
|
1933
2036
|
git_lab_projects_default as default,
|
|
1934
|
-
create
|
|
2037
|
+
create3 as create
|
|
1935
2038
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -21,7 +21,7 @@ var __require = (id) => {
|
|
|
21
21
|
return import.meta.require(id);
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
//
|
|
24
|
+
// bine_modules/commander/lib/suggestS
|
|
25
25
|
var require_error = __commonJS((exports) => {
|
|
26
26
|
class CommanderError extends Error {
|
|
27
27
|
constructor(exitCode, code, message) {
|
|
@@ -45,7 +45,7 @@ var require_error = __commonJS((exports) => {
|
|
|
45
45
|
exports.InvalidArgumentError = InvalidArgumentError;
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
//
|
|
48
|
+
// bine_modules/commander/lib/suggestSimi
|
|
49
49
|
var require_argument = __commonJS((exports) => {
|
|
50
50
|
var humanReadableArgName = function(arg) {
|
|
51
51
|
const nameOutput = arg.name() + (arg.variadic === true ? "..." : "");
|
|
@@ -124,7 +124,7 @@ var require_argument = __commonJS((exports) => {
|
|
|
124
124
|
exports.humanReadableArgName = humanReadableArgName;
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
-
//
|
|
127
|
+
// bine_modules/commander/lib/suggest
|
|
128
128
|
var require_help = __commonJS((exports) => {
|
|
129
129
|
var { humanReadableArgName } = require_argument();
|
|
130
130
|
|
|
@@ -364,7 +364,7 @@ var require_help = __commonJS((exports) => {
|
|
|
364
364
|
exports.Help = Help;
|
|
365
365
|
});
|
|
366
366
|
|
|
367
|
-
//
|
|
367
|
+
// bine_modules/commander/lib/suggestSi
|
|
368
368
|
var require_option = __commonJS((exports) => {
|
|
369
369
|
var camelcase = function(str) {
|
|
370
370
|
return str.split("-").reduce((str2, word) => {
|
|
@@ -516,7 +516,7 @@ var require_option = __commonJS((exports) => {
|
|
|
516
516
|
exports.DualOptions = DualOptions;
|
|
517
517
|
});
|
|
518
518
|
|
|
519
|
-
//
|
|
519
|
+
// bine_modules/commander/lib/suggestSimilar.js
|
|
520
520
|
var require_suggestSimilar = __commonJS((exports) => {
|
|
521
521
|
var editDistance = function(a, b) {
|
|
522
522
|
if (Math.abs(a.length - b.length) > maxDistance)
|
|
@@ -587,7 +587,7 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
587
587
|
exports.suggestSimilar = suggestSimilar;
|
|
588
588
|
});
|
|
589
589
|
|
|
590
|
-
//
|
|
590
|
+
// bine_modules/commander/lib/suggestSim
|
|
591
591
|
var require_command = __commonJS((exports) => {
|
|
592
592
|
var outputHelpIfRequested = function(cmd, args) {
|
|
593
593
|
const helpOption = cmd._hasHelpOption && args.find((arg) => arg === cmd._helpLongFlag || arg === cmd._helpShortFlag);
|
|
@@ -1765,7 +1765,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1765
1765
|
exports.Command = Command;
|
|
1766
1766
|
});
|
|
1767
1767
|
|
|
1768
|
-
//
|
|
1768
|
+
// bine_modules/commander/lib/sugg
|
|
1769
1769
|
var require_commander = __commonJS((exports, module) => {
|
|
1770
1770
|
var { Argument } = require_argument();
|
|
1771
1771
|
var { Command } = require_command();
|
|
@@ -1783,7 +1783,7 @@ var require_commander = __commonJS((exports, module) => {
|
|
|
1783
1783
|
exports.Option = Option;
|
|
1784
1784
|
});
|
|
1785
1785
|
|
|
1786
|
-
//
|
|
1786
|
+
// bine_modules/commander/lib/sug
|
|
1787
1787
|
var import_ = __toESM(require_commander(), 1);
|
|
1788
1788
|
var {
|
|
1789
1789
|
program,
|
|
@@ -1799,7 +1799,36 @@ var {
|
|
|
1799
1799
|
Help
|
|
1800
1800
|
} = import_.default;
|
|
1801
1801
|
|
|
1802
|
-
//
|
|
1802
|
+
// bine_modules/c
|
|
1803
|
+
import path from "path";
|
|
1804
|
+
import fs from "fs";
|
|
1805
|
+
function findPackageJson() {
|
|
1806
|
+
const cwd = import.meta.dir;
|
|
1807
|
+
let dir = cwd;
|
|
1808
|
+
while (dir !== "/") {
|
|
1809
|
+
const packageJson = path.join(dir, "package.json");
|
|
1810
|
+
if (fs.existsSync(packageJson)) {
|
|
1811
|
+
return packageJson;
|
|
1812
|
+
}
|
|
1813
|
+
dir = path.dirname(dir);
|
|
1814
|
+
}
|
|
1815
|
+
return null;
|
|
1816
|
+
}
|
|
1817
|
+
async function getPackageJson() {
|
|
1818
|
+
const packagePath = findPackageJson();
|
|
1819
|
+
if (!packagePath) {
|
|
1820
|
+
throw new Error(`No package.json found in ${import.meta.dir} or any parent directory`);
|
|
1821
|
+
}
|
|
1822
|
+
const packageJsonText = fs.readFileSync(packagePath, "utf8");
|
|
1823
|
+
return JSON.parse(packageJsonText);
|
|
1824
|
+
}
|
|
1825
|
+
async function getPackageVersion() {
|
|
1826
|
+
const packageJson = await packageJsonPromise;
|
|
1827
|
+
return packageJson.version;
|
|
1828
|
+
}
|
|
1829
|
+
var packageJsonPromise = getPackageJson();
|
|
1830
|
+
|
|
1831
|
+
// bine_modules
|
|
1803
1832
|
async function spawn(args, options = defaultOptions) {
|
|
1804
1833
|
const proc = Bun.spawn(args, { stdout: "pipe", stderr: "pipe" });
|
|
1805
1834
|
const stdout = new Response(proc.stdout);
|
|
@@ -1824,7 +1853,7 @@ var defaultOptions = {
|
|
|
1824
1853
|
expectQuiet: false
|
|
1825
1854
|
};
|
|
1826
1855
|
|
|
1827
|
-
//
|
|
1856
|
+
// bine_modul
|
|
1828
1857
|
async function getConfig(key) {
|
|
1829
1858
|
return doCommand(["git", "config", "--get", key]);
|
|
1830
1859
|
}
|
|
@@ -1838,25 +1867,44 @@ async function getRemote() {
|
|
|
1838
1867
|
return doCommand(["git", "ls-remote", "--get-url", "origin"]);
|
|
1839
1868
|
}
|
|
1840
1869
|
|
|
1841
|
-
//
|
|
1842
|
-
import path from "path";
|
|
1870
|
+
// bine_modules/command
|
|
1843
1871
|
async function getGitlabConfig() {
|
|
1844
|
-
const host = await
|
|
1872
|
+
const host = await hostP;
|
|
1845
1873
|
if (!host)
|
|
1846
1874
|
throw new Error("gitlab.host not in git config");
|
|
1847
|
-
const user = await
|
|
1875
|
+
const user = await userP;
|
|
1848
1876
|
if (!user)
|
|
1849
1877
|
throw new Error("user.email not in git config");
|
|
1850
|
-
const token = await
|
|
1878
|
+
const token = await tokenP;
|
|
1851
1879
|
if (!token)
|
|
1852
1880
|
throw new Error("gitlab.token not in git config");
|
|
1853
1881
|
return { host, user, token };
|
|
1854
1882
|
}
|
|
1855
|
-
|
|
1883
|
+
var hostP = getConfig("gitlab.host");
|
|
1884
|
+
var userP = getConfig("user.email");
|
|
1885
|
+
var tokenP = getConfig("gitlab.token");
|
|
1886
|
+
|
|
1887
|
+
// bine_modules/comm
|
|
1888
|
+
var getNextLink = function(link) {
|
|
1889
|
+
if (!link) {
|
|
1890
|
+
return;
|
|
1891
|
+
}
|
|
1892
|
+
const regex = /<([^>]+)>; rel="next"/;
|
|
1893
|
+
const match = link.match(regex);
|
|
1894
|
+
const next = match ? match[1] : undefined;
|
|
1895
|
+
return next;
|
|
1896
|
+
};
|
|
1897
|
+
async function gitlabApi(endpoint) {
|
|
1898
|
+
if (endpoint.startsWith("/")) {
|
|
1899
|
+
console.warn(`gitlabApi: endpoint ${endpoint} starts with /, removing it`);
|
|
1900
|
+
endpoint = endpoint.slice(1);
|
|
1901
|
+
}
|
|
1856
1902
|
const method = "GET";
|
|
1857
1903
|
const { host, token } = await getGitlabConfig();
|
|
1858
1904
|
const base = `https://${host}/api/v4`;
|
|
1859
|
-
const
|
|
1905
|
+
const requested = 100;
|
|
1906
|
+
const sep = endpoint.includes("?") ? "&" : "?";
|
|
1907
|
+
const uri = `${base}/${endpoint}${sep}per_page=${requested}`;
|
|
1860
1908
|
const headers = new Headers;
|
|
1861
1909
|
headers.append("Accept", "application/json");
|
|
1862
1910
|
headers.append("Private-Token", token);
|
|
@@ -1864,68 +1912,64 @@ async function get(endpoint) {
|
|
|
1864
1912
|
method,
|
|
1865
1913
|
headers
|
|
1866
1914
|
};
|
|
1867
|
-
|
|
1915
|
+
let request = new Request(uri, options);
|
|
1868
1916
|
const response = await fetch(request);
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
}
|
|
1879
|
-
return await get(`/projects?visibility=private&membership=true&simple=true${search}`);
|
|
1880
|
-
}
|
|
1881
|
-
async function findProject(ssh_url) {
|
|
1882
|
-
const parts = ssh_url.split(":");
|
|
1883
|
-
if (parts.length != 2) {
|
|
1884
|
-
throw new Error(`${ssh_url} is invalid, could not be split into two parts at :`);
|
|
1885
|
-
}
|
|
1886
|
-
const name = path.basename(parts[1], ".git");
|
|
1887
|
-
const projects = await getProjects([name]);
|
|
1888
|
-
const project = projects.find((p) => {
|
|
1889
|
-
return p.ssh_url_to_repo === ssh_url;
|
|
1890
|
-
});
|
|
1891
|
-
if (!project) {
|
|
1892
|
-
throw new Error(`No project with ssh_url_to_repo ${ssh_url} found`);
|
|
1917
|
+
let link = getNextLink(response.headers.get("Link"));
|
|
1918
|
+
let partial = await response.json();
|
|
1919
|
+
let result = partial;
|
|
1920
|
+
while (partial.length == requested && link) {
|
|
1921
|
+
let request2 = new Request(link, options);
|
|
1922
|
+
const next_response = await fetch(request2);
|
|
1923
|
+
link = getNextLink(next_response.headers.get("Link"));
|
|
1924
|
+
partial = await next_response.json();
|
|
1925
|
+
result = result.concat(partial);
|
|
1893
1926
|
}
|
|
1894
|
-
return
|
|
1927
|
+
return result;
|
|
1895
1928
|
}
|
|
1896
|
-
|
|
1897
|
-
|
|
1929
|
+
|
|
1930
|
+
// bine_modules/comma
|
|
1931
|
+
async function whoami() {
|
|
1932
|
+
return await gitlabApi("user");
|
|
1898
1933
|
}
|
|
1899
1934
|
|
|
1900
|
-
//
|
|
1935
|
+
// bine_modules/c
|
|
1901
1936
|
import path2 from "path";
|
|
1937
|
+
var justBase = function(filename) {
|
|
1938
|
+
const ext = path2.extname(filename);
|
|
1939
|
+
const base = path2.basename(filename, ext);
|
|
1940
|
+
return base;
|
|
1941
|
+
};
|
|
1902
1942
|
function isMain(self) {
|
|
1903
|
-
const
|
|
1904
|
-
|
|
1943
|
+
const arg1 = Bun.argv[1];
|
|
1944
|
+
const argv1Base = justBase(arg1);
|
|
1945
|
+
const selfBase = justBase(self);
|
|
1946
|
+
const result = argv1Base === selfBase;
|
|
1947
|
+
return result;
|
|
1905
1948
|
}
|
|
1906
1949
|
|
|
1907
|
-
//
|
|
1950
|
+
// bine_modules/commande
|
|
1908
1951
|
function create() {
|
|
1909
1952
|
const program2 = new Command;
|
|
1910
|
-
program2.name("whoami").description("get GitLab user information for current user").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
1911
|
-
const
|
|
1912
|
-
if (!
|
|
1953
|
+
program2.version(version).name("whoami").description("get GitLab user information for current user").option("-v, --verbose", "Verbose output").action(async (options) => {
|
|
1954
|
+
const user2 = await whoami();
|
|
1955
|
+
if (!user2) {
|
|
1913
1956
|
console.error(`No user!`);
|
|
1914
1957
|
process.exit(1);
|
|
1915
1958
|
}
|
|
1916
1959
|
if (options.verbose) {
|
|
1917
|
-
console.log(
|
|
1960
|
+
console.log(user2);
|
|
1918
1961
|
process.exit(0);
|
|
1919
1962
|
} else {
|
|
1920
|
-
console.log(
|
|
1963
|
+
console.log(user2.username);
|
|
1921
1964
|
}
|
|
1922
1965
|
});
|
|
1923
1966
|
return program2;
|
|
1924
1967
|
}
|
|
1968
|
+
var version = await getPackageVersion();
|
|
1969
|
+
var git_lab_whoami_default = create;
|
|
1925
1970
|
if (isMain("git-lab-whoami")) {
|
|
1926
1971
|
await create().parseAsync(Bun.argv);
|
|
1927
1972
|
}
|
|
1928
|
-
var git_lab_whoami_default = create;
|
|
1929
1973
|
export {
|
|
1930
1974
|
git_lab_whoami_default as default,
|
|
1931
1975
|
create
|