@bdsqqq/lnr-cli 1.4.0 → 1.6.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/package.json +1 -1
- package/src/router/issues.ts +31 -4
package/package.json
CHANGED
package/src/router/issues.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
deleteReaction,
|
|
23
23
|
createIssueRelation,
|
|
24
24
|
getProject,
|
|
25
|
+
linkGitHubPR,
|
|
25
26
|
type Issue,
|
|
26
27
|
type ListIssuesFilter,
|
|
27
28
|
type Comment,
|
|
@@ -55,6 +56,7 @@ const issueInput = z.object({
|
|
|
55
56
|
idOrNew: z.string().meta({ positional: true }).describe("issue identifier (e.g. ENG-123) or 'new'"),
|
|
56
57
|
json: z.boolean().optional().describe("output as json"),
|
|
57
58
|
open: z.boolean().optional().describe("open issue in browser"),
|
|
59
|
+
branch: z.boolean().optional().describe("output git branch name"),
|
|
58
60
|
state: z.string().optional().describe("set workflow state"),
|
|
59
61
|
assignee: z.string().optional().describe("set assignee by email or @me"),
|
|
60
62
|
priority: z.string().optional().describe("set priority (urgent, high, medium, low, none)"),
|
|
@@ -78,6 +80,7 @@ const issueInput = z.object({
|
|
|
78
80
|
unreact: z.string().optional().describe("reaction id to remove"),
|
|
79
81
|
parent: z.string().optional().describe("set parent issue identifier"),
|
|
80
82
|
subIssues: z.boolean().optional().describe("list sub-issues"),
|
|
83
|
+
pr: z.string().optional().describe("link a github pr url"),
|
|
81
84
|
});
|
|
82
85
|
|
|
83
86
|
type IssueInput = z.infer<typeof issueInput>;
|
|
@@ -139,6 +142,11 @@ async function handleShowIssue(
|
|
|
139
142
|
exitWithError(`issue ${identifier} not found`, undefined, EXIT_CODES.NOT_FOUND);
|
|
140
143
|
}
|
|
141
144
|
|
|
145
|
+
if (input.branch) {
|
|
146
|
+
console.log(issue.branchName);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
142
150
|
if (input.open) {
|
|
143
151
|
const { spawn } = await import("child_process");
|
|
144
152
|
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
@@ -428,6 +436,15 @@ async function handleUpdateIssue(
|
|
|
428
436
|
console.log(`removed reaction ${input.unreact.slice(0, 8)}`);
|
|
429
437
|
}
|
|
430
438
|
|
|
439
|
+
// Link PR
|
|
440
|
+
if (input.pr) {
|
|
441
|
+
const success = await linkGitHubPR(client, issue.id, input.pr);
|
|
442
|
+
if (!success) {
|
|
443
|
+
exitWithError(`failed to link pr`);
|
|
444
|
+
}
|
|
445
|
+
console.log(`linked ${input.pr} to ${identifier}`);
|
|
446
|
+
}
|
|
447
|
+
|
|
431
448
|
// Archive last (restricts further edits)
|
|
432
449
|
if (input.archive) {
|
|
433
450
|
await archiveIssue(client, issue.id);
|
|
@@ -521,10 +538,19 @@ async function handleCreateIssue(input: IssueInput): Promise<void> {
|
|
|
521
538
|
}
|
|
522
539
|
|
|
523
540
|
const issue = await createIssue(client, createPayload);
|
|
524
|
-
if (issue) {
|
|
525
|
-
console.log(`created ${issue.identifier}: ${issue.title}`);
|
|
526
|
-
} else {
|
|
541
|
+
if (!issue) {
|
|
527
542
|
console.log("created issue");
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
console.log(`created ${issue.identifier}: ${issue.title}`);
|
|
547
|
+
|
|
548
|
+
if (input.pr) {
|
|
549
|
+
const success = await linkGitHubPR(client, issue.id, input.pr);
|
|
550
|
+
if (!success) {
|
|
551
|
+
exitWithError(`failed to link pr`);
|
|
552
|
+
}
|
|
553
|
+
console.log(`linked ${input.pr} to ${issue.identifier}`);
|
|
528
554
|
}
|
|
529
555
|
} catch (error) {
|
|
530
556
|
handleApiError(error);
|
|
@@ -568,7 +594,8 @@ export const issuesRouter = router({
|
|
|
568
594
|
input.parent ||
|
|
569
595
|
input.blocks ||
|
|
570
596
|
input.blockedBy ||
|
|
571
|
-
input.relatesTo
|
|
597
|
+
input.relatesTo ||
|
|
598
|
+
input.pr;
|
|
572
599
|
|
|
573
600
|
if (hasUpdate) {
|
|
574
601
|
await handleUpdateIssue(input.idOrNew, input);
|