11import { ActionContext } from '../types' ;
22import path from 'node:path' ;
3+ import { ProviderEnum } from './providerEnum' ;
4+
5+ export const getIacLocation = ( location ?: string ) : string => {
6+ const projectRoot = path . resolve ( process . cwd ( ) ) ;
7+ return location
8+ ? path . resolve ( projectRoot , location )
9+ : path . resolve ( projectRoot , 'serverlessinsight.yml' ) ||
10+ path . resolve ( projectRoot , 'serverlessInsight.yml' ) ||
11+ path . resolve ( projectRoot , 'ServerlessInsight.yml' ) ||
12+ path . resolve ( projectRoot , 'serverless-insight.yml' ) ;
13+ } ;
314
415export const constructActionContext = ( config ?: {
516 region ?: string ;
17+ provider ?: string ;
618 account ?: string ;
719 accessKeyId ?: string ;
820 accessKeySecret ?: string ;
@@ -20,15 +32,8 @@ export const constructActionContext = (config?: {
2032 accessKeyId : config ?. accessKeyId ?? ( process . env . ALIYUN_ACCESS_KEY_ID as string ) ,
2133 accessKeySecret : config ?. accessKeySecret ?? ( process . env . ALIYUN_ACCESS_KEY_SECRET as string ) ,
2234 securityToken : config ?. securityToken ?? process . env . ALIYUN_SECURITY_TOKEN ,
23- iacLocation : ( ( ) => {
24- const projectRoot = path . resolve ( process . cwd ( ) ) ;
25- return config ?. location
26- ? path . resolve ( projectRoot , config . location )
27- : path . resolve ( projectRoot , 'serverlessinsight.yml' ) ||
28- path . resolve ( projectRoot , 'serverlessInsight.yml' ) ||
29- path . resolve ( projectRoot , 'ServerlessInsight.yml' ) ||
30- path . resolve ( projectRoot , 'serverless-insight.yml' ) ;
31- } ) ( ) ,
35+ iacLocation : getIacLocation ( config ?. location ) ,
3236 parameters : Object . entries ( config ?. parameters ?? { } ) . map ( ( [ key , value ] ) => ( { key, value } ) ) ,
37+ provider : config ?. provider as ProviderEnum ,
3338 } ;
3439} ;
0 commit comments