diff --git a/Makefile b/Makefile index 172d43f..3eb8d34 100644 --- a/Makefile +++ b/Makefile @@ -11,12 +11,9 @@ export GO111MODULE=on undefine GOARCH undefine GOOS -.PHONY: $(MAKECMDGOALS) help +.PHONY: $(MAKECMDGOALS) -all: help - -vendor: - go mod vendor +all: $(COMMON_MAKEFILE): vendor @if [ ! -f $(COMMON_MAKEFILE) ]; then \ @@ -29,3 +26,6 @@ $(MAKECMDGOALS): $(COMMON_MAKEFILE) %: $(COMMON_MAKEFILE) @$(MAKE) -C $(COMMON_DIR) PROJECT_DIR="$(PROJECT_DIR)" $@ + +vendor: + go mod vendor diff --git a/example/example_pb.ts b/example/example_pb.ts index 0add9c4..1bff81d 100644 --- a/example/example_pb.ts +++ b/example/example_pb.ts @@ -2,8 +2,15 @@ // @generated from file github.com/aperturerobotics/template/example/example.proto (package example, syntax proto3) /* eslint-disable */ -import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; -import { Message, proto3 } from "@bufbuild/protobuf"; +import type { + BinaryReadOptions, + FieldList, + JsonReadOptions, + JsonValue, + PartialMessage, + PlainMessage, +} from '@bufbuild/protobuf' +import { Message, proto3 } from '@bufbuild/protobuf' /** * EchoMsg is the message body for Echo. @@ -14,33 +21,44 @@ export class EchoMsg extends Message { /** * @generated from field: string body = 1; */ - body = ""; + body = '' constructor(data?: PartialMessage) { - super(); - proto3.util.initPartial(data, this); + super() + proto3.util.initPartial(data, this) } - static readonly runtime: typeof proto3 = proto3; - static readonly typeName = "example.EchoMsg"; + static readonly runtime: typeof proto3 = proto3 + static readonly typeName = 'example.EchoMsg' static readonly fields: FieldList = proto3.util.newFieldList(() => [ - { no: 1, name: "body", kind: "scalar", T: 9 /* ScalarType.STRING */ }, - ]); + { no: 1, name: 'body', kind: 'scalar', T: 9 /* ScalarType.STRING */ }, + ]) - static fromBinary(bytes: Uint8Array, options?: Partial): EchoMsg { - return new EchoMsg().fromBinary(bytes, options); + static fromBinary( + bytes: Uint8Array, + options?: Partial, + ): EchoMsg { + return new EchoMsg().fromBinary(bytes, options) } - static fromJson(jsonValue: JsonValue, options?: Partial): EchoMsg { - return new EchoMsg().fromJson(jsonValue, options); + static fromJson( + jsonValue: JsonValue, + options?: Partial, + ): EchoMsg { + return new EchoMsg().fromJson(jsonValue, options) } - static fromJsonString(jsonString: string, options?: Partial): EchoMsg { - return new EchoMsg().fromJsonString(jsonString, options); + static fromJsonString( + jsonString: string, + options?: Partial, + ): EchoMsg { + return new EchoMsg().fromJsonString(jsonString, options) } - static equals(a: EchoMsg | PlainMessage | undefined, b: EchoMsg | PlainMessage | undefined): boolean { - return proto3.util.equals(EchoMsg, a, b); + static equals( + a: EchoMsg | PlainMessage | undefined, + b: EchoMsg | PlainMessage | undefined, + ): boolean { + return proto3.util.equals(EchoMsg, a, b) } } - diff --git a/example/example_srpc.pb.ts b/example/example_srpc.pb.ts index edad960..9248b6f 100644 --- a/example/example_srpc.pb.ts +++ b/example/example_srpc.pb.ts @@ -2,10 +2,15 @@ // @generated from file github.com/aperturerobotics/template/example/example.proto (package example, syntax proto3) /* eslint-disable */ -import { EchoMsg } from "./example_pb.js"; -import type { PartialMessage } from "@bufbuild/protobuf"; -import { MethodKind } from "@bufbuild/protobuf"; -import { buildDecodeMessageTransform, buildEncodeMessageTransform, MessageStream, ProtoRpc } from "starpc"; +import { EchoMsg } from './example_pb.js' +import type { PartialMessage } from '@bufbuild/protobuf' +import { MethodKind } from '@bufbuild/protobuf' +import { + buildDecodeMessageTransform, + buildEncodeMessageTransform, + MessageStream, + ProtoRpc, +} from 'starpc' /** * Echoer service returns the given message. @@ -13,7 +18,7 @@ import { buildDecodeMessageTransform, buildEncodeMessageTransform, MessageStream * @generated from service example.Echoer */ export const EchoerDefinition = { - typeName: "example.Echoer", + typeName: 'example.Echoer', methods: { /** * Echo returns the given message. @@ -21,7 +26,7 @@ export const EchoerDefinition = { * @generated from rpc example.Echoer.Echo */ Echo: { - name: "Echo", + name: 'Echo', I: EchoMsg, O: EchoMsg, kind: MethodKind.Unary, @@ -32,7 +37,7 @@ export const EchoerDefinition = { * @generated from rpc example.Echoer.EchoServerStream */ EchoServerStream: { - name: "EchoServerStream", + name: 'EchoServerStream', I: EchoMsg, O: EchoMsg, kind: MethodKind.ServerStreaming, @@ -43,7 +48,7 @@ export const EchoerDefinition = { * @generated from rpc example.Echoer.EchoClientStream */ EchoClientStream: { - name: "EchoClientStream", + name: 'EchoClientStream', I: EchoMsg, O: EchoMsg, kind: MethodKind.ClientStreaming, @@ -54,13 +59,13 @@ export const EchoerDefinition = { * @generated from rpc example.Echoer.EchoBidiStream */ EchoBidiStream: { - name: "EchoBidiStream", + name: 'EchoBidiStream', I: EchoMsg, O: EchoMsg, kind: MethodKind.BiDiStreaming, }, - } -} as const; + }, +} as const /** * Echoer service returns the given message. @@ -74,9 +79,9 @@ export interface Echoer { * @generated from rpc example.Echoer.Echo */ Echo( -request: PartialMessage, abortSignal?: AbortSignal -): -Promise> + request: PartialMessage, + abortSignal?: AbortSignal, + ): Promise> /** * EchoServerStream is an example of a server -> client one-way stream. @@ -84,9 +89,9 @@ Promise> * @generated from rpc example.Echoer.EchoServerStream */ EchoServerStream( -request: PartialMessage, abortSignal?: AbortSignal -): -MessageStream + request: PartialMessage, + abortSignal?: AbortSignal, + ): MessageStream /** * EchoClientStream is an example of client->server one-way stream. @@ -94,9 +99,9 @@ MessageStream * @generated from rpc example.Echoer.EchoClientStream */ EchoClientStream( -request: MessageStream, abortSignal?: AbortSignal -): -Promise> + request: MessageStream, + abortSignal?: AbortSignal, + ): Promise> /** * EchoBidiStream is an example of a two-way stream. @@ -104,10 +109,9 @@ Promise> * @generated from rpc example.Echoer.EchoBidiStream */ EchoBidiStream( -request: MessageStream, abortSignal?: AbortSignal -): -MessageStream - + request: MessageStream, + abortSignal?: AbortSignal, + ): MessageStream } export const EchoerServiceName = EchoerDefinition.typeName @@ -129,9 +133,9 @@ export class EchoerClient implements Echoer { * @generated from rpc example.Echoer.Echo */ async Echo( -request: PartialMessage, abortSignal?: AbortSignal -): -Promise> { + request: PartialMessage, + abortSignal?: AbortSignal, + ): Promise> { const requestMsg = new EchoMsg(request) const result = await this.rpc.request( this.service, @@ -148,9 +152,9 @@ Promise> { * @generated from rpc example.Echoer.EchoServerStream */ EchoServerStream( -request: PartialMessage, abortSignal?: AbortSignal -): -MessageStream { + request: PartialMessage, + abortSignal?: AbortSignal, + ): MessageStream { const requestMsg = new EchoMsg(request) const result = this.rpc.serverStreamingRequest( this.service, @@ -167,9 +171,9 @@ MessageStream { * @generated from rpc example.Echoer.EchoClientStream */ async EchoClientStream( -request: MessageStream, abortSignal?: AbortSignal -): -Promise> { + request: MessageStream, + abortSignal?: AbortSignal, + ): Promise> { const result = await this.rpc.clientStreamingRequest( this.service, EchoerDefinition.methods.EchoClientStream.name, @@ -185,9 +189,9 @@ Promise> { * @generated from rpc example.Echoer.EchoBidiStream */ EchoBidiStream( -request: MessageStream, abortSignal?: AbortSignal -): -MessageStream { + request: MessageStream, + abortSignal?: AbortSignal, + ): MessageStream { const result = this.rpc.bidirectionalStreamingRequest( this.service, EchoerDefinition.methods.EchoBidiStream.name, @@ -196,5 +200,4 @@ MessageStream { ) return buildDecodeMessageTransform(EchoMsg)(result) } - }