forked from plouc/nivo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
303 lines (241 loc) · 11 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
MAKEFLAGS += --no-print-directory
SOURCES = packages
.PHONY: help bootstrap init packages-build packages-publish clean-all website-install website website-build website-deploy storybook storybook-build storybook-deploy deploy-all examples-install
########################################################################################################################
#
# 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
#
########################################################################################################################
bootstrap: ##@0 global lerna bootstrap
@./node_modules/.bin/lerna bootstrap
init: ##@0 global cleanup/install/bootstrap
@$(MAKE) clean-all
@yarn install
@$(MAKE) bootstrap
@$(MAKE) packages-build
@$(MAKE) examples-install
fmt: ##@0 global format code using prettier (js, css, md)
@./node_modules/.bin/prettier --color --write \
"packages/*/{src,stories,tests}/**/*.{js,ts}" \
"packages/*/index.d.ts" \
"packages/*/README.md" \
"website/src/**/*.{js,css}" \
"examples/*/src/**/*.{js,ts,tsx,css}" \
"api/**/*.{js,ts,tsx}" \
"README.md"
fmt-check: ##@0 global check if files were all formatted using prettier
@echo "${YELLOW}Checking formatting${RESET}"
@./node_modules/.bin/prettier --color --list-different \
"packages/*/{src,stories,tests}/**/*.{js,ts}" \
"packages/*/index.d.ts" \
"packages/*/README.md" \
"website/src/**/*.{js,css}" \
"examples/*/src/**/*.{js,ts,tsx,css}" \
"api/**/*.{js,ts,tsx}" \
"README.md"
test: ##@0 global run all checks/tests (packages, website & examples)
@$(MAKE) fmt-check
@$(MAKE) lint
@$(MAKE) packages-test
deploy-all: ##@0 global deploy website & storybook
@$(MAKE) website-deploy
@$(MAKE) storybook-deploy
clean-all: ##@0 global uninstall node modules, remove transpiled code & lock files
@rm -rf node_modules
@rm -rf package-lock.json
@$(foreach source, $(SOURCES), $(call clean-source-all, $(source)))
@rm -rf website/node_modules
@rm -rf website/package-lock.json
define clean-source-lib
rm -rf $(1)/*/cjs
rm -rf $(1)/*/umd
endef
define clean-source-all
rm -rf $(1)/*/cjs
rm -rf $(1)/*/umd
rm -rf $(1)/*/node_modules
rm -rf $(1)/*/package-lock.json
endef
lint: ##@0 run eslint & tslint
@$(MAKE) packages-lint
@$(MAKE) packages-tslint
########################################################################################################################
#
# PACKAGES
#
########################################################################################################################
package-lint-%: ##@1 packages run eslint on package
@echo "${YELLOW}Running eslint on package ${WHITE}@nivo/${*}${RESET}"
@./node_modules/.bin/eslint ./packages/${*}/{src,tests}
packages-lint: ##@1 packages run eslint on all packages
@echo "${YELLOW}Running eslint on all packages${RESET}"
@./node_modules/.bin/eslint "./packages/*/{src,tests}/**/*.js"
package-tslint-%: ##@1 packages run tslint on package
@echo "${YELLOW}Running tslint on package ${WHITE}@nivo/${*}${RESET}"
@./node_modules/.bin/tslint ./packages/${*}/index.d.ts
packages-tslint: ##@1 packages run tslint on all packages
@echo "${YELLOW}Running tslint on all packages${RESET}"
@./node_modules/.bin/tslint \
./packages/annotations/index.d.ts \
./packages/axes/index.d.ts \
./packages/bar/index.d.ts \
./packages/calendar/index.d.ts \
./packages/chord/index.d.ts \
./packages/colors/index.d.ts \
./packages/core/index.d.ts \
./packages/geo/index.d.ts \
./packages/heatmap/index.d.ts \
./packages/legends/index.d.ts \
./packages/line/index.d.ts \
./packages/network/index.d.ts \
./packages/pie/index.d.ts \
./packages/radar/index.d.ts \
./packages/sankey/index.d.ts \
./packages/scales/index.d.ts \
./packages/scatterplot/index.d.ts \
./packages/stream/index.d.ts \
./packages/swarmplot/index.d.ts \
./packages/waffle/index.d.ts \
./packages/voronoi/index.d.ts
package-test-cover-%: ##@1 packages run tests for a package with code coverage
@yarn jest -c ./packages/jest.config.js --rootDir . --coverage ./packages/${*}/tests
package-test-%: ##@1 packages run tests for a package
@yarn jest -c ./packages/jest.config.js --rootDir . ./packages/${*}/tests
package-update-test-%: ##@1 packages run tests for a package and update its snapshots
@yarn jest -c ./packages/jest.config.js --rootDir . ./packages/${*}/tests -u
packages-test: ##@1 packages run tests for all packages
@echo "${YELLOW}Running test suites for all packages${RESET}"
@yarn jest -c ./packages/jest.config.js --rootDir . ./packages/*/tests
packages-test-cover: ##@1 packages run tests for all packages with code coverage
@echo "${YELLOW}Running test suites for all packages${RESET}"
@yarn jest -c ./packages/jest.config.js --rootDir . --coverage ./packages/*/tests
packages-build: ##@1 packages build all packages
@echo "${YELLOW}Building all packages${RESET}"
@find ./packages -type d -maxdepth 1 ! -path ./packages ! -path ./packages/babel-preset \
| sed 's|^./packages/||' \
| xargs -I '{}' sh -c '$(MAKE) package-build-{}'
package-build-%: ##@1 packages build a package
@echo "${YELLOW}Building package ${WHITE}@nivo/${*}${RESET}"
@rm -rf ./packages/${*}/dist
@export PACKAGE=${*}; ./node_modules/.bin/rollup -c conf/rollup.config.js
packages-screenshots: ##@1 packages generate screenshots for packages readme (website dev server must be running)
@node scripts/capture.js
packages-publish: ##@1 packages publish all packages
@$(MAKE) packages-build
@echo "${YELLOW}Publishing packages${RESET}"
@./node_modules/.bin/lerna publish ---exact
packages-publish-next: ##@1 packages publish all packages for @next npm tag
@$(MAKE) packages-build
@echo "${YELLOW}Publishing packages${RESET}"
@./node_modules/.bin/lerna publish ---exact --npm-tag=next
package-watch-%: ##@1 packages build package (es flavor) on change, eg. `package-build-watch-bar`
@echo "${YELLOW}Running build watcher for package ${WHITE}@nivo/${*}${RESET}"
@rm -rf ./packages/${*}/cjs
@rm -rf ./packages/${*}/umd
@export PACKAGE=${*}; ./node_modules/.bin/rollup -c conf/rollup.config.js -w
package-dev-%: ##@1 packages setup package for development, link to website, run watcher
@echo "${YELLOW}Preparing package ${WHITE}${*}${YELLOW} for development${RESET}"
@cd packages/${*} && yarn link
@cd examples/typescript && yarn link @nivo/${*}
@$(MAKE) package-watch-${*}
########################################################################################################################
#
# WEBSITE
#
########################################################################################################################
website-deps-up: ##@2 website interactive upgrade of website's dependencies
@yarn upgrade-interactive --latest
website: ##@2 website start website in dev mode
@echo "${YELLOW}Starting website dev server${RESET}"
@cd website && yarn start
website-build: ##@2 website build website
@echo "${YELLOW}Building website${RESET}"
@cd website && yarn build
website-serve: ##@2 website build & serve website
@$(MAKE) website-build
@cd website && yarn serve
website-deploy: ##@2 website build & deploy website
@$(MAKE) website-build
@echo "${YELLOW}Deploying website${RESET}"
@./node_modules/.bin/gh-pages -d website/public -r [email protected]:plouc/nivo.git -b gh-pages
website-audit: ##@2 website audit website build
@cd website && yarn analyze
website-sprites: ##@2 website build sprite sheet
@glue --img website/src/assets --css website/src/styles website/src/assets/icons
########################################################################################################################
#
# STORYBOOK
#
########################################################################################################################
storybook: ##@3 storybook start storybook in dev mode on port 6006
@yarn start-storybook -p 6006
storybook-build: ##@3 storybook build storybook
@echo "${YELLOW}Building storybook${RESET}"
@yarn build-storybook
storybook-deploy: ##@3 storybook build and deploy storybook
@$(MAKE) storybook-build
@echo "${YELLOW}Deploying storybook${RESET}"
@./node_modules/.bin/gh-pages -d storybook-static -r [email protected]:plouc/nivo.git -b gh-pages -e storybook
########################################################################################################################
#
# EXAMPLES
#
########################################################################################################################
examples-install: ##@4 examples install all examples dependencies
@$(MAKE) example-install-retro
@$(MAKE) example-install-typescript
example-install-%: ##@4 examples install example dependencies, eg. example-install-retro
@echo "${YELLOW}Installing ${WHITE}${*}${YELLOW} example dependencies${RESET}"
@cd examples/${*} && yarn install
example-deps-up-%: ##@4 examples interactive upgrade of example's dependencies
@cd examples/${*} && yarn upgrade-interactive --latest
example-start-%: ##@4 examples start example in dev mode, eg. example-start-retro
@echo "${YELLOW}Starting ${WHITE}${*}${YELLOW} example dev server${RESET}"
@cd examples/${*} && yarn start
examples-build: ##@4 examples build all examples
@$(MAKE) example-build-retro
@$(MAKE) example-build-typescript
example-build-%: ##@4 examples build an example, eg. example-build-retro
@echo "${YELLOW}Building ${WHITE}${*}${YELLOW} example${RESET}"
@cd examples/${*} && yarn build
########################################################################################################################
#
# API
#
########################################################################################################################
api-dev: ##@5 API run API in dev mode (watcher)
@echo "${YELLOW}Starting API in dev mode${RESET}"
@cd api && yarn dev
api: ##@5 API run API in regular mode (no watcher)
@echo "${YELLOW}Starting API${RESET}"
@cd api && yarn start
api-deploy: ##@5 Deploy API on heroku
git subtree push --prefix api heroku master