Skip to content

feat(hosting): ensure Firebase Hosting API is enabled before deploy and Hosting commands - #11296

Merged
bkendall merged 3 commits into
mainfrom
bk-ensure-hosting-api-enabled
Oct 15, 2026
Merged

bkendall merged 3 commits into
mainfrom
bk-ensure-hosting-api-enabled

Conversation

@bkendall

Copy link
Copy Markdown
Contributor

Description

Ensures that the Firebase Hosting API (firebasehosting.googleapis.com) is enabled on the target project(s) before deploying to Firebase Hosting or running hosting:* CLI commands (hosting:channel:*, hosting:sites:*, hosting:clone, hosting:disable).

Scenarios Tested

  • Unit tests for deploy command .before() hook (src/commands/deploy.spec.ts) and Hosting prepare step (src/deploy/hosting/prepare.spec.ts)
  • Unit tests for hosting:clone same-project and cross-project API enablement (src/commands/hosting-clone.spec.ts) and hosting:disable (src/commands/hosting-disable.spec.ts)

Sample Commands

firebase deploy --only hosting
firebase hosting:sites:list
firebase hosting:channel:deploy preview
firebase hosting:clone source-site:staging target-site:live
firebase hosting:disable

…nd Hosting commands

### Description
Ensures that the Firebase Hosting API (`firebasehosting.googleapis.com`) is enabled on the target project(s) before deploying to Firebase Hosting or running `hosting:*` CLI commands (`hosting:channel:*`, `hosting:sites:*`, `hosting:clone`, `hosting:disable`).

### Scenarios Tested
- Unit tests for `deploy` command `.before()` hook (`src/commands/deploy.spec.ts`) and Hosting `prepare` step (`src/deploy/hosting/prepare.spec.ts`)
- Unit tests for `hosting:clone` same-project and cross-project API enablement (`src/commands/hosting-clone.spec.ts`) and `hosting:disable` (`src/commands/hosting-disable.spec.ts`)

### Sample Commands
```bash
firebase deploy --only hosting
firebase hosting:sites:list
firebase hosting:channel:deploy preview
firebase hosting:clone source-site:staging target-site:live
firebase hosting:disable
```

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request ensures that the Firebase Hosting API is enabled before executing various Hosting commands (such as deploy, clone, disable, and channel/site management) by adding API enablement checks. The feedback suggests optimizing the hosting:clone command by running the API enablement checks concurrently using Promise.all, and refactoring the deploy command unit tests to dynamically locate the hosting hook rather than relying on a fragile hardcoded index.

Comment thread src/commands/hosting-clone.ts
Comment thread src/commands/deploy.spec.ts Outdated
@bkendall
bkendall marked this pull request as ready for review October 15, 2026 23:06
Comment thread src/commands/deploy.ts
}

if (options.filteredTargets.includes("hosting")) {
await ensure(needProjectId(options), hostingApiOrigin(), "hosting", true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Do this in the prepare step for hosting instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I have to keep it here. With deferred Hosting, the site may not exist yet, and this is where we check for it. I could (in theory) move this check inside one of the calls here, but... that's fighting about where a single line should go, and this seems okay-ish to me.

Maybe we should push this deferred Hosting logic deeper, but there's dependencies between products I'm unable to think about I'm sure.

@bkendall
bkendall merged commit 57bb89e into main Oct 15, 2026
51 checks passed
@bkendall
bkendall deleted the bk-ensure-hosting-api-enabled branch October 15, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants