-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
188 lines (147 loc) · 4.85 KB
/
Makefile
File metadata and controls
188 lines (147 loc) · 4.85 KB
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
JSDOC := ./node_modules/.bin/jsdoc
SOURCE := $(shell find src -type f -name '*.js')
LANG_PACKS := $(patsubst trans/%.tsv,src/lang/%.js,$(wildcard trans/*.tsv))
DIST_FILES := $(addprefix dist/,wcdatavis.js wcdatavis.min.js wcdatavis.css)
EXAMPLE_FILES := $(patsubst dist/%,examples/%,$(DIST_FILES))
PUB_PATH := zeus.med-web.com:~/public_html/datavis
PYTHON_VER ?= $(shell pyenv versions --bare --skip-aliases --skip-envs | sort -r -V | head -n 1)
.DEFAULT_GOAL := help
.PHONY: datavis
datavis: $(DIST_FILES)
# Setup/teardown of dependencies {{{1
.PHONY: npm-setup
npm-setup:
@if [ -f .nvmrc ] ; then \
printf '\033[34;1mPlease run `nvm use` to ensure the right version of Node is used.\033[0m\n' ; \
fi
npm install
./bin/update-deps.sh
.PHONY: npm-teardown
npm-teardown:
rm -rf node_modules
git checkout -- package-lock.json
.PHONY: python-setup
python-setup:
ifeq ($(DOCKER_ENV), 1)
echo "Running inside Docker"
pip install --break-system-packages -r requirements.txt
else
@if pyenv versions --bare | grep '^datavis$$' ; then \
printf '\033[34;1mRemoving existing "datavis" virtualenv first.\033[0m\n' ; \
pyenv virtualenv-delete -f datavis ; \
fi
@if [ -z "$(PYTHON_VER)" ] ; then \
printf '\033[31;1mUnable to find Python versions installed via pyenv.\033[0m\n' ; \
printf '\033[31;1mUsing your system Python version as a base. Good luck.\033[0m\n' ; \
pyenv virtualenv system datavis ; \
else \
printf '\033[32;1mCreating new "datavis" virtualenv based on Python $(PYTHON_VER).\033[0m\n' ; \
pyenv virtualenv "$(PYTHON_VER)" datavis ; \
fi
pyenv local datavis
pip install -r requirements.txt
endif
.PHONY: python-teardown
python-teardown:
-pyenv virtualenv-delete -f datavis
-pyenv local --unset
.PHONY: jsdoc-setup
jsdoc-setup:
cd third-party/jaguarjs-jsdoc && npm i
.PHONY: jsdoc-teardown
jsdoc-teardown:
cd third-party/jaguarjs-jsdoc && rm -rf node_modules
.PHONY: setup
setup: npm-setup python-setup
echo "You should have run git submodule update --init outside the containter"
git submodule update --init
$(MAKE) jsdoc-setup
.PHONY: teardown
teardown: npm-teardown python-teardown jsdoc-teardown
# Building DataVis {{{1
dist/wcdatavis.js: rollup.config.js datavis.js global-jquery.js ie-fixes.js $(SOURCE) $(LANG_PACKS)
npm run rollup
dist/wcdatavis.min.js: dist/wcdatavis.js
npm run uglify
dist/wcdatavis.css: wcdatavis.css
npm run rollup
# third-party/json-formatter.esm.js:
# cd third-party/json-formatter-js && npm i && npm run build
# cp third-party/json-formatter-js/dist/$(notdir $@) $@
# Documentation {{{1
.PHONY: doc
doc: jsdoc manual
@printf '\033[32;1mRun `make doc-publish` to publish documentation to $(PUB_PATH)\033[0m\n'
.PHONY: doc-publish
doc-publish: doc
rsync -a --delete doc/html/ $(PUB_PATH)/manual/
rsync -a --delete jsdoc/ $(PUB_PATH)/jsdoc/
$(MAKE) -C tests $@
.PHONY: doc-clean
doc-clean:
rm -rf doc/html
rm -rf jsdoc
$(MAKE) -C tests $@
.PHONY: doc-serve
doc-serve:
zensical serve
.PHONY: jsdoc
jsdoc:
$(JSDOC) -p -c jsdoc_conf.json -r src
$(MAKE) -C tests $@
.PHONY: manual
manual:
zensical build
.PHONY: publish
publish: doc-publish tests-publish
# Testing {{{1
.PHONY: serve
serve:
ifdef PORT
/usr/bin/env PORT=$(PORT) npm run dev
else
npm run dev
endif
tests: $(DIST_FILES)
$(MAKE) -C tests
.PHONY: tests-publish
tests-publish: tests
rsync -av --delete tests/pages/ $(PUB_PATH)/examples/
.PHONY: test
test: tests
npm run test
examples: tests $(EXAMPLE_FILES)
cp tests/data/*.json examples/test
$(EXAMPLE_FILES):examples/%: dist/%
cp $^ $@
# Cleanup {{{1
.PHONY: dist-clean
dist-clean:
rm -f dist/wcdatavis.js dist/wcdatavis.min.js
rm -f src/lang/*.js
rm -f $(EXAMPLE_FILES)
rm -f examples/test/*.json
.PHONY: clean
clean: doc-clean dist-clean
$(MAKE) -C tests $@
# Translations {{{1
$(LANG_PACKS):src/lang/%.js: trans/%.tsv bin/make-lang-packs.awk en-US.tsv
mkdir -p trans-missing
gawk -f ./bin/make-lang-packs.awk en-US.tsv $<
# Miscellaneous {{{1
.PHONY: tags
tags:
ctags -R -f TAGS --languages=JavaScript --sort=foldcase src
# Help {{{1
.PHONY: help
help:
@printf -- '\033[36;1mImportant targets:\033[0m\n'
@printf -- '\n'
@printf -- '- \033[1mmake setup\033[0m — Installs all dependencies.\n'
@printf -- '- \033[1mmake datavis\033[0m — Build the compressed DataVis JS and CSS files.\n'
@printf -- '- \033[1mmake tests\033[0m — Same as \033[1mmake datavis\033[0m, then copy to tests directory, and build test data.\n'
@printf -- '- \033[1mmake serve\033[0m — Start local server for interactive testing.\n'
@printf -- '- \033[1mmake test\033[0m — Same as \033[1mmake tests\033[0m, then run automated tests using Mocha & Selenium.\n'
@printf -- '- \033[1mmake doc\033[0m — Build all documentation.\n'
@printf -- ' - \033[1mmake jsdoc\033[0m — Build JS API documentation from comments in the source.\n'
@printf -- ' - \033[1mmake manual\033[0m — Build the Manual from Markdown files.\n'