From fd47e3ceb0649cee77b3901ef5f85599b140d90b Mon Sep 17 00:00:00 2001 From: Vishnu Ravi Date: Tue, 7 Jan 2025 16:11:48 -0500 Subject: [PATCH 1/5] Write firebase.json file before launching firebase emulator if needed --- Scripts/setup.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Scripts/setup.sh b/Scripts/setup.sh index f9d4ed00..01bb65fa 100644 --- a/Scripts/setup.sh +++ b/Scripts/setup.sh @@ -39,4 +39,38 @@ brew upgrade # 3. Test and start the firebase emulator + +# Check if firebase.json exists and create if it doesn't +if [ ! -f "firebase.json" ]; then + echo "Creating firebase.json file..." + cat > firebase.json << 'EOL' +{ + "firestore": { + "rules": "firestore.rules" + }, + "storage": { + "rules": "firebasestorage.rules" + }, + "emulators": { + "auth": { + "port": 9099 + }, + "firestore": { + "port": 8080 + }, + "ui": { + "enabled": true, + "port": 4000 + }, + "storage": { + "port": 9199 + }, + "singleProjectMode": true + } +} +EOL + firebase emulators:exec --project test "echo 'Firebase emulator installed and started successfully!'" + +# Clean up the firebase.json file +rm firebase.json \ No newline at end of file From 2099ad54dd16fb1defbf59d120427ac818d17931 Mon Sep 17 00:00:00 2001 From: Vishnu Ravi Date: Tue, 7 Jan 2025 16:14:17 -0500 Subject: [PATCH 2/5] Keep track of whether we wrote the firebase.json before deleting --- Scripts/setup.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) mode change 100644 => 100755 Scripts/setup.sh diff --git a/Scripts/setup.sh b/Scripts/setup.sh old mode 100644 new mode 100755 index 01bb65fa..54bb0048 --- a/Scripts/setup.sh +++ b/Scripts/setup.sh @@ -43,6 +43,7 @@ brew upgrade # Check if firebase.json exists and create if it doesn't if [ ! -f "firebase.json" ]; then echo "Creating firebase.json file..." + CREATED_FIREBASE_JSON=true cat > firebase.json << 'EOL' { "firestore": { @@ -72,5 +73,8 @@ EOL firebase emulators:exec --project test "echo 'Firebase emulator installed and started successfully!'" -# Clean up the firebase.json file -rm firebase.json \ No newline at end of file +# 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 From 7fc13fd9e312f2353eaa2791e8dae7f255b86ef6 Mon Sep 17 00:00:00 2001 From: Vishnu Ravi Date: Tue, 7 Jan 2025 16:23:00 -0500 Subject: [PATCH 3/5] Fix heredoc --- Scripts/setup.sh | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/Scripts/setup.sh b/Scripts/setup.sh index 54bb0048..44508b70 100755 --- a/Scripts/setup.sh +++ b/Scripts/setup.sh @@ -11,40 +11,42 @@ # # It is required that Xcode is installed on the macOS instance. -# 1. Install homebrew -export NONINTERACTIVE=1 -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile -eval "$(/opt/homebrew/bin/brew shellenv)" +# # 1. Install homebrew +# export NONINTERACTIVE=1 +# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +# echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile +# eval "$(/opt/homebrew/bin/brew shellenv)" -# 2. Install tools -brew install java -sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk -echo 'export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"' >> ~/.zshrc +# # 2. Install tools +# brew install java +# sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk +# echo 'export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"' >> ~/.zshrc -brew install node -brew install firebase-cli -brew install fastlane -# Set the local correctly to work with fastlane -echo 'export LC_ALL=en_US.UTF-8' >> ~/.zshrc -echo 'export LANG=en_US.UTF-8' >> ~/.zshrc +# brew install node +# brew install firebase-cli +# brew install fastlane +# # Set the local correctly to work with fastlane +# echo 'export LC_ALL=en_US.UTF-8' >> ~/.zshrc +# echo 'export LANG=en_US.UTF-8' >> ~/.zshrc -brew install git-lfs -git lfs install -git lfs install --system +# brew install git-lfs +# git lfs install +# git lfs install --system -# Ensure that everything on the system is up-to-date -brew upgrade +# # Ensure that everything on the system is up-to-date +# 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 > firebase.json << 'EOL' + cat << 'EOL' > firebase.json { "firestore": { "rules": "firestore.rules" @@ -70,6 +72,7 @@ if [ ! -f "firebase.json" ]; then } } EOL +fi firebase emulators:exec --project test "echo 'Firebase emulator installed and started successfully!'" From 453bba09e3f6c9c8247bacfbc8d731228067e719 Mon Sep 17 00:00:00 2001 From: Vishnu Ravi Date: Tue, 7 Jan 2025 16:24:36 -0500 Subject: [PATCH 4/5] Uncomment --- Scripts/setup.sh | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/Scripts/setup.sh b/Scripts/setup.sh index 44508b70..8f39ca2a 100755 --- a/Scripts/setup.sh +++ b/Scripts/setup.sh @@ -11,31 +11,31 @@ # # It is required that Xcode is installed on the macOS instance. -# # 1. Install homebrew -# export NONINTERACTIVE=1 -# /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -# echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile -# eval "$(/opt/homebrew/bin/brew shellenv)" +# 1. Install homebrew +export NONINTERACTIVE=1 +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile +eval "$(/opt/homebrew/bin/brew shellenv)" -# # 2. Install tools -# brew install java -# sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk -# echo 'export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"' >> ~/.zshrc +# 2. Install tools +brew install java +sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk +echo 'export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"' >> ~/.zshrc -# brew install node -# brew install firebase-cli -# brew install fastlane -# # Set the local correctly to work with fastlane -# echo 'export LC_ALL=en_US.UTF-8' >> ~/.zshrc -# echo 'export LANG=en_US.UTF-8' >> ~/.zshrc +brew install node +brew install firebase-cli +brew install fastlane +# Set the local correctly to work with fastlane +echo 'export LC_ALL=en_US.UTF-8' >> ~/.zshrc +echo 'export LANG=en_US.UTF-8' >> ~/.zshrc -# brew install git-lfs -# git lfs install -# git lfs install --system +brew install git-lfs +git lfs install +git lfs install --system -# # Ensure that everything on the system is up-to-date -# brew upgrade +# Ensure that everything on the system is up-to-date +brew upgrade # 3. Test and start the firebase emulator @@ -48,12 +48,6 @@ if [ ! -f "firebase.json" ]; then CREATED_FIREBASE_JSON=true cat << 'EOL' > firebase.json { - "firestore": { - "rules": "firestore.rules" - }, - "storage": { - "rules": "firebasestorage.rules" - }, "emulators": { "auth": { "port": 9099 From 54afc9c28e61b1c4da26cf73f239300eedaec405 Mon Sep 17 00:00:00 2001 From: Vishnu Ravi Date: Tue, 7 Jan 2025 16:27:09 -0500 Subject: [PATCH 5/5] Update firebase.json --- Scripts/setup.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/Scripts/setup.sh b/Scripts/setup.sh index 8f39ca2a..ee7750c5 100755 --- a/Scripts/setup.sh +++ b/Scripts/setup.sh @@ -59,9 +59,6 @@ if [ ! -f "firebase.json" ]; then "enabled": true, "port": 4000 }, - "storage": { - "port": 9199 - }, "singleProjectMode": true } }