@staff0rd/assist 0.813.0 → 0.814.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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.813.0",
9
+ version: "0.814.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -15827,6 +15827,87 @@ async function prStatus(req, res) {
15827
15827
  respondJson(res, 200, { pr });
15828
15828
  }
15829
15829
 
15830
+ // src/commands/sessions/web/releases/toReleaseCompareCommit.ts
15831
+ function toReleaseCompareCommit({
15832
+ sha,
15833
+ commit: commit2
15834
+ }) {
15835
+ return {
15836
+ sha,
15837
+ subject: commit2?.message?.split("\n")[0] ?? null,
15838
+ author: commit2?.author?.name ?? null,
15839
+ date: commit2?.committer?.date ?? null
15840
+ };
15841
+ }
15842
+
15843
+ // src/commands/sessions/web/releases/newestCommits.ts
15844
+ var PAGE_SIZE = 50;
15845
+ function comparePage(cwd, repo, range, page) {
15846
+ return ghJson(cwd, [
15847
+ "api",
15848
+ `repos/${repo}/compare/${range}?per_page=${PAGE_SIZE}&page=${page}`,
15849
+ "--jq",
15850
+ "{total_commits, commits: [.commits[] | {sha, commit}]}"
15851
+ ]);
15852
+ }
15853
+ async function newestCommits(cwd, repo, range) {
15854
+ const first = await comparePage(cwd, repo, range, 1);
15855
+ const total = first.total_commits;
15856
+ if (total <= PAGE_SIZE)
15857
+ return { total, commits: first.commits.map(toReleaseCompareCommit) };
15858
+ const last = Math.ceil(total / PAGE_SIZE);
15859
+ const tail = await Promise.all(
15860
+ [last - 1, last].map(
15861
+ (page) => page === 1 ? first : comparePage(cwd, repo, range, page)
15862
+ )
15863
+ );
15864
+ const commits2 = tail.flatMap((page) => page.commits).slice(-PAGE_SIZE);
15865
+ return { total, commits: commits2.map(toReleaseCompareCommit) };
15866
+ }
15867
+
15868
+ // src/commands/sessions/web/releases/compareCommits.ts
15869
+ async function compareCommits(cwd, repo, base, head) {
15870
+ if (!base) {
15871
+ const commit2 = await ghJson(cwd, [
15872
+ "api",
15873
+ `repos/${repo}/commits/${head}`,
15874
+ "--jq",
15875
+ "{sha, commit}"
15876
+ ]);
15877
+ return { total: 1, commits: [toReleaseCompareCommit(commit2)] };
15878
+ }
15879
+ const { total, commits: commits2 } = await newestCommits(
15880
+ cwd,
15881
+ repo,
15882
+ `${base}...${head}`
15883
+ );
15884
+ return { total, commits: commits2.reverse() };
15885
+ }
15886
+
15887
+ // src/commands/sessions/web/releases/releasesCompare.ts
15888
+ async function releasesCompare(req, res) {
15889
+ const cwd = getCwdParam(req, res);
15890
+ if (!cwd) return;
15891
+ const params = new URL(req.url ?? "/", "http://localhost").searchParams;
15892
+ const repo = params.get("repo");
15893
+ const head = params.get("head");
15894
+ if (!repo || !head) {
15895
+ respondJson(res, 400, { error: "Missing repo or head" });
15896
+ return;
15897
+ }
15898
+ try {
15899
+ respondJson(
15900
+ res,
15901
+ 200,
15902
+ await compareCommits(cwd, repo, params.get("base"), head)
15903
+ );
15904
+ } catch (error) {
15905
+ respondJson(res, 502, {
15906
+ error: error instanceof Error ? error.message : "gh compare failed"
15907
+ });
15908
+ }
15909
+ }
15910
+
15830
15911
  // src/commands/sessions/web/releases/releasesConfigured.ts
15831
15912
  function releasesConfigured(req, res) {
15832
15913
  const cwd = getCwdParam(req, res);
@@ -18002,6 +18083,7 @@ var routes2 = {
18002
18083
  "GET /api/news/nav": newsNavConfig,
18003
18084
  "GET /api/releases/state": releasesState,
18004
18085
  "GET /api/releases/configured": releasesConfigured,
18086
+ "GET /api/releases/compare": releasesCompare,
18005
18087
  "GET /api/usage/history": listUsageHistory,
18006
18088
  "GET /api/usage/items": listUsageItems,
18007
18089
  "GET /api/backups/list": getBackups,
@@ -29016,10 +29098,10 @@ function printPr(pr) {
29016
29098
  }
29017
29099
 
29018
29100
  // src/commands/prs/prs/displayPaginated.ts
29019
- var PAGE_SIZE = 10;
29101
+ var PAGE_SIZE2 = 10;
29020
29102
  function getPageSlice(pullRequests, page) {
29021
- const start2 = page * PAGE_SIZE;
29022
- return pullRequests.slice(start2, start2 + PAGE_SIZE);
29103
+ const start2 = page * PAGE_SIZE2;
29104
+ return pullRequests.slice(start2, start2 + PAGE_SIZE2);
29023
29105
  }
29024
29106
  function pageHeader(page, totalPages, total) {
29025
29107
  return `
@@ -29063,7 +29145,7 @@ async function promptNavigation(currentPage, totalPages) {
29063
29145
  return parseAction(action);
29064
29146
  }
29065
29147
  function computeTotalPages(count8) {
29066
- return Math.ceil(count8 / PAGE_SIZE);
29148
+ return Math.ceil(count8 / PAGE_SIZE2);
29067
29149
  }
29068
29150
  async function navigateAndDisplay(pullRequests, totalPages, currentPage) {
29069
29151
  const delta = await promptNavigation(currentPage, totalPages);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.813.0",
3
+ "version": "0.814.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {