Skip to content
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

Added validation for project id and project name #8057

Merged
merged 2 commits into from
Dec 12, 2024
Merged

Conversation

aalej
Copy link
Contributor

@aalej aalej commented Dec 12, 2024

Description

Fixes #2514

Inquirer will not accept the input until the validation passes. Instead, an error message is displayed at the bottom

Scenarios Tested

  1. Project ID too short
$ firebase init

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

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

  /Users/PATH/firebase-tools/test-apps/validate-project-id

? Which Firebase features do you want to set up for this directory? Press Space to select features, then Enter to confirm your choices. Data Connect: Set up a Firebase
 Data Connect service

=== 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.

? Please select an option: Create a new project
i  If you want to create a project in a Google Cloud organization or folder, please use "firebase projects:create" instead, and return to this command when you've created the project.
? Please specify a unique project id (warning: cannot be modified afterward) [6-30 characters]:
 abcde
>> Project ID must be at least 6 characters long
  1. Project name too short
$ firebase init

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

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

  /Users/alejandromarco/Desktop/firebase-tools/test-apps/validate-project-id

? Which Firebase features do you want to set up for this directory? Press Space to select features, then Enter to confirm your choices. Data Connect: Set up a Firebase
 Data Connect service

=== 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.

? Please select an option: Create a new project
i  If you want to create a project in a Google Cloud organization or folder, please use "firebase projects:create" instead, and return to this command when you've created the project.
? Please specify a unique project id (warning: cannot be modified afterward) [6-30 characters]:
 asfasf
? What would you like to call your project? (defaults to your project ID) asf
>> Project name must be at least 4 characters long

Sample Commands

@joehan joehan enabled auto-merge (squash) December 12, 2024 22:23
@joehan joehan merged commit 9805e5a into master Dec 12, 2024
42 of 46 checks passed
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.

CLI errors out when project name is less than 5 chars
2 participants