-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathMakefile
134 lines (106 loc) · 3.8 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
LIB=printj
REQS=loop_code
ADDONS=
AUXTARGETS=lib/loop_char.js lib/loop_code.js lib/index_char.js lib/index_code.js lib/regex.js
CMDS=bin/printj.njs
HTMLLINT=index.html
ULIB=$(shell echo $(LIB) | tr a-z A-Z)
DEPS=$(sort $(wildcard bits/*.js))
TARGET=$(LIB).js
FLOWTARGET=$(LIB).flow.js
MJSTARGET=$(LIB).mjs
FLOWTGTS=$(TARGET) $(AUXTARGETS)
CLOSURE=/usr/local/lib/node_modules/google-closure-compiler/compiler.jar
UGLIFY="./node_modules/@sheetjs/uglify-js/bin/uglifyjs"
JSCS=./node_modules/.bin/jscs
JSHINT=./node_modules/.bin/jshint
MOCHA=./node_modules/.bin/mocha
ESLINT=./node_modules/.bin/eslint
ALEX=./node_modules/.bin/alex
MDSPELL=./node_modules/.bin/mdspell
## Main Targets
.PHONY: all
all: $(TARGET) ## Build library and auxiliary scripts
.PHONY: lib
lib:
OUTDIR=$(PWD)/lib make -C bits
$(FLOWTGTS): %.js : %.flow.js
node -e 'process.stdout.write(require("fs").readFileSync("$<","utf8").replace(/^[ \t]*\/\*[:#][^*]*\*\/\s*(\n)?/gm,"").replace(/\/\*[:#][^*]*\*\//gm,""))' > $@
$(FLOWTARGET): $(DEPS) lib
cp lib/$(REQS).js $(FLOWTARGET)
cp lib/$(REQS).mjs $(MJSTARGET)
bits/01_version.js: package.json
echo "$(ULIB).version = '"`grep version package.json | awk '{gsub(/[^0-9a-z\.-]/,"",$$2); print $$2}'`"';" > $@
.PHONY: clean
clean: clean-stress ## Remove targets and build artifacts
@OUTDIR=$(PWD)/lib make -C bits clean
rm -f $(TARGET) $(FLOWTARGET)
.PHONY: init
init: ## Initial setup for development
npm i
.PHONY: dist
dist: $(TARGET) ## Prepare JS files for distribution
cp $(TARGET) dist/
cp LICENSE dist/
$(UGLIFY) $(TARGET) -o dist/$(LIB).min.js --source-map dist/$(LIB).min.map --preamble "$$(head -n 1 bits/00_header.js)"
misc/strip_sourcemap.sh dist/$(LIB).min.js
## Testing
.PHONY: test mocha
test mocha: test.js $(TARGET) ## Run test suite
$(MOCHA) -R spec -t 20000
.PHONY: ctest
ctest: ## Build browser test (into ctest/ subdirectory)
cp -f test.js ctest/test.js
cp -f shim.js ctest/shim.js
cp -f $(TARGET) ctest/
.PHONY: ctestserv
ctestserv: ## Start a test server on port 8000
@cd ctest && python -mSimpleHTTPServer
.PHONY: stress
stress: ## Run stress tests
@make -C stress clean
@make -C stress
@make -C stress test
.PHONY: clean-stress
clean-stress: ## Remove stress tests
@make -C stress clean
## Code Checking
.PHONY: fullint
fullint: lint old-lint tslint mdlint ## Run all checks
.PHONY: lint
lint: $(TARGET) ## Run eslint checks
@$(ESLINT) --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
.PHONY: old-lint
old-lint: $(TARGET) ## Run jshint and jscs checks
@$(JSHINT) --show-non-errors $(TARGET) $(AUXTARGETS)
@$(JSHINT) --show-non-errors $(CMDS)
@$(JSHINT) --show-non-errors package.json
@$(JSHINT) --show-non-errors --extract=always $(HTMLLINT)
@$(JSCS) lib/*.js
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
.PHONY: tslint
tslint: $(TARGET) ## Run typescript checks
#@npm install dtslint typescript
@npm run-script dtslint
.PHONY: flow
flow: lint ## Run flow checker
@flow check --all --show-all-errors
.PHONY: cov
cov: misc/coverage.html ## Run coverage test
misc/coverage.html: $(TARGET) test.js
$(MOCHA) --require blanket -R html-cov -t 20000 > $@
.PHONY: coveralls
coveralls: ## Coverage Test + Send to coveralls.io
$(MOCHA) --require blanket --reporter mocha-lcov-reporter -t 20000 | node ./node_modules/coveralls/bin/coveralls.js
MDLINT=README.md
.PHONY: mdlint
mdlint: $(MDLINT) ## Check markdown documents
$(ALEX) $^
$(MDSPELL) -a -n -x -r --en-us $^
.PHONY: help
help:
@grep -hE '(^[a-zA-Z_-][ a-zA-Z_-]*:.*?|^#[#*])' $(MAKEFILE_LIST) | bash misc/help.sh
#* To show a spinner, append "-spin" to any target e.g. cov-spin
%-spin:
@make $* & bash misc/spin.sh $$!