Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/ws-daemon-api/generate.sh
2492 views
1
#!/bin/bash
2
3
if [ -n "$DEBUG" ]; then
4
set -x
5
fi
6
7
set -o errexit
8
set -o nounset
9
set -o pipefail
10
11
ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)/../../
12
COMPONENTS_DIR="$ROOT_DIR"/components
13
14
# include protoc bash functions
15
# shellcheck disable=SC1090,SC1091
16
source "$ROOT_DIR"/scripts/protoc-generator.sh
17
18
install_dependencies
19
go_protoc "$COMPONENTS_DIR"
20
typescript_protoc "$COMPONENTS_DIR"
21
22
# cd go
23
pushd go
24
25
mockgen \
26
-package mock \
27
github.com/gitpod-io/gitpod/ws-daemon/api WorkspaceContentServiceClient,WorkspaceContentServiceServer,InWorkspaceServiceClient > mock/mock.go
28
29
# NOTE: must manually embed the Unimplemented struct as mockgen cannot do so
30
sed -i '/\trecorder \*MockWorkspaceContentServiceServerMockRecorde/a \\tapi.UnimplementedWorkspaceContentServiceServer' mock/mock.go
31
32
echo "updating JSON tags"
33
go install github.com/fatih/gomodifytags
34
# remove depreated json tags
35
# shellcheck disable=SC2002
36
gomodifytags -line 0,"$(cat daemon.pb.go|wc -l)" -file daemon.pb.go -remove-tags json -w >/dev/null
37
# add new JSON tags
38
# shellcheck disable=SC2002
39
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
40
# remove JSON tags for XXX_
41
for line in $(grep -n xxx daemon.pb.go | cut -f1 -d: | paste -sd " " -); do
42
gomodifytags -line "$line" -file daemon.pb.go -remove-tags json -w >/dev/null
43
gomodifytags -line "$line" -file daemon.pb.go -add-tags json:"-" -w >/dev/null
44
done
45
46
# return to previous directory
47
popd
48
49
pushd typescript/src
50
node "$COMPONENTS_DIR"/content-service-api/typescript/patch-grpc-js.ts
51
popd
52
53
update_license
54
55