-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
176 lines (127 loc) · 6.44 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
.PHONY: build-dapp build-indexer build-purs-editor build-purs-strict build-purs-watch build-purs build-server clean-dapp compile-contracts deploy-contracts faucet-locally frontend-build frontend-start-https frontend-start haskell-deps help hlint install migrate-ext migrate purs-repl run-gql-dev run-gql-server run-indexer run-server show-migrations-ext show-migrations signal-locally stylish test-dapp
.DEFAULT_GOAL := help
export
# see https://stackoverflow.com/a/26936855/1798418
PATH := node_modules/.bin:$(PATH)
SHELL := /bin/bash
NODE_URL ?= http://localhost:8545
ABIS_DIR ?= build
# default is cliquebait
NODE_URL = http://localhost:8545
SERVER_PORT = 9000
SERVER_BASE_HOST ?= localhost
SERVER_BASE_URL ?= //$(SERVER_BASE_HOST)
API_BASE_URL ?= $(SERVER_BASE_URL):$(SERVER_PORT)/
PG_BASE_DATABASE ?= postgres
PGDATABASE ?= signal_market
PGHOST ?= localhost
PGPORT ?= 5555
PGPASSWORD ?= password
PGUSER ?= postgres
GRAPHQL_PORT ?= 3003
GRAPHQL_API ?= 3003
GRAPHQL_PATH ?= /
GRAPHQL_PG_SCHEMAS ?= public
GRAPHQL_SIMPLE_AUTH_TOKEN ?= super_secret_token
GRAPHQL_API_URL ?= http://localhost:3003/graphql
REDIS_HOST ?= localhost
REDIS_PORT ?= 6379
PSQL ?= docker-compose run postgis psql
FLYWAY ?= docker-compose run flyway
NODE_ENV ?= development
# end export
# please keep that, it helps with autogenerating env wrappers
help: ## Ask for help!
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
all: install
@echo prereqs that are newer than install: $?
install: ## Runs npm and bower install
npm install
bower install
# hack to build purs deps only
pulp build --src-path dapp/contracts
cd graphql-server && npm install
############
# postgres
############
migrate: ## Run the flyway migration suite to setup postgis
PGDATABASE=$(PG_BASE_DATABASE) $(PSQL) -h postgis -p 5432 -U $(PGUSER) -tc "SELECT 1 FROM pg_database WHERE datname = '$(PGDATABASE)'" | grep -q 1 || \
PGDATABASE=$(PG_BASE_DATABASE) $(PSQL) -h postgis -p 5432 -U $(PGUSER) -c "CREATE DATABASE $(PGDATABASE);"
# the -jarDirs is temporary fix for https://github.com/NixOS/nixpkgs/issues/59687
$(FLYWAY) -user=$(PGUSER) -password=$(PGPASSWORD) -url=jdbc:postgresql://postgis:5432/$(PGDATABASE) -locations=filesystem:/flyway/sql/migrations -baselineOnMigrate=true migrate
migrate-ext: ## Run the flyway migration suite against an external Postgres server
$(FLYWAY) -user=$(PGUSER) -password=$(PGPASSWORD) -url=jdbc:postgresql://$(PGHOST):$(PGPORT)/$(PGDATABASE) -locations=filesystem:/flyway/sql/migrations -baselineOnMigrate=true migrate
show-migrations: ## Describe the migrations in the current database
$(FLYWAY) -user=$(PGUSER) -password=$(PGPASSWORD) -url=jdbc:postgresql://postgis:5432/$(PGDATABASE) -locations=filesystem:/flyway/sql/migrations -baselineOnMigrate=true info
show-migrations-ext: ## Describe the migrations in the current database on an external Postgres server
$(FLYWAY) -user=$(PGUSER) -password=$(PGPASSWORD) -url=jdbc:postgresql://$(PGHOST):$(PGPORT)/$(PGDATABASE) -locations=filesystem:/flyway/sql/migrations -baselineOnMigrate=true info
####################
# DAPP #
####################
compile-contracts: ## Compile all contracts in dapp and write purescript ffi modules
chanterelle compile && chanterelle codegen
build-dapp: ## Build the deploy script
pulp build --src-path dapp/src
deploy-contracts: build-dapp ## Deploy contracts in dapp project
chanterelle deploy ./output/Deploy.Main/index.js --node-url "$(NODE_URL)"
test-dapp: ## Run the dapp unit test suite
pulp test --src-path dapp/src --test-path dapp/test -m Test.Unit.Main -I frontend
test-e2e: ## Run the dapp unit test suite
pulp test --src-path dapp --test-path e2e -m E2E.Main -I frontend
clean-dapp: ## Clean up DApp related build artifacts
rm -f build/**/*.json
rm -rf output/Contracts.**
rm -rf dapp/src/Contracts
####################
# Haskell #
####################
haskell-deps: ## install supporting haskell-deps
stack install hlint stylish-haskell
hlint: ## Run hlint on all haskell projects
stack exec hlint -- -h .hlint.yaml server common indexer
stylish: ## Run stylish-haskell over all haskell projects
find ./server ./common ./indexer -name "*.hs" | xargs stack exec stylish-haskell -- -c ./.stylish_haskell.yaml -i
####################
# SERVER #
####################
build-server: ## build server and install binaries
stack install server
run-server: build-server ## run the server
stack exec -- server-exe
####################
# Indexer #
####################
build-indexer: ## build indexer and install binaries
stack install indexer
run-indexer: build-indexer ## run the indexer
stack exec -- indexer-exe
####################
# frontend #
####################
frontend-start: ## Starts webserver with livereload, (you might want to build all purescript sources first). Note that you should also be running PureScript IDE server which compiles PureScript files on change, If it's not the case for you run `make build-purs-watch` too.
webpack-dev-server --port 3333 --hot --host 0.0.0.0
frontend-start-https: ## Same as `frontend-start`, but running with `https`
webpack-dev-server --port 3333 --hot --host 0.0.0.0 --https
frontend-build: ## Builds css html and js assets.
webpack
build-purs-strict: ## Build whole purescript src and test file in strict mode
pulp build --jobs 8 --src-path frontend/src -I dapp/src -- --strict
build-purs: ## Build whole purescript src and test file
pulp build --jobs 8 --src-path frontend/src -I dapp/src
purs-repl: ## Run a pulp repl against the purescript sources
pulp repl --src-path frontend/src -I dapp/src
build-purs-watch: ## same as `make build-purs` but watches for changes for re-building
pulp -w build --jobs 8 --src-path frontend/src -I dapp/src
build-purs-editor: ## Same as `make build-purs` but with json output, it's used in `purescript.buildCommand` of `.vscode/settings.json`, this could potentially be useful for Atom users too.
pulp build --jobs 8 --src-path frontend/src -I dapp/src -- --json-errors
faucet-locally: ## Faucet some ETH locally
pulp run --jobs 8 --src-path dapp/scripts -I dapp/src:frontend/src -m Faucet
signal-locally: ## Create signal locally
pulp run --jobs 8 --src-path dapp/scripts -I dapp/src:frontend/src -m Signal
####################
# GraphQL Server #
####################
run-gql-server: ## run the graphql server
cd graphql-server && npm run start
run-gql-dev: ## run the graphql server in dev mode
cd graphql-server && npm run dev