@nulab/bee 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- 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-kJR0fRPw.mjs +143 -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-yfcnEl7k.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-CiIzSyoS.mjs +13 -0
- package/dist/edit-BBvSbt0m.mjs +22 -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/format-DHAR0n3J.mjs +9 -0
- package/dist/history-DpjqxFkX.mjs +55 -0
- package/dist/index.mjs +35 -207
- 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-B0ZQfBD5.mjs +35 -0
- package/dist/registry-RATsKPUm.mjs +2 -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.B3N0WBdU.mjs → src-BWaxjrq_.mjs} +143 -176
- 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 +12 -7
- package/dist/chunks/activities.mjs +0 -77
- package/dist/chunks/activities2.mjs +0 -77
- package/dist/chunks/activities3.mjs +0 -77
- package/dist/chunks/add-user.mjs +0 -40
- package/dist/chunks/add.mjs +0 -65
- package/dist/chunks/add2.mjs +0 -41
- package/dist/chunks/api.mjs +0 -176
- package/dist/chunks/attachments.mjs +0 -49
- package/dist/chunks/attachments2.mjs +0 -49
- package/dist/chunks/attachments3.mjs +0 -50
- package/dist/chunks/browse.mjs +0 -271
- package/dist/chunks/clone.mjs +0 -62
- package/dist/chunks/close.mjs +0 -52
- package/dist/chunks/comment.mjs +0 -127
- package/dist/chunks/comment2.mjs +0 -113
- package/dist/chunks/comments.mjs +0 -59
- package/dist/chunks/completion.mjs +0 -118
- package/dist/chunks/count.mjs +0 -70
- package/dist/chunks/count2.mjs +0 -71
- package/dist/chunks/count3.mjs +0 -61
- package/dist/chunks/count4.mjs +0 -37
- package/dist/chunks/count5.mjs +0 -54
- package/dist/chunks/create.mjs +0 -62
- package/dist/chunks/create2.mjs +0 -90
- package/dist/chunks/create3.mjs +0 -66
- package/dist/chunks/create4.mjs +0 -76
- package/dist/chunks/create5.mjs +0 -58
- package/dist/chunks/create6.mjs +0 -39
- package/dist/chunks/create7.mjs +0 -47
- package/dist/chunks/create8.mjs +0 -51
- package/dist/chunks/create9.mjs +0 -51
- package/dist/chunks/dashboard.mjs +0 -86
- package/dist/chunks/delete.mjs +0 -50
- package/dist/chunks/delete2.mjs +0 -48
- package/dist/chunks/delete3.mjs +0 -48
- package/dist/chunks/delete4.mjs +0 -51
- package/dist/chunks/delete5.mjs +0 -52
- package/dist/chunks/delete6.mjs +0 -52
- package/dist/chunks/delete7.mjs +0 -64
- package/dist/chunks/delete8.mjs +0 -55
- package/dist/chunks/delete9.mjs +0 -50
- package/dist/chunks/edit.mjs +0 -58
- package/dist/chunks/edit2.mjs +0 -80
- package/dist/chunks/edit3.mjs +0 -67
- package/dist/chunks/edit4.mjs +0 -53
- package/dist/chunks/edit5.mjs +0 -45
- package/dist/chunks/edit6.mjs +0 -56
- package/dist/chunks/edit7.mjs +0 -52
- package/dist/chunks/edit8.mjs +0 -52
- package/dist/chunks/history.mjs +0 -58
- 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 -54
- package/dist/chunks/list10.mjs +0 -46
- package/dist/chunks/list11.mjs +0 -51
- package/dist/chunks/list12.mjs +0 -47
- package/dist/chunks/list13.mjs +0 -47
- package/dist/chunks/list14.mjs +0 -56
- package/dist/chunks/list15.mjs +0 -48
- package/dist/chunks/list2.mjs +0 -105
- package/dist/chunks/list3.mjs +0 -87
- package/dist/chunks/list4.mjs +0 -81
- package/dist/chunks/list5.mjs +0 -79
- package/dist/chunks/list6.mjs +0 -47
- package/dist/chunks/list7.mjs +0 -50
- package/dist/chunks/list8.mjs +0 -48
- package/dist/chunks/list9.mjs +0 -55
- package/dist/chunks/login.mjs +0 -220
- package/dist/chunks/logout.mjs +0 -72
- package/dist/chunks/me.mjs +0 -50
- package/dist/chunks/read-all.mjs +0 -31
- package/dist/chunks/read.mjs +0 -31
- package/dist/chunks/read2.mjs +0 -29
- package/dist/chunks/refresh.mjs +0 -78
- package/dist/chunks/remove-user.mjs +0 -40
- package/dist/chunks/remove.mjs +0 -29
- package/dist/chunks/reopen.mjs +0 -44
- package/dist/chunks/status.mjs +0 -61
- package/dist/chunks/status2.mjs +0 -63
- package/dist/chunks/status3.mjs +0 -68
- package/dist/chunks/switch.mjs +0 -51
- package/dist/chunks/tags.mjs +0 -43
- package/dist/chunks/token.mjs +0 -38
- package/dist/chunks/tree.mjs +0 -63
- package/dist/chunks/users.mjs +0 -50
- package/dist/chunks/view.mjs +0 -60
- package/dist/chunks/view2.mjs +0 -96
- package/dist/chunks/view3.mjs +0 -70
- package/dist/chunks/view4.mjs +0 -72
- package/dist/chunks/view5.mjs +0 -63
- package/dist/chunks/view6.mjs +0 -54
- package/dist/chunks/view7.mjs +0 -50
- package/dist/chunks/view8.mjs +0 -63
- package/dist/chunks/view9.mjs +0 -50
- package/dist/shared/bee.BImw1HZl.mjs +0 -28
- package/dist/shared/bee.BTBGpv4K.mjs +0 -34
- package/dist/shared/bee.BXiuAfjJ.mjs +0 -10
- package/dist/shared/bee.BYqxm3yG.mjs +0 -24
- 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.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.DessOtkV.mjs +0 -132
- package/dist/shared/bee.DfqnFet4.mjs +0 -49
- package/dist/shared/bee.DoTvz3uW.mjs +0 -13
- package/dist/shared/bee.G4d7izLe.mjs +0 -14
- package/dist/shared/bee.KteAW2rM.mjs +0 -73
- package/dist/shared/bee.PF8hrVKn.mjs +0 -27
- package/dist/shared/bee.a05kNWpn.mjs +0 -32
- package/dist/shared/bee.n5MYN4a6.mjs +0 -12
- package/dist/shared/bee.x-FvgDW2.mjs +0 -37660
|
@@ -0,0 +1,56 @@
|
|
|
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 ENV_AUTH, t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
5
|
+
import { S as space, _ as offset, c as count, u as json, v as order } from "./common-options-BuYWxYdO.mjs";
|
|
6
|
+
import consola from "consola";
|
|
7
|
+
import { getTeams } from "backlog-js";
|
|
8
|
+
import * as v from "valibot";
|
|
9
|
+
//#region src/commands/team/list.ts
|
|
10
|
+
const list = new BeeCommand("list").summary("List teams").description(`Teams are groups of users that can be assigned to projects collectively.`).addOption(json()).addOption(order()).addOption(offset()).addOption(count()).addOption(space()).envVars([...ENV_AUTH]).examples([
|
|
11
|
+
{
|
|
12
|
+
description: "List all teams",
|
|
13
|
+
command: "bee team list"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
description: "List teams in descending order",
|
|
17
|
+
command: "bee team list --order desc"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
description: "Output as JSON",
|
|
21
|
+
command: "bee team list --json"
|
|
22
|
+
}
|
|
23
|
+
]).action(async (opts) => {
|
|
24
|
+
const { client } = await getClient(opts.space);
|
|
25
|
+
const order = parseArg(v.optional(v.picklist(["asc", "desc"])), opts.order, "--order");
|
|
26
|
+
const offset = parseArg(v.optional(vInteger), opts.offset, "--offset");
|
|
27
|
+
const count = parseArg(v.optional(vInteger), opts.count, "--count");
|
|
28
|
+
const teams = await getTeams(client, {
|
|
29
|
+
order,
|
|
30
|
+
offset,
|
|
31
|
+
count
|
|
32
|
+
});
|
|
33
|
+
outputResult(teams, opts, (data) => {
|
|
34
|
+
if (data.length === 0) {
|
|
35
|
+
consola.info("No teams found.");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const rows = data.map((t) => [
|
|
39
|
+
{
|
|
40
|
+
header: "ID",
|
|
41
|
+
value: String(t.id)
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
header: "NAME",
|
|
45
|
+
value: t.name
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
header: "MEMBERS",
|
|
49
|
+
value: String(t.members.length)
|
|
50
|
+
}
|
|
51
|
+
]);
|
|
52
|
+
printTable(rows);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
//#endregion
|
|
56
|
+
export { list as default };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { y as getClient } from "./src-CTD9-bSB.mjs";
|
|
2
|
+
import { t as outputResult } from "./output-DBvfyU1J.mjs";
|
|
3
|
+
import { r as printTable } from "./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 { getProjectStatuses } from "backlog-js";
|
|
8
|
+
//#region src/commands/status/list.ts
|
|
9
|
+
const list = new BeeCommand("list").summary("List statuses").description(`Statuses define the workflow states that issues move through.`).addOption(project()).addOption(json()).addOption(space()).envVars([...ENV_AUTH, ENV_PROJECT]).examples([{
|
|
10
|
+
description: "List all statuses",
|
|
11
|
+
command: "bee status list -p PROJECT"
|
|
12
|
+
}, {
|
|
13
|
+
description: "Output as JSON",
|
|
14
|
+
command: "bee status list -p PROJECT --json"
|
|
15
|
+
}]).action(async (opts, cmd) => {
|
|
16
|
+
await resolveOptions(cmd);
|
|
17
|
+
const { client } = await getClient(opts.space);
|
|
18
|
+
const statuses = await getProjectStatuses(client, opts.project);
|
|
19
|
+
outputResult(statuses, opts, (data) => {
|
|
20
|
+
if (data.length === 0) {
|
|
21
|
+
consola.info("No statuses found.");
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const rows = data.map((s) => [
|
|
25
|
+
{
|
|
26
|
+
header: "ID",
|
|
27
|
+
value: String(s.id)
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
header: "NAME",
|
|
31
|
+
value: s.name
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
header: "COLOR",
|
|
35
|
+
value: s.color
|
|
36
|
+
}
|
|
37
|
+
]);
|
|
38
|
+
printTable(rows);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
//#endregion
|
|
42
|
+
export { list as default };
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { b as exchangeAuthorizationCode, p as openUrl } from "./src-CTD9-bSB.mjs";
|
|
2
|
+
import { l as promptRequired, u as UserError } from "./src-CP4YLIAh.mjs";
|
|
3
|
+
import { t as readStdin } from "./stdin-C-vjNi9T.mjs";
|
|
4
|
+
import { c as RcHostSchema, o as updateConfig } from "./src-BWaxjrq_.mjs";
|
|
5
|
+
import { t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
6
|
+
import { S as space } from "./common-options-BuYWxYdO.mjs";
|
|
7
|
+
import consola from "consola";
|
|
8
|
+
import { OAuth2, createClient, getMyself } from "backlog-js";
|
|
9
|
+
import * as v from "valibot";
|
|
10
|
+
import { createServer } from "node:http";
|
|
11
|
+
//#region ../../packages/backlog-utils/src/oauth-callback.ts
|
|
12
|
+
/** 5 minutes in milliseconds */
|
|
13
|
+
const CALLBACK_TIMEOUT_MS = 3e5;
|
|
14
|
+
const DEFAULT_CALLBACK_PORT = 5033;
|
|
15
|
+
const SUCCESS_HTML = `<!DOCTYPE html>
|
|
16
|
+
<html><head><meta charset="utf-8"><title>Authentication Successful</title></head>
|
|
17
|
+
<body style="font-family:system-ui;text-align:center;padding:2em">
|
|
18
|
+
<h1>Authentication Successful</h1>
|
|
19
|
+
<p>You can close this window and return to the terminal.</p>
|
|
20
|
+
</body></html>`;
|
|
21
|
+
const ERROR_HTML = `<!DOCTYPE html>
|
|
22
|
+
<html><head><meta charset="utf-8"><title>Authentication Failed</title></head>
|
|
23
|
+
<body style="font-family:system-ui;text-align:center;padding:2em">
|
|
24
|
+
<h1>Authentication Failed</h1>
|
|
25
|
+
<p>Something went wrong. Please try again.</p>
|
|
26
|
+
</body></html>`;
|
|
27
|
+
const respondHtml = (res, html, statusCode = 200) => {
|
|
28
|
+
res.writeHead(statusCode, { "Content-Type": "text/html" });
|
|
29
|
+
res.end(html);
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Starts a local HTTP server to receive the OAuth callback.
|
|
33
|
+
*
|
|
34
|
+
* Listens on the given port (defaults to 5033, Nulab's stock code).
|
|
35
|
+
* Pass `0` to let the OS pick an available port.
|
|
36
|
+
*/
|
|
37
|
+
const startCallbackServer = (port = DEFAULT_CALLBACK_PORT) => {
|
|
38
|
+
let resolveCode = null;
|
|
39
|
+
let rejectCode = null;
|
|
40
|
+
const server = createServer((req, res) => {
|
|
41
|
+
const url = new URL(req.url ?? "/", `http://localhost:${actualPort}`);
|
|
42
|
+
if (url.pathname !== "/callback") {
|
|
43
|
+
res.writeHead(404);
|
|
44
|
+
res.end("Not Found");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const code = url.searchParams.get("code");
|
|
48
|
+
const state = url.searchParams.get("state");
|
|
49
|
+
const error = url.searchParams.get("error");
|
|
50
|
+
if (error) {
|
|
51
|
+
rejectCode?.(/* @__PURE__ */ new Error(`OAuth error: ${error}`));
|
|
52
|
+
respondHtml(res, ERROR_HTML);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!code || !state) {
|
|
56
|
+
rejectCode?.(/* @__PURE__ */ new Error("Missing code or state parameter"));
|
|
57
|
+
respondHtml(res, ERROR_HTML);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
resolveCode?.({
|
|
61
|
+
code,
|
|
62
|
+
state
|
|
63
|
+
});
|
|
64
|
+
respondHtml(res, SUCCESS_HTML);
|
|
65
|
+
});
|
|
66
|
+
server.listen(port);
|
|
67
|
+
const actualPort = server.address().port;
|
|
68
|
+
return {
|
|
69
|
+
port: actualPort,
|
|
70
|
+
waitForCallback(expectedState) {
|
|
71
|
+
return new Promise((resolve, reject) => {
|
|
72
|
+
const timeout = setTimeout(() => {
|
|
73
|
+
reject(/* @__PURE__ */ new Error("OAuth callback timed out after 5 minutes"));
|
|
74
|
+
server.close();
|
|
75
|
+
}, CALLBACK_TIMEOUT_MS);
|
|
76
|
+
resolveCode = (result) => {
|
|
77
|
+
clearTimeout(timeout);
|
|
78
|
+
if (result.state === expectedState) resolve(result.code);
|
|
79
|
+
else reject(/* @__PURE__ */ new Error("OAuth state mismatch — possible CSRF attack"));
|
|
80
|
+
};
|
|
81
|
+
rejectCode = (error) => {
|
|
82
|
+
clearTimeout(timeout);
|
|
83
|
+
reject(error);
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
stop() {
|
|
88
|
+
server.close();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/commands/auth/login.ts
|
|
94
|
+
const login = new BeeCommand("login").summary("Authenticate with a Backlog space").description(`The default mode is API key with interactive prompts.
|
|
95
|
+
|
|
96
|
+
Use \`--with-token\` to pass an API key on standard input.
|
|
97
|
+
Use \`--method oauth\` for OAuth authentication via the browser.`).addOption(space()).option("-m, --method <method>", "The authentication method to use", "api-key").option("--with-token", "Read token from standard input").envVars([
|
|
98
|
+
["BACKLOG_OAUTH_CLIENT_ID", "OAuth Client ID"],
|
|
99
|
+
["BACKLOG_OAUTH_CLIENT_SECRET", "OAuth Client Secret"],
|
|
100
|
+
["BACKLOG_OAUTH_PORT", "OAuth callback port (default: 5033)"]
|
|
101
|
+
]).examples([
|
|
102
|
+
{
|
|
103
|
+
description: "Start interactive setup",
|
|
104
|
+
command: "bee auth login"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
description: "Login with API key from stdin",
|
|
108
|
+
command: "echo 'your-api-key' | bee auth login --with-token"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
description: "Login with OAuth",
|
|
112
|
+
command: "bee auth login -m oauth"
|
|
113
|
+
}
|
|
114
|
+
]).action(async (opts) => {
|
|
115
|
+
const { method } = opts;
|
|
116
|
+
if (method !== "api-key" && method !== "oauth") throw new UserError("Invalid auth method. Use \"api-key\" or \"oauth\".");
|
|
117
|
+
const hostname = parseHostname(await promptRequired("Backlog space hostname:", opts.space, { placeholder: "xxx.backlog.com" }));
|
|
118
|
+
await (method === "api-key" ? loginWithApiKey(hostname, opts) : loginWithOAuth(hostname));
|
|
119
|
+
});
|
|
120
|
+
/**
|
|
121
|
+
* Rejects a hostname before it reaches the network, so an unusable value fails
|
|
122
|
+
* with an actionable message instead of a connection or schema error later on.
|
|
123
|
+
*/
|
|
124
|
+
const parseHostname = (input) => {
|
|
125
|
+
const result = v.safeParse(RcHostSchema, input.trim());
|
|
126
|
+
if (!result.success) throw new UserError(`"${input}" is not a valid hostname. Pass the space's bare hostname, without a scheme or path (e.g. xxx.backlog.com).`);
|
|
127
|
+
return result.output;
|
|
128
|
+
};
|
|
129
|
+
const loginWithApiKey = async (hostname, opts) => {
|
|
130
|
+
if (!opts.withToken) consola.info(`Tip: you can generate an API key at https://${hostname}/EditApiSettings.action`);
|
|
131
|
+
const apiKey = opts.withToken ? await readStdin() : await promptRequired("API key:");
|
|
132
|
+
consola.start(`Authenticating with ${hostname}...`);
|
|
133
|
+
let user;
|
|
134
|
+
try {
|
|
135
|
+
const client = createClient({
|
|
136
|
+
host: hostname,
|
|
137
|
+
apiKey
|
|
138
|
+
});
|
|
139
|
+
user = await getMyself(client);
|
|
140
|
+
} catch {
|
|
141
|
+
throw new UserError(`Authentication failed. Could not connect to ${hostname} with the provided API key.`);
|
|
142
|
+
}
|
|
143
|
+
saveSpace(hostname, {
|
|
144
|
+
method: "api-key",
|
|
145
|
+
apiKey
|
|
146
|
+
});
|
|
147
|
+
consola.success(`Logged in to ${hostname} as ${user.name} (${user.userId})`);
|
|
148
|
+
};
|
|
149
|
+
const loginWithOAuth = async (hostname) => {
|
|
150
|
+
const clientId = process.env.BACKLOG_OAUTH_CLIENT_ID;
|
|
151
|
+
const clientSecret = process.env.BACKLOG_OAUTH_CLIENT_SECRET;
|
|
152
|
+
if (!clientId || !clientSecret) throw new UserError("BACKLOG_OAUTH_CLIENT_ID and BACKLOG_OAUTH_CLIENT_SECRET must be set as environment variables.");
|
|
153
|
+
const port = process.env.BACKLOG_OAUTH_PORT ? Number(process.env.BACKLOG_OAUTH_PORT) : void 0;
|
|
154
|
+
if (port !== void 0 && (!Number.isInteger(port) || port < 0 || port > 65535)) throw new UserError("BACKLOG_OAUTH_PORT must be an integer between 0 and 65535.");
|
|
155
|
+
const callbackServer = startCallbackServer(port);
|
|
156
|
+
const redirectUri = `http://localhost:${callbackServer.port}/callback`;
|
|
157
|
+
const state = crypto.randomUUID();
|
|
158
|
+
const authUrl = new OAuth2({
|
|
159
|
+
clientId,
|
|
160
|
+
clientSecret
|
|
161
|
+
}).getAuthorizationURL({
|
|
162
|
+
host: hostname,
|
|
163
|
+
redirectUri,
|
|
164
|
+
state
|
|
165
|
+
});
|
|
166
|
+
consola.info("Opening browser for authorization...");
|
|
167
|
+
consola.info(`If the browser doesn't open, visit: ${authUrl}`);
|
|
168
|
+
await openUrl(authUrl);
|
|
169
|
+
let code;
|
|
170
|
+
try {
|
|
171
|
+
code = await callbackServer.waitForCallback(state);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
callbackServer.stop();
|
|
174
|
+
throw new UserError(`OAuth authorization failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
175
|
+
} finally {
|
|
176
|
+
callbackServer.stop();
|
|
177
|
+
}
|
|
178
|
+
consola.start("Exchanging authorization code for tokens...");
|
|
179
|
+
let tokenResponse;
|
|
180
|
+
try {
|
|
181
|
+
tokenResponse = await exchangeAuthorizationCode(hostname, {
|
|
182
|
+
code,
|
|
183
|
+
clientId,
|
|
184
|
+
clientSecret,
|
|
185
|
+
redirectUri
|
|
186
|
+
});
|
|
187
|
+
} catch {
|
|
188
|
+
throw new UserError("Failed to exchange authorization code for tokens.");
|
|
189
|
+
}
|
|
190
|
+
let user;
|
|
191
|
+
try {
|
|
192
|
+
const client = createClient({
|
|
193
|
+
host: hostname,
|
|
194
|
+
accessToken: tokenResponse.access_token
|
|
195
|
+
});
|
|
196
|
+
user = await getMyself(client);
|
|
197
|
+
} catch {
|
|
198
|
+
throw new UserError("Authentication verification failed.");
|
|
199
|
+
}
|
|
200
|
+
saveSpace(hostname, {
|
|
201
|
+
method: "oauth",
|
|
202
|
+
accessToken: tokenResponse.access_token,
|
|
203
|
+
refreshToken: tokenResponse.refresh_token,
|
|
204
|
+
clientId,
|
|
205
|
+
clientSecret
|
|
206
|
+
});
|
|
207
|
+
consola.success(`Logged in to ${hostname} as ${user.name} (${user.userId})`);
|
|
208
|
+
};
|
|
209
|
+
const saveSpace = (hostname, auth) => {
|
|
210
|
+
updateConfig((config) => {
|
|
211
|
+
const index = config.spaces.findIndex((s) => s.host === hostname);
|
|
212
|
+
const spaces = index === -1 ? [...config.spaces, {
|
|
213
|
+
host: hostname,
|
|
214
|
+
auth
|
|
215
|
+
}] : config.spaces.with(index, {
|
|
216
|
+
...config.spaces[index],
|
|
217
|
+
auth
|
|
218
|
+
});
|
|
219
|
+
const defaultSpace = config.defaultSpace ?? hostname;
|
|
220
|
+
return {
|
|
221
|
+
...config,
|
|
222
|
+
spaces,
|
|
223
|
+
defaultSpace
|
|
224
|
+
};
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
//#endregion
|
|
228
|
+
export { login as default };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { u as UserError } from "./src-CP4YLIAh.mjs";
|
|
2
|
+
import { a as loadConfig, n as removeAllSpaces, r as removeSpace } from "./src-BWaxjrq_.mjs";
|
|
3
|
+
import { t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
4
|
+
import { S as space } from "./common-options-BuYWxYdO.mjs";
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
//#region src/commands/auth/logout.ts
|
|
7
|
+
const logout = new BeeCommand("logout").summary("Remove authentication for a Backlog space").description(`Removes stored credentials locally. Does not revoke API keys or OAuth tokens on the server.`).addOption(space()).option("--all", "Log out of all spaces").examples([
|
|
8
|
+
{
|
|
9
|
+
description: "Select space via prompt",
|
|
10
|
+
command: "bee auth logout"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
description: "Log out of a specific space",
|
|
14
|
+
command: "bee auth logout -s xxx.backlog.com"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
description: "Log out of all spaces",
|
|
18
|
+
command: "bee auth logout --all"
|
|
19
|
+
}
|
|
20
|
+
]).action(async (opts) => {
|
|
21
|
+
if (opts.all && opts.space) throw new UserError("Cannot use --all with --space.");
|
|
22
|
+
const config = loadConfig();
|
|
23
|
+
if (opts.all) {
|
|
24
|
+
if (config.spaces.length === 0) {
|
|
25
|
+
consola.info("No spaces are currently authenticated.");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
removeAllSpaces();
|
|
29
|
+
consola.success(`Logged out of ${config.spaces.length} space(s).`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
let hostname = opts.space;
|
|
33
|
+
if (!hostname) {
|
|
34
|
+
if (config.spaces.length === 0) {
|
|
35
|
+
consola.info("No spaces are currently authenticated.");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const [firstSpace] = config.spaces;
|
|
39
|
+
if (config.spaces.length === 1) hostname = firstSpace.host;
|
|
40
|
+
else if (process.stdin.isTTY) {
|
|
41
|
+
hostname = await consola.prompt("Select a space to log out from:", {
|
|
42
|
+
type: "select",
|
|
43
|
+
options: config.spaces.map((s) => s.host)
|
|
44
|
+
});
|
|
45
|
+
if (typeof hostname !== "string" || !hostname) throw new UserError("No space selected.");
|
|
46
|
+
} else throw new UserError("Hostname is required. Use --space to provide it in non-interactive mode.");
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
removeSpace(hostname);
|
|
50
|
+
} catch {
|
|
51
|
+
throw new UserError(`Space "${hostname}" is not configured.`);
|
|
52
|
+
}
|
|
53
|
+
consola.success(`Logged out of ${hostname}.`);
|
|
54
|
+
});
|
|
55
|
+
//#endregion
|
|
56
|
+
export { logout as default };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { y as getClient } from "./src-CTD9-bSB.mjs";
|
|
2
|
+
import { t as outputResult } from "./output-DBvfyU1J.mjs";
|
|
3
|
+
import { n as printDefinitionList } from "./src-CP4YLIAh.mjs";
|
|
4
|
+
import { t as formatDate } from "./format-DHAR0n3J.mjs";
|
|
5
|
+
import { t as ROLE_LABELS } from "./role-labels-CLA2wmjO.mjs";
|
|
6
|
+
import { n as ENV_AUTH, t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
7
|
+
import { S as space, u as json } from "./common-options-BuYWxYdO.mjs";
|
|
8
|
+
import consola from "consola";
|
|
9
|
+
import { getMyself } from "backlog-js";
|
|
10
|
+
//#region src/commands/user/me.ts
|
|
11
|
+
const me = new BeeCommand("me").summary("View the authenticated user").description(`Shortcut for \`bee user view\` using the currently authenticated user.`).addOption(json()).addOption(space()).envVars([...ENV_AUTH]).examples([{
|
|
12
|
+
description: "View your own profile",
|
|
13
|
+
command: "bee user me"
|
|
14
|
+
}, {
|
|
15
|
+
description: "Output as JSON",
|
|
16
|
+
command: "bee user me --json"
|
|
17
|
+
}]).action(async (opts) => {
|
|
18
|
+
const { client } = await getClient(opts.space);
|
|
19
|
+
const myself = await getMyself(client);
|
|
20
|
+
outputResult(myself, opts, (data) => {
|
|
21
|
+
consola.log("");
|
|
22
|
+
consola.log(` ${data.name}`);
|
|
23
|
+
consola.log("");
|
|
24
|
+
printDefinitionList([
|
|
25
|
+
["ID", String(data.id)],
|
|
26
|
+
["User ID", data.userId],
|
|
27
|
+
["Email", data.mailAddress],
|
|
28
|
+
["Role", ROLE_LABELS[data.roleType] ?? `Unknown (${data.roleType})`],
|
|
29
|
+
["Language", data.lang],
|
|
30
|
+
["Last Login", data.lastLoginTime ? formatDate(data.lastLoginTime) : void 0]
|
|
31
|
+
]);
|
|
32
|
+
consola.log("");
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
//#endregion
|
|
36
|
+
export { me as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
2
|
+
//#region src/commands/milestone/index.ts
|
|
3
|
+
const milestone = new BeeCommand("milestone").summary("Manage project milestones");
|
|
4
|
+
await milestone.addCommands([
|
|
5
|
+
import("./list-VO_PbRjC.mjs"),
|
|
6
|
+
import("./create-vwRKZ3Lm.mjs"),
|
|
7
|
+
import("./edit-CN1gdpjd.mjs"),
|
|
8
|
+
import("./delete-CMwkcSiA.mjs")
|
|
9
|
+
]);
|
|
10
|
+
//#endregion
|
|
11
|
+
export { milestone as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
2
|
+
//#region src/commands/notification/index.ts
|
|
3
|
+
const notification = new BeeCommand("notification").summary("Manage Backlog notifications");
|
|
4
|
+
await notification.addCommands([
|
|
5
|
+
import("./list-CgIebllW.mjs"),
|
|
6
|
+
import("./count-DvmYzPD_.mjs"),
|
|
7
|
+
import("./read-CyCASx6U.mjs"),
|
|
8
|
+
import("./read-all-CjgMJ2to.mjs")
|
|
9
|
+
]);
|
|
10
|
+
//#endregion
|
|
11
|
+
export { notification as default };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region ../../packages/cli-utils/src/output.ts
|
|
2
|
+
const isRecord = (value) => typeof value === "object" && value !== null;
|
|
3
|
+
/**
|
|
4
|
+
* Picks specified top-level fields from a plain object.
|
|
5
|
+
*/
|
|
6
|
+
const pickFields = (obj, fields) => {
|
|
7
|
+
if (!isRecord(obj)) return {};
|
|
8
|
+
const result = {};
|
|
9
|
+
for (const field of fields) if (field in obj) result[field] = obj[field];
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Filters data to include only the specified fields.
|
|
14
|
+
* Works on both single objects and arrays.
|
|
15
|
+
*/
|
|
16
|
+
const filterFields = (data, fields) => {
|
|
17
|
+
if (Array.isArray(data)) return data.map((item) => pickFields(item, fields));
|
|
18
|
+
return pickFields(data, fields);
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Outputs structured data based on the `--json` flag.
|
|
22
|
+
*
|
|
23
|
+
* - No `--json`: calls `defaultFormat` for human-readable output
|
|
24
|
+
* - `--json` (no value): outputs full JSON
|
|
25
|
+
* - `--json field1,field2`: outputs JSON filtered to specified fields
|
|
26
|
+
*
|
|
27
|
+
* JSON is pretty-printed when stdout is a TTY, compact otherwise.
|
|
28
|
+
*/
|
|
29
|
+
const outputResult = (data, args, defaultFormat) => {
|
|
30
|
+
if (args.json === void 0) {
|
|
31
|
+
defaultFormat(data);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const output = args.json ? filterFields(data, args.json.split(",").map((f) => f.trim())) : data;
|
|
35
|
+
const json = process.stdout.isTTY ? JSON.stringify(output, null, 2) : JSON.stringify(output);
|
|
36
|
+
process.stdout.write(`${json}\n`);
|
|
37
|
+
};
|
|
38
|
+
//#endregion
|
|
39
|
+
export { outputResult as t };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
2
|
+
//#region src/commands/pr/index.ts
|
|
3
|
+
const pr = new BeeCommand("pr").summary("Manage Backlog pull requests");
|
|
4
|
+
await pr.addCommands([
|
|
5
|
+
import("./list-b6ByzUFt.mjs"),
|
|
6
|
+
import("./view-DJHrnN8j.mjs"),
|
|
7
|
+
import("./comments-SnOZ-EUJ.mjs"),
|
|
8
|
+
import("./status-CaGqMXh7.mjs"),
|
|
9
|
+
import("./create-DhAOhro9.mjs"),
|
|
10
|
+
import("./edit-Otc7XHU7.mjs"),
|
|
11
|
+
import("./comment-DzRBQNv8.mjs"),
|
|
12
|
+
import("./count-BI7ld4k5.mjs")
|
|
13
|
+
]);
|
|
14
|
+
//#endregion
|
|
15
|
+
export { pr as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
2
|
+
//#region src/commands/project/index.ts
|
|
3
|
+
const project = new BeeCommand("project").summary("Manage Backlog projects");
|
|
4
|
+
await project.addCommands([
|
|
5
|
+
import("./list-DqpWd9aR.mjs"),
|
|
6
|
+
import("./view-C1ECwTMN.mjs"),
|
|
7
|
+
import("./create-Y4vo2zwX.mjs"),
|
|
8
|
+
import("./edit-DxsP-aPX.mjs"),
|
|
9
|
+
import("./delete-CTeH7nzL.mjs"),
|
|
10
|
+
import("./users-BSGqsGSy.mjs"),
|
|
11
|
+
import("./activities-CRiEq51-.mjs"),
|
|
12
|
+
import("./add-user-BVWFcbH7.mjs"),
|
|
13
|
+
import("./remove-user-CShNCvf8.mjs")
|
|
14
|
+
]);
|
|
15
|
+
//#endregion
|
|
16
|
+
export { project as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { y as getClient } from "./src-CTD9-bSB.mjs";
|
|
2
|
+
import { a as parseArg, s as vInteger } from "./src-CP4YLIAh.mjs";
|
|
3
|
+
import { n as ENV_AUTH, t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
4
|
+
import { S as space } from "./common-options-BuYWxYdO.mjs";
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
import { resetWatchingListItemAsRead } from "backlog-js";
|
|
7
|
+
//#region src/commands/watching/read.ts
|
|
8
|
+
const read = new BeeCommand("read").summary("Mark a watching item as read").description(`Use \`bee watching list\` to find watching IDs.`).argument("<watching>", "Watching ID").addOption(space()).envVars([...ENV_AUTH]).examples([{
|
|
9
|
+
description: "Mark a watching item as read",
|
|
10
|
+
command: "bee watching read 12345"
|
|
11
|
+
}]).action(async (watching, opts) => {
|
|
12
|
+
const { client } = await getClient(opts.space);
|
|
13
|
+
await resetWatchingListItemAsRead(client, parseArg(vInteger, watching, "watching"));
|
|
14
|
+
consola.success(`Marked watching ${watching} as read.`);
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
export { read as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { y as getClient } from "./src-CTD9-bSB.mjs";
|
|
2
|
+
import { a as parseArg, s as vInteger } from "./src-CP4YLIAh.mjs";
|
|
3
|
+
import { n as ENV_AUTH, t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
4
|
+
import { S as space } from "./common-options-BuYWxYdO.mjs";
|
|
5
|
+
import consola from "consola";
|
|
6
|
+
import { markAsReadNotification } from "backlog-js";
|
|
7
|
+
//#region src/commands/notification/read.ts
|
|
8
|
+
const read = new BeeCommand("read").summary("Mark a notification as read").description(`Use \`bee notification list\` to find notification IDs.`).argument("<id>", "Notification ID").addOption(space()).envVars([...ENV_AUTH]).examples([{
|
|
9
|
+
description: "Mark a notification as read",
|
|
10
|
+
command: "bee notification read 12345"
|
|
11
|
+
}]).action(async (id, opts) => {
|
|
12
|
+
const { client } = await getClient(opts.space);
|
|
13
|
+
await markAsReadNotification(client, parseArg(vInteger, id, "id"));
|
|
14
|
+
consola.success(`Marked notification ${id} as read.`);
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
export { read as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { y as getClient } from "./src-CTD9-bSB.mjs";
|
|
2
|
+
import { n as ENV_AUTH, t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
3
|
+
import { S as space } from "./common-options-BuYWxYdO.mjs";
|
|
4
|
+
import consola from "consola";
|
|
5
|
+
import { resetNotificationsMarkAsRead } from "backlog-js";
|
|
6
|
+
//#region src/commands/notification/read-all.ts
|
|
7
|
+
const readAll = new BeeCommand("read-all").summary("Mark all notifications as read").description(`Resets the unread notification count to zero.`).addOption(space()).envVars([...ENV_AUTH]).examples([{
|
|
8
|
+
description: "Mark all notifications as read",
|
|
9
|
+
command: "bee notification read-all"
|
|
10
|
+
}]).action(async (opts) => {
|
|
11
|
+
const { client } = await getClient(opts.space);
|
|
12
|
+
await resetNotificationsMarkAsRead(client);
|
|
13
|
+
consola.success("Marked all notifications as read.");
|
|
14
|
+
});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { readAll as default };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { x as refreshAccessToken } from "./src-CTD9-bSB.mjs";
|
|
2
|
+
import { u as UserError } from "./src-CP4YLIAh.mjs";
|
|
3
|
+
import { a as loadConfig, i as updateSpaceAuth, t as findSpace } from "./src-BWaxjrq_.mjs";
|
|
4
|
+
import { t as BeeCommand } from "./bee-command-v0qvZeth.mjs";
|
|
5
|
+
import { S as space } from "./common-options-BuYWxYdO.mjs";
|
|
6
|
+
import consola from "consola";
|
|
7
|
+
import { createClient, getMyself } from "backlog-js";
|
|
8
|
+
//#region src/commands/auth/refresh.ts
|
|
9
|
+
const refresh = new BeeCommand("refresh").summary("Refresh OAuth token").description(`Only available for spaces authenticated with OAuth. If the refresh token is expired, re-authenticate with \`bee auth login -m oauth\`.`).addOption(space()).examples([{
|
|
10
|
+
description: "Refresh token for default space",
|
|
11
|
+
command: "bee auth refresh"
|
|
12
|
+
}, {
|
|
13
|
+
description: "Refresh token for specific space",
|
|
14
|
+
command: "bee auth refresh -s xxx.backlog.com"
|
|
15
|
+
}]).action(async (opts) => {
|
|
16
|
+
const config = loadConfig();
|
|
17
|
+
const host = opts.space ?? config.defaultSpace;
|
|
18
|
+
const space = host ? findSpace(config.spaces, host) : null;
|
|
19
|
+
if (!space) throw new UserError("No space configured. Run `bee auth login` to authenticate.");
|
|
20
|
+
if (space.auth.method !== "oauth") throw new UserError("Token refresh is only available for OAuth authentication. Current space uses API key.");
|
|
21
|
+
const { clientId, clientSecret } = space.auth;
|
|
22
|
+
if (!clientId || !clientSecret) throw new UserError("Client ID and Client Secret are missing from the stored OAuth configuration. Please re-authenticate with `bee auth login -m oauth`.");
|
|
23
|
+
consola.start(`Refreshing OAuth token for ${space.host}...`);
|
|
24
|
+
let tokenResponse;
|
|
25
|
+
try {
|
|
26
|
+
tokenResponse = await refreshAccessToken(space.host, {
|
|
27
|
+
clientId,
|
|
28
|
+
clientSecret,
|
|
29
|
+
refreshToken: space.auth.refreshToken
|
|
30
|
+
});
|
|
31
|
+
} catch {
|
|
32
|
+
throw new UserError("Failed to refresh OAuth token. Please re-authenticate with `bee auth login -m oauth`.");
|
|
33
|
+
}
|
|
34
|
+
let user;
|
|
35
|
+
try {
|
|
36
|
+
const client = createClient({
|
|
37
|
+
host: space.host,
|
|
38
|
+
accessToken: tokenResponse.access_token
|
|
39
|
+
});
|
|
40
|
+
user = await getMyself(client);
|
|
41
|
+
} catch {
|
|
42
|
+
throw new UserError("Token verification failed after refresh.");
|
|
43
|
+
}
|
|
44
|
+
updateSpaceAuth(space.host, {
|
|
45
|
+
method: "oauth",
|
|
46
|
+
accessToken: tokenResponse.access_token,
|
|
47
|
+
refreshToken: tokenResponse.refresh_token,
|
|
48
|
+
clientId,
|
|
49
|
+
clientSecret
|
|
50
|
+
});
|
|
51
|
+
consola.success(`Token refreshed for ${space.host} (${user.name})`);
|
|
52
|
+
});
|
|
53
|
+
//#endregion
|
|
54
|
+
export { refresh as default };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import "commander";
|
|
2
|
+
//#region src/commands/registry.ts
|
|
3
|
+
/**
|
|
4
|
+
* Every top-level command, in the order they are presented to users.
|
|
5
|
+
*
|
|
6
|
+
* Imports stay lazy so `bee <command>` only pays for the module it runs, and so
|
|
7
|
+
* the Skill generator can load the whole tree without executing the CLI entry
|
|
8
|
+
* point (which parses argv on import).
|
|
9
|
+
*/
|
|
10
|
+
const commandModules = [
|
|
11
|
+
() => import("./auth-5TJGBPxi.mjs"),
|
|
12
|
+
() => import("./project-Dilo1T5e.mjs"),
|
|
13
|
+
() => import("./issue-BRzJy3k1.mjs"),
|
|
14
|
+
() => import("./document-CiIzSyoS.mjs"),
|
|
15
|
+
() => import("./notification-CsOuC8Uk.mjs"),
|
|
16
|
+
() => import("./pr-BBe07JUp.mjs"),
|
|
17
|
+
() => import("./repo-B2K8y0mD.mjs"),
|
|
18
|
+
() => import("./team-DfQn8Tf5.mjs"),
|
|
19
|
+
() => import("./user-DMyFmoP3.mjs"),
|
|
20
|
+
() => import("./wiki-B-DQUuIX.mjs"),
|
|
21
|
+
() => import("./category-BZ7XdVgx.mjs"),
|
|
22
|
+
() => import("./milestone-Dc3alfp9.mjs"),
|
|
23
|
+
() => import("./issue-type-Byzh4yLx.mjs"),
|
|
24
|
+
() => import("./space-BgZeUqoH.mjs"),
|
|
25
|
+
() => import("./status-DDFyQrRZ.mjs"),
|
|
26
|
+
() => import("./star-Sgb-e2CQ.mjs"),
|
|
27
|
+
() => import("./watching-D22YYxOT.mjs"),
|
|
28
|
+
() => import("./dashboard-CYYU5Yii.mjs"),
|
|
29
|
+
() => import("./browse-vgF6nz7X.mjs"),
|
|
30
|
+
() => import("./api-kJR0fRPw.mjs"),
|
|
31
|
+
() => import("./completion-yfcnEl7k.mjs")
|
|
32
|
+
];
|
|
33
|
+
const loadCommands = () => commandModules.map((load) => load());
|
|
34
|
+
//#endregion
|
|
35
|
+
export { loadCommands as t };
|