handleCheckBilling function
Check Firebase billing plan (Spark vs Blaze).
Implemented in T3 (FirebaseBillingService); the orchestrator gates Cloud Run / cleanup steps on the result via BlazeStatus.enabled.
Implementation
Future<void> handleCheckBilling() async {
final config = await requireFirebaseProjectConfig();
if (config == null) return;
final FirebaseBillingService billing = FirebaseBillingService(
config.firebaseProjectId!,
);
info('Checking billing for ${config.firebaseProjectId}...');
final BillingCheckResult result = await billing.checkBlazeStatus();
switch (result.status) {
case BlazeStatus.enabled:
success('Project is on Blaze (pay-as-you-go).');
if (result.billingAccountName != null) {
print('Linked account: ${result.billingAccountName}');
}
break;
case BlazeStatus.notEnabled:
warn('Project is on Spark. Cloud Run / cleanup features are gated.');
print('');
UserPrompt.printList(<String>[
'Upgrade at: '
'${FirebaseBillingService.upgradeUrl(config.firebaseProjectId!)}',
'Spark covers Hosting, Firestore (small), Auth, Storage (small).',
'Blaze is required for Cloud Run, Artifact Registry cleanup,',
' scheduled jobs, and most production workloads.',
]);
break;
case BlazeStatus.unknown:
error(
'Could not determine billing status: ${result.message ?? 'unknown error'}',
);
print('');
UserPrompt.printList(<String>[
'Verify gcloud is installed and authenticated: `gcloud auth login`',
'Check the project ID in config/setup_config.env',
'You can still continue; Blaze-gated steps will simply be skipped.',
]);
break;
}
}