forked from irinazheltisheva/powergate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen-js-protos.sh
More file actions
executable file
·36 lines (26 loc) · 1.04 KB
/
gen-js-protos.sh
File metadata and controls
executable file
·36 lines (26 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
LIB_VERSION=$1
PROTOS_PATH=$2
OUT_PATH=$3
LIB_PREFIX="@textile"
LIB_POSTFIX="grpc-powergate-client"
LIB_NAME="$LIB_PREFIX/$LIB_POSTFIX"
LIB_SRC_DIR="dist"
PROTOC_GEN_TS_PATH="$OUT_PATH/node_modules/.bin/protoc-gen-ts"
PTOTOC_GEN_OUT_DIR="$OUT_PATH/$LIB_SRC_DIR"
if [ -d "$OUT_PATH" ]
then
rm -rf $OUT_PATH
fi
mkdir -p $PTOTOC_GEN_OUT_DIR
printf '{"name":"%s", "version":"%s", "files":["%s"]}' $LIB_NAME $LIB_VERSION $LIB_SRC_DIR > $OUT_PATH/package.json
(cd $OUT_PATH && npm install --save-dev ts-protoc-gen)
(cd $OUT_PATH && npm install google-protobuf@^3.12.2 @improbable-eng/grpc-web @types/google-protobuf@^3.7.2)
ABS_OUT_PATH="$( cd $OUT_PATH >/dev/null 2>&1 ; pwd -P )"
ABS_PROTOS_PATH="$( cd $PROTOS_PATH >/dev/null 2>&1 ; pwd -P )"
PROTOS=$(find $ABS_PROTOS_PATH -path $ABS_OUT_PATH -prune -o -iname "*.proto" -print)
protoc \
--plugin="protoc-gen-ts=${PROTOC_GEN_TS_PATH}" \
--js_out="import_style=commonjs,binary:${PTOTOC_GEN_OUT_DIR}" \
--ts_out="service=grpc-web:${PTOTOC_GEN_OUT_DIR}" \
-I $ABS_PROTOS_PATH \
${PROTOS}