From 5ea66704dc96063f91a5075ce6cf306a6e10e25a Mon Sep 17 00:00:00 2001 From: Vishnu Ravi Date: Tue, 7 Jan 2025 16:59:03 -0500 Subject: [PATCH] Update dev tool setup script to address Firebase emulator error (#95) # *Update dev tool setup script to address Firebase emulator error* ## :recycle: Current situation & Problem If the development tool setup script is run in a directory without a `firebase.json` file (i.e. outside of the Spezi Template Application repository) it throws an error when attempting to test the Firebase emulator suite. As this script installs tools that are independent of the Spezi Template Application itself, it should be able to run completely on its own. ## :gear: Release Notes This PR adds a step in the setup script to create a temporary `firebase.json` if one does not exist before testing the firebase emulator suite. The file is removed before the script exits. ## :pencil: Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md): - [X] I agree to follow the [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md). --- Scripts/setup.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) mode change 100644 => 100755 Scripts/setup.sh diff --git a/Scripts/setup.sh b/Scripts/setup.sh old mode 100644 new mode 100755 index f9d4ed0..ee7750c --- a/Scripts/setup.sh +++ b/Scripts/setup.sh @@ -39,4 +39,36 @@ brew upgrade # 3. Test and start the firebase emulator + +# Check if firebase.json exists and create if it doesn't +CREATED_FIREBASE_JSON=false + +if [ ! -f "firebase.json" ]; then + echo "Creating firebase.json file..." + CREATED_FIREBASE_JSON=true + cat << 'EOL' > firebase.json +{ + "emulators": { + "auth": { + "port": 9099 + }, + "firestore": { + "port": 8080 + }, + "ui": { + "enabled": true, + "port": 4000 + }, + "singleProjectMode": true + } +} +EOL +fi + firebase emulators:exec --project test "echo 'Firebase emulator installed and started successfully!'" + +# Clean up the firebase.json file only if we created it +if [ "$CREATED_FIREBASE_JSON" = true ]; then + echo "Cleaning up temporary firebase.json file..." + rm firebase.json +fi \ No newline at end of file