Closed iostat closed 5 years ago
Main issue with running chanterelle locally is that if you execute deploy command it will require(...)
specified js deploy script and for it to work, both chanterelle executable and the script shuold should be compiled together so Instance of checks don't fail. executing other commands from global executable is fine. I think we can merge this and think about this issue and fix it later.
Maybe we can disable deploy when global exeutable is used for example.
Would you be updating Docs in this PR?
Thanks for the reminder about docs, will do so prior to merging.
Currently, a ChanterelleMain has to be compiled within your project's PureScript output directly for the
chanterelle
command to work. This can lead to chicken-and-egg situations where your only dependency on Chanterelle is for deployments, which require you tochanterelle codegen
to get the PureScript bindings for your Solidity contracts, but you can't use thechanterelle compile/codegen
commands to do anything because if the rest of your project can't compile,ChanterelleMain
can't get compiled either.This PR modifies
package.json
to notify the user to runchanterelle postinstall
if they want to be able to use a fallback "global" install. Note that this can't be automated as a package.jsonpostinstall
script as it may fail in cases wherenpm
is running as root or the user doesn't have pulp/bower/etc. globally available. Assudo npm install
is considered a Very Bad Practice™ anyway, we don't attempt to support that mode any more than is feasible. NVM is a recommended way to manage global package sets for those kinds of use-cases anyway. (For instance, you can'tsudo npm install -g purescript
becausepostinstall
s run asnobody
and thepurescript
postinstaller can't download thepurs
binary, and we needpurescript
to build).If a project-local ChanterelleMain is available, the old behavior is resumed. If not, the user is notified that we are attempting to fall back to a global install. If a global install is not available, the user is prompted to run
chanterelle global-postinstall
to set up a global installation.chanterelle global-postinstall
is idempotent (but exits with nonzero in case there's nothing to do and--force
isn't specified) and can be put into build scripts. Runningglobal-postinstall
with a global installation already set up should be near instant, as it merely checks thatChanterelleMain
was built in the same directory as the realchanterelle-bin.sh
In principle, these changes should also allow users who want to do stuff like
npm run <some-script-that-calls-chanterelle>
and have it use their project'snode_modules/chanterelle
. they'd likely have tochanterelle global-postinstall || true && chanterelle whatever-they-want-to-do
in their package.json scripts. small price to pay for bulletproof builds imo.