Skip to content

Commit dc5c91a

Browse files
committed
build(firestore): modernize and improve protobuf generation scripts
Modernized update.sh and compile.sh to use npx and improved their robustness. Key changes include: - Replaced brittle line-number patching in update.sh with a context-aware .patch file for the verify field. - Automated proto file discovery in compile.sh using find instead of hardcoded file lists. - Added dependency verification for required CLI tools (git, patch, npx). - Restructured update.sh to selectively copy only necessary dependencies from google/api and google/protobuf. - Improved path handling to ensure scripts work correctly regardless of the current working directory. - Removed unused and untracked TypeScript declaration generation (temp.d.ts). - Updated Firestore and dependency protobufs to their latest versions.
1 parent 7bb8c35 commit dc5c91a

29 files changed

Lines changed: 6995 additions & 3435 deletions
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Copyright 2017 Google Inc.
3+
# Copyright 2026 Google Inc.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -16,19 +16,19 @@
1616

1717
set -euo pipefail
1818

19-
# Variables
20-
PROTOS_DIR="."
21-
PBJS="../../node_modules/.bin/pbjs"
22-
PBTS="../../node_modules/.bin/pbts"
19+
# Verify dependencies
20+
for cmd in npx find; do
21+
if ! command -v "$cmd" &> /dev/null; then
22+
echo "Error: $cmd is required but not installed." >&2
23+
exit 1
24+
fi
25+
done
2326

24-
"${PBJS}" --path=. --target=json -o protos.json \
25-
-r firestore/v1 "${PROTOS_DIR}/google/firestore/v1/*.proto" \
26-
"${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \
27-
"${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto"
27+
PROTOS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
28+
PROTO_FILES=$(find "${PROTOS_DIR}/google" -name "*.proto")
2829

29-
"${PBJS}" --path="${PROTOS_DIR}" --target=static -o temp.js \
30-
-r firestore/v1 "${PROTOS_DIR}/google/firestore/v1/*.proto" \
31-
"${PROTOS_DIR}/google/protobuf/*.proto" "${PROTOS_DIR}/google/type/*.proto" \
32-
"${PROTOS_DIR}/google/rpc/*.proto" "${PROTOS_DIR}/google/api/*.proto"
30+
# Generate JSON representation
31+
npx pbjs --path="${PROTOS_DIR}" --target=json -o "${PROTOS_DIR}/protos.json" \
32+
-r firestore/v1 $PROTO_FILES
3333

34-
"${PBTS}" -o temp.d.ts --no-comments temp.js
34+
rm -f "${PROTOS_DIR}/temp.d.ts"

packages/firestore/src/protos/google/api/annotations.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2015 Google LLC
1+
// Copyright 2025 Google LLC
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)