From 7347c050379b83b8790198b0faf0b0960e6c955a Mon Sep 17 00:00:00 2001 From: Thomas Lathuiliere Date: Mon, 17 Jun 2024 17:33:59 +0200 Subject: [PATCH] feat(firebase): export local data on exit --- .gitignore | 1 + README.md | 6 ++++-- firebase-local-data.example/auth_export/accounts.json | 1 + firebase-local-data.example/auth_export/config.json | 1 + firebase-local-data.example/firebase-export-metadata.json | 7 +++++++ firebase-local-data/auth_export/accounts.json | 1 - firebase-local-data/auth_export/config.json | 1 - firebase-local-data/firebase-export-metadata.json | 7 ------- 8 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 firebase-local-data.example/auth_export/accounts.json create mode 100644 firebase-local-data.example/auth_export/config.json create mode 100644 firebase-local-data.example/firebase-export-metadata.json delete mode 100644 firebase-local-data/auth_export/accounts.json delete mode 100644 firebase-local-data/auth_export/config.json delete mode 100644 firebase-local-data/firebase-export-metadata.json diff --git a/.gitignore b/.gitignore index 2c75b9f3c..47bb267bb 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ docker-compose.dev.yml .idea /.firebase +/firebase-local-data __debug_bin* # Use by the Fake GcsRepository diff --git a/README.md b/README.md index e33d9315f..2b23b49cc 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/firebase-local-data.example/auth_export/accounts.json b/firebase-local-data.example/auth_export/accounts.json new file mode 100644 index 000000000..1cfad5e5c --- /dev/null +++ b/firebase-local-data.example/auth_export/accounts.json @@ -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":"admin@checkmarble.com"}],"validSince":"1718638051","email":"admin@checkmarble.com","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":"jbe@zorg.com"},{"providerId":"password","email":"jbe@zorg.com","federatedId":"jbe@zorg.com","rawId":"jbe@zorg.com","displayName":"Jean-Baptiste Emanuel Zorg","photoUrl":"https://img02.imgsinemalar.com/images/karakter_buyuk/10446/Jean-baptiste-Emanuel-Zorg-0.jpg"}],"validSince":"1718638051","email":"jbe@zorg.com","emailVerified":true,"disabled":false}]} \ No newline at end of file diff --git a/firebase-local-data.example/auth_export/config.json b/firebase-local-data.example/auth_export/config.json new file mode 100644 index 000000000..6f240f7e9 --- /dev/null +++ b/firebase-local-data.example/auth_export/config.json @@ -0,0 +1 @@ +{"signIn":{"allowDuplicateEmails":false},"emailPrivacyConfig":{"enableImprovedEmailPrivacy":false}} \ No newline at end of file diff --git a/firebase-local-data.example/firebase-export-metadata.json b/firebase-local-data.example/firebase-export-metadata.json new file mode 100644 index 000000000..7e767adc8 --- /dev/null +++ b/firebase-local-data.example/firebase-export-metadata.json @@ -0,0 +1,7 @@ +{ + "version": "13.2.1", + "auth": { + "version": "13.2.1", + "path": "auth_export" + } +} \ No newline at end of file diff --git a/firebase-local-data/auth_export/accounts.json b/firebase-local-data/auth_export/accounts.json deleted file mode 100644 index 1a3702548..000000000 --- a/firebase-local-data/auth_export/accounts.json +++ /dev/null @@ -1 +0,0 @@ -{"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=","salt":"fakeSaltlEWpfBFXHXYKGxpuiwP1","passwordUpdatedAt":1690821189274,"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":"admin@checkmarble.com"}],"validSince":"1690821231","email":"admin@checkmarble.com","emailVerified":true,"disabled":false,"lastRefreshAt":"2023-07-31T16:33:51.307Z"},{"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","salt":"fakeSalt1T0nmsEeqFH9cCGv1YqX","passwordUpdatedAt":1690821285295,"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":"jbe@zorg.com"},{"providerId":"password","email":"jbe@zorg.com","federatedId":"jbe@zorg.com","rawId":"jbe@zorg.com","displayName":"Jean-Baptiste Emanuel Zorg","photoUrl":"https://img02.imgsinemalar.com/images/karakter_buyuk/10446/Jean-baptiste-Emanuel-Zorg-0.jpg"}],"validSince":"1690821285","email":"jbe@zorg.com","emailVerified":true,"disabled":false,"lastRefreshAt":"2023-07-31T16:34:45.296Z","passwordHash":"fakeHash:salt=fakeSalt1T0nmsEeqFH9cCGv1YqX:password=very-secret","customAttributes":""}]} \ No newline at end of file diff --git a/firebase-local-data/auth_export/config.json b/firebase-local-data/auth_export/config.json deleted file mode 100644 index 8f77af980..000000000 --- a/firebase-local-data/auth_export/config.json +++ /dev/null @@ -1 +0,0 @@ -{"signIn":{"allowDuplicateEmails":false}} \ No newline at end of file diff --git a/firebase-local-data/firebase-export-metadata.json b/firebase-local-data/firebase-export-metadata.json deleted file mode 100644 index 91864c775..000000000 --- a/firebase-local-data/firebase-export-metadata.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": "12.4.6", - "auth": { - "version": "12.4.6", - "path": "auth_export" - } -} \ No newline at end of file