@kud/gh-pr-health 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Erwann Mest
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # @kud/gh-pr-health
2
+
3
+ Checks, reviews and merge state for a GitHub PR in the terminal — a thin CLI over
4
+ [`@kud/gh`](../gh) + [`@kud/gh-ink`](../gh-ink).
5
+
6
+ ## Install
7
+
8
+ ```sh
9
+ npm install -g @kud/gh-pr-health
10
+ ```
11
+
12
+ Requires the [`gh`](https://cli.github.com) CLI, authenticated.
13
+
14
+ ## Usage
15
+
16
+ ```sh
17
+ gh-pr-health # the current branch's PR
18
+ gh-pr-health owner/repo#123 # a specific PR
19
+ gh-pr-health --retrigger # re-fire the Jenkins PR-builder webhook (headless)
20
+ ```
21
+
22
+ `↑↓` move · `↵` open the selected check · `r` retrigger failed CI · `m` merge
23
+ (with confirm) · `q` quit.
24
+
25
+ ## Licence
26
+
27
+ MIT © Erwann Mest
package/dist/index.js ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.tsx
4
+ import { useCallback, useEffect, useState } from "react";
5
+ import { render, Box, Text, useApp, useInput } from "ink";
6
+ import { execa } from "execa";
7
+ import { colors } from "@kud/ink-ui";
8
+ import {
9
+ fetchHealth,
10
+ resolveCurrentPr,
11
+ retriggerJenkinsWebhook
12
+ } from "@kud/gh";
13
+ import { HealthPanel } from "@kud/gh-ink";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ var parseRef = (arg) => {
16
+ if (!arg) return null;
17
+ const m = arg.match(/^([^/\s]+\/[^/#\s]+)[#\s](\d+)$/);
18
+ return m ? { repo: m[1], number: Number(m[2]) } : null;
19
+ };
20
+ var openUrl = (url) => {
21
+ if (url) void execa("open", [url]).catch(() => {
22
+ });
23
+ };
24
+ var App = ({ target }) => {
25
+ const { exit } = useApp();
26
+ const [data, setData] = useState(null);
27
+ const [error, setError] = useState(null);
28
+ const load = useCallback(() => {
29
+ fetchHealth(target.repo, target.number).then((d) => {
30
+ setData(d);
31
+ setError(null);
32
+ }).catch((e) => setError(e.message));
33
+ }, [target]);
34
+ useEffect(load, [load]);
35
+ useInput((input) => {
36
+ if (input === "q") exit();
37
+ });
38
+ return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
39
+ /* @__PURE__ */ jsxs(Box, { children: [
40
+ /* @__PURE__ */ jsxs(Text, { bold: true, color: colors.accent, children: [
41
+ target.repo,
42
+ " #",
43
+ target.number
44
+ ] }),
45
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: " \xB7 health" })
46
+ ] }),
47
+ /* @__PURE__ */ jsx(
48
+ HealthPanel,
49
+ {
50
+ repo: target.repo,
51
+ number: target.number,
52
+ data,
53
+ error,
54
+ reload: load,
55
+ onOpenCheck: (c) => openUrl(c.detailsUrl ?? c.targetUrl ?? "")
56
+ }
57
+ ),
58
+ /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2191\u2193 move \xB7 \u21B5 open check \xB7 r retrigger CI \xB7 m merge \xB7 q quit" }) })
59
+ ] });
60
+ };
61
+ var main = async () => {
62
+ const args = process.argv.slice(2);
63
+ const arg = args.find((a) => !a.startsWith("-"));
64
+ const target = parseRef(arg) ?? await resolveCurrentPr().then((pr) => ({ repo: pr.repo, number: pr.number })).catch(() => null);
65
+ if (!target) {
66
+ console.error(
67
+ "\u2717 No PR found \u2014 run inside a repo on a PR branch, or pass owner/repo#123"
68
+ );
69
+ process.exit(1);
70
+ }
71
+ if (args.includes("--retrigger")) {
72
+ try {
73
+ const { deliveryId } = await retriggerJenkinsWebhook(target.repo);
74
+ console.log(`\u2713 CI retriggered on ${target.repo} (delivery ${deliveryId})`);
75
+ } catch (e) {
76
+ console.error(`\u2717 ${e.message}`);
77
+ process.exit(1);
78
+ }
79
+ return;
80
+ }
81
+ render(/* @__PURE__ */ jsx(App, { target }), { alternateScreen: true });
82
+ };
83
+ void main();
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@kud/gh-pr-health",
3
+ "version": "0.1.0",
4
+ "description": "Checks, reviews and merge state for a GitHub PR in the terminal.",
5
+ "type": "module",
6
+ "bin": {
7
+ "gh-pr-health": "dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "engines": {
13
+ "node": ">=20"
14
+ },
15
+ "scripts": {
16
+ "build": "tsup",
17
+ "dev": "tsup --watch",
18
+ "typecheck": "tsc --noEmit",
19
+ "prepublishOnly": "npm run build"
20
+ },
21
+ "keywords": [
22
+ "github",
23
+ "pull-request",
24
+ "ci",
25
+ "cli",
26
+ "ink"
27
+ ],
28
+ "author": "Erwann Mest <m@kud.io>",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/kud/gh",
33
+ "directory": "packages/gh-pr-health"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "dependencies": {
39
+ "@kud/gh": "0.1.0",
40
+ "@kud/gh-ink": "0.1.0",
41
+ "@kud/ink-ui": "0.8.0",
42
+ "execa": "9.6.1",
43
+ "ink": "7.1.0",
44
+ "react": "19.2.7"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "22.20.1",
48
+ "@types/react": "19.2.17",
49
+ "tsup": "8.5.1",
50
+ "typescript": "5.9.3"
51
+ }
52
+ }