@stacksjs/github 0.70.73 → 0.70.74

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.
Files changed (2) hide show
  1. package/dist/runs.js +5 -7
  2. package/package.json +2 -2
package/dist/runs.js CHANGED
@@ -4,13 +4,12 @@ async function fillLatestCommit(base, owner, name, branch) {
4
4
  const res = await ghFetch(`${GITHUB_API}/repos/${owner}/${name}/commits?sha=${branch}&per_page=1`);
5
5
  if (!res.ok)
6
6
  return;
7
- const commits = await res.json();
8
- if (commits.length === 0)
7
+ const commits = await res.json(), [c] = commits;
8
+ if (!c)
9
9
  return;
10
- const c = commits[0];
11
10
  base.commitSha = c.sha.slice(0, 7);
12
11
  base.commitMessage = c.commit.message.split(`
13
- `)[0];
12
+ `)[0] ?? null;
14
13
  base.commitUrl = `https://github.com/${owner}/${name}/commit/${c.sha}`;
15
14
  base.commitAuthor = c.commit.author?.name ?? c.author?.login ?? null;
16
15
  base.updatedAt = c.commit.author?.date ?? null;
@@ -56,12 +55,11 @@ export async function fetchRepoStatus(owner, name, defaultBranch) {
56
55
  await fillLatestCommit(base, owner, name, defaultBranch);
57
56
  return base;
58
57
  }
59
- const data = await res.json();
60
- if (!data.workflow_runs || data.workflow_runs.length === 0) {
58
+ const data = await res.json(), [run] = data.workflow_runs ?? [];
59
+ if (!run) {
61
60
  await fillLatestCommit(base, owner, name, defaultBranch);
62
61
  return base;
63
62
  }
64
- const run = data.workflow_runs[0];
65
63
  base.workflowName = run.name;
66
64
  base.commitSha = run.head_sha.slice(0, 7);
67
65
  base.commitMessage = run.head_commit?.message.split(`
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/github",
3
3
  "type": "module",
4
- "version": "0.70.73",
4
+ "version": "0.70.74",
5
5
  "description": "GitHub API client used by Stacks framework features (dashboard CI surface, notifications, runner alerts).",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -46,7 +46,7 @@
46
46
  "prepublishOnly": "bun run build"
47
47
  },
48
48
  "devDependencies": {
49
- "better-dx": "^0.2.12"
49
+ "better-dx": "^0.2.16"
50
50
  },
51
51
  "sideEffects": false
52
52
  }