enableGoogleApis method

Future<bool> enableGoogleApis()

Enable Google Cloud APIs needed for deployment

Implementation

Future<bool> enableGoogleApis() async {
  if (config.firebaseProjectId == null) {
    error('Firebase project ID not set');
    return false;
  }

  info('Enabling Google Cloud APIs...');

  bool allOk = true;

  // Enable Artifact Registry
  ProcessResult result = await _runner.run('gcloud', <String>[
    'services',
    'enable',
    'artifactregistry.googleapis.com',
    '--project',
    config.firebaseProjectId!,
  ], environment: _authEnvironment);

  if (!result.success) {
    warn(
      'Failed to enable Artifact Registry API: ${_stripAnsi(result.stderr).trim()}',
    );
    allOk = false;
  }

  // Enable Cloud Run
  result = await _runner.run('gcloud', <String>[
    'services',
    'enable',
    'run.googleapis.com',
    '--project',
    config.firebaseProjectId!,
  ], environment: _authEnvironment);

  if (!result.success) {
    warn(
      'Failed to enable Cloud Run API: ${_stripAnsi(result.stderr).trim()}',
    );
    allOk = false;
  }

  return allOk;
}