(setup: Setup, config: Config)
| 134 | * @param config legacy config parameter. not used for database setup. |
| 135 | */ |
| 136 | export async function askQuestions(setup: Setup, config: Config): Promise<void> { |
| 137 | logger.info(); |
| 138 | logger.info( |
| 139 | "Firebase Realtime Database Security Rules allow you to define how your data should be", |
| 140 | ); |
| 141 | logger.info("structured and when your data can be read from and written to."); |
| 142 | logger.info(); |
| 143 | |
| 144 | const rulesFilename = await input({ |
| 145 | message: "What file should be used for Realtime Database Security Rules?", |
| 146 | default: DEFAULT_RULES_FILENAME, |
| 147 | }); |
| 148 | if (!rulesFilename) { |
| 149 | throw new FirebaseError("Must specify location for Realtime Database rules file."); |
| 150 | } |
| 151 | const info: RequiredInfo = { |
| 152 | rulesFilename, |
| 153 | rules: DEFAULT_RULES, |
| 154 | writeRules: true, |
| 155 | }; |
| 156 | if (setup.projectId) { |
| 157 | const instanceDetails = await initializeDatabaseInstance(setup.projectId); |
| 158 | if (instanceDetails) { |
| 159 | info.rules = await getDBRules(instanceDetails); |
| 160 | utils.logBullet( |
| 161 | `Downloaded the existing Realtime Database Security Rules of database ${clc.bold(instanceDetails.name)} from the Firebase console`, |
| 162 | ); |
| 163 | } |
| 164 | } |
| 165 | info.writeRules = await config.confirmWriteProjectFile(rulesFilename, info.rules); |
| 166 | // Populate featureInfo for the actuate step later. |
| 167 | setup.featureInfo = setup.featureInfo || {}; |
| 168 | setup.featureInfo.database = info; |
| 169 | } |
| 170 | |
| 171 | export async function actuate(setup: Setup, config: Config): Promise<void> { |
| 172 | const info = setup.featureInfo?.database; |
nothing calls this directly
no test coverage detected
searching dependent graphs…