@kud/jira-cli 0.4.0 → 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";
|
|
@@ -737,6 +735,7 @@ var registerProjectCommands = (program2) => {
|
|
|
737
735
|
// src/commands/misc.ts
|
|
738
736
|
import { mkdirSync, writeFileSync as writeFileSync2 } from "fs";
|
|
739
737
|
import { dirname } from "path";
|
|
738
|
+
import { configPath, readFileConfig } from "@kud/jira";
|
|
740
739
|
var registerSearchCommand = (program2) => {
|
|
741
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) => {
|
|
742
741
|
const ctx = context();
|
|
@@ -851,7 +850,7 @@ Setup:
|
|
|
851
850
|
id.atlassian.com/manage-profile/security/api-tokens
|
|
852
851
|
jira init --base-url myorg.atlassian.net --email you@example.com
|
|
853
852
|
|
|
854
|
-
Everything else lives in ${
|
|
853
|
+
Everything else lives in ${configPath2()}, and any of it can be
|
|
855
854
|
overridden with ATLASSIAN_BASE_URL / ATLASSIAN_USER_EMAIL.
|
|
856
855
|
|
|
857
856
|
Examples:
|
|
@@ -908,7 +907,7 @@ var interactiveArgs = (argv) => {
|
|
|
908
907
|
var main = async () => {
|
|
909
908
|
const { screen, mock, isBare } = interactiveArgs(process.argv);
|
|
910
909
|
if (screen === "list" && isBare) {
|
|
911
|
-
const { SCREENS } = await import("./tui-
|
|
910
|
+
const { SCREENS } = await import("./tui-IET37PRI.js");
|
|
912
911
|
process.stdout.write(`${SCREENS.join("\n")}
|
|
913
912
|
`);
|
|
914
913
|
return;
|
|
@@ -918,7 +917,7 @@ var main = async () => {
|
|
|
918
917
|
program.outputHelp();
|
|
919
918
|
return;
|
|
920
919
|
}
|
|
921
|
-
const { runTui } = await import("./tui-
|
|
920
|
+
const { runTui } = await import("./tui-IET37PRI.js");
|
|
922
921
|
const [, key] = (screen ?? "").split(":");
|
|
923
922
|
await runTui({
|
|
924
923
|
screen: screen?.startsWith("detail") ? "detail" : "issues",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
context
|
|
3
|
-
|
|
4
|
-
} from "./chunk-5MFNIQDW.js";
|
|
2
|
+
context
|
|
3
|
+
} from "./chunk-RTBMVYZM.js";
|
|
5
4
|
|
|
6
5
|
// src/tui/index.tsx
|
|
7
6
|
import { render } from "ink";
|
|
@@ -9,124 +8,14 @@ import { render } from "ink";
|
|
|
9
8
|
// src/tui/app.tsx
|
|
10
9
|
import { execFile } from "child_process";
|
|
11
10
|
import { Alert, ConfirmInput, Select, Spinner, TextInput } from "@kud/ink-ui";
|
|
12
|
-
import { Box as
|
|
13
|
-
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";
|
|
14
14
|
|
|
15
|
-
// src/tui/
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
Badge,
|
|
19
|
-
FooterHints,
|
|
20
|
-
KeyValue,
|
|
21
|
-
Tabs,
|
|
22
|
-
useTabs
|
|
23
|
-
} from "@kud/ink-ui";
|
|
15
|
+
// src/tui/list.tsx
|
|
16
|
+
import { FooterHints, SelectableRow, useListCursor } from "@kud/ink-ui";
|
|
24
17
|
import { Box, Text, useInput } from "ink";
|
|
25
|
-
import { useState } from "react";
|
|
26
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
27
|
-
var originOf = (a) => a.origins.map(
|
|
28
|
-
(o) => o.kind === "comment" ? `comment by ${o.author ?? "unknown"}` : o.kind === "description" ? "description" : "issue"
|
|
29
|
-
).join(", ");
|
|
30
|
-
var humanSize = (bytes) => {
|
|
31
|
-
const units = ["B", "KB", "MB", "GB"];
|
|
32
|
-
const e = Math.min(
|
|
33
|
-
units.length - 1,
|
|
34
|
-
Math.floor(Math.log(Math.max(bytes, 1)) / Math.log(1024))
|
|
35
|
-
);
|
|
36
|
-
const value = bytes / 1024 ** e;
|
|
37
|
-
return `${e === 0 ? value : value.toFixed(1)}${units[e]}`;
|
|
38
|
-
};
|
|
39
|
-
var commentsAsMarkdown = (issue) => issue.comments.length === 0 ? "_No comments._" : issue.comments.map((c) => `**${c.author}** \xB7 ${c.created}
|
|
40
|
-
|
|
41
|
-
${c.body}`).join("\n\n---\n\n");
|
|
42
|
-
var attachmentsAsMarkdown = (issue) => issue.attachments.length === 0 ? "_No attachments._" : issue.attachments.map(
|
|
43
|
-
(a) => `- \`${a.filename}\` \u2014 ${a.mimeType}, ${humanSize(a.size)}
|
|
44
|
-
from ${originOf(a)}
|
|
45
|
-
\`jira attachment read ${issue.key} ${a.filename}\``
|
|
46
|
-
).join("\n");
|
|
47
|
-
var IssueDetailView = ({
|
|
48
|
-
issue,
|
|
49
|
-
height,
|
|
50
|
-
width,
|
|
51
|
-
onBack,
|
|
52
|
-
onTransition,
|
|
53
|
-
onComment,
|
|
54
|
-
onAssign,
|
|
55
|
-
onOpenBrowser
|
|
56
|
-
}) => {
|
|
57
|
-
const tabs = [
|
|
58
|
-
{ value: "description", label: "Description" },
|
|
59
|
-
{ value: "comments", label: "Comments", count: issue.comments.length },
|
|
60
|
-
{
|
|
61
|
-
value: "attachments",
|
|
62
|
-
label: "Attachments",
|
|
63
|
-
count: issue.attachments.length
|
|
64
|
-
}
|
|
65
|
-
];
|
|
66
|
-
const { active } = useTabs(tabs, { initial: "description" });
|
|
67
|
-
const [scroll, setScroll] = useState(0);
|
|
68
|
-
useInput((input, key) => {
|
|
69
|
-
if (key.escape || key.leftArrow) return onBack();
|
|
70
|
-
if (input === "t") return onTransition();
|
|
71
|
-
if (input === "c") return onComment();
|
|
72
|
-
if (input === "a") return onAssign();
|
|
73
|
-
if (input === "o") return onOpenBrowser();
|
|
74
|
-
if (key.downArrow || input === "j") setScroll((s) => s + 1);
|
|
75
|
-
if (key.upArrow || input === "k") setScroll((s) => Math.max(0, s - 1));
|
|
76
|
-
});
|
|
77
|
-
const source = active === "comments" ? commentsAsMarkdown(issue) : active === "attachments" ? attachmentsAsMarkdown(issue) : issue.description || "_No description._";
|
|
78
|
-
const bodyHeight = Math.max(3, height - 12);
|
|
79
|
-
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
80
|
-
/* @__PURE__ */ jsxs(Text, { bold: true, children: [
|
|
81
|
-
issue.key,
|
|
82
|
-
" ",
|
|
83
|
-
issue.summary
|
|
84
|
-
] }),
|
|
85
|
-
/* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "column", children: [
|
|
86
|
-
issue.parent && /* @__PURE__ */ jsx(
|
|
87
|
-
KeyValue,
|
|
88
|
-
{
|
|
89
|
-
label: "parent",
|
|
90
|
-
value: `${issue.parent.key} ${truncate(issue.parent.summary, 60)}`
|
|
91
|
-
}
|
|
92
|
-
),
|
|
93
|
-
/* @__PURE__ */ jsx(KeyValue, { label: "status", value: /* @__PURE__ */ jsx(Badge, { children: issue.status }) }),
|
|
94
|
-
/* @__PURE__ */ jsx(KeyValue, { label: "type", value: issue.type }),
|
|
95
|
-
/* @__PURE__ */ jsx(KeyValue, { label: "assignee", value: issue.assignee }),
|
|
96
|
-
/* @__PURE__ */ jsx(KeyValue, { label: "reporter", value: issue.reporter }),
|
|
97
|
-
issue.labels.length > 0 && /* @__PURE__ */ jsx(KeyValue, { label: "labels", value: issue.labels.join(", ") })
|
|
98
|
-
] }),
|
|
99
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Tabs, { items: tabs, active: active ?? "description" }) }),
|
|
100
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(
|
|
101
|
-
MarkdownViewport,
|
|
102
|
-
{
|
|
103
|
-
source,
|
|
104
|
-
width: Math.max(20, width - 2),
|
|
105
|
-
height: bodyHeight,
|
|
106
|
-
scrollOffset: scroll
|
|
107
|
-
}
|
|
108
|
-
) }),
|
|
109
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(
|
|
110
|
-
FooterHints,
|
|
111
|
-
{
|
|
112
|
-
hints: [
|
|
113
|
-
["\u2190\u2192", "section"],
|
|
114
|
-
["\u2191\u2193", "scroll"],
|
|
115
|
-
["t", "transition"],
|
|
116
|
-
["c", "comment"],
|
|
117
|
-
["a", "assign to me"],
|
|
118
|
-
["o", "browser"],
|
|
119
|
-
["esc", "back"]
|
|
120
|
-
]
|
|
121
|
-
}
|
|
122
|
-
) })
|
|
123
|
-
] });
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
// src/tui/list.tsx
|
|
127
|
-
import { FooterHints as FooterHints2, SelectableRow, useListCursor } from "@kud/ink-ui";
|
|
128
|
-
import { Box as Box2, Text as Text2, useInput as useInput2 } from "ink";
|
|
129
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
130
19
|
var pad = (s, width) => s.length > width ? `${s.slice(0, width - 1)}\u2026` : s.padEnd(width);
|
|
131
20
|
var windowFor = (cursor, total, size) => {
|
|
132
21
|
const start = Math.max(
|
|
@@ -144,7 +33,7 @@ var IssueList = ({
|
|
|
144
33
|
height
|
|
145
34
|
}) => {
|
|
146
35
|
const { cursor } = useListCursor(rows.length, { vimKeys: true });
|
|
147
|
-
|
|
36
|
+
useInput((input, key) => {
|
|
148
37
|
if (key.return && rows[cursor]) onOpen(rows[cursor].key);
|
|
149
38
|
if (input === "a") onToggleAll();
|
|
150
39
|
if (input === "r") onRefresh();
|
|
@@ -157,41 +46,41 @@ var IssueList = ({
|
|
|
157
46
|
["q", "quit"]
|
|
158
47
|
];
|
|
159
48
|
if (rows.length === 0) {
|
|
160
|
-
return /* @__PURE__ */
|
|
161
|
-
/* @__PURE__ */
|
|
162
|
-
/* @__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 })
|
|
163
52
|
] });
|
|
164
53
|
}
|
|
165
54
|
const size = Math.max(3, height - 5);
|
|
166
55
|
const { start, end } = windowFor(cursor, rows.length, size);
|
|
167
56
|
const visible = rows.slice(start, end);
|
|
168
|
-
return /* @__PURE__ */
|
|
169
|
-
/* @__PURE__ */
|
|
57
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
58
|
+
/* @__PURE__ */ jsx(Box, { paddingLeft: 4, children: /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
170
59
|
pad("KEY", 11),
|
|
171
60
|
pad("STATUS", 17),
|
|
172
61
|
pad("SUMMARY", 60),
|
|
173
62
|
"ASSIGNEE"
|
|
174
63
|
] }) }),
|
|
175
|
-
visible.map((row, i) => /* @__PURE__ */
|
|
64
|
+
visible.map((row, i) => /* @__PURE__ */ jsx(SelectableRow, { active: start + i === cursor, children: /* @__PURE__ */ jsxs(Text, { children: [
|
|
176
65
|
pad(row.key, 11),
|
|
177
66
|
pad(row.status, 17),
|
|
178
67
|
pad(row.summary, 60),
|
|
179
|
-
/* @__PURE__ */
|
|
68
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: row.assignee })
|
|
180
69
|
] }) }, row.key)),
|
|
181
|
-
/* @__PURE__ */
|
|
182
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ jsxs(Box, { marginTop: 1, flexDirection: "column", children: [
|
|
71
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
183
72
|
cursor + 1,
|
|
184
73
|
"/",
|
|
185
74
|
rows.length,
|
|
186
75
|
showingAll ? " \xB7 all" : " \xB7 open only"
|
|
187
76
|
] }),
|
|
188
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ jsx(FooterHints, { hints })
|
|
189
78
|
] })
|
|
190
79
|
] });
|
|
191
80
|
};
|
|
192
81
|
|
|
193
82
|
// src/tui/app.tsx
|
|
194
|
-
import { jsx as
|
|
83
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
195
84
|
var MIN_WIDTH = 60;
|
|
196
85
|
var MIN_HEIGHT = 12;
|
|
197
86
|
var App = ({ data, initialScreen, initialKey }) => {
|
|
@@ -199,13 +88,13 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
199
88
|
const { stdout } = useStdout();
|
|
200
89
|
const width = stdout?.columns ?? 80;
|
|
201
90
|
const height = stdout?.rows ?? 24;
|
|
202
|
-
const [screen, setScreen] =
|
|
203
|
-
const [rows, setRows] =
|
|
204
|
-
const [issue, setIssue] =
|
|
205
|
-
const [overlay, setOverlay] =
|
|
206
|
-
const [showingAll, setShowingAll] =
|
|
207
|
-
const [error, setError] =
|
|
208
|
-
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);
|
|
209
98
|
const loadList = useCallback(
|
|
210
99
|
async (all) => {
|
|
211
100
|
setError(null);
|
|
@@ -235,7 +124,7 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
235
124
|
if (initialScreen === "detail" && initialKey) void loadIssue(initialKey);
|
|
236
125
|
else void loadList(false);
|
|
237
126
|
}, [initialScreen, initialKey, loadIssue, loadList]);
|
|
238
|
-
|
|
127
|
+
useInput2((input, key) => {
|
|
239
128
|
if (overlay.kind !== "none") return;
|
|
240
129
|
if (input === "q" || key.ctrl && input === "c") exit();
|
|
241
130
|
if (error && input === "r") {
|
|
@@ -244,7 +133,7 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
244
133
|
}
|
|
245
134
|
});
|
|
246
135
|
if (width < MIN_WIDTH || height < MIN_HEIGHT) {
|
|
247
|
-
return /* @__PURE__ */
|
|
136
|
+
return /* @__PURE__ */ jsxs2(Text2, { children: [
|
|
248
137
|
"Terminal too small \u2014 needs at least ",
|
|
249
138
|
MIN_WIDTH,
|
|
250
139
|
"\xD7",
|
|
@@ -258,20 +147,20 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
258
147
|
] });
|
|
259
148
|
}
|
|
260
149
|
if (error) {
|
|
261
|
-
return /* @__PURE__ */
|
|
262
|
-
/* @__PURE__ */
|
|
263
|
-
/* @__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" })
|
|
264
153
|
] });
|
|
265
154
|
}
|
|
266
|
-
if (busy) return /* @__PURE__ */
|
|
155
|
+
if (busy) return /* @__PURE__ */ jsx2(Spinner, { label: busy });
|
|
267
156
|
if (overlay.kind === "transition") {
|
|
268
|
-
return /* @__PURE__ */
|
|
269
|
-
/* @__PURE__ */
|
|
157
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", gap: 1, children: [
|
|
158
|
+
/* @__PURE__ */ jsxs2(Text2, { bold: true, children: [
|
|
270
159
|
"Move ",
|
|
271
160
|
issue?.key,
|
|
272
161
|
" to\u2026"
|
|
273
162
|
] }),
|
|
274
|
-
/* @__PURE__ */
|
|
163
|
+
/* @__PURE__ */ jsx2(
|
|
275
164
|
Select,
|
|
276
165
|
{
|
|
277
166
|
options: overlay.options.map((t) => ({
|
|
@@ -294,16 +183,16 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
294
183
|
}
|
|
295
184
|
}
|
|
296
185
|
),
|
|
297
|
-
/* @__PURE__ */
|
|
186
|
+
/* @__PURE__ */ jsx2(Text2, { dimColor: true, children: "esc cancel" })
|
|
298
187
|
] });
|
|
299
188
|
}
|
|
300
189
|
if (overlay.kind === "comment") {
|
|
301
|
-
return /* @__PURE__ */
|
|
302
|
-
/* @__PURE__ */
|
|
190
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", gap: 1, children: [
|
|
191
|
+
/* @__PURE__ */ jsxs2(Text2, { bold: true, children: [
|
|
303
192
|
"Comment on ",
|
|
304
193
|
issue?.key
|
|
305
194
|
] }),
|
|
306
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ jsx2(
|
|
307
196
|
TextInput,
|
|
308
197
|
{
|
|
309
198
|
placeholder: "Markdown is supported\u2026",
|
|
@@ -327,13 +216,13 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
327
216
|
] });
|
|
328
217
|
}
|
|
329
218
|
if (overlay.kind === "assign") {
|
|
330
|
-
return /* @__PURE__ */
|
|
331
|
-
/* @__PURE__ */
|
|
219
|
+
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", gap: 1, children: [
|
|
220
|
+
/* @__PURE__ */ jsxs2(Text2, { children: [
|
|
332
221
|
"Assign ",
|
|
333
222
|
issue?.key,
|
|
334
223
|
" to yourself?"
|
|
335
224
|
] }),
|
|
336
|
-
/* @__PURE__ */
|
|
225
|
+
/* @__PURE__ */ jsx2(
|
|
337
226
|
ConfirmInput,
|
|
338
227
|
{
|
|
339
228
|
onCancel: () => setOverlay({ kind: "none" }),
|
|
@@ -356,8 +245,8 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
356
245
|
] });
|
|
357
246
|
}
|
|
358
247
|
if (screen === "detail") {
|
|
359
|
-
if (!issue) return /* @__PURE__ */
|
|
360
|
-
return /* @__PURE__ */
|
|
248
|
+
if (!issue) return /* @__PURE__ */ jsx2(Spinner, { label: "Loading issue\u2026" });
|
|
249
|
+
return /* @__PURE__ */ jsx2(
|
|
361
250
|
IssueDetailView,
|
|
362
251
|
{
|
|
363
252
|
issue,
|
|
@@ -383,8 +272,8 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
383
272
|
}
|
|
384
273
|
);
|
|
385
274
|
}
|
|
386
|
-
if (!rows) return /* @__PURE__ */
|
|
387
|
-
return /* @__PURE__ */
|
|
275
|
+
if (!rows) return /* @__PURE__ */ jsx2(Spinner, { label: "Loading issues\u2026" });
|
|
276
|
+
return /* @__PURE__ */ jsx2(
|
|
388
277
|
IssueList,
|
|
389
278
|
{
|
|
390
279
|
rows,
|
|
@@ -403,7 +292,10 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
403
292
|
var opener = () => process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
404
293
|
|
|
405
294
|
// src/tui/data.ts
|
|
406
|
-
import {
|
|
295
|
+
import {
|
|
296
|
+
issueDetailOf,
|
|
297
|
+
transitionsOf
|
|
298
|
+
} from "@kud/jira-ink";
|
|
407
299
|
var OPEN_ONLY = "statusCategory != Done";
|
|
408
300
|
var toRow = (issue) => ({
|
|
409
301
|
key: issue.key,
|
|
@@ -418,36 +310,8 @@ var liveData = (ctx = context()) => ({
|
|
|
418
310
|
const jql = `assignee = currentUser()${all ? "" : ` AND ${OPEN_ONLY}`} ORDER BY updated DESC`;
|
|
419
311
|
return (await ctx.client.searchIssues(jql, { limit: 200 })).map(toRow);
|
|
420
312
|
},
|
|
421
|
-
getIssue:
|
|
422
|
-
|
|
423
|
-
const attachments = locateAttachments(issue);
|
|
424
|
-
const filenameOf = (id) => attachments.find((a) => a.id === id)?.filename;
|
|
425
|
-
const f = issue.fields;
|
|
426
|
-
return {
|
|
427
|
-
key: issue.key,
|
|
428
|
-
summary: f.summary ?? "",
|
|
429
|
-
status: f.status?.name ?? "\u2014",
|
|
430
|
-
type: f.issuetype?.name ?? "\u2014",
|
|
431
|
-
assignee: f.assignee?.displayName ?? "unassigned",
|
|
432
|
-
reporter: f.reporter?.displayName ?? "\u2014",
|
|
433
|
-
labels: f.labels ?? [],
|
|
434
|
-
parent: f.parent ? { key: f.parent.key, summary: f.parent.fields?.summary ?? "" } : void 0,
|
|
435
|
-
url: `${ctx.config.baseUrl}/browse/${issue.key}`,
|
|
436
|
-
description: adfToMarkdown(f.description, filenameOf),
|
|
437
|
-
comments: (f.comment?.comments ?? []).map((c) => ({
|
|
438
|
-
id: c.id,
|
|
439
|
-
author: c.author?.displayName ?? "unknown",
|
|
440
|
-
created: c.created?.slice(0, 10) ?? "",
|
|
441
|
-
body: adfToMarkdown(c.body, filenameOf)
|
|
442
|
-
})),
|
|
443
|
-
attachments
|
|
444
|
-
};
|
|
445
|
-
},
|
|
446
|
-
getTransitions: async (key) => (await ctx.client.getTransitions(key)).transitions.map((t) => ({
|
|
447
|
-
id: t.id,
|
|
448
|
-
name: t.name,
|
|
449
|
-
to: t.to?.name ?? t.name
|
|
450
|
-
})),
|
|
313
|
+
getIssue: (key) => issueDetailOf(ctx.client, ctx.config.baseUrl, key),
|
|
314
|
+
getTransitions: (key) => transitionsOf(ctx.client, key),
|
|
451
315
|
transition: (key, transitionId) => ctx.client.transitionIssue(key, transitionId),
|
|
452
316
|
comment: async (key, body) => {
|
|
453
317
|
const { markdownToAdf } = await import("@kud/jira");
|
|
@@ -583,7 +447,7 @@ var mockData = () => ({
|
|
|
583
447
|
});
|
|
584
448
|
|
|
585
449
|
// src/tui/index.tsx
|
|
586
|
-
import { jsx as
|
|
450
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
587
451
|
var SCREENS = ["issues", "detail"];
|
|
588
452
|
var runTui = async ({
|
|
589
453
|
screen,
|
|
@@ -593,7 +457,7 @@ var runTui = async ({
|
|
|
593
457
|
const data = mock ? mockData() : liveData();
|
|
594
458
|
const key = issueKey ?? (mock ? "SHOP-412" : void 0);
|
|
595
459
|
const { waitUntilExit } = render(
|
|
596
|
-
/* @__PURE__ */
|
|
460
|
+
/* @__PURE__ */ jsx3(App, { data, initialScreen: screen, initialKey: key })
|
|
597
461
|
);
|
|
598
462
|
await waitUntilExit();
|
|
599
463
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kud/jira-cli",
|
|
3
|
-
"version": "0.4.
|
|
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": {
|