@d3lm/pr-stats 0.2.3 → 0.2.4
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 +32 -34
- 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";
|
|
@@ -5316,37 +5316,32 @@ function openInBrowser(url, onError) {
|
|
|
5316
5316
|
}
|
|
5317
5317
|
|
|
5318
5318
|
// src/tui/utils/clipboard.ts
|
|
5319
|
-
import {
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5319
|
+
import {
|
|
5320
|
+
createClipboard,
|
|
5321
|
+
createHostClipboard,
|
|
5322
|
+
createRendererClipboardAdapter
|
|
5323
|
+
} from "@opentui/core";
|
|
5324
|
+
function failureReason(result) {
|
|
5325
|
+
if (result.host.status === "failed") {
|
|
5326
|
+
return result.host.error.message;
|
|
5327
|
+
}
|
|
5328
|
+
return `host ${result.host.status}, terminal ${result.terminal.status}`;
|
|
5329
|
+
}
|
|
5330
|
+
function createClipboardCopier(renderer2) {
|
|
5331
|
+
let service = null;
|
|
5332
|
+
return (text, onError) => {
|
|
5333
|
+
service ??= createClipboard({
|
|
5334
|
+
host: createHostClipboard(),
|
|
5335
|
+
terminal: createRendererClipboardAdapter(renderer2)
|
|
5336
|
+
});
|
|
5337
|
+
service.writeText(text, { destination: "best-available" }).then((result) => {
|
|
5338
|
+
if (result.host.status !== "written" && result.terminal.status !== "attempted") {
|
|
5339
|
+
onError(`could not copy the link (${failureReason(result)})`);
|
|
5331
5340
|
}
|
|
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);
|
|
5341
|
+
}).catch((error) => {
|
|
5342
|
+
onError(`could not copy the link (${error instanceof Error ? error.message : String(error)})`);
|
|
5343
|
+
});
|
|
5344
|
+
};
|
|
5350
5345
|
}
|
|
5351
5346
|
|
|
5352
5347
|
// src/tui/App.tsx
|
|
@@ -5358,10 +5353,13 @@ function App({
|
|
|
5358
5353
|
initialCopyLinks = false,
|
|
5359
5354
|
initialTheme = defaultThemeState(),
|
|
5360
5355
|
openUrl = openInBrowser,
|
|
5361
|
-
copyUrl
|
|
5356
|
+
copyUrl,
|
|
5362
5357
|
onQuit
|
|
5363
5358
|
}) {
|
|
5364
5359
|
const { width } = useTerminalDimensions3();
|
|
5360
|
+
const renderer2 = useRenderer2();
|
|
5361
|
+
const defaultCopyUrl = useMemo2(() => createClipboardCopier(renderer2), [renderer2]);
|
|
5362
|
+
const copyLink = copyUrl ?? defaultCopyUrl;
|
|
5365
5363
|
const [ui, dispatchUi] = useReducer(uiReducer, initialUiState);
|
|
5366
5364
|
const [browse, dispatchBrowse] = useReducer(browseReducer, initialBrowseState);
|
|
5367
5365
|
const [options, setOptions] = useState4(initial2);
|
|
@@ -5370,7 +5368,7 @@ function App({
|
|
|
5370
5368
|
const [copyLinks2, setCopyLinks] = useState4(initialCopyLinks);
|
|
5371
5369
|
const [themeState, setThemeState] = useState4(initialTheme);
|
|
5372
5370
|
const copyRow = (row) => {
|
|
5373
|
-
|
|
5371
|
+
copyLink(row.url, (message) => {
|
|
5374
5372
|
dispatchUi({ type: "openErrorReported", message });
|
|
5375
5373
|
});
|
|
5376
5374
|
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.4",
|
|
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
|
}
|