This repository has been archived by the owner on Jul 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
235 lines (195 loc) · 5.91 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
231
232
233
234
235
.ONESHELL:
SHELL=bash
default:
make --no-print-directory test-frontend FILES=frontend/tests/src/pages/EmailChangePageTest.tsx
h:
make --no-print-directory build PROJECT=frontend/pages/home
hw:
make --no-print-directory watch PROJECT=frontend/pages/home
fonts: frontend/shared/fonts/fonts.css
frontend/shared/fonts/fonts.css:
set -e
rm -rf $(@D)
mkdir -p $(@D)
( \
echo 'https://fonts.googleapis.com/css2?family=Vollkorn:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,400;1,500;1,600;1,700;1,800;1,900&display=swap'; \
echo 'https://fonts.googleapis.com/css2?family=Inria+Sans:ital,wght@0,300;0,400;0,700;1,300;1,400;1,700&display=swap'; \
) \
| while read url; do \
curl \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:69.0) Gecko/20100101 Firefox/69.0' \
--fail "$$url" >> $@; \
done
grep -Po 'https://fonts.gstatic.com\S+.woff2' $@ | xargs wget --continue --directory-prefix=$(@D)/
sed -i 's|https://fonts.gstatic.com/.*/|fonts/|' $@
cf: clean-fonts fonts
clean-fonts:
rm -rf frontend/shared/fonts
test: test-backend test-frontend
t: test
test-backend: node_modules
@set -e
echo -e "\nRunning backend tests:"
source .env.test
DEBUG=app:none \
TS_NODE_PROJECT=backend/tests/tsconfig.json \
TS_NODE_TRANSPILE_ONLY=true \
TS_NODE_SCOPE=true \
~/.nvm/nvm-exec \
node --no-deprecation `# avoid "DeprecationWarning: OutgoingMessage.prototype._headers is deprecated" caused by timed-out` \
node_modules/.bin/mocha \
--require ts-node/register \
--require tsconfig-paths/register \
--require amd-loader \
--reporter dot \
--file backend/tests/src/TestHelpers.ts \
--exit `# this is related to chai-http hanging Mocha` \
$${FILES:-'backend/tests/**/*Test.ts'}
tb: test-backend
test-frontend: node_modules
@set -e
echo -e "\nRunning frontend tests:"
TS_NODE_PROJECT=frontend/tests/tsconfig.json \
TS_NODE_TRANSPILE_ONLY=true \
TS_NODE_SCOPE=true \
~/.nvm/nvm-exec node_modules/.bin/mocha \
--require ts-node/register \
--require tsconfig-paths/register \
--require amd-loader \
--reporter dot \
--file frontend/tests/src/TestHelpers.ts \
$${FILES:-'frontend/tests/**/*Test.ts?'}
tf: test-frontend
c: build
build: node_modules fonts
~/.nvm/nvm-exec \
node_modules/.bin/tsc --build -v $(PROJECT)
cc: clean build
watch: node_modules
@~/.nvm/nvm-exec node_modules/.bin/tsc \
--build \
--watch \
--preserveWatchOutput \
$(PROJECT) \
| tee >( \
while read line; do
STATUS_LINE=`echo $$line | grep -Po 'Found \d+ errors?'`
if [ ! "$$STATUS_LINE" ]; then continue; fi
if [ "$$STATUS_LINE" = "Found 0 errors" ]; then
osascript -e "display notification \"Compilation complete\" with title \"✅ repetitor.tsx\""
else
osascript -e "display notification \"Compilation failed: $$STATUS_LINE\" with title \"❌ repetitor.tsx\""
fi
done \
)
start: build
@set -e
TS_NODE_PROJECT=backend/tsconfig.json \
~/.nvm/nvm-exec node_modules/.bin/nodemon \
--watch backend/src \
--watch backend/tsconfig.json \
--watch shared/src \
--watch shared/tsconfig.json \
--ext ts \
--exec 'heroku local'
e: edit
edit:
code -n .
open:
open http://localhost:$(PORT)
o: open
NPM_MODULES=. backend frontend
npm-update:
@set -x
for dir in $(NPM_MODULES); do
(cd $$dir; npm --depth 999 update)
done
audit:
@set -x
for dir in $(NPM_MODULES); do
(cd $$dir; npm audit)
done
node_modules: package.json ~/.nvm $(NODE_BINARY_PATH) frontend/node_modules backend/node_modules
backend/node_modules: backend/package.json
frontend/node_modules: frontend/package.json
node_modules backend/node_modules frontend/node_modules:
@set -e
(cd $(@D) && ~/.nvm/nvm-exec npm install)
touch $@
clean:
rm -rf \
shared/build/ \
backend/build/ \
backend/tests/build/ \
frontend/shared/build/ \
frontend/pages/*/build/
uninstall: clean
rm -rf {.,backend,frontend}/node_modules
NODE_BINARY_PATH=$(shell echo "~/.nvm/versions/node/`cat .nvmrc`/bin/node")
$(NODE_BINARY_PATH):
~/.nvm/nvm-exec nvm install
~/.nvm:
@echo "Install nvm from here: https://github.com/nvm-sh/nvm"
exit 1
pre-commit: check-for-only
time make --no-print-directory lint clean build pre-commit-test
pc: pre-commit
pre-commit-test:
TEST_EMAIL_UTILS=yes \
TEST_FILE_STORAGE=yes \
time make --no-print-directory test
pct: pre-commit-test
check-for-only:
@grep -nRP '.(only|skip)\(' {frontend,backend}/tests/src \
&& {
echo -e "\nSome Mocha tests are .only or .skip.\n"
exit 1
} \
|| exit 0
lint:
eslint . \
--ignore-path .gitignore \
--ext .ts,.tsx
l: lint
migrate:
@set -e
if [ ! "$$NODE_ENV" ] || [ "$$NODE_ENV" == "development" ]; then source .env; else source .env.$$NODE_ENV; fi
db-migrate $${DIRECTION:-up} \
--env $${NODE_ENV:-development} \
--config backend/migrations/config.json \
--migrations-dir backend/migrations
mup:
@make migrate --no-print-directory DIRECTION=up
mdown:
@make migrate --no-print-directory DIRECTION=down
m mtry: mup mdown
migration:
@set -e
if [ ! "$$NODE_ENV" ] || [ "$$NODE_ENV" == "development" ]; then source .env; else source .env.$$NODE_ENV; fi
read -p "Migration title: " MIGRATION_TITLE
db-migrate create $$MIGRATION_TITLE \
--env $${NODE_ENV:-development} \
--config backend/migrations/config.json \
--migrations-dir backend/migrations
mcheck:
@db-migrate $${DIRECTION:-up} \
--check \
--env $${NODE_ENV:-development} \
--config backend/migrations/config.json \
--migrations-dir backend/migrations
sql:
@set -e
if [ ! "$$NODE_ENV" ] || [ "$$NODE_ENV" == "development" ]; then source .env; else source .env.$$NODE_ENV; fi
mysql --host $$APP_DB_HOST --user $$APP_DB_USER --password=$$APP_DB_PASSWORD $$APP_DB_NAME
pretty:
git ls-tree -r master --name-only | xargs prettier --write
format: pretty
heroku-setup: h-expose-release-env h-env
h-env:
sed 's/^export //' .env.production \
| xargs heroku config:set \
--app repetitor
h-tail:
heroku logs --tail --app repetitor
h-expose-release-env:
heroku labs:enable runtime-dyno-metadata --app repetitor