Firebase Multi-Env Manager ๐
A production-ready Dart CLI tool designed to streamline Firebase environment management for Flutter projects. Safely switch between dev, staging, and prod environments with automatic configuration updates, backups, and validation.
โจ Features
- Platform-Specific Handlers:
- Android: Automatically updates
google-services.json,applicationIdinbuild.gradle, andandroid:labelinAndroidManifest.xml. - iOS: Updates
GoogleService-Info.plist,PRODUCT_BUNDLE_IDENTIFIERinproject.pbxproj, andCFBundleDisplayNameinInfo.plist.
- Android: Automatically updates
- Safety First:
- Automatic Backups: Creates a timestamped backup of sensitive files before every switch.
- Rollback System: Quickly restore previous configurations if a switch fails.
- Validation: Checks for project integrity and missing config files before making changes.
- Advanced CLI:
- Interactive Mode: Select environments from a menu.
- CI/CD Ready: Supports non-interactive flags and proper exit codes for automation.
- Diffing: Compare environment configurations directly from the terminal.
- Modular & Extensible: Clean architecture with separate layers for services, handlers, and CLI logic.
๐ Getting Started
Prerequisites
- Dart SDK (^3.10.0)
- A Flutter project with standard
android/andios/structures.
Configuration
Add the firebase_multi_env section to your pubspec.yaml:
firebase_multi_env:
default: dev
environments:
dev:
android_config: firebase/dev/google-services.json
ios_config: firebase/dev/GoogleService-Info.plist
android_application_id: com.example.app.dev
ios_bundle_id: com.example.app.dev
app_name: MyApp Dev
prod:
android_config: firebase/prod/google-services.json
ios_config: firebase/prod/GoogleService-Info.plist
android_application_id: com.example.app
ios_bundle_id: com.example.app
app_name: MyApp
๐ Usage
Run the tool using dart bin/firebase_multi_env_manager.dart or activate it globally.
Common Commands
-
List environments:
firebase_multi_env --list -
Switch environment:
firebase_multi_env --env dev -
Compare configurations:
firebase_multi_env --diff dev,prod -
Rollback to last backup:
firebase_multi_env --rollback -
CI Mode:
firebase_multi_env --env prod --ci
๐ Project Structure
lib/
โโโ cli/ # Argument parsing and user interaction
โโโ core/ # Shared constants, logger, and exceptions
โโโ handlers/ # Platform-specific (Android/iOS) modification logic
โโโ services/ # Core business logic (Backup, Config, Validator)
โโโ env_switcher.dart # Main orchestrator
๐งช Testing
Run the full test suite with:
dart test -j 1
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
Libraries
- cli/cli_parser
- core/constants
- core/exceptions
- core/logger
- env_switcher
- firebase_multi_env_manager
- handlers/android_handler
- handlers/dotenv_handler
- handlers/ios_handler
- handlers/macos_handler
- handlers/template_handler
- handlers/web_handler
- handlers/windows_handler
- services/backup_service
- services/config_reader
- services/validator