hs-client icon indicating copy to clipboard operation
hs-client copied to clipboard

bin: replace shell scripts with js require

Open rithvikvibhu opened this issue 3 years ago • 3 comments

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.

rithvikvibhu avatar Jun 20 '22 17:06 rithvikvibhu

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.

rithvikvibhu avatar Jun 29 '22 06:06 rithvikvibhu

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-client or publish the npm module directly from hsd/lib/client (see discussion in the bcoin issue & PR)

pinheadmz avatar Jul 25 '22 14:07 pinheadmz

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.

rithvikvibhu avatar Jul 30 '22 11:07 rithvikvibhu

see https://github.com/handshake-org/hsd/pull/746#issuecomment-1662663076

rithvikvibhu avatar Aug 02 '23 17:08 rithvikvibhu