]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git/blobdiff - cmd/web/Makefile
Reliable icon provider for cryptocurrencies logo : Bitonics.
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git] / cmd / web / Makefile
index cb83f56c417f7e5c53bc139f18ffe771711cb07a..8b7d86032d639d4a197a8686f4f58644f76b6739 100644 (file)
@@ -2,77 +2,99 @@ SHELL=/bin/bash
 ENV ?= dev
 export PATH := $(PATH):./node_modules/.bin
 
-SRC_DIR=js
-BUILD_DIR=build/js
-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
-JS_SRC= cookies.js app.js api.js
-STATIC_FILES= index.html style.css fontello.css
-STATIC_FILES+=$(addprefix fonts/, fontello.eot fontello.svg fontello.ttf fontello.woff fontello.woff2 cryptocoins.css cryptocoins.ttf cryptocoins.woff cryptocoins.woff2)
-JSX_OBJS=$(addprefix $(BUILD_DIR)/,$(JSX_SRC:.jsx=.js))
-JS_OBJS=$(addprefix $(BUILD_DIR)/,$(JS_SRC))
-ICONS=$(addprefix $(STATIC_BUILD_DIR)/icons/black/, $(notdir $(wildcard static/icons/black/*.svg)))
-ICONS+=$(addprefix $(STATIC_BUILD_DIR)/icons/color/, $(notdir $(wildcard static/icons/color/*.svg)))
+# Javascript objects
+JS_SRC_DIR=js
+JS_BUILD_DIR=build/js
+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
+JS_SRC=cookies.js app.js api.js
+JSX_OBJS=$(addprefix $(JS_BUILD_DIR)/,$(JSX_SRC:.jsx=.js))
+JS_OBJS=$(addprefix $(JS_BUILD_DIR)/,$(JS_SRC))
+
+# Static resources
 STATIC_BUILD_DIR=build/static
+STATIC_FILES=index.html style.css
 
+# Fontello icon provider - regular icons
+STATIC_FILES+=fontello.css
+STATIC_FILES+=$(addprefix fonts/, fontello.eot fontello.svg fontello.ttf fontello.woff fontello.woff2)
+FONTELLO_TMP_DIR = ./static/fontello
+FONTELLO_HOST ?= http://fontello.com
+
+# Biticonics cryptocurrency icon provider.
+STATIC_FILES+=$(addprefix fonts/, bitonics.min.css)
+CRYPTO_ICONS_FONTS=$(addprefix $(STATIC_BUILD_DIR)/fonts/glyphs/ttf/, $(notdir $(wildcard static/fonts/glyphs/ttf/*.ttf)))
+CRYPTO_ICONS_FONTS+=$(addprefix $(STATIC_BUILD_DIR)/fonts/glyphs/woff/, $(notdir $(wildcard static/fonts/glyphs/woff/*.woff)))
+CRYPTO_ICONS_FONTS+=$(addprefix $(STATIC_BUILD_DIR)/fonts/glyphs/woff2/, $(notdir $(wildcard static/fonts/glyphs/woff2/*.woff2)))
+
+define fetch-bitonics-icons =
+       DIR="static/fonts/glyphs"
+
+       curl 'https://bitonics.net/vendor/bitonics/bitonics.min.css' > static/fonts/bitonics.min.css
+
+       glyphs=($(curl 'https://bitonics.net/vendor/bitonics/bitonics.css' | grep -Po 'glyphs/ttf/[a-z0-9]{8}' | cut -c 12-))
+
+       for glyph in "${glyphs[@]}"
+       do
+               if [ ! -f "$DIR/ttf/$glyph.ttf" ]; then
+                 curl "https://bitonics.net/vendor/bitonics/glyphs/ttf/$glyph.ttf" > "$DIR/ttf/$glyph.ttf"
+                 curl "https://bitonics.net/vendor/bitonics/glyphs/woff/$glyph.woff" > "$DIR/woff/$glyph.woff"
+                 curl "https://bitonics.net/vendor/bitonics/glyphs/woff2/$glyph.woff2" > "$DIR/woff2/$glyph.woff2"
+               fi
+       done
+endef
+
+# Rules
 install:
        node --version
        npm --version
        yarn --version
        yarn install
 
-static: $(STATIC_BUILD_DIR) $(STATIC_BUILD_DIR)/fonts js $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) $(ICONS)
-
-js: build/static/main.js
-
-$(STATIC_BUILD_DIR)/%: static/%
-       cp $< $@
-
-$(STATIC_BUILD_DIR):
-       mkdir -p $(BUILD_DIR)
+$(JS_BUILD_DIR):
        mkdir -p $@
-       mkdir -p $@/icons/black
-       mkdir -p $@/icons/color
 
 $(STATIC_BUILD_DIR)/fonts:
        mkdir -p $@
 
-$(BUILD_DIR)/%.js: $(SRC_DIR)/%.jsx
+$(STATIC_BUILD_DIR)/fonts/glyphs:
+       mkdir -p $@/ttf
+       mkdir -p $@/woff
+       mkdir -p $@/woff2
+
+static: js $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) $(CRYPTO_ICONS_FONTS)
+
+js: build/static/main.js
+
+$(STATIC_BUILD_DIR)/%: static/% $(STATIC_BUILD_DIR)/fonts
+       cp $< $@
+
+$(JS_BUILD_DIR)/%.js: $(JS_SRC_DIR)/%.jsx
        eslint --fix $<
        cp $< $@
 
-$(BUILD_DIR)/%.js: $(SRC_DIR)/%.js
+$(JS_BUILD_DIR)/%.js: $(JS_SRC_DIR)/%.js
        eslint $<
        cp $< $@
 
-$(STATIC_BUILD_DIR)/icons/black/%.svg: static/icons/black/%.svg
+$(STATIC_BUILD_DIR)/fonts/glyphs/%: static/fonts/glyphs/% $(STATIC_BUILD_DIR)/fonts/glyphs
        cp $< $@
 
-build/static/main.js: $(JSX_OBJS) $(JS_OBJS) env/$(ENV).env
+build/static/main.js: $(JS_BUILD_DIR) $(JSX_OBJS) $(JS_OBJS) env/$(ENV).env
        browserify -t [ babelify --presets [ env react ] --plugins [ transform-class-properties ] ] \
                           -t [ localenvify --envfile env/$(ENV).env ] \
                           -t [ debowerify ]  \
-                           $(BUILD_DIR)/main.js -o $@
+                           $(JS_BUILD_DIR)/main.js -o $@
 
-build/webapp.tar.gz: $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) build/static/main.js $(ICONS)
+build/webapp.tar.gz: $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) build/static/main.js $(CRYPTO_ICONS_FONTS)
        tar czf $@ --directory=$(dir $<) $(subst $(STATIC_BUILD_DIR)/,,$^)
 
-release: $(STATIC_BUILD_DIR) build/webapp.tar.gz
+release: build/webapp.tar.gz
 
 clean:
        rm -rf build
        rm -rf node_modules
 
-
-FONT_DIR = ./static/fontello
-FONTELLO_HOST ?= http://fontello.com
-
-crypto-icons:
-       curl "https://raw.githubusercontent.com/AllienWorks/cryptocoins/master/webfont/cryptocoins.css" > ./static/fonts/cryptocoins.css
-       curl "https://raw.githubusercontent.com/AllienWorks/cryptocoins/master/webfont/cryptocoins.ttf" > ./static/fonts/cryptocoins.ttf
-       curl "https://raw.githubusercontent.com/AllienWorks/cryptocoins/master/webfont/cryptocoins.woff" > ./static/fonts/cryptocoins.woff
-       curl "https://raw.githubusercontent.com/AllienWorks/cryptocoins/master/webfont/cryptocoins.woff2" > ./static/fonts/cryptocoins.woff2
-
-fontopen:
+fontello-open:
        @if test ! `which curl` ; then \
                echo 'Install curl first.' >&2 ; \
                exit 128 ; \
@@ -82,8 +104,7 @@ fontopen:
                ${FONTELLO_HOST}
        x-www-browser ${FONTELLO_HOST}/`cat .fontello`
 
-
-fontsave:
+fontello-save:
        @if test ! `which unzip` ; then \
                echo 'Install unzip first.' >&2 ; \
                exit 128 ; \
@@ -96,9 +117,14 @@ fontsave:
        curl --silent --show-error --fail --output .fontello.zip \
                ${FONTELLO_HOST}/`cat .fontello`/get
        unzip .fontello.zip -d .fontello.src
-       rm -rf ${FONT_DIR}
-       mv `find ./.fontello.src -maxdepth 1 -name 'fontello-*'` ${FONT_DIR}
+       rm -rf ${FONTELLO_TMP_DIR}
+       mv `find ./.fontello.src -maxdepth 1 -name 'fontello-*'` ${FONTELLO_TMP_DIR}
        rm -rf .fontello.src .fontello.zip
-       cp ${FONT_DIR}/font/* static/fonts/
-       cp ${FONT_DIR}/css/fontello-codes.css static/fontello.css
-       rm -rf ${FONT_DIR}
\ No newline at end of file
+       cp ${FONTELLO_TMP_DIR}/font/* static/fonts/
+       cp ${FONTELLO_TMP_DIR}/css/fontello-codes.css static/fontello.css
+       rm -rf ${FONTELLO_TMP_DIR}
+
+
+crypto-icons: ; $(value fetch-bitonics-icons)
+
+.ONESHELL:
\ No newline at end of file