Skip to content

Commit dc1d7f5

Browse files
authored
Create proto descriptor set in build-protos.js script. (RooCodeInc#3524)
* Create proto descriptor set in build-protos.js script. Create the descriptor set that will be used by the standalone cline service. Add the standalone dist directory to the gitignore. Only call protoc once when generating typescript files, instead of for each file separately. * Fix undefined var in error message * Inline the exec options
1 parent 4ff7e06 commit dc1d7f5

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
out
22
dist
3+
dist-standalone
34
node_modules
45
tmp
56
.vscode-test/

proto/build-proto.js

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,42 @@ async function main() {
5555

5656
// Process all proto files
5757
console.log(chalk.cyan("Processing proto files from"), SCRIPT_DIR)
58-
const protoFiles = await globby("*.proto", { cwd: SCRIPT_DIR })
59-
60-
for (const protoFile of protoFiles) {
61-
console.log(chalk.cyan(`Generating TypeScript code for ${protoFile}...`))
62-
63-
// Build the protoc command with proper path handling for cross-platform
64-
const protocCommand = [
65-
protoc,
66-
`--plugin=protoc-gen-ts_proto="${tsProtoPlugin}"`,
67-
`--ts_proto_out="${TS_OUT_DIR}"`,
68-
"--ts_proto_opt=outputServices=generic-definitions,env=node,esModuleInterop=true,useDate=false,useOptionals=messages",
69-
`--proto_path="${SCRIPT_DIR}"`,
70-
`"${path.join(SCRIPT_DIR, protoFile)}"`,
71-
].join(" ")
58+
const protoFiles = await globby("*.proto", { cwd: SCRIPT_DIR, absolute: true })
59+
60+
// Build the protoc command with proper path handling for cross-platform
61+
const tsProtocCommand = [
62+
protoc,
63+
`--proto_path="${SCRIPT_DIR}"`,
64+
`--plugin=protoc-gen-ts_proto="${tsProtoPlugin}"`,
65+
`--ts_proto_out="${TS_OUT_DIR}"`,
66+
"--ts_proto_opt=outputServices=generic-definitions,env=node,esModuleInterop=true,useDate=false,useOptionals=messages",
67+
...protoFiles,
68+
].join(" ")
69+
try {
70+
console.log(chalk.cyan(`Generating TypeScript code for:\n${protoFiles.join("\n")}...`))
71+
execSync(tsProtocCommand, { stdio: "inherit" })
72+
} catch (error) {
73+
console.error(chalk.red("Error generating TypeScript for proto files:"), error)
74+
process.exit(1)
75+
}
7276

73-
try {
74-
const execOptions = {
75-
stdio: "inherit",
76-
}
77-
execSync(protocCommand, execOptions)
78-
} catch (error) {
79-
console.error(chalk.red(`Error generating TypeScript for ${protoFile}:`), error)
80-
process.exit(1)
81-
}
77+
const descriptorOutDir = path.join(ROOT_DIR, "dist-standalone", "proto")
78+
await fs.mkdir(descriptorOutDir, { recursive: true })
79+
80+
const descriptorFile = path.join(descriptorOutDir, "descriptor_set.pb")
81+
const descriptorProtocCommand = [
82+
protoc,
83+
`--proto_path="${SCRIPT_DIR}"`,
84+
`--descriptor_set_out="${descriptorFile}"`,
85+
"--include_imports",
86+
...protoFiles,
87+
].join(" ")
88+
try {
89+
console.log(chalk.cyan("Generating descriptor set..."))
90+
execSync(descriptorProtocCommand, { stdio: "inherit" })
91+
} catch (error) {
92+
console.error(chalk.red("Error generating descriptor set for proto file:"), error)
93+
process.exit(1)
8294
}
8395

8496
console.log(chalk.green("Protocol Buffer code generation completed successfully."))

0 commit comments

Comments
 (0)