@evanpurkhiser/tooling-personal 1.31.0 → 1.32.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/dist/cmd/pr.js +38 -11
- package/dist/index.js +11 -1
- package/dist/pulls.js +17 -1
- package/package.json +1 -1
package/dist/cmd/pr.js
CHANGED
|
@@ -143,30 +143,57 @@ async function pr(argv) {
|
|
|
143
143
|
console.log(chalk_1.default.red `Missing PR title, aborting`);
|
|
144
144
|
process.exit(1);
|
|
145
145
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
146
|
+
const createPrTask = async (ctx) => {
|
|
147
|
+
const pr = await pulls_1.createPull({
|
|
148
|
+
baseRefName: defaultBranch,
|
|
149
|
+
headRefName: branchName,
|
|
150
|
+
repositoryId: repoId,
|
|
151
|
+
draft: argv.draft,
|
|
152
|
+
title,
|
|
153
|
+
body,
|
|
154
|
+
});
|
|
155
|
+
ctx.pr = pr.createPullRequest.pullRequest;
|
|
156
|
+
};
|
|
157
|
+
const setAutoMergeTask = async (ctx, task) => {
|
|
158
|
+
const pullRequestId = ctx.pr.id;
|
|
159
|
+
try {
|
|
160
|
+
await pulls_1.enableAutoMerge({ pullRequestId, mergeMethod: 'SQUASH' });
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
task.skip('Auto Merge not available');
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const prTasks = new listr2_1.Listr([], { rendererOptions });
|
|
167
|
+
// 06-a. Create a Pull Request
|
|
168
|
+
prTasks.add({
|
|
169
|
+
title: 'Creating Pull Request',
|
|
170
|
+
task: createPrTask,
|
|
171
|
+
});
|
|
172
|
+
// 06-a. Enable auto merge
|
|
173
|
+
prTasks.add({
|
|
174
|
+
enabled: !!argv.autoMerge,
|
|
175
|
+
title: 'Enabling auto merge',
|
|
176
|
+
task: setAutoMergeTask,
|
|
154
177
|
});
|
|
178
|
+
const asyncPrTasks = prTasks.run();
|
|
179
|
+
// Do not let asyncPrTasks interfere with assignee selection
|
|
180
|
+
process.stdout.cork();
|
|
155
181
|
const reviewers = await assignees_1.selectAssignee(repo);
|
|
156
|
-
const {
|
|
182
|
+
const { pr } = await asyncPrTasks;
|
|
183
|
+
process.stdout.uncork();
|
|
157
184
|
// 07. Request reviews
|
|
158
185
|
const reviewRequestTask = new listr2_1.Listr([], { rendererOptions });
|
|
159
186
|
reviewRequestTask.add({
|
|
160
187
|
enabled: () => reviewers.length > 0,
|
|
161
188
|
title: 'Requesting Reviewers',
|
|
162
189
|
task: () => pulls_1.requestReview({
|
|
163
|
-
pullRequestId:
|
|
190
|
+
pullRequestId: pr.id,
|
|
164
191
|
userIds: reviewers.filter(a => a.type === assignees_1.AssigneeType.User).map(a => a.id),
|
|
165
192
|
teamIds: reviewers.filter(a => a.type === assignees_1.AssigneeType.Team).map(a => a.id),
|
|
166
193
|
}),
|
|
167
194
|
});
|
|
168
195
|
await reviewRequestTask.run();
|
|
169
196
|
// 08. Open in browser
|
|
170
|
-
open_1.default(
|
|
197
|
+
open_1.default(pr.url);
|
|
171
198
|
}
|
|
172
199
|
exports.pr = pr;
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,17 @@ yargs_1.default(process.argv.slice(2))
|
|
|
18
18
|
chalk_1.default.level = args.color ? 3 : 0;
|
|
19
19
|
}
|
|
20
20
|
}, true)
|
|
21
|
-
.command('pr', 'Create and update PRs', y => y
|
|
21
|
+
.command('pr', 'Create and update PRs', y => y
|
|
22
|
+
.option('draft', {
|
|
23
|
+
alias: 'd',
|
|
24
|
+
boolean: true,
|
|
25
|
+
desc: 'Create PR as a draft',
|
|
26
|
+
})
|
|
27
|
+
.option('autoMerge', {
|
|
28
|
+
alias: 'm',
|
|
29
|
+
boolean: true,
|
|
30
|
+
desc: 'Enable auto merge for the PR',
|
|
31
|
+
}), pr_1.pr)
|
|
22
32
|
.command('select-commit', 'Select a commit hash', select_commit_1.selectCommit)
|
|
23
33
|
.demandCommand(1, '')
|
|
24
34
|
.parse();
|
package/dist/pulls.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requestReview = exports.createPull = exports.getPulls = exports.getRepoInfo = void 0;
|
|
3
|
+
exports.requestReview = exports.enableAutoMerge = exports.createPull = exports.getPulls = exports.getRepoInfo = void 0;
|
|
4
4
|
const graphql_request_1 = require("graphql-request");
|
|
5
5
|
const graphql_1 = require("./graphql");
|
|
6
6
|
async function getRepoInfo(repo) {
|
|
@@ -83,6 +83,22 @@ function createPull(input) {
|
|
|
83
83
|
return graphql_1.request(prGql, { input });
|
|
84
84
|
}
|
|
85
85
|
exports.createPull = createPull;
|
|
86
|
+
/**
|
|
87
|
+
* Enables auto merge for a pull request
|
|
88
|
+
*/
|
|
89
|
+
function enableAutoMerge(input) {
|
|
90
|
+
const autoMergeGql = graphql_request_1.gql `
|
|
91
|
+
mutation enableAutoMerge($input: EnablePullRequestAutoMergeInput!) {
|
|
92
|
+
enablePullRequestAutoMerge(input: $input) {
|
|
93
|
+
pullRequest {
|
|
94
|
+
id
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
`;
|
|
99
|
+
return graphql_1.request(autoMergeGql, { input });
|
|
100
|
+
}
|
|
101
|
+
exports.enableAutoMerge = enableAutoMerge;
|
|
86
102
|
/**
|
|
87
103
|
* Assign reviewers to an existing pull request
|
|
88
104
|
*/
|
package/package.json
CHANGED