From 810ea54ea9e8dff71bebcda4ed5c6f0d37cb0392 Mon Sep 17 00:00:00 2001 From: Ashoat Tevosyan Date: Fri, 13 Oct 2023 15:48:21 -0400 Subject: [PATCH] [web] Introduce codegen-identity-grpc script Summary: In order to update our `grpc-web` codegen, we need to run `protoc` with some specific parameters, and then rename the files. I figured it would be good to put this into a Yarn script so we don't have to remember it / pull it from some diff's test plan every time. Note that after running this script, some more work is necessary. There are a couple small modifications necessary to the `.cjs` files (update the imported filename and add `@generated` annotations), but the bulk of the work is in converting the TypeScript libraries to Flow. Depends on D9490 Test Plan: Run the script Reviewers: varun, atul Reviewed By: varun Subscribers: tomek, wyilio Differential Revision: https://phab.comm.dev/D9491 --- web/package.json | 3 ++- web/scripts/codegen-identity-grpc.sh | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 web/scripts/codegen-identity-grpc.sh diff --git a/web/package.json b/web/package.json index 4ecaa84451..6ff990dc41 100644 --- 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 index 0000000000..760e7a6f0c --- /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!"