mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
proto compiling
This commit is contained in:
1 parent
054f33a649
commit
491b03ad00
4 files changed
+27
-4
No files matched your search
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user