-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathgenerate.sh
executable file
·53 lines (41 loc) · 1.61 KB
/
generate.sh
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
if [ -n "$DEBUG" ]; then
set -x
fi
set -o errexit
set -o nounset
set -o pipefail
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)/../../
COMPONENTS_DIR="$ROOT_DIR"/components
# include protoc bash functions
# shellcheck disable=SC1090,SC1091
source "$ROOT_DIR"/scripts/protoc-generator.sh
install_dependencies
go_protoc "$COMPONENTS_DIR"
typescript_protoc "$COMPONENTS_DIR"
# cd go
pushd go
mockgen \
-package mock \
github.com/gitpod-io/gitpod/ws-daemon/api WorkspaceContentServiceClient,WorkspaceContentServiceServer,InWorkspaceServiceClient > mock/mock.go
# NOTE: must manually embed the Unimplemented struct as mockgen cannot do so
sed -i '/\trecorder \*MockWorkspaceContentServiceServerMockRecorde/a \\tapi.UnimplementedWorkspaceContentServiceServer' mock/mock.go
echo "updating JSON tags"
go install github.com/fatih/gomodifytags
# remove depreated json tags
# shellcheck disable=SC2002
gomodifytags -line 0,"$(cat daemon.pb.go|wc -l)" -file daemon.pb.go -remove-tags json -w >/dev/null
# add new JSON tags
# shellcheck disable=SC2002
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
# return to previous directory
popd
pushd typescript/src
node "$COMPONENTS_DIR"/content-service-api/typescript/patch-grpc-js.ts
popd
update_license