55const process = require ( "process" ) ;
66const { createInterface } = require ( "readline" ) ;
77const admin = require ( "firebase-admin" ) ;
8+ const { getAuth } = require ( "firebase-admin/auth" ) ;
9+ const { getDatabase } = require ( "firebase-admin/database" ) ;
10+ const firestoreModule = require ( "firebase-admin/firestore" ) ;
11+ const { getStorage } = require ( "firebase-admin/storage" ) ;
812const { writeFileSync, existsSync, readFileSync } = require ( "fs" ) ;
913const { join, normalize } = require ( "path" ) ;
1014const { getProjectInfo } = require ( "../utils/getProjectInfo" ) ;
@@ -101,7 +105,7 @@ const app = admin.initializeApp({
101105 authDomain : `${ projectInfo . serviceAccount . project_id } .firebaseapp.com` ,
102106 databaseURL : `https://${ projectInfo . serviceAccount . project_id } .firebaseio.com` ,
103107 storageBucket : `${ projectInfo . serviceAccount . project_id } .appspot.com` ,
104- credential : admin . credential . cert ( projectInfo . serviceAccount ) ,
108+ credential : admin . cert ( projectInfo . serviceAccount ) ,
105109} ) ;
106110
107111function help ( ) {
@@ -113,46 +117,46 @@ fastcommands.push({
113117 alias : "help()" ,
114118} ) ;
115119
116- const auth = admin . auth ( ) ;
120+ const auth = getAuth ( app ) ;
117121fastcommands . push ( {
118122 command : "auth" ,
119123 title : "Сall firebase authorization interface" ,
120- alias : "admin.auth( )" ,
124+ alias : "getAuth(app )" ,
121125} ) ;
122126
123- const rtdb = admin . database ( ) ;
127+ const rtdb = getDatabase ( app ) ;
124128fastcommands . push ( {
125129 command : "rtdb" ,
126130 title : "Сall firebase database interface" ,
127- alias : "admin.database( )" ,
131+ alias : "getDatabase(app )" ,
128132} ) ;
129133
130- const db = admin . firestore ( ) ;
134+ const db = firestoreModule . getFirestore ( app ) ;
131135fastcommands . push ( {
132136 command : "db" ,
133137 title : "Сall firebase firestore interface" ,
134- alias : "admin.firestore( )" ,
138+ alias : "getFirestore(app )" ,
135139} ) ;
136140
137- const storage = admin . storage ( ) ;
141+ const storage = getStorage ( app ) ;
138142fastcommands . push ( {
139143 command : "storage" ,
140144 title : "Сall firebase storage interface" ,
141- alias : `admin.storage( )` ,
145+ alias : `getStorage(app )` ,
142146} ) ;
143147
144- const bucket = admin . storage ( ) . bucket ( ) ;
148+ const bucket = getStorage ( app ) . bucket ( ) ;
145149fastcommands . push ( {
146150 command : "bucket" ,
147151 title : "Сall firebase storage/bucket interface" ,
148- alias : `admin.storage( ).bucket()` ,
152+ alias : `getStorage(app ).bucket()` ,
149153} ) ;
150154
151- const types = admin . firestore ;
155+ const types = firestoreModule ;
152156fastcommands . push ( {
153157 command : "types" ,
154158 title : "Сall firebase firestore types interface" ,
155- alias : "admin. firestore" ,
159+ alias : "require('firebase- admin/ firestore') " ,
156160} ) ;
157161
158162const tools = Object . freeze ( {
0 commit comments