mirror of
https://github.com/0xrsydn/idx-cli.git
synced 2026-09-21 05:54:18 +00:00
feat: add npm distribution wrapper for idx-cli
Add an npm wrapper (package.json + postinstall downloader) so the Rust binary can be installed via npm/npx. Include a local smoke test, a GitHub Release cross-compile workflow, and nodejs in the dev shell. - package.json: idx-cli v0.2.3, bin idx, engines node>=16 - scripts/install.js: dependency-free postinstall that downloads the platform-specific GitHub Release asset (or IDX_BINARY_URL override) - scripts/idx.js: binary launcher preserving exit codes/signals - scripts/npm-smoke.sh: npm pack -> install tarball -> run idx --help and idx config --help, locale, no publish required - .github/workflows/release.yml: cross-compile linux-x64/arm64 and darwin-arm64 releases and attach binaries to the version tag - flake.nix: add nodejs_22 to the dev shell - docs/NPM_DISTRIBUTION.md: usage, local test, and release flow
This commit is contained in:
parent
603c0e49c1
commit
221dc01397
7 changed files with 463 additions and 0 deletions
31
scripts/idx.js
Executable file
31
scripts/idx.js
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#!/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" });
|
||||
|
||||
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.kill(process.pid, signal);
|
||||
return;
|
||||
}
|
||||
|
||||
process.exit(code === null ? 1 : code);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue