github-search-cli 0.7.0 → 0.8.1
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/README.md +163 -183
- package/bin/ghfind.js +55 -0
- package/completions/{search-cli.bash → ghfind.bash} +4 -4
- package/completions/ghfind.fish +19 -0
- package/completions/{search-cli.zsh → ghfind.zsh} +4 -4
- package/demo.svg +65 -65
- package/package.json +20 -9
- package/src/bookmarks.ts +2 -2
- package/src/cli.ts +32 -45
- package/src/compare.ts +1 -1
- package/src/config.ts +8 -8
- package/src/deepdive.ts +4 -10
- package/src/errors.ts +1 -4
- package/src/explore.ts +0 -1
- package/src/export.ts +2 -3
- package/src/help.ts +112 -120
- package/src/history.ts +2 -2
- package/src/init.ts +6 -6
- package/src/notifications.ts +2 -6
- package/src/open-url.ts +16 -17
- package/src/output.ts +2 -9
- package/src/pipe.ts +2 -8
- package/src/saved-searches.ts +2 -2
- package/src/search.ts +555 -0
- package/src/session.ts +4 -5
- package/src/share.ts +27 -22
- package/src/trending.ts +10 -15
- package/src/tui.ts +408 -261
- package/src/types.ts +3 -11
- package/src/watch.ts +3 -6
- package/vendor/bun.exe +0 -0
- package/bin/search-cli.js +0 -17
- package/completions/search-cli.fish +0 -19
- package/src/cache.ts +0 -64
- package/src/normalizer.ts +0 -66
- package/src/provider.ts +0 -165
- package/src/query.ts +0 -249
- package/src/ranking.ts +0 -57
package/src/share.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Share repo — copy formatted snippets to clipboard.
|
|
3
3
|
*/
|
|
4
|
-
import type { Repo } from "./types
|
|
4
|
+
import type { Repo } from "./types";
|
|
5
5
|
|
|
6
6
|
export type ShareFormat = "markdown" | "plain" | "gh-cli" | "short";
|
|
7
7
|
|
|
@@ -19,31 +19,36 @@ export function formatShare(repo: Repo, format: ShareFormat): string {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/** Copy text to clipboard via platform command. */
|
|
22
|
+
import { spawn } from "child_process";
|
|
23
|
+
|
|
22
24
|
export async function copyToClipboard(text: string): Promise<boolean> {
|
|
23
25
|
try {
|
|
24
26
|
const p = process.platform;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
proc.
|
|
33
|
-
|
|
34
|
-
await proc.exited;
|
|
35
|
-
} else {
|
|
36
|
-
// Linux — try xclip, then wl-copy
|
|
37
|
-
const cmd = Bun.which("xclip") ? ["xclip", "-selection", "clipboard"] :
|
|
38
|
-
Bun.which("wl-copy") ? ["wl-copy"] : null;
|
|
39
|
-
if (!cmd) return false;
|
|
40
|
-
const proc = Bun.spawn(cmd, { stdin: "pipe" });
|
|
41
|
-
proc.stdin.write(text);
|
|
42
|
-
proc.stdin.end();
|
|
43
|
-
await proc.exited;
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
27
|
+
const cmd = p === "win32" ? ["clip"] : p === "darwin" ? ["pbcopy"] : await findLinuxClipCmd();
|
|
28
|
+
if (!cmd) return false;
|
|
29
|
+
const proc = spawn(cmd[0], cmd.slice(1), { stdio: ["pipe", "ignore", "ignore"] });
|
|
30
|
+
proc.stdin.write(text);
|
|
31
|
+
proc.stdin.end();
|
|
32
|
+
return new Promise((resolve) => {
|
|
33
|
+
proc.on("close", (code) => resolve(code === 0));
|
|
34
|
+
proc.on("error", () => resolve(false));
|
|
35
|
+
});
|
|
46
36
|
} catch {
|
|
47
37
|
return false;
|
|
48
38
|
}
|
|
49
39
|
}
|
|
40
|
+
|
|
41
|
+
async function findLinuxClipboard(): Promise<string[] | null> {
|
|
42
|
+
const { execFileSync } = await import("child_process");
|
|
43
|
+
try {
|
|
44
|
+
execFileSync("xclip", ["-version"], { stdio: "ignore" });
|
|
45
|
+
return ["xclip", "-selection", "clipboard"];
|
|
46
|
+
} catch {
|
|
47
|
+
try {
|
|
48
|
+
execFileSync("wl-copy", ["--version"], { stdio: "ignore" });
|
|
49
|
+
return ["wl-copy"];
|
|
50
|
+
} catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/trending.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
/**
|
|
3
|
-
* trending.ts — "Trending Repositories" view for the GitHub repo browser CLI.
|
|
4
|
-
*
|
|
5
|
-
* Polished terminal UI built with OpenTUI. Tokyo Night palette.
|
|
6
|
-
*
|
|
7
|
-
* Run directly: bun run src/trending.ts
|
|
8
|
-
* Or import: import { launchTrending } from "./trending.ts";
|
|
9
|
-
*/
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** trending.ts — "Trending Repositories" view for the GitHub repo browser CLI. */
|
|
10
3
|
import {
|
|
11
4
|
createCliRenderer,
|
|
12
5
|
BoxRenderable,
|
|
@@ -18,10 +11,10 @@ import {
|
|
|
18
11
|
dim,
|
|
19
12
|
t,
|
|
20
13
|
} from "@opentui/core";
|
|
21
|
-
import type { Repo } from "./types
|
|
22
|
-
import { openUrl } from "./open-url
|
|
23
|
-
import { NetworkError } from "./errors
|
|
24
|
-
import type { GitHubSearchEnvelope } from "./
|
|
14
|
+
import type { Repo } from "./types";
|
|
15
|
+
import { openUrl } from "./open-url";
|
|
16
|
+
import { NetworkError } from "./errors";
|
|
17
|
+
import type { GitHubSearchEnvelope } from "./search";
|
|
25
18
|
|
|
26
19
|
// ─── Tokyo Night palette ──────────────────────────────────────────────
|
|
27
20
|
const C = {
|
|
@@ -130,7 +123,7 @@ export async function fetchTrendingRepos(since: "daily" | "weekly" | "monthly"):
|
|
|
130
123
|
res = await fetch(url, {
|
|
131
124
|
headers: {
|
|
132
125
|
Accept: "application/vnd.github+json",
|
|
133
|
-
"User-Agent": "
|
|
126
|
+
"User-Agent": "ghfind",
|
|
134
127
|
},
|
|
135
128
|
});
|
|
136
129
|
} catch {
|
|
@@ -559,6 +552,8 @@ export async function launchTrending(): Promise<void> {
|
|
|
559
552
|
}
|
|
560
553
|
|
|
561
554
|
// ── Auto-run ──────────────────────────────────────────────────────────
|
|
562
|
-
|
|
555
|
+
// Only launch when run directly (bun run src/trending.ts), not when bundled
|
|
556
|
+
// into cli.js or imported as a module.
|
|
557
|
+
if (import.meta.main && !process.env.GHFIND_BUNDLED) {
|
|
563
558
|
launchTrending();
|
|
564
559
|
}
|