From 02cf1fbed9b3ada8494a26e152aae0d29ac75d65 Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Sat, 28 Apr 2018 14:50:31 -0400 Subject: [PATCH] Add web api build script --- src/web/api/buildapi.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/web/api/buildapi.sh diff --git a/src/web/api/buildapi.sh b/src/web/api/buildapi.sh new file mode 100644 index 000000000..f916c7937 --- /dev/null +++ b/src/web/api/buildapi.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# "protogen": "pbjs -t json-module -w commonjs -o %build%/proto.js ../../lib/api/*.proto ../../lib/api/services/*.proto ../../lib/domain_model/*.proto ../../lib/sparkproto/*.proto ../../lib/md/protos/*.proto", +OUT=../../../build/web/ +mkdir -p $OUT/src +PROTO_LIST="../../lib/api/*.proto ../../lib/api/services/*.proto ../../lib/domain_model/*.proto ../../lib/sparkproto/*.proto ../../lib/md/protos/*.proto" + +# Run pbjs to produce protobuf module +echo pbjs +npx pbjs -t json-module -w commonjs -o $OUT/api/proto.js $PROTO_LIST + +# Run bts proto=>typescript compiler +echo protoc +../../../externals/linux/bin/protoc \ + --plugin=protoc-gen-service=../../lib/api/service_compiler/plugin.py \ + --service_out=lang=js,strip_out_path=1:$OUT/src \ + -I ../../ \ + $PROTO_LIST + +# run typescript compiler to convert typescript to javascript +echo tsc +npx tsc -p tsconfig.release.json + +# run ts2fable to make f# stubs from typescript definitions +for FILE in $OUT/api/*.d.ts; do + filename=$(basename -- $FILE) + filename="${filename%.d.ts}" + npx ts2fable $OUT/api/$filename.d.ts $OUT/api/$filename.fs +done \ No newline at end of file