forked from franky47/delta-v
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
163 lines (128 loc) · 5.2 KB
/
Copy pathmakefile
File metadata and controls
163 lines (128 loc) · 5.2 KB
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
DOCKER_COMPOSE = docker-compose
USER = --user $$(id -u):$$(id -g)
DOCKER_COMPOSE_RUN = $(DOCKER_COMPOSE) run $(USER)
FRONT_CONTAINER = frontend-web-delta-v
STORYBOOK_CONTAINER = storybook-delta-v
BACK_CONTAINER = backend-api-delta-v
DATABASE_CONTAINER = database-delta-v
ADMIN_DATABASE_CONTAINER = adminer
TEST_BACK_CONTAINER = e2e-test-backend-api-delta-v
TEST_DATABASE_CONTAINER = e2e-test-database-delta-v
DATABASE_CONTAINERS = $(DATABASE_CONTAINER) $(ADMIN_DATABASE_CONTAINER)
BACK_CONTAINERS = $(BACK_CONTAINER) $(DATABASE_CONTAINERS)
##
## -------------------------
## | Delta V - Dev |
## -------------------------
##
##
## -- DOCKER MANAGER --
##
.PHONY: start-back
start-back: ## Start the backend containers
$(DOCKER_COMPOSE) up -d --remove-orphans $(BACK_CONTAINERS)
$(DOCKER_COMPOSE) logs -f $(BACK_CONTAINER)
.PHONY: start-front
start-front: ## Start the frontend containers
$(DOCKER_COMPOSE) up --remove-orphans $(FRONT_CONTAINER)
.PHONY: start-storybook
start-storybook: ## Start the storybook containers
$(DOCKER_COMPOSE) up --remove-orphans $(STORYBOOK_CONTAINER)
.PHONY: stop
stop: ## Stop all the containers
$(DOCKER_COMPOSE) stop
##
## -- INSTANCE RUN --
##
.PHONY: run-back
run-back: ## Run command in the backend container
$(DOCKER_COMPOSE) run --rm $(BACK_CONTAINER) $(filter-out $@,$(MAKECMDGOALS))
.PHONY: run-back-e2e
run-back-e2e: ## Run command in the backend test container
$(DOCKER_COMPOSE) run --rm $(TEST_BACK_CONTAINER) $(filter-out $@,$(MAKECMDGOALS))
.PHONY: run-front
run-front: ## Run command in the frontend container
$(DOCKER_COMPOSE) run --rm $(FRONT_CONTAINER) $(filter-out $@,$(MAKECMDGOALS))
##
## -- BUILD --
##
.PHONY: build-front
build-front: ## build the frontend container
$(DOCKER_COMPOSE) run --rm $(FRONT_CONTAINER) yarn build-prod
.PHONY: start-build-front
start-build-front: ## start the build the frontend container
$(DOCKER_COMPOSE) run --rm $(FRONT_CONTAINER) yarn start
.PHONY: build-back
build-back: ## build the back container
$(DOCKER_COMPOSE) run --rm $(BACK_CONTAINER) yarn build
.PHONY: start-build-back
start-build-back: ## start the build the frontend container
$(DOCKER_COMPOSE) run --rm $(BACK_CONTAINER) yarn start
##
## -- DEPENDENCIES --
##
.PHONY: y-i-back
y-i-back: ## Install dependencies for the backend
$(DOCKER_COMPOSE) run --rm --no-deps $(BACK_CONTAINER) yarn install --ignore-scripts
.PHONY: y-i-front
y-i-front: ## Install dependencies for the frontend
$(DOCKER_COMPOSE) run --rm --no-deps $(FRONT_CONTAINER) yarn install --ignore-scripts
##
## -- TESTS --
##
.PHONY: test-back
test-back: ## Run the tests for the backend
$(DOCKER_COMPOSE) run --rm $(TEST_BACK_CONTAINER) yarn jest tests/$(filter-out $@,$(MAKECMDGOALS)) --color
$(DOCKER_COMPOSE) stop $(TEST_DATABASE_CONTAINER)
.PHONY: test-back-watch
test-back-watch: ## Run the tests for the backend with watch
$(DOCKER_COMPOSE) run --rm $(TEST_BACK_CONTAINER) yarn jest:watch tests/$(filter-out $@,$(MAKECMDGOALS)) --color
$(DOCKER_COMPOSE) stop $(TEST_DATABASE_CONTAINER)
.PHONY: test-front
test-front: ## Run the tests for the front
$(DOCKER_COMPOSE) run --rm $(FRONT_CONTAINER) yarn jest $(filter-out $@,$(MAKECMDGOALS)) --color
.PHONY: test-front-watch
test-front-watch: ## Run the tests for the front with watch
$(DOCKER_COMPOSE) run --rm $(FRONT_CONTAINER) yarn jest:watch $(filter-out $@,$(MAKECMDGOALS)) --color
.PHONY: lint-back
lint-back: ## Run the linter for the backend
$(DOCKER_COMPOSE) run --rm $(BACK_CONTAINER) yarn lint
.PHONY: lint-front
lint-front: ## Run the linter for the frontend
$(DOCKER_COMPOSE) run --rm $(FRONT_CONTAINER) yarn lint
##
## -- DATABASE --
##
.PHONY: db-drop
db-drop: ## drop the database
$(DOCKER_COMPOSE_RUN) --rm $(BACK_CONTAINER) yarn typeorm:drop
.PHONY: db-drop-e2e
db-drop-e2e: ## drop e2e database
$(DOCKER_COMPOSE_RUN) --rm $(TEST_BACK_CONTAINER) yarn typeorm:drop
.PHONY: db-generate-migration
db-generate-migration: ## generate migration, put YOUR_NAME in this command to custom the migration name
$(DOCKER_COMPOSE_RUN) --rm $(BACK_CONTAINER) yarn migration:generate -n $(filter-out $@,$(MAKECMDGOALS))
.PHONY: db-migrate-run
db-migrate-run: ## run migrations for dev database
$(DOCKER_COMPOSE_RUN) --rm $(BACK_CONTAINER) yarn migration:run
.PHONY: db-migrate-run-e2e
db-migrate-run-e2e: ## run migrations for e2e database
$(DOCKER_COMPOSE_RUN) --rm $(TEST_BACK_CONTAINER) yarn migration:run
.PHONY: db-fixtures-load
db-fixtures-load: ## load fixtures
$(DOCKER_COMPOSE_RUN) --rm $(BACK_CONTAINER) yarn fixtures:load
.PHONY: db-fixtures-clear-load
db-fixtures-clear-load: ## load fixtures
$(DOCKER_COMPOSE_RUN) --rm $(BACK_CONTAINER) bash -c "yarn typeorm:drop && yarn migration:run && yarn fixtures:load"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~ AUTO-DOCUMENTED HELP ~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ARGS = $(filter-out $@,$(MAKECMDGOALS))
.DEFAULT_GOAL := help # Show help without arguments
SPACE = 40 # Space before description
%: # Recipe generate AGRS
@:
help: # Recipe generate help with double hash prefix
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-${SPACE}s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
.PHONY: help
##