This repository has been archived by the owner on Jan 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
230 lines (180 loc) · 6.42 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# Default target
.DEFAULT_GOAL := check
# Make one-item-per-line work
NULL :=
# Get the absolute path to the repository
EQUATER_GIT_ROOT := $(shell git rev-parse --show-toplevel)
EQUATER_NODE_VERSION := 16.13.1
###############################################
# Run targets
###############################################
run/dev/api:
cd $(EQUATER_GIT_ROOT)/equater-api && npm run start:dev
run/dev/web:
cd $(EQUATER_GIT_ROOT)/equater-web && npm run dev
run/dev/docker:
cd $(EQUATER_GIT_ROOT) && docker compose up
run/dev/ngrok:
ngrok start equater-api equater-web-client
# Should only be used for troubleshooting containers
run/dev/web/docker-local:
cd $(EQUATER_GIT_ROOT)/equater-web && docker run --env-file .env.local -p 127.0.0.1:3000:3000 web
# Should only be used for troubleshooting containers
run/dev/api/docker-local:
cd $(EQUATER_GIT_ROOT)/equater-api && docker run --env-file .env -p 127.0.0.1:3001:3000 api
###############################################
# Deploy targets
###############################################
deploy/staging/web:
git push heroku/web/staging main
deploy/prod/web:
git push heroku/web/prod main
deploy/staging/api:
git push heroku/api/staging main
deploy/prod/api:
git push heroku/api/prod main
###############################################
# Bootstrap targets (mac-only for now)
###############################################
bootstrap: bootstrap/install bootstrap/ios bootstrap/api bootstrap/web build/android
bootstrap/install:
echo "Installing cocoapods..."
$(install/cocoapods)
echo "Cocoapods was installed"
echo "Installing homebrew"
$(install/homebrew)
echo "Homebrew was installed"
echo "Installing swiftformat"
$(install/swiftformat)
echo "swiftformat was installed"
echo "Installing npm"
$(install/npm)
echo "npm was installed"
echo "Next steps: Install ngrok, docker, setup .env files for web + api, setup .xcconfig files for ios, an set up ~/.gradle/gradle.properties for android."
install/homebrew:
command -v brew || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
install/cocoapods:
command -v pod || sudo gem install cocoapods
install/swiftformat:
command -v swiftformat || brew install swiftformat
install/npm:
command -v nvm || curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
command -v npm || nvm install $(EQUATER_NODE_VERSION) && nvm use $(EQUATER_NODE_VERSION)
install/ktlint:
command -v ktlint || brew install ktlint
bootstrap/ios:
cd $(EQUATER_GIT_ROOT)/equater-ios pod-install --repo-update && cd $(EQUATER_GIT_ROOT)
cd $(EQUATER_GIT_ROOT)
# TODO: .env file
bootstrap/api:
cd $(EQUATER_GIT_ROOT)/equater-api && npm i
docker compose up -d
cd terraform && terraform init && terraform apply -auto-approve
# TODO: .env file
bootstrap/web:
cd $(EQUATER_GIT_ROOT)/equater-web && npm i
###############################################
# Build targets
###############################################
build/api:
cd $(EQUATER_GIT_ROOT)/equater-api && \
npm run build && \
cd $(EQUATER_GIT_ROOT)
build/web:
cd $(EQUATER_GIT_ROOT)/equater-web && \
npm run build && \
cd $(EQUATER_GIT_ROOT)
build/ios:
cd $(EQUATER_GIT_ROOT)/equater-ios && \
xcodebuild -scheme "Equater" build && \
cd $(EQUATER_GIT_ROOT)
# Note: Must have JAVA_HOME set to a Java 11 runtime
build/android:
cd $(EQUATER_GIT_ROOT)/equater-android && \
./gradlew build
build/cli:
cd $(EQUATER_GIT_ROOT)/equater-cli && \
cargo b && \
cd $(EQUATER_GIT_ROOT)
clean/api:
cd $(EQUATER_GIT_ROOT)/equater-api && \
npm run clean && \
cd $(EQUATER_GIT_ROOT)
clean/web:
cd $(EQUATER_GIT_ROOT)/equater-web && \
npm run clean && \
cd $(EQUATER_GIT_ROOT)
clean/ios:
cd $(EQUATER_GIT_ROOT)/equater-ios && \
xcodebuild -scheme "Equater" clean && \
cd $(EQUATER_GIT_ROOT)
clean/android:
cd $(EQUATER_GIT_ROOT)/equater-android && \
./gradlew clean && \
cd $(EQUATER_GIT_ROOT)
clean/cli:
cd $(EQUATER_GIT_ROOT)/equater-cli && \
cargo clean && \
cd $(EQUATER_GIT_ROOT)
###############################################
# Test targets
###############################################
test/api:
cd $(EQUATER_GIT_ROOT)/equater-api && \
npm test && \
cd $(EQUATER_GIT_ROOT)
###############################################
# Format targets
###############################################
format: format/api format/web format/ios format/android
format/api:
npx --yes prettier --write $(EQUATER_GIT_ROOT)/equater-api/src/**/*.ts
format/web:
npx --yes prettier --write "$(EQUATER_GIT_ROOT)/equater-web/components/**/*.ts"
npx prettier --write "$(EQUATER_GIT_ROOT)/equater-web/constants/**/*.ts"
npx prettier --write "$(EQUATER_GIT_ROOT)/equater-web/hooks/**/*.ts"
npx prettier --write "$(EQUATER_GIT_ROOT)/equater-web/redux/**/*.ts"
npx prettier --write "$(EQUATER_GIT_ROOT)/equater-web/services/**/*.ts"
npx prettier --write "$(EQUATER_GIT_ROOT)/equater-web/types/**/*.ts"
npx prettier --write "$(EQUATER_GIT_ROOT)/equater-web/utils/**/*.ts"
format/ios:
swiftformat $(EQUATER_GIT_ROOT)/equater-ios/.
format/android:
cd $(EQUATER_GIT_ROOT)/equater-android && \
./gradlew ktlintFormat -p $(EQUATER_GIT_ROOT)/equater-android
format/cli:
cd $(EQUATER_GIT_ROOT)/equater-cli && \
cargo fmt --all
###############################################
# Lint targets
###############################################
check: check/api check/web check/ios check/android check/cli
check/api:
npx --yes prettier --check "$(EQUATER_GIT_ROOT)/equater-api/src/**/*.ts"
$(build/api)
check/web:
npx --yes prettier --check "$(EQUATER_GIT_ROOT)/equater-web/components/**/*.ts"
npx prettier --check "$(EQUATER_GIT_ROOT)/equater-web/constants/**/*.ts"
npx prettier --check "$(EQUATER_GIT_ROOT)/equater-web/hooks/**/*.ts"
npx prettier --check "$(EQUATER_GIT_ROOT)/equater-web/redux/**/*.ts"
npx prettier --check "$(EQUATER_GIT_ROOT)/equater-web/services/**/*.ts"
npx prettier --check "$(EQUATER_GIT_ROOT)/equater-web/types/**/*.ts"
npx prettier --check "$(EQUATER_GIT_ROOT)/equater-web/utils/**/*.ts"
$(build/web)
# TODO: Get iOS build working in CI
check/ios:
swiftformat --lint equater-ios/Equater
# build/ios
check/android:
cd $(EQUATER_GIT_ROOT)/equater-android && ./gradlew ktlint
$(build/android)
check/cli:
cd $(EQUATER_GIT_ROOT)/equater-cli && \
cargo clippy --all-features --all-targets --all && \
cd $(EQUATER_GIT_ROOT)
$(build/cli)
###############################################
# Update targets
###############################################
update/rust:
rustup update stable