Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 6 additions & 45 deletions src/proto/api.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions src/proto/tee-bundle.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/scripts/generate-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ mkdir -p src/proto
protoc --plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \
--ts_proto_out=./src/proto \
--ts_proto_opt=enumsAsLiterals=true,useExactTypes=false \
--proto_path=./proto ./proto/*.proto
--proto_path=./proto ./proto/*.proto

node src/scripts/remove-namespaces.js
35 changes: 35 additions & 0 deletions src/scripts/remove-namespaces.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const PROTO_DIR = path.join(__dirname, '../proto');

if (!fs.existsSync(PROTO_DIR)) {
console.error(`Directory not found: ${PROTO_DIR}`);
process.exit(1);
}

const files = fs.readdirSync(PROTO_DIR).filter(file => file.endsWith('.ts'));

files.forEach(file => {
const filePath = path.join(PROTO_DIR, file);
let content = fs.readFileSync(filePath, 'utf8');

// Regex to match "export namespace Name { ... }" blocks
// This assumes the namespace block ends with a closing brace on a new line
// and doesn't contain nested braces that would break a simple regex.
// Given the generated code structure, this should be safe.
const namespaceRegex = /export namespace \w+ \{[\s\S]*?\n\}/g;

if (namespaceRegex.test(content)) {
console.log(`Found namespaces in ${file}. Removing...`);
content = content.replace(namespaceRegex, '');
fs.writeFileSync(filePath, content, 'utf8');
console.log(`Namespaces removed from ${file}.`);
} else {
console.log(`No namespaces found in ${file}.`);
}
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
Loading