Skip to content

Commit

Permalink
fix: update to deployment to serial flow
Browse files Browse the repository at this point in the history
  • Loading branch information
yugasun committed Dec 15, 2020
1 parent 643430e commit f96518a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ nextjs 组件支持 0 配置部署,也就是可以直接通过配置文件中

以下是 nextjs 组件的 `serverless.yml`配置示例:


```yml
# serverless.yml
component: nextjs # (必填) 组件名称,此处为nextjs
Expand Down
2 changes: 1 addition & 1 deletion serverless.component.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: nextjs
version: 0.1.8
version: 0.1.9
author: 'Tencent Cloud, Inc.'
org: 'Tencent Cloud, Inc.'
description: Deploy a serverless Next.js application onto Tencent SCF and API Gateway.
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"dependencies": {
"adm-zip": "^0.4.16",
"download": "^8.0.0",
"tencent-component-toolkit": "^1.17.4",
"tencent-component-toolkit": "^1.19.8",
"type": "^2.1.0"
}
}
19 changes: 14 additions & 5 deletions src/serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,24 +258,33 @@ class ServerlessComopnent extends Component {
outputs.templateUrl = CONFIGS.templateUrl
}

const deployTasks = [this.deployFunction(credentials, functionConf, regionList, outputs)]
let apigwOutputs
const functionOutputs = await this.deployFunction(
credentials,
functionConf,
regionList,
outputs
)
// support apigatewayConf.isDisabled
if (apigatewayConf.isDisabled !== true) {
deployTasks.push(this.deployApigateway(credentials, apigatewayConf, regionList, outputs))
apigwOutputs = await this.deployApigateway(credentials, apigatewayConf, regionList, outputs)
} else {
this.state.apigwDisabled = true
}
const [functionOutputs, apigwOutputs = {}] = await Promise.all(deployTasks)

// optimize outputs for one region
if (regionList.length === 1) {
const [oneRegion] = regionList
outputs.region = oneRegion
outputs['apigw'] = apigwOutputs[oneRegion]
outputs['scf'] = functionOutputs[oneRegion]
if (apigwOutputs) {
outputs['apigw'] = apigwOutputs[oneRegion]
}
} else {
outputs['apigw'] = apigwOutputs
outputs['scf'] = functionOutputs
if (apigwOutputs) {
outputs['apigw'] = apigwOutputs
}
}

// start deploy static cdn
Expand Down

0 comments on commit f96518a

Please sign in to comment.