@staff0rd/assist 0.732.1 → 0.734.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/README.md +4 -2
- package/dist/commands/sessions/web/bundle.js +401 -401
- package/dist/index.js +453 -214
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.734.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -860,7 +860,14 @@ var assistConfigShape = {
|
|
|
860
860
|
}).optional(),
|
|
861
861
|
next: z3.strictObject({
|
|
862
862
|
peers: z3.array(z3.string()).optional(),
|
|
863
|
-
repos: z3.array(z3.string()).optional()
|
|
863
|
+
repos: z3.array(z3.string()).optional(),
|
|
864
|
+
projects: z3.array(
|
|
865
|
+
z3.string().regex(
|
|
866
|
+
/^[^/\s]+\/\d+$/,
|
|
867
|
+
"Use <owner>/<project number>, e.g. my-org/3"
|
|
868
|
+
)
|
|
869
|
+
).optional(),
|
|
870
|
+
pickStatuses: z3.array(z3.string()).optional()
|
|
864
871
|
}).optional(),
|
|
865
872
|
deny: z3.array(
|
|
866
873
|
z3.strictObject({
|
|
@@ -12576,6 +12583,16 @@ var nextConfigHelp = [
|
|
|
12576
12583
|
key: "next.repos",
|
|
12577
12584
|
setter: "assist config set next.repos my-org,other/web -g --repo",
|
|
12578
12585
|
note: "GitHub repos the web /next view reads peer PRs and issues assigned to you from: owner/name for one repo, or a bare owner (org or user) for all its unarchived repos (default: the selected repo)"
|
|
12586
|
+
},
|
|
12587
|
+
{
|
|
12588
|
+
key: "next.projects",
|
|
12589
|
+
setter: "assist config set next.projects my-org/3,my-org/5 -g --repo",
|
|
12590
|
+
note: "GitHub Projects (owner/number, from each URL) the web /next view suggests unassigned issues to pick up from; needs the gh project scope"
|
|
12591
|
+
},
|
|
12592
|
+
{
|
|
12593
|
+
key: "next.pickStatuses",
|
|
12594
|
+
setter: "assist config set next.pickStatuses Ready,Todo -g --repo",
|
|
12595
|
+
note: "Project Status values whose unassigned items the web /next view offers to pick up (default: Ready, Todo)"
|
|
12579
12596
|
}
|
|
12580
12597
|
];
|
|
12581
12598
|
|
|
@@ -13931,33 +13948,107 @@ async function fetchPeerPrs(cwd, repo, peers) {
|
|
|
13931
13948
|
return selectPeerPrs(nodes, viewer, peers).map((pr) => ({ ...pr, repo }));
|
|
13932
13949
|
}
|
|
13933
13950
|
|
|
13934
|
-
// src/commands/sessions/web/next/
|
|
13935
|
-
|
|
13936
|
-
|
|
13937
|
-
const { origin } = resolveCurrentOrigin(cwd);
|
|
13938
|
-
return origin.startsWith(GITHUB) ? origin.slice(GITHUB.length) : null;
|
|
13939
|
-
}
|
|
13940
|
-
function nextScope(cwd) {
|
|
13941
|
-
const next3 = loadConfigFrom(cwd).next;
|
|
13942
|
-
return {
|
|
13943
|
-
selfRepo: githubRepo(cwd),
|
|
13944
|
-
peers: next3?.peers ?? [],
|
|
13945
|
-
repos: next3?.repos ?? null
|
|
13946
|
-
};
|
|
13947
|
-
}
|
|
13948
|
-
|
|
13949
|
-
// src/commands/sessions/web/next/scopeRepos.ts
|
|
13950
|
-
function scopeRepos(configured, selfRepo) {
|
|
13951
|
-
if (configured) return configured;
|
|
13952
|
-
return selfRepo ? [selfRepo] : [];
|
|
13951
|
+
// src/commands/sessions/web/next/comparePickups.ts
|
|
13952
|
+
function comparePickups(a, b) {
|
|
13953
|
+
return a.priorityRank - b.priorityRank || a.createdAt.localeCompare(b.createdAt);
|
|
13953
13954
|
}
|
|
13954
13955
|
|
|
13955
|
-
// src/commands/sessions/web/next/
|
|
13956
|
-
function
|
|
13956
|
+
// src/commands/sessions/web/next/ghErrorText.ts
|
|
13957
|
+
function ghErrorText(error) {
|
|
13957
13958
|
const stderr = error.stderr;
|
|
13958
13959
|
if (typeof stderr === "string" && stderr.trim()) return stderr.trim();
|
|
13959
13960
|
return error instanceof Error ? error.message : String(error);
|
|
13960
13961
|
}
|
|
13962
|
+
|
|
13963
|
+
// src/commands/sessions/web/next/projectErrorText.ts
|
|
13964
|
+
function projectErrorText(error) {
|
|
13965
|
+
const text18 = ghErrorText(error);
|
|
13966
|
+
if (/read:project|required scopes/i.test(text18))
|
|
13967
|
+
return "The gh token has no project scope, so the project cannot be read. Run: gh auth refresh -h github.com -s project";
|
|
13968
|
+
return text18;
|
|
13969
|
+
}
|
|
13970
|
+
|
|
13971
|
+
// src/commands/sessions/web/next/pickupsQuery.ts
|
|
13972
|
+
var pickupsQuery = `query($owner: String!, $number: Int!, $after: String) {
|
|
13973
|
+
repositoryOwner(login: $owner) {
|
|
13974
|
+
... on ProjectV2Owner {
|
|
13975
|
+
projectV2(number: $number) {
|
|
13976
|
+
title
|
|
13977
|
+
priorityField: field(name: "Priority") {
|
|
13978
|
+
... on ProjectV2SingleSelectField { options { name } }
|
|
13979
|
+
}
|
|
13980
|
+
items(first: 100, after: $after) {
|
|
13981
|
+
pageInfo { hasNextPage endCursor }
|
|
13982
|
+
nodes {
|
|
13983
|
+
id
|
|
13984
|
+
status: fieldValueByName(name: "Status") {
|
|
13985
|
+
... on ProjectV2ItemFieldSingleSelectValue { name }
|
|
13986
|
+
}
|
|
13987
|
+
priority: fieldValueByName(name: "Priority") {
|
|
13988
|
+
... on ProjectV2ItemFieldSingleSelectValue { name }
|
|
13989
|
+
}
|
|
13990
|
+
content {
|
|
13991
|
+
... on Issue {
|
|
13992
|
+
number
|
|
13993
|
+
title
|
|
13994
|
+
url
|
|
13995
|
+
createdAt
|
|
13996
|
+
state
|
|
13997
|
+
author { login }
|
|
13998
|
+
repository { nameWithOwner }
|
|
13999
|
+
assignees(first: 1) { totalCount }
|
|
14000
|
+
labels(first: 20) { nodes { name } }
|
|
14001
|
+
}
|
|
14002
|
+
}
|
|
14003
|
+
}
|
|
14004
|
+
}
|
|
14005
|
+
}
|
|
14006
|
+
}
|
|
14007
|
+
}
|
|
14008
|
+
}`;
|
|
14009
|
+
|
|
14010
|
+
// src/commands/sessions/web/next/readProjectPage.ts
|
|
14011
|
+
function readProjectPage(cwd, owner, number, after) {
|
|
14012
|
+
return ghJson(cwd, [
|
|
14013
|
+
"api",
|
|
14014
|
+
"graphql",
|
|
14015
|
+
"-f",
|
|
14016
|
+
`query=${pickupsQuery}`,
|
|
14017
|
+
"-F",
|
|
14018
|
+
`owner=${owner}`,
|
|
14019
|
+
"-F",
|
|
14020
|
+
`number=${number}`,
|
|
14021
|
+
...after ? ["-f", `after=${after}`] : []
|
|
14022
|
+
]);
|
|
14023
|
+
}
|
|
14024
|
+
|
|
14025
|
+
// src/commands/sessions/web/next/readProjectItems.ts
|
|
14026
|
+
var MAX_PAGES = 10;
|
|
14027
|
+
async function readProjectItems(cwd, project) {
|
|
14028
|
+
const [owner, number] = project.split("/");
|
|
14029
|
+
const nodes = [];
|
|
14030
|
+
const board = { project, title: project, priorityOrder: [] };
|
|
14031
|
+
let after = null;
|
|
14032
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
14033
|
+
const response = await readProjectPage(cwd, owner, number, after);
|
|
14034
|
+
const projectV2 = response.data?.repositoryOwner?.projectV2;
|
|
14035
|
+
if (!projectV2?.items) {
|
|
14036
|
+
const reason4 = response.errors?.[0]?.message;
|
|
14037
|
+
throw new Error(reason4 ?? `No project ${number} owned by ${owner}`);
|
|
14038
|
+
}
|
|
14039
|
+
board.title = projectV2.title ?? project;
|
|
14040
|
+
board.priorityOrder = (projectV2.priorityField?.options ?? []).map(
|
|
14041
|
+
(option) => option.name
|
|
14042
|
+
);
|
|
14043
|
+
for (const node of projectV2.items.nodes ?? []) if (node) nodes.push(node);
|
|
14044
|
+
const { hasNextPage: hasNextPage2, endCursor } = projectV2.items.pageInfo ?? {};
|
|
14045
|
+
if (!hasNextPage2 || !endCursor) break;
|
|
14046
|
+
after = endCursor;
|
|
14047
|
+
}
|
|
14048
|
+
return { nodes, board };
|
|
14049
|
+
}
|
|
14050
|
+
|
|
14051
|
+
// src/commands/sessions/web/next/sectionAcross.ts
|
|
13961
14052
|
async function sectionAcross(repos2, load3, compare) {
|
|
13962
14053
|
if (repos2.length === 0)
|
|
13963
14054
|
return {
|
|
@@ -13970,7 +14061,7 @@ async function sectionAcross(repos2, load3, compare) {
|
|
|
13970
14061
|
results.forEach((result, index3) => {
|
|
13971
14062
|
if (result.status === "fulfilled")
|
|
13972
14063
|
for (const item of result.value) items2.set(item.url, item);
|
|
13973
|
-
else errors.push(`${repos2[index3]}: ${
|
|
14064
|
+
else errors.push(`${repos2[index3]}: ${ghErrorText(result.reason)}`);
|
|
13974
14065
|
});
|
|
13975
14066
|
return {
|
|
13976
14067
|
items: [...items2.values()].sort(compare),
|
|
@@ -13978,13 +14069,91 @@ async function sectionAcross(repos2, load3, compare) {
|
|
|
13978
14069
|
};
|
|
13979
14070
|
}
|
|
13980
14071
|
|
|
14072
|
+
// src/commands/sessions/web/next/selectPickups.ts
|
|
14073
|
+
function priorityRank(priority, order) {
|
|
14074
|
+
const index3 = priority ? order.indexOf(priority) : -1;
|
|
14075
|
+
return index3 === -1 ? order.length : index3;
|
|
14076
|
+
}
|
|
14077
|
+
function toPickup(node, board) {
|
|
14078
|
+
const issue = node.content;
|
|
14079
|
+
const repo = issue?.repository?.nameWithOwner;
|
|
14080
|
+
const status3 = node.status?.name;
|
|
14081
|
+
if (!issue?.number || !issue.url || !repo || !status3) return null;
|
|
14082
|
+
const priority = node.priority?.name ?? null;
|
|
14083
|
+
return {
|
|
14084
|
+
repo,
|
|
14085
|
+
number: issue.number,
|
|
14086
|
+
title: issue.title ?? "",
|
|
14087
|
+
url: issue.url,
|
|
14088
|
+
createdAt: issue.createdAt ?? "",
|
|
14089
|
+
author: issue.author?.login ?? "unknown",
|
|
14090
|
+
labels: (issue.labels?.nodes ?? []).flatMap(
|
|
14091
|
+
(label2) => label2?.name ? [label2.name] : []
|
|
14092
|
+
),
|
|
14093
|
+
project: board.project,
|
|
14094
|
+
projectTitle: board.title,
|
|
14095
|
+
itemId: node.id,
|
|
14096
|
+
status: status3,
|
|
14097
|
+
priority,
|
|
14098
|
+
priorityRank: priorityRank(priority, board.priorityOrder)
|
|
14099
|
+
};
|
|
14100
|
+
}
|
|
14101
|
+
function selectPickups(nodes, pickStatuses, board) {
|
|
14102
|
+
const statuses = new Set(pickStatuses.map((status3) => status3.toLowerCase()));
|
|
14103
|
+
return nodes.filter(
|
|
14104
|
+
(node) => node.content?.state === "OPEN" && node.content.assignees?.totalCount === 0
|
|
14105
|
+
).flatMap((node) => toPickup(node, board) ?? []).filter((pickup) => statuses.has(pickup.status.toLowerCase())).sort(comparePickups);
|
|
14106
|
+
}
|
|
14107
|
+
|
|
14108
|
+
// src/commands/sessions/web/next/fetchPickups.ts
|
|
14109
|
+
async function loadPickups(cwd, project, pickStatuses) {
|
|
14110
|
+
try {
|
|
14111
|
+
const { nodes, board } = await readProjectItems(cwd, project);
|
|
14112
|
+
return selectPickups(nodes, pickStatuses, board);
|
|
14113
|
+
} catch (error) {
|
|
14114
|
+
throw new Error(projectErrorText(error));
|
|
14115
|
+
}
|
|
14116
|
+
}
|
|
14117
|
+
async function fetchPickups(cwd, projects, pickStatuses) {
|
|
14118
|
+
if (projects.length === 0) return { items: [], error: null };
|
|
14119
|
+
return sectionAcross(
|
|
14120
|
+
projects,
|
|
14121
|
+
(project) => loadPickups(cwd, project, pickStatuses),
|
|
14122
|
+
comparePickups
|
|
14123
|
+
);
|
|
14124
|
+
}
|
|
14125
|
+
|
|
14126
|
+
// src/commands/sessions/web/next/nextScope.ts
|
|
14127
|
+
var GITHUB = "github.com/";
|
|
14128
|
+
var DEFAULT_PICK_STATUSES = ["Ready", "Todo"];
|
|
14129
|
+
function githubRepo(cwd) {
|
|
14130
|
+
const { origin } = resolveCurrentOrigin(cwd);
|
|
14131
|
+
return origin.startsWith(GITHUB) ? origin.slice(GITHUB.length) : null;
|
|
14132
|
+
}
|
|
14133
|
+
function nextScope(cwd) {
|
|
14134
|
+
const next3 = loadConfigFrom(cwd).next;
|
|
14135
|
+
return {
|
|
14136
|
+
selfRepo: githubRepo(cwd),
|
|
14137
|
+
peers: next3?.peers ?? [],
|
|
14138
|
+
repos: next3?.repos ?? null,
|
|
14139
|
+
projects: next3?.projects ?? [],
|
|
14140
|
+
pickStatuses: next3?.pickStatuses ?? DEFAULT_PICK_STATUSES
|
|
14141
|
+
};
|
|
14142
|
+
}
|
|
14143
|
+
|
|
14144
|
+
// src/commands/sessions/web/next/scopeRepos.ts
|
|
14145
|
+
function scopeRepos(configured, selfRepo) {
|
|
14146
|
+
if (configured) return configured;
|
|
14147
|
+
return selfRepo ? [selfRepo] : [];
|
|
14148
|
+
}
|
|
14149
|
+
|
|
13981
14150
|
// src/commands/sessions/web/next/nextItems.ts
|
|
13982
14151
|
async function nextItems(req, res) {
|
|
13983
14152
|
const cwd = getCwdParam(req, res);
|
|
13984
14153
|
if (!cwd) return;
|
|
13985
14154
|
const scope = nextScope(cwd);
|
|
13986
14155
|
const repos2 = scopeRepos(scope.repos, scope.selfRepo);
|
|
13987
|
-
const [peerPrs, assignedIssues] = await Promise.all([
|
|
14156
|
+
const [peerPrs, assignedIssues, pickups] = await Promise.all([
|
|
13988
14157
|
sectionAcross(
|
|
13989
14158
|
repos2,
|
|
13990
14159
|
(repo) => fetchPeerPrs(cwd, repo, scope.peers),
|
|
@@ -13994,12 +14163,224 @@ async function nextItems(req, res) {
|
|
|
13994
14163
|
repos2,
|
|
13995
14164
|
(repo) => fetchAssignedIssues(cwd, repo),
|
|
13996
14165
|
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
|
13997
|
-
)
|
|
14166
|
+
),
|
|
14167
|
+
fetchPickups(cwd, scope.projects, scope.pickStatuses)
|
|
13998
14168
|
]);
|
|
13999
|
-
const body = { scope, peerPrs, assignedIssues };
|
|
14169
|
+
const body = { scope, peerPrs, assignedIssues, pickups };
|
|
14000
14170
|
respondJson(res, 200, body);
|
|
14001
14171
|
}
|
|
14002
14172
|
|
|
14173
|
+
// src/commands/sessions/web/readJsonBody.ts
|
|
14174
|
+
async function readJsonBody(req) {
|
|
14175
|
+
const chunks = [];
|
|
14176
|
+
for await (const chunk of req) chunks.push(chunk);
|
|
14177
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
14178
|
+
}
|
|
14179
|
+
|
|
14180
|
+
// src/commands/github/issue/readGhTokenScopes.ts
|
|
14181
|
+
import { spawnSync as spawnSync3 } from "child_process";
|
|
14182
|
+
var SCOPES_LINE = /Token scopes:\s*(.*)/;
|
|
14183
|
+
function readGhTokenScopes() {
|
|
14184
|
+
const result = spawnSync3("gh", ["auth", "status"], {
|
|
14185
|
+
encoding: "utf8",
|
|
14186
|
+
windowsHide: true
|
|
14187
|
+
});
|
|
14188
|
+
const match = SCOPES_LINE.exec(
|
|
14189
|
+
`${result.stdout ?? ""}
|
|
14190
|
+
${result.stderr ?? ""}`
|
|
14191
|
+
);
|
|
14192
|
+
if (!match) return void 0;
|
|
14193
|
+
return (match[1] ?? "").split(",").map((scope) => scope.trim().replace(/^'|'$/g, "")).filter((scope) => scope.length > 0);
|
|
14194
|
+
}
|
|
14195
|
+
|
|
14196
|
+
// src/commands/github/issue/assertProjectScope.ts
|
|
14197
|
+
function assertProjectScope() {
|
|
14198
|
+
const scopes = readGhTokenScopes();
|
|
14199
|
+
if (!scopes || scopes.includes("project")) return;
|
|
14200
|
+
throw new Error(
|
|
14201
|
+
`The gh token has no project scope, so a project cannot be read or written. It has ${scopes.join(", ") || "no scopes"}. Run: gh auth refresh -h github.com -s project`
|
|
14202
|
+
);
|
|
14203
|
+
}
|
|
14204
|
+
|
|
14205
|
+
// src/commands/github/issue/assignIssueToSelf.ts
|
|
14206
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
14207
|
+
function assignIssueToSelf(number, repo) {
|
|
14208
|
+
const args = [
|
|
14209
|
+
"issue",
|
|
14210
|
+
"edit",
|
|
14211
|
+
String(number),
|
|
14212
|
+
"--repo",
|
|
14213
|
+
repo,
|
|
14214
|
+
"--add-assignee",
|
|
14215
|
+
"@me"
|
|
14216
|
+
];
|
|
14217
|
+
try {
|
|
14218
|
+
execFileSync3("gh", args, {
|
|
14219
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
14220
|
+
encoding: "utf8"
|
|
14221
|
+
});
|
|
14222
|
+
} catch (error) {
|
|
14223
|
+
const stderr = error.stderr;
|
|
14224
|
+
throw new Error(
|
|
14225
|
+
typeof stderr === "string" && stderr.trim() ? stderr.trim() : `Could not assign ${repo}#${number} to you`
|
|
14226
|
+
);
|
|
14227
|
+
}
|
|
14228
|
+
}
|
|
14229
|
+
|
|
14230
|
+
// src/shared/runGhGraphqlJson.ts
|
|
14231
|
+
import { spawnSync as spawnSync4 } from "child_process";
|
|
14232
|
+
|
|
14233
|
+
// src/shared/throwOnGraphqlErrors.ts
|
|
14234
|
+
function throwOnGraphqlErrors(stdout) {
|
|
14235
|
+
let parsed;
|
|
14236
|
+
try {
|
|
14237
|
+
parsed = JSON.parse(stdout);
|
|
14238
|
+
} catch {
|
|
14239
|
+
return;
|
|
14240
|
+
}
|
|
14241
|
+
if (!parsed || typeof parsed !== "object") return;
|
|
14242
|
+
const errors = parsed.errors;
|
|
14243
|
+
if (!Array.isArray(errors) || errors.length === 0) return;
|
|
14244
|
+
const messages = errors.map(
|
|
14245
|
+
(entry) => entry && typeof entry === "object" && "message" in entry ? String(entry.message) : String(entry)
|
|
14246
|
+
).join("; ");
|
|
14247
|
+
throw new Error(messages || "GraphQL request returned errors");
|
|
14248
|
+
}
|
|
14249
|
+
|
|
14250
|
+
// src/shared/runGhGraphqlJson.ts
|
|
14251
|
+
function runGhGraphqlJson(query, vars = {}) {
|
|
14252
|
+
const result = spawnSync4("gh", ["api", "graphql", "--input", "-"], {
|
|
14253
|
+
encoding: "utf8",
|
|
14254
|
+
windowsHide: true,
|
|
14255
|
+
input: JSON.stringify({ query, variables: vars }),
|
|
14256
|
+
maxBuffer: 64 * 1024 * 1024
|
|
14257
|
+
});
|
|
14258
|
+
if (result.status !== 0) throw new Error(result.stderr || result.stdout);
|
|
14259
|
+
throwOnGraphqlErrors(result.stdout);
|
|
14260
|
+
return result.stdout;
|
|
14261
|
+
}
|
|
14262
|
+
|
|
14263
|
+
// src/commands/github/issue/projectV2Query.ts
|
|
14264
|
+
function projectV2Query(root2) {
|
|
14265
|
+
return `query($owner: String!, $number: Int!) {
|
|
14266
|
+
${root2}(login: $owner) {
|
|
14267
|
+
projectV2(number: $number) {
|
|
14268
|
+
id
|
|
14269
|
+
title
|
|
14270
|
+
field(name: "Status") {
|
|
14271
|
+
... on ProjectV2SingleSelectField { id options { id name } }
|
|
14272
|
+
}
|
|
14273
|
+
}
|
|
14274
|
+
}
|
|
14275
|
+
}`;
|
|
14276
|
+
}
|
|
14277
|
+
|
|
14278
|
+
// src/commands/github/issue/readProject.ts
|
|
14279
|
+
function readProject(owner, number, root2) {
|
|
14280
|
+
let raw;
|
|
14281
|
+
try {
|
|
14282
|
+
raw = runGhGraphqlJson(projectV2Query(root2), { owner, number });
|
|
14283
|
+
} catch (error) {
|
|
14284
|
+
const message3 = error instanceof Error ? error.message : String(error);
|
|
14285
|
+
if (root2 === "organization" && message3.includes("Could not resolve to an")) {
|
|
14286
|
+
return void 0;
|
|
14287
|
+
}
|
|
14288
|
+
throw error;
|
|
14289
|
+
}
|
|
14290
|
+
const project = JSON.parse(raw).data?.[root2]?.projectV2;
|
|
14291
|
+
if (!project?.id) return void 0;
|
|
14292
|
+
const field = project.field;
|
|
14293
|
+
return {
|
|
14294
|
+
id: project.id,
|
|
14295
|
+
number,
|
|
14296
|
+
title: project.title ?? String(number),
|
|
14297
|
+
statusField: field?.id ? { id: field.id, options: field.options ?? [] } : void 0
|
|
14298
|
+
};
|
|
14299
|
+
}
|
|
14300
|
+
|
|
14301
|
+
// src/commands/github/issue/fetchProjectV2.ts
|
|
14302
|
+
function fetchProjectV2(owner, number) {
|
|
14303
|
+
const project = readProject(owner, number, "organization") ?? readProject(owner, number, "user");
|
|
14304
|
+
if (!project) {
|
|
14305
|
+
throw new Error(`No project ${number} owned by ${owner} could be read`);
|
|
14306
|
+
}
|
|
14307
|
+
return project;
|
|
14308
|
+
}
|
|
14309
|
+
|
|
14310
|
+
// src/commands/github/issue/setProjectItemStatus.ts
|
|
14311
|
+
var MUTATION = `mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {
|
|
14312
|
+
updateProjectV2ItemFieldValue(input: {
|
|
14313
|
+
projectId: $projectId
|
|
14314
|
+
itemId: $itemId
|
|
14315
|
+
fieldId: $fieldId
|
|
14316
|
+
value: { singleSelectOptionId: $optionId }
|
|
14317
|
+
}) {
|
|
14318
|
+
projectV2Item { id }
|
|
14319
|
+
}
|
|
14320
|
+
}`;
|
|
14321
|
+
function setProjectItemStatus(input) {
|
|
14322
|
+
runGhGraphqlJson(MUTATION, input);
|
|
14323
|
+
}
|
|
14324
|
+
|
|
14325
|
+
// src/commands/sessions/web/next/pickUpItem.ts
|
|
14326
|
+
var IN_PROGRESS = "in progress";
|
|
14327
|
+
function pickUpItem(target) {
|
|
14328
|
+
assertProjectScope();
|
|
14329
|
+
const [owner, number] = target.project.split("/");
|
|
14330
|
+
const board = fetchProjectV2(owner, Number(number));
|
|
14331
|
+
const option = board.statusField?.options.find(
|
|
14332
|
+
(candidate) => candidate.name.toLowerCase() === IN_PROGRESS
|
|
14333
|
+
);
|
|
14334
|
+
if (!board.statusField || !option)
|
|
14335
|
+
throw new Error(
|
|
14336
|
+
`Project ${target.project} (${board.title}) has no In Progress status to move ${target.repo}#${target.number} to`
|
|
14337
|
+
);
|
|
14338
|
+
assignIssueToSelf(target.number, target.repo);
|
|
14339
|
+
setProjectItemStatus({
|
|
14340
|
+
projectId: board.id,
|
|
14341
|
+
itemId: target.itemId,
|
|
14342
|
+
fieldId: board.statusField.id,
|
|
14343
|
+
optionId: option.id
|
|
14344
|
+
});
|
|
14345
|
+
}
|
|
14346
|
+
|
|
14347
|
+
// src/commands/sessions/web/next/nextPickup.ts
|
|
14348
|
+
function parseTarget(body) {
|
|
14349
|
+
const { project, repo, number, itemId: itemId2 } = body ?? {};
|
|
14350
|
+
if (typeof project !== "string") return null;
|
|
14351
|
+
if (typeof repo !== "string" || !repo.includes("/")) return null;
|
|
14352
|
+
if (typeof number !== "number" || !Number.isInteger(number)) return null;
|
|
14353
|
+
if (typeof itemId2 !== "string" || !itemId2) return null;
|
|
14354
|
+
return { project, repo, number, itemId: itemId2 };
|
|
14355
|
+
}
|
|
14356
|
+
async function nextPickup(req, res) {
|
|
14357
|
+
const cwd = getCwdParam(req, res);
|
|
14358
|
+
if (!cwd) return;
|
|
14359
|
+
let target;
|
|
14360
|
+
try {
|
|
14361
|
+
target = parseTarget(await readJsonBody(req));
|
|
14362
|
+
} catch {
|
|
14363
|
+
respondJson(res, 400, { error: "Invalid JSON body" });
|
|
14364
|
+
return;
|
|
14365
|
+
}
|
|
14366
|
+
if (!target) {
|
|
14367
|
+
respondJson(res, 400, { error: "Missing project, repo, number or itemId" });
|
|
14368
|
+
return;
|
|
14369
|
+
}
|
|
14370
|
+
if (!nextScope(cwd).projects.includes(target.project)) {
|
|
14371
|
+
respondJson(res, 400, {
|
|
14372
|
+
error: `${target.project} is not in next.projects for this repo`
|
|
14373
|
+
});
|
|
14374
|
+
return;
|
|
14375
|
+
}
|
|
14376
|
+
try {
|
|
14377
|
+
pickUpItem(target);
|
|
14378
|
+
respondJson(res, 200, { ok: true });
|
|
14379
|
+
} catch (error) {
|
|
14380
|
+
respondJson(res, 500, { error: ghErrorText(error) });
|
|
14381
|
+
}
|
|
14382
|
+
}
|
|
14383
|
+
|
|
14003
14384
|
// src/commands/sessions/web/listScopedRules.ts
|
|
14004
14385
|
import path27 from "path";
|
|
14005
14386
|
|
|
@@ -15010,7 +15391,7 @@ async function streamRunState(cwd, stream) {
|
|
|
15010
15391
|
}
|
|
15011
15392
|
|
|
15012
15393
|
// src/commands/sessions/web/releases/streamState.ts
|
|
15013
|
-
function
|
|
15394
|
+
function errorMessage(error) {
|
|
15014
15395
|
if (!(error instanceof Error)) return "Failed to read release state";
|
|
15015
15396
|
return error.message.trim().split("\n")[0] || "Failed to read release state";
|
|
15016
15397
|
}
|
|
@@ -15048,7 +15429,7 @@ async function streamState(cwd, stream, repoEnvironments2 = streamEnvironments(s
|
|
|
15048
15429
|
head: null,
|
|
15049
15430
|
nodes: [],
|
|
15050
15431
|
run: null,
|
|
15051
|
-
error:
|
|
15432
|
+
error: errorMessage(error)
|
|
15052
15433
|
};
|
|
15053
15434
|
}
|
|
15054
15435
|
}
|
|
@@ -15121,7 +15502,7 @@ async function restartDaemon() {
|
|
|
15121
15502
|
}
|
|
15122
15503
|
|
|
15123
15504
|
// src/commands/sessions/web/restartMenu/reExecWebServer.ts
|
|
15124
|
-
import { spawnSync as
|
|
15505
|
+
import { spawnSync as spawnSync5 } from "child_process";
|
|
15125
15506
|
function resolveExecve() {
|
|
15126
15507
|
return typeof process.execve === "function" ? process.execve.bind(process) : null;
|
|
15127
15508
|
}
|
|
@@ -15132,7 +15513,7 @@ function reExecWebServer(deps2 = {}) {
|
|
|
15132
15513
|
const {
|
|
15133
15514
|
beforeExec,
|
|
15134
15515
|
execveFn = resolveExecve(),
|
|
15135
|
-
spawnSyncFn =
|
|
15516
|
+
spawnSyncFn = spawnSync5,
|
|
15136
15517
|
exit = (code) => process.exit(code),
|
|
15137
15518
|
releasePort = releaseWebServerPort
|
|
15138
15519
|
} = deps2;
|
|
@@ -15222,13 +15603,13 @@ import { spawn as spawn4 } from "child_process";
|
|
|
15222
15603
|
import { existsSync as existsSync38 } from "fs";
|
|
15223
15604
|
|
|
15224
15605
|
// src/commands/run/resolveCommand.ts
|
|
15225
|
-
import { execFileSync as
|
|
15606
|
+
import { execFileSync as execFileSync4 } from "child_process";
|
|
15226
15607
|
import { existsSync as existsSync37 } from "fs";
|
|
15227
15608
|
import { dirname as dirname23, join as join38, resolve as resolve12 } from "path";
|
|
15228
15609
|
function resolveCommand(command) {
|
|
15229
15610
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
15230
15611
|
try {
|
|
15231
|
-
const gitPath =
|
|
15612
|
+
const gitPath = execFileSync4("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
15232
15613
|
const gitRoot = resolve12(dirname23(gitPath), "..");
|
|
15233
15614
|
const gitBash = join38(gitRoot, "bin", "bash.exe");
|
|
15234
15615
|
if (existsSync37(gitBash)) return gitBash;
|
|
@@ -15302,15 +15683,6 @@ async function selfUpdate(_req, res, deps2 = {}) {
|
|
|
15302
15683
|
|
|
15303
15684
|
// src/commands/sessions/web/revertDiffPaths.ts
|
|
15304
15685
|
import { relative as relative4 } from "path";
|
|
15305
|
-
|
|
15306
|
-
// src/commands/sessions/web/readJsonBody.ts
|
|
15307
|
-
async function readJsonBody(req) {
|
|
15308
|
-
const chunks = [];
|
|
15309
|
-
for await (const chunk of req) chunks.push(chunk);
|
|
15310
|
-
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
15311
|
-
}
|
|
15312
|
-
|
|
15313
|
-
// src/commands/sessions/web/revertDiffPaths.ts
|
|
15314
15686
|
function requestedPaths(body) {
|
|
15315
15687
|
const paths = body.paths;
|
|
15316
15688
|
if (!Array.isArray(paths)) return null;
|
|
@@ -16292,6 +16664,7 @@ var routes2 = {
|
|
|
16292
16664
|
"GET /api/server-runs": handleServerRuns,
|
|
16293
16665
|
"GET /api/pr-list": prList,
|
|
16294
16666
|
"GET /api/next": nextItems,
|
|
16667
|
+
"POST /api/next/pickup": nextPickup,
|
|
16295
16668
|
"GET /api/news/items": listNewsItems,
|
|
16296
16669
|
"GET /api/news/nav": newsNavConfig,
|
|
16297
16670
|
"GET /api/releases/state": releasesState,
|
|
@@ -20530,7 +20903,7 @@ function registerDeploy(program2) {
|
|
|
20530
20903
|
}
|
|
20531
20904
|
|
|
20532
20905
|
// src/commands/devlog/list.ts
|
|
20533
|
-
import { execFileSync as
|
|
20906
|
+
import { execFileSync as execFileSync5 } from "child_process";
|
|
20534
20907
|
import { basename as basename14 } from "path";
|
|
20535
20908
|
|
|
20536
20909
|
// src/commands/devlog/loadBlogSkipDays.ts
|
|
@@ -20710,7 +21083,7 @@ function list2(options2) {
|
|
|
20710
21083
|
if (options2.reverse) args.push("--reverse");
|
|
20711
21084
|
else args.push("-n", "500");
|
|
20712
21085
|
args.push("--pretty=format:%ad|%h|%s", "--date=short");
|
|
20713
|
-
const output =
|
|
21086
|
+
const output = execFileSync5("git", args, { encoding: "utf8" });
|
|
20714
21087
|
const commitsByDate = parseGitLogCommits(output, ignore3);
|
|
20715
21088
|
let dateCount = 0;
|
|
20716
21089
|
let isFirst = true;
|
|
@@ -20733,7 +21106,7 @@ function list2(options2) {
|
|
|
20733
21106
|
}
|
|
20734
21107
|
|
|
20735
21108
|
// src/commands/devlog/getLastVersionInfo.ts
|
|
20736
|
-
import { execFileSync as
|
|
21109
|
+
import { execFileSync as execFileSync6, execSync as execSync32 } from "child_process";
|
|
20737
21110
|
import semver from "semver";
|
|
20738
21111
|
function getVersionAtCommit(hash) {
|
|
20739
21112
|
try {
|
|
@@ -20752,7 +21125,7 @@ function stripToMinor(version2) {
|
|
|
20752
21125
|
}
|
|
20753
21126
|
function getLastVersionInfoFromGit() {
|
|
20754
21127
|
try {
|
|
20755
|
-
const output =
|
|
21128
|
+
const output = execFileSync6(
|
|
20756
21129
|
"git",
|
|
20757
21130
|
["log", "-1", "--pretty=format:%ad|%h", "--date=short"],
|
|
20758
21131
|
{
|
|
@@ -20797,7 +21170,7 @@ function bumpVersion(version2, type) {
|
|
|
20797
21170
|
}
|
|
20798
21171
|
|
|
20799
21172
|
// src/commands/devlog/next/displayNextEntry.ts
|
|
20800
|
-
import { execFileSync as
|
|
21173
|
+
import { execFileSync as execFileSync7 } from "child_process";
|
|
20801
21174
|
import chalk147 from "chalk";
|
|
20802
21175
|
|
|
20803
21176
|
// src/commands/devlog/next/displayNextEntry/displayVersion.ts
|
|
@@ -20831,7 +21204,7 @@ function findTargetDate(commitsByDate, skipDays) {
|
|
|
20831
21204
|
return Array.from(commitsByDate.keys()).filter((d) => !skipDays.has(d)).sort()[0];
|
|
20832
21205
|
}
|
|
20833
21206
|
function fetchCommitsByDate(ignore3, lastDate) {
|
|
20834
|
-
const output =
|
|
21207
|
+
const output = execFileSync7(
|
|
20835
21208
|
"git",
|
|
20836
21209
|
["log", "--pretty=format:%ad|%h|%s", "--date=short", "-n", "500"],
|
|
20837
21210
|
{ encoding: "utf8" }
|
|
@@ -22434,29 +22807,10 @@ function aggregateCommitters(authorLists) {
|
|
|
22434
22807
|
}
|
|
22435
22808
|
|
|
22436
22809
|
// src/shared/runGhGraphql.ts
|
|
22437
|
-
import { spawnSync as
|
|
22810
|
+
import { spawnSync as spawnSync6 } from "child_process";
|
|
22438
22811
|
import { unlinkSync as unlinkSync12, writeFileSync as writeFileSync30 } from "fs";
|
|
22439
22812
|
import { tmpdir as tmpdir6 } from "os";
|
|
22440
22813
|
import { join as join59 } from "path";
|
|
22441
|
-
|
|
22442
|
-
// src/shared/throwOnGraphqlErrors.ts
|
|
22443
|
-
function throwOnGraphqlErrors(stdout) {
|
|
22444
|
-
let parsed;
|
|
22445
|
-
try {
|
|
22446
|
-
parsed = JSON.parse(stdout);
|
|
22447
|
-
} catch {
|
|
22448
|
-
return;
|
|
22449
|
-
}
|
|
22450
|
-
if (!parsed || typeof parsed !== "object") return;
|
|
22451
|
-
const errors = parsed.errors;
|
|
22452
|
-
if (!Array.isArray(errors) || errors.length === 0) return;
|
|
22453
|
-
const messages = errors.map(
|
|
22454
|
-
(entry) => entry && typeof entry === "object" && "message" in entry ? String(entry.message) : String(entry)
|
|
22455
|
-
).join("; ");
|
|
22456
|
-
throw new Error(messages || "GraphQL request returned errors");
|
|
22457
|
-
}
|
|
22458
|
-
|
|
22459
|
-
// src/shared/runGhGraphql.ts
|
|
22460
22814
|
function buildArgs2(queryFile, vars) {
|
|
22461
22815
|
const args = ["api", "graphql", "-F", `query=@${queryFile}`];
|
|
22462
22816
|
for (const [key, value] of Object.entries(vars)) {
|
|
@@ -22469,7 +22823,7 @@ function runGhGraphql(mutation, vars) {
|
|
|
22469
22823
|
const queryFile = join59(tmpdir6(), `gh-query-${Date.now()}.graphql`);
|
|
22470
22824
|
writeFileSync30(queryFile, mutation);
|
|
22471
22825
|
try {
|
|
22472
|
-
const result =
|
|
22826
|
+
const result = spawnSync6("gh", buildArgs2(queryFile, vars), {
|
|
22473
22827
|
encoding: "utf8",
|
|
22474
22828
|
windowsHide: true
|
|
22475
22829
|
});
|
|
@@ -22637,38 +22991,24 @@ import chalk164 from "chalk";
|
|
|
22637
22991
|
// src/commands/github/issue/fixStructure/applyFixStructurePlan.ts
|
|
22638
22992
|
import chalk163 from "chalk";
|
|
22639
22993
|
|
|
22640
|
-
// src/shared/runGhGraphqlJson.ts
|
|
22641
|
-
import { spawnSync as spawnSync5 } from "child_process";
|
|
22642
|
-
function runGhGraphqlJson(query, vars = {}) {
|
|
22643
|
-
const result = spawnSync5("gh", ["api", "graphql", "--input", "-"], {
|
|
22644
|
-
encoding: "utf8",
|
|
22645
|
-
windowsHide: true,
|
|
22646
|
-
input: JSON.stringify({ query, variables: vars }),
|
|
22647
|
-
maxBuffer: 64 * 1024 * 1024
|
|
22648
|
-
});
|
|
22649
|
-
if (result.status !== 0) throw new Error(result.stderr || result.stdout);
|
|
22650
|
-
throwOnGraphqlErrors(result.stdout);
|
|
22651
|
-
return result.stdout;
|
|
22652
|
-
}
|
|
22653
|
-
|
|
22654
22994
|
// src/commands/github/issue/fixStructure/removeIssueLabels.ts
|
|
22655
|
-
var
|
|
22995
|
+
var MUTATION2 = `mutation($labelableId: ID!, $labelIds: [ID!]!) {
|
|
22656
22996
|
removeLabelsFromLabelable(input: { labelableId: $labelableId, labelIds: $labelIds }) {
|
|
22657
22997
|
labelable { __typename }
|
|
22658
22998
|
}
|
|
22659
22999
|
}`;
|
|
22660
23000
|
function removeIssueLabels(issueId, labelIds) {
|
|
22661
|
-
runGhGraphqlJson(
|
|
23001
|
+
runGhGraphqlJson(MUTATION2, { labelableId: issueId, labelIds });
|
|
22662
23002
|
}
|
|
22663
23003
|
|
|
22664
23004
|
// src/commands/github/issue/fixStructure/updateIssueType.ts
|
|
22665
|
-
var
|
|
23005
|
+
var MUTATION3 = `mutation($issueId: ID!, $issueTypeId: ID!) {
|
|
22666
23006
|
updateIssueIssueType(input: { issueId: $issueId, issueTypeId: $issueTypeId }) {
|
|
22667
23007
|
issue { id }
|
|
22668
23008
|
}
|
|
22669
23009
|
}`;
|
|
22670
23010
|
function updateIssueType(issueId, issueTypeId) {
|
|
22671
|
-
runGhGraphqlJson(
|
|
23011
|
+
runGhGraphqlJson(MUTATION3, { issueId, issueTypeId });
|
|
22672
23012
|
}
|
|
22673
23013
|
|
|
22674
23014
|
// src/commands/github/issue/fixStructure/writeLineNow.ts
|
|
@@ -23204,7 +23544,7 @@ async function readBodyArgument(value) {
|
|
|
23204
23544
|
}
|
|
23205
23545
|
|
|
23206
23546
|
// src/commands/github/issue/commentIssue.ts
|
|
23207
|
-
import { execFileSync as
|
|
23547
|
+
import { execFileSync as execFileSync8 } from "child_process";
|
|
23208
23548
|
|
|
23209
23549
|
// src/shared/validateProposedContent.ts
|
|
23210
23550
|
function validateProposedContent(labels, title, body) {
|
|
@@ -23265,7 +23605,7 @@ async function commentIssue(numberArg, options2) {
|
|
|
23265
23605
|
const args = ["issue", "comment", String(number), "--body", body];
|
|
23266
23606
|
if (options2.repo) args.push("--repo", options2.repo);
|
|
23267
23607
|
try {
|
|
23268
|
-
|
|
23608
|
+
execFileSync8("gh", args, { stdio: "inherit" });
|
|
23269
23609
|
} catch {
|
|
23270
23610
|
process.exit(1);
|
|
23271
23611
|
}
|
|
@@ -23307,26 +23647,26 @@ ${screenshots.join("\n\n")}`;
|
|
|
23307
23647
|
}
|
|
23308
23648
|
|
|
23309
23649
|
// src/commands/github/issue/addIssueToProject.ts
|
|
23310
|
-
var
|
|
23650
|
+
var MUTATION4 = `mutation($projectId: ID!, $contentId: ID!) {
|
|
23311
23651
|
addProjectV2ItemById(input: { projectId: $projectId, contentId: $contentId }) {
|
|
23312
23652
|
item { id }
|
|
23313
23653
|
}
|
|
23314
23654
|
}`;
|
|
23315
23655
|
function addIssueToProject(projectId, contentId) {
|
|
23316
|
-
const raw = runGhGraphqlJson(
|
|
23656
|
+
const raw = runGhGraphqlJson(MUTATION4, { projectId, contentId });
|
|
23317
23657
|
const id = JSON.parse(raw).data?.addProjectV2ItemById?.item?.id;
|
|
23318
23658
|
if (!id) throw new Error("The project returned no item for the issue");
|
|
23319
23659
|
return id;
|
|
23320
23660
|
}
|
|
23321
23661
|
|
|
23322
23662
|
// src/commands/github/issue/addSubIssue.ts
|
|
23323
|
-
var
|
|
23663
|
+
var MUTATION5 = `mutation($issueId: ID!, $subIssueId: ID!) {
|
|
23324
23664
|
addSubIssue(input: { issueId: $issueId, subIssueId: $subIssueId, replaceParent: true }) {
|
|
23325
23665
|
subIssue { id }
|
|
23326
23666
|
}
|
|
23327
23667
|
}`;
|
|
23328
23668
|
function addSubIssue(parentId, childId) {
|
|
23329
|
-
runGhGraphqlJson(
|
|
23669
|
+
runGhGraphqlJson(MUTATION5, { issueId: parentId, subIssueId: childId });
|
|
23330
23670
|
}
|
|
23331
23671
|
|
|
23332
23672
|
// src/commands/github/issue/fetchIssueNodeId.ts
|
|
@@ -23363,21 +23703,6 @@ function parseCreatedIssueUrl(output) {
|
|
|
23363
23703
|
};
|
|
23364
23704
|
}
|
|
23365
23705
|
|
|
23366
|
-
// src/commands/github/issue/setProjectItemStatus.ts
|
|
23367
|
-
var MUTATION5 = `mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {
|
|
23368
|
-
updateProjectV2ItemFieldValue(input: {
|
|
23369
|
-
projectId: $projectId
|
|
23370
|
-
itemId: $itemId
|
|
23371
|
-
fieldId: $fieldId
|
|
23372
|
-
value: { singleSelectOptionId: $optionId }
|
|
23373
|
-
}) {
|
|
23374
|
-
projectV2Item { id }
|
|
23375
|
-
}
|
|
23376
|
-
}`;
|
|
23377
|
-
function setProjectItemStatus(input) {
|
|
23378
|
-
runGhGraphqlJson(MUTATION5, input);
|
|
23379
|
-
}
|
|
23380
|
-
|
|
23381
23706
|
// src/commands/github/issue/applyCreatedIssueMetadata.ts
|
|
23382
23707
|
function applyCreatedIssueMetadata(createOutput, metadata2) {
|
|
23383
23708
|
let step3 = "identifying the created issue";
|
|
@@ -23594,78 +23919,6 @@ function resolveCreateIssueParent(target, parent) {
|
|
|
23594
23919
|
return { ...reference, id: fetchIssueNodeId(reference) };
|
|
23595
23920
|
}
|
|
23596
23921
|
|
|
23597
|
-
// src/commands/github/issue/readGhTokenScopes.ts
|
|
23598
|
-
import { spawnSync as spawnSync6 } from "child_process";
|
|
23599
|
-
var SCOPES_LINE = /Token scopes:\s*(.*)/;
|
|
23600
|
-
function readGhTokenScopes() {
|
|
23601
|
-
const result = spawnSync6("gh", ["auth", "status"], {
|
|
23602
|
-
encoding: "utf8",
|
|
23603
|
-
windowsHide: true
|
|
23604
|
-
});
|
|
23605
|
-
const match = SCOPES_LINE.exec(
|
|
23606
|
-
`${result.stdout ?? ""}
|
|
23607
|
-
${result.stderr ?? ""}`
|
|
23608
|
-
);
|
|
23609
|
-
if (!match) return void 0;
|
|
23610
|
-
return (match[1] ?? "").split(",").map((scope) => scope.trim().replace(/^'|'$/g, "")).filter((scope) => scope.length > 0);
|
|
23611
|
-
}
|
|
23612
|
-
|
|
23613
|
-
// src/commands/github/issue/assertProjectScope.ts
|
|
23614
|
-
function assertProjectScope() {
|
|
23615
|
-
const scopes = readGhTokenScopes();
|
|
23616
|
-
if (!scopes || scopes.includes("project")) return;
|
|
23617
|
-
throw new Error(
|
|
23618
|
-
`The gh token has no project scope, so a project cannot be read or written. It has ${scopes.join(", ") || "no scopes"}. Run: gh auth refresh -h github.com -s project`
|
|
23619
|
-
);
|
|
23620
|
-
}
|
|
23621
|
-
|
|
23622
|
-
// src/commands/github/issue/projectV2Query.ts
|
|
23623
|
-
function projectV2Query(root2) {
|
|
23624
|
-
return `query($owner: String!, $number: Int!) {
|
|
23625
|
-
${root2}(login: $owner) {
|
|
23626
|
-
projectV2(number: $number) {
|
|
23627
|
-
id
|
|
23628
|
-
title
|
|
23629
|
-
field(name: "Status") {
|
|
23630
|
-
... on ProjectV2SingleSelectField { id options { id name } }
|
|
23631
|
-
}
|
|
23632
|
-
}
|
|
23633
|
-
}
|
|
23634
|
-
}`;
|
|
23635
|
-
}
|
|
23636
|
-
|
|
23637
|
-
// src/commands/github/issue/readProject.ts
|
|
23638
|
-
function readProject(owner, number, root2) {
|
|
23639
|
-
let raw;
|
|
23640
|
-
try {
|
|
23641
|
-
raw = runGhGraphqlJson(projectV2Query(root2), { owner, number });
|
|
23642
|
-
} catch (error) {
|
|
23643
|
-
const message3 = error instanceof Error ? error.message : String(error);
|
|
23644
|
-
if (root2 === "organization" && message3.includes("Could not resolve to an")) {
|
|
23645
|
-
return void 0;
|
|
23646
|
-
}
|
|
23647
|
-
throw error;
|
|
23648
|
-
}
|
|
23649
|
-
const project = JSON.parse(raw).data?.[root2]?.projectV2;
|
|
23650
|
-
if (!project?.id) return void 0;
|
|
23651
|
-
const field = project.field;
|
|
23652
|
-
return {
|
|
23653
|
-
id: project.id,
|
|
23654
|
-
number,
|
|
23655
|
-
title: project.title ?? String(number),
|
|
23656
|
-
statusField: field?.id ? { id: field.id, options: field.options ?? [] } : void 0
|
|
23657
|
-
};
|
|
23658
|
-
}
|
|
23659
|
-
|
|
23660
|
-
// src/commands/github/issue/fetchProjectV2.ts
|
|
23661
|
-
function fetchProjectV2(owner, number) {
|
|
23662
|
-
const project = readProject(owner, number, "organization") ?? readProject(owner, number, "user");
|
|
23663
|
-
if (!project) {
|
|
23664
|
-
throw new Error(`No project ${number} owned by ${owner} could be read`);
|
|
23665
|
-
}
|
|
23666
|
-
return project;
|
|
23667
|
-
}
|
|
23668
|
-
|
|
23669
23922
|
// src/commands/github/issue/resolveCreateIssueProject.ts
|
|
23670
23923
|
function parseProjectNumber(value) {
|
|
23671
23924
|
const number = Number(value);
|
|
@@ -23736,13 +23989,13 @@ async function reviewProposedIssue(title, body, metadata2 = []) {
|
|
|
23736
23989
|
}
|
|
23737
23990
|
|
|
23738
23991
|
// src/commands/github/issue/runGhIssueCreate.ts
|
|
23739
|
-
import { execFileSync as
|
|
23992
|
+
import { execFileSync as execFileSync9 } from "child_process";
|
|
23740
23993
|
function runGhIssueCreate(title, body, repo, labels) {
|
|
23741
23994
|
const args = ["issue", "create", "--title", title, "--body", body];
|
|
23742
23995
|
if (repo) args.push("--repo", repo);
|
|
23743
23996
|
for (const label2 of labels ?? []) args.push("--label", label2);
|
|
23744
23997
|
try {
|
|
23745
|
-
return
|
|
23998
|
+
return execFileSync9("gh", args, {
|
|
23746
23999
|
encoding: "utf8",
|
|
23747
24000
|
stdio: ["ignore", "pipe", "inherit"]
|
|
23748
24001
|
});
|
|
@@ -23822,7 +24075,7 @@ function inWebSession() {
|
|
|
23822
24075
|
}
|
|
23823
24076
|
|
|
23824
24077
|
// src/commands/github/issue/fetchIssue.ts
|
|
23825
|
-
import { execFileSync as
|
|
24078
|
+
import { execFileSync as execFileSync10 } from "child_process";
|
|
23826
24079
|
function fetchIssue2(number, repo) {
|
|
23827
24080
|
const args = [
|
|
23828
24081
|
"issue",
|
|
@@ -23834,7 +24087,7 @@ function fetchIssue2(number, repo) {
|
|
|
23834
24087
|
if (repo) args.push("--repo", repo);
|
|
23835
24088
|
let raw;
|
|
23836
24089
|
try {
|
|
23837
|
-
raw =
|
|
24090
|
+
raw = execFileSync10("gh", args, { encoding: "utf8" });
|
|
23838
24091
|
} catch {
|
|
23839
24092
|
console.error(`Could not fetch issue #${number} with gh issue view`);
|
|
23840
24093
|
process.exit(1);
|
|
@@ -23925,12 +24178,12 @@ function prepareIssueEdit(number, repo, fresh) {
|
|
|
23925
24178
|
}
|
|
23926
24179
|
|
|
23927
24180
|
// src/commands/github/issue/pushIssueBody.ts
|
|
23928
|
-
import { execFileSync as
|
|
24181
|
+
import { execFileSync as execFileSync11 } from "child_process";
|
|
23929
24182
|
function pushIssueBody(number, repo, bodyPath) {
|
|
23930
24183
|
const args = ["issue", "edit", String(number), "--body-file", bodyPath];
|
|
23931
24184
|
if (repo) args.push("--repo", repo);
|
|
23932
24185
|
try {
|
|
23933
|
-
|
|
24186
|
+
execFileSync11("gh", args, { stdio: "inherit" });
|
|
23934
24187
|
} catch {
|
|
23935
24188
|
process.exit(1);
|
|
23936
24189
|
}
|
|
@@ -23990,12 +24243,12 @@ function setIssueParent(number, repo, parentArg) {
|
|
|
23990
24243
|
}
|
|
23991
24244
|
|
|
23992
24245
|
// src/commands/github/issue/viewIssue.ts
|
|
23993
|
-
import { execFileSync as
|
|
24246
|
+
import { execFileSync as execFileSync12 } from "child_process";
|
|
23994
24247
|
function viewIssue(number, repo) {
|
|
23995
24248
|
const args = ["issue", "view", String(number)];
|
|
23996
24249
|
if (repo) args.push("--repo", repo);
|
|
23997
24250
|
try {
|
|
23998
|
-
|
|
24251
|
+
execFileSync12("gh", args, { stdio: "inherit" });
|
|
23999
24252
|
} catch {
|
|
24000
24253
|
process.exit(1);
|
|
24001
24254
|
}
|
|
@@ -24051,7 +24304,7 @@ function registerEditIssue(issueCommand) {
|
|
|
24051
24304
|
}
|
|
24052
24305
|
|
|
24053
24306
|
// src/commands/github/issue/editIssueComment.ts
|
|
24054
|
-
import { execFileSync as
|
|
24307
|
+
import { execFileSync as execFileSync13 } from "child_process";
|
|
24055
24308
|
var USAGE4 = "Usage: assist github issue edit-comment <comment-id> --body <body> [-R <owner>/<repo>]";
|
|
24056
24309
|
async function editIssueComment(commentIdArg, options2) {
|
|
24057
24310
|
const commentId = Number.parseInt(commentIdArg, 10);
|
|
@@ -24078,7 +24331,7 @@ async function editIssueComment(commentIdArg, options2) {
|
|
|
24078
24331
|
];
|
|
24079
24332
|
let raw;
|
|
24080
24333
|
try {
|
|
24081
|
-
raw =
|
|
24334
|
+
raw = execFileSync13("gh", args, {
|
|
24082
24335
|
input: JSON.stringify({ body }),
|
|
24083
24336
|
encoding: "utf8"
|
|
24084
24337
|
});
|
|
@@ -24116,25 +24369,6 @@ function registerEditIssueComment(issueCommand) {
|
|
|
24116
24369
|
);
|
|
24117
24370
|
}
|
|
24118
24371
|
|
|
24119
|
-
// src/commands/github/issue/assignIssueToSelf.ts
|
|
24120
|
-
import { execFileSync as execFileSync13 } from "child_process";
|
|
24121
|
-
function assignIssueToSelf(number, repo) {
|
|
24122
|
-
const args = [
|
|
24123
|
-
"issue",
|
|
24124
|
-
"edit",
|
|
24125
|
-
String(number),
|
|
24126
|
-
"--repo",
|
|
24127
|
-
repo,
|
|
24128
|
-
"--add-assignee",
|
|
24129
|
-
"@me"
|
|
24130
|
-
];
|
|
24131
|
-
try {
|
|
24132
|
-
execFileSync13("gh", args, { stdio: ["ignore", "ignore", "inherit"] });
|
|
24133
|
-
} catch {
|
|
24134
|
-
process.exit(1);
|
|
24135
|
-
}
|
|
24136
|
-
}
|
|
24137
|
-
|
|
24138
24372
|
// src/commands/github/issue/toIssueProjectItem.ts
|
|
24139
24373
|
function toIssueProjectItem(node) {
|
|
24140
24374
|
const project = node?.project;
|
|
@@ -24185,7 +24419,7 @@ function fetchIssueProjectItems(target) {
|
|
|
24185
24419
|
}
|
|
24186
24420
|
|
|
24187
24421
|
// src/commands/github/issue/moveIssueToInProgress.ts
|
|
24188
|
-
var
|
|
24422
|
+
var IN_PROGRESS2 = "in progress";
|
|
24189
24423
|
function boardName(item) {
|
|
24190
24424
|
return `project ${item.projectNumber} (${item.projectTitle})`;
|
|
24191
24425
|
}
|
|
@@ -24196,7 +24430,7 @@ function moveItem(item) {
|
|
|
24196
24430
|
return;
|
|
24197
24431
|
}
|
|
24198
24432
|
const option = statusField.options.find(
|
|
24199
|
-
(candidate) => candidate.name.toLowerCase() ===
|
|
24433
|
+
(candidate) => candidate.name.toLowerCase() === IN_PROGRESS2
|
|
24200
24434
|
);
|
|
24201
24435
|
if (!option) {
|
|
24202
24436
|
const names = statusField.options.map((candidate) => candidate.name);
|
|
@@ -24240,7 +24474,12 @@ function startIssue(numberArg, options2) {
|
|
|
24240
24474
|
}
|
|
24241
24475
|
const { owner, repo } = resolveIssueRepoTarget(options2.repo);
|
|
24242
24476
|
const slug2 = `${owner}/${repo}`;
|
|
24243
|
-
|
|
24477
|
+
try {
|
|
24478
|
+
assignIssueToSelf(number, slug2);
|
|
24479
|
+
} catch (error) {
|
|
24480
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
24481
|
+
process.exit(1);
|
|
24482
|
+
}
|
|
24244
24483
|
console.log(`Assigned ${slug2}#${number} to you`);
|
|
24245
24484
|
moveIssueToInProgress({ owner, repo, number });
|
|
24246
24485
|
}
|
|
@@ -29942,12 +30181,12 @@ import fs27 from "fs";
|
|
|
29942
30181
|
|
|
29943
30182
|
// src/commands/lint/shared.ts
|
|
29944
30183
|
import chalk202 from "chalk";
|
|
29945
|
-
function reportViolations2(violations, checkName2,
|
|
30184
|
+
function reportViolations2(violations, checkName2, errorMessage2, successMessage) {
|
|
29946
30185
|
if (violations.length > 0) {
|
|
29947
30186
|
console.error(chalk202.red(`
|
|
29948
30187
|
${checkName2} failed:
|
|
29949
30188
|
`));
|
|
29950
|
-
console.error(chalk202.red(` ${
|
|
30189
|
+
console.error(chalk202.red(` ${errorMessage2}
|
|
29951
30190
|
`));
|
|
29952
30191
|
for (const violation of violations) {
|
|
29953
30192
|
console.error(chalk202.red(` ${violation.filePath}:${violation.line}`));
|