aboutsummaryrefslogtreecommitdiff
path: root/cmd/web/Makefile
blob: cb83f56c417f7e5c53bc139f18ffe771711cb07a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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)))
STATIC_BUILD_DIR=build/static

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)
	mkdir -p $@
	mkdir -p $@/icons/black
	mkdir -p $@/icons/color

$(STATIC_BUILD_DIR)/fonts:
	mkdir -p $@

$(BUILD_DIR)/%.js: $(SRC_DIR)/%.jsx
	eslint --fix $<
	cp $< $@

$(BUILD_DIR)/%.js: $(SRC_DIR)/%.js
	eslint $<
	cp $< $@

$(STATIC_BUILD_DIR)/icons/black/%.svg: static/icons/black/%.svg
	cp $< $@

build/static/main.js: $(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 $@

build/webapp.tar.gz: $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) build/static/main.js $(ICONS)
	tar czf $@ --directory=$(dir $<) $(subst $(STATIC_BUILD_DIR)/,,$^)

release: $(STATIC_BUILD_DIR) 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:
	@if test ! `which curl` ; then \
		echo 'Install curl first.' >&2 ; \
		exit 128 ; \
		fi
	curl --silent --show-error --fail --output .fontello \
		--form "config=@fontello_config.json" \
		${FONTELLO_HOST}
	x-www-browser ${FONTELLO_HOST}/`cat .fontello`


fontsave:
	@if test ! `which unzip` ; then \
		echo 'Install unzip first.' >&2 ; \
		exit 128 ; \
		fi
	@if test ! -e .fontello ; then \
		echo 'Run `make fontopen` first.' >&2 ; \
		exit 128 ; \
		fi
	rm -rf .fontello.src .fontello.zip
	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.src .fontello.zip
	cp ${FONT_DIR}/font/* static/fonts/
	cp ${FONT_DIR}/css/fontello-codes.css static/fontello.css
	rm -rf ${FONT_DIR}