-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
69 lines (58 loc) · 1.27 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
TARGET_DIR ?= ./target
CARGO_TARGET_DIR := ${TARGET_DIR}
MODE ?= development
RUSTFLAGS := -Ctarget-cpu=generic
TMP_DIST_DIR := /tmp/kp-chart-dist
.PHONY: init
init:
@echo "========> $@"
@rustup --version || (curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh)
rustup self update
rustup update
rustup target add wasm32-unknown-unknown
cargo install wasm-pack
npm --version
npm install
.PHONY: build
wasm:
@echo "========> $@"
wasm-pack build
.PHONY: build
build:
@echo "========> $@"
npm run build -- --mode=${MODE}
.PHONY: test
test: build
@echo "========> $@"
cargo test
npm run test
.PHONY: run
run: build
@echo "========> $@"
npm run start
.PHONY: clean
clean:
@echo "========> $@"
rm -rf ./pkg
rm -rf ./dist
.PHONY: deploy
deploy: clean
@echo "========> $@"
@git --version
# build the project
$(MAKE) MODE=production WASM_MODE=--release build
# deploy
git worktree add ${TMP_DIST_DIR} gh-pages
rm -rf ${TMP_DIST_DIR}/*
cp -rp dist/* ${TMP_DIST_DIR}
cd ${TMP_DIST_DIR} && \
git add -A && \
git diff --staged --quiet || \
(git commit -m "deployed on $(shell date) by ${USER}" && \
git push origin gh-pages)
$(MAKE) clean_worktree
.PHONY: clean_worktree
clean_worktree:
@echo "========> $@"
rm -rf ${TMP_DIST_DIR}
git worktree prune