From fed5a1cdccf124a138d658c4a5abb0ed50746c7c Mon Sep 17 00:00:00 2001 From: Ryan Clark Date: Mon, 22 Jan 2024 13:08:30 +0100 Subject: [PATCH 1/2] Install @protobuf-ts/plugin in the docker containers --- build.assets/Dockerfile | 3 ++- build.assets/Dockerfile-grpcbox | 5 ++++- build.assets/Makefile | 1 + build.assets/grpcbox.mk | 1 + build.assets/versions.mk | 2 ++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/build.assets/Dockerfile b/build.assets/Dockerfile index 7a023c49b9caf..695380d55fba2 100644 --- a/build.assets/Dockerfile +++ b/build.assets/Dockerfile @@ -293,7 +293,8 @@ RUN helm plugin install https://github.com/vbehar/helm3-unittest && \ # Install JS gRPC tools. ARG NODE_GRPC_TOOLS_VERSION # eg, "1.12.4" ARG NODE_PROTOC_TS_VERSION # eg, "5.0.1" -RUN npm install --global "grpc-tools@$NODE_GRPC_TOOLS_VERSION" "grpc_tools_node_protoc_ts@$NODE_PROTOC_TS_VERSION" +ARG PROTOBUF_TS_PLUGIN_VERSION # eg, "2.9.3" +RUN npm install --global "grpc-tools@$NODE_GRPC_TOOLS_VERSION" "grpc_tools_node_protoc_ts@$NODE_PROTOC_TS_VERSION" "@protobuf-ts/plugin@$PROTOBUF_TS_PLUGIN_VERSION" # Install protoc. ARG PROTOC_VERSION # eg, "3.20.2" diff --git a/build.assets/Dockerfile-grpcbox b/build.assets/Dockerfile-grpcbox index feba067c20709..c86c88887f99f 100644 --- a/build.assets/Dockerfile-grpcbox +++ b/build.assets/Dockerfile-grpcbox @@ -21,7 +21,10 @@ RUN go install "github.com/gogo/protobuf/protoc-gen-gogofast@$GOGO_PROTO_TAG" ARG NODE_GRPC_TOOLS_VERSION # eg, "5.0.1" ARG NODE_PROTOC_TS_VERSION -RUN npm install --global "grpc-tools@$NODE_GRPC_TOOLS_VERSION" "grpc_tools_node_protoc_ts@$NODE_PROTOC_TS_VERSION" +# @protobuf-ts/plugin +# eg, "2.9.3" +ARG PROTOBUF_TS_PLUGIN_VERSION +RUN npm install --global "grpc-tools@$NODE_GRPC_TOOLS_VERSION" "grpc_tools_node_protoc_ts@$NODE_PROTOC_TS_VERSION" "@protobuf-ts/plugin@$PROTOBUF_TS_PLUGIN_VERSION" # protoc # eg, "3.20.2" diff --git a/build.assets/Makefile b/build.assets/Makefile index 8f79524b0dd0a..a58470adaa0fc 100644 --- a/build.assets/Makefile +++ b/build.assets/Makefile @@ -144,6 +144,7 @@ buildbox: --build-arg GOGO_PROTO_TAG=$(GOGO_PROTO_TAG) \ --build-arg NODE_GRPC_TOOLS_VERSION=$(NODE_GRPC_TOOLS_VERSION) \ --build-arg NODE_PROTOC_TS_VERSION=$(NODE_PROTOC_TS_VERSION) \ + --build-arg PROTOBUF_TS_PLUGIN_VERSION=$(PROTOBUF_TS_PLUGIN_VERSION) \ --build-arg PROTOC_VERSION=$(PROTOC_VERSION) \ --cache-from $(BUILDBOX) \ $(if $(PUSH),--push,--load) \ diff --git a/build.assets/grpcbox.mk b/build.assets/grpcbox.mk index 43d4426478914..4f95959e52620 100644 --- a/build.assets/grpcbox.mk +++ b/build.assets/grpcbox.mk @@ -30,6 +30,7 @@ grpcbox: --build-arg GOGO_PROTO_TAG=$(GOGO_PROTO_TAG) \ --build-arg NODE_GRPC_TOOLS_VERSION=$(NODE_GRPC_TOOLS_VERSION) \ --build-arg NODE_PROTOC_TS_VERSION=$(NODE_PROTOC_TS_VERSION) \ + --build-arg PROTOBUF_TS_PLUGIN_VERSION=$(PROTOBUF_TS_PLUGIN_VERSION) \ --build-arg PROTOC_VERSION=$(PROTOC_VERSION) \ -f Dockerfile-grpcbox \ -t "$(GRPCBOX)" \ diff --git a/build.assets/versions.mk b/build.assets/versions.mk index f472f6d3d5a41..454ee275a2ca8 100644 --- a/build.assets/versions.mk +++ b/build.assets/versions.mk @@ -19,6 +19,8 @@ DEVTOOLSET ?= devtoolset-12 BUF_VERSION ?= v1.28.0 # Keep in sync with api/proto/buf.yaml (and buf.lock). GOGO_PROTO_TAG ?= v1.3.2 +# TODO(ryan): remove once Connect has migrated to the TS protobufs. NODE_GRPC_TOOLS_VERSION ?= 1.12.4 NODE_PROTOC_TS_VERSION ?= 5.0.1 +PROTOBUF_TS_PLUGIN_VERSION ?= 2.9.3 PROTOC_VERSION ?= 3.20.3 From ea2f7a23b49c3a5840f06b3126154162a16c5ed1 Mon Sep 17 00:00:00 2001 From: Ryan Clark Date: Mon, 22 Jan 2024 15:50:53 +0100 Subject: [PATCH 2/2] Use npm exec so buf uses the correct protoc-gen-ts --- buf-js.gen.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/buf-js.gen.yaml b/buf-js.gen.yaml index bfd50a1dd1484..579ee11932f03 100644 --- a/buf-js.gen.yaml +++ b/buf-js.gen.yaml @@ -18,4 +18,11 @@ plugins: - name: ts strategy: all out: gen/proto/js + path: + - npm + - exec + - --yes + - --package=grpc_tools_node_protoc_ts@5.0.1 + - -- + - protoc-gen-ts opt: "service=grpc-node"