From f96518a4f2f3254f7b7c2c74e8cb3e383e176595 Mon Sep 17 00:00:00 2001 From: yugasun Date: Fri, 11 Dec 2020 17:23:43 +0800 Subject: [PATCH] fix: update to deployment to serial flow --- README.md | 1 - serverless.component.yml | 2 +- src/package.json | 2 +- src/serverless.js | 19 ++++++++++++++----- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 658ec6a..709abf6 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,6 @@ nextjs 组件支持 0 配置部署,也就是可以直接通过配置文件中 以下是 nextjs 组件的 `serverless.yml`配置示例: - ```yml # serverless.yml component: nextjs # (必填) 组件名称,此处为nextjs diff --git a/serverless.component.yml b/serverless.component.yml index 3871544..d38fee0 100644 --- a/serverless.component.yml +++ b/serverless.component.yml @@ -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. diff --git a/src/package.json b/src/package.json index 4b9c0c2..d0f8567 100644 --- a/src/package.json +++ b/src/package.json @@ -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" } } diff --git a/src/serverless.js b/src/serverless.js index a33f4b0..b9ba1ab 100644 --- a/src/serverless.js +++ b/src/serverless.js @@ -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