forked from plouc/mozaik
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
232 lines (185 loc) · 8.42 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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
.PHONY: help ls website ext-build-all
PACKAGES = $(shell ls packages)
EXTENSIONS = $(shell ls extensions)
NODE_MODULES = "./node_modules"
NODE_MODULES_BIN = "$(NODE_MODULES)/.bin"
MOZAIK_TARGET_BRANCH = master
########################################################################################################################
#
# HELP
#
########################################################################################################################
# COLORS
RED = $(shell printf "\33[31m")
GREEN = $(shell printf "\33[32m")
WHITE = $(shell printf "\33[37m")
YELLOW = $(shell printf "\33[33m")
RESET = $(shell printf "\33[0m")
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
# A category can be added with @category
HELP_HELPER = \
%help; \
while(<>) { push @{$$help{$$2 // 'options'}}, [$$1, $$3] if /^([a-zA-Z\-\%]+)\s*:.*\#\#(?:@([0-9]+\s[a-zA-Z\-\%_]+))?\s(.*)$$/ }; \
print "usage: make [target]\n\n"; \
for (sort keys %help) { \
print "${WHITE}$$_:${RESET}\n"; \
for (@{$$help{$$_}}) { \
$$sep = " " x (32 - length $$_->[0]); \
print " ${YELLOW}$$_->[0]${RESET}$$sep${GREEN}$$_->[1]${RESET}\n"; \
}; \
print "\n"; }
help: ##prints help
@perl -e '$(HELP_HELPER)' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help
########################################################################################################################
#
# GLOBAL
#
########################################################################################################################
init: ##@0 global cleanup/install/bootstrap
@$(MAKE) clean-all
@yarn install
@$(MAKE) bootstrap
@$(MAKE) build
bootstrap: ##@0 global lerna bootstrap
@$(NODE_MODULES_BIN)/lerna bootstrap
link: ##@0 global symlink packages & extensions
@$(NODE_MODULES_BIN)/lerna link
build: ##@0 global build all packages
@$(NODE_MODULES_BIN)/lerna run build
lint: ##@0 global lint all packages
@$(NODE_MODULES_BIN)/lerna run lint
fmt: ##@0 global format code using prettier (js, css, md)
@$(NODE_MODULES_BIN)/lerna run fmt
fmt-check: ##@0 global check if files were all formatted using prettier
@$(NODE_MODULES_BIN)/lerna run fmt:check
ls: ##@0 global list packages & extensions
@echo "$(YELLOW)Available packages & extensions:$(RESET)"
@$(NODE_MODULES_BIN)/lerna ls
clean-all: ##@0 global uninstall node modules, remove transpiled code & lock files
@rm -rf node_modules
@rm -rf package-lock.json
@$(foreach pkg,$(PACKAGES),$(call clean_dir_all,packages/$(pkg)))
@$(foreach ext,$(EXTENSIONS),$(call clean_dir_all,extensions/$(ext)))
define clean_dir_all
rm -rf $(1)/es
rm -rf $(1)/lib
rm -rf $(1)/node_modules
rm -rf $(1)/package-lock.json
endef
test-all: ##@0 global all checks/tests
@$(MAKE) fmt-check
@$(MAKE) lint
@$(MAKE) pkg-test-server
@$(MAKE) pkg-test-ui
########################################################################################################################
#
# PACKAGES
#
########################################################################################################################
pkg-watch-%: ##@1 packages enable watch mode for a specific package
@$(MAKE) MAKEFLAGS="-j 2" ext-commonjs-watch-$(*) ext-es-watch-$(*)
pkg-commonjs-watch-%: ##@1 packages enable watch mode for a specific package (commonjs)
@echo "$(YELLOW)enabling watch mode (commonjs) for $(WHITE)@mozaik/$(*)$(RESET)"
@cd "packages/${*}" && yarn run build:commonjs:watch
pkg-es-watch-%: ##@1 packages enable watch mode for a specific package (es)
@echo "$(YELLOW)enabling watch mode (es) for $(WHITE)@mozaik/$(*)$(RESET)"
@cd "packages/$(*)" && yarn run build:es:watch
pkg-test-%: ##@1 packages run tests for a specific package
cd "packages/$(*)" && yarn run test
pkg-build-all: ##@1 packages build all packages
@$(MAKE) pkg-build-ui
@$(MAKE) pkg-build-themes
pkg-build-%: ##@1 packages build a specific package
@echo "$(YELLOW)Building: $(WHITE)@mozaik/$(*)$(RESET)"
@cd "packages/$(*)" && yarn run build
pkg-v-%: ##@1 packages get current local package version (eg. pkg-v-server)
@echo "$(WHITE)@mozaik/$(*) $(YELLOW)local package version:$(RESET)"
@cd "packages/$(*)" && npm run -s version
pkg-pub-%: ##@1 packages publish a package (eg. pkg-pub-server)
@if [ -z "$(V)" ]; then \
echo "$(RED)version 'V' is not defined$(RESET)"; \
exit 1; \
fi;
@echo "$(YELLOW)Publishing $(WHITE)@mozaik/$(*)@$(V)$(YELLOW) from $(WHITE)@mozaik/$(*)@$$(cd "packages/$(*)" && npm run -s version)$(RESET)"
@cd packages/$(*) && npm version "$(V)"
@git add packages/$(*)/package.json
@git commit -m "bump(@mozaik/$(*)): bump @mozaik/$(*) to version $(V)"
@cd packages/$(*) && npm publish --access public
@git tag -a "@mozaik/$(*)@$(V)" -m "@mozaik/$(*) v$(V)"
@git push --tags -u origin "$(MOZAIK_TARGET_BRANCH)"
@echo "$(GREEN)Published @mozaik/$(*)@$(V)$(RESET)"
ui-storybook: ##@1 packages run storybook for ui package
@cd packages/ui && yarn run storybook
########################################################################################################################
#
# EXTENSIONS
#
########################################################################################################################
ext-build-all: ##@2 extensions build all extensions
@$(foreach ext,$(EXTENSIONS),$(MAKE) ext-build-$(ext))
ext-build-%: ##@2 extensions build a specific extension
@echo "$(YELLOW)Building: $(WHITE)@mozaik/ext-$(*)$(RESET)"
@cd "extensions/$(*)" && yarn run build
ext-watch-%: ##@2 extensions enable watch mode for a specific extension
@$(MAKE) MAKEFLAGS="-j 2" ext-commonjs-watch-$(*) ext-es-watch-$(*)
ext-dev-%: ##@2 extensions start dev mode for a specific extension
@$(MAKE) pkg-build-server
@$(MAKE) ext-build-$(*)
@$(MAKE) MAKEFLAGS="-j 6" \
ext-commonjs-watch-$(*) \
ext-es-watch-$(*) \
pkg-commonjs-watch-ui \
pkg-es-watch-ui \
demo-start-ui \
demo-start-server CONF="conf/config-$(*).yml"
ext-commonjs-watch-%: ##@2 extensions enable watch mode for a specific extension (commonjs)
@echo "$(YELLOW)enabling watch mode (commonjs) for $(WHITE)@mozaik/ext-$(*)$(RESET)"
@cd "extensions/$(*)" && yarn run build:commonjs:watch
ext-es-watch-%: ##@2 extensions enable watch mode for a specific extension (es)
@echo "$(YELLOW)enabling watch mode (es) for $(WHITE)@mozaik/ext-$(*)$(RESET)"
@cd "extensions/$(*)" && yarn run build:es:watch
ext-pub-%: ##@2 extensions publish an extension (eg. ext-pub-gitlab)
@if [ -z "$(V)" ]; then \
echo "$(RED)version 'V' is not defined$(RESET)"; \
exit 1; \
fi;
@echo "$(YELLOW)Publishing $(WHITE)@mozaik/ext-$(*)@$(V)$(YELLOW) from $(WHITE)@mozaik/ext-$(*)@$$(cd "extensions/$(*)" && npm run -s version)$(RESET)"
@cd extensions/$(*) && rm -rf node_modules
@cd extensions/$(*) && yarn install --pure-lockfile
@cd extensions/$(*) && npm version -m "feat(release): release v%s" "$(V)"
@cd extensions/$(*) && git add package.json
@cd extensions/$(*) && npm publish --access public
@echo "$(GREEN)✔ successfully published @mozaik/ext-$(*)@$(V)$(RESET)"
@$(MAKE) link
########################################################################################################################
#
# DEMO
#
########################################################################################################################
demo-install: ##@3 demo install demo dependencies
@echo "$(YELLOW)Installing demo dependencies$(RESET)"
@cd demo && yarn install
demo-start-ui: ##@3 demo start demo react app
@echo "$(YELLOW)Starting demo react app$(RESET)"
@cd demo && yarn start
demo-start-server: ##@3 demo start demo mozaik server
@echo "$(YELLOW)Starting demo mozaïk server ($(CONF))$(RESET)"
@cd demo && node server.js $(CONF)
demo-start: ##@3 demo start demo
@$(MAKE) MAKEFLAGS="-j 2" demo-start-ui demo-start-server
########################################################################################################################
#
# WEBSITE
#
########################################################################################################################
website: ##@4 website start mozaik website in dev mode
@echo "$(YELLOW)Starting mozaik website in dev mode$(RESET)"
@cd website && "$(NODE_MODULES_BIN)/gatsby" develop
website-build: ##@4 website build mozaik website
@echo "$(YELLOW)Building mozaik website$(RESET)"
@cd website && "$(NODE_MODULES_BIN)/gatsby" build
website-serve: website-build ##@4 website build & serve mozaik website
@echo "$(YELLOW)Serving mozaik website$(RESET)"
@cd website && "$(NODE_MODULES_BIN)/gatsby" serve