hs-client
hs-client copied to clipboard
bin: replace shell scripts with js require
hs{d,w}-rpc scripts are currently shell scripts and depend on perl on macos.
This replaces them with simpler js requires.
It's a breaking change since CLI.open() / CLI.handleWallet() are only called when run as a script, not required. This way the CLI class can be required by other scripts.
This has a sibling PR on hsd:
- https://github.com/handshake-org/hsd/pull/746
I did think of simply rewriting the shell script and calling nodejs again with child_process exec or something, but this seems cleaner without leaving the current process, even if it means a bit of change to hsd.
If child_process is still preferred, I'll change it to that.
Also thinking if we should remove hs{d,w}-cli from hsd completely. Installing both hs-client and hsd globally errors in npm like:
npm ERR! code EEXIST
npm ERR! path /home/rithvik/.nvm/versions/node/v16.13.0/bin/hsd-cli
npm ERR! EEXIST: file already exists
npm ERR! File exists: /home/rithvik/.nvm/versions/node/v16.13.0/bin/hsd-cli
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
I just --force here because it's the same file, but not ideal.
This also happens when using npm link with hsd because that symlinks a local dir to global scope.
Take a look at https://github.com/bcoin-org/bcoin/pull/838
...should we just move the entire client into hsd repo?
Pros:
- bin/hsd-cli and bin/hsw-cli are JS scripts and require files from lib/client instead of another package
- atomic updates to client and server, PRs update both and there's only one release Cons:
- applications that only need the client... we may need to backport to
hs-clientor publish the npm module directly from hsd/lib/client (see discussion in the bcoin issue & PR)
Imo there should be a dedicated package for client that doesn't need native modules, whether it's from a different repo or part of hsd.
Read that PR and your comment here seems like the best way: https://github.com/bcoin-org/bcoin/issues/834#issuecomment-528904949. I'll try that.
see https://github.com/handshake-org/hsd/pull/746#issuecomment-1662663076