2019-08-07 22:33:23 +00:00
|
|
|
.PHONY: help clean purge compile-contracts patch-ipfs mk-build-dir copy-misc copy-backend compile-js copy-frontend archive
|
|
|
|
|
2019-08-12 18:26:11 +00:00
|
|
|
export NODE_ENV ?= localhost
|
2019-08-07 22:33:23 +00:00
|
|
|
export WALLET_PASSWORD ?= dev_password
|
|
|
|
export WALLET_MNEMONIC ?= erupt point century seek certain escape solution flee elegant hard please pen
|
|
|
|
|
|
|
|
ifeq ($(NODE_ENV),production)
|
|
|
|
export EMBARK_TARGET ?= livenet
|
|
|
|
else
|
2019-08-12 18:26:11 +00:00
|
|
|
ifeq ($(NODE_ENV), localhost)
|
2019-08-12 16:00:59 +00:00
|
|
|
export EMBARK_TARGET ?= development
|
|
|
|
else
|
|
|
|
export EMBARK_TARGET ?= testnet
|
|
|
|
endif
|
2019-08-07 22:33:23 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
HELP_FUN = \
|
|
|
|
%help; \
|
|
|
|
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-]+)\s*:.*\#\#(?:@([a-zA-Z\-]+))?\s(.*)$$/ }; \
|
|
|
|
print "Usage: make [target]\n\n"; \
|
|
|
|
for (sort keys %help) { \
|
|
|
|
print "${WHITE}$$_:${RESET}\n"; \
|
|
|
|
for (@{$$help{$$_}}) { \
|
|
|
|
$$sep = " " x (22 - length $$_->[0]); \
|
|
|
|
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
|
|
|
|
}; \
|
|
|
|
print "\n"; \
|
|
|
|
}
|
|
|
|
|
|
|
|
help: ##@miscellaneous Show this help.
|
|
|
|
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
|
|
|
|
|
|
|
|
all: ##@build Build the final app.zip from scratch
|
2019-08-12 16:00:59 +00:00
|
|
|
all: node_modules clean compile-contracts patch-ipfs mk-build-dir copy-misc copy-backend compile-js copy-frontend archive install-build
|
2019-08-12 18:26:11 +00:00
|
|
|
ifneq ($(NODE_ENV),localhost)
|
2019-08-07 22:33:23 +00:00
|
|
|
@echo "SUCCESS! Use the app.zip file."
|
2019-08-12 16:00:59 +00:00
|
|
|
else
|
2019-08-12 16:03:33 +00:00
|
|
|
@echo "SUCCESS! Execute 'yarn server-start' and browse http://localhost:4000"
|
2019-08-12 16:00:59 +00:00
|
|
|
endif
|
2019-08-07 22:33:23 +00:00
|
|
|
|
|
|
|
node_modules: ##@install Install the Node.js dependencies using Yarn
|
|
|
|
yarn install
|
|
|
|
|
|
|
|
check-prod-vars: ##@checks Check if the necesary env variables are set
|
|
|
|
ifeq ($(NODE_ENV),production)
|
|
|
|
[[ -z "${WALLET_MNEMONIC}" ]] && { echo "Not defined: WALLET_MNEMONIC"; exit 1 }
|
|
|
|
[[ -z "${WALLET_PASSWORD}" ]] && { echo "Not defined: WALLET_PASSWORD"; exit 1 }
|
|
|
|
else
|
2019-08-12 18:26:11 +00:00
|
|
|
ifneq ($(NODE_ENV),$(filter $(NODE_ENV),development localhost))
|
2019-08-07 22:33:23 +00:00
|
|
|
@echo "Unknown NODE_ENV value: ${NODE_ENV}"
|
2019-08-12 18:26:11 +00:00
|
|
|
@echo "Use 'production' or 'development' or 'localhost'."
|
2019-08-07 22:33:23 +00:00
|
|
|
exit 1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
compile-contracts: ##@compile Compile the contracts using Embark.js
|
|
|
|
compile-contracts: check-prod-vars
|
|
|
|
./node_modules/.bin/embark build "${EMBARK_TARGET}"
|
|
|
|
|
|
|
|
compile-js: ##@compile Compile the React application
|
|
|
|
./node_modules/.bin/react-scripts build
|
|
|
|
|
|
|
|
patch-ipfs: ##@patch Patch the deprecated id() call in IPFS API
|
|
|
|
sed -i 's#_ipfsConnection.id#_ipfsConnection.version#' \
|
|
|
|
src/embarkArtifacts/embarkjs.js
|
|
|
|
|
|
|
|
mk-build-dir: ##@create Create the destination directory for full build
|
|
|
|
mkdir full-build
|
|
|
|
|
|
|
|
copy-backend: ##@copy Copy over the backend files to full-build dir
|
|
|
|
cp -r back-end/* full-build/
|
|
|
|
|
|
|
|
copy-frontend: ##@copy Copy over the frontend files to full-build dir
|
|
|
|
mkdir full-build/frontend
|
|
|
|
cp -r build/* full-build/frontend/
|
|
|
|
|
|
|
|
copy-misc: ##@copy Copy over the miscalenious config config files
|
|
|
|
cp .npmrc full-build/
|
|
|
|
|
2019-08-12 16:00:59 +00:00
|
|
|
|
|
|
|
archive: ##@archive Create the app.zip archive for use with ElasticBeanstalk when running on testnet or mainnet
|
2019-08-12 18:26:11 +00:00
|
|
|
ifneq ($(NODE_ENV),localhost)
|
2019-08-07 22:33:23 +00:00
|
|
|
archive: clean-archive
|
|
|
|
cd full-build && zip -r ../app.zip ./
|
2019-08-12 16:00:59 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
install-build:
|
2019-08-12 18:26:11 +00:00
|
|
|
ifeq ($(NODE_ENV),localhost)
|
2019-08-12 16:00:59 +00:00
|
|
|
cd full-build && yarn
|
|
|
|
endif
|
2019-08-07 22:33:23 +00:00
|
|
|
|
|
|
|
clean-archive: ##@clean Remove app.zip
|
2019-08-12 18:26:11 +00:00
|
|
|
ifneq ($(NODE_ENV),localhost)
|
2019-08-07 22:33:23 +00:00
|
|
|
rm -f app.zip
|
2019-08-12 16:00:59 +00:00
|
|
|
endif
|
2019-08-07 22:33:23 +00:00
|
|
|
|
|
|
|
clean-build-dir: ##@clean Remove full-build dir
|
|
|
|
rm -fr full-build
|
|
|
|
|
|
|
|
clean: clean-build-dir clean-archive ##@clean Cleanup all the build artifacts
|
|
|
|
|
|
|
|
purge: ##@clean Remove everything that isn't committed
|
|
|
|
git clean -dxf -f
|