idx-cli/scripts/idx.js
hermes 4f8c90a108 fix: harden npm distribution release and installer
- release.yml: build static musl Linux binaries (no host glibc
  requirement), add darwin-x64, publish SHA256SUMS, allow
  workflow_dispatch for an existing tag (v0.2.3 has no binaries yet),
  and run build-only on PRs that touch the workflow or installer
- install.js: verify downloads against the release SHA256SUMS
  (IDX_BINARY_SHA256 for overrides), add a 60s request timeout, use
  stream.pipeline so truncated downloads fail, and skip the download
  inside the source checkout
- idx.js: forward SIGTERM/SIGHUP to the binary and keep the signal
  exit status
- package.json: drop the prepare script (no Rust toolchain needed to
  pack/publish)
- npm-smoke.sh: read the tarball name from npm pack, use grep over rg
- .gitignore: ignore /bin/ and *.tgz
- docs: musl targets, checksums, pnpm/bun opt-in, manual release flow

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017a5Cv5Z1NzdYKgKnTiAF4E
2026-09-24 18:57:53 +00:00

39 lines
1.2 KiB
JavaScript
Executable file

#!/usr/bin/env node
"use strict";
const fs = require("node:fs");
const path = require("node:path");
const { spawn } = require("node:child_process");
const binaryName = process.platform === "win32" ? "idx.exe" : "idx";
const binaryPath = path.join(__dirname, "..", "bin", binaryName);
if (!fs.existsSync(binaryPath)) {
console.error(`idx-cli: installed binary not found at ${binaryPath}`);
console.error("idx-cli: rerun npm install or set IDX_BINARY_URL for a local binary");
process.exit(1);
}
const child = spawn(binaryPath, process.argv.slice(2), { stdio: "inherit" });
// Pass termination signals from a supervisor (kill, docker stop) to the binary.
for (const signal of ["SIGTERM", "SIGHUP"]) {
process.on(signal, () => child.kill(signal));
}
// Ctrl+C already reaches the binary through the terminal's process group.
process.on("SIGINT", () => {});
child.once("error", (error) => {
console.error(`idx-cli: failed to start ${binaryPath}: ${error.message}`);
process.exit(1);
});
child.once("exit", (code, signal) => {
if (signal) {
process.removeAllListeners(signal);
process.kill(process.pid, signal);
return;
}
process.exit(code === null ? 1 : code);
});