@d3lm/pr-stats 0.2.3 → 0.2.5
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-app.mjs +41 -37
- package/package.json +4 -1
package/dist/tui-app.mjs
CHANGED
|
@@ -135,8 +135,8 @@ import { createCliRenderer } from "@opentui/core";
|
|
|
135
135
|
import { createRoot } from "@opentui/react";
|
|
136
136
|
|
|
137
137
|
// src/tui/App.tsx
|
|
138
|
-
import { useKeyboard, useTerminalDimensions as useTerminalDimensions3 } from "@opentui/react";
|
|
139
|
-
import { useEffect as useEffect6, useReducer, useRef as useRef5, useState as useState4 } from "react";
|
|
138
|
+
import { useKeyboard, useRenderer as useRenderer2, useTerminalDimensions as useTerminalDimensions3 } from "@opentui/react";
|
|
139
|
+
import { useEffect as useEffect6, useMemo as useMemo2, useReducer, useRef as useRef5, useState as useState4 } from "react";
|
|
140
140
|
|
|
141
141
|
// src/settings.ts
|
|
142
142
|
import { readFileSync as readFileSync2, rmSync as rmSync2 } from "node:fs";
|
|
@@ -1178,7 +1178,10 @@ function Placeholder({
|
|
|
1178
1178
|
}
|
|
1179
1179
|
function LoadProgress({ load }) {
|
|
1180
1180
|
if (!load.total) {
|
|
1181
|
-
return /* @__PURE__ */
|
|
1181
|
+
return /* @__PURE__ */ jsxs4("box", { flexDirection: "row", columnGap: 1, children: [
|
|
1182
|
+
/* @__PURE__ */ jsx5("text", { fg: theme.muted, children: loadLabel(load) }),
|
|
1183
|
+
/* @__PURE__ */ jsx5(Spinner, {})
|
|
1184
|
+
] });
|
|
1182
1185
|
}
|
|
1183
1186
|
const done = load.done ?? 0;
|
|
1184
1187
|
const cells = Math.min(done / load.total, 1) * BAR_WIDTH;
|
|
@@ -1196,7 +1199,7 @@ function LoadProgress({ load }) {
|
|
|
1196
1199
|
] });
|
|
1197
1200
|
}
|
|
1198
1201
|
function loadLabel(load) {
|
|
1199
|
-
return load.phase === "search" ? "searching PRs
|
|
1202
|
+
return load.phase === "search" ? "searching PRs" : "fetching PR details";
|
|
1200
1203
|
}
|
|
1201
1204
|
|
|
1202
1205
|
// src/tui/components/QueuePanel.tsx
|
|
@@ -4008,7 +4011,10 @@ function buildHeatmapCard({ title, subtitle, grid, columns, legend }) {
|
|
|
4008
4011
|
});
|
|
4009
4012
|
const columnWidths = columns.map((column) => column.label.length + 2);
|
|
4010
4013
|
const header = [
|
|
4011
|
-
{
|
|
4014
|
+
{
|
|
4015
|
+
text: ` ${["00 03", "06 09", "12 15", "18 21"].map((label) => label.padEnd(12)).join(" ")}`,
|
|
4016
|
+
fg: theme.dim
|
|
4017
|
+
},
|
|
4012
4018
|
{ text: columns.map((column, i) => column.label.padStart(columnWidths[i])).join(""), fg: theme.dim }
|
|
4013
4019
|
];
|
|
4014
4020
|
const lines = [header];
|
|
@@ -5316,37 +5322,32 @@ function openInBrowser(url, onError) {
|
|
|
5316
5322
|
}
|
|
5317
5323
|
|
|
5318
5324
|
// src/tui/utils/clipboard.ts
|
|
5319
|
-
import {
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5325
|
+
import {
|
|
5326
|
+
createClipboard,
|
|
5327
|
+
createHostClipboard,
|
|
5328
|
+
createRendererClipboardAdapter
|
|
5329
|
+
} from "@opentui/core";
|
|
5330
|
+
function failureReason(result) {
|
|
5331
|
+
if (result.host.status === "failed") {
|
|
5332
|
+
return result.host.error.message;
|
|
5333
|
+
}
|
|
5334
|
+
return `host ${result.host.status}, terminal ${result.terminal.status}`;
|
|
5335
|
+
}
|
|
5336
|
+
function createClipboardCopier(renderer2) {
|
|
5337
|
+
let service = null;
|
|
5338
|
+
return (text, onError) => {
|
|
5339
|
+
service ??= createClipboard({
|
|
5340
|
+
host: createHostClipboard(),
|
|
5341
|
+
terminal: createRendererClipboardAdapter(renderer2)
|
|
5342
|
+
});
|
|
5343
|
+
service.writeText(text, { destination: "best-available" }).then((result) => {
|
|
5344
|
+
if (result.host.status !== "written" && result.terminal.status !== "attempted") {
|
|
5345
|
+
onError(`could not copy the link (${failureReason(result)})`);
|
|
5331
5346
|
}
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
}
|
|
5336
|
-
function copyToClipboard(text, onError) {
|
|
5337
|
-
const { command, args } = copyCommand();
|
|
5338
|
-
const child = spawn2(command, args, { stdio: ["pipe", "ignore", "ignore"] });
|
|
5339
|
-
child.on("error", (error) => {
|
|
5340
|
-
onError(`could not copy the link (${error.message})`);
|
|
5341
|
-
});
|
|
5342
|
-
child.on("exit", (code) => {
|
|
5343
|
-
if (code !== null && code !== 0) {
|
|
5344
|
-
onError(`could not copy the link (${command} exited with ${code})`);
|
|
5345
|
-
}
|
|
5346
|
-
});
|
|
5347
|
-
child.stdin.on("error", () => {
|
|
5348
|
-
});
|
|
5349
|
-
child.stdin.end(text);
|
|
5347
|
+
}).catch((error) => {
|
|
5348
|
+
onError(`could not copy the link (${error instanceof Error ? error.message : String(error)})`);
|
|
5349
|
+
});
|
|
5350
|
+
};
|
|
5350
5351
|
}
|
|
5351
5352
|
|
|
5352
5353
|
// src/tui/App.tsx
|
|
@@ -5358,10 +5359,13 @@ function App({
|
|
|
5358
5359
|
initialCopyLinks = false,
|
|
5359
5360
|
initialTheme = defaultThemeState(),
|
|
5360
5361
|
openUrl = openInBrowser,
|
|
5361
|
-
copyUrl
|
|
5362
|
+
copyUrl,
|
|
5362
5363
|
onQuit
|
|
5363
5364
|
}) {
|
|
5364
5365
|
const { width } = useTerminalDimensions3();
|
|
5366
|
+
const renderer2 = useRenderer2();
|
|
5367
|
+
const defaultCopyUrl = useMemo2(() => createClipboardCopier(renderer2), [renderer2]);
|
|
5368
|
+
const copyLink = copyUrl ?? defaultCopyUrl;
|
|
5365
5369
|
const [ui, dispatchUi] = useReducer(uiReducer, initialUiState);
|
|
5366
5370
|
const [browse, dispatchBrowse] = useReducer(browseReducer, initialBrowseState);
|
|
5367
5371
|
const [options, setOptions] = useState4(initial2);
|
|
@@ -5370,7 +5374,7 @@ function App({
|
|
|
5370
5374
|
const [copyLinks2, setCopyLinks] = useState4(initialCopyLinks);
|
|
5371
5375
|
const [themeState, setThemeState] = useState4(initialTheme);
|
|
5372
5376
|
const copyRow = (row) => {
|
|
5373
|
-
|
|
5377
|
+
copyLink(row.url, (message) => {
|
|
5374
5378
|
dispatchUi({ type: "openErrorReported", message });
|
|
5375
5379
|
});
|
|
5376
5380
|
dispatchUi({ type: "copyReported", message: `copied ${row.ref} to the clipboard` });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d3lm/pr-stats",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
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",
|
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
"check": "tsc --noEmit",
|
|
39
39
|
"lint": "oxlint src && eslint --cache src",
|
|
40
40
|
"test": "bun test",
|
|
41
|
+
"changelog": "git-cliff -o CHANGELOG.md && prettier --write CHANGELOG.md",
|
|
42
|
+
"version": "git-cliff --tag v$npm_package_version -o CHANGELOG.md && prettier --write CHANGELOG.md && git add CHANGELOG.md",
|
|
41
43
|
"prepublishOnly": "pnpm build"
|
|
42
44
|
},
|
|
43
45
|
"dependencies": {
|
|
@@ -59,6 +61,7 @@
|
|
|
59
61
|
"@types/node": "^26.3.0",
|
|
60
62
|
"@types/react": "^19.2.18",
|
|
61
63
|
"esbuild": "^0.28.2",
|
|
64
|
+
"git-cliff": "^2.13.1",
|
|
62
65
|
"oxlint-tsgolint": "^7.0.2001",
|
|
63
66
|
"typescript": "^6.0.3"
|
|
64
67
|
}
|