]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git/blob - cmd/web/Makefile
Update static assets.
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git] / cmd / web / Makefile
1 SHELL=/bin/bash
2 ENV ?= dev
3 export PATH := $(PATH):./node_modules/.bin
4
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
14 STATIC_BUILD_DIR=build/static
15 STATIC_FILES=index.html style.css
16
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
47 install:
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
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
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
82 build/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
88 build/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
91 release: build/webapp.tar.gz
92
93 clean:
94 rm -rf build
95 rm -rf node_modules
96
97 fontello-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=@static/fontello_config.json" \
104 ${FONTELLO_HOST}
105 x-www-browser ${FONTELLO_HOST}/`cat .fontello`
106
107 fontello-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 cp ${FONTELLO_TMP_DIR}/config.json static/fontello_config.json
126 rm -rf ${FONTELLO_TMP_DIR}
127
128
129 crypto-icons: ; $(value fetch-bitonics-icons)
130
131 .ONESHELL: