-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
116 lines (91 loc) · 2.53 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
ENV__FILEPATH=.env.$(ENV)
include $(ENV_FILE_PATH)
COMPOSE_BASE_COMMAND=docker-compose --env-file $(ENV_FILE_PATH)
DOTENV_COMMAND=node node_modules/.bin/dotenv -e $(ENV_FILE_PATH)
.PHONY: compose-up
compose-up:
$(COMPOSE_BASE_COMMAND) up -d
.PHONY: compose-down
compose-down:
$(COMPOSE_BASE_COMMAND) down
.PHONY: run-database
run-database:
docker run -d \
--name $(DB_CONTAINER_NAME) \
-p $(DB_PORT):$(DB_PORT) \
-e PGDATA=/var/lib/postgresql/data/pgdata \
-e POSTGRES_USER=$(DB_USER) \
-e POSTGRES_PASSWORD=$(DB_PASS) \
-e POSTGRES_DB=$(DB_NAME) \
$(DB_TYPE):$(DB_VERSION)
.PHONY: start-database
start-database:
docker start $(DB_CONTAINER_NAME)
.PHONY: stop-database
stop-database:
docker stop $(DB_CONTAINER_NAME)
.PHONY: logs-database
logs-database:
docker logs $(DB_CONTAINER_NAME)
.PHONY: restart-database
restart-database:
docker restart $(DB_CONTAINER_NAME)
.PHONY: database-bash
database-bash:
docker exec -it $(DB_CONTAINER_NAME) bash
.PHONY: remove-database
remove-database:
docker rm -fv $(DB_CONTAINER_NAME)
.PHONY: remove-modules
remove-modules:
rm -rf node_modules
.PHONY: prisma-reset
prisma-reset:
$(DOTENV_COMMAND) -- npx prisma migrate reset --force --skip-seed
.PHONY: prisma-migrate
prisma-migrate:
$(DOTENV_COMMAND) -- yarn prisma migrate deploy
.PHONY: prisma-migrate-dev
prisma-migrate-dev:
$(DOTENV_COMMAND) -- yarn prisma migrate dev
.PHONY: run-app-test
run-app-test:
$(DOTENV_COMMAND) -- jest
.PHONY: db-seed-all
db-seed-all:
$(DOTENV_COMMAND) -- ts-node-dev -r tsconfig-paths/register \
prisma/seed/index.ts
.PHONY: db-seed-users
db-seed-users:
$(DOTENV_COMMAND) -- ts-node-dev -r tsconfig-paths/register \
prisma/seed/users/index.ts
.PHONY: app-serve-ts
app-serve-ts:
$(DOTENV_COMMAND) -- ts-node-dev -r tsconfig-paths/register \
--inspect --transpile-only --ignore-watch node_modules --respawn \
src/shared/infra/http/server.ts
.PHONY: app-serve-js
app-serve-js:
$(DOTENV_COMMAND) -- node dist/shared/infra/http/server.js
.PHONY: build
build:
node_modules/.bin/babel src --extensions \".ts\" --out-dir dist --copy-files
.PHONY: lint
lint:
node_modules/.bin/eslint . --ext .ts
.PHONY: lint-fix
lint-fix:
eslint . --ext .ts --fix
.PHONY: run-test-workflow
run-test-workflow:
yarn make:test run-database && \
yarn make:test prisma-migrate && \
yarn make:test db-seed-all && \
yarn make:test run-app-test; \
yarn make:test remove-database
.PHONY: serve-seed-dev
serve-seed-dev:
yarn make:dev compose-up && \
yarn make:dev prisma-migrate && \
yarn make:dev db-seed-all && \
yarn make:dev app-serve