@kud/jira-cli 0.10.0 → 0.11.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 +16 -3
- package/dist/index.js +180 -34
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -79,8 +79,9 @@ jira issue list # yours, most recently updated first
|
|
|
79
79
|
jira issue list --status 'In Progress'
|
|
80
80
|
jira issue list --project ABC --sprint current
|
|
81
81
|
jira issue view ABC-123
|
|
82
|
+
jira issue view ABC-123 --fields status,assignee,issuelinks
|
|
82
83
|
jira issue transition ABC-123 # list what's available
|
|
83
|
-
jira issue transition ABC-123 'In Review'
|
|
84
|
+
jira issue transition ABC-123 'In Review' # by transition name or target status
|
|
84
85
|
jira issue open ABC-123
|
|
85
86
|
```
|
|
86
87
|
|
|
@@ -88,14 +89,16 @@ Writing:
|
|
|
88
89
|
|
|
89
90
|
```sh
|
|
90
91
|
jira issue create -p ABC -t Task -s 'Fix the thing' -b 'Longer **markdown** body'
|
|
91
|
-
jira issue
|
|
92
|
-
jira issue
|
|
92
|
+
jira issue create -p ABC -t Task -s 'A sub-task' --parent ABC-100 --link Relates:ABC-99
|
|
93
|
+
jira issue edit ABC-123 --summary 'Better title' --assignee me --parent ABC-100
|
|
94
|
+
jira issue assign ABC-123 me # or a name, an email, an account id, or 'none'
|
|
93
95
|
jira issue comment add ABC-123 - # body from stdin
|
|
94
96
|
jira issue comment list ABC-123
|
|
95
97
|
jira issue comment edit ABC-123 12345 'Actually fixed in 2.1'
|
|
96
98
|
jira issue delete ABC-123 # asks first; --yes to confirm in scripts
|
|
97
99
|
jira issue rank ABC-1 ABC-2 --before ABC-3
|
|
98
100
|
jira issue link ABC-1 Blocks ABC-2
|
|
101
|
+
jira issue link list ABC-1
|
|
99
102
|
jira issue watch add ABC-123
|
|
100
103
|
jira issue worklog add ABC-123 '2h 30m'
|
|
101
104
|
jira issue worklog edit ABC-123 456 --time '3h'
|
|
@@ -106,6 +109,14 @@ jira issue remotelink remove ABC-123 789
|
|
|
106
109
|
jira issue history ABC-123
|
|
107
110
|
```
|
|
108
111
|
|
|
112
|
+
`jira issue view` lists the issue's links and subtasks, in plain text and in `--json`. Pass `--fields status,assignee,parent,issuelinks` (comma-separated) to see only those fields — both in plain text and `--json`; the key and summary stay either way, and without `--fields` the view is exactly what it has always been.
|
|
113
|
+
|
|
114
|
+
People are resolved for you. `issue assign`, and `--assignee` on `create` and `edit`, accept a name or an email: assignable users of the project are searched first, then every user. `me` means you, `none` unassigns, and a raw account id passes straight through. If a name matches several people nothing is assigned — every match is printed on stderr and the command exits non-zero, because a guess is worse than an error.
|
|
115
|
+
|
|
116
|
+
Parents and links belong to the same commands. `--parent ABC-100` sets a parent on `create` or `edit`, and `edit --parent none` clears it. `--link Relates:ABC-99` (repeatable, `<type>:<KEY>`) links the new issue right after creating it, exactly as `jira issue link <new> <type> <KEY>` would. The link type is checked against your instance's link type names before anything is created, so a typo costs nothing; if creation succeeds but a link fails, the new key and the failure are reported and the exit is non-zero.
|
|
117
|
+
|
|
118
|
+
`issue transition` takes either a transition name or the status it leads to (`Start Progress` or `In Progress`), matched case-insensitively and by transition id. With no argument it lists the transitions as `name → target status`.
|
|
119
|
+
|
|
109
120
|
Bodies accept Markdown — paragraphs, headings, lists, fenced code, links and code spans are converted to ADF.
|
|
110
121
|
|
|
111
122
|
Deletes (`issue delete`, `comment delete`, `worklog delete`, `remotelink remove`) ask before they act; piped or scripted runs refuse unless `--yes` is passed, since there is no undo on Jira's side. `remotelink add` is idempotent: re-adding the same url updates the same link rather than creating duplicates.
|
|
@@ -203,6 +214,8 @@ jira api /rest/api/3/myself
|
|
|
203
214
|
jira api /rest/api/3/issue/ABC-123/watchers -X POST -d '{"accountId":"..."}'
|
|
204
215
|
```
|
|
205
216
|
|
|
217
|
+
A call returning 2xx with an empty body — a 204, or a 201 with no content — prints nothing and exits 0, rather than printing the string `null`; that way `null` only ever means Jira really answered null. A non-2xx is still an error, showing the body.
|
|
218
|
+
|
|
206
219
|
## Licence
|
|
207
220
|
|
|
208
221
|
MIT
|
package/dist/index.js
CHANGED
|
@@ -267,11 +267,11 @@ var registerBacklogCommand = (program2) => {
|
|
|
267
267
|
|
|
268
268
|
// src/commands/issue.ts
|
|
269
269
|
import { execFile } from "child_process";
|
|
270
|
-
import { adfToMarkdown as adfToMarkdown2, locateAttachments as locateAttachments2 } from "@kud/jira";
|
|
270
|
+
import { adfToMarkdown as adfToMarkdown2, flattenIssueLinks as flattenIssueLinks2, locateAttachments as locateAttachments2 } from "@kud/jira";
|
|
271
271
|
|
|
272
272
|
// src/commands/issue-write.ts
|
|
273
273
|
import { readFileSync } from "fs";
|
|
274
|
-
import { adfToMarkdown, markdownToAdf } from "@kud/jira";
|
|
274
|
+
import { adfToMarkdown, flattenIssueLinks, markdownToAdf } from "@kud/jira";
|
|
275
275
|
|
|
276
276
|
// src/commands/confirm.ts
|
|
277
277
|
import { createInterface } from "readline/promises";
|
|
@@ -301,22 +301,61 @@ var rankPosition = (options) => {
|
|
|
301
301
|
return { after };
|
|
302
302
|
};
|
|
303
303
|
var readBody = (value) => value === "-" ? readFileSync(0, "utf8") : value;
|
|
304
|
+
var projectOf = (issueKey) => issueKey.split("-")[0];
|
|
305
|
+
var collectLink = (value, prior) => [
|
|
306
|
+
...prior,
|
|
307
|
+
value
|
|
308
|
+
];
|
|
309
|
+
var messageOf = (e) => e instanceof Error ? e.message : String(e);
|
|
310
|
+
var linkTypes = (ctx) => ctx.client.getIssueLinkTypes().then(({ issueLinkTypes }) => issueLinkTypes);
|
|
311
|
+
var parseLinkSpecs = (link, types) => {
|
|
312
|
+
if (!link?.length) return [];
|
|
313
|
+
const titles = types.map((t) => t.name);
|
|
314
|
+
return link.map((spec) => {
|
|
315
|
+
const colon = spec.indexOf(":");
|
|
316
|
+
const type = colon === -1 ? void 0 : spec.slice(0, colon);
|
|
317
|
+
const key = colon === -1 ? void 0 : spec.slice(colon + 1);
|
|
318
|
+
if (!type || !key)
|
|
319
|
+
throw exitError(
|
|
320
|
+
1,
|
|
321
|
+
`malformed --link '${spec}' \u2014 expected <type>:<KEY>, e.g. Relates:ABC-2`
|
|
322
|
+
);
|
|
323
|
+
const resolved = types.find(
|
|
324
|
+
(t) => t.name.toLowerCase() === type.toLowerCase()
|
|
325
|
+
);
|
|
326
|
+
if (!resolved)
|
|
327
|
+
throw exitError(
|
|
328
|
+
1,
|
|
329
|
+
`no link type '${type}'. Valid: ${titles.join(", ")}`
|
|
330
|
+
);
|
|
331
|
+
return { type: resolved.name, key };
|
|
332
|
+
});
|
|
333
|
+
};
|
|
304
334
|
var resolveAccountId = async (who, projectKey) => {
|
|
305
335
|
if (who === "none" || who === "unassigned") return null;
|
|
306
336
|
if (who === "me") return (await context().client.getMe()).accountId;
|
|
307
337
|
if (/^[0-9a-f]{24}$|:/.test(who)) return who;
|
|
308
338
|
const ctx = context();
|
|
309
|
-
const
|
|
339
|
+
const assignable = projectKey ? await ctx.client.searchAssignableUsers(who, projectKey) : [];
|
|
340
|
+
const candidates = assignable.length > 0 ? assignable : await ctx.client.searchUsers(who);
|
|
310
341
|
if (candidates.length === 0) throw exitError(1, `no user matching '${who}'`);
|
|
311
|
-
if (candidates.length > 1)
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
342
|
+
if (candidates.length > 1) {
|
|
343
|
+
for (const u of candidates)
|
|
344
|
+
process.stderr.write(
|
|
345
|
+
`${u.displayName}${u.emailAddress ? ` ${u.emailAddress}` : ""} ${u.accountId}
|
|
346
|
+
`
|
|
347
|
+
);
|
|
348
|
+
throw exitError(1, `'${who}' matches ${candidates.length} people`);
|
|
349
|
+
}
|
|
316
350
|
return candidates[0].accountId;
|
|
317
351
|
};
|
|
318
352
|
var registerIssueWriteCommands = (issue) => {
|
|
319
|
-
issue.command("create").description("create an issue").requiredOption("-p, --project <key>", "project key").requiredOption("-t, --type <type>", "issue type, e.g. Task").requiredOption("-s, --summary <text>", "summary").option("-b, --body <text>", "description; '-' reads stdin").option("-a, --assignee <who>", "assignee, or 'me'").option("-l, --label <label...>", "labels").option("--priority <name>", "priority name").option("--
|
|
353
|
+
issue.command("create").description("create an issue").requiredOption("-p, --project <key>", "project key").requiredOption("-t, --type <type>", "issue type, e.g. Task").requiredOption("-s, --summary <text>", "summary").option("-b, --body <text>", "description; '-' reads stdin").option("-a, --assignee <who>", "assignee, or 'me'").option("-l, --label <label...>", "labels").option("--priority <name>", "priority name").option("--parent <key>", "parent issue key").option(
|
|
354
|
+
"--link <type:key>",
|
|
355
|
+
"link the new issue to another, repeatable, e.g. Relates:ABC-2",
|
|
356
|
+
collectLink,
|
|
357
|
+
[]
|
|
358
|
+
).option("--json", "emit JSON").action(
|
|
320
359
|
async (options) => {
|
|
321
360
|
const ctx = context();
|
|
322
361
|
const fields = {
|
|
@@ -328,6 +367,7 @@ var registerIssueWriteCommands = (issue) => {
|
|
|
328
367
|
fields["description"] = markdownToAdf(readBody(options.body));
|
|
329
368
|
if (options.label) fields["labels"] = options.label;
|
|
330
369
|
if (options.priority) fields["priority"] = { name: options.priority };
|
|
370
|
+
if (options.parent) fields["parent"] = { key: options.parent };
|
|
331
371
|
if (options.assignee)
|
|
332
372
|
fields["assignee"] = {
|
|
333
373
|
accountId: await resolveAccountId(
|
|
@@ -335,13 +375,26 @@ var registerIssueWriteCommands = (issue) => {
|
|
|
335
375
|
options.project
|
|
336
376
|
)
|
|
337
377
|
};
|
|
378
|
+
const links = options.link?.length ? parseLinkSpecs(options.link, await linkTypes(ctx)) : [];
|
|
338
379
|
const created = await ctx.client.createIssue(fields);
|
|
339
|
-
if (options.json)
|
|
340
|
-
process.stdout.write(`${created.key}
|
|
380
|
+
if (options.json) printJson(created);
|
|
381
|
+
else process.stdout.write(`${created.key}
|
|
382
|
+
`);
|
|
383
|
+
for (const link2 of links) {
|
|
384
|
+
try {
|
|
385
|
+
await ctx.client.linkIssues(link2.type, created.key, link2.key);
|
|
386
|
+
} catch (e) {
|
|
387
|
+
throw exitError(
|
|
388
|
+
1,
|
|
389
|
+
`created ${created.key}, but the ${link2.type} link to ${link2.key} failed: ${messageOf(e)}`
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
process.stderr.write(`linked ${created.key} ${link2.type} ${link2.key}
|
|
341
393
|
`);
|
|
394
|
+
}
|
|
342
395
|
}
|
|
343
396
|
);
|
|
344
|
-
issue.command("edit <key>").description("change an issue's fields").option("-s, --summary <text>", "new summary").option("-b, --body <text>", "new description; '-' reads stdin").option("-l, --label <label...>", "replace labels").option("--priority <name>", "priority name").action(
|
|
397
|
+
issue.command("edit <key>").description("change an issue's fields").option("-s, --summary <text>", "new summary").option("-b, --body <text>", "new description; '-' reads stdin").option("-l, --label <label...>", "replace labels").option("--priority <name>", "priority name").option("--parent <key>", "parent issue key; 'none' clears it").option("-a, --assignee <who>", "assignee; 'me' or 'none' both work").action(
|
|
345
398
|
async (key, options) => {
|
|
346
399
|
const fields = {};
|
|
347
400
|
if (options.summary) fields["summary"] = options.summary;
|
|
@@ -349,6 +402,15 @@ var registerIssueWriteCommands = (issue) => {
|
|
|
349
402
|
fields["description"] = markdownToAdf(readBody(options.body));
|
|
350
403
|
if (options.label) fields["labels"] = options.label;
|
|
351
404
|
if (options.priority) fields["priority"] = { name: options.priority };
|
|
405
|
+
if (options.parent !== void 0)
|
|
406
|
+
fields["parent"] = options.parent === "none" ? null : { key: options.parent };
|
|
407
|
+
if (options.assignee) {
|
|
408
|
+
const accountId = await resolveAccountId(
|
|
409
|
+
options.assignee,
|
|
410
|
+
projectOf(key)
|
|
411
|
+
);
|
|
412
|
+
fields["assignee"] = accountId ? { accountId } : null;
|
|
413
|
+
}
|
|
352
414
|
if (Object.keys(fields).length === 0)
|
|
353
415
|
throw exitError(2, "nothing to change \u2014 pass at least one option");
|
|
354
416
|
await context().client.updateIssue(key, fields);
|
|
@@ -362,8 +424,8 @@ var registerIssueWriteCommands = (issue) => {
|
|
|
362
424
|
process.stderr.write(`deleted ${key}
|
|
363
425
|
`);
|
|
364
426
|
});
|
|
365
|
-
issue.command("assign <key> <who>").description("assign an issue; 'me' or 'none'
|
|
366
|
-
const accountId = await resolveAccountId(who);
|
|
427
|
+
issue.command("assign <key> <who>").description("assign an issue; 'me', a name, or 'none' all work").action(async (key, who) => {
|
|
428
|
+
const accountId = await resolveAccountId(who, projectOf(key));
|
|
367
429
|
await context().client.assignIssue(key, accountId);
|
|
368
430
|
process.stderr.write(`${key} assigned to ${accountId ? who : "nobody"}
|
|
369
431
|
`);
|
|
@@ -532,9 +594,31 @@ var registerIssueWriteCommands = (issue) => {
|
|
|
532
594
|
);
|
|
533
595
|
}
|
|
534
596
|
);
|
|
535
|
-
issue.command("link
|
|
597
|
+
const link = issue.command("link").description("link two issues, e.g. jira issue link ABC-1 Blocks ABC-2");
|
|
598
|
+
link.command("list <key>").alias("ls").description("links on an issue").option("--json", "emit JSON").action(async (key, options) => {
|
|
599
|
+
const ctx = context();
|
|
600
|
+
const found = await ctx.client.getIssue(key);
|
|
601
|
+
const links = flattenIssueLinks(found);
|
|
602
|
+
if (options.json) return printJson(links);
|
|
603
|
+
if (links.length === 0) {
|
|
604
|
+
process.stderr.write(`${key} has no links
|
|
605
|
+
`);
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
process.stdout.write(
|
|
609
|
+
`${table(links, [
|
|
610
|
+
{ header: "DIR", value: (l) => l.direction },
|
|
611
|
+
{ header: "TYPE", value: (l) => l.type },
|
|
612
|
+
{ header: "KEY", value: (l) => l.key },
|
|
613
|
+
{ header: "STATUS", value: (l) => l.status },
|
|
614
|
+
{ header: "SUMMARY", value: (l) => truncate(l.summary, 40) }
|
|
615
|
+
])}
|
|
616
|
+
`
|
|
617
|
+
);
|
|
618
|
+
});
|
|
619
|
+
link.argument("<inward>").argument("<type>").argument("<outward>").action(async (inward, type, outward) => {
|
|
536
620
|
await context().client.linkIssues(type, inward, outward);
|
|
537
|
-
process.stderr.write(
|
|
621
|
+
process.stderr.write(`linked ${inward} ${type} ${outward}
|
|
538
622
|
`);
|
|
539
623
|
});
|
|
540
624
|
issue.command("history <key>").description("what changed on an issue and when").option("--json", "emit JSON").action(async (key, options) => {
|
|
@@ -591,30 +675,71 @@ var registerIssueCommands = (program2) => {
|
|
|
591
675
|
`);
|
|
592
676
|
warnIfTruncated(issues.length, limit, { exitCode: false });
|
|
593
677
|
});
|
|
594
|
-
issue.command("view <key>").description("show one issue").option("--json", "emit JSON").option("--comments", "include comments").
|
|
678
|
+
issue.command("view <key>").description("show one issue").option("--json", "emit JSON").option("--comments", "include comments").option(
|
|
679
|
+
"--fields <list>",
|
|
680
|
+
"restrict the output to these fields, comma-separated"
|
|
681
|
+
).action(
|
|
595
682
|
async (key, options) => {
|
|
596
683
|
const ctx = context();
|
|
597
684
|
const found = await ctx.client.getIssue(key);
|
|
598
|
-
|
|
685
|
+
const fields = options.fields?.split(",").map((f2) => f2.trim().toLowerCase()).filter(Boolean);
|
|
686
|
+
const show = (field) => !fields || fields.includes(field.toLowerCase());
|
|
687
|
+
if (options.json) {
|
|
688
|
+
const chosen = fields ? Object.fromEntries(
|
|
689
|
+
Object.entries(found.fields).filter(
|
|
690
|
+
([k]) => fields.includes(k.toLowerCase())
|
|
691
|
+
)
|
|
692
|
+
) : { ...found.fields };
|
|
693
|
+
if (show("issuelinks")) chosen["issuelinks"] = flattenIssueLinks2(found);
|
|
694
|
+
if (show("subtasks"))
|
|
695
|
+
chosen["subtasks"] = found.fields.subtasks?.map((s) => ({
|
|
696
|
+
key: s.key,
|
|
697
|
+
summary: s.fields.summary,
|
|
698
|
+
status: s.fields.status.name
|
|
699
|
+
}));
|
|
700
|
+
return printJson({ ...found, fields: chosen });
|
|
701
|
+
}
|
|
599
702
|
const { bold, dim } = ctx.out;
|
|
600
703
|
const f = found.fields;
|
|
601
704
|
const lines = [
|
|
602
705
|
`${bold(found.key)} ${f.summary ?? ""}`,
|
|
603
706
|
"",
|
|
604
|
-
...f.parent ? [
|
|
707
|
+
...show("parent") && f.parent ? [
|
|
605
708
|
`${dim("parent")} ${f.parent.key} ${truncate(f.parent.fields?.summary ?? "", 60)}`
|
|
606
709
|
] : [],
|
|
607
|
-
`${dim("status")} ${f.status?.name ?? "\u2014"}
|
|
608
|
-
`${dim("type")} ${f.issuetype?.name ?? "\u2014"}
|
|
609
|
-
`${dim("assignee")} ${f.assignee?.displayName ?? "unassigned"}
|
|
610
|
-
`${dim("reporter")} ${f.reporter?.displayName ?? "\u2014"}
|
|
611
|
-
...f.labels?.length ? [`${dim("labels")} ${f.labels.join(", ")}`] : [],
|
|
612
|
-
...ctx.client.customFields.filter((cf) => f[cf.id] != null).map((cf) => `${dim(cf.label.padEnd(9))} ${formatField(f[cf.id])}`),
|
|
613
|
-
`${dim("url")} ${issueUrl(ctx, found.key)}`
|
|
710
|
+
...show("status") ? [`${dim("status")} ${f.status?.name ?? "\u2014"}`] : [],
|
|
711
|
+
...show("issuetype") ? [`${dim("type")} ${f.issuetype?.name ?? "\u2014"}`] : [],
|
|
712
|
+
...show("assignee") ? [`${dim("assignee")} ${f.assignee?.displayName ?? "unassigned"}`] : [],
|
|
713
|
+
...show("reporter") ? [`${dim("reporter")} ${f.reporter?.displayName ?? "\u2014"}`] : [],
|
|
714
|
+
...show("labels") && f.labels?.length ? [`${dim("labels")} ${f.labels.join(", ")}`] : [],
|
|
715
|
+
...ctx.client.customFields.filter((cf) => f[cf.id] != null && show(cf.id)).map((cf) => `${dim(cf.label.padEnd(9))} ${formatField(f[cf.id])}`),
|
|
716
|
+
...fields ? [] : [`${dim("url")} ${issueUrl(ctx, found.key)}`]
|
|
614
717
|
];
|
|
718
|
+
const links = flattenIssueLinks2(found);
|
|
719
|
+
if (show("issuelinks") && links.length > 0) {
|
|
720
|
+
lines.push(
|
|
721
|
+
"",
|
|
722
|
+
dim("\u2500\u2500\u2500 links \u2500\u2500\u2500"),
|
|
723
|
+
"",
|
|
724
|
+
...links.map(
|
|
725
|
+
(l) => `${l.direction.padEnd(7)} ${l.type.padEnd(12)} ${l.key} ${dim(l.status.padEnd(12))} ${truncate(l.summary, 60)}`
|
|
726
|
+
)
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
const subtasks = f.subtasks;
|
|
730
|
+
if (show("subtasks") && subtasks?.length) {
|
|
731
|
+
lines.push(
|
|
732
|
+
"",
|
|
733
|
+
dim("\u2500\u2500\u2500 subtasks \u2500\u2500\u2500"),
|
|
734
|
+
"",
|
|
735
|
+
...subtasks.map(
|
|
736
|
+
(s) => `${s.key} ${dim(s.fields.status.name.padEnd(12))} ${truncate(s.fields.summary, 60)}`
|
|
737
|
+
)
|
|
738
|
+
);
|
|
739
|
+
}
|
|
615
740
|
const attachments = locateAttachments2(found);
|
|
616
741
|
const filenameOf = (id) => attachments.find((a) => a.id === id)?.filename;
|
|
617
|
-
if (attachments.length > 0) {
|
|
742
|
+
if (!fields && attachments.length > 0) {
|
|
618
743
|
lines.push(
|
|
619
744
|
"",
|
|
620
745
|
dim("\u2500\u2500\u2500 attachments \u2500\u2500\u2500"),
|
|
@@ -627,9 +752,9 @@ var registerIssueCommands = (program2) => {
|
|
|
627
752
|
);
|
|
628
753
|
}
|
|
629
754
|
const description = adfToMarkdown2(f.description, filenameOf);
|
|
630
|
-
if (description)
|
|
755
|
+
if (show("description") && description)
|
|
631
756
|
lines.push("", dim("\u2500\u2500\u2500 description \u2500\u2500\u2500"), "", description);
|
|
632
|
-
if (options.comments && f.comment?.comments?.length) {
|
|
757
|
+
if (options.comments && show("comment") && f.comment?.comments?.length) {
|
|
633
758
|
lines.push("", dim("\u2500\u2500\u2500 comments \u2500\u2500\u2500"));
|
|
634
759
|
for (const c of f.comment.comments) {
|
|
635
760
|
lines.push(
|
|
@@ -652,21 +777,40 @@ var registerIssueCommands = (program2) => {
|
|
|
652
777
|
process.stdout.write(
|
|
653
778
|
`${table(transitions, [
|
|
654
779
|
{ header: "ID", value: (t) => t.id },
|
|
655
|
-
{ header: "NAME", value: (t) => t.name }
|
|
656
|
-
{ header: "TO", value: (t) => t.to?.name ?? "\u2014" }
|
|
780
|
+
{ header: "NAME \u2192 TO", value: (t) => `${t.name} \u2192 ${t.to?.name ?? "\u2014"}` }
|
|
657
781
|
])}
|
|
658
782
|
`
|
|
659
783
|
);
|
|
784
|
+
process.stderr.write(TRANSITION_HINT + "\n");
|
|
660
785
|
return;
|
|
661
786
|
}
|
|
662
787
|
const wanted = status.toLowerCase();
|
|
663
|
-
const
|
|
788
|
+
const byName = transitions.filter(
|
|
664
789
|
(t) => t.name.toLowerCase() === wanted || t.id === status
|
|
665
790
|
);
|
|
791
|
+
const byTarget = transitions.filter(
|
|
792
|
+
(t) => t.to?.name.toLowerCase() === wanted
|
|
793
|
+
);
|
|
794
|
+
const match = byName.length > 0 ? byName.length === 1 ? byName[0] : void 0 : byTarget.length === 1 ? byTarget[0] : void 0;
|
|
795
|
+
if (byName.length > 1) {
|
|
796
|
+
throw exitError(
|
|
797
|
+
1,
|
|
798
|
+
`'${status}' matches ${byName.length} transitions on ${key}: ${byName.map((t) => `${t.name} \u2192 ${t.to?.name ?? "\u2014"}`).join("; ")}`
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
if (byName.length === 0 && byTarget.length > 1) {
|
|
802
|
+
throw exitError(
|
|
803
|
+
1,
|
|
804
|
+
`${byTarget.length} transitions reach '${status}' on ${key}: ${byTarget.map((t) => `${t.name} \u2192 ${t.to?.name ?? "\u2014"}`).join("; ")}
|
|
805
|
+
Use a transition name instead`
|
|
806
|
+
);
|
|
807
|
+
}
|
|
666
808
|
if (!match) {
|
|
667
809
|
throw exitError(
|
|
668
810
|
1,
|
|
669
|
-
`no transition '${status}' on ${key}. Available:
|
|
811
|
+
`no transition or status '${status}' on ${key}. Available:
|
|
812
|
+
${transitions.map((t) => ` ${t.name} \u2192 ${t.to?.name ?? "\u2014"}`).join("\n")}
|
|
813
|
+
${TRANSITION_HINT}`
|
|
670
814
|
);
|
|
671
815
|
}
|
|
672
816
|
await ctx.client.transitionIssue(
|
|
@@ -692,6 +836,7 @@ var registerIssueCommands = (program2) => {
|
|
|
692
836
|
});
|
|
693
837
|
};
|
|
694
838
|
var issueUrl = (ctx, key) => `${ctx.config.baseUrl.replace(/\/$/, "")}/browse/${key}`;
|
|
839
|
+
var TRANSITION_HINT = "the argument may be either the transition name or its target status";
|
|
695
840
|
var formatField = (value) => {
|
|
696
841
|
if (value == null) return "\u2014";
|
|
697
842
|
if (typeof value === "object") {
|
|
@@ -958,7 +1103,8 @@ var registerApiCommand = (program2) => {
|
|
|
958
1103
|
method,
|
|
959
1104
|
...options.data ? { body: options.data } : {}
|
|
960
1105
|
});
|
|
961
|
-
|
|
1106
|
+
if (result == null) return;
|
|
1107
|
+
printJson(result);
|
|
962
1108
|
}
|
|
963
1109
|
);
|
|
964
1110
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kud/jira-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Jira on the command line — read issues, comments and attachments as plain text",
|
|
6
6
|
"keywords": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@kud/ink-ui": "0.32.0",
|
|
41
|
-
"@kud/jira": "0.
|
|
41
|
+
"@kud/jira": "0.6.0",
|
|
42
42
|
"@kud/jira-ink": "0.11.0",
|
|
43
43
|
"commander": "14.0.1",
|
|
44
44
|
"ink": "7.1.1",
|