Skip to content

Fixed issue where firebase init hosting re-prompts for source #8617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aalej
Copy link
Contributor

@aalej aalej commented May 16, 2025

Description

Fixes #8587

From what I can tell, the previous behavior of promptOnce and prompt was that, once a question has an answer, we no longer prompt for that question

--- promptOnce

export async function promptOnce<A>(question: Question, options: Options = {}): Promise<A> {
// Need to replace any .'s in the question name - otherwise, Inquirer puts the answer
// in a nested object like so: `"a.b.c" => {a: {b: {c: "my-answer"}}}`
question.name = question.name?.replace(/\./g, "/") || "question";
await prompt(options, [question]);
return options[question.name];

--- prompt

export async function prompt(
options: Options,
// NB: If Observables are to be added here, the for loop below will need to
// be adjusted as well.
questions: ReadonlyArray<inquirer.DistinctQuestion>,
): Promise<any> {
const prompts = [];
// For each of our questions, if Options already has an answer,
// we go ahead and _skip_ that question.
for (const question of questions) {
if (question.name && options[question.name] === undefined) {
prompts.push(question);
}
}
if (prompts.length && options.nonInteractive) {
const missingOptions = Array.from(new Set(prompts.map((p) => p.name))).join(", ");
throw new FirebaseError(
`Missing required options (${missingOptions}) while running in non-interactive mode`,
{
children: prompts,
},
);
}

Scenarios Tested

Verified that the prompts behave the same as the old versions (14.2.2)

14.2.2 behavior

$ firebase --version
14.2.2
$ firebase init hosting --project PROJECT_ID

     ######## #### ########  ######## ########     ###     ######  ########
     ##        ##  ##     ## ##       ##     ##  ##   ##  ##       ##
     ######    ##  ########  ######   ########  #########  ######  ######
     ##        ##  ##    ##  ##       ##     ## ##     ##       ## ##
     ##       #### ##     ## ######## ########  ##     ##  ######  ########

You're about to initialize a Firebase project in this directory:

  /PATH/orbital-osiris

Before we get started, keep in mind:

  * You are currently outside your home directory


=== Project Setup

First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add, 
but for now we'll just set up a default project.

i  Using project PROJECT_ID (PROJECT_NAME)

=== Hosting Setup
? Detected an existing Astro codebase in the current directory, should we use this? Yes
? 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

i  Writing configuration info to firebase.json...
i  Writing project information to .firebaserc...

✔  Firebase initialization complete!

branch behavior

$ firebase --version
14.4.0
$ firebase init hosting --project PROJECT_ID

     ######## #### ########  ######## ########     ###     ######  ########
     ##        ##  ##     ## ##       ##     ##  ##   ##  ##       ##
     ######    ##  ########  ######   ########  #########  ######  ######
     ##        ##  ##    ##  ##       ##     ## ##     ##       ## ##
     ##       #### ##     ## ######## ########  ##     ##  ######  ########

You're about to initialize a Firebase project in this directory:

  /PATH/8587


=== Project Setup

First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add, 
but for now we'll just set up a default project.

i  Using project PROJECT_ID (PROJECT_NAME)

=== Hosting Setup
✔ Detected an existing Astro codebase in the current directory, should we use this? Yes
✔ 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

i  Writing configuration info to firebase.json...
i  Writing project information to .firebaserc...

✔  Firebase initialization complete!

Sample Commands

default: true,
});
setup.hosting.useDiscoveredFramework =
setup.hosting.useDiscoveredFramework ||
Copy link
Member

Choose a reason for hiding this comment

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

You could simplify with ||= here for same effect but you really should be using ?? or ??= here since we want false to be a cachable value

Copy link
Member

Choose a reason for hiding this comment

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

Same feedback for other changed lines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! Will update

@aalej aalej requested a review from jamesdaniels May 16, 2025 17:42
@github-project-automation github-project-automation bot moved this from Changes Requested [PR] to Approved [PR] in [Cloud] Extensions + Functions May 19, 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.

Astro Initialize Hosting - Could not determine the web framework to use
2 participants