1 |
|
2 | import {IPlugin} from "../libs/plugin";
|
3 | import Types from './index'
|
4 |
|
5 | /**
|
6 | * A configuration is the top-level node of an infrastructure-components project
|
7 | */
|
8 | export interface IConfiguration {
|
9 |
|
10 |
|
11 | /**
|
12 | * An Infrastructure may provide plugins, the Plugins may need some data that we provide here!
|
13 | */
|
14 | createPlugins: (configPath: string, stage: string | undefined, parserMode: string) => Array<IPlugin>
|
15 |
|
16 | }
|
17 |
|
18 | /**
|
19 | * A function to check whether a component serves as an Infrastructure
|
20 | *
|
21 | * used in the parser during compilation, we get a real object here!
|
22 | *
|
23 | * @param parsedComponent is the real object to be tested!
|
24 | */
|
25 | export const isConfiguration = (parsedComponent): boolean => {
|
26 |
|
27 | //console.log("check if Configuration: " , parsedComponent)
|
28 |
|
29 | if (parsedComponent !== undefined) {
|
30 | return parsedComponent.createPlugins !== undefined &&
|
31 | parsedComponent.infrastructureType === Types.INFRASTRUCTURE_TYPE_CONFIGURATION
|
32 | }
|
33 |
|
34 | //console.log("NOPE!");
|
35 |
|
36 | return false;
|
37 | };
|
38 |
|
39 |
|
40 | /**
|
41 | * Extracts the plugins from an infrastructure
|
42 | *
|
43 | * @param infrastructure is the infrastructure-object
|
44 | * @param configPath specifies the path to the original configuration of the project, as passes as argument in the command
|
45 | *
|
46 | */
|
47 | export function extractPlugins(infrastructure: IConfiguration, configPath: string, stage: string | undefined, parserMode: string) {
|
48 |
|
49 | return infrastructure.createPlugins(configPath, stage, parserMode);
|
50 | }
|
51 |
|
52 |
|