@bdsqqq/lnr-cli 1.3.1 → 1.5.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 +36 -4
package/package.json
CHANGED
package/src/router/issues.ts
CHANGED
|
@@ -21,6 +21,8 @@ import {
|
|
|
21
21
|
createReaction,
|
|
22
22
|
deleteReaction,
|
|
23
23
|
createIssueRelation,
|
|
24
|
+
getProject,
|
|
25
|
+
linkGitHubPR,
|
|
24
26
|
type Issue,
|
|
25
27
|
type ListIssuesFilter,
|
|
26
28
|
type Comment,
|
|
@@ -65,6 +67,7 @@ const issueInput = z.object({
|
|
|
65
67
|
team: z.string().optional().describe("team key (required for new)"),
|
|
66
68
|
title: z.string().optional().describe("issue title (required for new)"),
|
|
67
69
|
description: z.string().optional().describe("issue description"),
|
|
70
|
+
project: z.string().optional().describe("project name to add issue to"),
|
|
68
71
|
comments: z.boolean().optional().describe("list comments on issue"),
|
|
69
72
|
editComment: z.string().optional().describe("comment id to edit (requires --text)"),
|
|
70
73
|
text: z.string().optional().describe("text for --edit-comment or --reply-to"),
|
|
@@ -76,6 +79,7 @@ const issueInput = z.object({
|
|
|
76
79
|
unreact: z.string().optional().describe("reaction id to remove"),
|
|
77
80
|
parent: z.string().optional().describe("set parent issue identifier"),
|
|
78
81
|
subIssues: z.boolean().optional().describe("list sub-issues"),
|
|
82
|
+
pr: z.string().optional().describe("link a github pr url"),
|
|
79
83
|
});
|
|
80
84
|
|
|
81
85
|
type IssueInput = z.infer<typeof issueInput>;
|
|
@@ -426,6 +430,15 @@ async function handleUpdateIssue(
|
|
|
426
430
|
console.log(`removed reaction ${input.unreact.slice(0, 8)}`);
|
|
427
431
|
}
|
|
428
432
|
|
|
433
|
+
// Link PR
|
|
434
|
+
if (input.pr) {
|
|
435
|
+
const success = await linkGitHubPR(client, issue.id, input.pr);
|
|
436
|
+
if (!success) {
|
|
437
|
+
exitWithError(`failed to link pr`);
|
|
438
|
+
}
|
|
439
|
+
console.log(`linked ${input.pr} to ${identifier}`);
|
|
440
|
+
}
|
|
441
|
+
|
|
429
442
|
// Archive last (restricts further edits)
|
|
430
443
|
if (input.archive) {
|
|
431
444
|
await archiveIssue(client, issue.id);
|
|
@@ -462,6 +475,7 @@ async function handleCreateIssue(input: IssueInput): Promise<void> {
|
|
|
462
475
|
priority?: number;
|
|
463
476
|
labelIds?: string[];
|
|
464
477
|
parentId?: string;
|
|
478
|
+
projectId?: string;
|
|
465
479
|
} = {
|
|
466
480
|
teamId: team.id,
|
|
467
481
|
title: input.title,
|
|
@@ -509,11 +523,28 @@ async function handleCreateIssue(input: IssueInput): Promise<void> {
|
|
|
509
523
|
createPayload.parentId = parentIssue.id;
|
|
510
524
|
}
|
|
511
525
|
|
|
526
|
+
if (input.project) {
|
|
527
|
+
const project = await getProject(client, input.project);
|
|
528
|
+
if (!project) {
|
|
529
|
+
exitWithError(`project "${input.project}" not found`);
|
|
530
|
+
}
|
|
531
|
+
createPayload.projectId = project.id;
|
|
532
|
+
}
|
|
533
|
+
|
|
512
534
|
const issue = await createIssue(client, createPayload);
|
|
513
|
-
if (issue) {
|
|
514
|
-
console.log(`created ${issue.identifier}: ${issue.title}`);
|
|
515
|
-
} else {
|
|
535
|
+
if (!issue) {
|
|
516
536
|
console.log("created issue");
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
console.log(`created ${issue.identifier}: ${issue.title}`);
|
|
541
|
+
|
|
542
|
+
if (input.pr) {
|
|
543
|
+
const success = await linkGitHubPR(client, issue.id, input.pr);
|
|
544
|
+
if (!success) {
|
|
545
|
+
exitWithError(`failed to link pr`);
|
|
546
|
+
}
|
|
547
|
+
console.log(`linked ${input.pr} to ${issue.identifier}`);
|
|
517
548
|
}
|
|
518
549
|
} catch (error) {
|
|
519
550
|
handleApiError(error);
|
|
@@ -557,7 +588,8 @@ export const issuesRouter = router({
|
|
|
557
588
|
input.parent ||
|
|
558
589
|
input.blocks ||
|
|
559
590
|
input.blockedBy ||
|
|
560
|
-
input.relatesTo
|
|
591
|
+
input.relatesTo ||
|
|
592
|
+
input.pr;
|
|
561
593
|
|
|
562
594
|
if (hasUpdate) {
|
|
563
595
|
await handleUpdateIssue(input.idOrNew, input);
|