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

Implement support for demo project ID namespace #3291

Merged
merged 6 commits into from Apr 21, 2021
Merged

Conversation

samtstern
Copy link
Contributor

Description

When the project ID begins with demo- (which is invalid in GCP) then we make up the Web and Admin SDK configs.

Scenarios Tested

Project: demo-project-1234

 firebase --project=demo-project-1234 emulators:start
i  emulators: Starting emulators: functions, firestore, hosting
i  emulators: Detected fake project ID "demo-project-1234", emulated services will use a demo configuration and non-emulated services will fail.
✔  functions: Using node@12 from host.
⚠  firestore: Did not find a Cloud Firestore rules file specified in a firebase.json config file.
⚠  firestore: The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration.
i  firestore: Firestore Emulator logging to firestore-debug.log
i  hosting: Serving hosting files from: public
✔  hosting: Local server: http://localhost:5000
⚠  ui: Emulator UI unable to start on port 4000, starting on 4001 instead.
i  ui: Emulator UI logging to ui-debug.log
i  functions: Watching "/private/var/folders/xl/6lkrzp7j07581mw8_4dlt3b000643s/T/tmp.ZAg8Flx4/functions" for Cloud Functions...
✔  functions[helloWorld]: http function initialized (http://localhost:5001/demo-project-1234/us-central1/helloWorld).

┌─────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is now safe to connect your app. │
│ i  View Emulator UI at http://localhost:4001                │
└─────────────────────────────────────────────────────────────┘

┌───────────┬────────────────┬─────────────────────────────────┐
│ Emulator  │ Host:Port      │ View in Emulator UI             │
├───────────┼────────────────┼─────────────────────────────────┤
│ Functions │ localhost:5001 │ http://localhost:4001/functions │
├───────────┼────────────────┼─────────────────────────────────┤
│ Firestore │ localhost:8080 │ http://localhost:4001/firestore │
├───────────┼────────────────┼─────────────────────────────────┤
│ Hosting   │ localhost:5000 │ n/a                             │
└───────────┴────────────────┴─────────────────────────────────┘
  Emulator Hub running at localhost:4400
  Other reserved ports: 4500

Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.

Project: fake-project-1234

$ firebase --project=fake-project-1234 emulators:start
i  emulators: Starting emulators: functions, firestore, hosting
⚠  functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, database, pubsub, storage
✔  functions: Using node@12 from host.
⚠  functions: Unable to fetch project Admin SDK configuration, Admin SDK behavior in Cloud Functions emulator may be incorrect.
⚠  firestore: Did not find a Cloud Firestore rules file specified in a firebase.json config file.
⚠  firestore: The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration.
i  firestore: Firestore Emulator logging to firestore-debug.log
⚠  hosting: Authentication error when trying to fetch your current web app configuration, have you run firebase login?
⚠  hosting: Could not fetch web app configuration and there is no cached configuration on this machine. Check your internet connection and make sure you are authenticated. To continue, you must call firebase.initializeApp({...}) in your code before using Firebase.
i  hosting: Serving hosting files from: public
✔  hosting: Local server: http://localhost:5000
⚠  ui: Emulator UI unable to start on port 4000, starting on 4001 instead.
i  ui: Emulator UI logging to ui-debug.log
i  functions: Watching "/private/var/folders/xl/6lkrzp7j07581mw8_4dlt3b000643s/T/tmp.ZAg8Flx4/functions" for Cloud Functions...
✔  functions[helloWorld]: http function initialized (http://localhost:5001/fake-project-1234/us-central1/helloWorld).

┌─────────────────────────────────────────────────────────────┐
│ ✔  All emulators ready! It is now safe to connect your app. │
│ i  View Emulator UI at http://localhost:4001                │
└─────────────────────────────────────────────────────────────┘

┌───────────┬────────────────┬─────────────────────────────────┐
│ Emulator  │ Host:Port      │ View in Emulator UI             │
├───────────┼────────────────┼─────────────────────────────────┤
│ Functions │ localhost:5001 │ http://localhost:4001/functions │
├───────────┼────────────────┼─────────────────────────────────┤
│ Firestore │ localhost:8080 │ http://localhost:4001/firestore │
├───────────┼────────────────┼─────────────────────────────────┤
│ Hosting   │ localhost:5000 │ n/a                             │
└───────────┴────────────────┴─────────────────────────────────┘
  Emulator Hub running at localhost:4400
  Other reserved ports: 4500

Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.
 

Sample Commands

N/A

@google-cla google-cla bot added the cla: yes Manual indication that this has passed CLA. label Apr 19, 2021
@samtstern
Copy link
Contributor Author

cc @markarndt if we do merge this, this will be something we'll want to add a docs section about. Happy to explain more about it to you when it's that time.

But also no rush because it will be an invisible change until we document it.

CHANGELOG.md Outdated Show resolved Hide resolved
src/emulator/constants.ts Outdated Show resolved Hide resolved
src/emulator/controller.ts Outdated Show resolved Hide resolved
@samtstern samtstern merged commit 2fbb636 into master Apr 21, 2021
@markgoho
Copy link

markgoho commented May 5, 2021

@samtstern looks like this just got released, where can we find the docs?

@samtstern
Copy link
Contributor Author

@markgoho we're working on the docs!

@laurentpayot
Copy link

Hi, any docs available at this time? 👀

@samtstern
Copy link
Contributor Author

@laurentpayot docs here:
https://firebase.google.com/docs/emulator-suite/connect_firestore#choose_a_firebase_project

@laurentpayot
Copy link

@samtstern Awesome. Right now I’m developing using a project with a -dev suffix. The production project has no suffix. I will see if transitioning to a demo project instead of the -dev project has unintended effects.

@bkendall bkendall deleted the ss-demo-project-id branch August 4, 2021 19:27
devpeerapong pushed a commit to devpeerapong/firebase-tools that referenced this pull request Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Manual indication that this has passed CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants