@theholocron/holocron-plugin-github 5.0.0-alpha.489 → 5.0.0-alpha.490

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.d.mts CHANGED
@@ -193,7 +193,10 @@ export declare class GitHubProjects implements Projects {
193
193
  private createField;
194
194
  private createView;
195
195
  private updateView;
196
- /** The board's issues and pull requests with their status, whether they are open and their open blockers. */
196
+ /**
197
+ * The board's issues and pull requests with their status, whether they are open and their open blockers; an issue also
198
+ * carries the pull requests that close it, each with the aggregate `ci / Required checks` state of its head commit.
199
+ */
197
200
  items(_owner: string, board: BoardSummary, template: BoardTemplate): Promise<BoardItem[]>;
198
201
  /** Puts an item in a status; `transitioned` is false when it already is there. */
199
202
  setStatus(_owner: string, board: BoardSummary, key: string, status: string): Promise<LifecycleResult>;
package/dist/index.mjs CHANGED
@@ -843,6 +843,47 @@ function parseIssueNumber(key, owner, repoName) {
843
843
  if (!/^\d+$/.test(num)) throw new Error(`Invalid GitHub issue key "${key}" — expected #N or N.`);
844
844
  return parseInt(num, 10);
845
845
  }
846
+ /** The GraphQL selection that reads an issue's closing pull requests and the aggregate check on each head commit. */
847
+ const CLOSING_PULL_REQUESTS = `closedByPullRequestsReferences(first: 5, includeClosedPrs: true) { nodes {
848
+ number state isDraft repository { nameWithOwner }
849
+ commits(last: 1) { nodes { commit { checkSuites(first: 50) { nodes {
850
+ checkRuns(first: 5, filterBy: { checkName: "ci / Required checks" }) { nodes { databaseId status conclusion startedAt } }
851
+ } } } } }
852
+ } }`;
853
+ const FAILED = /* @__PURE__ */ new Set([
854
+ "FAILURE",
855
+ "TIMED_OUT",
856
+ "STARTUP_FAILURE",
857
+ "ACTION_REQUIRED",
858
+ "STALE"
859
+ ]);
860
+ /**
861
+ * The state of the aggregate check from the runs of that name on one commit. Only the newest run counts (latest
862
+ * `startedAt`, then id), so a cancelled first batch or a re-run that went green does not hold the verdict red. A run
863
+ * that is not finished, or that was cancelled, is `pending`; one with no verdict (neutral, skipped) or none posted is `none`.
864
+ */
865
+ function aggregateChecks(runs) {
866
+ const newest = [...runs].sort((a, b) => (b.startedAt ?? "").localeCompare(a.startedAt ?? "") || b.databaseId - a.databaseId)[0];
867
+ if (!newest) return "none";
868
+ if (newest.status !== "COMPLETED") return "pending";
869
+ if (newest.conclusion === "SUCCESS") return "success";
870
+ if (newest.conclusion && FAILED.has(newest.conclusion)) return "failure";
871
+ if (newest.conclusion === "CANCELLED") return "pending";
872
+ return "none";
873
+ }
874
+ /** The neutral pull requests an issue is closed by; only an open one has its checks read, the others are `none`. */
875
+ function toBoardPullRequests(nodes, keyOf) {
876
+ return nodes.map((pr) => {
877
+ const state = pr.state === "OPEN" ? "open" : pr.state === "MERGED" ? "merged" : "closed";
878
+ const runs = (pr.commits?.nodes ?? []).flatMap((c) => c.commit.checkSuites.nodes.flatMap((suite) => suite.checkRuns.nodes));
879
+ return {
880
+ key: keyOf(pr.repository.nameWithOwner, pr.number),
881
+ state,
882
+ draft: pr.isDraft,
883
+ checks: state === "open" ? aggregateChecks(runs) : "none"
884
+ };
885
+ });
886
+ }
846
887
  // src/capabilities/projects.ts
847
888
  /** The name of the single select field that holds an item's status. */
848
889
  const STATUS_FIELD = "Status";
@@ -878,7 +919,7 @@ const ITEMS_QUERY = `query($id: ID!, $after: String) { node(id: $id) { ... on Pr
878
919
  fieldValues(first: 30) { nodes { ... on ProjectV2ItemFieldSingleSelectValue { name field { ... on ProjectV2FieldCommon { name } } } } }
879
920
  content {
880
921
  __typename
881
- ... on Issue { id number title state repository { nameWithOwner } blockedBy(first: 50) { nodes { number state repository { nameWithOwner } } } }
922
+ ... on Issue { id number title state repository { nameWithOwner } blockedBy(first: 50) { nodes { number state repository { nameWithOwner } } } ${CLOSING_PULL_REQUESTS} }
882
923
  ... on PullRequest { id number title state repository { nameWithOwner } }
883
924
  }
884
925
  }
@@ -1166,7 +1207,10 @@ var GitHubProjects = class {
1166
1207
  filter: change.filter
1167
1208
  });
1168
1209
  }
1169
- /** The board's issues and pull requests with their status, whether they are open and their open blockers. */
1210
+ /**
1211
+ * The board's issues and pull requests with their status, whether they are open and their open blockers; an issue also
1212
+ * carries the pull requests that close it, each with the aggregate `ci / Required checks` state of its head commit.
1213
+ */
1170
1214
  async items(_owner, board, template) {
1171
1215
  const categories = new Map(template.statuses.map((s) => [s.name, s.category]));
1172
1216
  return (await this.fetchItems(board.id)).map((i) => {
@@ -1180,7 +1224,8 @@ var GitHubProjects = class {
1180
1224
  ...status ? { status } : {},
1181
1225
  ...category ? { category } : {},
1182
1226
  blockedBy: i.blockers.map((b) => this.keyOf(b.repo, b.number)),
1183
- ...priority ? { priority } : {}
1227
+ ...priority ? { priority } : {},
1228
+ ...i.closing ? { pullRequests: toBoardPullRequests(i.closing, (r, n) => this.keyOf(r, n)) } : {}
1184
1229
  };
1185
1230
  });
1186
1231
  }
@@ -1400,7 +1445,8 @@ var GitHubProjects = class {
1400
1445
  blockers: (c.blockedBy?.nodes ?? []).filter((b) => b.state === "OPEN").map((b) => ({
1401
1446
  repo: b.repository.nameWithOwner,
1402
1447
  number: b.number
1403
- }))
1448
+ })),
1449
+ ...c.closedByPullRequestsReferences ? { closing: c.closedByPullRequestsReferences.nodes } : {}
1404
1450
  });
1405
1451
  }
1406
1452
  if (!page.pageInfo.hasNextPage) return items;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-github",
3
- "version": "5.0.0-alpha.489",
3
+ "version": "5.0.0-alpha.490",
4
4
  "description": "Holocron plugin for GitHub. Implements source, ci, secrets, environments, and issues capabilities against the GitHub REST API.",
5
5
  "keywords": [
6
6
  "ci",
@@ -44,21 +44,21 @@
44
44
  "tsx": "4.23.15",
45
45
  "typescript": "^5.9.3",
46
46
  "vitest": "^5.1.0",
47
+ "@theholocron/cli": "5.0.0-alpha.490",
47
48
  "@theholocron/eslint-config": "^8.9.0-alpha.21",
48
- "@theholocron/fs-utils": "^1.17.0-alpha.5",
49
+ "@theholocron/github-client": "^1.58.0-alpha.42",
50
+ "@theholocron/http-client": "^1.58.0-alpha.42",
49
51
  "@theholocron/misc-utils": "^1.17.0-alpha.5",
50
- "@theholocron/cli": "5.0.0-alpha.489",
51
- "@theholocron/tsconfig": "^8.9.0-alpha.21",
52
52
  "@theholocron/tsdown-config": "^8.9.0-alpha.21",
53
- "@theholocron/vitest-config": "^8.9.0-alpha.21",
54
- "@theholocron/github-client": "^1.58.0-alpha.42",
55
- "@theholocron/http-client": "^1.58.0-alpha.42"
53
+ "@theholocron/fs-utils": "^1.17.0-alpha.5",
54
+ "@theholocron/tsconfig": "^8.9.0-alpha.21",
55
+ "@theholocron/vitest-config": "^8.9.0-alpha.21"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "@theholocron/fs-utils": "^1.16.0",
59
59
  "@theholocron/github-client": "^1.58.0",
60
60
  "@theholocron/misc-utils": "^1.16.0",
61
- "@theholocron/cli": "5.0.0-alpha.489"
61
+ "@theholocron/cli": "5.0.0-alpha.490"
62
62
  },
63
63
  "engines": {
64
64
  "node": ">=22"