runConfigureClient method

Future<SetupStepResult> runConfigureClient()

Implementation

Future<SetupStepResult> runConfigureClient() async {
  final bool ok = await firebase.configureFlutterFire();
  if (ok) {
    return SetupStepResult.success(WizardSubStep.configureClient);
  }
  return SetupStepResult.failed(
    WizardSubStep.configureClient,
    message: config.template.isJasprApp
        // The Jaspr path runs `firebase apps:list WEB` + `apps:create WEB`
        // through `_runFirebaseWithRecovery`, which already auto-enables the
        // Firebase Management API and retries transient failures. If we
        // landed here anyway, the failure is one of:
        //   • The service account is missing IAM roles even after the gate
        //     in step 5.4 (e.g., `firebase.apps.create`,
        //     `serviceusage.services.enable`).
        //   • Firebase Management API is enabled but still propagating —
        //     re-running in 30-60 seconds will succeed.
        //   • A non-recoverable error (project deleted, billing issue,
        //     org policy block). The verbose logs above show the root
        //     cause from firebase-debug.log.
        ? 'Could not inject Firebase JS SDK into Jaspr index.html. '
              'See the warning above for the root cause from '
              'firebase-debug.log. Common fixes:\n'
              '  • Wait 30-60s and retry — the Firebase Management API may '
              'still be propagating after enable.\n'
              '  • Run `oracular deploy firebase-setup-full` to re-run the '
              'IAM gate (step 5.4) and retry this step.\n'
              '  • Verify the service account has the firebase-setup-full '
              'IAM bundle on this project.'
        : 'flutterfire configure did not complete successfully',
    fixHint: _fixHintFor(WizardSubStep.configureClient),
  );
}