Skip to content

Commit d7af752

Browse files
committed
Adopt metadata value / enhance object
Now just using JSON.stringify without wrapping the value in quotes
1 parent 5353a22 commit d7af752

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

lib/index.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const ImportCollectorPlugin = require("./plugin/import-collector");
1515
const VariableCollectorPlugin = require("./plugin/variable-collector");
1616
const UrlCollector = require("./plugin/url-collector");
1717

18+
const LESS_OPENUI5_VERSION = require("../package.json").version;
19+
1820
// Workaround for a performance issue in the "css" parser module when used in combination
1921
// with the "colors" module that enhances the String prototype.
2022
// See: https://github.com/reworkcss/css/issues/88
@@ -363,12 +365,31 @@ Builder.prototype.build = function(options) {
363365
scopes = [];
364366
}
365367

366-
const metadataJson = JSON.stringify({"Scopes": scopes});
368+
const libraryNameSlashed = options.library.name.replace(/\./g, "/");
367369
const libraryNameDashed = options.library.name.replace(/\./g, "-");
370+
371+
// TODO: How to get theme name? .theming "sId"? parse from file path? new parameter?
372+
const themeId = "<theme-name>";
373+
374+
const metadataJson = JSON.stringify({
375+
"Path": `UI5.${libraryNameSlashed}.${themeId}.library`,
376+
"PathPattern": "/%frameworkId%/%libId%/themes/%themeId%/%fileId%.css",
377+
"Extends": ["base"], // TODO: Read from .theming?
378+
"Scopes": scopes,
379+
"Engine": {
380+
"Version": LESS_OPENUI5_VERSION,
381+
"Name": "less-openui5"
382+
},
383+
"Version": {
384+
"Build": "<TODO>", // TOOD: add new property options.library.version
385+
"Source": "<TODO>" // TOOD: add new property options.library.version
386+
}
387+
});
388+
368389
const additionalVariables = `
369390
:root {
370391
--sapUiTheme-${libraryNameDashed}: true;
371-
--sapThemeMetaData-UI5-${libraryNameDashed}: '${metadataJson}';
392+
--sapThemeMetaData-UI5-${libraryNameDashed}: ${metadataJson};
372393
}
373394
`;
374395
result.css = additionalVariables + result.cssVariables + "\n" + result.css;

0 commit comments

Comments
 (0)