@nemoobc/opencode-termux 1.19.1 → 1.20.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/bin/opencode.js DELETED
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env node
2
- const { spawnSync } = require("child_process")
3
- const fs = require("fs")
4
- const path = require("path")
5
- const vendor = path.join(__dirname, "..", "vendor")
6
- const loader = path.join(vendor, "ld-musl.so")
7
- const bin = path.join(vendor, "opencode")
8
-
9
- function ready() {
10
- return fs.existsSync(loader) && fs.existsSync(bin)
11
- }
12
-
13
- // Auto-heal: kalau postinstall terlewat (mis. --ignore-scripts), pasang sekarang.
14
- if (!ready()) {
15
- console.log("[opencode-termux] vendor belum ada — menjalankan installer…")
16
- const r = spawnSync(process.execPath, [path.join(__dirname, "..", "install.mjs")], {
17
- stdio: "inherit",
18
- env: process.env,
19
- })
20
- if (r.status !== 0 || !ready()) {
21
- console.error("[opencode-termux] instalasi bundle gagal. Coba manual:")
22
- console.error(" npm rebuild @nemoobc/opencode-termux")
23
- process.exit(1)
24
- }
25
- }
26
-
27
- if (!ready()) process.exit(1)
28
-
29
- // DNS fix: musl hasil build kita membaca config dari prefix Termux —
30
- // pastikan filenya ada (bisa ditulis tanpa root).
31
- try {
32
- const PREFIX = process.env.TERMUX_PREFIX || "/data/data/com.termux/files/usr"
33
- const etc = path.join(PREFIX, "etc")
34
- fs.mkdirSync(etc, { recursive: true })
35
- const rc = path.join(etc, "resolv.conf")
36
- if (!fs.existsSync(rc)) fs.writeFileSync(rc, "nameserver 1.1.1.1\nnameserver 8.8.8.8\n")
37
- const hh = path.join(etc, "hosts")
38
- if (!fs.existsSync(hh)) fs.writeFileSync(hh, "127.0.0.1 localhost\n")
39
- } catch {}
40
-
41
- // LD_PRELOAD bawaan Termux (libtermux-exec) dibuat untuk Bionic dan akan
42
- // gagal relokasi jika ikut dimuat ke proses musl — jadi selalu dibersihkan.
43
- const { LD_PRELOAD, LD_PRELOAD_32BIT, ...cleanEnv } = process.env
44
- const r = spawnSync(loader, [bin, ...process.argv.slice(2)], {
45
- stdio: "inherit",
46
- env: { ...cleanEnv, LD_LIBRARY_PATH: vendor },
47
- })
48
- process.exit(r.status ?? 1)