Skip to content

Commit

Permalink
feat: add generated code comments (#1037)
Browse files Browse the repository at this point in the history
Closes #531
  • Loading branch information
dasco144 committed May 1, 2024
1 parent 577def4 commit cdd4a76
Show file tree
Hide file tree
Showing 260 changed files with 1,587 additions and 22 deletions.
6 changes: 6 additions & 0 deletions integration/angular/simple-message.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: simple-message.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";

Expand Down
6 changes: 6 additions & 0 deletions integration/async-iterable-services-abort-signal/simple.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: simple.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";

Expand Down
6 changes: 6 additions & 0 deletions integration/async-iterable-services/simple.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: simple.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";

Expand Down
6 changes: 6 additions & 0 deletions integration/avoid-import-conflicts-folder-name/ui.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: ui.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";

Expand Down
6 changes: 6 additions & 0 deletions integration/avoid-import-conflicts-folder-name/ui/simple.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: ui/simple.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";
import {
Expand Down
6 changes: 6 additions & 0 deletions integration/avoid-import-conflicts-types-only/simple.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: simple.proto

/* eslint-disable */
import type { Simple as Simple2, SimpleEnum as SimpleEnum1 } from "./simple2";

Expand Down
6 changes: 6 additions & 0 deletions integration/avoid-import-conflicts-types-only/simple2.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: simple2.proto

/* eslint-disable */

export const protobufPackage = "simple2";
Expand Down
6 changes: 6 additions & 0 deletions integration/avoid-import-conflicts/simple.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: simple.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";
import {
Expand Down
6 changes: 6 additions & 0 deletions integration/avoid-import-conflicts/simple2.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: simple2.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";

Expand Down
6 changes: 6 additions & 0 deletions integration/barrel-imports/bar.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: bar.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";

Expand Down
6 changes: 6 additions & 0 deletions integration/barrel-imports/foo.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: foo.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";
import { Bar } from "./bar";
Expand Down
6 changes: 6 additions & 0 deletions integration/batching-with-context-esModuleInterop/batching.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: batching.proto

/* eslint-disable */
import DataLoader from "dataloader";
import hash from "object-hash";
Expand Down
6 changes: 6 additions & 0 deletions integration/batching-with-context/batching.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: batching.proto

/* eslint-disable */
import * as DataLoader from "dataloader";
import * as hash from "object-hash";
Expand Down
6 changes: 6 additions & 0 deletions integration/batching/batching.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: batching.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";

Expand Down
6 changes: 6 additions & 0 deletions integration/before-after-request-streaming/example.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: example.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";
import { Observable } from "rxjs";
Expand Down
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: google/protobuf/wrappers.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";
import Long = require("long");
Expand Down
6 changes: 6 additions & 0 deletions integration/before-after-request/simple.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: simple.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";
import {
Expand Down
6 changes: 6 additions & 0 deletions integration/before-after-request/simple2.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: simple2.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";

Expand Down
6 changes: 6 additions & 0 deletions integration/bytes-as-base64-browser/message.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: message.proto

/* eslint-disable */

export const protobufPackage = "";
Expand Down
6 changes: 6 additions & 0 deletions integration/bytes-as-base64-node/message.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: message.proto

/* eslint-disable */

export const protobufPackage = "";
Expand Down
6 changes: 6 additions & 0 deletions integration/bytes-as-base64/message.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: message.proto

/* eslint-disable */

export const protobufPackage = "";
Expand Down
6 changes: 6 additions & 0 deletions integration/bytes-node/google/protobuf/wrappers.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: google/protobuf/wrappers.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";
import Long = require("long");
Expand Down
6 changes: 6 additions & 0 deletions integration/bytes-node/point.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: point.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";
import { BytesValue } from "./google/protobuf/wrappers";
Expand Down
19 changes: 15 additions & 4 deletions integration/codegen.ts
Expand Up @@ -4,7 +4,7 @@ import { parse } from "path";
import { promisify } from "util";
import { generateFile, makeUtils } from "../src/main";
import { createTypeMap } from "../src/types";
import { generateIndexFiles } from "../src/utils";
import { generateIndexFiles, getVersions } from "../src/utils";
import { getTsPoetOpts, optionsFromParameter } from "../src/options";
import { BaseContext, createFileContext } from "../src/context";
import { generateTypeRegistry } from "../src/generate-type-registry";
Expand All @@ -28,6 +28,8 @@ async function generate(binFile: string, baseDir: string, parameter: string) {
const request = CodeGeneratorRequest.decode(stdin);
request.parameter = parameter;

const { protocVersion, tsProtoVersion } = await getVersions(request);

const options = optionsFromParameter(parameter || "");
const typeMap = createTypeMap(request, options);

Expand All @@ -42,7 +44,10 @@ async function generate(binFile: string, baseDir: string, parameter: string) {
const filePath = `${baseDir}/${path}`;
const dirPath = parse(filePath).dir;
await promisify(mkdir)(dirPath, { recursive: true }).catch(() => {});
await promisify(writeFile)(filePath, code.toString({ ...getTsPoetOpts(options), path }));
await promisify(writeFile)(
filePath,
code.toString({ ...getTsPoetOpts(options, tsProtoVersion, protocVersion, file.name), path }),
);
}

if (options.outputTypeRegistry) {
Expand All @@ -54,15 +59,21 @@ async function generate(binFile: string, baseDir: string, parameter: string) {

const filePath = `${baseDir}/${path}`;

await promisify(writeFile)(filePath, code.toString({ ...getTsPoetOpts(options), path }));
await promisify(writeFile)(
filePath,
code.toString({ ...getTsPoetOpts(options, tsProtoVersion, protocVersion), path }),
);
}

if (options.outputIndex) {
for (const [path, code] of generateIndexFiles(request.protoFile, options)) {
const filePath = `${baseDir}/${path}`;
const dirPath = parse(filePath).dir;
await promisify(mkdir)(dirPath, { recursive: true }).catch(() => {});
await promisify(writeFile)(filePath, code.toString({ ...getTsPoetOpts(options), path }));
await promisify(writeFile)(
filePath,
code.toString({ ...getTsPoetOpts(options, tsProtoVersion, protocVersion), path }),
);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions integration/const-enum/const-enum.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: const-enum.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";

Expand Down
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: default-with-custom-metadata.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";
import { Foo } from "./custom-metadata";
Expand Down
6 changes: 6 additions & 0 deletions integration/default-with-metadata/default-with-metadata.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: default-with-metadata.proto

/* eslint-disable */
import { Metadata } from "@grpc/grpc-js";
import * as _m0 from "protobufjs/minimal";
Expand Down
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: google/protobuf/timestamp.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";
import Long = require("long");
Expand Down
6 changes: 6 additions & 0 deletions integration/emit-default-values-json/test.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: test.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";
import { Timestamp } from "./google/protobuf/timestamp";
Expand Down
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: enums-as-literals-with-string-enums.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";

Expand Down
6 changes: 6 additions & 0 deletions integration/enums-as-literals/enums-as-literals.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: enums-as-literals.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";

Expand Down
6 changes: 6 additions & 0 deletions integration/enums-with-unrecognized-name-value/test.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: test.proto

/* eslint-disable */

export const protobufPackage = "";
Expand Down
6 changes: 6 additions & 0 deletions integration/extensions/test.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: test.proto

/* eslint-disable */
import Long = require("long");
import * as _m0 from "protobufjs/minimal";
Expand Down
6 changes: 6 additions & 0 deletions integration/fieldmask-optional-all/fieldmask-optional.ts
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: fieldmask-optional.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";
import { FieldMask } from "./google/protobuf/field_mask";
Expand Down
@@ -1,3 +1,9 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.173.0
// protoc v3.19.1
// source: google/protobuf/field_mask.proto

/* eslint-disable */
import * as _m0 from "protobufjs/minimal";

Expand Down

0 comments on commit cdd4a76

Please sign in to comment.