@blogic-cz/agent-tools 0.9.0 → 0.10.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/gh-tool/index.ts +2 -0
- package/src/gh-tool/pr/commands.ts +39 -0
- package/src/gh-tool/pr/core.ts +22 -0
- package/src/gh-tool/pr/index.ts +1 -0
package/package.json
CHANGED
package/src/gh-tool/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
prViewCommand,
|
|
21
21
|
prStatusCommand,
|
|
22
22
|
prCreateCommand,
|
|
23
|
+
prCloseCommand,
|
|
23
24
|
prEditCommand,
|
|
24
25
|
prMergeCommand,
|
|
25
26
|
prThreadsCommand,
|
|
@@ -66,6 +67,7 @@ const prCommand = Command.make("pr", {}).pipe(
|
|
|
66
67
|
prViewCommand,
|
|
67
68
|
prStatusCommand,
|
|
68
69
|
prCreateCommand,
|
|
70
|
+
prCloseCommand,
|
|
69
71
|
prEditCommand,
|
|
70
72
|
prMergeCommand,
|
|
71
73
|
prThreadsCommand,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from "#gh/config";
|
|
18
18
|
|
|
19
19
|
import {
|
|
20
|
+
closePR,
|
|
20
21
|
createPR,
|
|
21
22
|
detectPRStatus,
|
|
22
23
|
editPR,
|
|
@@ -147,6 +148,44 @@ export const prEditCommand = Command.make(
|
|
|
147
148
|
}),
|
|
148
149
|
).pipe(Command.withDescription("Edit an existing PR's title, body, or other metadata"));
|
|
149
150
|
|
|
151
|
+
export const prCloseCommand = Command.make(
|
|
152
|
+
"close",
|
|
153
|
+
{
|
|
154
|
+
comment: Flag.string("comment").pipe(
|
|
155
|
+
Flag.withDescription("Comment to add when closing"),
|
|
156
|
+
Flag.optional,
|
|
157
|
+
),
|
|
158
|
+
commentFile: Flag.string("comment-file").pipe(
|
|
159
|
+
Flag.withDescription("Read close comment from a file path or '-' for stdin"),
|
|
160
|
+
Flag.optional,
|
|
161
|
+
),
|
|
162
|
+
deleteBranch: Flag.boolean("delete-branch").pipe(
|
|
163
|
+
Flag.withDescription("Delete the branch after closing"),
|
|
164
|
+
Flag.withDefault(false),
|
|
165
|
+
),
|
|
166
|
+
format: formatOption,
|
|
167
|
+
pr: Flag.integer("pr").pipe(Flag.withDescription("PR number to close")),
|
|
168
|
+
},
|
|
169
|
+
({ comment, commentFile, deleteBranch, format, pr }) =>
|
|
170
|
+
Effect.gen(function* () {
|
|
171
|
+
const resolvedComment = yield* resolveOptionalTextInput(
|
|
172
|
+
"gh-tool pr close",
|
|
173
|
+
Option.getOrNull(comment),
|
|
174
|
+
Option.getOrNull(commentFile),
|
|
175
|
+
"--comment",
|
|
176
|
+
"--comment-file",
|
|
177
|
+
"comment",
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const result = yield* closePR({
|
|
181
|
+
comment: resolvedComment,
|
|
182
|
+
deleteBranch,
|
|
183
|
+
pr,
|
|
184
|
+
});
|
|
185
|
+
yield* logFormatted(result, format);
|
|
186
|
+
}),
|
|
187
|
+
).pipe(Command.withDescription("Close a PR with optional comment and branch deletion"));
|
|
188
|
+
|
|
150
189
|
export const prMergeCommand = Command.make(
|
|
151
190
|
"merge",
|
|
152
191
|
{
|
package/src/gh-tool/pr/core.ts
CHANGED
|
@@ -606,6 +606,28 @@ export const mergePR = Effect.fn("pr.mergePR")(function* (opts: {
|
|
|
606
606
|
return result;
|
|
607
607
|
});
|
|
608
608
|
|
|
609
|
+
export const closePR = Effect.fn("pr.closePR")(function* (opts: {
|
|
610
|
+
pr: number;
|
|
611
|
+
comment: string | null;
|
|
612
|
+
deleteBranch: boolean;
|
|
613
|
+
}) {
|
|
614
|
+
const gh = yield* GitHubService;
|
|
615
|
+
|
|
616
|
+
const args = ["pr", "close", String(opts.pr)];
|
|
617
|
+
|
|
618
|
+
if (opts.comment !== null) {
|
|
619
|
+
args.push("--comment", opts.comment);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
if (opts.deleteBranch) {
|
|
623
|
+
args.push("--delete-branch");
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
yield* gh.runGh(args);
|
|
627
|
+
|
|
628
|
+
return yield* viewPR(opts.pr);
|
|
629
|
+
});
|
|
630
|
+
|
|
609
631
|
export const editPR = Effect.fn("pr.editPR")(function* (opts: {
|
|
610
632
|
pr: number;
|
|
611
633
|
title: string | null;
|