@@ -27,31 +27,40 @@ const DEFAULT_IGNORES = ["firebase.json", "**/.*", "**/node_modules/**"];
2727
2828/**
2929 * Does the setup steps for Firebase Hosting.
30+ * WARNING: #6527 - `options` may not have all the things you think it does.
3031 */
3132export async function doSetup ( setup : any , config : any , options : Options ) : Promise < void > {
3233 setup . hosting = { } ;
3334
34- let hasHostingSite = true ;
35- try {
36- await getDefaultHostingSite ( options ) ;
37- } catch ( err : unknown ) {
38- if ( err !== errNoDefaultSite ) {
39- throw err ;
35+ // There's a path where we can set up Hosting without a project, so if
36+ // if setup.projectId is empty, we don't do any checking for a Hosting site.
37+ if ( setup . projectId ) {
38+ let hasHostingSite = true ;
39+ try {
40+ await getDefaultHostingSite ( { projectId : setup . projectId } ) ;
41+ } catch ( err : unknown ) {
42+ if ( err !== errNoDefaultSite ) {
43+ throw err ;
44+ }
45+ hasHostingSite = false ;
4046 }
41- hasHostingSite = false ;
42- }
4347
44- if ( ! hasHostingSite ) {
45- const confirmCreate = await promptOnce ( {
46- type : "confirm" ,
47- message : "A Firebase Hosting site is required to deploy. Would you like to create one now?" ,
48- default : true ,
49- } ) ;
50- if ( confirmCreate ) {
51- const newSite = await interactiveCreateHostingSite ( "" , "" , options ) ;
52- logger . info ( ) ;
53- logSuccess ( `Firebase Hosting site ${ last ( newSite . name . split ( "/" ) ) } created!` ) ;
54- logger . info ( ) ;
48+ if ( ! hasHostingSite ) {
49+ const confirmCreate = await promptOnce ( {
50+ type : "confirm" ,
51+ message : "A Firebase Hosting site is required to deploy. Would you like to create one now?" ,
52+ default : true ,
53+ } ) ;
54+ if ( confirmCreate ) {
55+ const createOptions = {
56+ projectId : setup . projectId ,
57+ nonInteractive : options . nonInteractive ,
58+ } ;
59+ const newSite = await interactiveCreateHostingSite ( "" , "" , createOptions ) ;
60+ logger . info ( ) ;
61+ logSuccess ( `Firebase Hosting site ${ last ( newSite . name . split ( "/" ) ) } created!` ) ;
62+ logger . info ( ) ;
63+ }
5564 }
5665 }
5766
0 commit comments