@bitkyc08/opencodex 1.9.4 → 2.0.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.
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * postinstall — one-time GitHub-star prompt during `npm install -g @bitkyc08/opencodex`.
4
- *
5
- * Behavior:
6
- * - TTY-only (skips CI / piped installs)
7
- * - Requires `gh` CLI with auth (stars directly via `gh api`)
8
- * - Prompts once; shares the ~/.opencodex/.star-prompted marker with the first-`ocx start` prompt
9
- * (so bun users — where postinstall may not run on `-g` — still get it exactly once on start)
10
- * - Never blocks the install (all errors silently caught)
11
- */
12
- import { spawnSync } from "node:child_process";
13
- import { existsSync, mkdirSync, writeFileSync } from "node:fs";
14
- import { join } from "node:path";
15
- import { createInterface } from "node:readline/promises";
16
- import { homedir } from "node:os";
17
-
18
- const REPO = "lidge-jun/opencodex";
19
- const MARKER = join(homedir(), ".opencodex", ".star-prompted");
20
-
21
- function ghInstalled() {
22
- const r = spawnSync("gh", ["--version"], { stdio: "ignore", timeout: 3000, windowsHide: true });
23
- return !r.error && r.status === 0;
24
- }
25
-
26
- function starRepo() {
27
- const r = spawnSync("gh", ["api", "-X", "PUT", `/user/starred/${REPO}`],
28
- { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: 10000, windowsHide: true });
29
- if (r.error) return { ok: false, error: r.error.message };
30
- if (r.status !== 0) return { ok: false, error: (r.stderr || r.stdout || "").trim() || `gh exited ${r.status}` };
31
- return { ok: true };
32
- }
33
-
34
- async function askYesNo(question) {
35
- const rl = createInterface({ input: process.stdin, output: process.stdout });
36
- try {
37
- const a = (await rl.question(question)).trim().toLowerCase();
38
- return a === "" || a === "y" || a === "yes";
39
- } finally {
40
- rl.close();
41
- }
42
- }
43
-
44
- async function main() {
45
- if (!process.stdin.isTTY || !process.stdout.isTTY) return;
46
- if (existsSync(MARKER)) return;
47
- if (!ghInstalled()) return;
48
-
49
- try { mkdirSync(join(homedir(), ".opencodex"), { recursive: true }); writeFileSync(MARKER, new Date().toISOString()); } catch { /* best-effort */ }
50
-
51
- const yes = await askYesNo("[opencodex] Enjoying opencodex? Star it on GitHub? [Y/n] ");
52
- if (!yes) return;
53
- const r = starRepo();
54
- console.log(r.ok ? "[opencodex] Thanks for the star! ⭐" : `[opencodex] Couldn't star automatically: ${r.error}`);
55
- }
56
-
57
- main().catch(() => { /* never fail the install */ });