@kud/jira-cli 0.3.1 → 0.4.1
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.
|
@@ -1,52 +1,8 @@
|
|
|
1
|
-
// src/config.ts
|
|
2
|
-
import { readFileSync } from "fs";
|
|
3
|
-
import { homedir } from "os";
|
|
4
|
-
import { join } from "path";
|
|
5
|
-
import { normalizeBaseUrl } from "@kud/jira";
|
|
6
|
-
var configPath = () => process.env["JIRA_CONFIG_FILE"] || join(
|
|
7
|
-
process.env["XDG_CONFIG_HOME"] || join(homedir(), ".config"),
|
|
8
|
-
"jira",
|
|
9
|
-
"config.json"
|
|
10
|
-
);
|
|
11
|
-
var readFileConfig = (path = configPath()) => {
|
|
12
|
-
let raw;
|
|
13
|
-
try {
|
|
14
|
-
raw = readFileSync(path, "utf8");
|
|
15
|
-
} catch {
|
|
16
|
-
return {};
|
|
17
|
-
}
|
|
18
|
-
const parsed = JSON.parse(raw);
|
|
19
|
-
if (parsed.customFields && !Array.isArray(parsed.customFields))
|
|
20
|
-
throw new Error(`${path}: customFields must be an array of {id,label}`);
|
|
21
|
-
if ("token" in parsed || "apiToken" in parsed)
|
|
22
|
-
throw new Error(
|
|
23
|
-
`${path} contains a token. Tokens belong in ATLASSIAN_API_TOKEN, not in a file that gets shared and backed up \u2014 remove it.`
|
|
24
|
-
);
|
|
25
|
-
return parsed;
|
|
26
|
-
};
|
|
27
|
-
var loadConfig = (env = process.env, path = configPath()) => {
|
|
28
|
-
const file = readFileConfig(path);
|
|
29
|
-
const baseUrl = env["ATLASSIAN_BASE_URL"] || file.baseUrl;
|
|
30
|
-
const email = env["ATLASSIAN_USER_EMAIL"] || file.email;
|
|
31
|
-
const token = env["ATLASSIAN_API_TOKEN"];
|
|
32
|
-
const missing = [
|
|
33
|
-
["ATLASSIAN_BASE_URL", baseUrl],
|
|
34
|
-
["ATLASSIAN_USER_EMAIL", email],
|
|
35
|
-
["ATLASSIAN_API_TOKEN", token]
|
|
36
|
-
].filter(([, v]) => !v).map(([k]) => k);
|
|
37
|
-
if (missing.length > 0) return { missing };
|
|
38
|
-
return {
|
|
39
|
-
config: {
|
|
40
|
-
...file,
|
|
41
|
-
baseUrl: normalizeBaseUrl(baseUrl),
|
|
42
|
-
email,
|
|
43
|
-
token
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
1
|
// src/commands/context.ts
|
|
49
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createJiraClient,
|
|
4
|
+
loadConfig
|
|
5
|
+
} from "@kud/jira";
|
|
50
6
|
|
|
51
7
|
// src/output/format.ts
|
|
52
8
|
var identity = (s) => s;
|
|
@@ -108,8 +64,6 @@ var printJson = (value) => {
|
|
|
108
64
|
export {
|
|
109
65
|
table,
|
|
110
66
|
truncate,
|
|
111
|
-
configPath,
|
|
112
|
-
readFileConfig,
|
|
113
67
|
exitError,
|
|
114
68
|
isExitError,
|
|
115
69
|
context,
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
configPath,
|
|
4
3
|
context,
|
|
5
4
|
exitError,
|
|
6
5
|
isExitError,
|
|
7
6
|
printJson,
|
|
8
|
-
readFileConfig,
|
|
9
7
|
table,
|
|
10
8
|
truncate
|
|
11
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-RTBMVYZM.js";
|
|
12
10
|
|
|
13
11
|
// src/index.ts
|
|
14
12
|
import { realpathSync } from "fs";
|
|
15
13
|
import { createRequire } from "module";
|
|
16
14
|
import { fileURLToPath } from "url";
|
|
17
15
|
import { Command } from "commander";
|
|
18
|
-
import { isJiraApiError } from "@kud/jira";
|
|
16
|
+
import { configPath as configPath2, isJiraApiError } from "@kud/jira";
|
|
19
17
|
|
|
20
18
|
// src/commands/attachment.ts
|
|
21
19
|
import { writeFileSync } from "fs";
|
|
@@ -454,6 +452,9 @@ var registerIssueCommands = (program2) => {
|
|
|
454
452
|
const lines = [
|
|
455
453
|
`${bold(found.key)} ${f.summary ?? ""}`,
|
|
456
454
|
"",
|
|
455
|
+
...f.parent ? [
|
|
456
|
+
`${dim("parent")} ${f.parent.key} ${truncate(f.parent.fields?.summary ?? "", 60)}`
|
|
457
|
+
] : [],
|
|
457
458
|
`${dim("status")} ${f.status?.name ?? "\u2014"}`,
|
|
458
459
|
`${dim("type")} ${f.issuetype?.name ?? "\u2014"}`,
|
|
459
460
|
`${dim("assignee")} ${f.assignee?.displayName ?? "unassigned"}`,
|
|
@@ -734,6 +735,7 @@ var registerProjectCommands = (program2) => {
|
|
|
734
735
|
// src/commands/misc.ts
|
|
735
736
|
import { mkdirSync, writeFileSync as writeFileSync2 } from "fs";
|
|
736
737
|
import { dirname } from "path";
|
|
738
|
+
import { configPath, readFileConfig } from "@kud/jira";
|
|
737
739
|
var registerSearchCommand = (program2) => {
|
|
738
740
|
program2.command("search <jql>").description("run a raw JQL query").option("-n, --limit <n>", "maximum issues to return", "50").option("--json", "emit JSON").action(async (jql, options) => {
|
|
739
741
|
const ctx = context();
|
|
@@ -848,7 +850,7 @@ Setup:
|
|
|
848
850
|
id.atlassian.com/manage-profile/security/api-tokens
|
|
849
851
|
jira init --base-url myorg.atlassian.net --email you@example.com
|
|
850
852
|
|
|
851
|
-
Everything else lives in ${
|
|
853
|
+
Everything else lives in ${configPath2()}, and any of it can be
|
|
852
854
|
overridden with ATLASSIAN_BASE_URL / ATLASSIAN_USER_EMAIL.
|
|
853
855
|
|
|
854
856
|
Examples:
|
|
@@ -887,11 +889,15 @@ var fail = (error) => {
|
|
|
887
889
|
};
|
|
888
890
|
var interactiveArgs = (argv) => {
|
|
889
891
|
const rest = argv.slice(2);
|
|
890
|
-
const
|
|
891
|
-
const
|
|
892
|
-
const
|
|
893
|
-
|
|
894
|
-
);
|
|
892
|
+
const inlineAt = rest.findIndex((a) => a.startsWith("--screen="));
|
|
893
|
+
const spacedAt = rest.indexOf("--screen");
|
|
894
|
+
const screen = inlineAt !== -1 ? rest[inlineAt]?.slice("--screen=".length) : spacedAt === -1 ? void 0 : rest[spacedAt + 1];
|
|
895
|
+
const consumed = /* @__PURE__ */ new Set(["--mock"]);
|
|
896
|
+
if (inlineAt !== -1) consumed.add(rest[inlineAt]);
|
|
897
|
+
if (spacedAt !== -1) {
|
|
898
|
+
consumed.add("--screen");
|
|
899
|
+
consumed.add(rest[spacedAt + 1] ?? "");
|
|
900
|
+
}
|
|
895
901
|
return {
|
|
896
902
|
screen,
|
|
897
903
|
mock: rest.includes("--mock"),
|
|
@@ -901,7 +907,7 @@ var interactiveArgs = (argv) => {
|
|
|
901
907
|
var main = async () => {
|
|
902
908
|
const { screen, mock, isBare } = interactiveArgs(process.argv);
|
|
903
909
|
if (screen === "list" && isBare) {
|
|
904
|
-
const { SCREENS } = await import("./tui-
|
|
910
|
+
const { SCREENS } = await import("./tui-IET37PRI.js");
|
|
905
911
|
process.stdout.write(`${SCREENS.join("\n")}
|
|
906
912
|
`);
|
|
907
913
|
return;
|
|
@@ -911,7 +917,7 @@ var main = async () => {
|
|
|
911
917
|
program.outputHelp();
|
|
912
918
|
return;
|
|
913
919
|
}
|
|
914
|
-
const { runTui } = await import("./tui-
|
|
920
|
+
const { runTui } = await import("./tui-IET37PRI.js");
|
|
915
921
|
const [, key] = (screen ?? "").split(":");
|
|
916
922
|
await runTui({
|
|
917
923
|
screen: screen?.startsWith("detail") ? "detail" : "issues",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
context
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RTBMVYZM.js";
|
|
4
4
|
|
|
5
5
|
// src/tui/index.tsx
|
|
6
6
|
import { render } from "ink";
|
|
@@ -8,117 +8,14 @@ import { render } from "ink";
|
|
|
8
8
|
// src/tui/app.tsx
|
|
9
9
|
import { execFile } from "child_process";
|
|
10
10
|
import { Alert, ConfirmInput, Select, Spinner, TextInput } from "@kud/ink-ui";
|
|
11
|
-
import { Box as
|
|
12
|
-
import { useCallback, useEffect, useState
|
|
11
|
+
import { Box as Box2, Text as Text2, useApp, useInput as useInput2, useStdout } from "ink";
|
|
12
|
+
import { useCallback, useEffect, useState } from "react";
|
|
13
|
+
import { IssueDetailView } from "@kud/jira-ink";
|
|
13
14
|
|
|
14
|
-
// src/tui/
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
Badge,
|
|
18
|
-
FooterHints,
|
|
19
|
-
KeyValue,
|
|
20
|
-
Tabs,
|
|
21
|
-
useTabs
|
|
22
|
-
} from "@kud/ink-ui";
|
|
15
|
+
// src/tui/list.tsx
|
|
16
|
+
import { FooterHints, SelectableRow, useListCursor } from "@kud/ink-ui";
|
|
23
17
|
import { Box, Text, useInput } from "ink";
|
|
24
|
-
import { useState } from "react";
|
|
25
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
-
var originOf = (a) => a.origins.map(
|
|
27
|
-
(o) => o.kind === "comment" ? `comment by ${o.author ?? "unknown"}` : o.kind === "description" ? "description" : "issue"
|
|
28
|
-
).join(", ");
|
|
29
|
-
var humanSize = (bytes) => {
|
|
30
|
-
const units = ["B", "KB", "MB", "GB"];
|
|
31
|
-
const e = Math.min(
|
|
32
|
-
units.length - 1,
|
|
33
|
-
Math.floor(Math.log(Math.max(bytes, 1)) / Math.log(1024))
|
|
34
|
-
);
|
|
35
|
-
const value = bytes / 1024 ** e;
|
|
36
|
-
return `${e === 0 ? value : value.toFixed(1)}${units[e]}`;
|
|
37
|
-
};
|
|
38
|
-
var commentsAsMarkdown = (issue) => issue.comments.length === 0 ? "_No comments._" : issue.comments.map((c) => `**${c.author}** \xB7 ${c.created}
|
|
39
|
-
|
|
40
|
-
${c.body}`).join("\n\n---\n\n");
|
|
41
|
-
var attachmentsAsMarkdown = (issue) => issue.attachments.length === 0 ? "_No attachments._" : issue.attachments.map(
|
|
42
|
-
(a) => `- \`${a.filename}\` \u2014 ${a.mimeType}, ${humanSize(a.size)}
|
|
43
|
-
from ${originOf(a)}
|
|
44
|
-
\`jira attachment read ${issue.key} ${a.filename}\``
|
|
45
|
-
).join("\n");
|
|
46
|
-
var IssueDetailView = ({
|
|
47
|
-
issue,
|
|
48
|
-
height,
|
|
49
|
-
width,
|
|
50
|
-
onBack,
|
|
51
|
-
onTransition,
|
|
52
|
-
onComment,
|
|
53
|
-
onAssign,
|
|
54
|
-
onOpenBrowser
|
|
55
|
-
}) => {
|
|
56
|
-
const tabs = [
|
|
57
|
-
{ value: "description", label: "Description" },
|
|
58
|
-
{ value: "comments", label: "Comments", count: issue.comments.length },
|
|
59
|
-
{
|
|
60
|
-
value: "attachments",
|
|
61
|
-
label: "Attachments",
|
|
62
|
-
count: issue.attachments.length
|
|
63
|
-
}
|
|
64
|
-
];
|
|
65
|
-
const { active } = useTabs(tabs, { initial: "description" });
|
|
66
|
-
const [scroll, setScroll] = useState(0);
|
|
67
|
-
useInput((input, key) => {
|
|
68
|
-
if (key.escape || key.leftArrow) return onBack();
|
|
69
|
-
if (input === "t") return onTransition();
|
|
70
|
-
if (input === "c") return onComment();
|
|
71
|
-
if (input === "a") return onAssign();
|
|
72
|
-
if (input === "o") return onOpenBrowser();
|
|
73
|
-
if (key.downArrow || input === "j") setScroll((s) => s + 1);
|
|
74
|
-
if (key.upArrow || input === "k") setScroll((s) => Math.max(0, s - 1));
|
|
75
|
-
});
|
|
76
|
-
const source = active === "comments" ? commentsAsMarkdown(issue) : active === "attachments" ? attachmentsAsMarkdown(issue) : issue.description || "_No description._";
|
|
77
|
-
const bodyHeight = Math.max(3, height - 12);
|
|
78
|
-
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
79
|
-
/* @__PURE__ */ jsxs(Text, { bold: true, children: [
|
|
80
|
-
issue.key,
|
|
81
|
-
" ",
|
|
82
|
-
issue.summary
|
|
83
|
-
] }),
|
|
84
|
-
/* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "column", children: [
|
|
85
|
-
/* @__PURE__ */ jsx(KeyValue, { label: "status", value: /* @__PURE__ */ jsx(Badge, { children: issue.status }) }),
|
|
86
|
-
/* @__PURE__ */ jsx(KeyValue, { label: "type", value: issue.type }),
|
|
87
|
-
/* @__PURE__ */ jsx(KeyValue, { label: "assignee", value: issue.assignee }),
|
|
88
|
-
/* @__PURE__ */ jsx(KeyValue, { label: "reporter", value: issue.reporter }),
|
|
89
|
-
issue.labels.length > 0 && /* @__PURE__ */ jsx(KeyValue, { label: "labels", value: issue.labels.join(", ") })
|
|
90
|
-
] }),
|
|
91
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Tabs, { items: tabs, active: active ?? "description" }) }),
|
|
92
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(
|
|
93
|
-
MarkdownViewport,
|
|
94
|
-
{
|
|
95
|
-
source,
|
|
96
|
-
width: Math.max(20, width - 2),
|
|
97
|
-
height: bodyHeight,
|
|
98
|
-
scrollOffset: scroll
|
|
99
|
-
}
|
|
100
|
-
) }),
|
|
101
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(
|
|
102
|
-
FooterHints,
|
|
103
|
-
{
|
|
104
|
-
hints: [
|
|
105
|
-
["\u2190\u2192", "section"],
|
|
106
|
-
["\u2191\u2193", "scroll"],
|
|
107
|
-
["t", "transition"],
|
|
108
|
-
["c", "comment"],
|
|
109
|
-
["a", "assign to me"],
|
|
110
|
-
["o", "browser"],
|
|
111
|
-
["esc", "back"]
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
) })
|
|
115
|
-
] });
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// src/tui/list.tsx
|
|
119
|
-
import { FooterHints as FooterHints2, SelectableRow, useListCursor } from "@kud/ink-ui";
|
|
120
|
-
import { Box as Box2, Text as Text2, useInput as useInput2 } from "ink";
|
|
121
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
122
19
|
var pad = (s, width) => s.length > width ? `${s.slice(0, width - 1)}\u2026` : s.padEnd(width);
|
|
123
20
|
var windowFor = (cursor, total, size) => {
|
|
124
21
|
const start = Math.max(
|
|
@@ -136,7 +33,7 @@ var IssueList = ({
|
|
|
136
33
|
height
|
|
137
34
|
}) => {
|
|
138
35
|
const { cursor } = useListCursor(rows.length, { vimKeys: true });
|
|
139
|
-
|
|
36
|
+
useInput((input, key) => {
|
|
140
37
|
if (key.return && rows[cursor]) onOpen(rows[cursor].key);
|
|
141
38
|
if (input === "a") onToggleAll();
|
|
142
39
|
if (input === "r") onRefresh();
|
|
@@ -149,41 +46,41 @@ var IssueList = ({
|
|
|
149
46
|
["q", "quit"]
|
|
150
47
|
];
|
|
151
48
|
if (rows.length === 0) {
|
|
152
|
-
return /* @__PURE__ */
|
|
153
|
-
/* @__PURE__ */
|
|
154
|
-
/* @__PURE__ */
|
|
49
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", gap: 1, children: [
|
|
50
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: showingAll ? "Nothing is assigned to you." : "No open issues assigned to you \u2014 press a to include closed ones." }),
|
|
51
|
+
/* @__PURE__ */ jsx(FooterHints, { hints })
|
|
155
52
|
] });
|
|
156
53
|
}
|
|
157
54
|
const size = Math.max(3, height - 5);
|
|
158
55
|
const { start, end } = windowFor(cursor, rows.length, size);
|
|
159
56
|
const visible = rows.slice(start, end);
|
|
160
|
-
return /* @__PURE__ */
|
|
161
|
-
/* @__PURE__ */
|
|
57
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
58
|
+
/* @__PURE__ */ jsx(Box, { paddingLeft: 4, children: /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
162
59
|
pad("KEY", 11),
|
|
163
60
|
pad("STATUS", 17),
|
|
164
61
|
pad("SUMMARY", 60),
|
|
165
62
|
"ASSIGNEE"
|
|
166
63
|
] }) }),
|
|
167
|
-
visible.map((row, i) => /* @__PURE__ */
|
|
64
|
+
visible.map((row, i) => /* @__PURE__ */ jsx(SelectableRow, { active: start + i === cursor, children: /* @__PURE__ */ jsxs(Text, { children: [
|
|
168
65
|
pad(row.key, 11),
|
|
169
66
|
pad(row.status, 17),
|
|
170
67
|
pad(row.summary, 60),
|
|
171
|
-
/* @__PURE__ */
|
|
68
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: row.assignee })
|
|
172
69
|
] }) }, row.key)),
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "column", children: [
|
|
71
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
175
72
|
cursor + 1,
|
|
176
73
|
"/",
|
|
177
74
|
rows.length,
|
|
178
75
|
showingAll ? " \xB7 all" : " \xB7 open only"
|
|
179
76
|
] }),
|
|
180
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ jsx(FooterHints, { hints })
|
|
181
78
|
] })
|
|
182
79
|
] });
|
|
183
80
|
};
|
|
184
81
|
|
|
185
82
|
// src/tui/app.tsx
|
|
186
|
-
import { jsx as
|
|
83
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
187
84
|
var MIN_WIDTH = 60;
|
|
188
85
|
var MIN_HEIGHT = 12;
|
|
189
86
|
var App = ({ data, initialScreen, initialKey }) => {
|
|
@@ -191,13 +88,13 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
191
88
|
const { stdout } = useStdout();
|
|
192
89
|
const width = stdout?.columns ?? 80;
|
|
193
90
|
const height = stdout?.rows ?? 24;
|
|
194
|
-
const [screen, setScreen] =
|
|
195
|
-
const [rows, setRows] =
|
|
196
|
-
const [issue, setIssue] =
|
|
197
|
-
const [overlay, setOverlay] =
|
|
198
|
-
const [showingAll, setShowingAll] =
|
|
199
|
-
const [error, setError] =
|
|
200
|
-
const [busy, setBusy] =
|
|
91
|
+
const [screen, setScreen] = useState(initialScreen);
|
|
92
|
+
const [rows, setRows] = useState(null);
|
|
93
|
+
const [issue, setIssue] = useState(null);
|
|
94
|
+
const [overlay, setOverlay] = useState({ kind: "none" });
|
|
95
|
+
const [showingAll, setShowingAll] = useState(false);
|
|
96
|
+
const [error, setError] = useState(null);
|
|
97
|
+
const [busy, setBusy] = useState(null);
|
|
201
98
|
const loadList = useCallback(
|
|
202
99
|
async (all) => {
|
|
203
100
|
setError(null);
|
|
@@ -227,7 +124,7 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
227
124
|
if (initialScreen === "detail" && initialKey) void loadIssue(initialKey);
|
|
228
125
|
else void loadList(false);
|
|
229
126
|
}, [initialScreen, initialKey, loadIssue, loadList]);
|
|
230
|
-
|
|
127
|
+
useInput2((input, key) => {
|
|
231
128
|
if (overlay.kind !== "none") return;
|
|
232
129
|
if (input === "q" || key.ctrl && input === "c") exit();
|
|
233
130
|
if (error && input === "r") {
|
|
@@ -236,7 +133,7 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
236
133
|
}
|
|
237
134
|
});
|
|
238
135
|
if (width < MIN_WIDTH || height < MIN_HEIGHT) {
|
|
239
|
-
return /* @__PURE__ */
|
|
136
|
+
return /* @__PURE__ */ jsxs2(Text2, { children: [
|
|
240
137
|
"Terminal too small \u2014 needs at least ",
|
|
241
138
|
MIN_WIDTH,
|
|
242
139
|
"\xD7",
|
|
@@ -250,20 +147,20 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
250
147
|
] });
|
|
251
148
|
}
|
|
252
149
|
if (error) {
|
|
253
|
-
return /* @__PURE__ */
|
|
254
|
-
/* @__PURE__ */
|
|
255
|
-
/* @__PURE__ */
|
|
150
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", gap: 1, children: [
|
|
151
|
+
/* @__PURE__ */ jsx2(Alert, { variant: "error", children: error }),
|
|
152
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "r retry \xB7 q quit" })
|
|
256
153
|
] });
|
|
257
154
|
}
|
|
258
|
-
if (busy) return /* @__PURE__ */
|
|
155
|
+
if (busy) return /* @__PURE__ */ jsx2(Spinner, { label: busy });
|
|
259
156
|
if (overlay.kind === "transition") {
|
|
260
|
-
return /* @__PURE__ */
|
|
261
|
-
/* @__PURE__ */
|
|
157
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", gap: 1, children: [
|
|
158
|
+
/* @__PURE__ */ jsxs2(Text2, { bold: true, children: [
|
|
262
159
|
"Move ",
|
|
263
160
|
issue?.key,
|
|
264
161
|
" to\u2026"
|
|
265
162
|
] }),
|
|
266
|
-
/* @__PURE__ */
|
|
163
|
+
/* @__PURE__ */ jsx2(
|
|
267
164
|
Select,
|
|
268
165
|
{
|
|
269
166
|
options: overlay.options.map((t) => ({
|
|
@@ -286,16 +183,16 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
286
183
|
}
|
|
287
184
|
}
|
|
288
185
|
),
|
|
289
|
-
/* @__PURE__ */
|
|
186
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "esc cancel" })
|
|
290
187
|
] });
|
|
291
188
|
}
|
|
292
189
|
if (overlay.kind === "comment") {
|
|
293
|
-
return /* @__PURE__ */
|
|
294
|
-
/* @__PURE__ */
|
|
190
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", gap: 1, children: [
|
|
191
|
+
/* @__PURE__ */ jsxs2(Text2, { bold: true, children: [
|
|
295
192
|
"Comment on ",
|
|
296
193
|
issue?.key
|
|
297
194
|
] }),
|
|
298
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ jsx2(
|
|
299
196
|
TextInput,
|
|
300
197
|
{
|
|
301
198
|
placeholder: "Markdown is supported\u2026",
|
|
@@ -319,13 +216,13 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
319
216
|
] });
|
|
320
217
|
}
|
|
321
218
|
if (overlay.kind === "assign") {
|
|
322
|
-
return /* @__PURE__ */
|
|
323
|
-
/* @__PURE__ */
|
|
219
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", gap: 1, children: [
|
|
220
|
+
/* @__PURE__ */ jsxs2(Text2, { children: [
|
|
324
221
|
"Assign ",
|
|
325
222
|
issue?.key,
|
|
326
223
|
" to yourself?"
|
|
327
224
|
] }),
|
|
328
|
-
/* @__PURE__ */
|
|
225
|
+
/* @__PURE__ */ jsx2(
|
|
329
226
|
ConfirmInput,
|
|
330
227
|
{
|
|
331
228
|
onCancel: () => setOverlay({ kind: "none" }),
|
|
@@ -348,8 +245,8 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
348
245
|
] });
|
|
349
246
|
}
|
|
350
247
|
if (screen === "detail") {
|
|
351
|
-
if (!issue) return /* @__PURE__ */
|
|
352
|
-
return /* @__PURE__ */
|
|
248
|
+
if (!issue) return /* @__PURE__ */ jsx2(Spinner, { label: "Loading issue\u2026" });
|
|
249
|
+
return /* @__PURE__ */ jsx2(
|
|
353
250
|
IssueDetailView,
|
|
354
251
|
{
|
|
355
252
|
issue,
|
|
@@ -375,8 +272,8 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
375
272
|
}
|
|
376
273
|
);
|
|
377
274
|
}
|
|
378
|
-
if (!rows) return /* @__PURE__ */
|
|
379
|
-
return /* @__PURE__ */
|
|
275
|
+
if (!rows) return /* @__PURE__ */ jsx2(Spinner, { label: "Loading issues\u2026" });
|
|
276
|
+
return /* @__PURE__ */ jsx2(
|
|
380
277
|
IssueList,
|
|
381
278
|
{
|
|
382
279
|
rows,
|
|
@@ -395,7 +292,10 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
395
292
|
var opener = () => process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
396
293
|
|
|
397
294
|
// src/tui/data.ts
|
|
398
|
-
import {
|
|
295
|
+
import {
|
|
296
|
+
issueDetailOf,
|
|
297
|
+
transitionsOf
|
|
298
|
+
} from "@kud/jira-ink";
|
|
399
299
|
var OPEN_ONLY = "statusCategory != Done";
|
|
400
300
|
var toRow = (issue) => ({
|
|
401
301
|
key: issue.key,
|
|
@@ -410,35 +310,8 @@ var liveData = (ctx = context()) => ({
|
|
|
410
310
|
const jql = `assignee = currentUser()${all ? "" : ` AND ${OPEN_ONLY}`} ORDER BY updated DESC`;
|
|
411
311
|
return (await ctx.client.searchIssues(jql, { limit: 200 })).map(toRow);
|
|
412
312
|
},
|
|
413
|
-
getIssue:
|
|
414
|
-
|
|
415
|
-
const attachments = locateAttachments(issue);
|
|
416
|
-
const filenameOf = (id) => attachments.find((a) => a.id === id)?.filename;
|
|
417
|
-
const f = issue.fields;
|
|
418
|
-
return {
|
|
419
|
-
key: issue.key,
|
|
420
|
-
summary: f.summary ?? "",
|
|
421
|
-
status: f.status?.name ?? "\u2014",
|
|
422
|
-
type: f.issuetype?.name ?? "\u2014",
|
|
423
|
-
assignee: f.assignee?.displayName ?? "unassigned",
|
|
424
|
-
reporter: f.reporter?.displayName ?? "\u2014",
|
|
425
|
-
labels: f.labels ?? [],
|
|
426
|
-
url: `${ctx.config.baseUrl}/browse/${issue.key}`,
|
|
427
|
-
description: adfToMarkdown(f.description, filenameOf),
|
|
428
|
-
comments: (f.comment?.comments ?? []).map((c) => ({
|
|
429
|
-
id: c.id,
|
|
430
|
-
author: c.author?.displayName ?? "unknown",
|
|
431
|
-
created: c.created?.slice(0, 10) ?? "",
|
|
432
|
-
body: adfToMarkdown(c.body, filenameOf)
|
|
433
|
-
})),
|
|
434
|
-
attachments
|
|
435
|
-
};
|
|
436
|
-
},
|
|
437
|
-
getTransitions: async (key) => (await ctx.client.getTransitions(key)).transitions.map((t) => ({
|
|
438
|
-
id: t.id,
|
|
439
|
-
name: t.name,
|
|
440
|
-
to: t.to?.name ?? t.name
|
|
441
|
-
})),
|
|
313
|
+
getIssue: (key) => issueDetailOf(ctx.client, ctx.config.baseUrl, key),
|
|
314
|
+
getTransitions: (key) => transitionsOf(ctx.client, key),
|
|
442
315
|
transition: (key, transitionId) => ctx.client.transitionIssue(key, transitionId),
|
|
443
316
|
comment: async (key, body) => {
|
|
444
317
|
const { markdownToAdf } = await import("@kud/jira");
|
|
@@ -490,6 +363,7 @@ var DETAIL = {
|
|
|
490
363
|
assignee: "Ada Okafor",
|
|
491
364
|
reporter: "Bram Nilsen",
|
|
492
365
|
labels: ["checkout", "regression"],
|
|
366
|
+
parent: { key: "SHOP-300", summary: "Basket and checkout correctness" },
|
|
493
367
|
url: "https://example.atlassian.net/browse/SHOP-412",
|
|
494
368
|
description: [
|
|
495
369
|
"## What happens",
|
|
@@ -573,7 +447,7 @@ var mockData = () => ({
|
|
|
573
447
|
});
|
|
574
448
|
|
|
575
449
|
// src/tui/index.tsx
|
|
576
|
-
import { jsx as
|
|
450
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
577
451
|
var SCREENS = ["issues", "detail"];
|
|
578
452
|
var runTui = async ({
|
|
579
453
|
screen,
|
|
@@ -583,7 +457,7 @@ var runTui = async ({
|
|
|
583
457
|
const data = mock ? mockData() : liveData();
|
|
584
458
|
const key = issueKey ?? (mock ? "SHOP-412" : void 0);
|
|
585
459
|
const { waitUntilExit } = render(
|
|
586
|
-
/* @__PURE__ */
|
|
460
|
+
/* @__PURE__ */ jsx3(App, { data, initialScreen: screen, initialKey: key })
|
|
587
461
|
);
|
|
588
462
|
await waitUntilExit();
|
|
589
463
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kud/jira-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Jira on the command line — read issues, comments and attachments as plain text",
|
|
6
6
|
"keywords": [
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"prepublishOnly": "npm run build"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@kud/ink-
|
|
41
|
-
"@kud/
|
|
42
|
-
"@kud/jira": "0.
|
|
40
|
+
"@kud/ink-ui": "0.25.0",
|
|
41
|
+
"@kud/jira": "0.3.0",
|
|
42
|
+
"@kud/jira-ink": "0.1.0",
|
|
43
43
|
"commander": "14.0.1",
|
|
44
|
-
"ink": "7.
|
|
44
|
+
"ink": "7.1.1",
|
|
45
45
|
"react": "19.2.5"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|