slopcode 0.2.138 → 0.2.141

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/package.json CHANGED
@@ -36,20 +36,20 @@
36
36
  "scripts": {
37
37
  "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
38
38
  },
39
- "version": "0.2.138",
39
+ "version": "0.2.141",
40
40
  "license": "MIT",
41
41
  "optionalDependencies": {
42
- "slopcode-bin-darwin-x64-baseline": "0.2.138",
43
- "slopcode-bin-linux-x64-baseline": "0.2.138",
44
- "slopcode-bin-linux-x64-musl": "0.2.138",
45
- "slopcode-bin-windows-x64": "0.2.138",
46
- "slopcode-bin-darwin-x64": "0.2.138",
47
- "slopcode-bin-windows-x64-baseline": "0.2.138",
48
- "slopcode-bin-darwin-arm64": "0.2.138",
49
- "slopcode-bin-linux-x64-baseline-musl": "0.2.138",
50
- "slopcode-bin-linux-x64": "0.2.138",
51
- "slopcode-bin-linux-arm64-musl": "0.2.138",
52
- "slopcode-bin-linux-arm64": "0.2.138",
42
+ "slopcode-bin-darwin-x64-baseline": "0.2.141",
43
+ "slopcode-bin-linux-x64-baseline": "0.2.141",
44
+ "slopcode-bin-linux-x64-musl": "0.2.141",
45
+ "slopcode-bin-windows-x64": "0.2.141",
46
+ "slopcode-bin-darwin-x64": "0.2.141",
47
+ "slopcode-bin-windows-x64-baseline": "0.2.141",
48
+ "slopcode-bin-darwin-arm64": "0.2.141",
49
+ "slopcode-bin-linux-x64-baseline-musl": "0.2.141",
50
+ "slopcode-bin-linux-x64": "0.2.141",
51
+ "slopcode-bin-linux-arm64-musl": "0.2.141",
52
+ "slopcode-bin-linux-arm64": "0.2.141",
53
53
  "@oven/bun-linux-aarch64-android": "1.3.14",
54
54
  "@oven/bun-linux-x64-android": "1.3.14"
55
55
  }
package/postinstall.mjs CHANGED
@@ -39,7 +39,7 @@ function termuxEnv() {
39
39
  }
40
40
 
41
41
  function detectLibc(platform, arch) {
42
- if (platform === "android") return "bionic"
42
+ if (platform === "android" || termuxEnv()) return "bionic"
43
43
  if (platform !== "linux") return
44
44
  const report = process.report?.getReport?.()
45
45
  if (typeof report?.header?.glibcVersionRuntime === "string" && report.header.glibcVersionRuntime) {
@@ -59,7 +59,7 @@ function detectLibc(platform, arch) {
59
59
  const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
60
60
  if (text.includes("musl")) return "musl"
61
61
  if (text.includes("glibc") || text.includes("gnu libc")) return "glibc"
62
- if (text.includes("bionic") || termuxEnv()) return "bionic"
62
+ if (text.includes("bionic")) return "bionic"
63
63
  const loader = arch === "arm64" ? "/lib/ld-musl-aarch64.so.1" : arch === "x64" ? "/lib/ld-musl-x86_64.so.1" : ""
64
64
  if (loader && fs.existsSync(loader)) return "musl"
65
65
  }
@@ -142,7 +142,7 @@ function supportedMessage() {
142
142
 
143
143
  function termuxMessage() {
144
144
  return [
145
- "SlopCode native Termux support could not install the Android runtime.",
145
+ "SlopCode native Termux support could not install the Android runtime/bootstrap.",
146
146
  "Install from Termux with:",
147
147
  " pkg update",
148
148
  " pkg install nodejs git ripgrep neovim tar",
@@ -163,6 +163,21 @@ function androidUrl(arch) {
163
163
  return `https://github.com/teamslop/slopcode/releases/download/v${pkg.version}/slopcode-android-${arch}.tar.gz`
164
164
  }
165
165
 
166
+ const androidBunVersion = "1.3.14"
167
+
168
+ function androidBunPackage(arch) {
169
+ return arch === "arm64" ? "bun-linux-aarch64-android" : "bun-linux-x64-android"
170
+ }
171
+
172
+ function androidBunTarget(arch) {
173
+ return path.join(__dirname, "node_modules", "@oven", androidBunPackage(arch))
174
+ }
175
+
176
+ function androidBunUrl(arch) {
177
+ const name = androidBunPackage(arch)
178
+ return `https://registry.npmjs.org/@oven/${name}/-/${name}-${androidBunVersion}.tgz`
179
+ }
180
+
166
181
  async function androidAsset(arch, tmp) {
167
182
  if (process.env.SLOPCODE_ANDROID_ASSET_PATH) return process.env.SLOPCODE_ANDROID_ASSET_PATH
168
183
  const out = path.join(tmp, `slopcode-android-${arch}.tar.gz`)
@@ -206,6 +221,49 @@ async function installAndroid(arch) {
206
221
  }
207
222
  }
208
223
 
224
+ async function androidBunAsset(arch, tmp) {
225
+ if (process.env.SLOPCODE_ANDROID_BUN_ASSET_PATH) return process.env.SLOPCODE_ANDROID_BUN_ASSET_PATH
226
+ const out = path.join(tmp, `${androidBunPackage(arch)}.tgz`)
227
+ const res = await fetch(process.env.SLOPCODE_ANDROID_BUN_ASSET_URL || androidBunUrl(arch))
228
+ if (!res.ok) throw new Error(`Failed to download Android Bun bootstrap: ${res.status} ${res.statusText}`)
229
+ await fs.promises.writeFile(out, Buffer.from(await res.arrayBuffer()))
230
+ return out
231
+ }
232
+
233
+ async function installAndroidBun(arch) {
234
+ const target = androidBunTarget(arch)
235
+ const existing = path.join(target, "bin", "bun")
236
+ if (fs.existsSync(existing)) {
237
+ fs.chmodSync(existing, 0o755)
238
+ return "detected"
239
+ }
240
+
241
+ const tmp = await fs.promises.mkdtemp(path.join(os.tmpdir(), "slopcode-android-bun-"))
242
+ try {
243
+ const archive = await androidBunAsset(arch, tmp)
244
+ const extract = path.join(tmp, "extract")
245
+ await fs.promises.mkdir(extract, { recursive: true })
246
+ const result = require("child_process").spawnSync("tar", ["-xzf", path.basename(archive), "-C", extract], {
247
+ cwd: path.dirname(archive),
248
+ encoding: "utf8",
249
+ timeout: 120000,
250
+ })
251
+ if (result.status !== 0) {
252
+ throw new Error((result.stderr || result.stdout || "tar failed").trim())
253
+ }
254
+ const source = fs.existsSync(path.join(extract, "package", "bin", "bun")) ? path.join(extract, "package") : extract
255
+ const binary = path.join(source, "bin", "bun")
256
+ if (!fs.existsSync(binary)) throw new Error("Downloaded Android Bun bootstrap is missing bin/bun")
257
+ await fs.promises.rm(target, { recursive: true, force: true })
258
+ await fs.promises.mkdir(path.dirname(target), { recursive: true })
259
+ await fs.promises.rename(source, target)
260
+ fs.chmodSync(path.join(target, "bin", "bun"), 0o755)
261
+ return "installed"
262
+ } finally {
263
+ await fs.promises.rm(tmp, { recursive: true, force: true })
264
+ }
265
+ }
266
+
209
267
  function findBinary() {
210
268
  const { platform, arch } = detectPlatformAndArch()
211
269
  const binaryName = platform === "windows" ? "slopcode.exe" : "slopcode"
@@ -289,7 +347,8 @@ async function main() {
289
347
  if (detectLibc(platform, arch) === "bionic") {
290
348
  try {
291
349
  await installAndroid(arch)
292
- console.log("Android/Termux runtime installed from GitHub release asset")
350
+ await installAndroidBun(arch)
351
+ console.log("Android/Termux runtime and bootstrap installed from release assets")
293
352
  } catch (error) {
294
353
  console.log(termuxMessage())
295
354
  console.error(error.message)
@@ -302,7 +361,13 @@ async function main() {
302
361
 
303
362
  if (found.libc === "bionic") {
304
363
  clearCache()
305
- console.log("Android/Termux runtime package detected; runtime resolver will launch it")
364
+ try {
365
+ await installAndroidBun(arch)
366
+ console.log("Android/Termux runtime package detected; runtime resolver will launch it")
367
+ } catch (error) {
368
+ console.log(termuxMessage())
369
+ console.error(error.message)
370
+ }
306
371
  return
307
372
  }
308
373
  clearCache()