Skip to content

Commit d1f85aa

Browse files
committed
refactor: improved Makefile (#199)
* refactor: broke down the .PHONY statement * refactor: added node_modules target as dependency * refactor: improved test outputs * refactor: renamed build target to dist * refactor: improved targets output * refactor: grouped targets * refactor: renamed compile target * refactor: added missing node_modules dependency * refactor: removed extraneous dependency
1 parent 1555cee commit d1f85aa

File tree

1 file changed

+113
-50
lines changed

1 file changed

+113
-50
lines changed

Makefile

Lines changed: 113 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,132 @@
1+
.PHONY: all
12
all: test lint typecheck
23

3-
node_modules: package.json
4-
npm install && /usr/bin/touch node_modules
5-
6-
build: node_modules
7-
npx rollup -c
8-
4+
.PHONY: browser
95
browser:
106
./bin/server --exec "npx open-cli http://localhost:8000/test/fetch-api/browser/"
117

12-
commit:
8+
.PHONY: commit
9+
commit: node_modules
1310
npx cz
1411

15-
commitlint: node_modules
16-
npx commitlint --from origin/main --to HEAD --verbose
17-
18-
compile: node_modules test/fetch-api/api.spec.ts
19-
npx tsc
20-
21-
cov:
22-
npx nyc report --reporter=text-lcov > .reports/coverage.lcov && npx codecov
23-
24-
lint:
25-
npx standard
26-
27-
release:
12+
.PHONY: release
13+
release: node_modules
2814
npx standard-version
2915

30-
release-alpha:
16+
.PHONY: release-alpha
17+
release-alpha: node_modules
3118
npx standard-version --prerelease alpha
3219

33-
secure:
34-
npx snyk test
20+
##
21+
# Builds
3522

36-
test: compile test-fetch test-module
23+
node_modules: package.json
24+
@echo ""
25+
@echo "=> installing dependencies..."
26+
@npm install && /usr/bin/touch node_modules
3727

38-
test-fetch: test-fetch-browser test-fetch-whatwg test-fetch-node
28+
dist: package.json rollup.config.js $(wildcard src/*.js) node_modules
29+
@echo ""
30+
@echo "=> make $@"
31+
@npx rollup -c
3932

40-
test-fetch-browser: build
41-
./test/fetch-api/browser/run.sh
33+
test/fetch-api/api.spec.js: node_modules test/fetch-api/api.spec.ts
34+
@echo ""
35+
@echo "=> make $@"
36+
@npx tsc
4237

43-
test-fetch-whatwg: build
44-
./test/fetch-api/whatwg/run.sh
38+
##
39+
# Checks
4540

46-
test-fetch-node: build
47-
./test/fetch-api/node/run.sh
41+
.PHONY: commitlint
42+
commitlint: node_modules
43+
@echo ""
44+
@echo "=> linting commits..."
45+
@npx commitlint --from origin/main --to HEAD --verbose
46+
47+
.PHONY: cov
48+
cov: node_modules
49+
@echo ""
50+
@echo "=> checking code coverage..."
51+
@npx nyc report --reporter=text-lcov > .reports/coverage.lcov && npx codecov
52+
53+
.PHONY: lint
54+
lint: node_modules
55+
@echo ""
56+
@echo "=> make $@"
57+
@npx standard
58+
59+
.PHONY: secure
60+
secure: node_modules
61+
@echo ""
62+
@echo "=> make $@"
63+
@npx snyk test
64+
65+
.PHONY: typecheck
66+
typecheck: node_modules
67+
@echo ""
68+
@echo "=> make $@"
69+
@npx tsc --lib ES6 --noEmit index.d.ts ./test/fetch-api/api.spec.ts
70+
71+
##
72+
# Test groups
73+
74+
.PHONY: test
75+
test: test-fetch test-module
76+
77+
.PHONY: test-fetch
78+
test-fetch: test-fetch-browser test-fetch-whatwg test-fetch-node
4879

80+
.PHONY: test-module
4981
test-module: test-module-web-cjs test-module-web-esm test-module-node-cjs test-module-node-esm test-module-react-native
5082

51-
test-module-web-cjs: build
52-
./test/module-system/web.cjs/run.sh
53-
54-
test-module-web-esm: build
55-
./test/module-system/web.esm/run.sh
56-
57-
test-module-node-cjs: build
58-
./test/module-system/node.cjs/run.sh
59-
60-
test-module-node-esm: build
61-
./test/module-system/node.esm/run.sh
62-
63-
test-module-react-native: build
64-
./test/module-system/react-native/run.sh
65-
66-
typecheck:
67-
npx tsc --lib ES6 --noEmit index.d.ts ./test/fetch-api/api.spec.ts
68-
69-
.PHONY: all build deploy lint test test-fetch test-fetch-browser test-fetch-whatwg test-fetch-node test-module test-module-web-cjs test-module-web-esm test-module-node-cjs test-module-node-esm test-module-react-native typecheck
83+
##
84+
# Test units
85+
86+
.PHONY: test-fetch-browser
87+
test-fetch-browser: | dist test/fetch-api/api.spec.js
88+
@echo ""
89+
@echo "=> make $@"
90+
@./test/fetch-api/browser/run.sh
91+
92+
.PHONY: test-fetch-whatwg
93+
test-fetch-whatwg: | dist test/fetch-api/api.spec.js
94+
@echo ""
95+
@echo "=> make $@"
96+
@./test/fetch-api/whatwg/run.sh
97+
98+
.PHONY: test-fetch-node
99+
test-fetch-node: | dist test/fetch-api/api.spec.js
100+
@echo ""
101+
@echo "=> make $@"
102+
@./test/fetch-api/node/run.sh
103+
104+
.PHONY: test-module-web-cjs
105+
test-module-web-cjs: | dist
106+
@echo ""
107+
@echo "=> make $@"
108+
@./test/module-system/web.cjs/run.sh
109+
110+
.PHONY: test-module-web-esm
111+
test-module-web-esm: | dist
112+
@echo ""
113+
@echo "=> make $@"
114+
@./test/module-system/web.esm/run.sh
115+
116+
.PHONY: test-module-node-cjs
117+
test-module-node-cjs: | dist
118+
@echo ""
119+
@echo "=> make $@"
120+
@./test/module-system/node.cjs/run.sh
121+
122+
.PHONY: test-module-node-esm
123+
test-module-node-esm: | dist
124+
@echo ""
125+
@echo "=> make $@"
126+
@./test/module-system/node.esm/run.sh
127+
128+
.PHONY: test-module-react-native
129+
test-module-react-native: | dist
130+
@echo ""
131+
@echo "=> make $@"
132+
@./test/module-system/react-native/run.sh

0 commit comments

Comments
 (0)