]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git/blame_incremental - cmd/web/Makefile
Reliable icon provider for cryptocurrencies logo : Bitonics.
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git] / cmd / web / Makefile
... / ...
CommitLineData
1SHELL=/bin/bash
2ENV ?= dev
3export PATH := $(PATH):./node_modules/.bin
4
5# Javascript objects
6JS_SRC_DIR=js
7JS_BUILD_DIR=build/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
9JS_SRC=cookies.js app.js api.js
10JSX_OBJS=$(addprefix $(JS_BUILD_DIR)/,$(JSX_SRC:.jsx=.js))
11JS_OBJS=$(addprefix $(JS_BUILD_DIR)/,$(JS_SRC))
12
13# Static resources
14STATIC_BUILD_DIR=build/static
15STATIC_FILES=index.html style.css
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
47install:
48 node --version
49 npm --version
50 yarn --version
51 yarn install
52
53$(JS_BUILD_DIR):
54 mkdir -p $@
55
56$(STATIC_BUILD_DIR)/fonts:
57 mkdir -p $@
58
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
72 eslint --fix $<
73 cp $< $@
74
75$(JS_BUILD_DIR)/%.js: $(JS_SRC_DIR)/%.js
76 eslint $<
77 cp $< $@
78
79$(STATIC_BUILD_DIR)/fonts/glyphs/%: static/fonts/glyphs/% $(STATIC_BUILD_DIR)/fonts/glyphs
80 cp $< $@
81
82build/static/main.js: $(JS_BUILD_DIR) $(JSX_OBJS) $(JS_OBJS) env/$(ENV).env
83 browserify -t [ babelify --presets [ env react ] --plugins [ transform-class-properties ] ] \
84 -t [ localenvify --envfile env/$(ENV).env ] \
85 -t [ debowerify ] \
86 $(JS_BUILD_DIR)/main.js -o $@
87
88build/webapp.tar.gz: $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) build/static/main.js $(CRYPTO_ICONS_FONTS)
89 tar czf $@ --directory=$(dir $<) $(subst $(STATIC_BUILD_DIR)/,,$^)
90
91release: build/webapp.tar.gz
92
93clean:
94 rm -rf build
95 rm -rf node_modules
96
97fontello-open:
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
107fontello-save:
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
120 rm -rf ${FONTELLO_TMP_DIR}
121 mv `find ./.fontello.src -maxdepth 1 -name 'fontello-*'` ${FONTELLO_TMP_DIR}
122 rm -rf .fontello.src .fontello.zip
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
128crypto-icons: ; $(value fetch-bitonics-icons)
129
130.ONESHELL: