(options: any)
| 151 | * uses the emulator suite. |
| 152 | */ |
| 153 | export async function beforeEmulatorCommand(options: any): Promise<any> { |
| 154 | const optionsWithDefaultConfig = { |
| 155 | ...options, |
| 156 | config: DEFAULT_CONFIG, |
| 157 | }; |
| 158 | const optionsWithConfig = options.config ? options : optionsWithDefaultConfig; |
| 159 | |
| 160 | // We want to be able to run most emulators even in the absence of |
| 161 | // firebase.json. For Functions and Hosting we require the JSON file since the |
| 162 | // config interactions can become fairly complex. |
| 163 | const canStartWithoutConfig = |
| 164 | options.only && |
| 165 | !controller.shouldStart(optionsWithConfig, Emulators.FUNCTIONS) && |
| 166 | !controller.shouldStart(optionsWithConfig, Emulators.HOSTING); |
| 167 | |
| 168 | // We generally should not check for auth if you are using a demo project since prod calls to a fake project will fail. |
| 169 | // However, extensions makes 'publishers/*' calls that require auth, so we'll requireAuth if you are using extensions. |
| 170 | if ( |
| 171 | !Constants.isDemoProject(options.project) || |
| 172 | controller.shouldStart(optionsWithConfig, Emulators.EXTENSIONS) |
| 173 | ) { |
| 174 | try { |
| 175 | await requireAuth(options); |
| 176 | } catch (e: unknown) { |
| 177 | logger.debug(e as any); |
| 178 | utils.logLabeledWarning( |
| 179 | "emulators", |
| 180 | `You are not currently authenticated so some features may not work correctly. Please run ${clc.bold( |
| 181 | "firebase login", |
| 182 | )} to authenticate the CLI.`, |
| 183 | ); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | if (canStartWithoutConfig && !options.config) { |
| 188 | utils.logWarning("Could not find config (firebase.json) so using defaults."); |
| 189 | options.config = DEFAULT_CONFIG; |
| 190 | } else { |
| 191 | await requireConfig(options); |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Returns a literal port number if specified or true | false if enabled. |
nothing calls this directly
no test coverage detected
searching dependent graphs…