Skip to content

Add validation for feature selection - #8716

Merged
joehan merged 2 commits into
masterfrom
aalej-init-feature-validate
Jun 6, 2025
Merged

Add validation for feature selection#8716
joehan merged 2 commits into
masterfrom
aalej-init-feature-validate

Conversation

@aalej

@aalej aalej commented Jun 6, 2025

Copy link
Copy Markdown
Contributor

Description

FIxes #5232

With the validation, the scenario if (!setup.features || setup.features?.length === 0) is very unlikely to happen, but just in case it does, it might be a good idea to keep

if (!setup.features || setup.features?.length === 0) {
throw new FirebaseError(
"Must select at least one feature. Use " +
clc.bold(clc.underline("SPACEBAR")) +
" to select features, or specify a feature by running " +
clc.bold("firebase init [feature_name]"),
);
}

Scenarios Tested

Run firebase init then press enter without selecting any features

$ firebase init

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

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

  /Users/PATH/Desktop/firebase-tools/issues/5232

Before we get started, keep in mind:

  * You are initializing within an existing Firebase project directory

? Which Firebase features do you want to set up for this directory? Press Space to select features, then Enter to confirm your choices. (Press <space> to select, <a> to toggle
 all, <i> to invert selection, and <enter> to proceed)
❯◯ Data Connect: Set up a Firebase Data Connect service
 ◯ Firestore: Configure security rules and indexes files for Firestore
 ◯ Genkit: Setup a new Genkit project with Firebase
 ◯ Functions: Configure a Cloud Functions directory and its files
 ◯ App Hosting: Enable web app deployments with App Hosting
 ◯ Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys
 ◯ Storage: Configure a security rules file for Cloud Storage
> Must select at least one feature. Use SPACEBAR to select features, or specify a feature by running firebase init [feature_name]

Sample Commands

@aalej
aalej requested a review from joehan June 6, 2025 13:09
@joehan
joehan enabled auto-merge (squash) June 6, 2025 20:08
@joehan
joehan merged commit 0914871 into master Jun 6, 2025
@joehan
joehan deleted the aalej-init-feature-validate branch June 6, 2025 20:09
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 aborts when no feature is selected

2 participants