forked from jnordberg/dsteem
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile
79 lines (60 loc) · 2.18 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
SHELL := /bin/bash
PATH := ./node_modules/.bin:$(PATH)
SRC_FILES := $(shell find src -name '*.ts')
all: lib bundle docs
lib: $(SRC_FILES) node_modules
tsc -p tsconfig.json --outDir lib && \
VERSION="$$(node -p 'require("./package.json").version')"; \
echo "module.exports = '$${VERSION}';" > lib/version.js
touch lib
dist/%.js: lib
browserify $(filter-out $<,$^) --debug --full-paths \
--standalone dsteem --plugin tsify \
--transform [ babelify --extensions .ts ] \
| derequire > $@
uglifyjs $@ \
--source-map "content=inline,url=$(notdir $@).map,filename=$@.map" \
--compress "dead_code,collapse_vars,reduce_vars,keep_infinity,drop_console,passes=2" \
--output $@ || rm $@
dist/dsteem.js: src/index-browser.ts
dist/dsteem.d.ts: $(SRC_FILES) node_modules
dts-generator --name dsteem --project . --out dist/dsteem.d.ts
sed -e "s@'dsteem/index'@'dsteem'@g" -i '' dist/dsteem.d.ts
dist/%.gz: dist/dsteem.js
gzip -9 -f -c $(basename $@) > $(basename $@).gz
bundle: dist/dsteem.js.gz dist/dsteem.d.ts
.PHONY: coverage
coverage: node_modules
nyc -r html -r text -e .ts -i ts-node/register mocha --exit --reporter nyan --require ts-node/register test/*.ts
.PHONY: test
test: node_modules
mocha --exit --require ts-node/register test/*.ts --grep '$(grep)'
.PHONY: ci-test
ci-test: node_modules
tslint -p tsconfig.json -c tslint.json
nyc -r lcov -e .ts -i ts-node/register mocha --exit --reporter tap --require ts-node/register test/*.ts
.PHONY: browser-test
browser-test: dist/dsteem.js
BUILD_NUMBER="$$(git rev-parse --short HEAD)-$$(date +%s)" \
karma start test/_karma-sauce.js
.PHONY: browser-test-local
browser-test-local: dist/dsteem.js
karma start test/_karma.js
.PHONY: lint
lint: node_modules
tslint -p tsconfig.json -c tslint.json -t stylish --fix
node_modules:
yarn install --non-interactive --frozen-lockfile
docs: $(SRC_FILES) node_modules
typedoc --gitRevision master --target ES6 --mode file --out docs src
find docs -name "*.html" | xargs sed -i '' 's~$(shell pwd)~.~g'
echo "Served at <https://jnordberg.github.io/dsteem/>" > docs/README.md
touch docs
.PHONY: clean
clean:
rm -rf lib/
rm -f dist/*
rm -rf docs/
.PHONY: distclean
distclean: clean
rm -rf node_modules/