1- import { ActionContext } from '../types' ;
1+ import { ActionContext , ServerlessIac } from '../types' ;
22import path from 'node:path' ;
33import { ProviderEnum } from './providerEnum' ;
44
@@ -12,28 +12,32 @@ export const getIacLocation = (location?: string): string => {
1212 path . resolve ( projectRoot , 'serverless-insight.yml' ) ;
1313} ;
1414
15- export const constructActionContext = ( config ?: {
15+ export const constructActionContext = ( config : {
16+ stage ?: string ;
17+ stackName ?: string ;
1618 region ?: string ;
1719 provider ?: string ;
18- account ?: string ;
1920 accessKeyId ?: string ;
2021 accessKeySecret ?: string ;
2122 securityToken ?: string ;
2223 location ?: string ;
2324 parameters ?: { [ key : string ] : string } ;
24- stage ?: string ;
25- stackName ?: string ;
25+ iacProvider ?: ServerlessIac [ 'provider' ] ;
2626} ) : ActionContext => {
2727 return {
28- stage : config ?. stage ?? 'default' ,
29- stackName : config ?. stackName ?? '' ,
28+ stage : config . stage ?? 'default' ,
29+ stackName : config . stackName ?? '' ,
30+ provider : ( config . provider ?? config . iacProvider ?. name ?? ProviderEnum . ALIYUN ) as ProviderEnum ,
3031 region :
31- config ?. region ?? process . env . ROS_REGION_ID ?? process . env . ALIYUN_REGION ?? 'cn-hangzhou' ,
32- accessKeyId : config ?. accessKeyId ?? ( process . env . ALIYUN_ACCESS_KEY_ID as string ) ,
33- accessKeySecret : config ?. accessKeySecret ?? ( process . env . ALIYUN_ACCESS_KEY_SECRET as string ) ,
34- securityToken : config ?. securityToken ?? process . env . ALIYUN_SECURITY_TOKEN ,
35- iacLocation : getIacLocation ( config ?. location ) ,
36- parameters : Object . entries ( config ?. parameters ?? { } ) . map ( ( [ key , value ] ) => ( { key, value } ) ) ,
37- provider : config ?. provider as ProviderEnum ,
32+ config . region ??
33+ config . iacProvider ?. region ??
34+ process . env . ROS_REGION_ID ??
35+ process . env . ALIYUN_REGION ??
36+ 'cn-hangzhou' ,
37+ accessKeyId : config . accessKeyId ?? ( process . env . ALIYUN_ACCESS_KEY_ID as string ) ,
38+ accessKeySecret : config . accessKeySecret ?? ( process . env . ALIYUN_ACCESS_KEY_SECRET as string ) ,
39+ securityToken : config . securityToken ?? process . env . ALIYUN_SECURITY_TOKEN ,
40+ iacLocation : getIacLocation ( config . location ) ,
41+ parameters : Object . entries ( config . parameters ?? { } ) . map ( ( [ key , value ] ) => ( { key, value } ) ) ,
3842 } ;
3943} ;
0 commit comments