From a0c590944ff82d3584a532cd7400689297735757 Mon Sep 17 00:00:00 2001 From: Castor Regex Date: Wed, 22 Oct 2025 05:31:24 -0500 Subject: feat: add support for .proto files --- packages/core/src/services/fileSystemService.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'packages/core/src/services/fileSystemService.ts') diff --git a/packages/core/src/services/fileSystemService.ts b/packages/core/src/services/fileSystemService.ts index e2f30cf4..3e4cd30f 100644 --- a/packages/core/src/services/fileSystemService.ts +++ b/packages/core/src/services/fileSystemService.ts @@ -5,6 +5,7 @@ */ import fs from 'fs/promises'; +import protobuf from 'protobufjs'; /** * Interface for file system operations that may be delegated to different implementations @@ -18,6 +19,14 @@ export interface FileSystemService { */ readTextFile(filePath: string): Promise; + /** + * Read and parse a proto file + * + * @param filePath - The path to the file to read + * @returns The file content as a JSON string + */ + readProtoFile(filePath: string): Promise; + /** * Write text content to a file * @@ -35,6 +44,11 @@ export class StandardFileSystemService implements FileSystemService { return fs.readFile(filePath, 'utf-8'); } + async readProtoFile(filePath: string): Promise { + const root = await protobuf.load(filePath); + return JSON.stringify(root.toJSON(), null, 2); + } + async writeTextFile(filePath: string, content: string): Promise { await fs.writeFile(filePath, content, 'utf-8'); } -- cgit v1.2.3