@nulab/bee 1.1.1 → 1.2.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/dist/activities-BPTHt_MD.mjs +69 -0
- package/dist/activities-CRiEq51-.mjs +72 -0
- package/dist/activities-DyOMqdsM.mjs +69 -0
- package/dist/activity-labels-CLFpxp8o.mjs +34 -0
- package/dist/add-Br-_TLRp.mjs +55 -0
- package/dist/add-CTmmy2t9.mjs +26 -0
- package/dist/add-user-BVWFcbH7.mjs +26 -0
- package/dist/api-DhA8avDD.mjs +134 -0
- package/dist/attachments-CnL8t9tK.mjs +50 -0
- package/dist/attachments-D8IoJjYE.mjs +50 -0
- package/dist/attachments-DfgEkAY2.mjs +46 -0
- package/dist/auth-5TJGBPxi.mjs +13 -0
- package/dist/bee-command-v0qvZeth.mjs +57 -0
- package/dist/browse-vgF6nz7X.mjs +304 -0
- package/dist/category-BZ7XdVgx.mjs +11 -0
- package/dist/clone-DAWVtVbZ.mjs +43 -0
- package/dist/close-cTyZPv77.mjs +37 -0
- package/dist/comment-CkYJYFrF.mjs +115 -0
- package/dist/comment-DzRBQNv8.mjs +102 -0
- package/dist/comments-SnOZ-EUJ.mjs +47 -0
- package/dist/common-options-BuYWxYdO.mjs +45 -0
- package/dist/completion-yX2VOQSl.mjs +113 -0
- package/dist/count-BI7ld4k5.mjs +50 -0
- package/dist/count-Bw0mVlxC.mjs +40 -0
- package/dist/count-CH_LN4k6.mjs +51 -0
- package/dist/count-CHzDiMV3.mjs +25 -0
- package/dist/count-DvmYzPD_.mjs +46 -0
- package/dist/create-BHjwacOk.mjs +47 -0
- package/dist/create-BXWATibN.mjs +41 -0
- package/dist/create-BtLVFmbR.mjs +29 -0
- package/dist/create-CoF2bahH.mjs +29 -0
- package/dist/create-DhAOhro9.mjs +60 -0
- package/dist/create-DtMLv7Wq.mjs +26 -0
- package/dist/create-PtahSFdG.mjs +66 -0
- package/dist/create-Y4vo2zwX.mjs +44 -0
- package/dist/create-vwRKZ3Lm.mjs +31 -0
- package/dist/dashboard-CYYU5Yii.mjs +97 -0
- package/dist/delete-BCAPHs-g.mjs +25 -0
- package/dist/delete-BHNt5SWa.mjs +24 -0
- package/dist/delete-BlmanW0H.mjs +25 -0
- package/dist/delete-Bxk14ntp.mjs +24 -0
- package/dist/delete-C05oMZEW.mjs +24 -0
- package/dist/delete-CMwkcSiA.mjs +25 -0
- package/dist/delete-CTeH7nzL.mjs +29 -0
- package/dist/delete-D2yDBhZc.mjs +24 -0
- package/dist/delete-HMOfvtv3.mjs +25 -0
- package/dist/document-vTiqLew9.mjs +14 -0
- package/dist/edit-BBvSbt0m.mjs +22 -0
- package/dist/edit-BfCZ2Abi.mjs +50 -0
- package/dist/edit-CN1gdpjd.mjs +37 -0
- package/dist/edit-C_KbKopB.mjs +36 -0
- package/dist/edit-D5Z45NVj.mjs +27 -0
- package/dist/edit-DKQw-XXP.mjs +27 -0
- package/dist/edit-DRxr4r-r.mjs +60 -0
- package/dist/edit-DxsP-aPX.mjs +43 -0
- package/dist/edit-Otc7XHU7.mjs +52 -0
- package/dist/file-DwPTUKOI.mjs +17 -0
- package/dist/format-DHAR0n3J.mjs +9 -0
- package/dist/history-DpjqxFkX.mjs +55 -0
- package/dist/index.mjs +33 -37918
- package/dist/issue-BRzJy3k1.mjs +18 -0
- package/dist/issue-type-Byzh4yLx.mjs +11 -0
- package/dist/list-B3A5SDEm.mjs +35 -0
- package/dist/list-BMKaJoe_.mjs +64 -0
- package/dist/list-BOMbpS4m.mjs +46 -0
- package/dist/list-BmZ_JbLB.mjs +104 -0
- package/dist/list-BpUUxxwQ.mjs +46 -0
- package/dist/list-CgIebllW.mjs +94 -0
- package/dist/list-D0Z__0nw.mjs +42 -0
- package/dist/list-D3FkO9gb.mjs +56 -0
- package/dist/list-D7WLdHvX.mjs +42 -0
- package/dist/list-DAr3urtu.mjs +53 -0
- package/dist/list-DqpWd9aR.mjs +59 -0
- package/dist/list-VO_PbRjC.mjs +50 -0
- package/dist/list-b6ByzUFt.mjs +79 -0
- package/dist/list-jpQ28gU2.mjs +56 -0
- package/dist/list-y93EXyDj.mjs +42 -0
- package/dist/login-BnJYzdR3.mjs +228 -0
- package/dist/logout-YMnSRLLF.mjs +56 -0
- package/dist/me-CLPAe7X2.mjs +36 -0
- package/dist/milestone-Dc3alfp9.mjs +11 -0
- package/dist/notification-CsOuC8Uk.mjs +11 -0
- package/dist/output-DBvfyU1J.mjs +39 -0
- package/dist/pr-BBe07JUp.mjs +15 -0
- package/dist/project-Dilo1T5e.mjs +16 -0
- package/dist/read-BS2G4sNq.mjs +17 -0
- package/dist/read-CyCASx6U.mjs +17 -0
- package/dist/read-all-CjgMJ2to.mjs +16 -0
- package/dist/refresh-DDU2ZLnc.mjs +54 -0
- package/dist/registry-D8DfbunX.mjs +2 -0
- package/dist/registry-PlBmfTR4.mjs +35 -0
- package/dist/remove-BSDJvkVJ.mjs +17 -0
- package/dist/remove-user-CShNCvf8.mjs +26 -0
- package/dist/reopen-BIRhcmsI.mjs +28 -0
- package/dist/repo-B2K8y0mD.mjs +10 -0
- package/dist/role-labels-CLA2wmjO.mjs +11 -0
- package/dist/space-BgZeUqoH.mjs +6 -0
- package/dist/{shared/bee.CHtg3F43.mjs → src-BWaxjrq_.mjs} +143 -175
- package/dist/src-CP4YLIAh.mjs +1008 -0
- package/dist/src-CTD9-bSB.mjs +22760 -0
- package/dist/star-Sgb-e2CQ.mjs +11 -0
- package/dist/status-BkFMW8Jh.mjs +53 -0
- package/dist/status-CaGqMXh7.mjs +64 -0
- package/dist/status-DDFyQrRZ.mjs +11 -0
- package/dist/status-nI4Dpcoo.mjs +58 -0
- package/dist/stdin-C-vjNi9T.mjs +17 -0
- package/dist/switch-CMLfVGDN.mjs +34 -0
- package/dist/tags-DuMJZyBL.mjs +29 -0
- package/dist/team-DfQn8Tf5.mjs +6 -0
- package/dist/token-BmkUX9vc.mjs +28 -0
- package/dist/tree-CozBqPbN.mjs +46 -0
- package/dist/user-DMyFmoP3.mjs +11 -0
- package/dist/users-BSGqsGSy.mjs +51 -0
- package/dist/view-Bj99sk7O.mjs +48 -0
- package/dist/view-Bs8o0c7i.mjs +36 -0
- package/dist/view-C1ECwTMN.mjs +54 -0
- package/dist/view-COBYBfu7.mjs +38 -0
- package/dist/view-CZHT-HiE.mjs +36 -0
- package/dist/view-D1RuQJV6.mjs +76 -0
- package/dist/view-DBO75WzR.mjs +54 -0
- package/dist/view-DJHrnN8j.mjs +62 -0
- package/dist/view-DLx6qQt9.mjs +51 -0
- package/dist/watching-D22YYxOT.mjs +12 -0
- package/dist/wiki-B-DQUuIX.mjs +16 -0
- package/package.json +14 -11
- package/dist/chunks/activities.mjs +0 -75
- package/dist/chunks/activities2.mjs +0 -75
- package/dist/chunks/activities3.mjs +0 -75
- package/dist/chunks/add-user.mjs +0 -38
- package/dist/chunks/add.mjs +0 -63
- package/dist/chunks/add2.mjs +0 -39
- package/dist/chunks/api.mjs +0 -174
- package/dist/chunks/attachments.mjs +0 -47
- package/dist/chunks/attachments2.mjs +0 -47
- package/dist/chunks/attachments3.mjs +0 -48
- package/dist/chunks/browse.mjs +0 -269
- package/dist/chunks/clone.mjs +0 -60
- package/dist/chunks/close.mjs +0 -50
- package/dist/chunks/comment.mjs +0 -125
- package/dist/chunks/comment2.mjs +0 -111
- package/dist/chunks/comments.mjs +0 -57
- package/dist/chunks/completion.mjs +0 -113
- package/dist/chunks/count.mjs +0 -68
- package/dist/chunks/count2.mjs +0 -69
- package/dist/chunks/count3.mjs +0 -59
- package/dist/chunks/count4.mjs +0 -35
- package/dist/chunks/count5.mjs +0 -52
- package/dist/chunks/create.mjs +0 -60
- package/dist/chunks/create2.mjs +0 -88
- package/dist/chunks/create3.mjs +0 -64
- package/dist/chunks/create4.mjs +0 -74
- package/dist/chunks/create5.mjs +0 -56
- package/dist/chunks/create6.mjs +0 -37
- package/dist/chunks/create7.mjs +0 -45
- package/dist/chunks/create8.mjs +0 -49
- package/dist/chunks/create9.mjs +0 -49
- package/dist/chunks/dashboard.mjs +0 -84
- package/dist/chunks/delete.mjs +0 -48
- package/dist/chunks/delete2.mjs +0 -46
- package/dist/chunks/delete3.mjs +0 -46
- package/dist/chunks/delete4.mjs +0 -49
- package/dist/chunks/delete5.mjs +0 -50
- package/dist/chunks/delete6.mjs +0 -50
- package/dist/chunks/delete7.mjs +0 -62
- package/dist/chunks/delete8.mjs +0 -53
- package/dist/chunks/delete9.mjs +0 -48
- package/dist/chunks/edit.mjs +0 -56
- package/dist/chunks/edit2.mjs +0 -78
- package/dist/chunks/edit3.mjs +0 -65
- package/dist/chunks/edit4.mjs +0 -51
- package/dist/chunks/edit5.mjs +0 -43
- package/dist/chunks/edit6.mjs +0 -54
- package/dist/chunks/edit7.mjs +0 -50
- package/dist/chunks/edit8.mjs +0 -50
- package/dist/chunks/history.mjs +0 -56
- package/dist/chunks/index.mjs +0 -15
- package/dist/chunks/index10.mjs +0 -18
- package/dist/chunks/index11.mjs +0 -13
- package/dist/chunks/index12.mjs +0 -13
- package/dist/chunks/index13.mjs +0 -13
- package/dist/chunks/index14.mjs +0 -8
- package/dist/chunks/index15.mjs +0 -13
- package/dist/chunks/index16.mjs +0 -13
- package/dist/chunks/index17.mjs +0 -14
- package/dist/chunks/index2.mjs +0 -18
- package/dist/chunks/index3.mjs +0 -20
- package/dist/chunks/index4.mjs +0 -15
- package/dist/chunks/index5.mjs +0 -13
- package/dist/chunks/index6.mjs +0 -17
- package/dist/chunks/index7.mjs +0 -8
- package/dist/chunks/index8.mjs +0 -8
- package/dist/chunks/index9.mjs +0 -13
- package/dist/chunks/list.mjs +0 -52
- package/dist/chunks/list10.mjs +0 -44
- package/dist/chunks/list11.mjs +0 -49
- package/dist/chunks/list12.mjs +0 -45
- package/dist/chunks/list13.mjs +0 -45
- package/dist/chunks/list14.mjs +0 -54
- package/dist/chunks/list15.mjs +0 -46
- package/dist/chunks/list2.mjs +0 -103
- package/dist/chunks/list3.mjs +0 -85
- package/dist/chunks/list4.mjs +0 -79
- package/dist/chunks/list5.mjs +0 -77
- package/dist/chunks/list6.mjs +0 -45
- package/dist/chunks/list7.mjs +0 -48
- package/dist/chunks/list8.mjs +0 -46
- package/dist/chunks/list9.mjs +0 -53
- package/dist/chunks/login.mjs +0 -218
- package/dist/chunks/logout.mjs +0 -76
- package/dist/chunks/me.mjs +0 -48
- package/dist/chunks/read-all.mjs +0 -29
- package/dist/chunks/read.mjs +0 -29
- package/dist/chunks/read2.mjs +0 -27
- package/dist/chunks/refresh.mjs +0 -76
- package/dist/chunks/remove-user.mjs +0 -38
- package/dist/chunks/remove.mjs +0 -27
- package/dist/chunks/reopen.mjs +0 -42
- package/dist/chunks/status.mjs +0 -64
- package/dist/chunks/status2.mjs +0 -61
- package/dist/chunks/status3.mjs +0 -66
- package/dist/chunks/switch.mjs +0 -55
- package/dist/chunks/tags.mjs +0 -41
- package/dist/chunks/token.mjs +0 -42
- package/dist/chunks/tree.mjs +0 -61
- package/dist/chunks/users.mjs +0 -48
- package/dist/chunks/view.mjs +0 -58
- package/dist/chunks/view2.mjs +0 -95
- package/dist/chunks/view3.mjs +0 -68
- package/dist/chunks/view4.mjs +0 -70
- package/dist/chunks/view5.mjs +0 -61
- package/dist/chunks/view6.mjs +0 -52
- package/dist/chunks/view7.mjs +0 -48
- package/dist/chunks/view8.mjs +0 -61
- package/dist/chunks/view9.mjs +0 -48
- package/dist/shared/bee.084B_7FC.mjs +0 -27
- package/dist/shared/bee.BTBGpv4K.mjs +0 -34
- package/dist/shared/bee.BXiuAfjJ.mjs +0 -10
- package/dist/shared/bee.Btmq3TXs.mjs +0 -19
- package/dist/shared/bee.C--ZWPxf.mjs +0 -14
- package/dist/shared/bee.C4p7W8_P.mjs +0 -18
- package/dist/shared/bee.CAARNIp6.mjs +0 -49
- package/dist/shared/bee.CirccSk2.mjs +0 -51
- package/dist/shared/bee.CktwmH8R.mjs +0 -25
- package/dist/shared/bee.CzKcWSES.mjs +0 -42
- package/dist/shared/bee.DFnSWb6q.mjs +0 -396
- package/dist/shared/bee.DoTvz3uW.mjs +0 -13
- package/dist/shared/bee.KteAW2rM.mjs +0 -73
- package/dist/shared/bee.RsR9yniy.mjs +0 -131
- package/dist/shared/bee.a05kNWpn.mjs +0 -32
- package/dist/shared/bee.n5MYN4a6.mjs +0 -12
- package/dist/shared/bee.q93n012-.mjs +0 -14
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { colorize } from "consola/utils";
|
|
3
|
+
//#region src/lib/bee-command.ts
|
|
4
|
+
var BeeCommand = class BeeCommand extends Command {
|
|
5
|
+
beeExamples = [];
|
|
6
|
+
beeEnvVars = [];
|
|
7
|
+
action(fn) {
|
|
8
|
+
this.option("-y, --yes", "Skip confirmation prompt");
|
|
9
|
+
return super.action(fn);
|
|
10
|
+
}
|
|
11
|
+
helpInformation() {
|
|
12
|
+
return super.helpInformation() + this._renderExamples() + this._renderEnvVars();
|
|
13
|
+
}
|
|
14
|
+
createCommand(name) {
|
|
15
|
+
return new BeeCommand(name);
|
|
16
|
+
}
|
|
17
|
+
examples(examples) {
|
|
18
|
+
this.beeExamples.push(...examples);
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
envVars(vars) {
|
|
22
|
+
this.beeEnvVars.push(...vars);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
async addCommands(mods) {
|
|
26
|
+
const resolved = await Promise.all(mods);
|
|
27
|
+
for (const mod of resolved) this.addCommand(mod.default);
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
_renderExamples() {
|
|
31
|
+
if (this.beeExamples.length === 0) return "";
|
|
32
|
+
const lines = this.beeExamples.flatMap((ex) => [
|
|
33
|
+
` # ${ex.description}`,
|
|
34
|
+
` $ ${ex.command}`,
|
|
35
|
+
""
|
|
36
|
+
]);
|
|
37
|
+
return `\n${colorize("bold", "EXAMPLES")}\n${lines.join("\n")}`;
|
|
38
|
+
}
|
|
39
|
+
_renderEnvVars() {
|
|
40
|
+
const fromOptions = this.options.filter((opt) => opt.envVar).map((opt) => [opt.envVar, opt.description ?? ""]);
|
|
41
|
+
const seen = /* @__PURE__ */ new Set();
|
|
42
|
+
const vars = [...fromOptions, ...this.beeEnvVars].filter(([name]) => {
|
|
43
|
+
if (seen.has(name)) return false;
|
|
44
|
+
seen.add(name);
|
|
45
|
+
return true;
|
|
46
|
+
});
|
|
47
|
+
if (vars.length === 0) return "";
|
|
48
|
+
const maxLen = Math.max(...vars.map(([k]) => k.length));
|
|
49
|
+
const lines = vars.map(([k, d]) => ` ${k.padEnd(maxLen + 3)}${d}`);
|
|
50
|
+
return `\n${colorize("bold", "ENVIRONMENT VARIABLES")}\n${lines.join("\n")}`;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const ENV_AUTH = [["BACKLOG_API_KEY", "Authenticate with an API key"], ["BACKLOG_SPACE", "Space hostname"]];
|
|
54
|
+
const ENV_PROJECT = ["BACKLOG_PROJECT", "Default project ID or project key"];
|
|
55
|
+
const ENV_REPO = ["BACKLOG_REPO", "Default repository name"];
|
|
56
|
+
//#endregion
|
|
57
|
+
export { ENV_REPO as i, ENV_AUTH as n, ENV_PROJECT as r, BeeCommand as t };
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { c as gitTreeUrl, f as openOrPrintUrl, g as repositoryUrl, i as dashboardUrl, m as projectUrl, n as buildBacklogUrl, o as gitBlobUrl, s as gitCommitUrl, u as issueUrl, y as getClient } from "./src-CTD9-bSB.mjs";
|
|
2
|
+
import { a as parseArg, s as vInteger, u as UserError } from "./src-CP4YLIAh.mjs";
|
|
3
|
+
import { n as ENV_AUTH, r as ENV_PROJECT, t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
4
|
+
import { S as space, b as projectOptional, h as noBrowser } from "./common-options-BuYWxYdO.mjs";
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
import { execFile } from "node:child_process";
|
|
7
|
+
//#region ../../packages/backlog-utils/src/git-context.ts
|
|
8
|
+
/**
|
|
9
|
+
* Parses a Backlog git remote URL into its components.
|
|
10
|
+
*
|
|
11
|
+
* Supports SSH (SCP-like and URL), and HTTPS formats:
|
|
12
|
+
* - SCP: `<user>@<space>.git.backlog.com:/<PROJECT>/<repo>.git`
|
|
13
|
+
* - SSH: `ssh://<user>@<space>.git.backlog.com/<PROJECT>/<repo>.git`
|
|
14
|
+
* - HTTPS: `https://<space>.backlog.com/git/<PROJECT>/<repo>.git`
|
|
15
|
+
*
|
|
16
|
+
* Works with both `.backlog.com` and `.backlog.jp` domains.
|
|
17
|
+
*/
|
|
18
|
+
const parseBacklogRemoteUrl = (url) => {
|
|
19
|
+
const sshUrlMatch = url.match(/^ssh:\/\/[^@]+@([^.]+)\.git\.(backlog\.(?:com|jp))\/([^/]+)\/([^/.]+?)(?:\.git)?$/);
|
|
20
|
+
if (sshUrlMatch) {
|
|
21
|
+
const [, space, domain, projectKey, repoName] = sshUrlMatch;
|
|
22
|
+
return {
|
|
23
|
+
host: `${space}.${domain}`,
|
|
24
|
+
projectKey,
|
|
25
|
+
repoName
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const scpMatch = url.match(/^[^@]+@([^.]+)\.git\.(backlog\.(?:com|jp)):\/?([^/]+)\/([^/.]+?)(?:\.git)?$/);
|
|
29
|
+
if (scpMatch) {
|
|
30
|
+
const [, space, domain, projectKey, repoName] = scpMatch;
|
|
31
|
+
return {
|
|
32
|
+
host: `${space}.${domain}`,
|
|
33
|
+
projectKey,
|
|
34
|
+
repoName
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const httpsMatch = url.match(/^https?:\/\/(.+\.backlog\.(?:com|jp))\/git\/([^/]+)\/([^/]+?)(?:\.git)?$/);
|
|
38
|
+
if (httpsMatch) {
|
|
39
|
+
const [, host, projectKey, repoName] = httpsMatch;
|
|
40
|
+
return {
|
|
41
|
+
host,
|
|
42
|
+
projectKey,
|
|
43
|
+
repoName
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const execGit = (args, cwd) => new Promise((resolve, reject) => {
|
|
48
|
+
execFile("git", args, { cwd }, (error, stdout) => {
|
|
49
|
+
if (error) {
|
|
50
|
+
reject(error);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
resolve(stdout.trim());
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* Detects the Backlog git context from the current directory's git remote.
|
|
58
|
+
*
|
|
59
|
+
* Reads the `origin` remote URL and parses it. Returns `undefined` when not
|
|
60
|
+
* inside a Backlog repository.
|
|
61
|
+
*/
|
|
62
|
+
const detectGitContext = async (cwd) => {
|
|
63
|
+
try {
|
|
64
|
+
const remoteUrl = await execGit([
|
|
65
|
+
"remote",
|
|
66
|
+
"get-url",
|
|
67
|
+
"origin"
|
|
68
|
+
], cwd);
|
|
69
|
+
return parseBacklogRemoteUrl(remoteUrl);
|
|
70
|
+
} catch {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Returns the current git branch name, or `undefined` if detached or not in a repo.
|
|
76
|
+
*/
|
|
77
|
+
const getCurrentBranch = async (cwd) => {
|
|
78
|
+
try {
|
|
79
|
+
return await execGit([
|
|
80
|
+
"rev-parse",
|
|
81
|
+
"--abbrev-ref",
|
|
82
|
+
"HEAD"
|
|
83
|
+
], cwd);
|
|
84
|
+
} catch {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Returns the latest commit SHA (short form), or `undefined` if not in a repo.
|
|
90
|
+
*/
|
|
91
|
+
const getLatestCommit = async (cwd) => {
|
|
92
|
+
try {
|
|
93
|
+
return await execGit(["rev-parse", "HEAD"], cwd);
|
|
94
|
+
} catch {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Returns the path from the git repository root to the current directory.
|
|
100
|
+
* Used to resolve relative file paths to repo-relative paths.
|
|
101
|
+
*/
|
|
102
|
+
const getRepoRelativePath = async (cwd) => {
|
|
103
|
+
try {
|
|
104
|
+
return await execGit(["rev-parse", "--show-prefix"], cwd) || void 0;
|
|
105
|
+
} catch {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/commands/browse-url.ts
|
|
111
|
+
const ISSUE_KEY_PATTERN = /^[A-Z][A-Z0-9_]+-\d+$/;
|
|
112
|
+
const ISSUE_NUMBER_PATTERN = /^\d+$/;
|
|
113
|
+
const FILE_LINE_PATTERN = /^(.+):(\d+)$/;
|
|
114
|
+
const resolveUrl = (host, args, git) => {
|
|
115
|
+
if (args.target && ISSUE_KEY_PATTERN.test(args.target)) return {
|
|
116
|
+
ok: true,
|
|
117
|
+
url: issueUrl(host, args.target)
|
|
118
|
+
};
|
|
119
|
+
if (args.target && ISSUE_NUMBER_PATTERN.test(args.target)) {
|
|
120
|
+
const projectKey = args.project ?? git.context?.projectKey;
|
|
121
|
+
if (projectKey) return {
|
|
122
|
+
ok: true,
|
|
123
|
+
url: issueUrl(host, `${projectKey}-${args.target}`)
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
ok: false,
|
|
127
|
+
error: "Cannot resolve issue number without a project. Use --project or run inside a Backlog repository."
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (args.target && isFilePath(args.target)) return resolveFileUrl(host, args, git);
|
|
131
|
+
const projectKey = args.target ?? args.project ?? git.context?.projectKey;
|
|
132
|
+
if (projectKey) {
|
|
133
|
+
if (args.issues) return {
|
|
134
|
+
ok: true,
|
|
135
|
+
url: buildBacklogUrl(host, `/find/${projectKey}`)
|
|
136
|
+
};
|
|
137
|
+
if (args.board) return {
|
|
138
|
+
ok: true,
|
|
139
|
+
url: buildBacklogUrl(host, `/board/${projectKey}`)
|
|
140
|
+
};
|
|
141
|
+
if (args.gantt) return {
|
|
142
|
+
ok: true,
|
|
143
|
+
url: buildBacklogUrl(host, `/gantt/${projectKey}`)
|
|
144
|
+
};
|
|
145
|
+
if (args.wiki) return {
|
|
146
|
+
ok: true,
|
|
147
|
+
url: buildBacklogUrl(host, `/wiki/${projectKey}`)
|
|
148
|
+
};
|
|
149
|
+
if (args.documents) return {
|
|
150
|
+
ok: true,
|
|
151
|
+
url: buildBacklogUrl(host, `/document/${projectKey}`)
|
|
152
|
+
};
|
|
153
|
+
if (args.files) return {
|
|
154
|
+
ok: true,
|
|
155
|
+
url: buildBacklogUrl(host, `/file/${projectKey}`)
|
|
156
|
+
};
|
|
157
|
+
if (args.git) return {
|
|
158
|
+
ok: true,
|
|
159
|
+
url: buildBacklogUrl(host, `/git/${projectKey}`)
|
|
160
|
+
};
|
|
161
|
+
if (args.svn) return {
|
|
162
|
+
ok: true,
|
|
163
|
+
url: buildBacklogUrl(host, `/subversion/${projectKey}`)
|
|
164
|
+
};
|
|
165
|
+
if (args.settings) return {
|
|
166
|
+
ok: true,
|
|
167
|
+
url: buildBacklogUrl(host, `/EditProject.action?project.id=${projectKey}`)
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (args.branch || args.commit) return resolveFileUrl(host, args, git);
|
|
171
|
+
if (args.target) return {
|
|
172
|
+
ok: true,
|
|
173
|
+
url: projectUrl(host, args.target)
|
|
174
|
+
};
|
|
175
|
+
if (git.context) return {
|
|
176
|
+
ok: true,
|
|
177
|
+
url: repositoryUrl(host, git.context.projectKey, git.context.repoName)
|
|
178
|
+
};
|
|
179
|
+
return {
|
|
180
|
+
ok: true,
|
|
181
|
+
url: dashboardUrl(host)
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
const isFilePath = (target) => {
|
|
185
|
+
if (target.includes("/")) return true;
|
|
186
|
+
if (FILE_LINE_PATTERN.test(target)) return true;
|
|
187
|
+
if (target.includes(".") && !ISSUE_KEY_PATTERN.test(target)) return true;
|
|
188
|
+
return false;
|
|
189
|
+
};
|
|
190
|
+
const resolveFileUrl = (host, args, git) => {
|
|
191
|
+
if (!git.context) return {
|
|
192
|
+
ok: false,
|
|
193
|
+
error: "Not inside a Backlog Git repository. Cannot resolve file path."
|
|
194
|
+
};
|
|
195
|
+
let ref;
|
|
196
|
+
if (args.commit) {
|
|
197
|
+
if (!git.latestCommit) return {
|
|
198
|
+
ok: false,
|
|
199
|
+
error: "Could not determine the latest commit."
|
|
200
|
+
};
|
|
201
|
+
if (!args.target) return {
|
|
202
|
+
ok: true,
|
|
203
|
+
url: gitCommitUrl(host, git.context.projectKey, git.context.repoName, git.latestCommit)
|
|
204
|
+
};
|
|
205
|
+
ref = git.latestCommit;
|
|
206
|
+
} else if (args.branch) ref = args.branch;
|
|
207
|
+
else ref = git.currentBranch ?? "main";
|
|
208
|
+
if (!args.target) return {
|
|
209
|
+
ok: true,
|
|
210
|
+
url: gitTreeUrl(host, git.context.projectKey, git.context.repoName, ref)
|
|
211
|
+
};
|
|
212
|
+
const lineMatch = args.target.match(FILE_LINE_PATTERN);
|
|
213
|
+
const filePath = lineMatch ? lineMatch[1] : args.target;
|
|
214
|
+
const line = lineMatch ? parseArg(vInteger, lineMatch[2], "line") : void 0;
|
|
215
|
+
const fullPath = git.repoRelativePath ? `${git.repoRelativePath}${filePath}` : filePath;
|
|
216
|
+
if (filePath.endsWith("/")) return {
|
|
217
|
+
ok: true,
|
|
218
|
+
url: gitTreeUrl(host, git.context.projectKey, git.context.repoName, ref, fullPath.replace(/\/$/, ""))
|
|
219
|
+
};
|
|
220
|
+
return {
|
|
221
|
+
ok: true,
|
|
222
|
+
url: gitBlobUrl(host, git.context.projectKey, git.context.repoName, ref, fullPath, line)
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region src/commands/browse.ts
|
|
227
|
+
const browse = new BeeCommand("browse").summary("Open a Backlog page in the browser").description(`With no arguments, opens the repository page (inside a Backlog repo) or the dashboard.
|
|
228
|
+
|
|
229
|
+
Accepts an issue key (\`PROJECT-123\`), bare number (\`123\`, project inferred from Git remote), file path (\`src/main.ts\`), or path with line (\`src/main.ts:42\`). Paths ending with \`/\` open the directory tree. Use \`--project\` with section flags (e.g. \`--issues\`, \`--board\`) for project pages.`).argument("[target]", "Issue key, issue number, file path, or project key").addOption(projectOptional()).option("-b, --branch <name>", "View file at a specific branch").option("-c, --commit", "View file at the latest commit").addOption(noBrowser()).option("--issues", "Open the issues page").option("--board", "Open the board page").option("--gantt", "Open the Gantt chart page").option("--wiki", "Open the wiki page").option("--documents", "Open the documents page").option("--files", "Open the shared files page").option("--git", "Open the git repositories page").option("--svn", "Open the Subversion page").option("--settings", "Open the project settings page").addOption(space()).envVars([...ENV_AUTH, ENV_PROJECT]).examples([
|
|
230
|
+
{
|
|
231
|
+
description: "Open repository page (in a Backlog repo)",
|
|
232
|
+
command: "bee browse"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
description: "Open dashboard (outside a Backlog repo)",
|
|
236
|
+
command: "bee browse"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
description: "Open an issue",
|
|
240
|
+
command: "bee browse PROJECT-123"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
description: "Open issue by number (inferred project)",
|
|
244
|
+
command: "bee browse 123"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
description: "Open a file in git viewer",
|
|
248
|
+
command: "bee browse src/main.ts"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
description: "Open a file at a specific line",
|
|
252
|
+
command: "bee browse src/main.ts:42"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
description: "Open a directory in git viewer",
|
|
256
|
+
command: "bee browse src/"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
description: "Browse at a specific branch",
|
|
260
|
+
command: "bee browse src/main.ts -b develop"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
description: "Browse at the latest commit",
|
|
264
|
+
command: "bee browse -c"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
description: "Print URL without opening browser",
|
|
268
|
+
command: "bee browse -n"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
description: "Open project issues page",
|
|
272
|
+
command: "bee browse -p PROJECT --issues"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
description: "Open project board",
|
|
276
|
+
command: "bee browse -p PROJECT --board"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
description: "Open Gantt chart",
|
|
280
|
+
command: "bee browse -p PROJECT --gantt"
|
|
281
|
+
}
|
|
282
|
+
]).action(async (target, opts) => {
|
|
283
|
+
const { host } = await getClient(opts.space);
|
|
284
|
+
const [context, currentBranch, latestCommit, repoRelativePath] = await Promise.all([
|
|
285
|
+
detectGitContext(),
|
|
286
|
+
getCurrentBranch(),
|
|
287
|
+
getLatestCommit(),
|
|
288
|
+
getRepoRelativePath()
|
|
289
|
+
]);
|
|
290
|
+
const browseArgs = {
|
|
291
|
+
target,
|
|
292
|
+
...opts
|
|
293
|
+
};
|
|
294
|
+
const result = resolveUrl(context?.host ?? host, browseArgs, {
|
|
295
|
+
context,
|
|
296
|
+
currentBranch,
|
|
297
|
+
latestCommit,
|
|
298
|
+
repoRelativePath
|
|
299
|
+
});
|
|
300
|
+
if (!result.ok) throw new UserError(result.error);
|
|
301
|
+
await openOrPrintUrl(result.url, opts.browser === false, consola);
|
|
302
|
+
});
|
|
303
|
+
//#endregion
|
|
304
|
+
export { browse as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
2
|
+
//#region src/commands/category/index.ts
|
|
3
|
+
const category = new BeeCommand("category").summary("Manage project categories");
|
|
4
|
+
await category.addCommands([
|
|
5
|
+
import("./list-B3A5SDEm.mjs"),
|
|
6
|
+
import("./create-DtMLv7Wq.mjs"),
|
|
7
|
+
import("./edit-BBvSbt0m.mjs"),
|
|
8
|
+
import("./delete-BCAPHs-g.mjs")
|
|
9
|
+
]);
|
|
10
|
+
//#endregion
|
|
11
|
+
export { category as default };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { y as getClient } from "./src-CTD9-bSB.mjs";
|
|
2
|
+
import { t as outputResult } from "./output-DBvfyU1J.mjs";
|
|
3
|
+
import "./src-CP4YLIAh.mjs";
|
|
4
|
+
import { n as ENV_AUTH, r as ENV_PROJECT, t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
5
|
+
import { E as resolveOptions, S as space, u as json, y as project } from "./common-options-BuYWxYdO.mjs";
|
|
6
|
+
import consola from "consola";
|
|
7
|
+
import { getGitRepository } from "backlog-js";
|
|
8
|
+
import { spawn } from "node:child_process";
|
|
9
|
+
//#region src/commands/repo/clone.ts
|
|
10
|
+
const gitClone = (gitArgs) => new Promise((resolve, reject) => {
|
|
11
|
+
spawn("git", gitArgs, { stdio: "inherit" }).on("close", (code) => {
|
|
12
|
+
if (code === 0) resolve();
|
|
13
|
+
else reject(/* @__PURE__ */ new Error(`git clone exited with code ${code}`));
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
const clone = new BeeCommand("clone").summary("Clone a repository").description(`By default the SSH URL is used; pass \`--http\` to clone over HTTPS instead.`).argument("<repository>", "Repository name or ID").addOption(project()).option("-d, --directory <path>", "Directory to clone into").option("--http", "Clone using HTTP URL instead of SSH").addOption(json()).addOption(space()).envVars([...ENV_AUTH, ENV_PROJECT]).examples([
|
|
17
|
+
{
|
|
18
|
+
description: "Clone a repository",
|
|
19
|
+
command: "bee repo clone api-server -p PROJECT_KEY"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
description: "Clone to a specific directory",
|
|
23
|
+
command: "bee repo clone api-server -p PROJECT_KEY --directory ./dest"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
description: "Clone using HTTP URL",
|
|
27
|
+
command: "bee repo clone api-server -p PROJECT_KEY --http"
|
|
28
|
+
}
|
|
29
|
+
]).action(async (repository, opts, cmd) => {
|
|
30
|
+
await resolveOptions(cmd);
|
|
31
|
+
const { client } = await getClient(opts.space);
|
|
32
|
+
const repo = await getGitRepository(client, opts.project, repository);
|
|
33
|
+
if (opts.json !== void 0) {
|
|
34
|
+
outputResult(repo, opts, () => {});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const gitArgs = ["clone", opts.http ? repo.httpUrl : repo.sshUrl];
|
|
38
|
+
if (opts.directory) gitArgs.push(opts.directory);
|
|
39
|
+
consola.info(`Cloning into '${opts.directory ?? repo.name}'...`);
|
|
40
|
+
await gitClone(gitArgs);
|
|
41
|
+
});
|
|
42
|
+
//#endregion
|
|
43
|
+
export { clone as default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { A as ResolutionId, D as IssueStatusId, y as getClient } from "./src-CTD9-bSB.mjs";
|
|
2
|
+
import { t as outputResult } from "./output-DBvfyU1J.mjs";
|
|
3
|
+
import { a as parseArg, s as vInteger } from "./src-CP4YLIAh.mjs";
|
|
4
|
+
import { n as ENV_AUTH, t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
5
|
+
import { S as space, g as notify, u as json } from "./common-options-BuYWxYdO.mjs";
|
|
6
|
+
import consola from "consola";
|
|
7
|
+
import { patchIssue } from "backlog-js";
|
|
8
|
+
//#region src/commands/issue/close.ts
|
|
9
|
+
const close = new BeeCommand("close").summary("Close an issue").description(`Sets the status to Closed with resolution \`Fixed\` by default. Use \`--resolution\` for a different resolution.`).argument("<issue>", "Issue ID or issue key").option("-c, --comment <text>", "Comment to add when closing").option("--resolution <name>", `Resolution`).addOption(notify()).addOption(json()).addOption(space()).envVars([...ENV_AUTH]).examples([
|
|
10
|
+
{
|
|
11
|
+
description: "Close an issue",
|
|
12
|
+
command: "bee issue close PROJECT-123"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
description: "Close with a comment",
|
|
16
|
+
command: "bee issue close PROJECT-123 -c \"Done\""
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
description: "Close as duplicate",
|
|
20
|
+
command: "bee issue close PROJECT-123 --resolution duplicate"
|
|
21
|
+
}
|
|
22
|
+
]).action(async (issue, opts) => {
|
|
23
|
+
const { client } = await getClient(opts.space);
|
|
24
|
+
const resolutionId = opts.resolution ? ResolutionId[opts.resolution] ?? parseArg(vInteger, opts.resolution, "--resolution") : ResolutionId.fixed;
|
|
25
|
+
const notifiedUserId = opts.notify ?? [];
|
|
26
|
+
const issueData = await patchIssue(client, issue, {
|
|
27
|
+
statusId: IssueStatusId.Closed,
|
|
28
|
+
resolutionId,
|
|
29
|
+
comment: opts.comment,
|
|
30
|
+
notifiedUserId
|
|
31
|
+
});
|
|
32
|
+
outputResult(issueData, opts, (data) => {
|
|
33
|
+
consola.success(`Closed issue ${data.issueKey}: ${data.summary}`);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
//#endregion
|
|
37
|
+
export { close as default };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { y as getClient } from "./src-CTD9-bSB.mjs";
|
|
2
|
+
import { t as outputResult } from "./output-DBvfyU1J.mjs";
|
|
3
|
+
import { c as confirmOrExit, r as printTable } from "./src-CP4YLIAh.mjs";
|
|
4
|
+
import { n as resolveStdinArg } from "./stdin-C-vjNi9T.mjs";
|
|
5
|
+
import { t as formatDate } from "./format-DHAR0n3J.mjs";
|
|
6
|
+
import { n as ENV_AUTH, t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
7
|
+
import { S as space, g as notify, r as attachment, u as json } from "./common-options-BuYWxYdO.mjs";
|
|
8
|
+
import consola from "consola";
|
|
9
|
+
import { deleteIssueComment, getIssueComments, getMyself, patchIssueComment, postIssueComments } from "backlog-js";
|
|
10
|
+
//#region src/commands/issue/comment.ts
|
|
11
|
+
const comment = new BeeCommand("comment").summary("Add a comment to an issue").description(`When input is piped, it is used as the body automatically.
|
|
12
|
+
|
|
13
|
+
Use \`--list\`, \`--edit-last\`, or \`--delete-last\` for other comment operations.`).argument("<issue>", "Issue ID or issue key").option("-b, --body <text>", "Comment body").addOption(notify()).addOption(attachment()).option("--list", "List comments on the issue").option("--edit-last", "Edit your most recent comment").option("--delete-last", "Delete your most recent comment").addOption(json()).addOption(space()).envVars([...ENV_AUTH]).examples([
|
|
14
|
+
{
|
|
15
|
+
description: "Add a comment",
|
|
16
|
+
command: "bee issue comment PROJECT-123 -b \"This is a comment\""
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
description: "Add a comment from stdin",
|
|
20
|
+
command: "echo \"Comment body\" | bee issue comment PROJECT-123"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
description: "List all comments",
|
|
24
|
+
command: "bee issue comment PROJECT-123 --list"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
description: "Edit your last comment",
|
|
28
|
+
command: "bee issue comment PROJECT-123 --edit-last -b \"Updated text\""
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
description: "Delete your last comment",
|
|
32
|
+
command: "bee issue comment PROJECT-123 --delete-last --yes"
|
|
33
|
+
}
|
|
34
|
+
]).action(async (issue, opts) => {
|
|
35
|
+
const { client } = await getClient(opts.space);
|
|
36
|
+
if (opts.list) {
|
|
37
|
+
const comments = await getIssueComments(client, issue, { order: "asc" });
|
|
38
|
+
outputResult(comments, opts, (data) => {
|
|
39
|
+
const filtered = data.filter((c) => c.content);
|
|
40
|
+
if (filtered.length === 0) {
|
|
41
|
+
consola.info("No comments found.");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const rows = filtered.map((c) => [
|
|
45
|
+
{
|
|
46
|
+
header: "ID",
|
|
47
|
+
value: String(c.id)
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
header: "AUTHOR",
|
|
51
|
+
value: c.createdUser.name
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
header: "DATE",
|
|
55
|
+
value: formatDate(c.created)
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
header: "CONTENT",
|
|
59
|
+
value: c.content
|
|
60
|
+
}
|
|
61
|
+
]);
|
|
62
|
+
printTable(rows);
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (opts.editLast) {
|
|
67
|
+
const myself = await getMyself(client);
|
|
68
|
+
const myComment = (await getIssueComments(client, issue, { order: "desc" })).find((c) => c.createdUser.id === myself.id);
|
|
69
|
+
if (!myComment) {
|
|
70
|
+
consola.error(`No comment by you was found on ${issue}.`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const content = await resolveStdinArg(opts.body) ?? opts.body;
|
|
74
|
+
if (!content) {
|
|
75
|
+
consola.error("Comment body is required. Use --body or pipe input.");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const result = await patchIssueComment(client, issue, myComment.id, { content });
|
|
79
|
+
outputResult(result, opts, () => {
|
|
80
|
+
consola.success(`Updated comment on ${issue}`);
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (opts.deleteLast) {
|
|
85
|
+
const myself = await getMyself(client);
|
|
86
|
+
const myComment = (await getIssueComments(client, issue, { order: "desc" })).find((c) => c.createdUser.id === myself.id);
|
|
87
|
+
if (!myComment) {
|
|
88
|
+
consola.error(`No comment by you was found on ${issue}.`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (!await confirmOrExit(`Are you sure you want to delete your comment on ${issue}?`, opts.yes)) return;
|
|
92
|
+
const result = await deleteIssueComment(client, issue, myComment.id);
|
|
93
|
+
outputResult(result, opts, () => {
|
|
94
|
+
consola.success(`Deleted comment on ${issue}`);
|
|
95
|
+
});
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const content = await resolveStdinArg(opts.body) ?? opts.body;
|
|
99
|
+
if (!content) {
|
|
100
|
+
consola.error("Comment body is required. Use --body or pipe input.");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const notifiedUserId = opts.notify ?? [];
|
|
104
|
+
const attachmentId = opts.attachment ?? [];
|
|
105
|
+
const result = await postIssueComments(client, issue, {
|
|
106
|
+
content,
|
|
107
|
+
notifiedUserId,
|
|
108
|
+
attachmentId
|
|
109
|
+
});
|
|
110
|
+
outputResult(result, opts, () => {
|
|
111
|
+
consola.success(`Added comment to ${issue}`);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
//#endregion
|
|
115
|
+
export { comment as default };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { y as getClient } from "./src-CTD9-bSB.mjs";
|
|
2
|
+
import { t as outputResult } from "./output-DBvfyU1J.mjs";
|
|
3
|
+
import { a as parseArg, r as printTable, s as vInteger } from "./src-CP4YLIAh.mjs";
|
|
4
|
+
import { n as resolveStdinArg } from "./stdin-C-vjNi9T.mjs";
|
|
5
|
+
import { t as formatDate } from "./format-DHAR0n3J.mjs";
|
|
6
|
+
import { i as ENV_REPO, n as ENV_AUTH, r as ENV_PROJECT, t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
7
|
+
import { E as resolveOptions, S as space, g as notify, u as json, x as repo, y as project } from "./common-options-BuYWxYdO.mjs";
|
|
8
|
+
import consola from "consola";
|
|
9
|
+
import { getMyself, getPullRequestComments, patchPullRequestComments, postPullRequestComments } from "backlog-js";
|
|
10
|
+
//#region src/commands/pr/comment.ts
|
|
11
|
+
const comment = new BeeCommand("comment").summary("Add a comment to a pull request").description(`When input is piped, it is used as the body automatically.
|
|
12
|
+
|
|
13
|
+
Use \`--list\` or \`--edit-last\` for other comment operations.`).argument("<number>", "Pull request number").addOption(project()).addOption(repo()).option("-b, --body <text>", "Comment body").addOption(notify()).option("--list", "List comments on the pull request").option("--edit-last", "Edit your most recent comment").addOption(json()).addOption(space()).envVars([
|
|
14
|
+
...ENV_AUTH,
|
|
15
|
+
ENV_PROJECT,
|
|
16
|
+
ENV_REPO
|
|
17
|
+
]).examples([
|
|
18
|
+
{
|
|
19
|
+
description: "Add a comment",
|
|
20
|
+
command: "bee pr comment 42 -p PROJECT -R repo -b \"Looks good!\""
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
description: "Add a comment from stdin",
|
|
24
|
+
command: "echo \"Comment body\" | bee pr comment 42 -p PROJECT -R repo"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
description: "List all comments",
|
|
28
|
+
command: "bee pr comment 42 -p PROJECT -R repo --list"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
description: "Edit your last comment",
|
|
32
|
+
command: "bee pr comment 42 -p PROJECT -R repo --edit-last -b \"Updated\""
|
|
33
|
+
}
|
|
34
|
+
]).action(async (number, opts, cmd) => {
|
|
35
|
+
await resolveOptions(cmd);
|
|
36
|
+
const { client } = await getClient(opts.space);
|
|
37
|
+
const prNumber = parseArg(vInteger, number, "number");
|
|
38
|
+
const json = opts.json === true ? "" : opts.json;
|
|
39
|
+
if (opts.list) {
|
|
40
|
+
const comments = await getPullRequestComments(client, opts.project, opts.repo, prNumber, { order: "asc" });
|
|
41
|
+
outputResult(comments, { json }, (data) => {
|
|
42
|
+
const filtered = data.filter((c) => c.content);
|
|
43
|
+
if (filtered.length === 0) {
|
|
44
|
+
consola.info("No comments found.");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const rows = filtered.map((c) => [
|
|
48
|
+
{
|
|
49
|
+
header: "ID",
|
|
50
|
+
value: String(c.id)
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
header: "AUTHOR",
|
|
54
|
+
value: c.createdUser.name
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
header: "DATE",
|
|
58
|
+
value: formatDate(c.created)
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
header: "CONTENT",
|
|
62
|
+
value: c.content
|
|
63
|
+
}
|
|
64
|
+
]);
|
|
65
|
+
printTable(rows);
|
|
66
|
+
});
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (opts.editLast) {
|
|
70
|
+
const myself = await getMyself(client);
|
|
71
|
+
const myComment = (await getPullRequestComments(client, opts.project, opts.repo, prNumber, { order: "desc" })).find((c) => c.createdUser.id === myself.id);
|
|
72
|
+
if (!myComment) {
|
|
73
|
+
consola.error(`No comment by you was found on pull request #${number}.`);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const content = await resolveStdinArg(opts.body) ?? opts.body;
|
|
77
|
+
if (!content) {
|
|
78
|
+
consola.error("Comment body is required. Use --body or pipe input.");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const result = await patchPullRequestComments(client, opts.project, opts.repo, prNumber, myComment.id, { content });
|
|
82
|
+
outputResult(result, { json }, () => {
|
|
83
|
+
consola.success(`Updated comment on pull request #${number}`);
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const content = await resolveStdinArg(opts.body) ?? opts.body;
|
|
88
|
+
if (!content) {
|
|
89
|
+
consola.error("Comment body is required. Use --body or pipe input.");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const notifiedUserId = opts.notify ?? [];
|
|
93
|
+
const result = await postPullRequestComments(client, opts.project, opts.repo, prNumber, {
|
|
94
|
+
content,
|
|
95
|
+
notifiedUserId
|
|
96
|
+
});
|
|
97
|
+
outputResult(result, { json }, () => {
|
|
98
|
+
consola.success(`Added comment to pull request #${number}`);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
//#endregion
|
|
102
|
+
export { comment as default };
|