Skip to content

Commit

Permalink
fix: update remove flow (#17)
Browse files Browse the repository at this point in the history
* fix: update remove flow

* fix: update deps
  • Loading branch information
yugasun authored Dec 21, 2020
1 parent cb2937b commit 96879d4
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_AUTHOR_NAME: slsplus
GIT_AUTHOR_EMAIL: yuga.sun.bj@gmail.com
GIT_AUTHOR_EMAIL: slsplus.sz@gmail.com
GIT_COMMITTER_NAME: slsplus
GIT_COMMITTER_EMAIL: yuga.sun.bj@gmail.com
GIT_COMMITTER_EMAIL: slsplus.sz@gmail.com
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
run: |
npm update --no-save
npm update --save-dev --no-save
- name: Running integration tests
- name: Running tests
run: npm run test
env:
SERVERLESS_PLATFORM_VENDOR: tencent
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ serverless deploy

> **说明**:如果鉴权失败,请参考 [权限配置](https://cloud.tencent.com/document/product/1154/43006) 进行授权。

### 4. 配置

nuxtjs 组件支持 0 配置部署,也就是可以直接通过配置文件中的默认值进行部署。但你依然可以修改更多可选配置来进一步开发该 nuxtjs 项目。
Expand Down
10 changes: 2 additions & 8 deletions tests/integration.test.js → __tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
require('dotenv').config()
const { generateId, getServerlessSdk } = require('./utils')
const { generateId, getServerlessSdk } = require('./lib/utils')
const axios = require('axios')

// set enough timeout for deployment to finish
jest.setTimeout(600000)

// the yaml file we're testing against
const instanceYaml = {
org: 'orgDemo',
app: 'appDemo',
component: 'nuxtjs',
component: 'nuxtjs@dev',
name: `nuxtjs-integration-tests-${generateId()}`,
stage: 'dev',
inputs: {
Expand All @@ -19,15 +15,13 @@ const instanceYaml = {
}
}

// get credentials from process.env but need to init empty credentials object
const credentials = {
tencent: {
SecretId: process.env.TENCENT_SECRET_ID,
SecretKey: process.env.TENCENT_SECRET_KEY,
}
}

// get serverless construct sdk
const sdk = getServerlessSdk(instanceYaml.org)

it('should successfully deploy nuxtjs app', async () => {
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { join } = require('path')
require('dotenv').config({ path: join(__dirname, '.env.test') })

const config = {
verbose: true,
silent: false,
testTimeout: 600000,
testEnvironment: 'node',
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)$',
testPathIgnorePatterns: ['/node_modules/', '/__tests__/lib/'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
}

module.exports = config
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"description": "Tencent Cloud Nuxt.js Serverless Component",
"scripts": {
"test": "jest ./tests/integration.test.js --testEnvironment node",
"test": "jest",
"commitlint": "commitlint -f HEAD@{15}",
"lint": "eslint --ext .js,.ts,.tsx .",
"lint:fix": "eslint --fix --ext .js,.ts,.tsx .",
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: nuxtjs
version: 0.1.7
version: 0.1.8
author: 'Tencent Cloud, Inc.'
org: 'Tencent Cloud, Inc.'
description: Deploy a serverless Nuxt.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.19.8",
"tencent-component-toolkit": "^1.20.5",
"type": "^2.1.0"
}
}
8 changes: 4 additions & 4 deletions src/serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,6 @@ class ServerlessComopnent extends Component {
const scf = new Scf(credentials, curRegion)
const apigw = new Apigw(credentials, curRegion)
const handler = async () => {
await scf.remove({
functionName: curState.functionName,
namespace: curState.namespace
})
// if disable apigw, no need to remove
if (state.apigwDisabled !== true) {
await apigw.remove({
Expand All @@ -372,6 +368,10 @@ class ServerlessComopnent extends Component {
customDomains: curState.customDomains
})
}
await scf.remove({
functionName: curState.functionName,
namespace: curState.namespace
})
}
removeHandlers.push(handler())
}
Expand Down

0 comments on commit 96879d4

Please sign in to comment.