@evanpurkhiser/tooling-personal 1.34.0 → 1.37.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/assignees.js +10 -10
- package/dist/cmd/pr.js +20 -21
- package/dist/cmd/select-commit.js +5 -6
- package/dist/config.js +3 -3
- package/dist/editor.js +3 -4
- package/dist/fzf.js +2 -3
- package/dist/graphql.js +3 -3
- package/dist/index.js +1 -1
- package/dist/pulls.js +15 -16
- package/dist/utils.js +13 -14
- package/package.json +10 -9
package/dist/assignees.js
CHANGED
|
@@ -14,7 +14,7 @@ var AssigneeType;
|
|
|
14
14
|
(function (AssigneeType) {
|
|
15
15
|
AssigneeType[AssigneeType["User"] = 0] = "User";
|
|
16
16
|
AssigneeType[AssigneeType["Team"] = 1] = "Team";
|
|
17
|
-
})(AssigneeType
|
|
17
|
+
})(AssigneeType || (exports.AssigneeType = AssigneeType = {}));
|
|
18
18
|
function isUser(obj) {
|
|
19
19
|
return obj.repository !== undefined;
|
|
20
20
|
}
|
|
@@ -22,7 +22,7 @@ function isUser(obj) {
|
|
|
22
22
|
* Generates a list of assignable teams and users
|
|
23
23
|
*/
|
|
24
24
|
async function* getAssignees(repo) {
|
|
25
|
-
const assigneesGql = graphql_request_1.gql `
|
|
25
|
+
const assigneesGql = (0, graphql_request_1.gql) `
|
|
26
26
|
query userAssignees($owner: String!, $repo: String!, $cursor: String) {
|
|
27
27
|
repository(owner: $owner, name: $repo) {
|
|
28
28
|
assignableUsers(first: 100, after: $cursor) {
|
|
@@ -39,14 +39,14 @@ async function* getAssignees(repo) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
`;
|
|
42
|
-
const orgInfoGql = graphql_request_1.gql `
|
|
42
|
+
const orgInfoGql = (0, graphql_request_1.gql) `
|
|
43
43
|
query orgInfo($owner: String!) {
|
|
44
44
|
organization(login: $owner) {
|
|
45
45
|
name
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
`;
|
|
49
|
-
const teamGql = graphql_request_1.gql `
|
|
49
|
+
const teamGql = (0, graphql_request_1.gql) `
|
|
50
50
|
query teamAssignees($owner: String!, $cursor: String) {
|
|
51
51
|
organization(login: $owner) {
|
|
52
52
|
teams(first: 100, after: $cursor) {
|
|
@@ -65,18 +65,18 @@ async function* getAssignees(repo) {
|
|
|
65
65
|
`;
|
|
66
66
|
let isOrganization = true;
|
|
67
67
|
try {
|
|
68
|
-
await graphql_1.request(orgInfoGql, { owner: repo.owner });
|
|
68
|
+
await (0, graphql_1.request)(orgInfoGql, { owner: repo.owner });
|
|
69
69
|
}
|
|
70
70
|
catch {
|
|
71
71
|
isOrganization = false;
|
|
72
72
|
}
|
|
73
|
-
const userAssignees = graphql_1.paginatedRequest(assigneesGql, { ...repo }, (obj) => obj.repository.assignableUsers.pageInfo);
|
|
73
|
+
const userAssignees = (0, graphql_1.paginatedRequest)(assigneesGql, { ...repo }, (obj) => obj.repository.assignableUsers.pageInfo);
|
|
74
74
|
const teamAssignees = !isOrganization
|
|
75
75
|
? null
|
|
76
|
-
: graphql_1.paginatedRequest(teamGql, { owner: repo.owner }, (obj) => obj.organization.teams.pageInfo);
|
|
76
|
+
: (0, graphql_1.paginatedRequest)(teamGql, { owner: repo.owner }, (obj) => obj.organization.teams.pageInfo);
|
|
77
77
|
const items = !isOrganization
|
|
78
78
|
? userAssignees
|
|
79
|
-
: fast_merge_async_iterators_1.default(userAssignees, teamAssignees);
|
|
79
|
+
: (0, fast_merge_async_iterators_1.default)(userAssignees, teamAssignees);
|
|
80
80
|
const assigneeesToIgnore = config_1.config
|
|
81
81
|
.get('ignoreAssignees')
|
|
82
82
|
.map(value => new RegExp(value));
|
|
@@ -103,12 +103,12 @@ async function* getAssignees(repo) {
|
|
|
103
103
|
* Create a fzf prompt for selecting assignees for PRs / issues in this
|
|
104
104
|
* repository.
|
|
105
105
|
*/
|
|
106
|
-
const selectAssignee = (repo) => fzf_1.fzfSelect({
|
|
106
|
+
const selectAssignee = (repo) => (0, fzf_1.fzfSelect)({
|
|
107
107
|
prompt: 'Select Assignees:',
|
|
108
108
|
genValues: async (addOption) => {
|
|
109
109
|
for await (const assignee of getAssignees(repo)) {
|
|
110
110
|
const name = assignee.name === null ? chalk_1.default.gray('No name') : chalk_1.default.yellow(assignee.name);
|
|
111
|
-
const label = chalk_1.default `${assignee.slug} {white [}${name}{white ]}\n`;
|
|
111
|
+
const label = (0, chalk_1.default) `${assignee.slug} {white [}${name}{white ]}\n`;
|
|
112
112
|
addOption({ label, ...assignee });
|
|
113
113
|
}
|
|
114
114
|
},
|
package/dist/cmd/pr.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.pr =
|
|
6
|
+
exports.pr = pr;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const listr2_1 = require("listr2");
|
|
9
9
|
const open_1 = __importDefault(require("open"));
|
|
@@ -14,12 +14,12 @@ const fzf_1 = require("../fzf");
|
|
|
14
14
|
const pulls_1 = require("../pulls");
|
|
15
15
|
const utils_1 = require("../utils");
|
|
16
16
|
function getCommits(to) {
|
|
17
|
-
return simple_git_1.default().log({ from: 'HEAD', to });
|
|
17
|
+
return (0, simple_git_1.default)().log({ from: 'HEAD', to });
|
|
18
18
|
}
|
|
19
19
|
async function pr(argv) {
|
|
20
|
-
const username = await utils_1.getEmailUsername();
|
|
21
|
-
const repo = await utils_1.getRepoKey();
|
|
22
|
-
const { head, origin } = await utils_1.getBranchNames();
|
|
20
|
+
const username = await (0, utils_1.getEmailUsername)();
|
|
21
|
+
const repo = await (0, utils_1.getRepoKey)();
|
|
22
|
+
const { head, origin } = await (0, utils_1.getBranchNames)();
|
|
23
23
|
if (head === null) {
|
|
24
24
|
throw new Error('Cannot determine HEAD branch name');
|
|
25
25
|
}
|
|
@@ -34,7 +34,7 @@ async function pr(argv) {
|
|
|
34
34
|
collectInfoTask.add({
|
|
35
35
|
title: 'Fetching repository info',
|
|
36
36
|
task: async (ctx, task) => {
|
|
37
|
-
const details = await pulls_1.getRepoInfo(repo);
|
|
37
|
+
const details = await (0, pulls_1.getRepoInfo)(repo);
|
|
38
38
|
if (details === null) {
|
|
39
39
|
throw new Error('Failed to get repository ID');
|
|
40
40
|
}
|
|
@@ -57,19 +57,19 @@ async function pr(argv) {
|
|
|
57
57
|
collectInfoTask.add({
|
|
58
58
|
title: 'Fetching existing Pull Requests',
|
|
59
59
|
task: async (ctx, task) => {
|
|
60
|
-
ctx.prs = await pulls_1.getPulls(repo);
|
|
60
|
+
ctx.prs = await (0, pulls_1.getPulls)(repo);
|
|
61
61
|
task.title = `Found ${ctx.prs.length} existing PRs`;
|
|
62
62
|
},
|
|
63
63
|
});
|
|
64
64
|
const { repoId, defaultBranch, commits, prs } = await collectInfoTask.run();
|
|
65
|
-
const selectCommits = () => fzf_1.fzfSelect({
|
|
65
|
+
const selectCommits = () => (0, fzf_1.fzfSelect)({
|
|
66
66
|
prompt: 'Select commit(s) for PR:',
|
|
67
67
|
genValues: addOption => commits.all.forEach(commit => {
|
|
68
|
-
const branchName = utils_1.branchFromMessage(username, commit.message);
|
|
68
|
+
const branchName = (0, utils_1.branchFromMessage)(username, commit.message);
|
|
69
69
|
const pr = prs.find(pr => pr.headRefName === branchName);
|
|
70
70
|
const existingPrLabel = pr !== undefined ? chalk_1.default.yellowBright `(updates #${pr.number})` : '';
|
|
71
71
|
const shortHash = commit.hash.slice(0, 8);
|
|
72
|
-
const label = chalk_1.default `{red ${shortHash}} {blue [${commit.author_name}]} {white ${commit.message}} ${existingPrLabel}`;
|
|
72
|
+
const label = (0, chalk_1.default) `{red ${shortHash}} {blue [${commit.author_name}]} {white ${commit.message}} ${existingPrLabel}`;
|
|
73
73
|
addOption({ label, id: commit.hash, ...commit });
|
|
74
74
|
}),
|
|
75
75
|
});
|
|
@@ -91,11 +91,11 @@ async function pr(argv) {
|
|
|
91
91
|
.map(sha => `pick ${sha}`)
|
|
92
92
|
.join('\n');
|
|
93
93
|
const targetCommit = selectedCommits[selectedCommits.length - 1];
|
|
94
|
-
const branchName = utils_1.branchFromMessage(username, targetCommit.message);
|
|
94
|
+
const branchName = (0, utils_1.branchFromMessage)(username, targetCommit.message);
|
|
95
95
|
const willOpenPr = prs.some(pr => pr.headRefName === branchName);
|
|
96
96
|
// 03. Rebase and push the selected commits
|
|
97
97
|
const doRebase = async () => {
|
|
98
|
-
const rebase = simple_git_1.default()
|
|
98
|
+
const rebase = (0, simple_git_1.default)()
|
|
99
99
|
.env({ ...process.env, GIT_SEQUENCE_EDITOR: `echo "${rebaseContents}" >` })
|
|
100
100
|
.rebase(['--interactive', '--autostash', origin]);
|
|
101
101
|
try {
|
|
@@ -103,7 +103,7 @@ async function pr(argv) {
|
|
|
103
103
|
}
|
|
104
104
|
catch (error) {
|
|
105
105
|
// Abort a failed rebase
|
|
106
|
-
await simple_git_1.default().rebase(['--abort']);
|
|
106
|
+
await (0, simple_git_1.default)().rebase(['--abort']);
|
|
107
107
|
throw new Error(`Failed to rebase\n${error}`);
|
|
108
108
|
}
|
|
109
109
|
};
|
|
@@ -112,7 +112,7 @@ async function pr(argv) {
|
|
|
112
112
|
const commitIdx = newCommits.all.length - selectedCommits.length;
|
|
113
113
|
const rebaseTargetCommit = newCommits.all[commitIdx];
|
|
114
114
|
const refSpec = `${rebaseTargetCommit.hash}:refs/heads/${branchName}`;
|
|
115
|
-
await simple_git_1.default().push(['--force', 'origin', refSpec]);
|
|
115
|
+
await (0, simple_git_1.default)().push(['--force', 'origin', refSpec]);
|
|
116
116
|
};
|
|
117
117
|
const rebaseAndPushTask = new listr2_1.Listr([], { rendererOptions });
|
|
118
118
|
rebaseAndPushTask.add({ title: 'Rebasing commits', task: doRebase });
|
|
@@ -127,7 +127,7 @@ async function pr(argv) {
|
|
|
127
127
|
// close vim
|
|
128
128
|
process.stdout.cork();
|
|
129
129
|
// 05. Open an editor to write the pull request
|
|
130
|
-
const { editor, editorResult } = await editor_1.editPullRequest(targetCommit);
|
|
130
|
+
const { editor, editorResult } = await (0, editor_1.editPullRequest)(targetCommit);
|
|
131
131
|
const rebaseAndPush = rebaseAndPushTask.run();
|
|
132
132
|
rebaseAndPush.catch(() => editor.kill());
|
|
133
133
|
const { title, body } = await editorResult;
|
|
@@ -144,7 +144,7 @@ async function pr(argv) {
|
|
|
144
144
|
process.exit(1);
|
|
145
145
|
}
|
|
146
146
|
const createPrTask = async (ctx) => {
|
|
147
|
-
const pr = await pulls_1.createPull({
|
|
147
|
+
const pr = await (0, pulls_1.createPull)({
|
|
148
148
|
baseRefName: defaultBranch,
|
|
149
149
|
headRefName: branchName,
|
|
150
150
|
repositoryId: repoId,
|
|
@@ -157,7 +157,7 @@ async function pr(argv) {
|
|
|
157
157
|
const setAutoMergeTask = async (ctx, task) => {
|
|
158
158
|
const pullRequestId = ctx.pr.id;
|
|
159
159
|
try {
|
|
160
|
-
await pulls_1.enableAutoMerge({ pullRequestId, mergeMethod: 'SQUASH' });
|
|
160
|
+
await (0, pulls_1.enableAutoMerge)({ pullRequestId, mergeMethod: 'SQUASH' });
|
|
161
161
|
}
|
|
162
162
|
catch {
|
|
163
163
|
task.skip('Auto Merge not available');
|
|
@@ -178,7 +178,7 @@ async function pr(argv) {
|
|
|
178
178
|
const asyncPrTasks = prTasks.run();
|
|
179
179
|
// Do not let asyncPrTasks interfere with assignee selection
|
|
180
180
|
process.stdout.cork();
|
|
181
|
-
const reviewers = await assignees_1.selectAssignee(repo);
|
|
181
|
+
const reviewers = await (0, assignees_1.selectAssignee)(repo);
|
|
182
182
|
const { pr } = await asyncPrTasks;
|
|
183
183
|
process.stdout.uncork();
|
|
184
184
|
// 07. Request reviews
|
|
@@ -186,7 +186,7 @@ async function pr(argv) {
|
|
|
186
186
|
reviewRequestTask.add({
|
|
187
187
|
enabled: () => reviewers.length > 0,
|
|
188
188
|
title: 'Requesting Reviewers',
|
|
189
|
-
task: () => pulls_1.requestReview({
|
|
189
|
+
task: () => (0, pulls_1.requestReview)({
|
|
190
190
|
pullRequestId: pr.id,
|
|
191
191
|
userIds: reviewers.filter(a => a.type === assignees_1.AssigneeType.User).map(a => a.id),
|
|
192
192
|
teamIds: reviewers.filter(a => a.type === assignees_1.AssigneeType.Team).map(a => a.id),
|
|
@@ -194,6 +194,5 @@ async function pr(argv) {
|
|
|
194
194
|
});
|
|
195
195
|
await reviewRequestTask.run();
|
|
196
196
|
// 08. Open in browser
|
|
197
|
-
open_1.default(pr.url);
|
|
197
|
+
(0, open_1.default)(pr.url);
|
|
198
198
|
}
|
|
199
|
-
exports.pr = pr;
|
|
@@ -3,23 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.selectCommit =
|
|
6
|
+
exports.selectCommit = selectCommit;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const simple_git_1 = __importDefault(require("simple-git"));
|
|
9
9
|
const fzf_1 = require("../fzf");
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
async function selectCommit() {
|
|
12
|
-
const { origin } = await utils_1.getBranchNames();
|
|
13
|
-
const commits = await simple_git_1.default().log({ from: 'HEAD', to: origin });
|
|
14
|
-
const selected = await fzf_1.fzfSelect({
|
|
12
|
+
const { origin } = await (0, utils_1.getBranchNames)();
|
|
13
|
+
const commits = await (0, simple_git_1.default)().log({ from: 'HEAD', to: origin });
|
|
14
|
+
const selected = await (0, fzf_1.fzfSelect)({
|
|
15
15
|
prompt: 'Select commit(s):',
|
|
16
16
|
genValues: addOption => commits.all.forEach(commit => {
|
|
17
17
|
const shortHash = commit.hash.slice(0, 8);
|
|
18
|
-
const label = chalk_1.default `{red ${shortHash}} {blue [${commit.author_name}]} {white ${commit.message}}`;
|
|
18
|
+
const label = (0, chalk_1.default) `{red ${shortHash}} {blue [${commit.author_name}]} {white ${commit.message}}`;
|
|
19
19
|
addOption({ label, id: commit.hash, ...commit });
|
|
20
20
|
}),
|
|
21
21
|
});
|
|
22
22
|
const commitHashes = selected.map(commit => commit.hash);
|
|
23
23
|
console.log(commitHashes.join('\n'));
|
|
24
24
|
}
|
|
25
|
-
exports.selectCommit = selectCommit;
|
package/dist/config.js
CHANGED
|
@@ -8,7 +8,7 @@ const convict_1 = __importDefault(require("convict"));
|
|
|
8
8
|
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
9
9
|
const path_1 = require("path");
|
|
10
10
|
convict_1.default.addParser({ extension: ['yml', 'yaml'], parse: js_yaml_1.default.load });
|
|
11
|
-
const config = convict_1.default({
|
|
11
|
+
const config = (0, convict_1.default)({
|
|
12
12
|
ignoreAssignees: {
|
|
13
13
|
doc: 'Assignee names / teams to ignore. Should be a regex expression.',
|
|
14
14
|
format: Array,
|
|
@@ -17,6 +17,6 @@ const config = convict_1.default({
|
|
|
17
17
|
});
|
|
18
18
|
exports.config = config;
|
|
19
19
|
const home = process.env.HOME;
|
|
20
|
-
const configDir = process.env.XDG_CONFIG_HOME || path_1.join(home, '.config');
|
|
21
|
-
config.loadFile(path_1.join(configDir, 'pt', 'config.yml'));
|
|
20
|
+
const configDir = process.env.XDG_CONFIG_HOME || (0, path_1.join)(home, '.config');
|
|
21
|
+
config.loadFile((0, path_1.join)(configDir, 'pt', 'config.yml'));
|
|
22
22
|
config.validate();
|
package/dist/editor.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.editPullRequest =
|
|
6
|
+
exports.editPullRequest = editPullRequest;
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
8
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -12,9 +12,9 @@ async function editPullRequest(commit) {
|
|
|
12
12
|
const messageBody = commit.body;
|
|
13
13
|
const split = messageBody.length > 0 ? '\n\n' : '';
|
|
14
14
|
const prTemplate = `${commit.message}${split}${messageBody}`;
|
|
15
|
-
const pullEditFile = path_1.default.join(await utils_1.getRepoPath(), '.git', 'PULLREQ_EDITMSG');
|
|
15
|
+
const pullEditFile = path_1.default.join(await (0, utils_1.getRepoPath)(), '.git', 'PULLREQ_EDITMSG');
|
|
16
16
|
await promises_1.default.writeFile(pullEditFile, prTemplate);
|
|
17
|
-
const editor = child_process_1.spawn(process.env.EDITOR ?? 'vim', [pullEditFile], {
|
|
17
|
+
const editor = (0, child_process_1.spawn)(process.env.EDITOR ?? 'vim', [pullEditFile], {
|
|
18
18
|
shell: true,
|
|
19
19
|
stdio: 'inherit',
|
|
20
20
|
});
|
|
@@ -27,4 +27,3 @@ async function editPullRequest(commit) {
|
|
|
27
27
|
}
|
|
28
28
|
return { editor, editorResult: getResult() };
|
|
29
29
|
}
|
|
30
|
-
exports.editPullRequest = editPullRequest;
|
package/dist/fzf.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fzfSelect =
|
|
3
|
+
exports.fzfSelect = fzfSelect;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
async function fzfSelect({ prompt, genValues, }) {
|
|
6
|
-
const fzf = child_process_1.spawn('fzf', [
|
|
6
|
+
const fzf = (0, child_process_1.spawn)('fzf', [
|
|
7
7
|
'--ansi',
|
|
8
8
|
'--height=40%',
|
|
9
9
|
'--reverse',
|
|
@@ -33,4 +33,3 @@ async function fzfSelect({ prompt, genValues, }) {
|
|
|
33
33
|
.map(line => line.split('\t')[0])
|
|
34
34
|
.map(id => options[id]);
|
|
35
35
|
}
|
|
36
|
-
exports.fzfSelect = fzfSelect;
|
package/dist/graphql.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.request = exports.
|
|
3
|
+
exports.request = exports.githubClient = void 0;
|
|
4
|
+
exports.paginatedRequest = paginatedRequest;
|
|
4
5
|
const graphql_request_1 = require("graphql-request");
|
|
5
6
|
const utils_1 = require("./utils");
|
|
6
|
-
const authorization = `Bearer ${utils_1.getAccessToken()}`;
|
|
7
|
+
const authorization = `Bearer ${(0, utils_1.getAccessToken)()}`;
|
|
7
8
|
exports.githubClient = new graphql_request_1.GraphQLClient('https://api.github.com/graphql', {
|
|
8
9
|
headers: { authorization },
|
|
9
10
|
});
|
|
@@ -21,5 +22,4 @@ async function* paginatedRequest(query, variables, pickCursor) {
|
|
|
21
22
|
yield result;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
exports.paginatedRequest = paginatedRequest;
|
|
25
25
|
exports.request = exports.githubClient.request.bind(exports.githubClient);
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
8
8
|
const yargs_1 = __importDefault(require("yargs"));
|
|
9
9
|
const pr_1 = require("./cmd/pr");
|
|
10
10
|
const select_commit_1 = require("./cmd/select-commit");
|
|
11
|
-
yargs_1.default(process.argv.slice(2))
|
|
11
|
+
(0, yargs_1.default)(process.argv.slice(2))
|
|
12
12
|
.option('color', {
|
|
13
13
|
boolean: true,
|
|
14
14
|
desc: 'Use colored output (default: auto-detect)',
|
package/dist/pulls.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getRepoInfo = getRepoInfo;
|
|
4
|
+
exports.getPulls = getPulls;
|
|
5
|
+
exports.createPull = createPull;
|
|
6
|
+
exports.enableAutoMerge = enableAutoMerge;
|
|
7
|
+
exports.requestReview = requestReview;
|
|
4
8
|
const graphql_request_1 = require("graphql-request");
|
|
5
9
|
const graphql_1 = require("./graphql");
|
|
6
10
|
async function getRepoInfo(repo) {
|
|
7
|
-
const repoGql = graphql_request_1.gql `
|
|
11
|
+
const repoGql = (0, graphql_request_1.gql) `
|
|
8
12
|
query repo($owner: String!, $repo: String!) {
|
|
9
13
|
repository(owner: $owner, name: $repo) {
|
|
10
14
|
id
|
|
@@ -16,7 +20,7 @@ async function getRepoInfo(repo) {
|
|
|
16
20
|
`;
|
|
17
21
|
let resp = null;
|
|
18
22
|
try {
|
|
19
|
-
resp = await graphql_1.request(repoGql, { ...repo });
|
|
23
|
+
resp = await (0, graphql_1.request)(repoGql, { ...repo });
|
|
20
24
|
}
|
|
21
25
|
catch {
|
|
22
26
|
return null;
|
|
@@ -26,12 +30,11 @@ async function getRepoInfo(repo) {
|
|
|
26
30
|
defaultBranch: resp.repository.defaultBranchRef.name,
|
|
27
31
|
};
|
|
28
32
|
}
|
|
29
|
-
exports.getRepoInfo = getRepoInfo;
|
|
30
33
|
/**
|
|
31
34
|
* Get your open pull requests for this repo
|
|
32
35
|
*/
|
|
33
36
|
async function getPulls(repo) {
|
|
34
|
-
const user = await graphql_1.request(graphql_request_1.gql `
|
|
37
|
+
const user = await (0, graphql_1.request)((0, graphql_request_1.gql) `
|
|
35
38
|
query {
|
|
36
39
|
viewer {
|
|
37
40
|
login
|
|
@@ -39,7 +42,7 @@ async function getPulls(repo) {
|
|
|
39
42
|
}
|
|
40
43
|
`);
|
|
41
44
|
const author = user.viewer.login;
|
|
42
|
-
const pullResults = graphql_1.paginatedRequest(graphql_request_1.gql `
|
|
45
|
+
const pullResults = (0, graphql_1.paginatedRequest)((0, graphql_request_1.gql) `
|
|
43
46
|
query myPullRequests($query: String!, $cursor: String) {
|
|
44
47
|
search(query: $query, first: 100, type: ISSUE, after: $cursor) {
|
|
45
48
|
edges {
|
|
@@ -65,12 +68,11 @@ async function getPulls(repo) {
|
|
|
65
68
|
}
|
|
66
69
|
return prs;
|
|
67
70
|
}
|
|
68
|
-
exports.getPulls = getPulls;
|
|
69
71
|
/**
|
|
70
72
|
* Creates a pull request
|
|
71
73
|
*/
|
|
72
74
|
function createPull(input) {
|
|
73
|
-
const prGql = graphql_request_1.gql `
|
|
75
|
+
const prGql = (0, graphql_request_1.gql) `
|
|
74
76
|
mutation createPull($input: CreatePullRequestInput!) {
|
|
75
77
|
createPullRequest(input: $input) {
|
|
76
78
|
pullRequest {
|
|
@@ -80,14 +82,13 @@ function createPull(input) {
|
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
`;
|
|
83
|
-
return graphql_1.request(prGql, { input });
|
|
85
|
+
return (0, graphql_1.request)(prGql, { input });
|
|
84
86
|
}
|
|
85
|
-
exports.createPull = createPull;
|
|
86
87
|
/**
|
|
87
88
|
* Enables auto merge for a pull request
|
|
88
89
|
*/
|
|
89
90
|
function enableAutoMerge(input) {
|
|
90
|
-
const autoMergeGql = graphql_request_1.gql `
|
|
91
|
+
const autoMergeGql = (0, graphql_request_1.gql) `
|
|
91
92
|
mutation enableAutoMerge($input: EnablePullRequestAutoMergeInput!) {
|
|
92
93
|
enablePullRequestAutoMerge(input: $input) {
|
|
93
94
|
pullRequest {
|
|
@@ -96,20 +97,18 @@ function enableAutoMerge(input) {
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
`;
|
|
99
|
-
return graphql_1.request(autoMergeGql, { input });
|
|
100
|
+
return (0, graphql_1.request)(autoMergeGql, { input });
|
|
100
101
|
}
|
|
101
|
-
exports.enableAutoMerge = enableAutoMerge;
|
|
102
102
|
/**
|
|
103
103
|
* Assign reviewers to an existing pull request
|
|
104
104
|
*/
|
|
105
105
|
function requestReview(input) {
|
|
106
|
-
const reviewerGql = graphql_request_1.gql `
|
|
106
|
+
const reviewerGql = (0, graphql_request_1.gql) `
|
|
107
107
|
mutation requestReview($input: RequestReviewsInput!) {
|
|
108
108
|
requestReviews(input: $input) {
|
|
109
109
|
clientMutationId
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
`;
|
|
113
|
-
return graphql_1.request(reviewerGql, { input });
|
|
113
|
+
return (0, graphql_1.request)(reviewerGql, { input });
|
|
114
114
|
}
|
|
115
|
-
exports.requestReview = requestReview;
|
package/dist/utils.js
CHANGED
|
@@ -3,7 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getRepoKey = getRepoKey;
|
|
7
|
+
exports.getEmailUsername = getEmailUsername;
|
|
8
|
+
exports.getRepoPath = getRepoPath;
|
|
9
|
+
exports.getBranchNames = getBranchNames;
|
|
10
|
+
exports.getAccessToken = getAccessToken;
|
|
11
|
+
exports.branchFromMessage = branchFromMessage;
|
|
7
12
|
const git_url_parse_1 = __importDefault(require("git-url-parse"));
|
|
8
13
|
const simple_git_1 = __importDefault(require("simple-git"));
|
|
9
14
|
const child_process_1 = require("child_process");
|
|
@@ -11,8 +16,8 @@ const child_process_1 = require("child_process");
|
|
|
11
16
|
* Get's the current repo information
|
|
12
17
|
*/
|
|
13
18
|
async function getRepoKey() {
|
|
14
|
-
const url = await simple_git_1.default().listRemote(['--get-url', 'origin']);
|
|
15
|
-
const repo = git_url_parse_1.default(url);
|
|
19
|
+
const url = await (0, simple_git_1.default)().listRemote(['--get-url', 'origin']);
|
|
20
|
+
const repo = (0, git_url_parse_1.default)(url);
|
|
16
21
|
const repoKey = {
|
|
17
22
|
owner: repo.owner,
|
|
18
23
|
repo: repo.name,
|
|
@@ -20,23 +25,20 @@ async function getRepoKey() {
|
|
|
20
25
|
};
|
|
21
26
|
return repoKey;
|
|
22
27
|
}
|
|
23
|
-
exports.getRepoKey = getRepoKey;
|
|
24
28
|
/**
|
|
25
29
|
* Get the git username from email
|
|
26
30
|
*/
|
|
27
31
|
async function getEmailUsername() {
|
|
28
|
-
const email = await simple_git_1.default().raw('config', '--get', 'user.email');
|
|
32
|
+
const email = await (0, simple_git_1.default)().raw('config', '--get', 'user.email');
|
|
29
33
|
return email.split('@')[0].toLowerCase();
|
|
30
34
|
}
|
|
31
|
-
exports.getEmailUsername = getEmailUsername;
|
|
32
35
|
/**
|
|
33
36
|
* Get's the absolute path to the current git repo
|
|
34
37
|
*/
|
|
35
38
|
async function getRepoPath() {
|
|
36
|
-
const path = await simple_git_1.default().revparse(['--show-toplevel']);
|
|
39
|
+
const path = await (0, simple_git_1.default)().revparse(['--show-toplevel']);
|
|
37
40
|
return path.trim();
|
|
38
41
|
}
|
|
39
|
-
exports.getRepoPath = getRepoPath;
|
|
40
42
|
/**
|
|
41
43
|
* Get's the "default" head and origin branch names
|
|
42
44
|
*/
|
|
@@ -44,32 +46,30 @@ async function getBranchNames() {
|
|
|
44
46
|
let head = null;
|
|
45
47
|
let origin = null;
|
|
46
48
|
try {
|
|
47
|
-
head = await simple_git_1.default().revparse(['--abbrev-ref', 'HEAD']);
|
|
49
|
+
head = await (0, simple_git_1.default)().revparse(['--abbrev-ref', 'HEAD']);
|
|
48
50
|
}
|
|
49
51
|
catch {
|
|
50
52
|
// null
|
|
51
53
|
}
|
|
52
54
|
try {
|
|
53
|
-
origin = await simple_git_1.default().revparse(['--abbrev-ref', '@{upstream}']);
|
|
55
|
+
origin = await (0, simple_git_1.default)().revparse(['--abbrev-ref', '@{upstream}']);
|
|
54
56
|
}
|
|
55
57
|
catch {
|
|
56
58
|
// null
|
|
57
59
|
}
|
|
58
60
|
return { head, origin };
|
|
59
61
|
}
|
|
60
|
-
exports.getBranchNames = getBranchNames;
|
|
61
62
|
/**
|
|
62
63
|
* Get's the GitHub Oauth token from the gh auth token command
|
|
63
64
|
*/
|
|
64
65
|
function getAccessToken() {
|
|
65
66
|
try {
|
|
66
|
-
return child_process_1.execSync('gh auth token').toString().trim();
|
|
67
|
+
return (0, child_process_1.execSync)('gh auth token').toString().trim();
|
|
67
68
|
}
|
|
68
69
|
catch {
|
|
69
70
|
throw new Error('Cannot get token from `gh auth token`');
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
|
-
exports.getAccessToken = getAccessToken;
|
|
73
73
|
/**
|
|
74
74
|
* Generates a consistent branch name from a commit message
|
|
75
75
|
*/
|
|
@@ -81,4 +81,3 @@ function branchFromMessage(prefix, commitMessage) {
|
|
|
81
81
|
.slice(0, 255);
|
|
82
82
|
return `${prefix}/${branch}`;
|
|
83
83
|
}
|
|
84
|
-
exports.branchFromMessage = branchFromMessage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
2
3
|
"name": "@evanpurkhiser/tooling-personal",
|
|
3
|
-
"version": "1.
|
|
4
|
+
"version": "1.37.0",
|
|
4
5
|
"description": "Evan Purkhiser's personal tooling",
|
|
5
6
|
"repository": "https://github.com/evanpurkhiser/tooling-personal",
|
|
6
7
|
"author": "Evan Purkhiser",
|
|
@@ -29,12 +30,12 @@
|
|
|
29
30
|
"yargs": "^17.0.1"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@evanpurkhiser/eslint-config": "^0.
|
|
33
|
+
"@evanpurkhiser/eslint-config": "^0.27.0",
|
|
33
34
|
"@tsconfig/node16": "^1.0.1",
|
|
34
|
-
"eslint": "^9.
|
|
35
|
-
"prettier": "^3.
|
|
36
|
-
"ts-node": "^10.
|
|
37
|
-
"typescript": "^
|
|
35
|
+
"eslint": "^9.30.1",
|
|
36
|
+
"prettier": "^3.6.2",
|
|
37
|
+
"ts-node": "^10.9.2",
|
|
38
|
+
"typescript": "^5.8.3"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
41
|
"build": "tsc && chmod +x ./dist/index.js",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"pt": "./dist/index.js"
|
|
45
46
|
},
|
|
46
47
|
"volta": {
|
|
47
|
-
"node": "
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
"node": "24.3.0"
|
|
49
|
+
},
|
|
50
|
+
"packageManager": "pnpm@10.12.4"
|
|
50
51
|
}
|