2020-05-13 12:41:43 +00:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
set -eux
|
|
|
|
|
2020-07-07 13:21:18 +00:00
|
|
|
GEN_PATH=src/app/proto/generated
|
2020-05-13 12:41:43 +00:00
|
|
|
|
|
|
|
echo "Remove old files"
|
|
|
|
rm -rf $GEN_PATH
|
|
|
|
|
|
|
|
echo "Create folders"
|
|
|
|
mkdir -p $GEN_PATH
|
|
|
|
|
2020-07-08 08:00:15 +00:00
|
|
|
targetcurl () {
|
|
|
|
mkdir -p $1 && cd $1 && { curl -O $2; cd -; }
|
|
|
|
}
|
|
|
|
|
2020-07-07 13:21:18 +00:00
|
|
|
echo "Download additional protofiles"
|
2020-07-08 08:00:15 +00:00
|
|
|
targetcurl tmp/validate https://raw.githubusercontent.com/envoyproxy/protoc-gen-validate/v0.4.0/validate/validate.proto
|
|
|
|
targetcurl tmp/protoc-gen-swagger/options https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/v1.14.6/protoc-gen-swagger/options/annotations.proto
|
|
|
|
targetcurl tmp/protoc-gen-swagger/options https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/v1.14.6/protoc-gen-swagger/options/openapiv2.proto
|
2020-07-07 13:21:18 +00:00
|
|
|
|
2020-05-13 12:41:43 +00:00
|
|
|
echo "Generate grpc"
|
|
|
|
|
|
|
|
protoc \
|
|
|
|
-I=/usr/local/include \
|
2020-07-08 11:56:37 +00:00
|
|
|
-I=../pkg/grpc/message \
|
|
|
|
-I=../pkg/grpc/management/proto \
|
|
|
|
-I=../pkg/grpc/auth/proto \
|
|
|
|
-I=../pkg/grpc/admin/proto \
|
2020-07-07 13:21:18 +00:00
|
|
|
-I=../internal/protoc/protoc-gen-authoption \
|
|
|
|
-I=node_modules/google-proto-files \
|
|
|
|
-I=tmp \
|
2020-05-13 12:41:43 +00:00
|
|
|
--js_out=import_style=commonjs,binary:$GEN_PATH \
|
|
|
|
--grpc-web_out=import_style=commonjs+dts,mode=grpcweb:$GEN_PATH \
|
2020-07-08 11:56:37 +00:00
|
|
|
../pkg/grpc/message/proto/*.proto \
|
|
|
|
../pkg/grpc/management/proto/*.proto \
|
|
|
|
../pkg/grpc/admin/proto/*.proto \
|
|
|
|
../pkg/grpc/auth/proto/*.proto
|
2020-05-13 12:41:43 +00:00
|
|
|
|
|
|
|
echo "Generate annotations js file (compatibility)"
|
|
|
|
|
|
|
|
mkdir -p $GEN_PATH/google/api/
|
|
|
|
touch $GEN_PATH/google/api/annotations_pb.js
|
|
|
|
echo "export {}" > $GEN_PATH/google/api/annotations_pb.d.ts
|
|
|
|
|
|
|
|
mkdir -p $GEN_PATH/validate
|
|
|
|
touch $GEN_PATH/validate/validate_pb.js
|
|
|
|
echo "export {}" > $GEN_PATH/validate/validate_pb.d.ts
|
|
|
|
|
|
|
|
mkdir -p $GEN_PATH/protoc-gen-swagger/options
|
|
|
|
touch $GEN_PATH/protoc-gen-swagger/options/annotations_pb.js
|
|
|
|
echo "export {}" > $GEN_PATH/protoc-gen-swagger/options/annotations_pb.d.ts
|
|
|
|
|
|
|
|
mkdir -p $GEN_PATH/authoption
|
|
|
|
touch $GEN_PATH/authoption/options_pb.js
|
2020-07-07 13:21:18 +00:00
|
|
|
echo "export {}" > $GEN_PATH/authoption/options_pb.d.ts
|