Skip to content

Commit

Permalink
feat(firebase): export local data on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
balzdur committed Jun 17, 2024
1 parent 64937f5 commit 7347c05
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ docker-compose.dev.yml

.idea
/.firebase
/firebase-local-data
__debug_bin*

# Use by the Fake GcsRepository
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ Install the [Firebase tools](https://firebase.google.com/docs/emulator-suite):
curl -sL firebase.tools | bash
```

Then copy the `./firebase-local-data.example` folder to `./firebase-local-data`. This folder will be used to store the local data of the Firebase emulator. It is ignored by git.

Then start it using (replace `GOOGLE_CLOUD_PROJECT` with the value from your `.env` file):

```sh
firebase --project GOOGLE_CLOUD_PROJECT emulators:start --import=./firebase-local-data
firebase --project GOOGLE_CLOUD_PROJECT emulators:start --import=./firebase-local-data --export-on-exit
```

> NB: The `--import` flag is used to import the local data into the emulator.
> NB: The `--import` flag is used to import the local data into the emulator. The `--export-on-exit` flag is used to export the data when the emulator is stopped so you don't lose your changes.
### Launch the project

Expand Down
1 change: 1 addition & 0 deletions firebase-local-data.example/auth_export/accounts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"kind":"identitytoolkit#DownloadAccountResponse","users":[{"localId":"Mhfs3QNjO9zpfqbuIg3Ro4M3vUuz","createdAt":"1690820033836","lastLoginAt":"1690821231307","displayName":"Marble admin","photoUrl":"https://media.istockphoto.com/id/544749502/photo/large-marble.jpg?s=612x612&w=0&k=20&c=5Zo5-y3OdQ0L3RWwss7lKgNiK_W7graRlPmV4j9wDUU=","providerUserInfo":[{"providerId":"google.com","rawId":"6616793602105471758262596699004156090238","federatedId":"6616793602105471758262596699004156090238","displayName":"Marble admin","photoUrl":"https://media.istockphoto.com/id/544749502/photo/large-marble.jpg?s=612x612&w=0&k=20&c=5Zo5-y3OdQ0L3RWwss7lKgNiK_W7graRlPmV4j9wDUU=","email":"[email protected]"}],"validSince":"1718638051","email":"[email protected]","emailVerified":true,"disabled":false},{"localId":"bD404UHJjo0DNbzqhsHZoVNBBvcL","createdAt":"1690820180765","lastLoginAt":"1690821274389","displayName":"Jean-Baptiste Emanuel Zorg","photoUrl":"https://img02.imgsinemalar.com/images/karakter_buyuk/10446/Jean-baptiste-Emanuel-Zorg-0.jpg","passwordHash":"fakeHash:salt=fakeSalt1T0nmsEeqFH9cCGv1YqX:password=very-secret","salt":"fakeSalt1T0nmsEeqFH9cCGv1YqX","passwordUpdatedAt":1718638051371,"providerUserInfo":[{"providerId":"google.com","rawId":"1814841806696016153489550872216860403245","federatedId":"1814841806696016153489550872216860403245","displayName":"Jean-Baptiste Emanuel Zorg","photoUrl":"https://img02.imgsinemalar.com/images/karakter_buyuk/10446/Jean-baptiste-Emanuel-Zorg-0.jpg","email":"[email protected]"},{"providerId":"password","email":"[email protected]","federatedId":"[email protected]","rawId":"[email protected]","displayName":"Jean-Baptiste Emanuel Zorg","photoUrl":"https://img02.imgsinemalar.com/images/karakter_buyuk/10446/Jean-baptiste-Emanuel-Zorg-0.jpg"}],"validSince":"1718638051","email":"[email protected]","emailVerified":true,"disabled":false}]}
1 change: 1 addition & 0 deletions firebase-local-data.example/auth_export/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"signIn":{"allowDuplicateEmails":false},"emailPrivacyConfig":{"enableImprovedEmailPrivacy":false}}
7 changes: 7 additions & 0 deletions firebase-local-data.example/firebase-export-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"version": "13.2.1",
"auth": {
"version": "13.2.1",
"path": "auth_export"
}
}
1 change: 0 additions & 1 deletion firebase-local-data/auth_export/accounts.json

This file was deleted.

1 change: 0 additions & 1 deletion firebase-local-data/auth_export/config.json

This file was deleted.

7 changes: 0 additions & 7 deletions firebase-local-data/firebase-export-metadata.json

This file was deleted.

0 comments on commit 7347c05

Please sign in to comment.