-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
116 lines (82 loc) · 2.23 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
SHELL := /bin/bash
all: install build
########################################################
install: install_nvm install_rustup install_cargo_watch install_api install_ui
install_nvm:
@if [ -z "${NVM_DIR}" ]; then\
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | sh; \
nvm use; \
fi
install_rustup:
@if [ -z "${NVM_DIR}" ]; then\
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh; \
rustup default nightly; \
fi
install_api: build_api
install_cargo_watch:
cargo install cargo-watch --force
install_ui:
pushd ui && \
npm i && \
popd
########################################################
build: build_api build_ui
build_api: # TODO: Docker
pushd api && \
cargo build && \
popd
build_ui: # TODO: Docker
pushd ui && \
npm run build && \
popd
########################################################
test: test_api test_ui
test_api:
pushd api && \
cargo test && \
popd
test_ui:
pushd ui && \
npm test && \
popd
########################################################
clean: clean_containers clean_api clean_ui
clean_containers:
docker-compose -f ./docker-compose.dev.yml -f ./docker-compose.yml stop && \
docker-compose -f ./docker-compose.dev.yml -f ./docker-compose.yml rm
clean_api:
pushd api && \
cargo clean && \
popd
clean_ui:
pushd ui && \
rm -rf ./node_modules ./static/* && \
popd
clean_migrations:
source ./.env && \
pushd api && \
rm -f src/schema.rs && \
popd
# psql -c "UPDATE pg_database SET datallowconn = 'false' WHERE datname = 'squrt'; SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'squrt';" $DATABASE_CLI_URL && \
# psql -c "DROP DATABASE squrt" $DATABASE_CLI_URL && \
########################################################
run:
npx concurrently "make run_ui" "make run_containers" "make run_api"
run_ui:
pushd ui && \
NODE_ENV=development npm start && \
popd
run_api:
pushd ui && \
DEBUG=1 cargo watch -x run && \
popd
run_containers:
docker-compose -f ./docker-compose.dev.yml -f ./docker-compose.yml up -d
run_migrations: load_env
pushd api && \
diesel setup && \
diesel migration run && \
popd
##########################################################
load_env:
source ./.env