Skip to content

Commit 1761c0e

Browse files
authored
protoc version check (RooCodeInc#2981)
1 parent fbb13f1 commit 1761c0e

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

proto/build-proto.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,35 @@ const ROOT_DIR = path.resolve(SCRIPT_DIR, "..")
1313
async function main() {
1414
console.log(chalk.bold.blue("Starting Protocol Buffer code generation..."))
1515

16-
// Check if protoc is installed
16+
// Check if protoc is installed and has the correct version
1717
try {
18-
const options = { stdio: "ignore" }
19-
execSync("protoc --version", options)
18+
const protocOutput = execSync("protoc --version", { encoding: "utf8" }).trim()
19+
console.log(chalk.cyan(`Found ${protocOutput}`))
20+
const versionMatch = protocOutput.match(/libprotoc\s+(\d+\.\d+)/)
21+
if (!versionMatch) {
22+
console.warn(chalk.yellow("Warning: Could not determine protoc version. Continuing anyway..."))
23+
} else {
24+
const version = versionMatch[1]
25+
const requiredVersion = "30.1"
26+
if (version !== requiredVersion) {
27+
console.warn(
28+
chalk.yellow(`Warning: protoc version ${version} found, but version ${requiredVersion} is required.`),
29+
)
30+
console.warn(
31+
chalk.yellow(
32+
`To install the correct version, visit: https://github.com/protocolbuffers/protobuf/releases/tag/v${requiredVersion}`,
33+
),
34+
)
35+
process.exit(0) // Exit with success as requested
36+
}
37+
}
2038
} catch (error) {
2139
console.warn(chalk.yellow("Warning: protoc is not installed. Skipping proto generation."))
22-
console.warn(chalk.yellow("To install Protocol Buffers compiler, visit: https://grpc.io/docs/protoc-installation/"))
40+
console.warn(
41+
chalk.yellow(
42+
"To install Protocol Buffers compiler, visit: https://github.com/protocolbuffers/protobuf/releases/tag/v30.1",
43+
),
44+
)
2345
process.exit(0) // Exit with success as requested
2446
}
2547

0 commit comments

Comments
 (0)