@kud/jira-cli 0.6.2 → 0.8.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-HYJNQNH4.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-HYJNQNH4.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";
|
|
@@ -9,6 +9,7 @@ import { render } from "ink";
|
|
|
9
9
|
import { execFile } from "child_process";
|
|
10
10
|
import {
|
|
11
11
|
Alert,
|
|
12
|
+
colors,
|
|
12
13
|
ConfirmInput,
|
|
13
14
|
Select,
|
|
14
15
|
Spinner,
|
|
@@ -20,7 +21,10 @@ import { useCallback, useEffect, useState } from "react";
|
|
|
20
21
|
import { errorMessagesOf, isJiraApiError } from "@kud/jira";
|
|
21
22
|
import {
|
|
22
23
|
IssueBoard,
|
|
23
|
-
IssueDetailView
|
|
24
|
+
IssueDetailView,
|
|
25
|
+
pendingRow,
|
|
26
|
+
settleRow,
|
|
27
|
+
transitionRow
|
|
24
28
|
} from "@kud/jira-ink";
|
|
25
29
|
|
|
26
30
|
// src/tui/frame.tsx
|
|
@@ -80,6 +84,9 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
80
84
|
const [showingAll, setShowingAll] = useState(false);
|
|
81
85
|
const [error, setError] = useState(null);
|
|
82
86
|
const [busy, setBusy] = useState(null);
|
|
87
|
+
const [parents, setParents] = useState([]);
|
|
88
|
+
const [flash, setFlash] = useState(null);
|
|
89
|
+
const [moving, setMoving] = useState(null);
|
|
83
90
|
const loadList = useCallback(
|
|
84
91
|
async (all) => {
|
|
85
92
|
setError(null);
|
|
@@ -87,8 +94,11 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
87
94
|
setScope({ kind: "mine" });
|
|
88
95
|
setSearchError(null);
|
|
89
96
|
try {
|
|
90
|
-
|
|
97
|
+
const next = await data.board(all);
|
|
98
|
+
setModel(next);
|
|
91
99
|
setLoadedAt(Date.now());
|
|
100
|
+
void data.parents(next.rows).then(setParents).catch(() => {
|
|
101
|
+
});
|
|
92
102
|
} catch (e) {
|
|
93
103
|
setError(e instanceof Error ? e.message : String(e));
|
|
94
104
|
}
|
|
@@ -114,6 +124,8 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
114
124
|
try {
|
|
115
125
|
const result = await data.search(query, mode);
|
|
116
126
|
setModel(result.model);
|
|
127
|
+
void data.parents(result.model.rows).then(setParents).catch(() => {
|
|
128
|
+
});
|
|
117
129
|
setScope({ kind: "search", query, mode: result.mode });
|
|
118
130
|
setLoadedAt(Date.now());
|
|
119
131
|
} catch (e) {
|
|
@@ -122,6 +134,24 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
122
134
|
},
|
|
123
135
|
[data]
|
|
124
136
|
);
|
|
137
|
+
const move = useCallback(
|
|
138
|
+
async (key, t) => {
|
|
139
|
+
setFlash(null);
|
|
140
|
+
setMoving(key);
|
|
141
|
+
setModel((m) => m ? pendingRow(m, key, t.to) : m);
|
|
142
|
+
try {
|
|
143
|
+
await data.transition(key, t.id);
|
|
144
|
+
setModel((m) => m ? transitionRow(m, key, t.to) : m);
|
|
145
|
+
setIssue((i) => i && i.key === key ? { ...i, status: t.to.name } : i);
|
|
146
|
+
} catch (e) {
|
|
147
|
+
setModel((m) => m ? settleRow(m, key) : m);
|
|
148
|
+
setFlash(jiraMessageOf(e));
|
|
149
|
+
} finally {
|
|
150
|
+
setMoving(null);
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
[data]
|
|
154
|
+
);
|
|
125
155
|
useEffect(() => {
|
|
126
156
|
void data.me().then((me) => setViewer(me.displayName)).catch(() => {
|
|
127
157
|
});
|
|
@@ -185,22 +215,13 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
185
215
|
Select,
|
|
186
216
|
{
|
|
187
217
|
options: overlay.options.map((t) => ({
|
|
188
|
-
label: `${t.name} \u2192 ${t.to}`,
|
|
218
|
+
label: `${t.name} \u2192 ${t.to.name}`,
|
|
189
219
|
value: t.id
|
|
190
220
|
})),
|
|
191
221
|
onSubmit: (id) => {
|
|
222
|
+
const chosen = overlay.options.find((t) => t.id === id);
|
|
192
223
|
setOverlay({ kind: "none" });
|
|
193
|
-
void (
|
|
194
|
-
setBusy("Transitioning\u2026");
|
|
195
|
-
try {
|
|
196
|
-
await data.transition(issue.key, id);
|
|
197
|
-
await loadIssue(issue.key);
|
|
198
|
-
} catch (e) {
|
|
199
|
-
setError(e instanceof Error ? e.message : String(e));
|
|
200
|
-
} finally {
|
|
201
|
-
setBusy(null);
|
|
202
|
-
}
|
|
203
|
-
})();
|
|
224
|
+
void move(issue.key, chosen);
|
|
204
225
|
}
|
|
205
226
|
}
|
|
206
227
|
),
|
|
@@ -290,7 +311,11 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
290
311
|
hints: hints.filter(([k]) => k !== "\u232B"),
|
|
291
312
|
page: "nested",
|
|
292
313
|
children: [
|
|
293
|
-
/* @__PURE__ */
|
|
314
|
+
/* @__PURE__ */ jsxs(Box, { paddingLeft: 2, children: [
|
|
315
|
+
/* @__PURE__ */ jsx2(Text, { dimColor: true, children: subtitle }),
|
|
316
|
+
moving === issue.key ? /* @__PURE__ */ jsx2(Text, { color: colors.accent, children: " \u22EF moving" }) : null
|
|
317
|
+
] }),
|
|
318
|
+
flash ? /* @__PURE__ */ jsx2(Box, { paddingLeft: 2, children: /* @__PURE__ */ jsx2(Text, { color: colors.error, children: `\u2717 ${flash}` }) }) : null,
|
|
294
319
|
/* @__PURE__ */ jsx2(
|
|
295
320
|
Box,
|
|
296
321
|
{
|
|
@@ -309,6 +334,7 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
309
334
|
onAssign: () => setOverlay({ kind: "assign" }),
|
|
310
335
|
onComment: () => setOverlay({ kind: "comment" }),
|
|
311
336
|
onTransition: () => {
|
|
337
|
+
if (moving) return;
|
|
312
338
|
void (async () => {
|
|
313
339
|
setBusy("Loading transitions\u2026");
|
|
314
340
|
try {
|
|
@@ -329,6 +355,7 @@ var App = ({ data, initialScreen, initialKey }) => {
|
|
|
329
355
|
IssueBoard,
|
|
330
356
|
{
|
|
331
357
|
model,
|
|
358
|
+
parents,
|
|
332
359
|
frame: ({ title, hints, body }) => /* @__PURE__ */ jsx2(
|
|
333
360
|
Frame,
|
|
334
361
|
{
|
|
@@ -371,27 +398,39 @@ import { searchJql } from "@kud/jira";
|
|
|
371
398
|
import {
|
|
372
399
|
boardOf,
|
|
373
400
|
issueDetailOf,
|
|
374
|
-
|
|
401
|
+
parentsOf,
|
|
402
|
+
transitionsOf,
|
|
403
|
+
withBehind
|
|
375
404
|
} from "@kud/jira-ink";
|
|
376
405
|
var DEFAULT_SCOPE = "(statusCategory != Done OR (statusCategory = Done AND updated >= -14d))";
|
|
377
406
|
var boardOptions = (ctx) => ({
|
|
378
407
|
...ctx.config.tabs ? { tabs: ctx.config.tabs } : {},
|
|
379
408
|
...ctx.board ?? ctx.config.defaultBoard !== void 0 ? { board: ctx.board ?? ctx.config.defaultBoard } : {}
|
|
380
409
|
});
|
|
410
|
+
var marked = (model) => ({
|
|
411
|
+
...model,
|
|
412
|
+
rows: withBehind(model.rows, model.tabs)
|
|
413
|
+
});
|
|
381
414
|
var liveData = (ctx = context()) => ({
|
|
382
415
|
baseUrl: ctx.config.baseUrl,
|
|
383
|
-
board: (all) =>
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
416
|
+
board: async (all) => marked(
|
|
417
|
+
await boardOf(
|
|
418
|
+
ctx.client,
|
|
419
|
+
`assignee = currentUser()${all ? "" : ` AND ${DEFAULT_SCOPE}`} ORDER BY updated DESC`,
|
|
420
|
+
boardOptions(ctx)
|
|
421
|
+
)
|
|
387
422
|
),
|
|
423
|
+
parents: (rows) => parentsOf(ctx.client, rows),
|
|
388
424
|
me: async () => ({ displayName: (await ctx.client.getMe()).displayName }),
|
|
389
425
|
search: async (query, mode) => {
|
|
390
426
|
const { jql, mode: used } = searchJql(query, {
|
|
391
427
|
mode,
|
|
392
428
|
scope: "assignee = currentUser()"
|
|
393
429
|
});
|
|
394
|
-
return {
|
|
430
|
+
return {
|
|
431
|
+
model: marked(await boardOf(ctx.client, jql, boardOptions(ctx))),
|
|
432
|
+
mode: used
|
|
433
|
+
};
|
|
395
434
|
},
|
|
396
435
|
getIssue: (key) => issueDetailOf(ctx.client, ctx.config.baseUrl, key),
|
|
397
436
|
getTransitions: (key) => transitionsOf(ctx.client, key),
|
|
@@ -503,11 +542,25 @@ var mockData = () => ({
|
|
|
503
542
|
}
|
|
504
543
|
};
|
|
505
544
|
},
|
|
545
|
+
// Nobody's epic is missing from the mock board, so the lookup has nothing
|
|
546
|
+
// to find — which is the honest answer here rather than an invented fence.
|
|
547
|
+
parents: async () => [],
|
|
506
548
|
getIssue: async (key) => DETAIL[key] ?? fallbackDetail(key),
|
|
549
|
+
// The status ids match the mock board's own, so a transition here actually
|
|
550
|
+
// lands the row in the tab it names — a mock whose move goes nowhere cannot
|
|
551
|
+
// demonstrate the one thing the move is for.
|
|
507
552
|
getTransitions: async () => [
|
|
508
|
-
{
|
|
509
|
-
|
|
510
|
-
|
|
553
|
+
{
|
|
554
|
+
id: "11",
|
|
555
|
+
name: "Start progress",
|
|
556
|
+
to: { id: "10001", name: "In Progress", category: "indeterminate" }
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
id: "21",
|
|
560
|
+
name: "Ready for review",
|
|
561
|
+
to: { id: "10002", name: "In Review", category: "indeterminate" }
|
|
562
|
+
},
|
|
563
|
+
{ id: "31", name: "Done", to: { id: "10003", name: "Done", category: "done" } }
|
|
511
564
|
],
|
|
512
565
|
transition: async () => {
|
|
513
566
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kud/jira-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Jira on the command line — read issues, comments and attachments as plain text",
|
|
6
6
|
"keywords": [
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@kud/ink-ui": "0.28.2",
|
|
41
41
|
"@kud/jira": "0.4.0",
|
|
42
|
-
"@kud/jira-ink": "0.
|
|
42
|
+
"@kud/jira-ink": "0.10.0",
|
|
43
43
|
"commander": "14.0.1",
|
|
44
44
|
"ink": "7.1.1",
|
|
45
45
|
"react": "19.2.5"
|