forked from openhive-network/dhive
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
87 lines (67 loc) · 2.49 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
SHELL := /bin/bash
PATH := ./node_modules/.bin:$(PATH)
SRC_FILES := $(shell find src -name '*.ts')
define VERSION_TEMPLATE
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = '$(shell node -p 'require("./package.json").version')';
endef
all: lib bundle docs
export VERSION_TEMPLATE
lib: $(SRC_FILES) node_modules
tsc -p tsconfig.json --outDir lib && \
echo "$$VERSION_TEMPLATE" > lib/version.js
touch lib
# --compress "dead_code,collapse_vars,reduce_vars,keep_infinity,drop_console,passes=2"
# to print console log: --compress "dead_code,collapse_vars,reduce_vars,keep_infinity,passes=2"
dist/%.js: lib
browserify $(filter-out $<,$^) --debug --full-paths \
--standalone dhive --plugin tsify \
--transform [ babelify --extensions .ts ] \
| derequire > $@
uglifyjs $@ \
--source-map "content=inline,url=$(notdir $@).map,[email protected]" \
--compress "dead_code,collapse_vars,reduce_vars,keep_infinity,passes=2" \
--output $@ || rm $@
dist/dhive.js: src/index-browser.ts
dist/dhive.d.ts: $(SRC_FILES) node_modules
dts-generator --name dhive --project . --out dist/dhive.d.ts
perl -i -pe"s@'dhive/index'@'dhive'@g" dist/dhive.d.ts
dist/%.gz: dist/dhive.js
gzip -9 -f -c $(basename $@) > $(basename $@).gz
bundle: dist/dhive.js.gz dist/dhive.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 -r test/_node.js test/*.ts --grep '$(grep)'
.PHONY: ci-test
ci-test: node_modules
eslint -c .eslintrc.json src/**/*.ts
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/dhive.js
BUILD_NUMBER="$$(git rev-parse --short HEAD)-$$(date +%s)" \
karma start test/_karma-sauce.js
.PHONY: browser-test-local
browser-test-local: dist/dhive.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 perl -i -pe's~$(shell pwd)~.~g'
echo "Served at <https://openhive-network.github.io/dhive>" > 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/