Skip to content

Commit

Permalink
[web] Introduce codegen-identity-grpc script
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ashoat committed Oct 17, 2023
1 parent 6133bb3 commit 810ea54
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions web/scripts/codegen-identity-grpc.sh
Original file line number Diff line number Diff line change
@@ -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!"

0 comments on commit 810ea54

Please sign in to comment.