-
Notifications
You must be signed in to change notification settings - Fork 170
/
Makefile
119 lines (97 loc) · 2.97 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
SHA := $(shell git rev-parse HEAD)
THIS_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
VERSION := $(shell npm ls | grep "xcharts@" | grep -Eo "[0-9]*\.[0-9]*\.[0-9]*")
NODE_PATH = node_modules/.bin
JS_COMPILER = $(NODE_PATH)/uglifyjs --comments="license"
JS_BEAUTIFIER = $(NODE_PATH)/uglifyjs -b -i 2 -nm -ns
CSS_COMPILER = $(NODE_PATH)/lessc --strict-imports
CSS_MINIFIER = $(CSS_COMPILER) --yui-compress
TMP = 'tmp_build'
REMOTE=origin
DOC_BRANCH=gh-pages
all:
@npm install -d
@cp scripts/githooks/* .git/hooks/
@chmod -R +x .git/hooks/
pre-build:
@mkdir -p build
@sed -i.bak 's/v[0-9]*\.[0-9]*\.[0-9]*/v${VERSION}/' scripts/wrap-start.js
build: pre-build \
build/xcharts.js \
build/xcharts.min.js \
build/xcharts.css \
build/xcharts.min.css \
build/LICENSE \
build/README.md
@tar -czf xcharts-build.tar.gz build/
@find ./ -name "*.bak" -delete
.INTERMEDIATE build/xcharts.js: \
scripts/wrap-start.js \
node_modules/underscore/underscore-min.js \
lib/visutils.js \
lib/scales.js \
lib/vis/bar.js \
lib/vis/line.js \
lib/vis/line-dotted.js \
lib/vis/cumulative.js \
lib/chart.js \
scripts/wrap-end.js
.INTERMEDIATE build/xcharts.css: \
lib/xcharts.less
.INTERMEDIATE build/xcharts.min.css: \
lib/xcharts.less
.INTERMEDIATE build/LICENSE: \
LICENSE
.INTERMEDIATE build/README.md: \
README.md
build/%.min.js: build/%.js
@echo "Building $^..."
@rm -f $@
@$(JS_COMPILER) < $< > $@
build/xcharts.js:
@echo "Building $^..."
@rm -rf $@
@cat $(filter %.js,$^) > $@
build/xcharts.css:
@echo "Building $^..."
@$(CSS_COMPILER) $(filter %.less,$^) $@
build/%.min.css:
@echo "Building $^..."
@$(CSS_MINIFIER) $(filter %.less,$^) $@
build/%: %
@echo "Building $^..."
@cat $^ > $@
clean:
@echo "Cleaning..."
@rm -rf build
@rm -rf ${TMP}
jsfiles := $(shell find . -name '*.js' ! -name '*lodash.js' ! -path './node_modules/*' ! -path './test/lib/*' ! -path "./build/*" ! -path "./scripts/*" ! -path "./tmp_build/*" ! -path "./docs/*xcharts*js" ! -name "*.min.js")
lint:
@node_modules/nodelint/nodelint ${jsfiles} --config=scripts/lint-config.js
reporter='dot'
test: build
@${NODE_PATH}/mocha-phantomjs test/test.html --reporter ${reporter}
pre-docs: clean build
@sed -i.bak 's/v[0-9]*\.[0-9]*\.[0-9]*/v${VERSION}/' docs.json
@rm docs.json.bak
docs: pre-docs
@mkdir -p docs/css
@node_modules/.bin/lessc --yui-compress --include-path=docs/less docs/less/master.less docs/css/master.css
@node_modules/.bin/still docs -o ${TMP} -i "layouts" -i "json" -i "less" -i "macro"
@cp node_modules/d3/d3.min.js ${TMP}/js/d3.min.js
@cp build/xcharts*js ${TMP}/js/
@git checkout master
@cp xcharts-build.tar.gz ${TMP}/xcharts-build.tar.gz
@git checkout ${DOC_BRANCH}
@cp -r ${TMP}/* ./
@rm -rf ${TMP}
@git add .
@git commit -n -am "Automated build from ${SHA}"
@git push ${REMOTE} ${DOC_BRANCH}
@git checkout ${THIS_BRANCH}
port = 3000
test-docs: pre-docs
@node_modules/.bin/still-server docs/ -p ${port} -o
publish: all clean build
@npm publish
.PHONY: lint test clean docs test-docs