]>
Commit | Line | Data |
---|---|---|
7a9e5112 | 1 | SHELL=/bin/bash |
2 | ENV ?= dev | |
3 | export PATH := $(PATH):./node_modules/.bin | |
4 | ||
335b0c9b | 5 | # Javascript objects |
6 | JS_SRC_DIR=js | |
7 | JS_BUILD_DIR=build/js | |
8 | JSX_SRC=header_footer.jsx main.jsx signup.jsx signin.jsx otp.jsx poloniex.jsx password_reset.jsx change_password.jsx account.jsx balance.jsx admin.jsx panel.jsx icon.jsx | |
9 | JS_SRC=cookies.js app.js api.js | |
10 | JSX_OBJS=$(addprefix $(JS_BUILD_DIR)/,$(JSX_SRC:.jsx=.js)) | |
11 | JS_OBJS=$(addprefix $(JS_BUILD_DIR)/,$(JS_SRC)) | |
12 | ||
13 | # Static resources | |
7a9e5112 | 14 | STATIC_BUILD_DIR=build/static |
335b0c9b | 15 | STATIC_FILES=index.html style.css |
7a9e5112 | 16 | |
335b0c9b | 17 | # Fontello icon provider - regular icons |
18 | STATIC_FILES+=fontello.css | |
19 | STATIC_FILES+=$(addprefix fonts/, fontello.eot fontello.svg fontello.ttf fontello.woff fontello.woff2) | |
20 | FONTELLO_TMP_DIR = ./static/fontello | |
21 | FONTELLO_HOST ?= http://fontello.com | |
22 | ||
23 | # Biticonics cryptocurrency icon provider. | |
24 | STATIC_FILES+=$(addprefix fonts/, bitonics.min.css) | |
25 | CRYPTO_ICONS_FONTS=$(addprefix $(STATIC_BUILD_DIR)/fonts/glyphs/ttf/, $(notdir $(wildcard static/fonts/glyphs/ttf/*.ttf))) | |
26 | CRYPTO_ICONS_FONTS+=$(addprefix $(STATIC_BUILD_DIR)/fonts/glyphs/woff/, $(notdir $(wildcard static/fonts/glyphs/woff/*.woff))) | |
27 | CRYPTO_ICONS_FONTS+=$(addprefix $(STATIC_BUILD_DIR)/fonts/glyphs/woff2/, $(notdir $(wildcard static/fonts/glyphs/woff2/*.woff2))) | |
28 | ||
29 | define fetch-bitonics-icons = | |
30 | DIR="static/fonts/glyphs" | |
31 | ||
32 | curl 'https://bitonics.net/vendor/bitonics/bitonics.min.css' > static/fonts/bitonics.min.css | |
33 | ||
34 | glyphs=($(curl 'https://bitonics.net/vendor/bitonics/bitonics.css' | grep -Po 'glyphs/ttf/[a-z0-9]{8}' | cut -c 12-)) | |
35 | ||
36 | for glyph in "${glyphs[@]}" | |
37 | do | |
38 | if [ ! -f "$DIR/ttf/$glyph.ttf" ]; then | |
39 | curl "https://bitonics.net/vendor/bitonics/glyphs/ttf/$glyph.ttf" > "$DIR/ttf/$glyph.ttf" | |
40 | curl "https://bitonics.net/vendor/bitonics/glyphs/woff/$glyph.woff" > "$DIR/woff/$glyph.woff" | |
41 | curl "https://bitonics.net/vendor/bitonics/glyphs/woff2/$glyph.woff2" > "$DIR/woff2/$glyph.woff2" | |
42 | fi | |
43 | done | |
44 | endef | |
45 | ||
46 | # Rules | |
7a9e5112 | 47 | install: |
48 | node --version | |
49 | npm --version | |
50 | yarn --version | |
51 | yarn install | |
52 | ||
335b0c9b | 53 | $(JS_BUILD_DIR): |
2f91f20a | 54 | mkdir -p $@ |
78e3e81d | 55 | |
56 | $(STATIC_BUILD_DIR)/fonts: | |
57 | mkdir -p $@ | |
7a9e5112 | 58 | |
335b0c9b | 59 | $(STATIC_BUILD_DIR)/fonts/glyphs: |
60 | mkdir -p $@/ttf | |
61 | mkdir -p $@/woff | |
62 | mkdir -p $@/woff2 | |
63 | ||
64 | static: js $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) $(CRYPTO_ICONS_FONTS) | |
65 | ||
66 | js: build/static/main.js | |
67 | ||
68 | $(STATIC_BUILD_DIR)/%: static/% $(STATIC_BUILD_DIR)/fonts | |
69 | cp $< $@ | |
70 | ||
71 | $(JS_BUILD_DIR)/%.js: $(JS_SRC_DIR)/%.jsx | |
989fb5c7 | 72 | eslint --fix $< |
73 | cp $< $@ | |
7a9e5112 | 74 | |
335b0c9b | 75 | $(JS_BUILD_DIR)/%.js: $(JS_SRC_DIR)/%.js |
989fb5c7 | 76 | eslint $< |
7a9e5112 | 77 | cp $< $@ |
7a9e5112 | 78 | |
335b0c9b | 79 | $(STATIC_BUILD_DIR)/fonts/glyphs/%: static/fonts/glyphs/% $(STATIC_BUILD_DIR)/fonts/glyphs |
6b3f0ad0 | 80 | cp $< $@ |
81 | ||
335b0c9b | 82 | build/static/main.js: $(JS_BUILD_DIR) $(JSX_OBJS) $(JS_OBJS) env/$(ENV).env |
989fb5c7 | 83 | browserify -t [ babelify --presets [ env react ] --plugins [ transform-class-properties ] ] \ |
84 | -t [ localenvify --envfile env/$(ENV).env ] \ | |
85 | -t [ debowerify ] \ | |
335b0c9b | 86 | $(JS_BUILD_DIR)/main.js -o $@ |
7a9e5112 | 87 | |
335b0c9b | 88 | build/webapp.tar.gz: $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) build/static/main.js $(CRYPTO_ICONS_FONTS) |
6b3f0ad0 | 89 | tar czf $@ --directory=$(dir $<) $(subst $(STATIC_BUILD_DIR)/,,$^) |
7a9e5112 | 90 | |
335b0c9b | 91 | release: build/webapp.tar.gz |
7a9e5112 | 92 | |
93 | clean: | |
94 | rm -rf build | |
2f91f20a | 95 | rm -rf node_modules |
bf5deb87 | 96 | |
335b0c9b | 97 | fontello-open: |
bf5deb87 | 98 | @if test ! `which curl` ; then \ |
99 | echo 'Install curl first.' >&2 ; \ | |
100 | exit 128 ; \ | |
101 | fi | |
102 | curl --silent --show-error --fail --output .fontello \ | |
103 | --form "config=@fontello_config.json" \ | |
104 | ${FONTELLO_HOST} | |
105 | x-www-browser ${FONTELLO_HOST}/`cat .fontello` | |
106 | ||
335b0c9b | 107 | fontello-save: |
bf5deb87 | 108 | @if test ! `which unzip` ; then \ |
109 | echo 'Install unzip first.' >&2 ; \ | |
110 | exit 128 ; \ | |
111 | fi | |
112 | @if test ! -e .fontello ; then \ | |
113 | echo 'Run `make fontopen` first.' >&2 ; \ | |
114 | exit 128 ; \ | |
115 | fi | |
116 | rm -rf .fontello.src .fontello.zip | |
117 | curl --silent --show-error --fail --output .fontello.zip \ | |
118 | ${FONTELLO_HOST}/`cat .fontello`/get | |
119 | unzip .fontello.zip -d .fontello.src | |
335b0c9b | 120 | rm -rf ${FONTELLO_TMP_DIR} |
121 | mv `find ./.fontello.src -maxdepth 1 -name 'fontello-*'` ${FONTELLO_TMP_DIR} | |
bf5deb87 | 122 | rm -rf .fontello.src .fontello.zip |
335b0c9b | 123 | cp ${FONTELLO_TMP_DIR}/font/* static/fonts/ |
124 | cp ${FONTELLO_TMP_DIR}/css/fontello-codes.css static/fontello.css | |
125 | rm -rf ${FONTELLO_TMP_DIR} | |
126 | ||
127 | ||
128 | crypto-icons: ; $(value fetch-bitonics-icons) | |
129 | ||
130 | .ONESHELL: |