Christian Weichel 8d1664f81f [ws-daemon] Search and replace ws-sync
This should have happened in #2003

/werft https=true
2020-10-19 10:26:18 +02:00

31 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
GO111MODULE=on go get github.com/golang/protobuf/protoc-gen-go@v1.3.5
protoc -I. -I.. --go_out=plugins=grpc:. *.proto
mv github.com/gitpod-io/gitpod/ws-daemon/api/* go && rm -rf github.com
GO111MODULE=on go get github.com/golang/mock/mockgen@latest
cd go
mockgen -package mock -source=daemon.pb.go > mock/mock_wsdaemon.go
echo "updating JSON tags"
go get github.com/fatih/gomodifytags
# remove depreated json tags
gomodifytags -line 0,$(cat daemon.pb.go|wc -l) -file daemon.pb.go -remove-tags json -w >/dev/null
# add new JSON tags
gomodifytags -line 0,$(cat daemon.pb.go|wc -l) -file daemon.pb.go -add-tags json -transform camelcase -add-options json=omitempty -w >/dev/null
# remove JSON tags for XXX_
for line in $(grep -n xxx daemon.pb.go | cut -f1 -d: | paste -sd " " -); do
gomodifytags -line $line -file daemon.pb.go -remove-tags json -w >/dev/null
gomodifytags -line $line -file daemon.pb.go -add-tags json:"-" -w >/dev/null
done
cd ..
export PATH=$PWD/../../node_modules/.bin:$PATH
protoc --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` --js_out=import_style=commonjs,binary:typescript/src --grpc_out=typescript/src -I.. -I. *.proto
protoc --plugin=protoc-gen-ts=`which protoc-gen-ts` --ts_out=typescript/src -I /usr/lib/protoc/include -I.. -I. *.proto
cd typescript/src
node ../../../content-service-api/typescript/patch-grpc-js.ts
cd -