proto compiling

This commit is contained in:
tresabhi committed 2026-09-13 12:52:25 -05:00
1 parent 054f33a649
commit 491b03ad00
4 files changed
+27 -4

No files matched your search

+5
View File
@@ -52,6 +52,9 @@
"ts-deepmerge": "^7.0.3",
},
},
"packages/protos": {
"name": "@blitzkit/protos",
},
"packages/scripts": {
"name": "@blitzkit/scripts",
"dependencies": {
@@ -400,6 +403,8 @@
"@blitzkit/i18n": ["@blitzkit/i18n@workspace:packages/i18n"],
"@blitzkit/protos": ["@blitzkit/protos@workspace:packages/protos"],
"@blitzkit/scripts": ["@blitzkit/scripts@workspace:packages/scripts"],
"@blitzkit/website": ["@blitzkit/website@workspace:packages/website"],
+6
View File
@@ -0,0 +1,6 @@
{
"name": "@blitzkit/protos",
"private": true,
"type": "module",
"main": "src/index.ts"
}
+1
View File
@@ -0,0 +1 @@
export * from "./blitzkit";
+15 -4
View File
@@ -2,7 +2,7 @@ import { execFile } from "child_process";
import { mkdir, readdir, rm, writeFile } from "fs/promises";
const TEMP = "../../temp";
const TS_PROTO_EXECUTABLE = "./node_modules/.bin/protoc-gen-ts_proto";
const TS_PROTO_EXECUTABLE = "../../node_modules/.bin/protoc-gen-ts_proto";
const ROOTS = ["../protos/src/blitzkit"];
for (const root of ROOTS) {
@@ -17,20 +17,29 @@ for (const root of ROOTS) {
args += "--ts_proto_opt=snakeToCamel=false\n";
args += `--ts_proto_out=${root}\n`;
for (const dir of await readdir(root)) {
args += `-I=${root}/${dir}\n`;
for (const dir of ROOTS) {
args += `-I=${dir}\n`;
}
const filesRaw = await readdir(`${root}`, { recursive: true });
const files: string[] = [];
let index = "";
index += "// @ts-nocheck\n";
for (const file of filesRaw) {
if (file.endsWith(".proto")) {
files.push(file);
args += `${root}/${file}\n`;
}
if (file.endsWith(".ts")) await rm(`${root}/${file}`);
if (file.endsWith(".ts")) {
const name = file.slice(0, -3);
index += `export * from "./${name}";\n`;
await rm(`${root}/${file}`);
}
}
await writeFile(`${TEMP}/protoc.txt`, args);
@@ -40,4 +49,6 @@ for (const root of ROOTS) {
if (stderr) console.error(stderr);
if (stdout) console.log(stdout);
});
await writeFile(`${root}/index.ts`, index);
}