Replace Bun-specific APIs with Node.js child_process for compatibility - #32
Merged
Merged
Conversation
When users install via `npm install -g` without having Bun installed, the CLI now shows a helpful error message with installation instructions instead of failing silently or with a confusing error. - Add bin/hn shell wrapper that checks for Bun before running - Update package.json bin entry to use the wrapper - Include bin directory in npm package files https://claude.ai/code/session_019648v5yaArRCrsghuSW4SE
- Add shell wrapper that checks for Bun before running CLI - Show clear error message with installation instructions when Bun is missing - Explains that @opentui/core requires Bun runtime - Replace Bun.spawn with node:child_process spawn (works in both runtimes) Note: Full Node.js compatibility isn't possible because @opentui/core uses bun:ffi for Yoga layout engine and tree-sitter bindings. https://claude.ai/code/session_019648v5yaArRCrsghuSW4SE
This enables npm users to install the CLI without needing Bun installed
at runtime. The app is compiled to standalone executables for each platform.
Changes:
- bin/hn: Node.js launcher that finds and runs platform-specific binary
- script/build-binaries.ts: Cross-platform compilation script
- package.json: Added optionalDependencies for platform packages
- .github/workflows/publish.yml: Build and publish platform packages
- src/app.ts, src/components/Header.ts: Fixed TypeScript errors
Distribution model:
- npm install -g @brianlovin/hn-cli installs the launcher + platform binary
- Platform packages: @brianlovin/hn-cli-{darwin,linux,windows}-{arm64,x64}
- No Bun runtime required for end users
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The build script now updates optionalDependencies in package.json to match the current version, ensuring platform package versions stay in sync during releases. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR replaces Bun-specific runtime APIs with standard Node.js APIs to improve compatibility and allow the CLI to run under different JavaScript runtimes. The changes maintain the same functionality while using cross-platform alternatives.
Key Changes
bin/hn): New executable shell script that checks for Bun installation and delegates to the compiled CLI, providing a better user experience with clear error messages if Bun is not availablebinentry point from directly referencing the compiled CLI to using the new shell wrapper, and addedbindirectory to thefilesarray for distributionBun.spawn()withnode:child_process: Updated clipboard operations insrc/app.tsandsrc/components/Header.tsto use the standard Node.jsspawn()function instead of Bun-specific APIscloseanderrorevents, ensuring graceful failure if clipboard commands are unavailableImplementation Details
spawn()calls use the same clipboard commands (xclip/pbcopy) but with standard Node.js APIshttps://claude.ai/code/session_019648v5yaArRCrsghuSW4SE