clipper/protogen.sh

26 lines
721 B
Bash
Raw Normal View History

2021-10-22 19:30:09 +00:00
#!/usr/bin/env bash
#
# Dependencies:
#
# protobuf (pacman -S protobuf)
# protoc-gen-go (go install google.golang.org/protobuf/cmd/protoc-gen-go@latest)
# protoc-gen-go-grpc (go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest)
# protoc-gen-ts (uses local copy from node_modules)
#
set -ex
TARGET_BACKEND="./backend/generated"
TARGET_FRONTEND="./frontend/src/generated"
mkdir -p $TARGET_BACKEND
mkdir -p $TARGET_FRONTEND
protoc \
-I./proto/ \
--plugin="protoc-gen-ts=./frontend/node_modules/.bin/protoc-gen-ts" \
--go_out="$TARGET_BACKEND" \
--go-grpc_out="$TARGET_BACKEND" \
--js_out="import_style=commonjs,binary:$TARGET_FRONTEND" \
--ts_out="service=grpc-web:$TARGET_FRONTEND" \
./proto/*