1 |
|
2 | import { IConfigParseResult } from '../libs/config-parse-result';
|
3 | import {IPlugin, forwardChildIamRoleStatements} from '../libs/plugin';
|
4 | import { isIdentity } from '../identity/identity-component';
|
5 | import * as deepmerge from 'deepmerge';
|
6 |
|
7 | /**
|
8 | * Parameters that apply to the whole Plugin, passed by other plugins
|
9 | */
|
10 | export interface IIdentityPlugin {
|
11 |
|
12 | }
|
13 |
|
14 | /**
|
15 | * We require an IdentityPlugin to forward the configuration from lower level webapps
|
16 | * TODO: refactor so that we don't need such dummy plugins!
|
17 | */
|
18 | export const IdentityPlugin = (props: IIdentityPlugin): IPlugin => {
|
19 | const path = require('path');
|
20 |
|
21 | const result: IPlugin = {
|
22 | applies: (component):boolean => {
|
23 |
|
24 | return isIdentity(component);
|
25 | },
|
26 |
|
27 | // convert the component into configuration parts
|
28 | // while the component is of Type `any`, its props must be of type `IDataLayerArgs` | `IDataLayerProps`
|
29 | process: (component:any,
|
30 | childConfigs:Array<IConfigParseResult>,
|
31 | infrastructureMode:string | undefined
|
32 | ):IConfigParseResult => {
|
33 |
|
34 |
|
35 | return {
|
36 |
|
37 | slsConfigs: deepmerge.all(childConfigs.map(config => config.slsConfigs)),
|
38 |
|
39 | // add the server config
|
40 | webpackConfigs: childConfigs.reduce((result, config) => result.concat(config.webpackConfigs), []),
|
41 |
|
42 | postBuilds: childConfigs.reduce((result, config) => result.concat(config.postBuilds), []),
|
43 |
|
44 | iamRoleStatements: forwardChildIamRoleStatements(childConfigs)
|
45 |
|
46 | /* THESE VALUES MUST NOT BE PROVIDED BY A CHILD, THEY ARE NOT FORWARED UPWARDS
|
47 |
|
48 | environments: environments,
|
49 |
|
50 | //stackName: component.stackName,
|
51 |
|
52 | assetsPath: component.assetsPath,
|
53 |
|
54 | buildPath: component.buildPath,
|
55 |
|
56 | region: component.region,
|
57 |
|
58 | domain: domain,
|
59 |
|
60 | certArn: certArn,
|
61 |
|
62 | supportOfflineStart: true,
|
63 |
|
64 | supportCreateDomain: true
|
65 | */
|
66 | }
|
67 | }
|
68 | };
|
69 |
|
70 |
|
71 | return result;
|
72 |
|
73 | }; |
\ | No newline at end of file |