-
Notifications
You must be signed in to change notification settings - Fork 0
/
copyproto.sh
59 lines (55 loc) · 2.31 KB
/
copyproto.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
54
55
56
57
58
59
protobuf=$(go list -m -f {{.Dir}} github.com/hopeio/protobuf)
protobuf=${protobuf//\\/\/}
echo $protobuf
# 复制proto文件
echo "copy proto dependencies ..."
## 依赖地址
gatewayDir=$(go list -m -f {{.Dir}} github.com/grpc-ecosystem/grpc-gateway/v2)
gatewayDir=${gatewayDir//\\/\/}
#validatorsDir=$(go list -m -f {{.Dir}} github.com/envoyproxy/protoc-gen-validate)
#validatorsDir=${validatorsDir//\\/\/}
protopatchDir=$(go list -m -f {{.Dir}} github.com/alta/protopatch)
protopatchDir=${protopatchDir//\\/\/}
gqlDir=$(go list -m -f {{.Dir}} github.com/danielvladco/go-proto-gql)
gqlDir=${gqlDir//\\/\/}
protoDir=$protobuf/_proto
tmpMod=/tmp/proto
mkdir $tmpMod
## googleapis
cd $tmpMod
go mod init proto
go mod tidy
go get github.com/googleapis/googleapis
googleapisDir=$(go list -m -f {{.Dir}} github.com/googleapis/googleapis)
googleapisDir=${googleapisDir//\\/\/}
echo $googleapisDir
go get github.com/protocolbuffers/protobuf
protobufDir=$(go list -m -f {{.Dir}} github.com/protocolbuffers/protobuf)
protobufDir=${protobufDir//\\/\/}
echo $protobufDir
go get github.com/bufbuild/protovalidate@main
validatorsDir=$(go list -m -f {{.Dir}} github.com/bufbuild/protovalidate)
validatorsDir=${validatorsDir//\\/\/}
echo $validatorsDir
## copy
mkdir -p $protoDir/protoc-gen-openapiv2/options
cp $gatewayDir/protoc-gen-openapiv2/options/*.proto $protoDir/protoc-gen-openapiv2/options
mkdir -p $protoDir/google/api
cp $googleapisDir/google/api/*.proto $protoDir/google/api
mkdir -p $protoDir/buf/validate/priv
cp $validatorsDir/proto/protovalidate/buf/validate/*.proto $protoDir/buf/validate
# chmod -R 777 $validatorsDir/proto/protovalidate/buf/validate/priv
cp $validatorsDir/proto/protovalidate/buf/validate/priv/*.proto $protoDir/buf/validate/priv/
mkdir -p $protoDir/google/protobuf
cp $protobufDir/src/google/protobuf/*.proto $protoDir/google/protobuf
rm -f $protoDir/google/protobuf/unittest*.proto
rm -f $protoDir/google/protobuf/test_*.proto
rm -f $protoDir/google/protobuf/*unittest.proto
rm -f $protoDir/google/protobuf/*_test.proto
rm -f $protoDir/google/protobuf/sample_messages_edition.proto
#不使用github.com/alta/protopatch
mkdir -p $protoDir/patch
cp $protopatchDir/patch/*.proto $protoDir/patch
mkdir -p $protoDir/danielvladco/protobuf
cp $gqlDir/api/danielvladco/protobuf/*.proto $protoDir/danielvladco/protobuf
rm -rf $tmpMod