-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
95 lines (74 loc) · 2.31 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
# Project related variables
APP_NAME:=readme-ui
DOCKER_BUILD_TARGET:=readme-ui:latest
# Build and test tools abstraction.
NPM_BIN:=$(shell which npm)
NPM_INSTALL_CMD:=install
DOCKER_BIN:=$(shell which docker)
PWD:=$(shell pwd)
RM:=$(shell which rm)
# target: help - display this help.
.PHONY: help
help:
@egrep '^# target' [Mm]akefile
# target: env - configure development and build environment.
.PHONY: env
env: env-ui
node_modules: ;
package-lock.json: package.json node_modules
$(NPM_BIN) $(NPM_INSTALL_CMD) && touch package-lock.json
.PHONY: env-ui
env-ui: package-lock.json
# target: host-ui - hosts UI server and watches UI code for changes.
.PHONY: host-ui
host-ui: env-ui
$(NPM_BIN) run dev -- --host
# target: docker-build - builds the docker image.
.PHONY: docker-build
docker-build:
$(DOCKER_BIN) build -t $(DOCKER_BUILD_TARGET) $(PWD)
# target: host-docker-ui - hosts UI server within a docker container and watches UI code for changes.
.PHONY: host-docker-ui
host-docker-ui: docker-build
$(DOCKER_BIN) run --rm -it -p 5173:5173 -v $(PWD):/app --name $(APP_NAME) $(DOCKER_BUILD_TARGET)
.PHONY: docker-dev
docker-dev: env-ui
$(NPM_BIN) run docker-dev
# target: build - builds the UI.
.PHONY: build
build: env-ui
$(NPM_BIN) run build
# target: preview - previews the app after build.
.PHONY: preview
preview: build
$(NPM RUN) preview
# target: test - lint and test with watch mode.
.PHONY: test
test: env-ui
export $$(cat .env | xargs) && $(NPM_BIN) run lint && $(NPM_BIN) run test:unit
.PHONY: test-ci
test-ci: env-ui
export $$(cat .env | xargs) && $(NPM_BIN) run lint && $(NPM_BIN) run test:unit:ci
# target: test-e2e - runs the e2e tests in interactive mode.
.PHONY: test-e2e
test-e2e: env-ui
$(NPP_BIN) run test:e2e
.PHONY: test-e2e-ci
test-e2e-ci: env-ui
$(NPM_BIN) run test:e2e:ci
# target: lint - runs lint check on the files.
.PHONY: lint
lint: env-ui
$(NPM_BIN) run lint
# target: format - formats all files with prettier formatter.
.PHONY: format
format: env-ui
$(NPM_BIN) run format
# target: clean - clean up docker images created.
.PHONY: clean
clean:
$(DOCKER_BIN) image rm $(DOCKER_BUILD_TARGET)
# target: distclean - clean up.
.PHONY: distclean
distclean:
$(RM) -rf node_modules dist coverage npm-debug.log