From cea1df69e3a9d58367e7d9c441e2a7116bfe6cf3 Mon Sep 17 00:00:00 2001 From: echosoar <82163514@qq.com> Date: Tue, 28 Apr 2020 16:47:14 +0800 Subject: [PATCH 1/3] fix: aggregation all --- packages/faas-cli-plugin-package/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/faas-cli-plugin-package/src/index.ts b/packages/faas-cli-plugin-package/src/index.ts index 766ed868..9dd31f47 100644 --- a/packages/faas-cli-plugin-package/src/index.ts +++ b/packages/faas-cli-plugin-package/src/index.ts @@ -513,7 +513,7 @@ export class PackagePlugin extends BasePlugin { let allFuncNames = Object.keys(this.core.service.functions); for (const aggregationName in this.core.service.aggregation) { const aggregationConfig = this.core.service.aggregation[aggregationName]; - const aggregationFuncName = aggregationName; + const aggregationFuncName = aggregationName === 'all' ? 'aggregationall': aggregationName; this.core.service.functions[ aggregationFuncName ] = aggregationConfig; From 7186b777792acaef624be4d57e8a26d70daff6df Mon Sep 17 00:00:00 2001 From: echosoar <82163514@qq.com> Date: Tue, 28 Apr 2020 16:50:17 +0800 Subject: [PATCH 2/3] fix: aggregation all test --- packages/faas-cli-plugin-package/test/aggregation.test.ts | 2 +- .../faas-cli-plugin-package/test/fixtures/aggregation/f.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/faas-cli-plugin-package/test/aggregation.test.ts b/packages/faas-cli-plugin-package/test/aggregation.test.ts index d9275ccc..9ec86f04 100644 --- a/packages/faas-cli-plugin-package/test/aggregation.test.ts +++ b/packages/faas-cli-plugin-package/test/aggregation.test.ts @@ -25,7 +25,7 @@ describe('/test/package.test.ts', () => { core.addPlugin(AliyunFCPlugin); await core.ready(); await core.invoke(['package']); - assert(existsSync(resolve(buildDir, 'api.js'))); + assert(existsSync(resolve(buildDir, 'aggregationall.js'))); assert(existsSync(resolve(buildDir, 'normal.js'))); assert(existsSync(resolve(buildDir, 'renderNot2.js'))); }); diff --git a/packages/faas-cli-plugin-package/test/fixtures/aggregation/f.yml b/packages/faas-cli-plugin-package/test/fixtures/aggregation/f.yml index f67847e1..d399d198 100644 --- a/packages/faas-cli-plugin-package/test/fixtures/aggregation/f.yml +++ b/packages/faas-cli-plugin-package/test/fixtures/aggregation/f.yml @@ -58,7 +58,7 @@ custom: domainName: 'aggregation.exanple.com' aggregation: - api: + all: functionsPattern: - api* renderNot2: From 082886438f5151128f3d9e2f3c4f7dfcb3a3a130 Mon Sep 17 00:00:00 2001 From: echosoar <82163514@qq.com> Date: Tue, 28 Apr 2020 17:07:24 +0800 Subject: [PATCH 3/3] fix: aggre --- packages/faas-cli-plugin-package/src/index.ts | 7 ++++++- packages/faas-cli-plugin-package/test/aggregation.test.ts | 2 +- .../test/fixtures/aggregation/f.yml | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/faas-cli-plugin-package/src/index.ts b/packages/faas-cli-plugin-package/src/index.ts index 9dd31f47..fe96aff0 100644 --- a/packages/faas-cli-plugin-package/src/index.ts +++ b/packages/faas-cli-plugin-package/src/index.ts @@ -513,7 +513,7 @@ export class PackagePlugin extends BasePlugin { let allFuncNames = Object.keys(this.core.service.functions); for (const aggregationName in this.core.service.aggregation) { const aggregationConfig = this.core.service.aggregation[aggregationName]; - const aggregationFuncName = aggregationName === 'all' ? 'aggregationall': aggregationName; + const aggregationFuncName = this.getAggregationFunName(aggregationName); this.core.service.functions[ aggregationFuncName ] = aggregationConfig; @@ -615,5 +615,10 @@ export class PackagePlugin extends BasePlugin { writeToSpec(this.servicePath, this.core.service, this.core.config.specFile); } + + getAggregationFunName(aggregationName: string) { + return aggregationName; + } + finalize() {} } diff --git a/packages/faas-cli-plugin-package/test/aggregation.test.ts b/packages/faas-cli-plugin-package/test/aggregation.test.ts index 9ec86f04..d9275ccc 100644 --- a/packages/faas-cli-plugin-package/test/aggregation.test.ts +++ b/packages/faas-cli-plugin-package/test/aggregation.test.ts @@ -25,7 +25,7 @@ describe('/test/package.test.ts', () => { core.addPlugin(AliyunFCPlugin); await core.ready(); await core.invoke(['package']); - assert(existsSync(resolve(buildDir, 'aggregationall.js'))); + assert(existsSync(resolve(buildDir, 'api.js'))); assert(existsSync(resolve(buildDir, 'normal.js'))); assert(existsSync(resolve(buildDir, 'renderNot2.js'))); }); diff --git a/packages/faas-cli-plugin-package/test/fixtures/aggregation/f.yml b/packages/faas-cli-plugin-package/test/fixtures/aggregation/f.yml index d399d198..f67847e1 100644 --- a/packages/faas-cli-plugin-package/test/fixtures/aggregation/f.yml +++ b/packages/faas-cli-plugin-package/test/fixtures/aggregation/f.yml @@ -58,7 +58,7 @@ custom: domainName: 'aggregation.exanple.com' aggregation: - all: + api: functionsPattern: - api* renderNot2: