Skip to content

Commit daa99a3

Browse files
committed
chore: update inject faas layer logic
1 parent bd1e28d commit daa99a3

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

src/components/config.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,7 @@ const FRAMEWORK_COMPONENTS = [
3838
'thinkphp',
3939
];
4040

41-
const HTTP_FRAMEWORKS = [
42-
'express',
43-
'koa',
44-
'egg',
45-
'nextjs',
46-
'nuxtjs',
47-
'nest',
48-
'flask',
49-
'django',
50-
'laravel',
51-
];
41+
const NEW_STANDARD_COMPONENTS = ['http'];
5242

5343
const COMPONENTS = [...BASE_COMPONENTS, ...FRAMEWORK_COMPONENTS];
5444

@@ -60,8 +50,8 @@ const isFrameworkComponent = (name = 'framework') => {
6050
return FRAMEWORK_COMPONENTS.indexOf(name) !== -1;
6151
};
6252

63-
const isHttpFramework = (component: string, framework?: string) => {
64-
return component === 'http' && framework && HTTP_FRAMEWORKS.includes(framework);
53+
const isNewStandardFramework = (component: string) => {
54+
return NEW_STANDARD_COMPONENTS.includes(component);
6555
};
6656

67-
export { COMPONENTS, getDefaultConfig, isBaseComponent, isFrameworkComponent, isHttpFramework };
57+
export { COMPONENTS, getDefaultConfig, isBaseComponent, isFrameworkComponent, isNewStandardFramework };

src/parse.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import chalk from 'chalk';
66
import { program } from 'commander';
77
import { fileExist, isJsonPath, isYamlPath, getFileExt, mergeObject } from './utils';
88
import { AnyObject, ParseOptions } from './typings';
9-
import { getDefaultConfig, isHttpFramework } from './components/config';
9+
import { getDefaultConfig, isNewStandardFramework } from './components/config';
1010
import { createLayerConfig } from './components/layer';
1111

1212
/**
@@ -73,10 +73,7 @@ function generateLayerYaml(rootDir: string, slsOptions: AnyObject, layerOptions
7373
const layerConfig = createLayerConfig(layerPath, JSON.parse(layerOptions));
7474
// 2. update project serverless.yml
7575
slsOptions.inputs = slsOptions.inputs || {};
76-
if (
77-
slsOptions.inputs?.faas?.framework &&
78-
isHttpFramework(slsOptions.component, slsOptions.inputs.faas.framework)
79-
) {
76+
if (isNewStandardFramework(slsOptions.component)) {
8077
slsOptions.inputs.faas.layers = slsOptions.inputs.faas.layers || [];
8178
slsOptions.inputs.faas.layers.push({
8279
name: '${output:${stage}:${app}:' + layerConfig.name + '.name}',

0 commit comments

Comments
 (0)