-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
109 lines (90 loc) · 2.36 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
#!/usr/bin/env
.PHONY: help build clean cdn dev docs deploy examples install publish test
STATUS:="\x1b[96;01m\xE2\x80\xA2\x1b[0m"
ECHO = @echo "\033[0;34m$(1)\033[0m$(2)"
# HELP
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
@echo
@echo 📻 OEM:
@echo
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-10s\033[0m %s\n", $$1, $$2}'
@echo
@echo USAGE:
@echo See README.md
@echo
.DEFAULT_GOAL := help
# TASKS
cdn: ## Build for CDN
@echo $(STATUS) Building cdn dist...
@npx esbuild \
./src/index.ts \
--bundle \
--minify-whitespace \
--minify-syntax \
--sourcemap \
--format=iife \
--target=es2015 \
--global-name=oem \
--outfile=./dist/oem.min.js
clean: ## Clean the project
@echo $(STATUS) Cleaning...
@rm -rf ./docs/bundle.min.js ./docs/bundle.min.js.map ./node_modules ./package-lock.json ./dist
dev: ## Run the project in development mode
@echo $(STATUS) Running in development mode...
@open ./docs/index.html
@npx esbuild \
./docs/app.ts \
--bundle \
--minify \
--sourcemap \
--target=es2015 \
--watch \
--outfile=./docs/bundle.min.js
deploy: ## Deploy the project
@echo $(STATUS) Deploying...
@git branch -D gh-pages
@git checkout -b gh-pages
@git merge main --no-commit --no-ff
@make clean
@npm i
@make docs
@git add .
@git commit -m 'deploy'
@git push -f origin gh-pages
@git checkout main
dist: ## Build for distribution
@echo $(STATUS) Building dist...
@npx esbuild \
./src/index.ts \
--bundle \
--minify-whitespace \
--minify-syntax \
--sourcemap \
--format=esm \
--target=es2015 \
--outfile=./dist/oem.min.js
docs: ## Build docs
@rm -rf ./dist
@echo $(STATUS) Building docs...
@npx esbuild \
./docs/app.ts \
--bundle \
--minify-whitespace \
--minify-syntax \
--sourcemap \
--target=es2015 \
--outfile=./docs/bundle.min.js
dev_todo: ## Dev todo example
@echo $(STATUS) Building examples...
@open ./examples/todo/index.html
@npx esbuild --bundle ./examples/todo/src/index.ts --outdir=./examples/todo --watch --sourcemap --minify
install: ## Install the project
@echo $(STATUS) Installing...
@npm install
publish: ## Publish the project to npm
@echo $(STATUS) Publish package...
@npm publish --access public
test: ## Run tests
@echo $(STATUS) Testing...
@node ./cmd/test.js FILTER=$(FILTER)