Files
spark/src/web/api/build.sh
T

68 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
OUT=../../../build/web/
# clean
rm -rf $OUT/api
mkdir -p $OUT/api
mkdir -p $OUT/api/fable
if [ "$#" -gt 0 ]
then
PROTO_LIST="$@"
FULL=1
else
PROTO_LIST="../../lib/api/*.proto ../../lib/api/services/*.proto ../../lib/domain_model/*.proto ../../lib/sparkproto/*.proto ../../lib/md/protos/*.proto ../../../externals/linux/include/google/protobuf/descriptor.proto ../../../externals/linux/include/google/protobuf/timestamp.proto"
FULL=0
fi
export PYTHONPATH=../../../externals/linux/python/
PROTOC=../../../externals/linux/bin/protoc
ORANGE='\033[0;33m'
NOCOLOR='\033[0m'
npm install
# Run pbjs to produce protobuf module
echo -e \* ${ORANGE} pbjs ${NOCOLOR}
npx --no-install pbjs -t json-module -w commonjs -o $OUT/api/proto.js $PROTO_LIST
echo -e \* ${ORANGE} protoc - f\# ${NOCOLOR}
$PROTOC --plugin=protoc-gen-service=../../lib/api/service_compiler/plugin.py \
--service_out=lang=fs,strip_out_path=1:$OUT/api/fable \
-I ../../ \
-I ../../../externals/linux/include/ \
$PROTO_LIST
# exit 1
# run typescript compiler to convert typescript to javascript
echo -e \* ${ORANGE} tsc ${NOCOLOR}
npx --no-install tsc -p tsconfig.release.json
# cleanup
# run ts2fable to make f# stubs from typescript definitions
ts2fable() {
for FILE in $1/*.d.ts; do
filename=$(basename -- $FILE)
filename="${filename%.d.ts}"
npx --no-install ts2fable $1/$filename.d.ts $1/$filename.fs &
done
wait
}
echo -e \* ${ORANGE} ts2fable ${NOCOLOR}
ts2fable $OUT/api
# ts2fable $OUT/api/gen
if [ "$FULL" == "1" ]; then
echo \* fable
cd ../ui/
npm install
cd src
cp -r ../public/* ../$OUT/ui/
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 dotnet restore
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 dotnet fable webpack -- -p
fi