twonly-app/scripts/generate_proto.sh

52 lines
1.4 KiB
Bash
Raw Normal View History

2025-01-19 20:29:00 +00:00
#!/bin/bash
# Set the source directory
2025-07-14 22:38:23 +00:00
if [ ! -f "pubspec.yaml" ]; then
echo "Must be executed from the flutter main repo."
exit 1
fi
2025-10-29 10:13:13 +00:00
# Definitions for twonly Backup
2025-10-19 00:45:17 +00:00
GENERATED_DIR="./lib/src/model/protobuf/client/generated/"
CLIENT_DIR="./lib/src/model/protobuf/client/"
2025-10-19 00:45:17 +00:00
protoc --proto_path="$CLIENT_DIR" --dart_out="$GENERATED_DIR" "backup.proto"
protoc --proto_path="$CLIENT_DIR" --dart_out="$GENERATED_DIR" "messages.proto"
2025-11-01 00:46:02 +00:00
protoc --proto_path="$CLIENT_DIR" --dart_out="$GENERATED_DIR" "groups.proto"
2025-12-07 23:06:45 +00:00
protoc --proto_path="$CLIENT_DIR" --dart_out="$GENERATED_DIR" "qr.proto"
2026-01-22 22:26:23 +00:00
protoc --proto_path="$CLIENT_DIR" --dart_out="$GENERATED_DIR" "data.proto"
2025-10-19 00:45:17 +00:00
protoc --proto_path="$CLIENT_DIR" --dart_out="$GENERATED_DIR" "push_notification.proto"
protoc --proto_path="$CLIENT_DIR" --swift_out="./ios/NotificationService/" "push_notification.proto"
2025-07-14 22:38:23 +00:00
# Definitions for the Server API
2025-11-01 00:46:02 +00:00
SRC_DIR="../twonly-server/twonly-api/src/"
2025-01-19 20:29:00 +00:00
2025-04-21 19:32:18 +00:00
DST_DIR="$(pwd)/lib/src/model/protobuf/"
2025-01-19 20:29:00 +00:00
2025-11-01 00:46:02 +00:00
mkdir $DST_DIR &>/dev/null
2025-01-19 20:29:00 +00:00
ORIGINAL_DIR=$(pwd)
cd "$SRC_DIR" || {
echo "Failed to change directory to $SRC_DIR"
exit 1
}
2025-06-09 21:35:45 +00:00
for proto_file in "api/"**/*.proto; do
2025-01-19 20:29:00 +00:00
if [[ -f "$proto_file" ]]; then
protoc --proto_path="." --dart_out="$DST_DIR" "$proto_file"
else
echo "No .proto files found in $SRC_DIR"
fi
done
cd "$ORIGINAL_DIR" || {
echo "Failed to change back to the original directory"
exit 1
}
2025-11-01 00:46:02 +00:00
echo "Finished processing .proto files :)"