firebase / firebase/firebase-tools
deploy: pre-flight Blaze-tier check + surface tier requirement in firebase init (avoid wasted deploys)
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 84
Description
### Which command?
deploy
### Version info
firebase-tools 15.22.3
### Platform
All (behaviour is deploy-time-only, platform-independent)
### CLI/emulator log
```
Error: Cloud Functions deployment requires the pay-as-you-go (Blaze) billing plan. To upgrade your project, visit the following URL:
https://console.firebase.google.com/project//usage/details
```
### Reproduction steps
1. On a project on the free Spark plan, run `firebase init functions` (or add Cloud Functions, Extensions, or a Data Connect service).
2. Write code. Run `firebase deploy`.
3. Deploy proceeds through TS/JS build, packaging, artifact upload, and only then — after minutes of work — fails at `cloudBuildEnabled` (see `src/deploy/functions/ensure.ts`, `nodeBillingError`) with the Blaze-required error.
The same pattern exists for Extensions (`src/extensions/checkProjectBilling.ts`) and Data Connect / Cloud SQL provisioning (`src/dataconnect/provisionCloudSql.ts` calls `cloudbilling.checkBillingEnabled`). Each surface only detects the tier mismatch after significant work — never at `firebase init` time, and never up-front in `firebase deploy`.
### Expected behavior
Two additive fixes, both cheap:
1. **Pre-flight billing check in `deploy` prepare phase.** Before `prepare.ts` triggers builds, call `cloudbilling.checkBillingEnabled(projectId)` once. If the plan is Spark and the plan targets features known to require Blaze (Cloud Functions of any generation, Extensions, Data Connect with Cloud SQL, App Hosting), fail fast with the same Blaze error. Skips minutes of wasted CPU/network on every doomed deploy.
2. **Tier badge in `firebase init`.** When the user picks a feature that requires Blaze, print an inline note (`requires the Blaze billing plan`) next to the choice — the same wording `nodeBillingError` produces at deploy time. Right now the tier requirement is invisible until first deploy fails.
Both changes reuse existing helpers (`cloudbilling.checkBillingEnabled`, `nodeBillingError`) — no new API surface, no new dependencies. Feature-to-tier mapping already implicit in the code; just needs to be surfaced.
Files: `src/deploy/functions/prepare.ts`, `src/deploy/functions/ensure.ts`, `src/init/features/**` (per-feature init prompts), `src/gcp/cloudbilling.ts` (helper, no change).
Contributor guide
Research direction
Start in src/deploy/functions/prepare.ts and trace how deployment preparation triggers builds, then inspect src/deploy/functions/ensure.ts and nodeBillingError for the existing Blaze failure. Compare the billing flow with src/extensions/checkProjectBilling.ts and src/dataconnect/provisionCloudSql.ts, then review src/init/features/** for feature prompts. Done means eligible deploys fail before build work and Blaze-required init choices show the specified note.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, cloud
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100