aboutsummaryrefslogtreecommitdiff
path: root/cmd/web/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/web/Makefile')
-rw-r--r--cmd/web/Makefile118
1 files changed, 72 insertions, 46 deletions
diff --git a/cmd/web/Makefile b/cmd/web/Makefile
index cb83f56..8b7d860 100644
--- a/cmd/web/Makefile
+++ b/cmd/web/Makefile
@@ -2,77 +2,99 @@ SHELL=/bin/bash
2ENV ?= dev 2ENV ?= dev
3export PATH := $(PATH):./node_modules/.bin 3export PATH := $(PATH):./node_modules/.bin
4 4
5SRC_DIR=js 5# Javascript objects
6BUILD_DIR=build/js 6JS_SRC_DIR=js
7JSX_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 7JS_BUILD_DIR=build/js
8JS_SRC= cookies.js app.js api.js 8JSX_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
9STATIC_FILES= index.html style.css fontello.css 9JS_SRC=cookies.js app.js api.js
10STATIC_FILES+=$(addprefix fonts/, fontello.eot fontello.svg fontello.ttf fontello.woff fontello.woff2 cryptocoins.css cryptocoins.ttf cryptocoins.woff cryptocoins.woff2) 10JSX_OBJS=$(addprefix $(JS_BUILD_DIR)/,$(JSX_SRC:.jsx=.js))
11JSX_OBJS=$(addprefix $(BUILD_DIR)/,$(JSX_SRC:.jsx=.js)) 11JS_OBJS=$(addprefix $(JS_BUILD_DIR)/,$(JS_SRC))
12JS_OBJS=$(addprefix $(BUILD_DIR)/,$(JS_SRC)) 12
13ICONS=$(addprefix $(STATIC_BUILD_DIR)/icons/black/, $(notdir $(wildcard static/icons/black/*.svg))) 13# Static resources
14ICONS+=$(addprefix $(STATIC_BUILD_DIR)/icons/color/, $(notdir $(wildcard static/icons/color/*.svg)))
15STATIC_BUILD_DIR=build/static 14STATIC_BUILD_DIR=build/static
15STATIC_FILES=index.html style.css
16 16
17# Fontello icon provider - regular icons
18STATIC_FILES+=fontello.css
19STATIC_FILES+=$(addprefix fonts/, fontello.eot fontello.svg fontello.ttf fontello.woff fontello.woff2)
20FONTELLO_TMP_DIR = ./static/fontello
21FONTELLO_HOST ?= http://fontello.com
22
23# Biticonics cryptocurrency icon provider.
24STATIC_FILES+=$(addprefix fonts/, bitonics.min.css)
25CRYPTO_ICONS_FONTS=$(addprefix $(STATIC_BUILD_DIR)/fonts/glyphs/ttf/, $(notdir $(wildcard static/fonts/glyphs/ttf/*.ttf)))
26CRYPTO_ICONS_FONTS+=$(addprefix $(STATIC_BUILD_DIR)/fonts/glyphs/woff/, $(notdir $(wildcard static/fonts/glyphs/woff/*.woff)))
27CRYPTO_ICONS_FONTS+=$(addprefix $(STATIC_BUILD_DIR)/fonts/glyphs/woff2/, $(notdir $(wildcard static/fonts/glyphs/woff2/*.woff2)))
28
29define 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
44endef
45
46# Rules
17install: 47install:
18 node --version 48 node --version
19 npm --version 49 npm --version
20 yarn --version 50 yarn --version
21 yarn install 51 yarn install
22 52
23static: $(STATIC_BUILD_DIR) $(STATIC_BUILD_DIR)/fonts js $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) $(ICONS) 53$(JS_BUILD_DIR):
24
25js: build/static/main.js
26
27$(STATIC_BUILD_DIR)/%: static/%
28 cp $< $@
29
30$(STATIC_BUILD_DIR):
31 mkdir -p $(BUILD_DIR)
32 mkdir -p $@ 54 mkdir -p $@
33 mkdir -p $@/icons/black
34 mkdir -p $@/icons/color
35 55
36$(STATIC_BUILD_DIR)/fonts: 56$(STATIC_BUILD_DIR)/fonts:
37 mkdir -p $@ 57 mkdir -p $@
38 58
39$(BUILD_DIR)/%.js: $(SRC_DIR)/%.jsx 59$(STATIC_BUILD_DIR)/fonts/glyphs:
60 mkdir -p $@/ttf
61 mkdir -p $@/woff
62 mkdir -p $@/woff2
63
64static: js $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) $(CRYPTO_ICONS_FONTS)
65
66js: 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
40 eslint --fix $< 72 eslint --fix $<
41 cp $< $@ 73 cp $< $@
42 74
43$(BUILD_DIR)/%.js: $(SRC_DIR)/%.js 75$(JS_BUILD_DIR)/%.js: $(JS_SRC_DIR)/%.js
44 eslint $< 76 eslint $<
45 cp $< $@ 77 cp $< $@
46 78
47$(STATIC_BUILD_DIR)/icons/black/%.svg: static/icons/black/%.svg 79$(STATIC_BUILD_DIR)/fonts/glyphs/%: static/fonts/glyphs/% $(STATIC_BUILD_DIR)/fonts/glyphs
48 cp $< $@ 80 cp $< $@
49 81
50build/static/main.js: $(JSX_OBJS) $(JS_OBJS) env/$(ENV).env 82build/static/main.js: $(JS_BUILD_DIR) $(JSX_OBJS) $(JS_OBJS) env/$(ENV).env
51 browserify -t [ babelify --presets [ env react ] --plugins [ transform-class-properties ] ] \ 83 browserify -t [ babelify --presets [ env react ] --plugins [ transform-class-properties ] ] \
52 -t [ localenvify --envfile env/$(ENV).env ] \ 84 -t [ localenvify --envfile env/$(ENV).env ] \
53 -t [ debowerify ] \ 85 -t [ debowerify ] \
54 $(BUILD_DIR)/main.js -o $@ 86 $(JS_BUILD_DIR)/main.js -o $@
55 87
56build/webapp.tar.gz: $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) build/static/main.js $(ICONS) 88build/webapp.tar.gz: $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) build/static/main.js $(CRYPTO_ICONS_FONTS)
57 tar czf $@ --directory=$(dir $<) $(subst $(STATIC_BUILD_DIR)/,,$^) 89 tar czf $@ --directory=$(dir $<) $(subst $(STATIC_BUILD_DIR)/,,$^)
58 90
59release: $(STATIC_BUILD_DIR) build/webapp.tar.gz 91release: build/webapp.tar.gz
60 92
61clean: 93clean:
62 rm -rf build 94 rm -rf build
63 rm -rf node_modules 95 rm -rf node_modules
64 96
65 97fontello-open:
66FONT_DIR = ./static/fontello
67FONTELLO_HOST ?= http://fontello.com
68
69crypto-icons:
70 curl "https://raw.githubusercontent.com/AllienWorks/cryptocoins/master/webfont/cryptocoins.css" > ./static/fonts/cryptocoins.css
71 curl "https://raw.githubusercontent.com/AllienWorks/cryptocoins/master/webfont/cryptocoins.ttf" > ./static/fonts/cryptocoins.ttf
72 curl "https://raw.githubusercontent.com/AllienWorks/cryptocoins/master/webfont/cryptocoins.woff" > ./static/fonts/cryptocoins.woff
73 curl "https://raw.githubusercontent.com/AllienWorks/cryptocoins/master/webfont/cryptocoins.woff2" > ./static/fonts/cryptocoins.woff2
74
75fontopen:
76 @if test ! `which curl` ; then \ 98 @if test ! `which curl` ; then \
77 echo 'Install curl first.' >&2 ; \ 99 echo 'Install curl first.' >&2 ; \
78 exit 128 ; \ 100 exit 128 ; \
@@ -82,8 +104,7 @@ fontopen:
82 ${FONTELLO_HOST} 104 ${FONTELLO_HOST}
83 x-www-browser ${FONTELLO_HOST}/`cat .fontello` 105 x-www-browser ${FONTELLO_HOST}/`cat .fontello`
84 106
85 107fontello-save:
86fontsave:
87 @if test ! `which unzip` ; then \ 108 @if test ! `which unzip` ; then \
88 echo 'Install unzip first.' >&2 ; \ 109 echo 'Install unzip first.' >&2 ; \
89 exit 128 ; \ 110 exit 128 ; \
@@ -96,9 +117,14 @@ fontsave:
96 curl --silent --show-error --fail --output .fontello.zip \ 117 curl --silent --show-error --fail --output .fontello.zip \
97 ${FONTELLO_HOST}/`cat .fontello`/get 118 ${FONTELLO_HOST}/`cat .fontello`/get
98 unzip .fontello.zip -d .fontello.src 119 unzip .fontello.zip -d .fontello.src
99 rm -rf ${FONT_DIR} 120 rm -rf ${FONTELLO_TMP_DIR}
100 mv `find ./.fontello.src -maxdepth 1 -name 'fontello-*'` ${FONT_DIR} 121 mv `find ./.fontello.src -maxdepth 1 -name 'fontello-*'` ${FONTELLO_TMP_DIR}
101 rm -rf .fontello.src .fontello.zip 122 rm -rf .fontello.src .fontello.zip
102 cp ${FONT_DIR}/font/* static/fonts/ 123 cp ${FONTELLO_TMP_DIR}/font/* static/fonts/
103 cp ${FONT_DIR}/css/fontello-codes.css static/fontello.css 124 cp ${FONTELLO_TMP_DIR}/css/fontello-codes.css static/fontello.css
104 rm -rf ${FONT_DIR} \ No newline at end of file 125 rm -rf ${FONTELLO_TMP_DIR}
126
127
128crypto-icons: ; $(value fetch-bitonics-icons)
129
130.ONESHELL: \ No newline at end of file