-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from pubg/feature/types
Introducing Dynamic TypeScript Type Generation from Envoy Proto Files
- Loading branch information
Showing
325 changed files
with
10,500 additions
and
418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
/test | ||
.git | ||
.gitignore | ||
**/*.md | ||
.repos | ||
**/*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,5 @@ dist | |
|
||
# TernJS port file | ||
.tern-port | ||
|
||
.repos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
```bash | ||
npm run generate-types | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash -e | ||
# This script is used to generate the typescript types for the envoy proto files. | ||
|
||
# read ENVOY_VERSION from ../Dockerfile | ||
ENVOY_VERSION=`grep 'ARG ENVOY_VERSION' Dockerfile | cut -d '=' -f 2` | ||
echo "Generating types for envoy version $ENVOY_VERSION" | ||
|
||
# Install the dependencies | ||
echo "Installing dependencies" | ||
npm install -g @grpc/proto-loader | ||
|
||
# Clone the repos | ||
echo "Cloning repos" | ||
[ ! -d '.repos/envoy' ] && git clone --depth=1 --branch $ENVOY_VERSION [email protected]:envoyproxy/envoy.git .repos/envoy | ||
[ ! -d '.repos/udpa' ] && git clone --depth=1 [email protected]:cncf/udpa.git .repos/udpa | ||
[ ! -d '.repos/protoc-gen-validate' ] && git clone --depth=1 [email protected]:bufbuild/protoc-gen-validate.git .repos/protoc-gen-validate | ||
[ ! -d '.repos/xds' ] && git clone --depth=1 [email protected]:cncf/xds.git .repos/xds | ||
|
||
# Generate the types | ||
echo "Generating types" | ||
proto-loader-gen-types \ | ||
--keepCase \ | ||
--enums=string \ | ||
--json=true \ | ||
--grpcLib=@grpc/grpc-js \ | ||
-I .repos/envoy/api .repos/udpa .repos/protoc-gen-validate .repos/xds \ | ||
--outDir=types/ \ | ||
.repos/envoy/api/envoy/config/bootstrap/v3/bootstrap.proto \ | ||
.repos/envoy/api/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto \ | ||
.repos/envoy/api/envoy/extensions/filters/network/tcp_proxy/v3/tcp_proxy.proto \ | ||
.repos/envoy/api/envoy/extensions/access_loggers/file/v3/file.proto \ | ||
.repos/envoy/api/envoy/extensions/transport_sockets/tls/v3/tls.proto | ||
|
||
# Cleanup | ||
# echo "Cleaning up" | ||
# rm -rf .repos | ||
|
||
# Fix the generated types | ||
echo "Fixing BoolValue" | ||
cat > types/google/protobuf/BoolValue.ts << 'EOT' | ||
// generate-types.sh generated | ||
export type BoolValue = boolean; | ||
export type BoolValue__Output = boolean; | ||
EOT | ||
|
||
echo "Fixing UInt32Value" | ||
cat > types/google/protobuf/UInt32Value.ts << 'EOT' | ||
// generate-types.sh generated | ||
export type UInt32Value = number; | ||
export type UInt32Value__Output = number; | ||
EOT | ||
|
||
echo "Fixing Duration" | ||
cat > types/google/protobuf/Duration.ts << 'EOT' | ||
// generate-types.sh generated | ||
export type Duration = string; | ||
export type Duration__Output = string; | ||
EOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
echo-client - echo-server | ||
|
||
```bash | ||
docker-compose up | ||
npm run grpc-test | ||
``` | ||
```bash | ||
... | ||
|
Oops, something went wrong.