-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.sh
57 lines (49 loc) · 1.44 KB
/
build.sh
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
#!/bin/bash
tsServices=("profile" "category" "catalog" "cart" "promo" "delivery" "order")
goServices=("authentication" "search")
authInternalServices=("account" "confirmation" "token")
gatewayServices=("authentication" "category" "catalog" "cart" "order" "delivery" "profile" "promo" "search")
function cleanup() {
folderPath="$1/generated"
echo "$folderPath"
if [ -d "$folderPath" ]; then
rm -r "$folderPath"
fi
mkdir -p "$folderPath"
}
function generateTS() {
if [ -d "$1" ]; then
cd "$1" || return
npm run protoc
cd ..
fi
}
function generateGo() {
path="$1/generated"
protoc --go_out="$path" --go-grpc_out="$path" --proto_path=proto "$2.proto"
}
# generate code for TS services
for service in "${tsServices[@]}"; do
generateTS "$service" "$service"
echo "generated proto for TS service: $service"
done
# generate code for Go services
for service in "${goServices[@]}"; do
cleanup "$service"
if [ "$service" == "authentication" ]; then
# generate code for authentication
for innerService in "${authInternalServices[@]}"; do
generateGo "$service" "$innerService"
echo "generated proto for authentication: $innerService"
done
fi
generateGo "$service" "$service"
echo "generated proto for Go service: $service"
done
# generate code for gateway
cleanup gateway
for service in "${gatewayServices[@]}"; do
generateGo gateway "$service"
echo "generated proto for gateway: $service"
done
sleep .5