-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
137 lines (107 loc) · 2.78 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
# The big benefit of using a Makefile is to avoid pointless re-running of
# tests, linting, type checking etc., as can often happen with package.json
# scripts.
# Make does this by default with non-phony targets, since it compares
# everything just by using files' last-modified timestamps.
TS := $(shell find src -iname "*.ts" -o -iname "*.tsx") tsconfig.json
TEST_FILES := $(shell find src -iname "*.test.*")
CSS := $(shell find src -iname "*.css")
ENV_FILES := $(shell find env -iname "*.env")
SOURCE := $(TS) $(CSS) $(ENV_FILES)
BIN := node_modules/.bin
SHELL := /bin/bash
ENV := dev
.PHONY: help
help:
@echo "usage: make [target] ..."
@echo "targets:"
@echo "* deploy"
@echo "* build"
@echo "* serve"
@echo "* check (checkformat, typecheck, lint, test)"
@exit 1
node_modules: package.json
yarn
@touch $@
.PHONY: build
build: check dist
.PHONY: format
format: .make/format
.make/format: $(SOURCE) node_modules
$(BIN)/prettier --loglevel=warn --write .
@touch $@
.PHONY: checkformat
checkformat: .make/checkformat
.make/checkformat: $(SOURCE) node_modules
$(BIN)/prettier -c --loglevel=warn .
@touch $@
.PHONY: check
check: checkformat typecheck lint test
.PHONY: test
test: unit integration
.PHONY: unit
unit: .make/unit
.make/unit: $(TS) $(TEST_FILES) node_modules
$(BIN)/jest --coverage
@touch $@
.PHONY: integration
integration: .make/integration
.make/integration: $(SOURCE) $(wildcard integration/*.ts) playwright.config.ts node_modules
$(BIN)/playwright test
@touch $@
.PHONY: always-rebuild
.make/environment: always-rebuild
@echo $(ENV) > .make/environment.new
@cmp --quiet .make/environment.new .make/environment || cp .make/environment{.new,}
@rm .make/environment.new
dist: $(SOURCE) .make/environment node_modules
$(BIN)/env-cmd -f env/$(ENV).env $(BIN)/vite build
@touch $@
.PHONY: typecheck
typecheck: .make/typecheck
.make/typecheck: $(TS) node_modules
$(BIN)/tsc --noEmit
@echo
@touch $@
.PHONY: lint
lint: .make/lint
.make/lint: $(TS) node_modules
$(BIN)/eslint --cache .
@touch $@
.PHONY: lintfix
lintfix: $(TS) node_modules
$(BIN)/eslint --cache --fix .
.PHONY: delete
delete:
@echo Deleting environment $(ENV)...
@echo Deleted.
@echo
.PHONY: fix
fix: lintfix format
.PHONY: serve
serve: build
npx serve dist -c ../serve.json
.PHONY: serve-existing
serve-existing: dist
npx serve dist -c ../serve.json
.PHONY: deploy
deploy: build
@echo Deploying environment $(ENV)
@echo Deployed!
@echo
.PHONY: start
start: node_modules
$(BIN)/env-cmd -f env/$(ENV).env $(BIN)/vite
.PHONY: visualise
visualise: visualise.pdf
visualise.pdf:
python3 generate_makefile_graph.py
.PHONY: component
component:
node scripts/makeComponent.js
.PHONY: storybook
storybook:
$(BIN)/start-storybook -p 6006
.PHONY: build-storybook
build-storybook:
$(BIN)/build-storybook