UNPKG

2.06 kBPlain TextView Raw
1import { IConfigParseResult } from './config-parse-result';
2import * as deepmerge from 'deepmerge';
3
4
5export interface IPlugin {
6
7 /**
8 * check whether the plugin applies to the provided component
9 * @param component to process
10 * @return boolean whether the plugin applies to the component
11 */
12 applies: (component) => boolean,
13
14 /**
15 * process the provided component. return a tuple {Array<slsConfigs>, Array<webpackConfigs>, Array<postBuilds>}
16 *
17 * @param component component that this plugin applies to
18 *
19 * @param childConfigs list of the parsing result of the children
20 * type: Array<{Array<slsConfigs>, Array<webpackConfigs>, Array<postBuilds>}>
21 * @param compileMode boolean, if true, the components have beeen loaded statically only!
22 */
23 process: (
24 component: any,
25 childConfigs: Array<IConfigParseResult>,
26 infrastructureMode: string | undefined,
27 stage: string | undefined) => IConfigParseResult,
28}
29
30
31export const forwardChildPostBuilds = (childConfigs: Array<IConfigParseResult>) => (
32 childConfigs.reduce((result, config) => result.concat(config.postBuilds), [])
33);
34
35
36/**
37 * provide all client configs in a flat list
38 */
39export const forwardChildWebpackConfigs = (childConfigs: Array<IConfigParseResult>) => {
40 return childConfigs.reduce((result, config) => result.concat(...config.webpackConfigs), []);
41}
42
43
44/**
45 * provide all client configs in a flat list
46 */
47export const forwardChildIamRoleStatements = (childConfigs: Array<IConfigParseResult>) => {
48
49 return childConfigs.reduce((result, config) => {
50
51 //console.log("reduce iam: ", config.iamRoleStatements);
52 const statements = (config.iamRoleStatements !== undefined && Array.isArray(config.iamRoleStatements)) ?
53 config.iamRoleStatements : [];
54
55 //console.log("iam result: ", statements)
56
57 return result.concat(statements);
58 }, [])
59};
60/*
61export const mergeIamRoleStatements = (statements: Array<any>) => {
62 return deepmerge.all(statements);
63};*/
\No newline at end of file