clipper/protogen.sh

26 lines
762 B
Bash
Raw Permalink 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)
2021-11-02 16:20:47 +00:00
# ts-proto (uses local copy from node_modules)
2021-10-22 19:30:09 +00:00
#
set -ex
TARGET_BACKEND="./backend/generated"
TARGET_FRONTEND="./frontend/src/generated"
mkdir -p $TARGET_BACKEND
mkdir -p $TARGET_FRONTEND
protoc \
-I./proto/ \
2021-11-02 16:20:47 +00:00
--plugin="./frontend/node_modules/.bin/protoc-gen-ts_proto" \
2021-10-22 19:30:09 +00:00
--go_out="$TARGET_BACKEND" \
--go-grpc_out="$TARGET_BACKEND" \
--js_out="import_style=commonjs,binary:$TARGET_FRONTEND" \
2021-11-02 16:20:47 +00:00
--ts_proto_out="outputClientImpl=grpc-web,useOptionals=true,esModuleInterop=true:$TARGET_FRONTEND" \
2021-10-22 19:30:09 +00:00
./proto/*