@staff0rd/assist 0.732.0 → 0.733.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 +426 -206
- 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.733.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -860,7 +860,9 @@ 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
|
+
project: z3.string().regex(/^[^/\s]+\/\d+$/, "Use <owner>/<project number>, e.g. my-org/3").optional(),
|
|
865
|
+
pickStatuses: z3.array(z3.string()).optional()
|
|
864
866
|
}).optional(),
|
|
865
867
|
deny: z3.array(
|
|
866
868
|
z3.strictObject({
|
|
@@ -12576,6 +12578,16 @@ var nextConfigHelp = [
|
|
|
12576
12578
|
key: "next.repos",
|
|
12577
12579
|
setter: "assist config set next.repos my-org,other/web -g --repo",
|
|
12578
12580
|
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)"
|
|
12581
|
+
},
|
|
12582
|
+
{
|
|
12583
|
+
key: "next.project",
|
|
12584
|
+
setter: "assist config set next.project my-org/3 -g --repo",
|
|
12585
|
+
note: "GitHub Project (owner/number, from its URL) the web /next view suggests unassigned issues to pick up from; needs the gh project scope"
|
|
12586
|
+
},
|
|
12587
|
+
{
|
|
12588
|
+
key: "next.pickStatuses",
|
|
12589
|
+
setter: "assist config set next.pickStatuses Ready,Todo -g --repo",
|
|
12590
|
+
note: "Project Status values whose unassigned items the web /next view offers to pick up (default: Ready, Todo)"
|
|
12579
12591
|
}
|
|
12580
12592
|
];
|
|
12581
12593
|
|
|
@@ -13792,6 +13804,12 @@ var ownerPeerPrsQuery = `query($requested: String!, $authored: String!, $hasPeer
|
|
|
13792
13804
|
}
|
|
13793
13805
|
}`;
|
|
13794
13806
|
|
|
13807
|
+
// src/commands/prs/status/isDoNotMerge.ts
|
|
13808
|
+
var DO_NOT_MERGE = /^\s*[[(]\s*(do[\s_-]*not\b[^\])]*|dnm)\s*[\])]/i;
|
|
13809
|
+
function isDoNotMerge(title) {
|
|
13810
|
+
return DO_NOT_MERGE.test(title);
|
|
13811
|
+
}
|
|
13812
|
+
|
|
13795
13813
|
// src/commands/sessions/web/next/headCommit.ts
|
|
13796
13814
|
function headCommit(node) {
|
|
13797
13815
|
return node.commits?.nodes?.[0]?.commit ?? null;
|
|
@@ -13845,7 +13863,8 @@ function selectPeerPrs(nodes, viewer, peers) {
|
|
|
13845
13863
|
const selected = [];
|
|
13846
13864
|
for (const node of nodes) {
|
|
13847
13865
|
const author = node.author?.login ?? "unknown";
|
|
13848
|
-
if (node.isDraft || sameLogin(author, viewer))
|
|
13866
|
+
if (node.isDraft || isDoNotMerge(node.title) || sameLogin(author, viewer))
|
|
13867
|
+
continue;
|
|
13849
13868
|
const requested = isRequested(node, viewer);
|
|
13850
13869
|
const byPeer = peers.some((peer) => sameLogin(author, peer));
|
|
13851
13870
|
if (!requested && (!byPeer || approvedHead(node, viewer))) continue;
|
|
@@ -13924,8 +13943,150 @@ async function fetchPeerPrs(cwd, repo, peers) {
|
|
|
13924
13943
|
return selectPeerPrs(nodes, viewer, peers).map((pr) => ({ ...pr, repo }));
|
|
13925
13944
|
}
|
|
13926
13945
|
|
|
13946
|
+
// src/commands/sessions/web/next/ghErrorText.ts
|
|
13947
|
+
function ghErrorText(error) {
|
|
13948
|
+
const stderr = error.stderr;
|
|
13949
|
+
if (typeof stderr === "string" && stderr.trim()) return stderr.trim();
|
|
13950
|
+
return error instanceof Error ? error.message : String(error);
|
|
13951
|
+
}
|
|
13952
|
+
|
|
13953
|
+
// src/commands/sessions/web/next/pickupsError.ts
|
|
13954
|
+
function pickupsError(project, error) {
|
|
13955
|
+
const text18 = ghErrorText(error);
|
|
13956
|
+
if (/read:project|required scopes/i.test(text18))
|
|
13957
|
+
return `The gh token has no project scope, so project ${project} cannot be read. Run: gh auth refresh -h github.com -s project`;
|
|
13958
|
+
return `${project}: ${text18}`;
|
|
13959
|
+
}
|
|
13960
|
+
|
|
13961
|
+
// src/commands/sessions/web/next/pickupsQuery.ts
|
|
13962
|
+
var pickupsQuery = `query($owner: String!, $number: Int!, $after: String) {
|
|
13963
|
+
repositoryOwner(login: $owner) {
|
|
13964
|
+
... on ProjectV2Owner {
|
|
13965
|
+
projectV2(number: $number) {
|
|
13966
|
+
priorityField: field(name: "Priority") {
|
|
13967
|
+
... on ProjectV2SingleSelectField { options { name } }
|
|
13968
|
+
}
|
|
13969
|
+
items(first: 100, after: $after) {
|
|
13970
|
+
pageInfo { hasNextPage endCursor }
|
|
13971
|
+
nodes {
|
|
13972
|
+
id
|
|
13973
|
+
status: fieldValueByName(name: "Status") {
|
|
13974
|
+
... on ProjectV2ItemFieldSingleSelectValue { name }
|
|
13975
|
+
}
|
|
13976
|
+
priority: fieldValueByName(name: "Priority") {
|
|
13977
|
+
... on ProjectV2ItemFieldSingleSelectValue { name }
|
|
13978
|
+
}
|
|
13979
|
+
content {
|
|
13980
|
+
... on Issue {
|
|
13981
|
+
number
|
|
13982
|
+
title
|
|
13983
|
+
url
|
|
13984
|
+
createdAt
|
|
13985
|
+
state
|
|
13986
|
+
author { login }
|
|
13987
|
+
repository { nameWithOwner }
|
|
13988
|
+
assignees(first: 1) { totalCount }
|
|
13989
|
+
labels(first: 20) { nodes { name } }
|
|
13990
|
+
}
|
|
13991
|
+
}
|
|
13992
|
+
}
|
|
13993
|
+
}
|
|
13994
|
+
}
|
|
13995
|
+
}
|
|
13996
|
+
}
|
|
13997
|
+
}`;
|
|
13998
|
+
|
|
13999
|
+
// src/commands/sessions/web/next/readProjectPage.ts
|
|
14000
|
+
function readProjectPage(cwd, owner, number, after) {
|
|
14001
|
+
return ghJson(cwd, [
|
|
14002
|
+
"api",
|
|
14003
|
+
"graphql",
|
|
14004
|
+
"-f",
|
|
14005
|
+
`query=${pickupsQuery}`,
|
|
14006
|
+
"-F",
|
|
14007
|
+
`owner=${owner}`,
|
|
14008
|
+
"-F",
|
|
14009
|
+
`number=${number}`,
|
|
14010
|
+
...after ? ["-f", `after=${after}`] : []
|
|
14011
|
+
]);
|
|
14012
|
+
}
|
|
14013
|
+
|
|
14014
|
+
// src/commands/sessions/web/next/readProjectItems.ts
|
|
14015
|
+
var MAX_PAGES = 10;
|
|
14016
|
+
async function readProjectItems(cwd, project) {
|
|
14017
|
+
const [owner, number] = project.split("/");
|
|
14018
|
+
const nodes = [];
|
|
14019
|
+
let priorityOrder = [];
|
|
14020
|
+
let after = null;
|
|
14021
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
14022
|
+
const response = await readProjectPage(cwd, owner, number, after);
|
|
14023
|
+
const projectV2 = response.data?.repositoryOwner?.projectV2;
|
|
14024
|
+
if (!projectV2?.items) {
|
|
14025
|
+
const reason4 = response.errors?.[0]?.message;
|
|
14026
|
+
throw new Error(reason4 ?? `No project ${number} owned by ${owner}`);
|
|
14027
|
+
}
|
|
14028
|
+
priorityOrder = (projectV2.priorityField?.options ?? []).map(
|
|
14029
|
+
(option) => option.name
|
|
14030
|
+
);
|
|
14031
|
+
for (const node of projectV2.items.nodes ?? []) if (node) nodes.push(node);
|
|
14032
|
+
const { hasNextPage: hasNextPage2, endCursor } = projectV2.items.pageInfo ?? {};
|
|
14033
|
+
if (!hasNextPage2 || !endCursor) break;
|
|
14034
|
+
after = endCursor;
|
|
14035
|
+
}
|
|
14036
|
+
return { nodes, priorityOrder };
|
|
14037
|
+
}
|
|
14038
|
+
|
|
14039
|
+
// src/commands/sessions/web/next/selectPickups.ts
|
|
14040
|
+
function toPickup(node) {
|
|
14041
|
+
const issue = node.content;
|
|
14042
|
+
const repo = issue?.repository?.nameWithOwner;
|
|
14043
|
+
const status3 = node.status?.name;
|
|
14044
|
+
if (!issue?.number || !issue.url || !repo || !status3) return null;
|
|
14045
|
+
return {
|
|
14046
|
+
repo,
|
|
14047
|
+
number: issue.number,
|
|
14048
|
+
title: issue.title ?? "",
|
|
14049
|
+
url: issue.url,
|
|
14050
|
+
createdAt: issue.createdAt ?? "",
|
|
14051
|
+
author: issue.author?.login ?? "unknown",
|
|
14052
|
+
labels: (issue.labels?.nodes ?? []).flatMap(
|
|
14053
|
+
(label2) => label2?.name ? [label2.name] : []
|
|
14054
|
+
),
|
|
14055
|
+
itemId: node.id,
|
|
14056
|
+
status: status3,
|
|
14057
|
+
priority: node.priority?.name ?? null
|
|
14058
|
+
};
|
|
14059
|
+
}
|
|
14060
|
+
function selectPickups(nodes, pickStatuses, priorityOrder) {
|
|
14061
|
+
const statuses = new Set(pickStatuses.map((status3) => status3.toLowerCase()));
|
|
14062
|
+
const rank = (pickup) => {
|
|
14063
|
+
const index3 = pickup.priority ? priorityOrder.indexOf(pickup.priority) : -1;
|
|
14064
|
+
return index3 === -1 ? priorityOrder.length : index3;
|
|
14065
|
+
};
|
|
14066
|
+
return nodes.filter(
|
|
14067
|
+
(node) => node.content?.state === "OPEN" && node.content.assignees?.totalCount === 0
|
|
14068
|
+
).flatMap((node) => toPickup(node) ?? []).filter((pickup) => statuses.has(pickup.status.toLowerCase())).sort(
|
|
14069
|
+
(a, b) => rank(a) - rank(b) || a.createdAt.localeCompare(b.createdAt)
|
|
14070
|
+
);
|
|
14071
|
+
}
|
|
14072
|
+
|
|
14073
|
+
// src/commands/sessions/web/next/fetchPickups.ts
|
|
14074
|
+
async function fetchPickups(cwd, project, pickStatuses) {
|
|
14075
|
+
if (!project) return { items: [], error: null };
|
|
14076
|
+
try {
|
|
14077
|
+
const { nodes, priorityOrder } = await readProjectItems(cwd, project);
|
|
14078
|
+
return {
|
|
14079
|
+
items: selectPickups(nodes, pickStatuses, priorityOrder),
|
|
14080
|
+
error: null
|
|
14081
|
+
};
|
|
14082
|
+
} catch (error) {
|
|
14083
|
+
return { items: [], error: pickupsError(project, error) };
|
|
14084
|
+
}
|
|
14085
|
+
}
|
|
14086
|
+
|
|
13927
14087
|
// src/commands/sessions/web/next/nextScope.ts
|
|
13928
14088
|
var GITHUB = "github.com/";
|
|
14089
|
+
var DEFAULT_PICK_STATUSES = ["Ready", "Todo"];
|
|
13929
14090
|
function githubRepo(cwd) {
|
|
13930
14091
|
const { origin } = resolveCurrentOrigin(cwd);
|
|
13931
14092
|
return origin.startsWith(GITHUB) ? origin.slice(GITHUB.length) : null;
|
|
@@ -13935,7 +14096,9 @@ function nextScope(cwd) {
|
|
|
13935
14096
|
return {
|
|
13936
14097
|
selfRepo: githubRepo(cwd),
|
|
13937
14098
|
peers: next3?.peers ?? [],
|
|
13938
|
-
repos: next3?.repos ?? null
|
|
14099
|
+
repos: next3?.repos ?? null,
|
|
14100
|
+
project: next3?.project ?? null,
|
|
14101
|
+
pickStatuses: next3?.pickStatuses ?? DEFAULT_PICK_STATUSES
|
|
13939
14102
|
};
|
|
13940
14103
|
}
|
|
13941
14104
|
|
|
@@ -13946,11 +14109,6 @@ function scopeRepos(configured, selfRepo) {
|
|
|
13946
14109
|
}
|
|
13947
14110
|
|
|
13948
14111
|
// src/commands/sessions/web/next/sectionAcross.ts
|
|
13949
|
-
function errorMessage(error) {
|
|
13950
|
-
const stderr = error.stderr;
|
|
13951
|
-
if (typeof stderr === "string" && stderr.trim()) return stderr.trim();
|
|
13952
|
-
return error instanceof Error ? error.message : String(error);
|
|
13953
|
-
}
|
|
13954
14112
|
async function sectionAcross(repos2, load3, compare) {
|
|
13955
14113
|
if (repos2.length === 0)
|
|
13956
14114
|
return {
|
|
@@ -13963,7 +14121,7 @@ async function sectionAcross(repos2, load3, compare) {
|
|
|
13963
14121
|
results.forEach((result, index3) => {
|
|
13964
14122
|
if (result.status === "fulfilled")
|
|
13965
14123
|
for (const item of result.value) items2.set(item.url, item);
|
|
13966
|
-
else errors.push(`${repos2[index3]}: ${
|
|
14124
|
+
else errors.push(`${repos2[index3]}: ${ghErrorText(result.reason)}`);
|
|
13967
14125
|
});
|
|
13968
14126
|
return {
|
|
13969
14127
|
items: [...items2.values()].sort(compare),
|
|
@@ -13977,7 +14135,7 @@ async function nextItems(req, res) {
|
|
|
13977
14135
|
if (!cwd) return;
|
|
13978
14136
|
const scope = nextScope(cwd);
|
|
13979
14137
|
const repos2 = scopeRepos(scope.repos, scope.selfRepo);
|
|
13980
|
-
const [peerPrs, assignedIssues] = await Promise.all([
|
|
14138
|
+
const [peerPrs, assignedIssues, pickups] = await Promise.all([
|
|
13981
14139
|
sectionAcross(
|
|
13982
14140
|
repos2,
|
|
13983
14141
|
(repo) => fetchPeerPrs(cwd, repo, scope.peers),
|
|
@@ -13987,12 +14145,222 @@ async function nextItems(req, res) {
|
|
|
13987
14145
|
repos2,
|
|
13988
14146
|
(repo) => fetchAssignedIssues(cwd, repo),
|
|
13989
14147
|
(a, b) => a.createdAt.localeCompare(b.createdAt)
|
|
13990
|
-
)
|
|
14148
|
+
),
|
|
14149
|
+
fetchPickups(cwd, scope.project, scope.pickStatuses)
|
|
13991
14150
|
]);
|
|
13992
|
-
const body = { scope, peerPrs, assignedIssues };
|
|
14151
|
+
const body = { scope, peerPrs, assignedIssues, pickups };
|
|
13993
14152
|
respondJson(res, 200, body);
|
|
13994
14153
|
}
|
|
13995
14154
|
|
|
14155
|
+
// src/commands/sessions/web/readJsonBody.ts
|
|
14156
|
+
async function readJsonBody(req) {
|
|
14157
|
+
const chunks = [];
|
|
14158
|
+
for await (const chunk of req) chunks.push(chunk);
|
|
14159
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
14160
|
+
}
|
|
14161
|
+
|
|
14162
|
+
// src/commands/github/issue/readGhTokenScopes.ts
|
|
14163
|
+
import { spawnSync as spawnSync3 } from "child_process";
|
|
14164
|
+
var SCOPES_LINE = /Token scopes:\s*(.*)/;
|
|
14165
|
+
function readGhTokenScopes() {
|
|
14166
|
+
const result = spawnSync3("gh", ["auth", "status"], {
|
|
14167
|
+
encoding: "utf8",
|
|
14168
|
+
windowsHide: true
|
|
14169
|
+
});
|
|
14170
|
+
const match = SCOPES_LINE.exec(
|
|
14171
|
+
`${result.stdout ?? ""}
|
|
14172
|
+
${result.stderr ?? ""}`
|
|
14173
|
+
);
|
|
14174
|
+
if (!match) return void 0;
|
|
14175
|
+
return (match[1] ?? "").split(",").map((scope) => scope.trim().replace(/^'|'$/g, "")).filter((scope) => scope.length > 0);
|
|
14176
|
+
}
|
|
14177
|
+
|
|
14178
|
+
// src/commands/github/issue/assertProjectScope.ts
|
|
14179
|
+
function assertProjectScope() {
|
|
14180
|
+
const scopes = readGhTokenScopes();
|
|
14181
|
+
if (!scopes || scopes.includes("project")) return;
|
|
14182
|
+
throw new Error(
|
|
14183
|
+
`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`
|
|
14184
|
+
);
|
|
14185
|
+
}
|
|
14186
|
+
|
|
14187
|
+
// src/commands/github/issue/assignIssueToSelf.ts
|
|
14188
|
+
import { execFileSync as execFileSync3 } from "child_process";
|
|
14189
|
+
function assignIssueToSelf(number, repo) {
|
|
14190
|
+
const args = [
|
|
14191
|
+
"issue",
|
|
14192
|
+
"edit",
|
|
14193
|
+
String(number),
|
|
14194
|
+
"--repo",
|
|
14195
|
+
repo,
|
|
14196
|
+
"--add-assignee",
|
|
14197
|
+
"@me"
|
|
14198
|
+
];
|
|
14199
|
+
try {
|
|
14200
|
+
execFileSync3("gh", args, {
|
|
14201
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
14202
|
+
encoding: "utf8"
|
|
14203
|
+
});
|
|
14204
|
+
} catch (error) {
|
|
14205
|
+
const stderr = error.stderr;
|
|
14206
|
+
throw new Error(
|
|
14207
|
+
typeof stderr === "string" && stderr.trim() ? stderr.trim() : `Could not assign ${repo}#${number} to you`
|
|
14208
|
+
);
|
|
14209
|
+
}
|
|
14210
|
+
}
|
|
14211
|
+
|
|
14212
|
+
// src/shared/runGhGraphqlJson.ts
|
|
14213
|
+
import { spawnSync as spawnSync4 } from "child_process";
|
|
14214
|
+
|
|
14215
|
+
// src/shared/throwOnGraphqlErrors.ts
|
|
14216
|
+
function throwOnGraphqlErrors(stdout) {
|
|
14217
|
+
let parsed;
|
|
14218
|
+
try {
|
|
14219
|
+
parsed = JSON.parse(stdout);
|
|
14220
|
+
} catch {
|
|
14221
|
+
return;
|
|
14222
|
+
}
|
|
14223
|
+
if (!parsed || typeof parsed !== "object") return;
|
|
14224
|
+
const errors = parsed.errors;
|
|
14225
|
+
if (!Array.isArray(errors) || errors.length === 0) return;
|
|
14226
|
+
const messages = errors.map(
|
|
14227
|
+
(entry) => entry && typeof entry === "object" && "message" in entry ? String(entry.message) : String(entry)
|
|
14228
|
+
).join("; ");
|
|
14229
|
+
throw new Error(messages || "GraphQL request returned errors");
|
|
14230
|
+
}
|
|
14231
|
+
|
|
14232
|
+
// src/shared/runGhGraphqlJson.ts
|
|
14233
|
+
function runGhGraphqlJson(query, vars = {}) {
|
|
14234
|
+
const result = spawnSync4("gh", ["api", "graphql", "--input", "-"], {
|
|
14235
|
+
encoding: "utf8",
|
|
14236
|
+
windowsHide: true,
|
|
14237
|
+
input: JSON.stringify({ query, variables: vars }),
|
|
14238
|
+
maxBuffer: 64 * 1024 * 1024
|
|
14239
|
+
});
|
|
14240
|
+
if (result.status !== 0) throw new Error(result.stderr || result.stdout);
|
|
14241
|
+
throwOnGraphqlErrors(result.stdout);
|
|
14242
|
+
return result.stdout;
|
|
14243
|
+
}
|
|
14244
|
+
|
|
14245
|
+
// src/commands/github/issue/projectV2Query.ts
|
|
14246
|
+
function projectV2Query(root2) {
|
|
14247
|
+
return `query($owner: String!, $number: Int!) {
|
|
14248
|
+
${root2}(login: $owner) {
|
|
14249
|
+
projectV2(number: $number) {
|
|
14250
|
+
id
|
|
14251
|
+
title
|
|
14252
|
+
field(name: "Status") {
|
|
14253
|
+
... on ProjectV2SingleSelectField { id options { id name } }
|
|
14254
|
+
}
|
|
14255
|
+
}
|
|
14256
|
+
}
|
|
14257
|
+
}`;
|
|
14258
|
+
}
|
|
14259
|
+
|
|
14260
|
+
// src/commands/github/issue/readProject.ts
|
|
14261
|
+
function readProject(owner, number, root2) {
|
|
14262
|
+
let raw;
|
|
14263
|
+
try {
|
|
14264
|
+
raw = runGhGraphqlJson(projectV2Query(root2), { owner, number });
|
|
14265
|
+
} catch (error) {
|
|
14266
|
+
const message3 = error instanceof Error ? error.message : String(error);
|
|
14267
|
+
if (root2 === "organization" && message3.includes("Could not resolve to an")) {
|
|
14268
|
+
return void 0;
|
|
14269
|
+
}
|
|
14270
|
+
throw error;
|
|
14271
|
+
}
|
|
14272
|
+
const project = JSON.parse(raw).data?.[root2]?.projectV2;
|
|
14273
|
+
if (!project?.id) return void 0;
|
|
14274
|
+
const field = project.field;
|
|
14275
|
+
return {
|
|
14276
|
+
id: project.id,
|
|
14277
|
+
number,
|
|
14278
|
+
title: project.title ?? String(number),
|
|
14279
|
+
statusField: field?.id ? { id: field.id, options: field.options ?? [] } : void 0
|
|
14280
|
+
};
|
|
14281
|
+
}
|
|
14282
|
+
|
|
14283
|
+
// src/commands/github/issue/fetchProjectV2.ts
|
|
14284
|
+
function fetchProjectV2(owner, number) {
|
|
14285
|
+
const project = readProject(owner, number, "organization") ?? readProject(owner, number, "user");
|
|
14286
|
+
if (!project) {
|
|
14287
|
+
throw new Error(`No project ${number} owned by ${owner} could be read`);
|
|
14288
|
+
}
|
|
14289
|
+
return project;
|
|
14290
|
+
}
|
|
14291
|
+
|
|
14292
|
+
// src/commands/github/issue/setProjectItemStatus.ts
|
|
14293
|
+
var MUTATION = `mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {
|
|
14294
|
+
updateProjectV2ItemFieldValue(input: {
|
|
14295
|
+
projectId: $projectId
|
|
14296
|
+
itemId: $itemId
|
|
14297
|
+
fieldId: $fieldId
|
|
14298
|
+
value: { singleSelectOptionId: $optionId }
|
|
14299
|
+
}) {
|
|
14300
|
+
projectV2Item { id }
|
|
14301
|
+
}
|
|
14302
|
+
}`;
|
|
14303
|
+
function setProjectItemStatus(input) {
|
|
14304
|
+
runGhGraphqlJson(MUTATION, input);
|
|
14305
|
+
}
|
|
14306
|
+
|
|
14307
|
+
// src/commands/sessions/web/next/pickUpItem.ts
|
|
14308
|
+
var IN_PROGRESS = "in progress";
|
|
14309
|
+
function pickUpItem(project, target) {
|
|
14310
|
+
assertProjectScope();
|
|
14311
|
+
const [owner, number] = project.split("/");
|
|
14312
|
+
const board = fetchProjectV2(owner, Number(number));
|
|
14313
|
+
const option = board.statusField?.options.find(
|
|
14314
|
+
(candidate) => candidate.name.toLowerCase() === IN_PROGRESS
|
|
14315
|
+
);
|
|
14316
|
+
if (!board.statusField || !option)
|
|
14317
|
+
throw new Error(
|
|
14318
|
+
`Project ${project} (${board.title}) has no In Progress status to move ${target.repo}#${target.number} to`
|
|
14319
|
+
);
|
|
14320
|
+
assignIssueToSelf(target.number, target.repo);
|
|
14321
|
+
setProjectItemStatus({
|
|
14322
|
+
projectId: board.id,
|
|
14323
|
+
itemId: target.itemId,
|
|
14324
|
+
fieldId: board.statusField.id,
|
|
14325
|
+
optionId: option.id
|
|
14326
|
+
});
|
|
14327
|
+
}
|
|
14328
|
+
|
|
14329
|
+
// src/commands/sessions/web/next/nextPickup.ts
|
|
14330
|
+
function parseTarget(body) {
|
|
14331
|
+
const { repo, number, itemId: itemId2 } = body ?? {};
|
|
14332
|
+
if (typeof repo !== "string" || !repo.includes("/")) return null;
|
|
14333
|
+
if (typeof number !== "number" || !Number.isInteger(number)) return null;
|
|
14334
|
+
if (typeof itemId2 !== "string" || !itemId2) return null;
|
|
14335
|
+
return { repo, number, itemId: itemId2 };
|
|
14336
|
+
}
|
|
14337
|
+
async function nextPickup(req, res) {
|
|
14338
|
+
const cwd = getCwdParam(req, res);
|
|
14339
|
+
if (!cwd) return;
|
|
14340
|
+
let target;
|
|
14341
|
+
try {
|
|
14342
|
+
target = parseTarget(await readJsonBody(req));
|
|
14343
|
+
} catch {
|
|
14344
|
+
respondJson(res, 400, { error: "Invalid JSON body" });
|
|
14345
|
+
return;
|
|
14346
|
+
}
|
|
14347
|
+
if (!target) {
|
|
14348
|
+
respondJson(res, 400, { error: "Missing repo, number or itemId" });
|
|
14349
|
+
return;
|
|
14350
|
+
}
|
|
14351
|
+
const { project } = nextScope(cwd);
|
|
14352
|
+
if (!project) {
|
|
14353
|
+
respondJson(res, 400, { error: "next.project is not set for this repo" });
|
|
14354
|
+
return;
|
|
14355
|
+
}
|
|
14356
|
+
try {
|
|
14357
|
+
pickUpItem(project, target);
|
|
14358
|
+
respondJson(res, 200, { ok: true });
|
|
14359
|
+
} catch (error) {
|
|
14360
|
+
respondJson(res, 500, { error: ghErrorText(error) });
|
|
14361
|
+
}
|
|
14362
|
+
}
|
|
14363
|
+
|
|
13996
14364
|
// src/commands/sessions/web/listScopedRules.ts
|
|
13997
14365
|
import path27 from "path";
|
|
13998
14366
|
|
|
@@ -15003,7 +15371,7 @@ async function streamRunState(cwd, stream) {
|
|
|
15003
15371
|
}
|
|
15004
15372
|
|
|
15005
15373
|
// src/commands/sessions/web/releases/streamState.ts
|
|
15006
|
-
function
|
|
15374
|
+
function errorMessage(error) {
|
|
15007
15375
|
if (!(error instanceof Error)) return "Failed to read release state";
|
|
15008
15376
|
return error.message.trim().split("\n")[0] || "Failed to read release state";
|
|
15009
15377
|
}
|
|
@@ -15041,7 +15409,7 @@ async function streamState(cwd, stream, repoEnvironments2 = streamEnvironments(s
|
|
|
15041
15409
|
head: null,
|
|
15042
15410
|
nodes: [],
|
|
15043
15411
|
run: null,
|
|
15044
|
-
error:
|
|
15412
|
+
error: errorMessage(error)
|
|
15045
15413
|
};
|
|
15046
15414
|
}
|
|
15047
15415
|
}
|
|
@@ -15114,7 +15482,7 @@ async function restartDaemon() {
|
|
|
15114
15482
|
}
|
|
15115
15483
|
|
|
15116
15484
|
// src/commands/sessions/web/restartMenu/reExecWebServer.ts
|
|
15117
|
-
import { spawnSync as
|
|
15485
|
+
import { spawnSync as spawnSync5 } from "child_process";
|
|
15118
15486
|
function resolveExecve() {
|
|
15119
15487
|
return typeof process.execve === "function" ? process.execve.bind(process) : null;
|
|
15120
15488
|
}
|
|
@@ -15125,7 +15493,7 @@ function reExecWebServer(deps2 = {}) {
|
|
|
15125
15493
|
const {
|
|
15126
15494
|
beforeExec,
|
|
15127
15495
|
execveFn = resolveExecve(),
|
|
15128
|
-
spawnSyncFn =
|
|
15496
|
+
spawnSyncFn = spawnSync5,
|
|
15129
15497
|
exit = (code) => process.exit(code),
|
|
15130
15498
|
releasePort = releaseWebServerPort
|
|
15131
15499
|
} = deps2;
|
|
@@ -15215,13 +15583,13 @@ import { spawn as spawn4 } from "child_process";
|
|
|
15215
15583
|
import { existsSync as existsSync38 } from "fs";
|
|
15216
15584
|
|
|
15217
15585
|
// src/commands/run/resolveCommand.ts
|
|
15218
|
-
import { execFileSync as
|
|
15586
|
+
import { execFileSync as execFileSync4 } from "child_process";
|
|
15219
15587
|
import { existsSync as existsSync37 } from "fs";
|
|
15220
15588
|
import { dirname as dirname23, join as join38, resolve as resolve12 } from "path";
|
|
15221
15589
|
function resolveCommand(command) {
|
|
15222
15590
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
15223
15591
|
try {
|
|
15224
|
-
const gitPath =
|
|
15592
|
+
const gitPath = execFileSync4("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
15225
15593
|
const gitRoot = resolve12(dirname23(gitPath), "..");
|
|
15226
15594
|
const gitBash = join38(gitRoot, "bin", "bash.exe");
|
|
15227
15595
|
if (existsSync37(gitBash)) return gitBash;
|
|
@@ -15295,15 +15663,6 @@ async function selfUpdate(_req, res, deps2 = {}) {
|
|
|
15295
15663
|
|
|
15296
15664
|
// src/commands/sessions/web/revertDiffPaths.ts
|
|
15297
15665
|
import { relative as relative4 } from "path";
|
|
15298
|
-
|
|
15299
|
-
// src/commands/sessions/web/readJsonBody.ts
|
|
15300
|
-
async function readJsonBody(req) {
|
|
15301
|
-
const chunks = [];
|
|
15302
|
-
for await (const chunk of req) chunks.push(chunk);
|
|
15303
|
-
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
15304
|
-
}
|
|
15305
|
-
|
|
15306
|
-
// src/commands/sessions/web/revertDiffPaths.ts
|
|
15307
15666
|
function requestedPaths(body) {
|
|
15308
15667
|
const paths = body.paths;
|
|
15309
15668
|
if (!Array.isArray(paths)) return null;
|
|
@@ -16285,6 +16644,7 @@ var routes2 = {
|
|
|
16285
16644
|
"GET /api/server-runs": handleServerRuns,
|
|
16286
16645
|
"GET /api/pr-list": prList,
|
|
16287
16646
|
"GET /api/next": nextItems,
|
|
16647
|
+
"POST /api/next/pickup": nextPickup,
|
|
16288
16648
|
"GET /api/news/items": listNewsItems,
|
|
16289
16649
|
"GET /api/news/nav": newsNavConfig,
|
|
16290
16650
|
"GET /api/releases/state": releasesState,
|
|
@@ -20523,7 +20883,7 @@ function registerDeploy(program2) {
|
|
|
20523
20883
|
}
|
|
20524
20884
|
|
|
20525
20885
|
// src/commands/devlog/list.ts
|
|
20526
|
-
import { execFileSync as
|
|
20886
|
+
import { execFileSync as execFileSync5 } from "child_process";
|
|
20527
20887
|
import { basename as basename14 } from "path";
|
|
20528
20888
|
|
|
20529
20889
|
// src/commands/devlog/loadBlogSkipDays.ts
|
|
@@ -20703,7 +21063,7 @@ function list2(options2) {
|
|
|
20703
21063
|
if (options2.reverse) args.push("--reverse");
|
|
20704
21064
|
else args.push("-n", "500");
|
|
20705
21065
|
args.push("--pretty=format:%ad|%h|%s", "--date=short");
|
|
20706
|
-
const output =
|
|
21066
|
+
const output = execFileSync5("git", args, { encoding: "utf8" });
|
|
20707
21067
|
const commitsByDate = parseGitLogCommits(output, ignore3);
|
|
20708
21068
|
let dateCount = 0;
|
|
20709
21069
|
let isFirst = true;
|
|
@@ -20726,7 +21086,7 @@ function list2(options2) {
|
|
|
20726
21086
|
}
|
|
20727
21087
|
|
|
20728
21088
|
// src/commands/devlog/getLastVersionInfo.ts
|
|
20729
|
-
import { execFileSync as
|
|
21089
|
+
import { execFileSync as execFileSync6, execSync as execSync32 } from "child_process";
|
|
20730
21090
|
import semver from "semver";
|
|
20731
21091
|
function getVersionAtCommit(hash) {
|
|
20732
21092
|
try {
|
|
@@ -20745,7 +21105,7 @@ function stripToMinor(version2) {
|
|
|
20745
21105
|
}
|
|
20746
21106
|
function getLastVersionInfoFromGit() {
|
|
20747
21107
|
try {
|
|
20748
|
-
const output =
|
|
21108
|
+
const output = execFileSync6(
|
|
20749
21109
|
"git",
|
|
20750
21110
|
["log", "-1", "--pretty=format:%ad|%h", "--date=short"],
|
|
20751
21111
|
{
|
|
@@ -20790,7 +21150,7 @@ function bumpVersion(version2, type) {
|
|
|
20790
21150
|
}
|
|
20791
21151
|
|
|
20792
21152
|
// src/commands/devlog/next/displayNextEntry.ts
|
|
20793
|
-
import { execFileSync as
|
|
21153
|
+
import { execFileSync as execFileSync7 } from "child_process";
|
|
20794
21154
|
import chalk147 from "chalk";
|
|
20795
21155
|
|
|
20796
21156
|
// src/commands/devlog/next/displayNextEntry/displayVersion.ts
|
|
@@ -20824,7 +21184,7 @@ function findTargetDate(commitsByDate, skipDays) {
|
|
|
20824
21184
|
return Array.from(commitsByDate.keys()).filter((d) => !skipDays.has(d)).sort()[0];
|
|
20825
21185
|
}
|
|
20826
21186
|
function fetchCommitsByDate(ignore3, lastDate) {
|
|
20827
|
-
const output =
|
|
21187
|
+
const output = execFileSync7(
|
|
20828
21188
|
"git",
|
|
20829
21189
|
["log", "--pretty=format:%ad|%h|%s", "--date=short", "-n", "500"],
|
|
20830
21190
|
{ encoding: "utf8" }
|
|
@@ -22427,29 +22787,10 @@ function aggregateCommitters(authorLists) {
|
|
|
22427
22787
|
}
|
|
22428
22788
|
|
|
22429
22789
|
// src/shared/runGhGraphql.ts
|
|
22430
|
-
import { spawnSync as
|
|
22790
|
+
import { spawnSync as spawnSync6 } from "child_process";
|
|
22431
22791
|
import { unlinkSync as unlinkSync12, writeFileSync as writeFileSync30 } from "fs";
|
|
22432
22792
|
import { tmpdir as tmpdir6 } from "os";
|
|
22433
22793
|
import { join as join59 } from "path";
|
|
22434
|
-
|
|
22435
|
-
// src/shared/throwOnGraphqlErrors.ts
|
|
22436
|
-
function throwOnGraphqlErrors(stdout) {
|
|
22437
|
-
let parsed;
|
|
22438
|
-
try {
|
|
22439
|
-
parsed = JSON.parse(stdout);
|
|
22440
|
-
} catch {
|
|
22441
|
-
return;
|
|
22442
|
-
}
|
|
22443
|
-
if (!parsed || typeof parsed !== "object") return;
|
|
22444
|
-
const errors = parsed.errors;
|
|
22445
|
-
if (!Array.isArray(errors) || errors.length === 0) return;
|
|
22446
|
-
const messages = errors.map(
|
|
22447
|
-
(entry) => entry && typeof entry === "object" && "message" in entry ? String(entry.message) : String(entry)
|
|
22448
|
-
).join("; ");
|
|
22449
|
-
throw new Error(messages || "GraphQL request returned errors");
|
|
22450
|
-
}
|
|
22451
|
-
|
|
22452
|
-
// src/shared/runGhGraphql.ts
|
|
22453
22794
|
function buildArgs2(queryFile, vars) {
|
|
22454
22795
|
const args = ["api", "graphql", "-F", `query=@${queryFile}`];
|
|
22455
22796
|
for (const [key, value] of Object.entries(vars)) {
|
|
@@ -22462,7 +22803,7 @@ function runGhGraphql(mutation, vars) {
|
|
|
22462
22803
|
const queryFile = join59(tmpdir6(), `gh-query-${Date.now()}.graphql`);
|
|
22463
22804
|
writeFileSync30(queryFile, mutation);
|
|
22464
22805
|
try {
|
|
22465
|
-
const result =
|
|
22806
|
+
const result = spawnSync6("gh", buildArgs2(queryFile, vars), {
|
|
22466
22807
|
encoding: "utf8",
|
|
22467
22808
|
windowsHide: true
|
|
22468
22809
|
});
|
|
@@ -22630,38 +22971,24 @@ import chalk164 from "chalk";
|
|
|
22630
22971
|
// src/commands/github/issue/fixStructure/applyFixStructurePlan.ts
|
|
22631
22972
|
import chalk163 from "chalk";
|
|
22632
22973
|
|
|
22633
|
-
// src/shared/runGhGraphqlJson.ts
|
|
22634
|
-
import { spawnSync as spawnSync5 } from "child_process";
|
|
22635
|
-
function runGhGraphqlJson(query, vars = {}) {
|
|
22636
|
-
const result = spawnSync5("gh", ["api", "graphql", "--input", "-"], {
|
|
22637
|
-
encoding: "utf8",
|
|
22638
|
-
windowsHide: true,
|
|
22639
|
-
input: JSON.stringify({ query, variables: vars }),
|
|
22640
|
-
maxBuffer: 64 * 1024 * 1024
|
|
22641
|
-
});
|
|
22642
|
-
if (result.status !== 0) throw new Error(result.stderr || result.stdout);
|
|
22643
|
-
throwOnGraphqlErrors(result.stdout);
|
|
22644
|
-
return result.stdout;
|
|
22645
|
-
}
|
|
22646
|
-
|
|
22647
22974
|
// src/commands/github/issue/fixStructure/removeIssueLabels.ts
|
|
22648
|
-
var
|
|
22975
|
+
var MUTATION2 = `mutation($labelableId: ID!, $labelIds: [ID!]!) {
|
|
22649
22976
|
removeLabelsFromLabelable(input: { labelableId: $labelableId, labelIds: $labelIds }) {
|
|
22650
22977
|
labelable { __typename }
|
|
22651
22978
|
}
|
|
22652
22979
|
}`;
|
|
22653
22980
|
function removeIssueLabels(issueId, labelIds) {
|
|
22654
|
-
runGhGraphqlJson(
|
|
22981
|
+
runGhGraphqlJson(MUTATION2, { labelableId: issueId, labelIds });
|
|
22655
22982
|
}
|
|
22656
22983
|
|
|
22657
22984
|
// src/commands/github/issue/fixStructure/updateIssueType.ts
|
|
22658
|
-
var
|
|
22985
|
+
var MUTATION3 = `mutation($issueId: ID!, $issueTypeId: ID!) {
|
|
22659
22986
|
updateIssueIssueType(input: { issueId: $issueId, issueTypeId: $issueTypeId }) {
|
|
22660
22987
|
issue { id }
|
|
22661
22988
|
}
|
|
22662
22989
|
}`;
|
|
22663
22990
|
function updateIssueType(issueId, issueTypeId) {
|
|
22664
|
-
runGhGraphqlJson(
|
|
22991
|
+
runGhGraphqlJson(MUTATION3, { issueId, issueTypeId });
|
|
22665
22992
|
}
|
|
22666
22993
|
|
|
22667
22994
|
// src/commands/github/issue/fixStructure/writeLineNow.ts
|
|
@@ -23197,7 +23524,7 @@ async function readBodyArgument(value) {
|
|
|
23197
23524
|
}
|
|
23198
23525
|
|
|
23199
23526
|
// src/commands/github/issue/commentIssue.ts
|
|
23200
|
-
import { execFileSync as
|
|
23527
|
+
import { execFileSync as execFileSync8 } from "child_process";
|
|
23201
23528
|
|
|
23202
23529
|
// src/shared/validateProposedContent.ts
|
|
23203
23530
|
function validateProposedContent(labels, title, body) {
|
|
@@ -23258,7 +23585,7 @@ async function commentIssue(numberArg, options2) {
|
|
|
23258
23585
|
const args = ["issue", "comment", String(number), "--body", body];
|
|
23259
23586
|
if (options2.repo) args.push("--repo", options2.repo);
|
|
23260
23587
|
try {
|
|
23261
|
-
|
|
23588
|
+
execFileSync8("gh", args, { stdio: "inherit" });
|
|
23262
23589
|
} catch {
|
|
23263
23590
|
process.exit(1);
|
|
23264
23591
|
}
|
|
@@ -23300,26 +23627,26 @@ ${screenshots.join("\n\n")}`;
|
|
|
23300
23627
|
}
|
|
23301
23628
|
|
|
23302
23629
|
// src/commands/github/issue/addIssueToProject.ts
|
|
23303
|
-
var
|
|
23630
|
+
var MUTATION4 = `mutation($projectId: ID!, $contentId: ID!) {
|
|
23304
23631
|
addProjectV2ItemById(input: { projectId: $projectId, contentId: $contentId }) {
|
|
23305
23632
|
item { id }
|
|
23306
23633
|
}
|
|
23307
23634
|
}`;
|
|
23308
23635
|
function addIssueToProject(projectId, contentId) {
|
|
23309
|
-
const raw = runGhGraphqlJson(
|
|
23636
|
+
const raw = runGhGraphqlJson(MUTATION4, { projectId, contentId });
|
|
23310
23637
|
const id = JSON.parse(raw).data?.addProjectV2ItemById?.item?.id;
|
|
23311
23638
|
if (!id) throw new Error("The project returned no item for the issue");
|
|
23312
23639
|
return id;
|
|
23313
23640
|
}
|
|
23314
23641
|
|
|
23315
23642
|
// src/commands/github/issue/addSubIssue.ts
|
|
23316
|
-
var
|
|
23643
|
+
var MUTATION5 = `mutation($issueId: ID!, $subIssueId: ID!) {
|
|
23317
23644
|
addSubIssue(input: { issueId: $issueId, subIssueId: $subIssueId, replaceParent: true }) {
|
|
23318
23645
|
subIssue { id }
|
|
23319
23646
|
}
|
|
23320
23647
|
}`;
|
|
23321
23648
|
function addSubIssue(parentId, childId) {
|
|
23322
|
-
runGhGraphqlJson(
|
|
23649
|
+
runGhGraphqlJson(MUTATION5, { issueId: parentId, subIssueId: childId });
|
|
23323
23650
|
}
|
|
23324
23651
|
|
|
23325
23652
|
// src/commands/github/issue/fetchIssueNodeId.ts
|
|
@@ -23356,21 +23683,6 @@ function parseCreatedIssueUrl(output) {
|
|
|
23356
23683
|
};
|
|
23357
23684
|
}
|
|
23358
23685
|
|
|
23359
|
-
// src/commands/github/issue/setProjectItemStatus.ts
|
|
23360
|
-
var MUTATION5 = `mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {
|
|
23361
|
-
updateProjectV2ItemFieldValue(input: {
|
|
23362
|
-
projectId: $projectId
|
|
23363
|
-
itemId: $itemId
|
|
23364
|
-
fieldId: $fieldId
|
|
23365
|
-
value: { singleSelectOptionId: $optionId }
|
|
23366
|
-
}) {
|
|
23367
|
-
projectV2Item { id }
|
|
23368
|
-
}
|
|
23369
|
-
}`;
|
|
23370
|
-
function setProjectItemStatus(input) {
|
|
23371
|
-
runGhGraphqlJson(MUTATION5, input);
|
|
23372
|
-
}
|
|
23373
|
-
|
|
23374
23686
|
// src/commands/github/issue/applyCreatedIssueMetadata.ts
|
|
23375
23687
|
function applyCreatedIssueMetadata(createOutput, metadata2) {
|
|
23376
23688
|
let step3 = "identifying the created issue";
|
|
@@ -23587,78 +23899,6 @@ function resolveCreateIssueParent(target, parent) {
|
|
|
23587
23899
|
return { ...reference, id: fetchIssueNodeId(reference) };
|
|
23588
23900
|
}
|
|
23589
23901
|
|
|
23590
|
-
// src/commands/github/issue/readGhTokenScopes.ts
|
|
23591
|
-
import { spawnSync as spawnSync6 } from "child_process";
|
|
23592
|
-
var SCOPES_LINE = /Token scopes:\s*(.*)/;
|
|
23593
|
-
function readGhTokenScopes() {
|
|
23594
|
-
const result = spawnSync6("gh", ["auth", "status"], {
|
|
23595
|
-
encoding: "utf8",
|
|
23596
|
-
windowsHide: true
|
|
23597
|
-
});
|
|
23598
|
-
const match = SCOPES_LINE.exec(
|
|
23599
|
-
`${result.stdout ?? ""}
|
|
23600
|
-
${result.stderr ?? ""}`
|
|
23601
|
-
);
|
|
23602
|
-
if (!match) return void 0;
|
|
23603
|
-
return (match[1] ?? "").split(",").map((scope) => scope.trim().replace(/^'|'$/g, "")).filter((scope) => scope.length > 0);
|
|
23604
|
-
}
|
|
23605
|
-
|
|
23606
|
-
// src/commands/github/issue/assertProjectScope.ts
|
|
23607
|
-
function assertProjectScope() {
|
|
23608
|
-
const scopes = readGhTokenScopes();
|
|
23609
|
-
if (!scopes || scopes.includes("project")) return;
|
|
23610
|
-
throw new Error(
|
|
23611
|
-
`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`
|
|
23612
|
-
);
|
|
23613
|
-
}
|
|
23614
|
-
|
|
23615
|
-
// src/commands/github/issue/projectV2Query.ts
|
|
23616
|
-
function projectV2Query(root2) {
|
|
23617
|
-
return `query($owner: String!, $number: Int!) {
|
|
23618
|
-
${root2}(login: $owner) {
|
|
23619
|
-
projectV2(number: $number) {
|
|
23620
|
-
id
|
|
23621
|
-
title
|
|
23622
|
-
field(name: "Status") {
|
|
23623
|
-
... on ProjectV2SingleSelectField { id options { id name } }
|
|
23624
|
-
}
|
|
23625
|
-
}
|
|
23626
|
-
}
|
|
23627
|
-
}`;
|
|
23628
|
-
}
|
|
23629
|
-
|
|
23630
|
-
// src/commands/github/issue/readProject.ts
|
|
23631
|
-
function readProject(owner, number, root2) {
|
|
23632
|
-
let raw;
|
|
23633
|
-
try {
|
|
23634
|
-
raw = runGhGraphqlJson(projectV2Query(root2), { owner, number });
|
|
23635
|
-
} catch (error) {
|
|
23636
|
-
const message3 = error instanceof Error ? error.message : String(error);
|
|
23637
|
-
if (root2 === "organization" && message3.includes("Could not resolve to an")) {
|
|
23638
|
-
return void 0;
|
|
23639
|
-
}
|
|
23640
|
-
throw error;
|
|
23641
|
-
}
|
|
23642
|
-
const project = JSON.parse(raw).data?.[root2]?.projectV2;
|
|
23643
|
-
if (!project?.id) return void 0;
|
|
23644
|
-
const field = project.field;
|
|
23645
|
-
return {
|
|
23646
|
-
id: project.id,
|
|
23647
|
-
number,
|
|
23648
|
-
title: project.title ?? String(number),
|
|
23649
|
-
statusField: field?.id ? { id: field.id, options: field.options ?? [] } : void 0
|
|
23650
|
-
};
|
|
23651
|
-
}
|
|
23652
|
-
|
|
23653
|
-
// src/commands/github/issue/fetchProjectV2.ts
|
|
23654
|
-
function fetchProjectV2(owner, number) {
|
|
23655
|
-
const project = readProject(owner, number, "organization") ?? readProject(owner, number, "user");
|
|
23656
|
-
if (!project) {
|
|
23657
|
-
throw new Error(`No project ${number} owned by ${owner} could be read`);
|
|
23658
|
-
}
|
|
23659
|
-
return project;
|
|
23660
|
-
}
|
|
23661
|
-
|
|
23662
23902
|
// src/commands/github/issue/resolveCreateIssueProject.ts
|
|
23663
23903
|
function parseProjectNumber(value) {
|
|
23664
23904
|
const number = Number(value);
|
|
@@ -23729,13 +23969,13 @@ async function reviewProposedIssue(title, body, metadata2 = []) {
|
|
|
23729
23969
|
}
|
|
23730
23970
|
|
|
23731
23971
|
// src/commands/github/issue/runGhIssueCreate.ts
|
|
23732
|
-
import { execFileSync as
|
|
23972
|
+
import { execFileSync as execFileSync9 } from "child_process";
|
|
23733
23973
|
function runGhIssueCreate(title, body, repo, labels) {
|
|
23734
23974
|
const args = ["issue", "create", "--title", title, "--body", body];
|
|
23735
23975
|
if (repo) args.push("--repo", repo);
|
|
23736
23976
|
for (const label2 of labels ?? []) args.push("--label", label2);
|
|
23737
23977
|
try {
|
|
23738
|
-
return
|
|
23978
|
+
return execFileSync9("gh", args, {
|
|
23739
23979
|
encoding: "utf8",
|
|
23740
23980
|
stdio: ["ignore", "pipe", "inherit"]
|
|
23741
23981
|
});
|
|
@@ -23815,7 +24055,7 @@ function inWebSession() {
|
|
|
23815
24055
|
}
|
|
23816
24056
|
|
|
23817
24057
|
// src/commands/github/issue/fetchIssue.ts
|
|
23818
|
-
import { execFileSync as
|
|
24058
|
+
import { execFileSync as execFileSync10 } from "child_process";
|
|
23819
24059
|
function fetchIssue2(number, repo) {
|
|
23820
24060
|
const args = [
|
|
23821
24061
|
"issue",
|
|
@@ -23827,7 +24067,7 @@ function fetchIssue2(number, repo) {
|
|
|
23827
24067
|
if (repo) args.push("--repo", repo);
|
|
23828
24068
|
let raw;
|
|
23829
24069
|
try {
|
|
23830
|
-
raw =
|
|
24070
|
+
raw = execFileSync10("gh", args, { encoding: "utf8" });
|
|
23831
24071
|
} catch {
|
|
23832
24072
|
console.error(`Could not fetch issue #${number} with gh issue view`);
|
|
23833
24073
|
process.exit(1);
|
|
@@ -23918,12 +24158,12 @@ function prepareIssueEdit(number, repo, fresh) {
|
|
|
23918
24158
|
}
|
|
23919
24159
|
|
|
23920
24160
|
// src/commands/github/issue/pushIssueBody.ts
|
|
23921
|
-
import { execFileSync as
|
|
24161
|
+
import { execFileSync as execFileSync11 } from "child_process";
|
|
23922
24162
|
function pushIssueBody(number, repo, bodyPath) {
|
|
23923
24163
|
const args = ["issue", "edit", String(number), "--body-file", bodyPath];
|
|
23924
24164
|
if (repo) args.push("--repo", repo);
|
|
23925
24165
|
try {
|
|
23926
|
-
|
|
24166
|
+
execFileSync11("gh", args, { stdio: "inherit" });
|
|
23927
24167
|
} catch {
|
|
23928
24168
|
process.exit(1);
|
|
23929
24169
|
}
|
|
@@ -23983,12 +24223,12 @@ function setIssueParent(number, repo, parentArg) {
|
|
|
23983
24223
|
}
|
|
23984
24224
|
|
|
23985
24225
|
// src/commands/github/issue/viewIssue.ts
|
|
23986
|
-
import { execFileSync as
|
|
24226
|
+
import { execFileSync as execFileSync12 } from "child_process";
|
|
23987
24227
|
function viewIssue(number, repo) {
|
|
23988
24228
|
const args = ["issue", "view", String(number)];
|
|
23989
24229
|
if (repo) args.push("--repo", repo);
|
|
23990
24230
|
try {
|
|
23991
|
-
|
|
24231
|
+
execFileSync12("gh", args, { stdio: "inherit" });
|
|
23992
24232
|
} catch {
|
|
23993
24233
|
process.exit(1);
|
|
23994
24234
|
}
|
|
@@ -24044,7 +24284,7 @@ function registerEditIssue(issueCommand) {
|
|
|
24044
24284
|
}
|
|
24045
24285
|
|
|
24046
24286
|
// src/commands/github/issue/editIssueComment.ts
|
|
24047
|
-
import { execFileSync as
|
|
24287
|
+
import { execFileSync as execFileSync13 } from "child_process";
|
|
24048
24288
|
var USAGE4 = "Usage: assist github issue edit-comment <comment-id> --body <body> [-R <owner>/<repo>]";
|
|
24049
24289
|
async function editIssueComment(commentIdArg, options2) {
|
|
24050
24290
|
const commentId = Number.parseInt(commentIdArg, 10);
|
|
@@ -24071,7 +24311,7 @@ async function editIssueComment(commentIdArg, options2) {
|
|
|
24071
24311
|
];
|
|
24072
24312
|
let raw;
|
|
24073
24313
|
try {
|
|
24074
|
-
raw =
|
|
24314
|
+
raw = execFileSync13("gh", args, {
|
|
24075
24315
|
input: JSON.stringify({ body }),
|
|
24076
24316
|
encoding: "utf8"
|
|
24077
24317
|
});
|
|
@@ -24109,25 +24349,6 @@ function registerEditIssueComment(issueCommand) {
|
|
|
24109
24349
|
);
|
|
24110
24350
|
}
|
|
24111
24351
|
|
|
24112
|
-
// src/commands/github/issue/assignIssueToSelf.ts
|
|
24113
|
-
import { execFileSync as execFileSync13 } from "child_process";
|
|
24114
|
-
function assignIssueToSelf(number, repo) {
|
|
24115
|
-
const args = [
|
|
24116
|
-
"issue",
|
|
24117
|
-
"edit",
|
|
24118
|
-
String(number),
|
|
24119
|
-
"--repo",
|
|
24120
|
-
repo,
|
|
24121
|
-
"--add-assignee",
|
|
24122
|
-
"@me"
|
|
24123
|
-
];
|
|
24124
|
-
try {
|
|
24125
|
-
execFileSync13("gh", args, { stdio: ["ignore", "ignore", "inherit"] });
|
|
24126
|
-
} catch {
|
|
24127
|
-
process.exit(1);
|
|
24128
|
-
}
|
|
24129
|
-
}
|
|
24130
|
-
|
|
24131
24352
|
// src/commands/github/issue/toIssueProjectItem.ts
|
|
24132
24353
|
function toIssueProjectItem(node) {
|
|
24133
24354
|
const project = node?.project;
|
|
@@ -24178,7 +24399,7 @@ function fetchIssueProjectItems(target) {
|
|
|
24178
24399
|
}
|
|
24179
24400
|
|
|
24180
24401
|
// src/commands/github/issue/moveIssueToInProgress.ts
|
|
24181
|
-
var
|
|
24402
|
+
var IN_PROGRESS2 = "in progress";
|
|
24182
24403
|
function boardName(item) {
|
|
24183
24404
|
return `project ${item.projectNumber} (${item.projectTitle})`;
|
|
24184
24405
|
}
|
|
@@ -24189,7 +24410,7 @@ function moveItem(item) {
|
|
|
24189
24410
|
return;
|
|
24190
24411
|
}
|
|
24191
24412
|
const option = statusField.options.find(
|
|
24192
|
-
(candidate) => candidate.name.toLowerCase() ===
|
|
24413
|
+
(candidate) => candidate.name.toLowerCase() === IN_PROGRESS2
|
|
24193
24414
|
);
|
|
24194
24415
|
if (!option) {
|
|
24195
24416
|
const names = statusField.options.map((candidate) => candidate.name);
|
|
@@ -24233,7 +24454,12 @@ function startIssue(numberArg, options2) {
|
|
|
24233
24454
|
}
|
|
24234
24455
|
const { owner, repo } = resolveIssueRepoTarget(options2.repo);
|
|
24235
24456
|
const slug2 = `${owner}/${repo}`;
|
|
24236
|
-
|
|
24457
|
+
try {
|
|
24458
|
+
assignIssueToSelf(number, slug2);
|
|
24459
|
+
} catch (error) {
|
|
24460
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
24461
|
+
process.exit(1);
|
|
24462
|
+
}
|
|
24237
24463
|
console.log(`Assigned ${slug2}#${number} to you`);
|
|
24238
24464
|
moveIssueToInProgress({ owner, repo, number });
|
|
24239
24465
|
}
|
|
@@ -28652,12 +28878,6 @@ function describeAge(timestamp6, now = Date.now()) {
|
|
|
28652
28878
|
return { hours, label: `${Math.floor(hours / 24)}d` };
|
|
28653
28879
|
}
|
|
28654
28880
|
|
|
28655
|
-
// src/commands/prs/status/isDoNotMerge.ts
|
|
28656
|
-
var DO_NOT_MERGE = /^\s*[[(]\s*(do[\s_-]*not\b[^\])]*|dnm)\s*[\])]/i;
|
|
28657
|
-
function isDoNotMerge(title) {
|
|
28658
|
-
return DO_NOT_MERGE.test(title);
|
|
28659
|
-
}
|
|
28660
|
-
|
|
28661
28881
|
// src/commands/prs/status/summariseChecks.ts
|
|
28662
28882
|
var PASSING_CONCLUSIONS = /* @__PURE__ */ new Set(["SUCCESS", "NEUTRAL", "SKIPPED"]);
|
|
28663
28883
|
var PENDING_STATES = /* @__PURE__ */ new Set(["PENDING", "EXPECTED"]);
|
|
@@ -29941,12 +30161,12 @@ import fs27 from "fs";
|
|
|
29941
30161
|
|
|
29942
30162
|
// src/commands/lint/shared.ts
|
|
29943
30163
|
import chalk202 from "chalk";
|
|
29944
|
-
function reportViolations2(violations, checkName2,
|
|
30164
|
+
function reportViolations2(violations, checkName2, errorMessage2, successMessage) {
|
|
29945
30165
|
if (violations.length > 0) {
|
|
29946
30166
|
console.error(chalk202.red(`
|
|
29947
30167
|
${checkName2} failed:
|
|
29948
30168
|
`));
|
|
29949
|
-
console.error(chalk202.red(` ${
|
|
30169
|
+
console.error(chalk202.red(` ${errorMessage2}
|
|
29950
30170
|
`));
|
|
29951
30171
|
for (const violation of violations) {
|
|
29952
30172
|
console.error(chalk202.red(` ${violation.filePath}:${violation.line}`));
|