firebase-tools: Allow emulators to export on exit

Originally requested through FIrebase support, there is some demand for a flag like this:

firebase emulators:start --import=./seed --export-on-exit

This would import from a location but save any mutations made on exit.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 12
  • Comments: 19 (14 by maintainers)

Most upvoted comments

@michi88 thanks for asking all the right questions. My personal take:

  • I like the name --export-on-exit

  • I think it should take an optional path --export-on-exit=./some-path. When unspecified it would use the same path as --import. If you do a bare --export-on-exit with no --import=something flag that’s an error. So:

    • ✅ VALID: emulators:start --import=./foo --export-on-exit
    • ✅ VALID: emulators:start --import=./foo --export-on-exit=./bar
    • ✅ VALID: emulators:start --export-on-exit=./bar
    • ❌ NOT VALID: emulators:start --export-on-exit

If that sounds good to you I’ll propose it to the API people.

Waiting with anticipation. I didn’t realise that data was not saved automatically after restarting and was wondering what was wrong with my app until I checked the db, I’m glad I’m not crazy.

@michi88 totally makes sense, although right now we do want import and export to feel explicit and separate for the reason you said: they’re one-time expensive operations. Something like --data-dir implies that these emulators have a persistence layer, which they do not.

I’ll go ahead and kick this off.