@kud/jira-cli 0.7.0 → 0.9.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/README.md
CHANGED
|
@@ -145,8 +145,17 @@ Exit codes:
|
|
|
145
145
|
| `0` | success |
|
|
146
146
|
| `1` | Jira rejected the request, or bad usage |
|
|
147
147
|
| `2` | the environment is not set up |
|
|
148
|
+
| `3` | `--json` result may be truncated |
|
|
148
149
|
| `4` | not authenticated |
|
|
149
150
|
|
|
151
|
+
`issue list` and `search` stop at `--limit` (50 by default), and Jira no longer
|
|
152
|
+
reports a total, so a full page is the only evidence that rows were left behind.
|
|
153
|
+
When one comes back, both commands warn on stderr, and with `--json` they also
|
|
154
|
+
exit `3`. Stdout is untouched, so `--json` parses exactly as before and a caller
|
|
155
|
+
that ignores the exit code sees no change. The table output keeps exiting `0`,
|
|
156
|
+
so `jira issue list && …` still works at a terminal.
|
|
157
|
+
Raise `--limit` to be sure you have it all.
|
|
158
|
+
|
|
150
159
|
Colour is disabled automatically when stdout is not a TTY, and when `NO_COLOR` is set.
|
|
151
160
|
|
|
152
161
|
## Custom fields
|
|
@@ -60,6 +60,16 @@ var printJson = (value) => {
|
|
|
60
60
|
process.stdout.write(`${JSON.stringify(value, null, 2)}
|
|
61
61
|
`);
|
|
62
62
|
};
|
|
63
|
+
var TRUNCATED_EXIT_CODE = 3;
|
|
64
|
+
var isTruncated = (count, limit) => Number.isFinite(limit) && limit > 0 && count >= limit;
|
|
65
|
+
var warnIfTruncated = (count, limit, { exitCode }) => {
|
|
66
|
+
if (!isTruncated(count, limit)) return;
|
|
67
|
+
process.stderr.write(
|
|
68
|
+
`jira: result may be truncated at --limit ${limit} \u2014 there may be more
|
|
69
|
+
`
|
|
70
|
+
);
|
|
71
|
+
if (exitCode) process.exitCode = TRUNCATED_EXIT_CODE;
|
|
72
|
+
};
|
|
63
73
|
|
|
64
74
|
export {
|
|
65
75
|
table,
|
|
@@ -67,5 +77,6 @@ export {
|
|
|
67
77
|
exitError,
|
|
68
78
|
isExitError,
|
|
69
79
|
context,
|
|
70
|
-
printJson
|
|
80
|
+
printJson,
|
|
81
|
+
warnIfTruncated
|
|
71
82
|
};
|
package/dist/index.js
CHANGED
|
@@ -5,8 +5,9 @@ import {
|
|
|
5
5
|
isExitError,
|
|
6
6
|
printJson,
|
|
7
7
|
table,
|
|
8
|
-
truncate
|
|
9
|
-
|
|
8
|
+
truncate,
|
|
9
|
+
warnIfTruncated
|
|
10
|
+
} from "./chunk-UTNXGDH2.js";
|
|
10
11
|
|
|
11
12
|
// src/index.ts
|
|
12
13
|
import { realpathSync } from "fs";
|
|
@@ -407,10 +408,13 @@ var registerIssueCommands = (program2) => {
|
|
|
407
408
|
issue.command("list").alias("ls").description("list issues matching the given filters").option("-a, --assignee <who>", "assignee account id, email, or 'none'").option("-m, --mine", "issues assigned to you").option("-s, --status <status>", "status name, e.g. 'In Progress'").option("-p, --project <key>", "project key").option("--sprint <name>", "sprint name, or 'current' for open sprints").option("-l, --label <label>", "label").option("-q, --jql <jql>", "raw JQL, replacing all other filters").option("-n, --limit <n>", "maximum issues to return", "50").option("--json", "emit JSON").action(async (options) => {
|
|
408
409
|
const ctx = context();
|
|
409
410
|
const jql = buildJql(options, ctx.config.defaultProject);
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
411
|
+
const limit = Number(options.limit);
|
|
412
|
+
const issues = await ctx.client.searchIssues(jql, { limit });
|
|
413
|
+
if (options.json) {
|
|
414
|
+
printJson(issues);
|
|
415
|
+
warnIfTruncated(issues.length, limit, { exitCode: true });
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
414
418
|
if (issues.length === 0) {
|
|
415
419
|
const me = await ctx.client.getMe().catch(() => null);
|
|
416
420
|
if (!me?.accountId)
|
|
@@ -424,6 +428,7 @@ var registerIssueCommands = (program2) => {
|
|
|
424
428
|
}
|
|
425
429
|
process.stdout.write(`${table(issues, issueColumns(ctx))}
|
|
426
430
|
`);
|
|
431
|
+
warnIfTruncated(issues.length, limit, { exitCode: false });
|
|
427
432
|
});
|
|
428
433
|
issue.command("view <key>").description("show one issue").option("--json", "emit JSON").option("--comments", "include comments").action(
|
|
429
434
|
async (key, options) => {
|
|
@@ -722,10 +727,13 @@ import { configPath, readFileConfig } from "@kud/jira";
|
|
|
722
727
|
var registerSearchCommand = (program2) => {
|
|
723
728
|
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) => {
|
|
724
729
|
const ctx = context();
|
|
725
|
-
const
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
730
|
+
const limit = Number(options.limit);
|
|
731
|
+
const issues = await ctx.client.searchIssues(jql, { limit });
|
|
732
|
+
if (options.json) {
|
|
733
|
+
printJson(issues);
|
|
734
|
+
warnIfTruncated(issues.length, limit, { exitCode: true });
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
729
737
|
if (issues.length === 0) {
|
|
730
738
|
process.stderr.write("no issues match\n");
|
|
731
739
|
return;
|
|
@@ -738,6 +746,7 @@ var registerSearchCommand = (program2) => {
|
|
|
738
746
|
])}
|
|
739
747
|
`
|
|
740
748
|
);
|
|
749
|
+
warnIfTruncated(issues.length, limit, { exitCode: false });
|
|
741
750
|
});
|
|
742
751
|
};
|
|
743
752
|
var registerFieldsCommand = (program2) => {
|
|
@@ -900,7 +909,7 @@ var interactiveArgs = (argv) => {
|
|
|
900
909
|
var main = async () => {
|
|
901
910
|
const { screen, mock, board, isBare } = interactiveArgs(process.argv);
|
|
902
911
|
if (screen === "list" && isBare) {
|
|
903
|
-
const { SCREENS } = await import("./tui-
|
|
912
|
+
const { SCREENS } = await import("./tui-5ILW4QX4.js");
|
|
904
913
|
process.stdout.write(`${SCREENS.join("\n")}
|
|
905
914
|
`);
|
|
906
915
|
return;
|
|
@@ -910,7 +919,7 @@ var main = async () => {
|
|
|
910
919
|
program.outputHelp();
|
|
911
920
|
return;
|
|
912
921
|
}
|
|
913
|
-
const { runTui } = await import("./tui-
|
|
922
|
+
const { runTui } = await import("./tui-5ILW4QX4.js");
|
|
914
923
|
const [, key] = (screen ?? "").split(":");
|
|
915
924
|
await runTui({
|
|
916
925
|
screen: screen?.startsWith("detail") ? "detail" : "issues",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
context
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UTNXGDH2.js";
|
|
4
4
|
|
|
5
5
|
// src/tui/index.tsx
|
|
6
6
|
import { render } from "ink";
|
|
@@ -16,11 +16,12 @@ import {
|
|
|
16
16
|
TextInput,
|
|
17
17
|
useAppKeys
|
|
18
18
|
} from "@kud/ink-ui";
|
|
19
|
-
import { Box, Text, useApp, useInput,
|
|
19
|
+
import { Box, Text, useApp, useInput, useWindowSize } from "ink";
|
|
20
20
|
import { useCallback, useEffect, useState } from "react";
|
|
21
21
|
import { errorMessagesOf, isJiraApiError } from "@kud/jira";
|
|
22
22
|
import {
|
|
23
23
|
IssueBoard,
|
|
24
|
+
IssueBoardSkeleton,
|
|
24
25
|
IssueDetailView,
|
|
25
26
|
pendingRow,
|
|
26
27
|
settleRow,
|
|
@@ -31,8 +32,6 @@ import {
|
|
|
31
32
|
import { Page } from "@kud/ink-ui";
|
|
32
33
|
import { jsx } from "react/jsx-runtime";
|
|
33
34
|
var Frame = ({
|
|
34
|
-
width,
|
|
35
|
-
height,
|
|
36
35
|
facts,
|
|
37
36
|
count,
|
|
38
37
|
user,
|
|
@@ -41,6 +40,7 @@ var Frame = ({
|
|
|
41
40
|
hints,
|
|
42
41
|
page = "root",
|
|
43
42
|
gap = true,
|
|
43
|
+
help,
|
|
44
44
|
children
|
|
45
45
|
}) => /* @__PURE__ */ jsx(
|
|
46
46
|
Page,
|
|
@@ -55,8 +55,8 @@ var Frame = ({
|
|
|
55
55
|
hints,
|
|
56
56
|
page,
|
|
57
57
|
gap,
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
help,
|
|
59
|
+
fill: true,
|
|
60
60
|
children
|
|
61
61
|
}
|
|
62
62
|
);
|
|
@@ -69,9 +69,7 @@ var MIN_WIDTH = 60;
|
|
|
69
69
|
var MIN_HEIGHT = 12;
|
|
70
70
|
var App = ({ data, initialScreen, initialKey }) => {
|
|
71
71
|
const { exit } = useApp();
|
|
72
|
-
const {
|
|
73
|
-
const width = stdout?.columns ?? 80;
|
|
74
|
-
const height = stdout?.rows ?? 24;
|
|
72
|
+
const { columns: width, rows: height } = useWindowSize();
|
|
75
73
|
const [screen, setScreen] = useState(initialScreen);
|
|
76
74
|
const [model, setModel] = useState(null);
|
|
77
75
|
const [viewer, setViewer] = useState("you");
|
|
@@ -85,22 +83,26 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
85
83
|
const [error, setError] = useState(null);
|
|
86
84
|
const [busy, setBusy] = useState(null);
|
|
87
85
|
const [parents, setParents] = useState([]);
|
|
86
|
+
const [tabs, setTabs] = useState(null);
|
|
87
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
88
88
|
const [flash, setFlash] = useState(null);
|
|
89
89
|
const [moving, setMoving] = useState(null);
|
|
90
90
|
const loadList = useCallback(
|
|
91
91
|
async (all) => {
|
|
92
92
|
setError(null);
|
|
93
|
-
setModel(null);
|
|
94
|
-
setScope({ kind: "mine" });
|
|
95
93
|
setSearchError(null);
|
|
94
|
+
setRefreshing(true);
|
|
96
95
|
try {
|
|
97
96
|
const next = await data.board(all);
|
|
98
97
|
setModel(next);
|
|
98
|
+
setScope({ kind: "mine" });
|
|
99
99
|
setLoadedAt(Date.now());
|
|
100
100
|
void data.parents(next.rows).then(setParents).catch(() => {
|
|
101
101
|
});
|
|
102
102
|
} catch (e) {
|
|
103
103
|
setError(e instanceof Error ? e.message : String(e));
|
|
104
|
+
} finally {
|
|
105
|
+
setRefreshing(false);
|
|
104
106
|
}
|
|
105
107
|
},
|
|
106
108
|
[data]
|
|
@@ -121,6 +123,7 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
121
123
|
const runSearch = useCallback(
|
|
122
124
|
async (query, mode) => {
|
|
123
125
|
setSearchError(null);
|
|
126
|
+
setRefreshing(true);
|
|
124
127
|
try {
|
|
125
128
|
const result = await data.search(query, mode);
|
|
126
129
|
setModel(result.model);
|
|
@@ -130,6 +133,8 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
130
133
|
setLoadedAt(Date.now());
|
|
131
134
|
} catch (e) {
|
|
132
135
|
setSearchError(jiraMessageOf(e));
|
|
136
|
+
} finally {
|
|
137
|
+
setRefreshing(false);
|
|
133
138
|
}
|
|
134
139
|
},
|
|
135
140
|
[data]
|
|
@@ -156,6 +161,16 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
156
161
|
void data.me().then((me) => setViewer(me.displayName)).catch(() => {
|
|
157
162
|
});
|
|
158
163
|
}, [data]);
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
let cancelled = false;
|
|
166
|
+
data.tabs().then((t) => {
|
|
167
|
+
if (!cancelled) setTabs(t);
|
|
168
|
+
}).catch(() => {
|
|
169
|
+
});
|
|
170
|
+
return () => {
|
|
171
|
+
cancelled = true;
|
|
172
|
+
};
|
|
173
|
+
}, [data]);
|
|
159
174
|
useEffect(() => {
|
|
160
175
|
if (initialScreen === "detail" && initialKey) void loadIssue(initialKey);
|
|
161
176
|
else void loadList(false);
|
|
@@ -196,7 +211,7 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
196
211
|
"."
|
|
197
212
|
] });
|
|
198
213
|
}
|
|
199
|
-
const framed = (facts, body, hints, page = screen === "detail" ? "nested" : "root") => /* @__PURE__ */ jsx2(Frame, {
|
|
214
|
+
const framed = (facts, body, hints, page = screen === "detail" ? "nested" : "root") => /* @__PURE__ */ jsx2(Frame, { facts, hints, page, children: /* @__PURE__ */ jsx2(Box, { flexDirection: "column", marginTop: 1, paddingLeft: 2, flexGrow: 1, children: body }) });
|
|
200
215
|
if (error)
|
|
201
216
|
return framed("error", /* @__PURE__ */ jsx2(Alert, { variant: "error", children: error }), [
|
|
202
217
|
["r", "retry"]
|
|
@@ -302,33 +317,23 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
302
317
|
issue,
|
|
303
318
|
width,
|
|
304
319
|
height: height - FRAME_CHROME - DETAIL_CHROME,
|
|
305
|
-
frame: ({ title, subtitle, hints, body }) => /* @__PURE__ */ jsxs(
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
flexDirection: "column",
|
|
323
|
-
marginTop: 1,
|
|
324
|
-
paddingLeft: 2,
|
|
325
|
-
flexGrow: 1,
|
|
326
|
-
children: body
|
|
327
|
-
}
|
|
328
|
-
)
|
|
329
|
-
]
|
|
330
|
-
}
|
|
331
|
-
),
|
|
320
|
+
frame: ({ title, subtitle, hints, body }) => /* @__PURE__ */ jsxs(Frame, { scope: title, hints: hints.filter(([k]) => k !== "\u232B"), page: "nested", children: [
|
|
321
|
+
/* @__PURE__ */ jsxs(Box, { paddingLeft: 2, children: [
|
|
322
|
+
/* @__PURE__ */ jsx2(Text, { dimColor: true, children: subtitle }),
|
|
323
|
+
moving === issue.key ? /* @__PURE__ */ jsx2(Text, { color: colors.accent, children: " \u22EF moving" }) : null
|
|
324
|
+
] }),
|
|
325
|
+
flash ? /* @__PURE__ */ jsx2(Box, { paddingLeft: 2, children: /* @__PURE__ */ jsx2(Text, { color: colors.error, children: `\u2717 ${flash}` }) }) : null,
|
|
326
|
+
/* @__PURE__ */ jsx2(
|
|
327
|
+
Box,
|
|
328
|
+
{
|
|
329
|
+
flexDirection: "column",
|
|
330
|
+
marginTop: 1,
|
|
331
|
+
paddingLeft: 2,
|
|
332
|
+
flexGrow: 1,
|
|
333
|
+
children: body
|
|
334
|
+
}
|
|
335
|
+
)
|
|
336
|
+
] }),
|
|
332
337
|
onBack: () => setScreen("issues"),
|
|
333
338
|
onOpenBrowser: () => execFile(opener(), [issue.url]),
|
|
334
339
|
onAssign: () => setOverlay({ kind: "assign" }),
|
|
@@ -350,33 +355,45 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
350
355
|
}
|
|
351
356
|
);
|
|
352
357
|
}
|
|
353
|
-
|
|
358
|
+
const boardHeight = height - (FRAME_CHROME - 1) - 1;
|
|
359
|
+
const boardFrame = (help) => ({ title, hints, body }) => /* @__PURE__ */ jsx2(
|
|
360
|
+
Frame,
|
|
361
|
+
{
|
|
362
|
+
count: title.count ?? void 0,
|
|
363
|
+
user: title.user,
|
|
364
|
+
scope: title.scope,
|
|
365
|
+
status: refreshing && model ? { text: "\u21BB refreshing\u2026", tone: "busy" } : title.status,
|
|
366
|
+
hints,
|
|
367
|
+
gap: false,
|
|
368
|
+
help,
|
|
369
|
+
children: body
|
|
370
|
+
}
|
|
371
|
+
);
|
|
372
|
+
if (!model) {
|
|
373
|
+
if (!tabs) return framed("loading\u2026", /* @__PURE__ */ jsx2(Spinner, { label: "Loading issues\u2026" }));
|
|
374
|
+
return /* @__PURE__ */ jsx2(
|
|
375
|
+
IssueBoardSkeleton,
|
|
376
|
+
{
|
|
377
|
+
tabs,
|
|
378
|
+
width,
|
|
379
|
+
height: boardHeight,
|
|
380
|
+
frame: boardFrame(false)
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
}
|
|
354
384
|
return /* @__PURE__ */ jsx2(
|
|
355
385
|
IssueBoard,
|
|
356
386
|
{
|
|
357
387
|
model,
|
|
358
388
|
parents,
|
|
359
|
-
frame: (
|
|
360
|
-
Frame,
|
|
361
|
-
{
|
|
362
|
-
width,
|
|
363
|
-
height,
|
|
364
|
-
count: title.count,
|
|
365
|
-
user: title.user,
|
|
366
|
-
scope: title.scope,
|
|
367
|
-
status: title.status,
|
|
368
|
-
hints,
|
|
369
|
-
gap: false,
|
|
370
|
-
children: body
|
|
371
|
-
}
|
|
372
|
-
),
|
|
389
|
+
frame: boardFrame(),
|
|
373
390
|
onInputFocus: setInputFocused,
|
|
374
391
|
viewer,
|
|
375
392
|
loadedAt,
|
|
376
393
|
scope,
|
|
377
394
|
searchError,
|
|
378
395
|
width,
|
|
379
|
-
height:
|
|
396
|
+
height: boardHeight,
|
|
380
397
|
showingAll,
|
|
381
398
|
onOpen: (key) => void loadIssue(key),
|
|
382
399
|
onRefresh: () => void (scope.kind === "search" ? runSearch(scope.query, scope.mode) : loadList(showingAll)),
|
|
@@ -399,6 +416,9 @@ import {
|
|
|
399
416
|
boardOf,
|
|
400
417
|
issueDetailOf,
|
|
401
418
|
parentsOf,
|
|
419
|
+
tabsFromBoard,
|
|
420
|
+
tabsFromConfig,
|
|
421
|
+
tabsFromCategories,
|
|
402
422
|
transitionsOf,
|
|
403
423
|
withBehind
|
|
404
424
|
} from "@kud/jira-ink";
|
|
@@ -407,6 +427,13 @@ var boardOptions = (ctx) => ({
|
|
|
407
427
|
...ctx.config.tabs ? { tabs: ctx.config.tabs } : {},
|
|
408
428
|
...ctx.board ?? ctx.config.defaultBoard !== void 0 ? { board: ctx.board ?? ctx.config.defaultBoard } : {}
|
|
409
429
|
});
|
|
430
|
+
var tabsOf = async (ctx) => {
|
|
431
|
+
const { tabs, board } = boardOptions(ctx);
|
|
432
|
+
if (tabs?.length) return tabsFromConfig(tabs);
|
|
433
|
+
if (board === void 0) return tabsFromCategories();
|
|
434
|
+
const configuration = await ctx.client.getBoardConfiguration(board);
|
|
435
|
+
return tabsFromBoard(configuration) ?? tabsFromCategories();
|
|
436
|
+
};
|
|
410
437
|
var marked = (model) => ({
|
|
411
438
|
...model,
|
|
412
439
|
rows: withBehind(model.rows, model.tabs)
|
|
@@ -420,6 +447,7 @@ var liveData = (ctx = context()) => ({
|
|
|
420
447
|
boardOptions(ctx)
|
|
421
448
|
)
|
|
422
449
|
),
|
|
450
|
+
tabs: () => tabsOf(ctx),
|
|
423
451
|
parents: (rows) => parentsOf(ctx.client, rows),
|
|
424
452
|
me: async () => ({ displayName: (await ctx.client.getMe()).displayName }),
|
|
425
453
|
search: async (query, mode) => {
|
|
@@ -527,6 +555,7 @@ var fallbackDetail = (key) => {
|
|
|
527
555
|
var mockData = () => ({
|
|
528
556
|
baseUrl: "https://example.atlassian.net",
|
|
529
557
|
board: async () => mockBoard(),
|
|
558
|
+
tabs: async () => mockBoard().tabs,
|
|
530
559
|
me: async () => ({ displayName: "Ada Okafor" }),
|
|
531
560
|
search: async (query, mode) => {
|
|
532
561
|
const used = mode === "jql" || mode === "auto" && looksLikeJql(query) ? "jql" : "text";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kud/jira-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Jira on the command line — read issues, comments and attachments as plain text",
|
|
6
6
|
"keywords": [
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"prepublishOnly": "npm run build"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@kud/ink-ui": "0.
|
|
40
|
+
"@kud/ink-ui": "0.32.0",
|
|
41
41
|
"@kud/jira": "0.4.0",
|
|
42
|
-
"@kud/jira-ink": "0.
|
|
42
|
+
"@kud/jira-ink": "0.11.0",
|
|
43
43
|
"commander": "14.0.1",
|
|
44
44
|
"ink": "7.1.1",
|
|
45
45
|
"react": "19.2.5"
|