Conversation
|
@yuchenshi @abeisgoat apologies this PR got a little larger than I would have liked because it involved implementing the hub and also some new end-to-end testing logic. The core is not too complex though. |
| `Found running emulator hub for project ${clc.bold(projectId)} at ${hubOrigin}` | ||
| ); | ||
|
|
||
| // If the export target directory does not exist, we should attempt to create it |
|
|
||
| // Remove all existing data (metadata.json will be overwritten automatically) | ||
| if (existingMetadata) { | ||
| if (existingMetadata.firestore) { |
Co-Authored-By: Yuchen Shi <yuchenshi@google.com>
|
PLEASE IGNORE - EDIT - Turns out I had moved my partial exports from their original root folder. All works now, thanks for working on this really useful feature @samtstern ! I've exported my "production" Firestore data using I've added this to my firebase project in a seed folder, and have added a When I attempt to start only the Firestore emulator ( Any ideas? My Firestore export has not been changed from what was exported thru gcloud CLI. |
|
@dazziola could you please file a new issue for this? Also we'll need the following extra info:
Thanks! |
Description
(Fixes #1167)
TODO:
This pull request imports import/export, currently only supporting the Firestore emulator but doing so in a general way.
Emulator Hub
This PR introduces the "emulator hub" which is a new local service that has the same behavior patterns as any other emulator but does not emulate a real Firebase service. Instead it is a local REST API which can be used for controlling running emulators.
When the hub starts it writes a file to
/tmp/hub-$PROJECTID.jsonthat looks like this:{"version":"7.12.1","host":"localhost","port":4000}This allows other instances of the CLI to discover where the hub is running for a given project. As of this PR the hub exposes two endpoints:
GET /Used for a hub health check. Returns exactly what is in the tmp json file above.
POST /_admin/exportKick off a data export of all running emulators. Takes a JSON body with a single
pathfield.These endpoints are not considered a public API at this time, although they may be one in the future.
Import data
This adds a new
--importflag to bothemulators:startandemulators:execExport data
Adds a new command
firebase emulators:exportwhich discovers the emulator hub of another running emulators process and hits the admin export endpoint.Scenarios Tested
Start with import
Export (clean)
Export (overwrite prompt)
Export (--force)
Sample Commands
See above (scenarios tested)