@staff0rd/assist 0.731.0 → 0.732.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 +2 -2
- package/dist/commands/sessions/web/bundle.js +2 -2
- package/dist/index.js +92 -27
- 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.0",
|
|
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,9 +13779,16 @@ 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
|
|
|
@@ -13838,8 +13854,56 @@ function selectPeerPrs(nodes, viewer, peers) {
|
|
|
13838
13854
|
return selected.sort((a, b) => a.requestedAt.localeCompare(b.requestedAt));
|
|
13839
13855
|
}
|
|
13840
13856
|
|
|
13857
|
+
// src/commands/sessions/web/next/fetchOwnerPeerPrs.ts
|
|
13858
|
+
function uniqueNodes(...results) {
|
|
13859
|
+
const byUrl = /* @__PURE__ */ new Map();
|
|
13860
|
+
for (const node of results.flatMap((result) => result?.nodes ?? []))
|
|
13861
|
+
if (node?.url) byUrl.set(node.url, node);
|
|
13862
|
+
return [...byUrl.values()];
|
|
13863
|
+
}
|
|
13864
|
+
async function fetchOwnerPeerPrs(cwd, owner, peers) {
|
|
13865
|
+
const base = `user:${owner} is:pr is:open archived:false`;
|
|
13866
|
+
const authors = peers.map((peer) => `author:${peer}`).join(" ");
|
|
13867
|
+
const response = await ghJson(cwd, [
|
|
13868
|
+
"api",
|
|
13869
|
+
"graphql",
|
|
13870
|
+
"-f",
|
|
13871
|
+
`query=${ownerPeerPrsQuery}`,
|
|
13872
|
+
"-f",
|
|
13873
|
+
`requested=${base} review-requested:@me`,
|
|
13874
|
+
"-f",
|
|
13875
|
+
`authored=${base} ${authors}`,
|
|
13876
|
+
"-F",
|
|
13877
|
+
`hasPeers=${peers.length > 0}`
|
|
13878
|
+
]);
|
|
13879
|
+
const viewer = response.data?.viewer?.login;
|
|
13880
|
+
if (!viewer || !response.data?.requested)
|
|
13881
|
+
throw new Error("Owner not searchable");
|
|
13882
|
+
const nodes = uniqueNodes(response.data.requested, response.data.authored);
|
|
13883
|
+
const repoOf2 = new Map(
|
|
13884
|
+
nodes.map((node) => [node.url, node.repository?.nameWithOwner ?? owner])
|
|
13885
|
+
);
|
|
13886
|
+
return selectPeerPrs(nodes, viewer, peers).map((pr) => ({
|
|
13887
|
+
...pr,
|
|
13888
|
+
repo: repoOf2.get(pr.url) ?? owner
|
|
13889
|
+
}));
|
|
13890
|
+
}
|
|
13891
|
+
|
|
13892
|
+
// src/commands/sessions/web/next/peerPrsQuery.ts
|
|
13893
|
+
var peerPrsQuery = `query($owner: String!, $name: String!) {
|
|
13894
|
+
viewer { login }
|
|
13895
|
+
repository(owner: $owner, name: $name) {
|
|
13896
|
+
pullRequests(states: OPEN, first: 100, orderBy: { field: CREATED_AT, direction: ASC }) {
|
|
13897
|
+
nodes {
|
|
13898
|
+
${peerPrFields}
|
|
13899
|
+
}
|
|
13900
|
+
}
|
|
13901
|
+
}
|
|
13902
|
+
}`;
|
|
13903
|
+
|
|
13841
13904
|
// src/commands/sessions/web/next/fetchPeerPrs.ts
|
|
13842
13905
|
async function fetchPeerPrs(cwd, repo, peers) {
|
|
13906
|
+
if (isOwnerEntry(repo)) return fetchOwnerPeerPrs(cwd, repo, peers);
|
|
13843
13907
|
const [owner, name] = repo.split("/");
|
|
13844
13908
|
const response = await ghJson(cwd, [
|
|
13845
13909
|
"api",
|
|
@@ -13894,14 +13958,15 @@ async function sectionAcross(repos2, load3, compare) {
|
|
|
13894
13958
|
error: "No GitHub repo to read: set next.repos or select a repo with a GitHub origin."
|
|
13895
13959
|
};
|
|
13896
13960
|
const results = await Promise.allSettled(repos2.map((repo) => load3(repo)));
|
|
13897
|
-
const items2 =
|
|
13961
|
+
const items2 = /* @__PURE__ */ new Map();
|
|
13898
13962
|
const errors = [];
|
|
13899
13963
|
results.forEach((result, index3) => {
|
|
13900
|
-
if (result.status === "fulfilled")
|
|
13964
|
+
if (result.status === "fulfilled")
|
|
13965
|
+
for (const item of result.value) items2.set(item.url, item);
|
|
13901
13966
|
else errors.push(`${repos2[index3]}: ${errorMessage(result.reason)}`);
|
|
13902
13967
|
});
|
|
13903
13968
|
return {
|
|
13904
|
-
items: items2.sort(compare),
|
|
13969
|
+
items: [...items2.values()].sort(compare),
|
|
13905
13970
|
error: errors.length > 0 ? errors.join("\n") : null
|
|
13906
13971
|
};
|
|
13907
13972
|
}
|
|
@@ -28517,10 +28582,10 @@ function describeFetchError(error) {
|
|
|
28517
28582
|
|
|
28518
28583
|
// src/commands/prs/status/fetchRepoPullRequests.ts
|
|
28519
28584
|
import { execSync as execSync47 } from "child_process";
|
|
28520
|
-
var
|
|
28585
|
+
var FIELDS2 = "number,title,url,author,isDraft,createdAt,updatedAt,reviewDecision,latestReviews,statusCheckRollup,mergeable";
|
|
28521
28586
|
function fetchRepoPullRequests(org, repo) {
|
|
28522
28587
|
const output = execSync47(
|
|
28523
|
-
`gh pr list --state open --json ${
|
|
28588
|
+
`gh pr list --state open --json ${FIELDS2} --limit 100 -R ${org}/${repo}`,
|
|
28524
28589
|
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
|
|
28525
28590
|
);
|
|
28526
28591
|
const parsed = JSON.parse(output);
|