-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
85 lines (70 loc) · 2 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
ROLLUP = ./node_modules/.bin/rollup --config rollup.config.mts --configPlugin swc3
TSX = ./node_modules/.bin/tsx
VERSION += ''
TAG += ''
FLAGS += --access public
install:
@echo "Using berry to install dependencies..."
corepack enable
pnpm install
client-analyze:
@echo "Analyzing client code..."
@pnpm exec vite build src/client --config analyze.config.mts
awk '{ print }' dist/client/stats.json > src/client/data.json
server-analyze:
@echo "Analyzing server code..."
-rm -rf analysis
./node_modules/.bin/rollup --config analyze.server.mjs
build-all:cleanup build-server cleaup-client
cleaup-client:
-rm -rf dist/client
cleanup:
-rm -rf dist
build-client:
@echo "Building client code..."
@pnpm exec vite build src/client
make clean-html
build-server: build-client
@echo "Building server code..."
@$(TSX) ./pre-compile.mts > dist/html.mjs
@$(ROLLUP)
-rm -rf dist/cli.mjs
awk '{ print }' bin.txt > dist/bin.js
dev-client:
@echo "Starting client in development mode..."
@pnpm exec vite src/client
test:
@echo "Running tests..."
@pnpm exec vitest --coverage
lint:
@echo "Linting code..."
@pnpm exec eslint . --fix
format:
@echo "Formatting code..."
pnpm exec dprint fmt
clean-html:
@echo "Cleaning up html file..."
@awk 'BEGIN \
{ RS=""; FS=""; ORS="" } \
{ \
gsub(/<script[^>]*>[\\s\\S]*?<\/script>/, ""); \
gsub(/<link[^>]*rel="stylesheet"[^>]*>/, ""); \
gsub(/<title>[^<]*<\/title>/, ""); \
gsub(/[ \t\n\r]+/, " "); \
print \
} \
' dist/client/index.html > dist/client/index.tmp && \
mv dist/client/index.tmp dist/client/index.html
publish: build-all
@echo "Publishing package..."
$(eval VERSION = $(shell awk -F'"' '/"version":/ {print $4}' package.json))
$(eval TAG = $(shell echo $(VERSION) | awk -F'-' '{if (NF > 1) print $$2; else print ""}' | cut -d'.' -f1))
$(eval FLAGS += $(shell \
if [ "$(WITH_PROVENANCE)" == "true" ]; then \
echo "--provenance"; \
fi; \
if [ "$(TAG)" != "" ]; then \
echo "--tag $(TAG)"; \
fi \
))
@npm publish $(FLAGS)