@@ -3,9 +3,11 @@ import { AppSchema } from '../../schema/app'
3
3
import { DeploySchema } from '../../schema/deploy'
4
4
import { pushAll as pushAllFunctions } from '../function'
5
5
import { create as createBucket , push as pushBucket } from '../storage'
6
+ import { create as createWebsite } from '../website'
6
7
import { push as pushDependency } from '../dependency'
7
8
import { pullAll as pullAllPolicies } from '../policy'
8
9
import { getEmoji } from '../../util/print'
10
+ import { websiteControllerFindAll } from '../../api/v1/websitehosting'
9
11
10
12
export async function deploy ( ) {
11
13
if ( ! DeploySchema . exist ( ) ) {
@@ -37,7 +39,23 @@ export async function deploy() {
37
39
if ( ! bucketMap . has ( bucket . name ) ) {
38
40
await createBucket ( bucket . name , { policy : bucket . policy } )
39
41
} else {
40
- console . log ( `${ bucket . name } already exist, skip` )
42
+ console . log ( `bucket ${ bucket . name } already exist, skip` )
43
+ }
44
+ }
45
+ }
46
+
47
+ if ( deploySchema ?. resources ?. websites ) {
48
+ const websites = await websiteControllerFindAll ( appSchema . appid )
49
+ const websiteMap = new Map < string , boolean > ( )
50
+ websites . forEach ( ( website ) => {
51
+ websiteMap . set ( website . bucketName , true )
52
+ } )
53
+
54
+ for ( let website of deploySchema ?. resources ?. websites ) {
55
+ if ( ! websiteMap . has ( website . bucketName ) && ! websiteMap . has ( appSchema . appid + '-' + website . bucketName ) ) {
56
+ await createWebsite ( website . bucketName , { } )
57
+ } else {
58
+ console . log ( `website:${ website . bucketName } already exist, skip` )
41
59
}
42
60
}
43
61
}
@@ -48,5 +66,6 @@ export async function deploy() {
48
66
await pushBucket ( bucket . bucketName , bucket . srcDir , { force : true , detail : false } )
49
67
}
50
68
}
69
+
51
70
console . log ( `${ getEmoji ( '🚀' ) } deploy success` )
52
71
}
0 commit comments