@d3lm/pr-stats 0.1.2 → 0.2.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/tui.mjs ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
3
+ import { fileURLToPath } from "node:url";
4
+ const MIN_NODE_MAJOR = 26;
5
+ const MIN_NODE_MINOR = 4;
6
+ const appUrl = new URL("tui-app.mjs", import.meta.url);
7
+ function reexec(command, args, onSpawnError) {
8
+ const child = spawn(command, [...args, ...process.argv.slice(2)], { stdio: "inherit" });
9
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
10
+ process.on(signal, () => child.kill(signal));
11
+ }
12
+ child.on("error", (error) => {
13
+ if (onSpawnError !== void 0) {
14
+ onSpawnError(error);
15
+ return;
16
+ }
17
+ console.error(`pr-stats failed to start ${command} (${error.code ?? error.message})`);
18
+ process.exit(1);
19
+ });
20
+ child.on("exit", (code, signal) => {
21
+ process.exit(code ?? (signal !== null ? 1 : 0));
22
+ });
23
+ }
24
+ async function ffiAvailable() {
25
+ try {
26
+ await import("node:ffi");
27
+ return true;
28
+ } catch {
29
+ return false;
30
+ }
31
+ }
32
+ if (process.versions.bun) {
33
+ await import(appUrl.href);
34
+ } else {
35
+ const [major = 0, minor = 0] = process.versions.node.split(".").map((part) => Number.parseInt(part, 10));
36
+ if (major < MIN_NODE_MAJOR || major === MIN_NODE_MAJOR && minor < MIN_NODE_MINOR) {
37
+ reexec("bun", [fileURLToPath(appUrl)], () => {
38
+ console.error(
39
+ `pr-stats needs Node.js ${MIN_NODE_MAJOR}.${MIN_NODE_MINOR} or later, or Bun 1.3 or later. You are running Node.js ${process.versions.node} and no bun binary was found.`
40
+ );
41
+ process.exit(1);
42
+ });
43
+ } else if (await ffiAvailable()) {
44
+ await import(appUrl.href);
45
+ } else {
46
+ reexec(process.execPath, ["--experimental-ffi", "--disable-warning=ExperimentalWarning", fileURLToPath(appUrl)]);
47
+ }
48
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@d3lm/pr-stats",
3
- "version": "0.1.2",
4
- "description": "GitHub PR stats from the command line, via the gh CLI or an access token",
3
+ "version": "0.2.0",
4
+ "description": "GitHub PR stats in an interactive terminal UI, via the gh CLI or an access token",
5
5
  "type": "module",
6
6
  "author": "Dominic Elm",
7
7
  "license": "MIT",
@@ -15,10 +15,11 @@
15
15
  "pull-request",
16
16
  "review",
17
17
  "stats",
18
- "cli"
18
+ "tui",
19
+ "terminal"
19
20
  ],
20
21
  "bin": {
21
- "pr-stats": "./dist/index.mjs"
22
+ "pr-stats": "./dist/tui.mjs"
22
23
  },
23
24
  "files": [
24
25
  "dist"
@@ -30,12 +31,27 @@
30
31
  "access": "public"
31
32
  },
32
33
  "devDependencies": {
33
- "esbuild": "^0.28.2"
34
+ "@types/asciichart": "^1.5.8",
35
+ "@types/bun": "^1.4.0",
36
+ "@types/node": "^26.3.0",
37
+ "@types/react": "^19.2.18",
38
+ "esbuild": "^0.28.2",
39
+ "typescript": "^7.0.2"
34
40
  },
35
41
  "dependencies": {
36
- "asciichart": "^1.5.25"
42
+ "@opentui/core": "^0.5.8",
43
+ "@opentui/react": "^0.5.8",
44
+ "asciichart": "^1.5.25",
45
+ "react": "^19.2.8"
37
46
  },
38
47
  "scripts": {
39
- "build": "esbuild index.mjs --bundle --platform=node --format=esm --target=node20 --outfile=dist/index.mjs"
48
+ "build": "pnpm build:app && pnpm build:bin",
49
+ "build:app": "esbuild tui/main.tsx --bundle --platform=node --format=esm --target=esnext --jsx=automatic --jsx-import-source=@opentui/react --external:@opentui/core --external:@opentui/react --external:react --outfile=dist/tui-app.mjs",
50
+ "build:bin": "esbuild tui/launch.ts --platform=node --format=esm --target=node20 --outfile=dist/tui.mjs",
51
+ "tui": "bun tui/main.tsx",
52
+ "tui:node": "pnpm build && node dist/tui.mjs",
53
+ "check": "tsc --noEmit",
54
+ "lint": "oxlint . && eslint --cache .",
55
+ "test": "bun test"
40
56
  }
41
57
  }