@staff0rd/assist 0.731.0 → 0.732.1
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 +2 -2
- package/dist/commands/sessions/web/bundle.js +2 -2
- package/dist/index.js +100 -34
- 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.732.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -12574,8 +12574,8 @@ var nextConfigHelp = [
|
|
|
12574
12574
|
},
|
|
12575
12575
|
{
|
|
12576
12576
|
key: "next.repos",
|
|
12577
|
-
setter: "assist config set next.repos
|
|
12578
|
-
note: "
|
|
12577
|
+
setter: "assist config set next.repos my-org,other/web -g --repo",
|
|
12578
|
+
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)"
|
|
12579
12579
|
}
|
|
12580
12580
|
];
|
|
12581
12581
|
|
|
@@ -13713,24 +13713,38 @@ function ghJson(cwd, args) {
|
|
|
13713
13713
|
return result;
|
|
13714
13714
|
}
|
|
13715
13715
|
|
|
13716
|
+
// src/commands/sessions/web/next/isOwnerEntry.ts
|
|
13717
|
+
function isOwnerEntry(entry) {
|
|
13718
|
+
return !entry.includes("/");
|
|
13719
|
+
}
|
|
13720
|
+
|
|
13716
13721
|
// src/commands/sessions/web/next/fetchAssignedIssues.ts
|
|
13717
|
-
|
|
13722
|
+
var FIELDS = "number,title,url,createdAt,author,labels";
|
|
13723
|
+
function listArgs(entry) {
|
|
13724
|
+
if (isOwnerEntry(entry))
|
|
13725
|
+
return [
|
|
13726
|
+
"search",
|
|
13727
|
+
"issues",
|
|
13728
|
+
"--owner",
|
|
13729
|
+
entry,
|
|
13730
|
+
"--archived=false",
|
|
13731
|
+
"--json",
|
|
13732
|
+
`${FIELDS},repository`
|
|
13733
|
+
];
|
|
13734
|
+
return ["issue", "list", "--repo", entry, "--json", FIELDS];
|
|
13735
|
+
}
|
|
13736
|
+
async function fetchAssignedIssues(cwd, entry) {
|
|
13718
13737
|
const issues = await ghJson(cwd, [
|
|
13719
|
-
|
|
13720
|
-
"list",
|
|
13721
|
-
"--repo",
|
|
13722
|
-
repo,
|
|
13738
|
+
...listArgs(entry),
|
|
13723
13739
|
"--assignee",
|
|
13724
13740
|
"@me",
|
|
13725
13741
|
"--state",
|
|
13726
13742
|
"open",
|
|
13727
13743
|
"--limit",
|
|
13728
|
-
"100"
|
|
13729
|
-
"--json",
|
|
13730
|
-
"number,title,url,createdAt,author,labels"
|
|
13744
|
+
"100"
|
|
13731
13745
|
]);
|
|
13732
13746
|
return issues.map((issue) => ({
|
|
13733
|
-
repo,
|
|
13747
|
+
repo: issue.repository?.nameWithOwner ?? entry,
|
|
13734
13748
|
number: issue.number,
|
|
13735
13749
|
title: issue.title,
|
|
13736
13750
|
url: issue.url,
|
|
@@ -13742,13 +13756,8 @@ async function fetchAssignedIssues(cwd, repo) {
|
|
|
13742
13756
|
}));
|
|
13743
13757
|
}
|
|
13744
13758
|
|
|
13745
|
-
// src/commands/sessions/web/next/
|
|
13746
|
-
var
|
|
13747
|
-
viewer { login }
|
|
13748
|
-
repository(owner: $owner, name: $name) {
|
|
13749
|
-
pullRequests(states: OPEN, first: 100, orderBy: { field: CREATED_AT, direction: ASC }) {
|
|
13750
|
-
nodes {
|
|
13751
|
-
number
|
|
13759
|
+
// src/commands/sessions/web/next/peerPrFields.ts
|
|
13760
|
+
var peerPrFields = `number
|
|
13752
13761
|
title
|
|
13753
13762
|
url
|
|
13754
13763
|
createdAt
|
|
@@ -13770,12 +13779,25 @@ var peerPrsQuery = `query($owner: String!, $name: String!) {
|
|
|
13770
13779
|
requestedReviewer { ... on User { login } }
|
|
13771
13780
|
}
|
|
13772
13781
|
}
|
|
13773
|
-
}
|
|
13774
|
-
|
|
13775
|
-
|
|
13782
|
+
}`;
|
|
13783
|
+
|
|
13784
|
+
// src/commands/sessions/web/next/ownerPeerPrsQuery.ts
|
|
13785
|
+
var ownerPeerPrsQuery = `query($requested: String!, $authored: String!, $hasPeers: Boolean!) {
|
|
13786
|
+
viewer { login }
|
|
13787
|
+
requested: search(query: $requested, type: ISSUE, first: 100) {
|
|
13788
|
+
nodes { ... on PullRequest { repository { nameWithOwner } ${peerPrFields} } }
|
|
13789
|
+
}
|
|
13790
|
+
authored: search(query: $authored, type: ISSUE, first: 100) @include(if: $hasPeers) {
|
|
13791
|
+
nodes { ... on PullRequest { repository { nameWithOwner } ${peerPrFields} } }
|
|
13776
13792
|
}
|
|
13777
13793
|
}`;
|
|
13778
13794
|
|
|
13795
|
+
// src/commands/prs/status/isDoNotMerge.ts
|
|
13796
|
+
var DO_NOT_MERGE = /^\s*[[(]\s*(do[\s_-]*not\b[^\])]*|dnm)\s*[\])]/i;
|
|
13797
|
+
function isDoNotMerge(title) {
|
|
13798
|
+
return DO_NOT_MERGE.test(title);
|
|
13799
|
+
}
|
|
13800
|
+
|
|
13779
13801
|
// src/commands/sessions/web/next/headCommit.ts
|
|
13780
13802
|
function headCommit(node) {
|
|
13781
13803
|
return node.commits?.nodes?.[0]?.commit ?? null;
|
|
@@ -13829,7 +13851,8 @@ function selectPeerPrs(nodes, viewer, peers) {
|
|
|
13829
13851
|
const selected = [];
|
|
13830
13852
|
for (const node of nodes) {
|
|
13831
13853
|
const author = node.author?.login ?? "unknown";
|
|
13832
|
-
if (node.isDraft || sameLogin(author, viewer))
|
|
13854
|
+
if (node.isDraft || isDoNotMerge(node.title) || sameLogin(author, viewer))
|
|
13855
|
+
continue;
|
|
13833
13856
|
const requested = isRequested(node, viewer);
|
|
13834
13857
|
const byPeer = peers.some((peer) => sameLogin(author, peer));
|
|
13835
13858
|
if (!requested && (!byPeer || approvedHead(node, viewer))) continue;
|
|
@@ -13838,8 +13861,56 @@ function selectPeerPrs(nodes, viewer, peers) {
|
|
|
13838
13861
|
return selected.sort((a, b) => a.requestedAt.localeCompare(b.requestedAt));
|
|
13839
13862
|
}
|
|
13840
13863
|
|
|
13864
|
+
// src/commands/sessions/web/next/fetchOwnerPeerPrs.ts
|
|
13865
|
+
function uniqueNodes(...results) {
|
|
13866
|
+
const byUrl = /* @__PURE__ */ new Map();
|
|
13867
|
+
for (const node of results.flatMap((result) => result?.nodes ?? []))
|
|
13868
|
+
if (node?.url) byUrl.set(node.url, node);
|
|
13869
|
+
return [...byUrl.values()];
|
|
13870
|
+
}
|
|
13871
|
+
async function fetchOwnerPeerPrs(cwd, owner, peers) {
|
|
13872
|
+
const base = `user:${owner} is:pr is:open archived:false`;
|
|
13873
|
+
const authors = peers.map((peer) => `author:${peer}`).join(" ");
|
|
13874
|
+
const response = await ghJson(cwd, [
|
|
13875
|
+
"api",
|
|
13876
|
+
"graphql",
|
|
13877
|
+
"-f",
|
|
13878
|
+
`query=${ownerPeerPrsQuery}`,
|
|
13879
|
+
"-f",
|
|
13880
|
+
`requested=${base} review-requested:@me`,
|
|
13881
|
+
"-f",
|
|
13882
|
+
`authored=${base} ${authors}`,
|
|
13883
|
+
"-F",
|
|
13884
|
+
`hasPeers=${peers.length > 0}`
|
|
13885
|
+
]);
|
|
13886
|
+
const viewer = response.data?.viewer?.login;
|
|
13887
|
+
if (!viewer || !response.data?.requested)
|
|
13888
|
+
throw new Error("Owner not searchable");
|
|
13889
|
+
const nodes = uniqueNodes(response.data.requested, response.data.authored);
|
|
13890
|
+
const repoOf2 = new Map(
|
|
13891
|
+
nodes.map((node) => [node.url, node.repository?.nameWithOwner ?? owner])
|
|
13892
|
+
);
|
|
13893
|
+
return selectPeerPrs(nodes, viewer, peers).map((pr) => ({
|
|
13894
|
+
...pr,
|
|
13895
|
+
repo: repoOf2.get(pr.url) ?? owner
|
|
13896
|
+
}));
|
|
13897
|
+
}
|
|
13898
|
+
|
|
13899
|
+
// src/commands/sessions/web/next/peerPrsQuery.ts
|
|
13900
|
+
var peerPrsQuery = `query($owner: String!, $name: String!) {
|
|
13901
|
+
viewer { login }
|
|
13902
|
+
repository(owner: $owner, name: $name) {
|
|
13903
|
+
pullRequests(states: OPEN, first: 100, orderBy: { field: CREATED_AT, direction: ASC }) {
|
|
13904
|
+
nodes {
|
|
13905
|
+
${peerPrFields}
|
|
13906
|
+
}
|
|
13907
|
+
}
|
|
13908
|
+
}
|
|
13909
|
+
}`;
|
|
13910
|
+
|
|
13841
13911
|
// src/commands/sessions/web/next/fetchPeerPrs.ts
|
|
13842
13912
|
async function fetchPeerPrs(cwd, repo, peers) {
|
|
13913
|
+
if (isOwnerEntry(repo)) return fetchOwnerPeerPrs(cwd, repo, peers);
|
|
13843
13914
|
const [owner, name] = repo.split("/");
|
|
13844
13915
|
const response = await ghJson(cwd, [
|
|
13845
13916
|
"api",
|
|
@@ -13894,14 +13965,15 @@ async function sectionAcross(repos2, load3, compare) {
|
|
|
13894
13965
|
error: "No GitHub repo to read: set next.repos or select a repo with a GitHub origin."
|
|
13895
13966
|
};
|
|
13896
13967
|
const results = await Promise.allSettled(repos2.map((repo) => load3(repo)));
|
|
13897
|
-
const items2 =
|
|
13968
|
+
const items2 = /* @__PURE__ */ new Map();
|
|
13898
13969
|
const errors = [];
|
|
13899
13970
|
results.forEach((result, index3) => {
|
|
13900
|
-
if (result.status === "fulfilled")
|
|
13971
|
+
if (result.status === "fulfilled")
|
|
13972
|
+
for (const item of result.value) items2.set(item.url, item);
|
|
13901
13973
|
else errors.push(`${repos2[index3]}: ${errorMessage(result.reason)}`);
|
|
13902
13974
|
});
|
|
13903
13975
|
return {
|
|
13904
|
-
items: items2.sort(compare),
|
|
13976
|
+
items: [...items2.values()].sort(compare),
|
|
13905
13977
|
error: errors.length > 0 ? errors.join("\n") : null
|
|
13906
13978
|
};
|
|
13907
13979
|
}
|
|
@@ -28517,10 +28589,10 @@ function describeFetchError(error) {
|
|
|
28517
28589
|
|
|
28518
28590
|
// src/commands/prs/status/fetchRepoPullRequests.ts
|
|
28519
28591
|
import { execSync as execSync47 } from "child_process";
|
|
28520
|
-
var
|
|
28592
|
+
var FIELDS2 = "number,title,url,author,isDraft,createdAt,updatedAt,reviewDecision,latestReviews,statusCheckRollup,mergeable";
|
|
28521
28593
|
function fetchRepoPullRequests(org, repo) {
|
|
28522
28594
|
const output = execSync47(
|
|
28523
|
-
`gh pr list --state open --json ${
|
|
28595
|
+
`gh pr list --state open --json ${FIELDS2} --limit 100 -R ${org}/${repo}`,
|
|
28524
28596
|
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
|
|
28525
28597
|
);
|
|
28526
28598
|
const parsed = JSON.parse(output);
|
|
@@ -28587,12 +28659,6 @@ function describeAge(timestamp6, now = Date.now()) {
|
|
|
28587
28659
|
return { hours, label: `${Math.floor(hours / 24)}d` };
|
|
28588
28660
|
}
|
|
28589
28661
|
|
|
28590
|
-
// src/commands/prs/status/isDoNotMerge.ts
|
|
28591
|
-
var DO_NOT_MERGE = /^\s*[[(]\s*(do[\s_-]*not\b[^\])]*|dnm)\s*[\])]/i;
|
|
28592
|
-
function isDoNotMerge(title) {
|
|
28593
|
-
return DO_NOT_MERGE.test(title);
|
|
28594
|
-
}
|
|
28595
|
-
|
|
28596
28662
|
// src/commands/prs/status/summariseChecks.ts
|
|
28597
28663
|
var PASSING_CONCLUSIONS = /* @__PURE__ */ new Set(["SUCCESS", "NEUTRAL", "SKIPPED"]);
|
|
28598
28664
|
var PENDING_STATES = /* @__PURE__ */ new Set(["PENDING", "EXPECTED"]);
|