@@ -61,9 +61,9 @@ class Module {
6161 if ( shimCollection ) {
6262 // Retrieve and clone shims in constructor
6363 // Shims added to the collection at a later point in time should not be applied in this module
64- const shims = shimCollection . getConfigurationShims ( this . getId ( ) ) ;
64+ const shims = shimCollection . getProjectConfigurationShims ( this . getId ( ) ) ;
6565 if ( shims && shims . length ) {
66- this . _configShims = clone ( shims ) ;
66+ this . _projectConfigShims = clone ( shims ) ;
6767 }
6868 }
6969 }
@@ -91,8 +91,6 @@ class Module {
9191 async _getSpecifications ( ) {
9292 const configs = await this . _getConfigurations ( ) ;
9393
94- // let project;
95- // const extensions = [];
9694 const specs = await Promise . all ( configs . map ( async ( configuration ) => {
9795 const spec = await Specification . create ( {
9896 id : this . getId ( ) ,
@@ -103,36 +101,6 @@ class Module {
103101
104102 log . verbose ( `Module ${ this . getId ( ) } contains ${ spec . getKind ( ) } ${ spec . getName ( ) } ` ) ;
105103 return spec ;
106-
107- // switch (configuration.kind) {
108- // case "project":
109- // if (project) {
110- // throw new Error(
111- // `Invalid configuration for module ${this.getId()}: Per module there ` +
112- // `must be no more than one configuration of kind 'project'`);
113- // }
114- // log.verbose(`Module ${this.getId()} contains project ${configuration.getName()}`);
115- // project = await Project.create({
116- // id: this.getId(),
117- // version: this.getVersion(),
118- // modulePath: this.getPath(),
119- // configuration
120- // });
121- // break;
122- // case "extension":
123- // log.verbose(`Module ${this.getId()} contains extension ${configuration.getName()}`);
124- // extensions.push(new Extension({
125- // id: this.getId(),
126- // version: this.getVersion(),
127- // modulePath: this.getPath(),
128- // configuration
129- // }));
130- // break;
131- // default:
132- // throw new Error(
133- // `Encountered unexpected specification configuration of kind ${configuration.kind} ` +
134- // `Supported kinds are 'project' and 'extension'`);
135- // }
136104 } ) ) ;
137105
138106 const projects = specs . filter ( ( spec ) => {
@@ -172,29 +140,28 @@ class Module {
172140 return configurations || [ ] ;
173141 }
174142
175- async _createConfigurationObject ( config ) {
143+ async _normalizeAndApplyShims ( config ) {
176144 this . _normalizeConfig ( config ) ;
177- if ( config . kind === "project" ) {
178- this . _applyShims ( config ) ;
145+
146+ if ( config . kind !== "project" ) {
147+ this . _applyProjectShims ( config ) ;
179148 }
180- // await this._validateConfig(config);
181149 return config ;
182150 }
183151
184152 async _createConfigurationFromShim ( ) {
185- const config = this . _applyShims ( ) ;
153+ const config = this . _applyProjectShims ( ) ;
186154 if ( config ) {
187155 this . _normalizeConfig ( config ) ;
188- // await this._validateConfig(config);
189156 return config ;
190157 }
191158 }
192159
193- _applyShims ( config = { } ) {
194- if ( ! this . _configShims ) {
160+ _applyProjectShims ( config = { } ) {
161+ if ( ! this . _projectConfigShims ) {
195162 return ;
196163 }
197- this . _configShims . forEach ( ( { name, shim} ) => {
164+ this . _projectConfigShims . forEach ( ( { name, shim} ) => {
198165 log . verbose ( `Applying project shim ${ name } for module ${ this . getId ( ) } ...` ) ;
199166 Object . assign ( config , shim ) ;
200167 } ) ;
@@ -205,7 +172,7 @@ class Module {
205172 if ( this . _suppliedConfigs . length ) {
206173 log . verbose ( `Configuration for module ${ this . getId ( ) } has been supplied directly` ) ;
207174 return await Promise . all ( this . _suppliedConfigs . map ( async ( config ) => {
208- return this . _createConfigurationObject ( config ) ;
175+ return this . _normalizeAndApplyShims ( config ) ;
209176 } ) ) ;
210177 }
211178 }
@@ -228,44 +195,8 @@ class Module {
228195 return [ ] ;
229196 }
230197
231- // for (let i = configs.length - 1; i >= 0; i--) {
232- // this._normalizeConfig(configs[i]);
233- // }
234-
235- // const projectConfigs = configs.filter((config) => {
236- // return config.kind === "project";
237- // });
238-
239- // const extensionConfigs = configs.filter((config) => {
240- // return config.kind === "extension";
241- // });
242-
243- // // While a project can contain multiple configurations,
244- // // from a dependency tree perspective it is always a single project
245- // // This means it can represent one "project", plus multiple extensions or
246- // // one extension, plus multiple extensions
247-
248- // if (projectConfigs.length > 1) {
249- // throw new Error(
250- // `Found ${projectConfigs.length} configurations of kind 'project' for ` +
251- // `project ${this.getId()}. There is only one project per configuration allowed.`);
252- // } else if (projectConfigs.length === 0 && extensionConfigs.length === 0) {
253- // throw new Error(
254- // `Found ${configs.length} configurations for ` +
255- // `project ${this.getId()}. However, none of them are of kind 'project' or 'extension'.`);
256- // }
257-
258- // const configurations = [];
259- // if (projectConfigs.length) {
260- // configurations.push(await this._createConfigurationObject(projectConfigs[0]));
261- // }
262-
263- // await Promise.all(extensionConfigs.map(async (config) => {
264- // configurations.push(await this._createConfigurationObject(config));
265- // }));
266-
267198 return await Promise . all ( configs . map ( ( config ) => {
268- return this . _createConfigurationObject ( config ) ;
199+ return this . _normalizeAndApplyShims ( config ) ;
269200 } ) ) ;
270201 }
271202
@@ -361,34 +292,6 @@ class Module {
361292 return config ;
362293 }
363294
364- // async _validateConfig(config) {
365- // const moduleId = this.getId();
366- // if (!moduleId.startsWith("@openui5/") && !moduleId.startsWith("@sapui5/")) {
367- // if (config.specVersion === "0.1" || config.specVersion === "1.0" ||
368- // config.specVersion === "1.1") {
369- // throw new Error(
370- // `Unsupported specification version ${config.specVersion} defined in module ` +
371- // `${this.getId()}. The new Module API can only be used with specification versions >= 2.0. ` +
372- // `For details see https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions`);
373- // }
374- // if (config.specVersion !== "2.0" &&
375- // config.specVersion !== "2.1" && config.specVersion !== "2.2" &&
376- // config.specVersion !== "2.3") {
377- // throw new Error(
378- // `Unsupported specification version ${config.specVersion} defined in module ` +
379- // `${this.getId()}. Your UI5 CLI installation might be outdated. ` +
380- // `For details see https://sap.github.io/ui5-tooling/pages/Configuration/#specification-versions`);
381- // }
382- // }
383-
384- // await validate({
385- // config,
386- // project: {
387- // id: moduleId
388- // }
389- // });
390- // }
391-
392295 _isConfigValid ( project ) {
393296 if ( ! project . type ) {
394297 if ( project . _isRoot ) {
0 commit comments