@@ -27,31 +27,40 @@ const DEFAULT_IGNORES = ["firebase.json", "**/.*", "**/node_modules/**"];
27
27
28
28
/**
29
29
* Does the setup steps for Firebase Hosting.
30
+ * WARNING: #6527 - `options` may not have all the things you think it does.
30
31
*/
31
32
export async function doSetup ( setup : any , config : any , options : Options ) : Promise < void > {
32
33
setup . hosting = { } ;
33
34
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 ;
40
46
}
41
- hasHostingSite = false ;
42
- }
43
47
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
+ }
55
64
}
56
65
}
57
66
0 commit comments