forked from tbaltrushaitis/cv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
176 lines (127 loc) · 5.89 KB
/
Makefile
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
## ------------------------------------------------------------------------ ##
## Build Project ##
## ------------------------------------------------------------------------ ##
.SILENT:
.EXPORT_ALL_VARIABLES:
.IGNORE:
.ONESHELL:
SHELL = /bin/sh
## ------------------------------------------------------------------------ ##
$(shell [ -f NODE_ENV ] || cp -prfu config/.NODE_ENV ./NODE_ENV);
$(shell [ -f .bowerrc ] || cp -prfu config/.bowerrc ./);
$(shell [ -f .npmrc ] || cp -prfu config/.npmrc ./);
## ------------------------------------------------------------------------ ##
APP_NAME := cv
APP_SLOG := CV+PORTFOLIO
APP_LOGO := ./assets/BANNER
APP_REPO := $(shell git ls-remote --get-url)
CODE_VERSION := $(shell cat ./VERSION)
GIT_COMMIT := $(shell git rev-list --remove-empty --remotes --max-count=1 --date-order --reverse)
WD := $(shell pwd -P)
DT = $(shell date +'%Y%m%d%H%M%S')
APP_ENV := $(strip $(shell [ -f NODE_ENV ] && cat NODE_ENV || cat config/.NODE_ENV))
ifeq ($(APP_ENV),)
$(info [$(White)$(DT)$(NC)] APP_ENV is NOT DETECTED!)
APP_ENV := $(strip $(shell echo $([ -f NODE_ENV ] && cat NODE_ENV || cat config/.NODE_ENV)))
endif
BUILD_FILE = BUILD-$(CODE_VERSION)
BUILD_CNTR = $(strip $(shell [ -f "$(BUILD_FILE)" ] && cat $(BUILD_FILE) || echo 0))
BUILD_CNTR := $(shell echo $$(( $(BUILD_CNTR) + 1 )))
BUILD_FULL := $(shell date +'%Y-%m-%dT%H:%M:%SZ %Z')
BUILD_DATE := $(shell date +'%Y-%m-%d')
BUILD_TIME := $(shell date +'%H:%M:%S')
BUILD_YEAR := $(shell date +'%Y')
BUILD_HASH := $(shell echo "$(BUILD_FULL)" | md5sum | cut -b -4)
## ------------------------------------------------------------------------ ##
## Colors definitions
## ------------------------------------------------------------------------ ##
include bin/Colors
## ------------------------------------------------------------------------ ##
## BUILDs counter
## ------------------------------------------------------------------------ ##
$(file > $(BUILD_FILE),$(BUILD_CNTR))
$(info [$(White)$(DT)$(NC)] Created file [$(Yellow)$(BUILD_FILE)$(NC):$(BPurple)$(BUILD_CNTR)$(NC)])
## ------------------------------------------------------------------------ ##
## BUILD information
## ------------------------------------------------------------------------ ##
BUILD_CONTENT = $(strip $(shell cat config/build.tpl))
BUILD_CONTENT := $(subst BUILD_CNTR,$(BUILD_CNTR),$(BUILD_CONTENT))
BUILD_CONTENT := $(subst BUILD_FULL,$(BUILD_FULL),$(BUILD_CONTENT))
BUILD_CONTENT := $(subst BUILD_DATE,$(BUILD_DATE),$(BUILD_CONTENT))
BUILD_CONTENT := $(subst BUILD_TIME,$(BUILD_TIME),$(BUILD_CONTENT))
BUILD_CONTENT := $(subst BUILD_YEAR,$(BUILD_YEAR),$(BUILD_CONTENT))
BUILD_CONTENT := $(subst BUILD_HASH,$(BUILD_HASH),$(BUILD_CONTENT))
BUILD_CONTENT := $(subst GIT_COMMIT,$(GIT_COMMIT),$(BUILD_CONTENT))
BUILD_CONTENT := $(subst CODE_VERSION,$(CODE_VERSION),$(BUILD_CONTENT))
# $(info [$(White)$(DT)$(NC)] BUILD_CONTENT [$(Yellow)$(BUILD_CONTENT)$(NC)])
$(file > config/build.json,$(BUILD_CONTENT))
$(info [$(White)$(DT)$(NC)] Created file [$(Yellow)BUILD_CONTENT$(NC):$(BPurple)$(WD)/config/build.json$(NC)])
## ------------------------------------------------------------------------ ##
$(file > COMMIT,$(GIT_COMMIT));
$(info [$(White)$(DT)$(NC)] Created file [$(BYellow)COMMIT$(NC):$(BPurple)$(GIT_COMMIT)$(NC)]);
DIR_SRC := ${WD}/src
DIR_BUILD := ${WD}/build-${CODE_VERSION}
DIR_DIST := ${WD}/dist-${CODE_VERSION}
DIR_WEB := ${WD}/webroot
## ------------------------------------------------------------------------ ##
## Query default goal.
## ------------------------------------------------------------------------ ##
ifeq ($(.DEFAULT_GOAL),)
.DEFAULT_GOAL := default
endif
$(info [$(White)$(DT)$(NC)] $(BYellow)Goal$(NC) [$(Yellow)DEFAULT$(NC):$(BPurple)$(.DEFAULT_GOAL)$(NC)]);
$(info [$(White)$(DT)$(NC)] $(BYellow)Goal$(NC) [$(Yellow)CURRENT$(NC):$(BPurple)$(MAKECMDGOALS)$(NC)]);
## ------------------------------------------------------------------------ ##
## INCLUDES ##
## ------------------------------------------------------------------------ ##
include ./bin/*.mk
## ------------------------------------------------------------------------ ##
.PHONY: default
default: run ;
## ------------------------------------------------------------------------ ##
.PHONY: test config tasklist tasktree
test: state help usage banner ;
@ export NODE_ENV="${APP_ENV}"; npm run test
config:
@ export NODE_ENV="${APP_ENV}"; npm run config
tasklist:
@ gulp --tasks --depth 1 --color
tasktree:
@ gulp --tasks --depth 2 --color
## ------------------------------------------------------------------------ ##
.PHONY: build dist deploy pre-update update
setup: setup-deps ;
@ touch setup
setup-deps:
@ npm i -g bower ;
@ npm i ;
@ bower i --production ;
@ touch setup-deps
build:
@ export NODE_ENV="${APP_ENV}"; npm run build
dist:
@ export NODE_ENV="${APP_ENV}"; gulp dist
deploy:
@ export NODE_ENV="${APP_ENV}"; npm run deploy
pre-update:
@ rm -f setup setup-deps ;
update: pre-update setup ;
## ------------------------------------------------------------------------ ##
.PHONY: rebuild redeploy
rebuild: build ;
redeploy: rebuild deploy banner ;
## ------------------------------------------------------------------------ ##
.PHONY: all full cycle cycle-dev dev run watch
#* means the word "all" doesn't represent a file name in this Makefile;
#* means the Makefile has nothing to do with a file called "all" in the same directory.
all: clean cycle banner ;
full: clean-all all banner ;
cycle: rights setup build deploy ;
cycle-dev: build deploy ;
dev: clean-build cycle-dev banner ;
@ export NODE_ENV="${APP_ENV}"; npm run dev ;
run: banner help ;
@ export NODE_ENV="${APP_ENV}"; npm run all
watch:
@ export NODE_ENV="${APP_ENV}"; npm run watch
## ------------------------------------------------------------------------ ##