Skip to content

Conversation

bkendall
Copy link
Contributor

@bkendall bkendall commented Nov 3, 2023

Description

Adds an experiment for and logic to detect when a hosting site isn't available and prompt to create one when able.

  • firebase init <hosting> prompt to create a site if one is not available
  • firebase deploy prompt to create site if one is not available
  • firebase hosting:channel:* will fail if no Hosting site exists

Scenarios Tested

All of the above

Sample Commands

» firebase --project xxxxxxxxxx-01 init hosting

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

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

  xxxxxxxxxx

Before we get started, keep in mind:

  * You are initializing within an existing Firebase project 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 xxxxxxxxxx-01 (xxxxxxxxxx-01)

=== Hosting Setup
? A Firebase Hosting site is required to deploy. Would you like to create one now? Yes
? Please provide an unique, URL-friendly id for the site (<id>.web.app): xxxxxxxxxx
⚠  Invalid name: `xxxxxxxxxx` is reserved by another project; try something like `xxxxxxxxxx-f7b35` instead
? Please provide an unique, URL-friendly id for the site (<id>.web.app): (xxxxxxxxxx-f7b35)
» firebase --project xxxxxxxxxx-01 deploy --only hosting
i  No Hosting site detected.
? Please provide an unique, URL-friendly id for the site (<id>.web.app): xxxxxxxxxx
⚠  Invalid name: `xxxxxxxxxx` is reserved by another project; try something like `xxxxxxxxxx-b429e` instead
? Please provide an unique, URL-friendly id for the site (<id>.web.app): (xxxxxxxxxx-b429e)

» firebase --non-interactive --project xxxxxxxxxx-01 deploy --only hosting

Error: Unable to deploy to Hosting as there is no Hosting site. Use firebase hosting:sites:create to create a site.
» firebase --project xxxxxxxxxx-01 hosting:channel:create

Error: Unable to deploy to Hosting as there is no Hosting site. Use firebase hosting:sites:create to create a site.

@codecov-commenter
Copy link

codecov-commenter commented Nov 3, 2023

Codecov Report

Attention: 57 lines in your changes are missing coverage. Please review.

Comparison is base (aeb2901) 54.73% compared to head (c624849) 54.65%.

Files Patch % Lines
src/hosting/interactive.ts 19.04% 34 Missing ⚠️
src/commands/deploy.ts 31.25% 11 Missing ⚠️
src/getDefaultHostingSite.ts 28.57% 10 Missing ⚠️
src/hosting/api.ts 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6493      +/-   ##
==========================================
- Coverage   54.73%   54.65%   -0.08%     
==========================================
  Files         346      347       +1     
  Lines       23724    23801      +77     
  Branches     4877     4893      +16     
==========================================
+ Hits        12985    13009      +24     
- Misses       9543     9595      +52     
- Partials     1196     1197       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bkendall bkendall requested a review from svnsairam November 3, 2023 23:11
@joehan
Copy link
Contributor

joehan commented Nov 7, 2023

BTW - if you want this to not go in until 13, merge into launch/v13.0.0 instead of master

@bkendall bkendall enabled auto-merge (squash) November 14, 2023 20:18
@bkendall bkendall merged commit 61523b9 into master Nov 14, 2023
@bkendall bkendall deleted the bk-deferred-hosting branch November 14, 2023 22:48