Skip to content

Conversation

@aalej
Copy link
Contributor

@aalej aalej commented Oct 29, 2025

Description

Fixes #9403

Scenarios Tested

Set up on 14.21.0 works, so I'm comparing with that one

Plain - blank

14.21.0 Local repo
firebase init hosting --project fir-support-testproj firebase init hosting --project fir-support-testproj
Do you want to use web framework? No Do you want to use web framework? No
What do you want to use as your public directory? public What do you want to use as your public directory? public
Configure as single-page app? Yes Configure as single-page app? Yes
Set up automatic builds and deploys with GitHub? No Set up automatic builds and deploys with GitHub? No
Directory is setup correctly Directory is setup correctly

Plain - existing

14.21.0 Local repo
firebase init hosting --project fir-support-testproj firebase init hosting --project fir-support-testproj
Do you want to use web framework? No Do you want to use web framework? No
What do you want to use as your public directory? public What do you want to use as your public directory? public
Configure as single-page app? Yes Configure as single-page app? Yes
Set up automatic builds and deploys with GitHub? No File public/index.html already exists. Overwrite? No
File public/index.html already exists. Overwrite? No Set up automatic builds and deploys with GitHub? No
Directory is setup correctly Directory is setup correctly

WebFramework - blank

14.21.0 Local repo
Do you want to use a web framework? Yes Do you want to use a web framework? (experimental) Yes
What folder would you like to use for your web application's root directory? hosting What folder would you like to use for your web application's root directory? hosting
Could not determine the web framework in use.Please choose the framework: React Could not determine the web framework in use.Please choose the framework: React
What language would you like to use? Javascript In which region would you like to host server-side content, if applicable? us-central1 (Iowa)
In which region would you like to host server-side content, if applicable? us-central1 What language would you like to use? JavaScript
Set up automatic builds and deploys with GitHub? No Set up automatic builds and deploys with GitHub? No
Directory is setup correctly Directory is setup correctly

WebFramework - existing

14.21.0 Local repo
Do you want to use a web framework? Yes Do you want to use a web framework? (experimental) Yes
What folder would you like to use for your web application's root directory? hosting What folder would you like to use for your web application's root directory? hosting
Detected an existing Vite codebase in hosting, should we use this? Yes Detected an existing Vite codebase in hosting, should we use this? Yes
In which region would you like to host server-side content, if applicable? us-central1 In which region would you like to host server-side content, if applicable? us-central1 (Iowa)
Set up automatic builds and deploys with GitHub? No Set up automatic builds and deploys with GitHub? No

Sample Commands

firebase init hosting

Notes

The arrangements of the prompts are now a little different

Moved he initGitHub code to actuate

if (await confirm("Set up automatic builds and deploys with GitHub?")) {
    return initGitHub(setup);
  }

since initGitHub uses setup.config.hosting

if (!setup.config.hosting) {
return reject(
`Didn't find a Hosting config in firebase.json. Run ${bold("firebase init hosting")} instead.`,
);
}

which is only set in the actuate method

setup.config.hosting = {
source: hostingInfo.source,
// TODO swap out for framework ignores
ignore: DEFAULT_IGNORES,
frameworksBackend: {
region: hostingInfo.region,
},
};
} else {
setup.config.hosting = {
public: hostingInfo.public,
ignore: DEFAULT_IGNORES,
};


We could also opt for doing

export async function askQuestions(setup: Setup, config: Config, options: Options): Promise<void> {
   ...
   setup.featureInfo.github = await confirm("Set up automatic builds and deploys with GitHub?")
}

so we could do

export async function actuate(setup: Setup, config: Config, options: Options): Promise<void> {
   ...
   if (hostingInfo.github) {
    return initGitHub(setup);
  }
}

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @aalej, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the firebase init hosting command that prevented users from being correctly prompted for essential hosting configuration details, such as the public directory, and caused issues with GitHub integration setup. The changes primarily involve restructuring the initialization logic to ensure that all necessary setup information is properly collected and available at the correct stages of the process, particularly for web framework detection and GitHub Actions configuration. This leads to a more robust and predictable firebase init hosting experience for users.

Highlights

  • Bug Fix: Resolved an issue where the firebase init hosting command would fail to prompt for the public directory and properly set up Hosting files, specifically addressing problem firebase init hosting setup does not prompt for public dir #9403.
  • Logic Reordering for GitHub Integration: The call to initGitHub has been moved from the askQuestions function to the actuate function. This ensures that setup.config.hosting is correctly initialized and available before initGitHub attempts to use it, preventing errors during GitHub Actions setup.
  • Improved Web Framework Prompting Flow: Adjusted the timing and scope of web framework discovery and related prompts within the firebase init hosting process, leading to a more consistent and reliable user experience when initializing projects with web frameworks.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 effectively resolves a logic issue in the firebase init hosting command flow. The primary bug, where prompts for a traditional static hosting setup were incorrectly skipped when the webframeworks experiment was enabled but not chosen by the user, is fixed by restructuring the conditional logic in askQuestions. This ensures the correct prompts are always displayed based on user choice. Furthermore, moving the GitHub Actions initialization prompt to the actuate function is a crucial correction, as it guarantees that the necessary hosting configuration is available, preventing potential errors. The changes are clear, well-justified, and improve the robustness of the initialization process. The code quality is good, and the fix is solid.

As a side note, while reviewing the related initGitHub function, I noticed it seems to access setup.hosting (e.g., setup.hosting.useWebFrameworks), but the hosting setup information appears to be stored in setup.featureInfo.hosting. This is outside the scope of the current changes but might be a pre-existing issue worth investigating in a follow-up.

Copy link
Contributor

@joehan joehan left a comment

Choose a reason for hiding this comment

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

Thank you for fixing this! The testing LGTM, but lets move initGithub out of actuate

"Configure as a single-page app (rewrite all urls to /index.html)?",
);
}
// GitHub Action set up is still structured as doSetup
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we still need to keep this in here instead of allowing it into actuate - initGithub includes interactive prompts, and we need actuate to be safe to run noninteractively

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if can move initGitHub into askQuestions. initGitHub uses setup.config.hosting a couple of times, which is only set during actuate.

if (!setup.config.hosting) {
return reject(
`Didn't find a Hosting config in firebase.json. Run ${bold("firebase init hosting")} instead.`,
);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated, moved initGitHub into askQuestions.

It looks like the only scenario Didn't find a Hosting config in firebase.json will error out is during the setup of a fresh project, otherwise it will correctly pick up the existing config.

During the initial set up with a blank project, I think we can instead use setup.featureInfo?.hosting if setup.config.hosting does not have values

@joehan joehan merged commit e4bcf05 into master Oct 30, 2025
49 of 50 checks passed
@joehan joehan deleted the aalej-inithosting-prompt branch October 30, 2025 22:30
@github-project-automation github-project-automation bot moved this from Approved [PR] to Done in [Cloud] Extensions + Functions Oct 30, 2025
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.

firebase init hosting setup does not prompt for public dir

2 participants