-
-
Notifications
You must be signed in to change notification settings - Fork 75
/
Makefile
77 lines (64 loc) · 2.57 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
all:
make start & make backend-webpack & make frontend-webpack
# $(npm bin)/nodemon doesn't work, npm bin is '' then.
start:
NODE_ENV=development node_modules/.bin/nodemon --inspect --watch backend backend/webpacked/index.js
# build and watch
backend-webpack:
cd backend; ../node_modules/.bin/webpack --config ./webpack/development.config.js -w
frontend-webpack:
cd frontend; ../node_modules/.bin/webpack --config ./webpack/development.config.js -w
# database
db-drop:
psql -U postgres -c 'DROP DATABASE IF EXISTS memcode'
db-reset:
# 'database=' here is a variable used in schema.sql (-v).
psql -v database=memcode -U postgres -f backend/db/schema.sql
db-migrate:
psql -v database=memcode -U postgres -f backend/db/migrations/15.sql
# dump and restore data
db-dump:
pg_dump -d memcode -U postgres > backend/db/dump.sql
db-restore:
psql -d memcode -U postgres < backend/db/dump.sql
# test
test-db-reset:
psql -v database=memcode_test -U postgres -f backend/db/schema.sql
test-backend:
cd backend; NODE_ENV=test ../node_modules/.bin/mocha --recursive ./webpacked/test --require babel-polyfill --require source-map-support/register
test-frontend:
cd frontend; NODE_ENV=test ../node_modules/.bin/karma start
# production
heroku-postbuild:
# npm install
# is run automatically. since we need to compile code on heroku, we need our devDependencies installed too. so I set
# heroku config:set NPM_CONFIG_PRODUCTION=false
# for this purpose.
touch env.js;
make heroku-backend-webpack &
make heroku-frontend-webpack
heroku-deploy:
git push heroku master
heroku-backend-webpack:
cd backend; ../node_modules/.bin/webpack --config ./webpack/production.config.js
heroku-frontend-webpack:
cd frontend; ../node_modules/.bin/webpack --config ./webpack/production.config.js
DB_URL = $$(heroku config:get DATABASE_URL --app memcode)
# ___Where did we get these credentials from?
# Find our credentials from `heroku config`
# ___How to run a particular migration?
# Manually input migration you want to run (eg 1.sql)
# ___Where is 7.sql taken from?
# From local files!
heroku-db-migrate:
psql -v database=d9glthq2q1grjs $(DB_URL) -f backend/db/migrations/14.sql
heroku-db-console:
psql -v $(DB_URL)
# when they ask for password - they ask for the local one (yes, 4 times)
heroku-db-pull:
make db-drop
PGUSER=postgres PGPASSWORD=§1§1§1 heroku pg:pull DATABASE_URL memcode --app memcode
# when they ask for password - they ask for the local one (yes, 4 times)
# heroku-pg-push:
# PGUSER=postgres heroku pg:reset DATABASE_URL
# PGUSER=postgres heroku pg:push memcode DATABASE_URL --app memcode