diff --git a/web/package.json b/web/package.json --- a/web/package.json +++ b/web/package.json @@ -10,7 +10,8 @@ "prod": "yarn workspace keyserver babel-build-comm-config && yarn webpack --config webpack.config.cjs --env prod --progress", "test": "jest", "build-db-wasm": "./scripts/run_emscripten.sh", - "clean-db-wasm": "rm -rf database/_generated/ && rm -rf database/sqlite/" + "clean-db-wasm": "rm -rf database/_generated/ && rm -rf database/sqlite/", + "codegen-identity-grpc": "./scripts/codegen-identity-grpc.sh" }, "devDependencies": { "@babel/core": "^7.13.14", diff --git a/web/scripts/codegen-identity-grpc.sh b/web/scripts/codegen-identity-grpc.sh new file mode 100755 --- /dev/null +++ b/web/scripts/codegen-identity-grpc.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -Eeuo pipefail + +protoc -I=../shared/protos/ identity_client.proto --js_out=import_style=commonjs:protobufs --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:protobufs + +mv protobufs/identity_client_pb.js protobufs/identity-structs.cjs +mv protobufs/identity_client_grpc_web_pb.js protobufs/identity-client.cjs +mv protobufs/identity_client_pb.d.ts protobufs/identity-structs.cjs.flow +mv protobufs/identity_client_grpc_web_pb.d.ts protobufs/identity-client.cjs.flow + +# This echo statement splits the string to ensure that Phabricator shows this file in reviews +echo "Make sure to edit the files to correct import paths, reintroduce @""generated annotation, and convert TS to Flow!"