-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·140 lines (114 loc) · 4.73 KB
/
Makefile
File metadata and controls
executable file
·140 lines (114 loc) · 4.73 KB
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
MAKEFLAGS += --no-print-directory
SOURCES = packages
DIR = $(shell pwd)
########################################################################################################################
#
# 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: ##@1 Global init project before start after each pull
${MAKE} clean
${MAKE} install
${MAKE} build
clean: ##@1 Global uninstall node modules, remove transpiled code & lock files
@rm -rf ./node_modules
@rm -rf ./package-lock.json
@find ./packages -type d -maxdepth 1 ! -path ./packages \
| sed 's|^./packages/||' \
| xargs -I '{}' sh -c '$(MAKE) clean-{}'
clean-%:
@rm -rf ./packages/${*}/dist
@rm -rf ./packages/${*}/node_modules
@rm -rf ./packages/${*}/package-lock.json
@rm -rf ./packages/${*}/yarn.lock
install: ##@1 Global yarn install all packages
@echo "${YELLOW}Running yarn install${RESET}"
@yarn install
@find ./packages -type d -maxdepth 1 ! -path ./packages \
| sed 's|^./packages/||' \
| xargs -I '{}' sh -c '$(MAKE) add-dist-folders-{}'
@echo "${YELLOW}Running lerna bootstrap${RESET}"
@./node_modules/.bin/lerna bootstrap
add-dist-folders-%:
@mkdir -p ./packages/${*}/dist
########################################################################################################################
#
# BUILD Operations
#
########################################################################################################################
build: ##@4 Build build all packages
${MAKE} build-react
build-%: ##@4 Build build a specific package
@echo "${YELLOW}Building package ${WHITE}${*}${RESET}"
@export NODE_ENV=production; cd ./packages/${*} && yarn build
bw: ##@4 Build parallels build:watch all
@export NODE_ENV=development
@./node_modules/.bin/lerna run build:watch --parallel
bw-%: ##@2 Build build:watch specific package
@export PACKAGE=${*}; cd ./packages/${*} && yarn build:watch
########################################################################################################################
#
# Publish Operations
#
########################################################################################################################
move-package-json-to-dist:
@find ./packages -type d -maxdepth 1 ! -path ./packages \
| sed 's|^./packages/||' \
| xargs -I '{}' sh -c 'node scripts/move-package-json-to-dist.js ./packages/{}'
update-entry:
@find ./packages -type d -maxdepth 1 ! -path ./packages \
| sed 's|^./packages/||' \
| xargs -I '{}' sh -c 'node scripts/update-entry.js ./packages/{}'
prerelease-version-upgrade-%:
@find ./packages -type d -maxdepth 1 ! -path ./packages \
| sed 's|^./packages/||' \
| xargs -I '{}' sh -c 'node scripts/update-prerelease-version.js "./packages/{}" "${*}"'
########################################################################################################################
#
# Helpers Operations
#
########################################################################################################################
pretty:
@yarn prettier-hook
demo:
@cd ./packages/demo-saas && yarn start
publish-packages-next:
@cp ./.npmrc "./packages/react/dist/.npmrc"
@cp ./.npmignore "./packages/react/dist/.npmignore"
@cd "./packages/react/dist" && npm publish --tag next
publish-packages-alpha:
@cp ./.npmrc "./packages/react/dist/.npmrc"
@cp ./.npmignore "./packages/react/dist/.npmignore"
@cd "./packages/react/dist" && npm publish --tag alpha
publish-packages-latest:
@cp ./.npmrc "./packages/react/dist/.npmrc"
@cp ./.npmignore "./packages/react/dist/.npmignore"
@cd "./packages/react/dist" && npm publish --tag latest