Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase Local Emulator #256

Closed

Conversation

n0rthk1n9
Copy link

What it Does

How I Tested

  • Make sure Node v 8.0 or higher is installed
  • Make sure Openjdk v 11 or higher is installed (If you installed it via brew, don't forget to add the executable to $PATH, brew will output it as a handy command to execute for you)
  • Make sure firebase-cli is installed (npm install -g firebase-tools)
  • Make sure you ran firebase login and authenticated successfully
  • Go to backend/Basic-Car-Maintenance and run firebase emulators:start
  • Now every request from the app should go against the emulator
  • In the emulator UI at http://127.0.0.1:4000/ you can check if the data you added in the app is added in the emulated Firestore

Notes

  • Anything else that should be noted about how you implemented this feature?

Screenshot

SCR-20231031-mvu

Copy link
Owner

@mikaelacaron mikaelacaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!! I haven't tested this because I haven't downloaded everything

  • Make sure Node v 8.0 or higher is installed
  • Make sure Openjdk v 11 or higher is installed (If you installed it via brew, don't forget to add the executable to $PATH, brew will output it as a handy command to execute for you)
  • Make sure firebase-cli is installed (npm install -g firebase-tools)

Can you note the best way to download these? (Preferably with Homebrew) Also I have a few questions, you can comment directly in that thread

Comment on lines +76 to +81
<CommandLineArguments>
<CommandLineArgument
argument = "-useEmulator YES"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would this flag need to be enabled vs disabled? Only when wanting to use the emulator? Otherwise it would be unchecked, which would default to using the real project?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly

Comment on lines +40 to +41
let useEmulator = UserDefaults.standard.bool(forKey: "useEmulator")
if useEmulator {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use UseDefaults, as opposed to the command line argument?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly I don't have a better answer to that question than "Because Peter recommended it doing it like that in his article" But I guess it could also be done via command line arguments, if you prefer that :)

@mikaelacaron mikaelacaron added the hacktoberfest-accepted Accepted PR for Hacktoberfest label Nov 4, 2023
@n0rthk1n9
Copy link
Author

The best way to install all the requirements is indeed via homebrew:

  1. brew install nvm (Installs node version manager, so you don't need to update the system node version)
  2. nvm install stable and nvm use stable to download and set the last stable node version
  3. brew install openjdk to install openjdk. Add the executable to the $PATH via .zshrc or .bashrc file as prompted after installation
  4. npm install -g firebase-tools

With that all prerequisites should be installed. Let me know if anything doesn't work

@mikaelacaron
Copy link
Owner

Thanks so much for all the help on this! I'm finally getting around to implementing it

I'm going to close your PR because I'm working on this on a separate branch, because I'm also updating a few other things.

Your steps were super helpful to finally get this running!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Accepted PR for Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup the Firebase Local Emulator
2 participants