#!/bin/bash
# Script to generate Firebase configuration files for different environments/flavors
# Feel free to reuse and adapt this script for your own projects

if [[ $# -eq 0 ]]; then
  echo "Error: No environment specified. Use 'dev', 'stg', or 'prod'."
  exit 1
fi

case $1 in
  develop)
    flutterfire config \
      --project=comwell-phoenix-dev \
      --out=lib/firebase_options_dev.dart \
      --ios-bundle-id=com.comwell.phoenix.dev \
      --ios-out=ios/flavors/develop/GoogleService-Info.plist \
      --android-package-name=com.comwell.phoenix.dev \
      --android-out=android/app/src/develop/google-services.json
    ;;
  test)
    flutterfire config \
      --project=comwell-phoenix-test \
      --out=lib/firebase_options_test.dart \
      --ios-bundle-id=com.comwell.phoenix.test \
      --ios-out=ios/flavors/test/GoogleService-Info.plist \
      --android-package-name=com.comwell.phoenix.rtest \
      --android-out=android/app/src/test/google-services.json
    ;;
    stage)
    flutterfire config \
      --project=comwell-phoenix-stage \
      --out=lib/firebase_options_stage.dart \
      --ios-bundle-id=com.comwell.phoenix.stage \
      --ios-out=ios/flavors/stage/GoogleService-Info.plist \
      --android-package-name=com.comwell.phoenix.stage \
      --android-out=android/app/src/stage/google-services.json
    ;;

  prod)
    flutterfire config \
      --project=comwell-phoenix \
      --out=lib/firebase_options_prod.dart \
      --ios-bundle-id=com.comwell.phoenix \
      --ios-out=ios/flavors/prod/GoogleService-Info.plist \
      --android-package-name=com.comwell.phoenix \
      --android-out=android/app/src/prod/google-services.json
    ;;
  *)
    echo "Error: Invalid environment specified. Use 'dev', 'stg', or 'prod'."
    exit 1
    ;;
esac