-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
157 lines (125 loc) · 3.96 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
.PHONY: build ci clean cover docs graph image install push run run-debug run-image test
DOCKER_ARGS ?=
DOCKER_IMAGE := ssube/textual-engine
GIT_ARGS ?=
GIT_HEAD_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
NODE_ARGS ?=
RELEASE_ARGS ?= --sign
build: ## build the app
build: node_modules
yarn tsc
bundle: build
node config/esbuild/browser.mjs
cp -rv src/index.html out/
ci: build cover
clean: clean-target
rm -rf node_modules/
clean-target:
rm -rf out/
docs:
yarn api-extractor run -c config/api-extractor.json
yarn api-documenter markdown -i out/temp -o out/docs
GRAPH_LAYOUT ?= dot
graph: ## render any debug graphs
cat out/debug-graph | $(GRAPH_LAYOUT) -Tpng -oout/debug-graph.png && sensible-browser out/debug-graph.png
image-cli: ## build the CLI image
docker build $(DOCKER_ARGS) -f Dockerfile.cli -t $(DOCKER_IMAGE) .
image-server: ## build the nginx server image
docker build $(DOCKER_ARGS) -f Dockerfile.server -t $(DOCKER_IMAGE) .
install:
yarn
lint: ## run eslint
lint: node_modules
yarn eslint src/ --ext .ts,.tsx
node_modules: install
out: build
pages: bundle
cp out/bundle/browser.js bundle/browser.js
push: ## push to both github and gitlab
git push $(GIT_ARGS) github $(GIT_HEAD_BRANCH)
git push $(GIT_ARGS) gitlab $(GIT_HEAD_BRANCH)
release: ## tag and push a release
release: node_modules
if [[ "$(GIT_HEAD_BRANCH)" != master ]]; \
then \
echo "Please merge to master before releasing."; \
exit 1; \
fi
yarn standard-version $(RELEASE_ARGS)
GIT_ARGS=--follow-tags $(MAKE) push
RUN_ARGS ?= --config data/config.yml \
--data file://data/demo.yml \
--input 'create a test with test and with 20' \
--input help
run: ## run app with demo data
run: build
node $(NODE_ARGS) out/src/cli.js $(RUN_ARGS)
run-debug: ## run app and wait for debugger
NODE_ARGS=--inspect-brk $(MAKE) run
run-graph: build
node $(NODE_ARGS) out/src/cli.js $(RUN_ARGS) --depth 13
$(MAKE) graph
run-image: ## run app from docker image
run-image: image
docker run --rm -it $(DOCKER_IMAGE):latest $(RUN_ARGS)
MOCHA_ARGS := --async-only \
--check-leaks \
--forbid-only \
--require source-map-support \
--require out/test/setup.js \
--recursive \
--sort
test: ## run tests
test: node_modules out
yarn mocha $(MOCHA_ARGS) "out/src/lib.js" "out/**/Test*.js"
COVER_ARGS := --all \
--check-coverage \
--exclude ".eslintrc.js" \
--exclude "bundle/**" \
--exclude "config/**" \
--exclude "docs/**" \
--exclude "out/bundle/**" \
--exclude "out/coverage/**" \
--exclude "test/**" \
--reporter=text-summary \
--reporter=lcov \
--report-dir=out/coverage
cover: ## run tests with coverage
cover: node_modules out
yarn c8 $(COVER_ARGS) yarn mocha $(MOCHA_ARGS) "out/**/Test*.js"
# from https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help: ## print this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort \
| sed 's/^.*\/\(.*\)/\1/' \
| awk 'BEGIN {FS = ":[^:]*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
todo:
@echo "Remaining tasks:"
@echo ""
@grep -i "todo" -r docs/ src/ test/ || true
@echo ""
@echo "Pending tests:"
@echo ""
@grep "[[:space:]]xit" -r test/ || true
@echo ""
@echo "Casts to any:"
@echo ""
@grep "as any" -r src/ test/ || true
@echo ""
@echo "Uses of null:"
@echo ""
@grep -P -e "null(?!able)" -r src/ test/ || true
@echo ""
@echo "Uses of ==:"
@echo ""
@grep -e "[^=!]==[^=]" -r src/ test/ || true
@echo ""
# from https://gist.github.com/amitchhajer/4461043#gistcomment-2349917
git-stats: ## print git contributor line counts (approx, for fun)
git ls-files | while read f; do git blame -w -M -C -C --line-porcelain "$$f" |\
grep -I '^author '; done | sort -f | uniq -ic | sort -n
git-push: ## push to both Github and Gitlab
git push github
git push gitlab
upload-climate:
cc-test-reporter format-coverage -t lcov -o out/coverage/codeclimate.json -p . out/coverage/lcov.info
cc-test-reporter upload-coverage --debug -i out/coverage/codeclimate.json -r "$(shell echo "${CODECLIMATE_SECRET}" | base64 -d)"