Skip to content

Commit dc0905f

Browse files
committed
update protogen
1 parent ecfb85f commit dc0905f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

scripts/protogen.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const { exec } = require('child_process');
2+
3+
// Configuration Variables
4+
const branchName = '17-6.1.0';
5+
const protoUrl = `https://raw.githubusercontent.com/pganalyze/libpg_query/${branchName}/protobuf/pg_query.proto`;
6+
const inFile = 'libpg_query/protobuf/pg_query.proto';
7+
const outFile = 'proto.js';
8+
9+
const protogenCmd = [
10+
'pg-proto-parser',
11+
'protogen',
12+
'--protoUrl',
13+
protoUrl,
14+
'--inFile',
15+
inFile,
16+
'--outFile',
17+
outFile,
18+
'--originalPackageName',
19+
'protobufjs/minimal',
20+
'--newPackageName',
21+
'@launchql/protobufjs/minimal'
22+
];
23+
24+
// Step 2: Generate proto.js using pbjs (Assuming pbjs is installed and accessible)
25+
function generateProtoJS(callback) {
26+
exec(protogenCmd.join(' '), (error, stdout, stderr) => {
27+
if (error) {
28+
console.error(`Error during code generation: ${error.message}`);
29+
return;
30+
}
31+
console.log('Generated proto.js from proto file.');
32+
callback();
33+
});
34+
}
35+
36+
generateProtoJS(() => {
37+
console.log('all done 🎉');
38+
});

0 commit comments

Comments
 (0)