slopcode 0.2.138 → 0.2.140

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/slopcode CHANGED
@@ -77,7 +77,7 @@ function termuxEnv() {
77
77
  }
78
78
 
79
79
  function libc() {
80
- if (platform === "android") return "bionic"
80
+ if (platform === "android" || termuxEnv()) return "bionic"
81
81
  if (platform !== "linux") return
82
82
  const report = process.report?.getReport?.()
83
83
  if (typeof report?.header?.glibcVersionRuntime === "string" && report.header.glibcVersionRuntime) {
@@ -97,7 +97,7 @@ function libc() {
97
97
  const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
98
98
  if (text.includes("musl")) return "musl"
99
99
  if (text.includes("glibc") || text.includes("gnu libc")) return "glibc"
100
- if (text.includes("bionic") || termuxEnv()) return "bionic"
100
+ if (text.includes("bionic")) return "bionic"
101
101
  const loader = arch === "arm64" ? "/lib/ld-musl-aarch64.so.1" : arch === "x64" ? "/lib/ld-musl-x86_64.so.1" : ""
102
102
  if (loader && fs.existsSync(loader)) return "musl"
103
103
  }
@@ -223,7 +223,18 @@ function androidDoctor(args) {
223
223
  }
224
224
 
225
225
  function androidInteractive(args) {
226
- return !androidDoctor(args) && !args.includes("--self-test")
226
+ return !androidDoctor(args) && args[0] !== "--version" && !args.includes("--self-test")
227
+ }
228
+
229
+ function findNodeModuleFile(startDir, parts) {
230
+ let current = startDir
231
+ for (;;) {
232
+ const candidate = path.join(current, "node_modules", ...parts)
233
+ if (fs.existsSync(candidate)) return candidate
234
+ const parent = path.dirname(current)
235
+ if (parent === current) return
236
+ current = parent
237
+ }
227
238
  }
228
239
 
229
240
  function androidBun(arch) {
@@ -231,7 +242,9 @@ function androidBun(arch) {
231
242
  return [
232
243
  process.env.SLOPCODE_BUN_PATH,
233
244
  path.join(rootDir, "node_modules", "@oven", name, "bin", "bun"),
245
+ findNodeModuleFile(scriptDir, ["@oven", name, "bin", "bun"]),
234
246
  path.join(rootDir, "node_modules", ".bin", process.platform === "win32" ? "bun.cmd" : "bun"),
247
+ findNodeModuleFile(scriptDir, [".bin", process.platform === "win32" ? "bun.cmd" : "bun"]),
235
248
  ].find((item) => item && fs.existsSync(item))
236
249
  }
237
250
 
@@ -296,8 +309,14 @@ if (!resolved) {
296
309
  }
297
310
 
298
311
  const args = process.argv.slice(2)
299
- if (platform === "android" && androidInteractive(args)) {
312
+ if (libc() === "bionic" && androidInteractive(args)) {
300
313
  const bun = androidBun(arch)
314
+ if (!fs.existsSync(androidBundle)) {
315
+ console.error(
316
+ "SlopCode Android CLI bootstrap bundle is missing. Reinstall from Termux with: npm install -g slopcode@latest --include=optional",
317
+ )
318
+ process.exit(1)
319
+ }
301
320
  if (bun && fs.existsSync(androidBundle)) {
302
321
  const runtimeRoot = path.dirname(path.dirname(resolved.path))
303
322
  run(bun, {
@@ -313,13 +332,12 @@ if (platform === "android" && androidInteractive(args)) {
313
332
  },
314
333
  })
315
334
  }
316
- if (fs.existsSync(androidBundle) && !bun) {
335
+ if (!bun) {
317
336
  console.error(
318
- "SlopCode Android CLI bootstrap is missing. Reinstall from Termux with: npm install -g slopcode@latest --include=optional",
337
+ "SlopCode Android CLI bootstrap is missing. Run npm rebuild slopcode or reinstall from Termux with: npm install -g slopcode@latest --include=optional",
319
338
  )
320
339
  process.exit(1)
321
340
  }
322
341
  }
323
342
 
324
343
  run(resolved.path)
325
-
package/bundle/index.js CHANGED
@@ -56350,7 +56350,7 @@ var init_installation = __esm(async () => {
56350
56350
  await $2`${process.execPath} --version`.nothrow().quiet().text();
56351
56351
  }
56352
56352
  Installation.upgrade = upgrade;
56353
- Installation.VERSION = "0.2.138";
56353
+ Installation.VERSION = "0.2.140";
56354
56354
  Installation.CHANNEL = "latest";
56355
56355
  Installation.USER_AGENT = `${product.id}/${Installation.CHANNEL}/${Installation.VERSION}/${Flag.SLOPCODE_CLIENT}`;
56356
56356
  async function latest(installMethod) {
@@ -405185,11 +405185,14 @@ await init_app();
405185
405185
  init_ui();
405186
405186
  import fs38 from "fs";
405187
405187
  import path103 from "path";
405188
+ function bionic() {
405189
+ return process.env.SLOPCODE_BIONIC === "1" || process.env.TERMUX_VERSION !== undefined || process.env.PREFIX?.includes("/com.termux/");
405190
+ }
405188
405191
  function native(input2 = { platform: process.platform, override: process.env.SLOPCODE_ANDROID_TUI }) {
405189
- return input2.platform !== "android";
405192
+ return !android(input2);
405190
405193
  }
405191
405194
  function android(input2 = { platform: process.platform, override: process.env.SLOPCODE_ANDROID_TUI }) {
405192
- return input2.platform === "android";
405195
+ return input2.platform === "android" || input2.platform === process.platform && bionic();
405193
405196
  }
405194
405197
  function client5(root4 = process.env.SLOPCODE_ANDROID_ROOT) {
405195
405198
  const host2 = root4 && path103.join(root4, "bin", "slopcode-android-host");
package/bundle/worker.js CHANGED
@@ -27961,7 +27961,7 @@ var init_installation = __esm(async () => {
27961
27961
  await $`${process.execPath} --version`.nothrow().quiet().text();
27962
27962
  }
27963
27963
  Installation.upgrade = upgrade;
27964
- Installation.VERSION = "0.2.138";
27964
+ Installation.VERSION = "0.2.140";
27965
27965
  Installation.CHANNEL = "latest";
27966
27966
  Installation.USER_AGENT = `${product.id}/${Installation.CHANNEL}/${Installation.VERSION}/${Flag.SLOPCODE_CLIENT}`;
27967
27967
  async function latest(installMethod) {
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.140",
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.140",
43
+ "slopcode-bin-linux-x64-baseline": "0.2.140",
44
+ "slopcode-bin-linux-x64-musl": "0.2.140",
45
+ "slopcode-bin-windows-x64": "0.2.140",
46
+ "slopcode-bin-darwin-x64": "0.2.140",
47
+ "slopcode-bin-windows-x64-baseline": "0.2.140",
48
+ "slopcode-bin-darwin-arm64": "0.2.140",
49
+ "slopcode-bin-linux-x64-baseline-musl": "0.2.140",
50
+ "slopcode-bin-linux-x64": "0.2.140",
51
+ "slopcode-bin-linux-arm64-musl": "0.2.140",
52
+ "slopcode-bin-linux-arm64": "0.2.140",
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,51 @@ 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"))
255
+ ? path.join(extract, "package")
256
+ : extract
257
+ const binary = path.join(source, "bin", "bun")
258
+ if (!fs.existsSync(binary)) throw new Error("Downloaded Android Bun bootstrap is missing bin/bun")
259
+ await fs.promises.rm(target, { recursive: true, force: true })
260
+ await fs.promises.mkdir(path.dirname(target), { recursive: true })
261
+ await fs.promises.rename(source, target)
262
+ fs.chmodSync(path.join(target, "bin", "bun"), 0o755)
263
+ return "installed"
264
+ } finally {
265
+ await fs.promises.rm(tmp, { recursive: true, force: true })
266
+ }
267
+ }
268
+
209
269
  function findBinary() {
210
270
  const { platform, arch } = detectPlatformAndArch()
211
271
  const binaryName = platform === "windows" ? "slopcode.exe" : "slopcode"
@@ -289,7 +349,8 @@ async function main() {
289
349
  if (detectLibc(platform, arch) === "bionic") {
290
350
  try {
291
351
  await installAndroid(arch)
292
- console.log("Android/Termux runtime installed from GitHub release asset")
352
+ await installAndroidBun(arch)
353
+ console.log("Android/Termux runtime and bootstrap installed from release assets")
293
354
  } catch (error) {
294
355
  console.log(termuxMessage())
295
356
  console.error(error.message)
@@ -302,7 +363,13 @@ async function main() {
302
363
 
303
364
  if (found.libc === "bionic") {
304
365
  clearCache()
305
- console.log("Android/Termux runtime package detected; runtime resolver will launch it")
366
+ try {
367
+ await installAndroidBun(arch)
368
+ console.log("Android/Termux runtime package detected; runtime resolver will launch it")
369
+ } catch (error) {
370
+ console.log(termuxMessage())
371
+ console.error(error.message)
372
+ }
306
373
  return
307
374
  }
308
375
  clearCache()