@@ -119,6 +119,36 @@ export default class FcDeployComponent {
119
119
( needDeployAll && type !== 'code' ) || ( ! command && type !== 'code' ) || command === 'trigger' ;
120
120
let needDeployAllTriggers = true ;
121
121
122
+ // deploy custom domain
123
+ let hasAutoCustomDomainNameInDomains = false ;
124
+ const resolvedCustomDomainConfs : CustomDomainConfig [ ] = [ ] ;
125
+ const needDeployDomain = needDeployAll || ( ! command && type !== 'code' ) || command === 'domain' ;
126
+ if ( ! _ . isEmpty ( this . fcCustomDomains ) && needDeployDomain ) {
127
+ logger . spinner ?. stop ( ) ;
128
+ const spin = core . spinner ( 'Generated auto custom domain...' ) ;
129
+ try {
130
+ for ( let i = 0 ; i < this . fcCustomDomains . length ; i ++ ) {
131
+ await this . fcCustomDomains [ i ] . initLocal ( useLocal , useRemote , _ . cloneDeep ( inputs ) ) ;
132
+ if ( this . fcCustomDomains [ i ] . useRemote ) {
133
+ continue ;
134
+ }
135
+ const resolvedCustomDomainConf : CustomDomainConfig = await this . fcCustomDomains [
136
+ i
137
+ ] . makeCustomDomain ( this . args , this . credentials ) ;
138
+ hasAutoCustomDomainNameInDomains =
139
+ hasAutoCustomDomainNameInDomains || this . fcCustomDomains [ i ] . isDomainNameAuto ;
140
+ resolvedCustomDomainConfs . push ( resolvedCustomDomainConf ) ;
141
+ logger . debug (
142
+ `resolved custom domain: \n${ JSON . stringify ( resolvedCustomDomainConf , null , ' ' ) } ` ,
143
+ ) ;
144
+ }
145
+ spin . succeed ( 'Generated auto custom domain succeed' ) ;
146
+ } catch ( error ) {
147
+ spin . fail ( 'Generated auto custom domain failed' ) ;
148
+ throw error ;
149
+ }
150
+ }
151
+
122
152
await logger . task ( 'Checking' , [
123
153
{
124
154
title : `Checking Service ${ this . fcService ?. name } exists` ,
@@ -359,29 +389,21 @@ export default class FcDeployComponent {
359
389
}
360
390
}
361
391
362
- // deploy custom domain
363
- let hasAutoCustomDomainNameInDomains = false ;
364
- const resolvedCustomDomainConfs : CustomDomainConfig [ ] = [ ] ;
365
- const needDeployDomain = needDeployAll || ( ! command && type !== 'code' ) || command === 'domain' ;
366
392
await logger . task ( 'Creating custom domain' , [
367
393
{
368
- title : 'Generated auto custom domain ...' ,
369
- enabled : ( ) => ! _ . isEmpty ( this . fcCustomDomains ) && needDeployDomain ,
394
+ title : 'Check domain config auto dns ...' ,
395
+ enabled : ( ) => ! _ . isEmpty ( resolvedCustomDomainConfs ) ,
370
396
task : async ( ) => {
371
- for ( let i = 0 ; i < this . fcCustomDomains . length ; i ++ ) {
372
- await this . fcCustomDomains [ i ] . initLocal ( useLocal , useRemote , _ . cloneDeep ( inputs ) ) ;
373
- if ( this . fcCustomDomains [ i ] . useRemote ) {
397
+ for ( const fcCustomDomain of this . fcCustomDomains ) {
398
+ if ( fcCustomDomain . useRemote || ! fcCustomDomain . isDomainNameAuto ) {
374
399
continue ;
375
400
}
376
- const resolvedCustomDomainConf : CustomDomainConfig = await this . fcCustomDomains [
377
- i
378
- ] . makeCustomDomain ( this . args , this . credentials ) ;
379
- hasAutoCustomDomainNameInDomains =
380
- hasAutoCustomDomainNameInDomains || this . fcCustomDomains [ i ] . isDomainNameAuto ;
381
- resolvedCustomDomainConfs . push ( resolvedCustomDomainConf ) ;
382
- logger . debug (
383
- `resolved custom domain: \n${ JSON . stringify ( resolvedCustomDomainConf , null , ' ' ) } ` ,
384
- ) ;
401
+ logger . debug ( `check domain props: ${ fcCustomDomain . customDomainConf . domainName } ` ) ;
402
+ try {
403
+ await fcCustomDomain . checkCname ( ) ;
404
+ } catch ( ex ) {
405
+ logger . debug ( `check domain dns error: ${ ex . message } ` ) ;
406
+ }
385
407
}
386
408
} ,
387
409
} ,
0 commit comments