-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (48 loc) · 1.31 KB
/
Makefile
File metadata and controls
59 lines (48 loc) · 1.31 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
NPM := pnpm
NPM_LOCK := pnpm-lock.yaml
TS_CONFIGS := tsconfig.json tsconfig-build.json
TS_FILES := $(shell find src/ -name '*.ts')
NPM_BIN := ./node_modules/.bin
all: dist
## help: show this help
.PHONY: help
help:
@sed -n 's/^##//p' Makefile | sort
## clean: delete generated files
.PHONY: clean
clean:
rm -rf coverage dist node_modules $(NPM_LOCK)
## ci: run tests and remove dev dependencies
.PHONY: ci
ci: test dist
$(NPM) prune --prod
rm $(NPM_LOCK)
dist: node_modules $(TS_FILES) $(TS_CONFIGS) Makefile
rm -rf $@
$(NPM_BIN)/tsc -p tsconfig-build.json
## lint: run linter checks
.PHONY: lint
lint: node_modules
$(NPM_BIN)/biome check --write --error-on-warnings
node_modules: package.json $(NPM_LOCK)
$(NPM) install || (rm -rf $@; exit 1)
test -d $@ && touch $@ || true
## start-dev: start application in development mode
.PHONY: start-dev
start-dev: node_modules
while true; do LOG_LEVEL=debug $(NPM_BIN)/tsx watch ./src/index.ts; sleep 1; done
## test: run unit tests (set FILE env variable to run test for that file only)
.PHONY: test
ifdef FILE
test: node_modules
$(NPM_BIN)/vitest $(FILE)
else
test: node_modules
$(NPM_BIN)/vitest --coverage --run
endif
## test-watch: run unit tests in watch mode
.PHONY: test-watch
test-watch: node_modules
$(NPM_BIN)/vitest
$(NPM_LOCK):
$(NPM) install && touch $@