Skip to content

Commit c589a22

Browse files
authored
Merge pull request #21 from reload/dependabot/npm_and_yarn/bufbuild/protobuf-2.11.0
chore(deps): Bump @bufbuild/protobuf from 1.4.2 to 2.11.0
2 parents fa4ea1a + 97ac563 commit c589a22

7 files changed

Lines changed: 228 additions & 575 deletions

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/src/gen/plugin/codegen_pb.ts linguist-generated=true

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ out.js: src/app.ts $(wildcard src/drivers/*.ts) src/gen/plugin/codegen_pb.ts nod
1212
npx esbuild --bundle src/app.ts --tree-shaking=true --format=esm --target=es2020 --outfile=out.js
1313

1414
src/gen/plugin/codegen_pb.ts: buf.gen.yaml
15-
buf generate --template buf.gen.yaml buf.build/sqlc/sqlc --path plugin/
15+
npx @bufbuild/buf generate --template buf.gen.yaml buf.build/sqlc/sqlc --path plugin/
1616

1717
node_modules: package.json package-lock.json
1818
npm install

buf.gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version: v1
22
plugins:
3-
- plugin: buf.build/bufbuild/es:v1.4.2
3+
- plugin: buf.build/bufbuild/es:v2.11.0
44
opt: target=ts
55
out: src/gen

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"typescript": "^5.2.2"
1414
},
1515
"dependencies": {
16-
"@bufbuild/protobuf": "^1.4.2",
16+
"@bufbuild/protobuf": "^2.11.0",
1717
"javy": "^0.1.2",
1818
"pg": "^8.11.3"
1919
}

src/app.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ import {
1818
factory,
1919
} from "typescript";
2020

21+
import { create, fromBinary, toBinary } from "@bufbuild/protobuf";
2122
import {
2223
GenerateRequest,
24+
GenerateRequestSchema,
2325
GenerateResponse,
26+
GenerateResponseSchema,
2427
Parameter,
2528
Column,
2629
File,
30+
FileSchema,
2731
Query,
2832
} from "./gen/plugin/codegen_pb";
2933

@@ -200,7 +204,7 @@ ${query.text}`
200204
}
201205
if (nodes) {
202206
files.push(
203-
new File({
207+
create(FileSchema, {
204208
name: `${filename.replace(".", "_")}.ts`,
205209
contents: new TextEncoder().encode(printNode(nodes)),
206210
})
@@ -209,15 +213,15 @@ ${query.text}`
209213
}
210214
}
211215

212-
return new GenerateResponse({
216+
return create(GenerateResponseSchema, {
213217
files: files,
214218
});
215219
}
216220

217221
// Read input from stdin
218222
function readInput(): GenerateRequest {
219223
const buffer = readFileSync(STDIO.Stdin);
220-
return GenerateRequest.fromBinary(buffer);
224+
return fromBinary(GenerateRequestSchema, buffer);
221225
}
222226

223227
function queryDecl(name: string, sql: string) {
@@ -299,7 +303,6 @@ function printNode(nodes: Node[]): string {
299303

300304
// Write output to stdout
301305
function writeOutput(output: GenerateResponse) {
302-
const encodedOutput = output.toBinary();
303-
const buffer = new Uint8Array(encodedOutput);
306+
const buffer = toBinary(GenerateResponseSchema, output);
304307
writeFileSync(STDIO.Stdout, buffer);
305308
}

0 commit comments

Comments
 (0)