fix: replace postinstall download with optional platform packages#17
fix: replace postinstall download with optional platform packages#17smorimoto wants to merge 1 commit into
Conversation
The previous `postinstall` approach silently fails under `bunx` and `pnpx` (issues upstash#6 and upstash#9), where dlx-style install hooks are disabled by default for security. Migrate to the optional platform packages pattern used by esbuild, biome, and similar tooling. - Add a small CommonJS launcher at `bin/qstash` that resolves the platform-specific binary via `require.resolve` and execs it, propagating the exit code and any terminating signal. - Introduce six platform packages under `packages/` with `os` / `cpu` filters so that npm installs only the matching binary. Each declares its own `publishConfig`, so access and provenance behaviour stays consistent whether published from CI or locally. - Rewrite the release workflow to publish all six platform packages in a matrix, then publish the main package with `optionalDependencies` pinned to the same version. - Drop `install.ts`, `tsconfig.json`, `bun.lockb`, and `bin/.gitkeep` along with the now-unused `tar` and `unzipper` dependencies. Closes upstash#6 Closes upstash#9
1aef881 to
ef556d7
Compare
|
Hi @smorimoto — really nice work here. I opened #18 a few hours ago after running into the same Three things this PR does better than what I built, worth keeping regardless of any other changes:
Suggestions below, roughly priority order. None are blockers; all mechanically simple if you want them. 1. Verify the downloaded binary against the upstream SHA-256 manifest
curl --fail --silent --show-error --location --output checksums.txt \
"https://artifacts.upstash.com/qstash/versions/${VERSION}/qstash-server_${VERSION}_checksums.txt"
grep -F " archive.${{ matrix.ext }}" checksums.txt > expected.sha256 \
|| { echo "Archive not listed in checksums.txt" >&2; exit 1; }
sha256sum -c expected.sha2562. Sanity-check the extracted binary's file-type matches the slotThis PR closes #9 ("Bus error when using pnpm on Linux"), which is the classic wrong-binary-in-wrong-slot symptom. The checksum from (1) catches "binary swapped" but not "binary uploaded to the wrong filename." A case "${node_os}-${node_arch}" in
darwin-arm64) family=Mach-O arch=arm64 ;;
darwin-x64) family=Mach-O arch=x86_64 ;;
linux-arm64) family=ELF arch=aarch64 ;;
linux-x64) family=ELF arch=x86-64 ;;
win32-arm64) family=PE32 arch=Aarch64 ;;
win32-x64) family=PE32 arch=x86-64 ;;
esac
out=$(file --brief "bin/$bin_name")
[[ "$out" == *"$family"* && "$out" == *"$arch"* ]] \
|| { echo "wrong binary in slot: $out" >&2; exit 1; }3. Pin every
|
Summary
postinstall-based binary download (which silently fails underbunx/pnpxbecause their dlx hooks are disabled by default for security — see issue running the cli using bunx #6 and bug:Bus errorwhen usingpnpmon Linux #9) with the optional platform packages pattern used by esbuild, biome, and similar tooling.bin/qstashthat resolves the platform-specific binary viarequire.resolveand execs it, propagating the exit code and signal.@upstash/qstash-cli-<platform>-<arch>) underpackages/withos/cpufilters and their ownpublishConfig, so access and provenance behaviour stays consistent locally and in CI.optionalDependenciespinned to the same version.install.ts,tsconfig.json,bun.lockb,bin/.gitkeep, and the now-unusedtar/unzipperdependencies.Closes #6
Closes #9