Skip to content

Commit 0032998

Browse files
committed
feat: add protoc-insertion-point
In order for other plugins to generate extra code in the index.ts file protoc_insertion_point can be used. This commit adds one insertion point at the end of the file. From docs: > If non-empty, indicates that the named file should already exist, and the > content here is to be inserted into that file at a defined insertion > point. This feature allows a code generator to extend the output > produced by another code generator. The original generator may provide > insertion points by placing special annotations in the file that look > like: > @@protoc_insertion_point(NAME)
1 parent c4f2a30 commit 0032998

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

examples/proto/gen/typescript/einride/example/freight/v1/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,3 +644,5 @@ export function createFreightServiceClient(
644644
},
645645
};
646646
}
647+
648+
// @@protoc_insertion_point(typescript-http-eof)

examples/proto/gen/typescript/einride/example/syntax/v1/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,5 @@ export function createSyntaxServiceClient(
400400
},
401401
};
402402
}
403+
404+
// @@protoc_insertion_point(typescript-http-eof)

examples/proto/gen/typescript/einride/example/syntax/v2/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,5 @@ export type einrideexamplesyntaxv1_Message_NestedMessage = {
251251
export type einrideexamplesyntaxv1_Message_NestedEnum =
252252
// NESTEDENUM_UNSPECIFIED
253253
"NESTEDENUM_UNSPECIFIED";
254+
255+
// @@protoc_insertion_point(typescript-http-eof)

internal/plugin/generate.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ func Generate(request *pluginpb.CodeGeneratorRequest) (*pluginpb.CodeGeneratorRe
4040
if err := (packageGenerator{pkg: pkg, files: files}).Generate(&index); err != nil {
4141
return nil, fmt.Errorf("generate package '%s': %w", pkg, err)
4242
}
43+
index.P()
44+
index.P("// @@protoc_insertion_point(typescript-http-eof)")
4345
res.File = append(res.File, &pluginpb.CodeGeneratorResponse_File{
4446
Name: proto.String(path.Join(indexPathElems...)),
4547
Content: proto.String(string(index.Content())),

0 commit comments

Comments
 (0)