Menu

How to create firebase’s web site

2018-07-17 - Firebase

Hosting

npm install -g firebase-tools;
mkdir -p skensaku/public_html;
cd skensaku/public_html;
firebase login;
firebase init;
firebase deploy;

Use different environment

You should do it by creating multiple environment.
For example, in the case of stg environment

firebase use stg;

#confirmation
firebase use;

#deploy
firebase deploy -p stg;

You also have to change the config’s content based on the localhost.hostname.

Add functions

npm install -g firebase-tools;
firebase login;
firebase init functions;
firebase deploy --only functions;

Worked rule memo

service cloud.firestore {
  match /databases/{database}/documents {
    match /favorites/{favorite} {
      allow read: if true;
      allow write: if true;
    }
  }
}

Get auth user list

firebase auth:export /tmp/userlist.json --format=json

If you want to create code by yourself, please refer to hhttps://firebase.google.com/docs/auth/admin/manage-users

Import user into firebase

You have to got to web console’ s auth screen and have to get necessary information like hash key

firebase auth:import /tmp/userlist.json --rounds=8 --mem-cost=14 --hash-key= --salt-separator=

Reference

https://firebase.google.com/docs/functions/write-firebase-functions


Export firestore table’s content

git clone https://github.com/dalenguyen/firestore-import-export.git
ln -s firestore-import-export.git bin;

edit
firestore-import-export/serviceAccountKey.json
to include credential which you can get from web console’s setting of the project.

node bin/export.js vpsCourses;perl -e 'use FileHandle;my $fh=new FileHandle("firestore-export.json");local $/=undef;my $con=<$fh>;$fh->close();$con=~ s!,"!,\n"!gs;my $wfh=new FileHandle("> /tmp/write.txt");print $wfh $con;$wfh->close();rename("/tmp/write.txt", "firestore-export.json");';mv firestore-export.json data/`date +%Y%m%d`.json;

Import json into firestore

example

node bin/import.js data/edited_20181026.json