This repository was archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
143 lines (127 loc) · 4.34 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
BINDIR=node_modules/.bin
MICROBUNDLE=$(BINDIR)/microbundle
TSLINT=$(BINDIR)/tslint
ARG=$(filter-out $@,$(MAKECMDGOALS))
PACKAGE=packages/$(ARG)
PACKAGE_VERSION=$(shell node -p -e 'require("./$(PACKAGE)/package.json").version')
help :
@echo "Available commands for hyperfun.js monorepo:"
@echo ""
@echo " make dist <package>\t\tbuild dist for <package> only (e.g. 'make dist run')"
@echo " make dist-all\t\t\tbuild everything"
@echo " make example <example>t\texecute example"
@echo " make format-all\t\tformat all packages"
@echo " make format <package>\t\tformat just <package> (e.g. 'make format dom')"
@echo " make lint-all\t\t\tlint all packages"
@echo " make lint <package>\t\tlint just <package> (e.g. 'make lint dom')"
@echo " make release-minor <package>\trelease a new minor version of <package>"
@echo " make release-major <package>\trelease a new major version of <package>"
@echo " make test\t\t\ttest everything"
@echo " make test <package>\t\ttest just <package> (e.g. 'make test run')"
@echo " make test:watch <package>\ttest just <package> (e.g. 'make test:watch run')"
@echo ""
dist :
@if [ "$(ARG)" = "" ]; then \
echo "Error: please call 'make dist' with an argument, like 'make dist run'" ;\
else \
rm -rf $(PACKAGE)/dist/ ;\
cd $(PACKAGE) || exit $? ;\
../../$(MICROBUNDLE) build -i src/index.ts --name $(PACKAGE) || exit $? ; \
cd ../../ || exit $? ; \
([ $$? -eq 0 ] && echo "✓ Builded $(ARG) distribution files" || exit 1) ;\
fi
dist-all :
@if [ "$(ARG)" = "" ]; then \
while read d ; do \
echo "Compiling $$d" ; \
make dist $$d || exit $? ;\
done < .scripts/PACKAGES ; \
([ $$? -eq 0 ] && echo "✓ Builded $$d distribution files" || exit 1) ;\
fi
example :
@if [ "$(ARG)" = "" ]; then \
echo "Error: please call 'make example' with an argument, like 'make example counter'" ;\
else \
npm run example:$(ARG) ;\
fi
format :
@if [ "$(ARG)" = "" ]; then \
echo "Error: please call 'make format' with an argument, like 'make format run'" ;\
else \
$(BINDIR)/prettier --write "packages/$(ARG)/{src,test}/**/*.ts" ;\
fi
format-all :
@if [ "$(ARG)" = "" ]; then \
while read d ; do \
echo "Format $$d" ; \
make format $$d || exit $? ;\
done < .scripts/PACKAGES ; \
([ $$? -eq 0 ] && echo "✓ Formatted files" || exit 1) ;\
fi
lint :
@if [ "$(ARG)" = "" ]; then \
make lint-all ;\
else \
cd $(PACKAGE) && ../../$(TSLINT) --fix --config ../../tslint.json --project tsconfig.json &&\
echo "✓ TSLint $(PACKAGE) passed" ;\
fi
lint-all :
.scripts/lint-all.sh
release :
@if [ "$(ARG)" = "" ]; then \
echo "Error: No package defined" ;\
else \
git add -A || exit $? ;\
git commit -m 'release($(ARG)): $(PACKAGE_VERSION)' || exit $? ;\
git push origin master || exit $? ;\
git tag $(ARG)-$(PACKAGE_VERSION) || exit $? ;\
git push --tags || exit $? ;\
cd $(PACKAGE) || exit $? ;\
npm publish || exit $? ;\
cd ../../ || exit $? ;\
([ $$? -eq 0 ] && echo "✓ Released $(ARG) $(PACKAGE_VERSION)" || exit 1) ;\
fi
release-minor :
@if [ "$(ARG)" = "" ]; then \
echo "Error: please call 'make release-minor' with an argument, like 'make release-minor run'" ;\
else \
make test $(ARG) || exit $? ;\
make dist $(ARG) || exit $? ;\
cd $(PACKAGE) || exit $? ;\
npm version minor || exit $? ;\
cd ../../ || exit $? ;\
make release $(ARG) || exit $? ;\
([ $$? -eq 0 ] && echo "✓ Released new minor $(ARG)-$(PACKAGE_VERSION)" || exit 1) ;\
fi
release-major :
@if [ "$(ARG)" = "" ]; then \
echo "Error: please call 'make release-major' with an argument, like 'make release-major run'" ;\
else \
make test $(ARG) || exit $? ;\
make dist $(ARG) || exit $? ;\
cd $(PACKAGE) || exit $? ;\
npm version major || exit $? ;\
cd ../../ || exit $? ;\
make release $(ARG) || exit $? ;\
([ $$? -eq 0 ] && echo "✓ Released new major $(ARG)-$(PACKAGE_VERSION)" || exit 1) ;\
fi
test :
@if [ "$(ARG)" = "" ]; then \
make test-all ;\
else \
cd $(PACKAGE) || exit $? ;\
export NODE_ENV=test && npm run test || exit $? ;\
cd ../../ || exit $? ;\
([ $$? -eq 0 ] && echo "✓ Tested $(PACKAGE)" || exit 1) ;\
fi
test-watch :
@if [ "$(ARG)" = "" ]; then \
echo "Error: No package defined" ;\
else \
cd $(PACKAGE) && npm run test:watch && ([ $$? -eq 0 ] && echo "✓ Tested $(PACKAGE)") || exit 1;\
fi
test-all :
.scripts/test-all.sh
# catch anything and do nothing
%:
@: