Skip to content

Commit b9e2c20

Browse files
committed
Move legacy OpenUI5 theme library handling to graph.Module
1 parent 0fabc78 commit b9e2c20

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

lib/graph/Module.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const {validate} = require("../validation/validator");
99

1010
const log = require("@ui5/logger").getLogger("graph:Module");
1111

12-
const defaultConfigPath = "ui5.yaml";
12+
const DEFAULT_CONFIG_PATH = "ui5.yaml";
13+
const SAP_THEMES_NS_EXEMPTIONS = ["themelib_sap_fiori_3", "themelib_sap_bluecrystal", "themelib_sap_belize"];
1314

1415
function clone(obj) {
1516
return JSON.parse(JSON.stringify(obj));
@@ -36,7 +37,7 @@ class Module {
3637
* @param {@ui5/project.graph.ShimCollection} [parameters.shimCollection]
3738
* Collection of shims that might be relevant for this module
3839
*/
39-
constructor({id, version, modulePath, configPath = defaultConfigPath, configuration = [], shimCollection}) {
40+
constructor({id, version, modulePath, configPath = DEFAULT_CONFIG_PATH, configuration = [], shimCollection}) {
4041
if (!id) {
4142
throw new Error(`Could not create Module: Missing or empty parameter 'id'`);
4243
}
@@ -127,6 +128,14 @@ class Module {
127128
});
128129
}
129130

131+
configs.forEach((configuration) => {
132+
if (configuration.kind === "project" && configuration.type === "library" &&
133+
configuration.metadata && configuration.metadata.name &&
134+
SAP_THEMES_NS_EXEMPTIONS.includes(configuration.metadata.name)) {
135+
configuration.type = "theme-library";
136+
}
137+
});
138+
130139
const specs = await Promise.all(configs.map(async (configuration) => {
131140
const spec = await Specification.create({
132141
id: this.getId(),
@@ -258,7 +267,7 @@ class Module {
258267
`${this.getId()} at "${configPath}". Error: ${err.message}`);
259268
}
260269
if (!configResource) {
261-
if (configPath !== defaultConfigPath) {
270+
if (configPath !== DEFAULT_CONFIG_PATH) {
262271
throw new Error("Failed to read configuration for module " +
263272
`${this.getId()}: Could not find configuration file in module at path '${configPath}'`);
264273
}

lib/specifications/types/Library.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ const {promisify} = require("util");
44
const resourceFactory = require("@ui5/fs").resourceFactory;
55
const ComponentProject = require("../ComponentProject");
66

7-
const SAP_THEMES_NS_EXEMPTIONS = ["themelib_sap_fiori_3", "themelib_sap_bluecrystal", "themelib_sap_belize"];
8-
9-
107
class Library extends ComponentProject {
118
constructor(parameters) {
129
super(parameters);
@@ -131,20 +128,7 @@ class Library extends ComponentProject {
131128
async _parseConfiguration(config) {
132129
await super._parseConfiguration(config);
133130

134-
try {
135-
this._namespace = await this.getNamespace();
136-
} catch (err) {
137-
if (SAP_THEMES_NS_EXEMPTIONS.includes(this.getName())) {
138-
// Exceptional handling for SAP theme libraries which used to be of type "library"
139-
// (today they use "theme-library").
140-
// To allow use of OpenUI5 theme libraries in versions lower than 1.75 we must ignore
141-
// namespace detection errors.
142-
this._log.verbose(`Ignoring failed namespace detection for exempted SAP theme library ` +
143-
`${this.getName()}: ${err.message}`);
144-
} else {
145-
throw err;
146-
}
147-
}
131+
this._namespace = await this.getNamespace();
148132

149133
if (!config.metadata.copyright) {
150134
try {

0 commit comments

Comments
 (0)