From f11ffa98142322891a130a8251a45837452d4ead Mon Sep 17 00:00:00 2001 From: Florian Vogt Date: Thu, 24 Mar 2022 14:08:50 +0100 Subject: [PATCH 1/6] [FEAT]: enable build with CSS variables --- lib/builder/BuildContext.js | 8 ++- lib/builder/ProjectBuildContext.js | 4 ++ lib/builder/builder.js | 10 ++- lib/tasks/TaskUtil.js | 12 ++++ lib/types/library/LibraryBuilder.js | 3 +- lib/types/themeLibrary/ThemeLibraryBuilder.js | 3 +- .../theme/j/themes/somefancytheme/Button.less | 3 + .../j/themes/somefancytheme/css_variables.css | 3 + .../somefancytheme/css_variables.source.less | 5 ++ .../j/themes/somefancytheme/library-RTL.css | 3 + .../somefancytheme/library-parameters.json | 1 + .../theme/j/themes/somefancytheme/library.css | 3 + .../themes/somefancytheme/library.source.less | 2 + .../somefancytheme/library_skeleton-RTL.css | 1 + .../somefancytheme/library_skeleton.css | 1 + test/lib/builder/BuildContext.js | 19 ++++++ test/lib/builder/ProjectBuildContext.js | 12 ++++ test/lib/builder/builder.js | 65 +++++++++++++++++++ test/lib/tasks/TaskUtil.js | 15 +++++ .../types/themeLibrary/ThemeLibraryBuilder.js | 6 ++ 20 files changed, 173 insertions(+), 6 deletions(-) create mode 100644 test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/Button.less create mode 100644 test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/css_variables.css create mode 100644 test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/css_variables.source.less create mode 100644 test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library-RTL.css create mode 100644 test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library-parameters.json create mode 100644 test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library.css create mode 100644 test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library.source.less create mode 100644 test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library_skeleton-RTL.css create mode 100644 test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library_skeleton.css diff --git a/lib/builder/BuildContext.js b/lib/builder/BuildContext.js index e445602dc..6ed64a0ab 100644 --- a/lib/builder/BuildContext.js +++ b/lib/builder/BuildContext.js @@ -15,22 +15,26 @@ const GLOBAL_TAGS = Object.freeze({ * @memberof module:@ui5/builder.builder */ class BuildContext { - constructor({rootProject}) { + constructor({rootProject, options = {}}) { if (!rootProject) { throw new Error(`Missing parameter 'rootProject'`); } this.rootProject = rootProject; this.projectBuildContexts = []; - this._resourceTagCollection = new ResourceTagCollection({ allowedTags: Object.values(GLOBAL_TAGS) }); + this.options = options; } getRootProject() { return this.rootProject; } + getOption(key) { + return this.options[key]; + } + createProjectContext({project, resources}) { const projectBuildContext = new ProjectBuildContext({ buildContext: this, diff --git a/lib/builder/ProjectBuildContext.js b/lib/builder/ProjectBuildContext.js index fc1a1c426..5f8bc5ab1 100644 --- a/lib/builder/ProjectBuildContext.js +++ b/lib/builder/ProjectBuildContext.js @@ -39,6 +39,10 @@ class ProjectBuildContext { return this._project === this._buildContext.getRootProject(); } + getOption(key) { + return this._buildContext.getOption(key); + } + registerCleanupTask(callback) { this.queues.cleanup.push(callback); } diff --git a/lib/builder/builder.js b/lib/builder/builder.js index d48d9f527..e32137529 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -224,6 +224,7 @@ module.exports = { * @param {boolean} [parameters.dev=false] * Decides whether a development build should be activated (skips non-essential and time-intensive tasks) * @param {boolean} [parameters.selfContained=false] Flag to activate self contained build + * @param {boolean} [parameters.cssVariables=false] Flag to activate CSS variables generation * @param {boolean} [parameters.jsdoc=false] Flag to activate JSDoc build * @param {Array.} [parameters.includedTasks=[]] List of tasks to be included * @param {Array.} [parameters.excludedTasks=[]] List of tasks to be excluded. @@ -234,7 +235,7 @@ module.exports = { async build({ tree, destPath, cleanDest = false, buildDependencies = false, includedDependencies = [], excludedDependencies = [], - dev = false, selfContained = false, jsdoc = false, + dev = false, selfContained = false, cssVariables = false, jsdoc = false, includedTasks = [], excludedTasks = [], devExcludeProject = [] }) { const startTime = process.hrtime(); @@ -249,7 +250,12 @@ module.exports = { virBasePath: "/" }); - const buildContext = new BuildContext({rootProject: tree}); + const buildContext = new BuildContext({ + rootProject: tree, + options: { + cssVariables: cssVariables + } + }); const cleanupSigHooks = registerCleanupSigHooks(buildContext); const projects = {}; // Unique project index to prevent building the same project multiple times diff --git a/lib/tasks/TaskUtil.js b/lib/tasks/TaskUtil.js index 9e397a62e..97e8d2742 100644 --- a/lib/tasks/TaskUtil.js +++ b/lib/tasks/TaskUtil.js @@ -108,6 +108,18 @@ class TaskUtil { return this._projectBuildContext.isRootProject(); } + /** + * Retrieves a build option defined by it's keykey is stored, undefined is returned. + * + * @param {string} key The option key + * @returns {object|undefined} The build option (or undefined) + * @public + */ + getBuildOption(key) { + return this._projectBuildContext.getOption(key); + } + /** * Register a function that must be executed once the build is finished. This can be used to, for example, * clean up files temporarily created on the file system. If the callback returns a Promise, it will be waited for. diff --git a/lib/types/library/LibraryBuilder.js b/lib/types/library/LibraryBuilder.js index 13e322217..01c79e96a 100644 --- a/lib/types/library/LibraryBuilder.js +++ b/lib/types/library/LibraryBuilder.js @@ -198,7 +198,8 @@ class LibraryBuilder extends AbstractBuilder { projectName: project.metadata.name, librariesPattern: !taskUtil.isRootProject() ? "/resources/**/(*.library|library.js)" : undefined, themesPattern: !taskUtil.isRootProject() ? "/resources/sap/ui/core/themes/*" : undefined, - inputPattern + inputPattern, + cssVariables: taskUtil.getBuildOption("cssVariables") } }); }); diff --git a/lib/types/themeLibrary/ThemeLibraryBuilder.js b/lib/types/themeLibrary/ThemeLibraryBuilder.js index 1404357a1..e9de714c8 100644 --- a/lib/types/themeLibrary/ThemeLibraryBuilder.js +++ b/lib/types/themeLibrary/ThemeLibraryBuilder.js @@ -31,7 +31,8 @@ class ThemeLibraryBuilder extends AbstractBuilder { projectName: project.metadata.name, librariesPattern: !taskUtil.isRootProject() ? "/resources/**/(*.library|library.js)" : undefined, themesPattern: !taskUtil.isRootProject() ? "/resources/sap/ui/core/themes/*" : undefined, - inputPattern: "/resources/**/themes/*/library.source.less" + inputPattern: "/resources/**/themes/*/library.source.less", + cssVariables: taskUtil.getBuildOption("cssVariables") } }); }); diff --git a/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/Button.less b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/Button.less new file mode 100644 index 000000000..ca968183f --- /dev/null +++ b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/Button.less @@ -0,0 +1,3 @@ +.someClass { + color: @someColor +} diff --git a/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/css_variables.css b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/css_variables.css new file mode 100644 index 000000000..6232d9e35 --- /dev/null +++ b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/css_variables.css @@ -0,0 +1,3 @@ +:root{--someColor:#000} +/* Inline theming parameters */ +#sap-ui-theme-theme\.j{background-image:url('data:text/plain;utf-8,%7B%22someColor%22%3A%22%23000%22%7D')} diff --git a/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/css_variables.source.less b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/css_variables.source.less new file mode 100644 index 000000000..5a6ce08e9 --- /dev/null +++ b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/css_variables.source.less @@ -0,0 +1,5 @@ +@someColor: #000000; + +:root { +--someColor: @someColor; +} diff --git a/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library-RTL.css b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library-RTL.css new file mode 100644 index 000000000..5009ca50e --- /dev/null +++ b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library-RTL.css @@ -0,0 +1,3 @@ +.someClass{color:#000} +/* Inline theming parameters */ +#sap-ui-theme-theme\.j{background-image:url('data:text/plain;utf-8,%7B%22someColor%22%3A%22%23000%22%7D')} diff --git a/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library-parameters.json b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library-parameters.json new file mode 100644 index 000000000..a190cda03 --- /dev/null +++ b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library-parameters.json @@ -0,0 +1 @@ +{"someColor":"#000"} \ No newline at end of file diff --git a/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library.css b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library.css new file mode 100644 index 000000000..5009ca50e --- /dev/null +++ b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library.css @@ -0,0 +1,3 @@ +.someClass{color:#000} +/* Inline theming parameters */ +#sap-ui-theme-theme\.j{background-image:url('data:text/plain;utf-8,%7B%22someColor%22%3A%22%23000%22%7D')} diff --git a/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library.source.less b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library.source.less new file mode 100644 index 000000000..834de919e --- /dev/null +++ b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library.source.less @@ -0,0 +1,2 @@ +@someColor: black; +@import "Button.less"; diff --git a/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library_skeleton-RTL.css b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library_skeleton-RTL.css new file mode 100644 index 000000000..7db086289 --- /dev/null +++ b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library_skeleton-RTL.css @@ -0,0 +1 @@ +.someClass{color:var(--someColor)} \ No newline at end of file diff --git a/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library_skeleton.css b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library_skeleton.css new file mode 100644 index 000000000..7db086289 --- /dev/null +++ b/test/expected/build/theme.j/dest-css-variables/resources/theme/j/themes/somefancytheme/library_skeleton.css @@ -0,0 +1 @@ +.someClass{color:var(--someColor)} \ No newline at end of file diff --git a/test/lib/builder/BuildContext.js b/test/lib/builder/BuildContext.js index 7b6af6aea..83af09a80 100644 --- a/test/lib/builder/BuildContext.js +++ b/test/lib/builder/BuildContext.js @@ -25,6 +25,25 @@ test("getRootProject", (t) => { t.is(buildContext.getRootProject(), "pony", "Returned correct value"); }); +test("getBuildOption", (t) => { + const buildContext = new BuildContext({ + rootProject: "root_project", + options: { + a: true, + b: "Pony", + c: 235, + d: { + d1: "Bee" + } + } + }); + + t.is(buildContext.getOption("a"), true, "Returned 'boolean' value is correct"); + t.is(buildContext.getOption("b"), "Pony", "Returned 'String' value is correct"); + t.is(buildContext.getOption("c"), 235, "Returned 'Number' value is correct"); + t.deepEqual(buildContext.getOption("d"), {d1: "Bee"}, "Returned 'object' value is correct"); +}); + test.serial("createProjectContext", (t) => { class DummyProjectContext { constructor({buildContext, project, resources, globalTags}) { diff --git a/test/lib/builder/ProjectBuildContext.js b/test/lib/builder/ProjectBuildContext.js index 911ef92a0..da765408f 100644 --- a/test/lib/builder/ProjectBuildContext.js +++ b/test/lib/builder/ProjectBuildContext.js @@ -56,6 +56,18 @@ test("isRootProject: false", (t) => { t.false(projectBuildContext.isRootProject(), "Correctly identified non-root project"); }); +test("getBuildOption", (t) => { + const projectBuildContext = new ProjectBuildContext({ + buildContext: { + getOption: () => "Pony" + }, + project: "my project", + resources: "resources" + }); + + t.deepEqual(projectBuildContext.getOption("a"), "Pony", "Returned value is correct"); +}); + test("registerCleanupTask", (t) => { const projectBuildContext = new ProjectBuildContext({ buildContext: { diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 6b9403a1a..1d807f1ab 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -31,6 +31,7 @@ const libraryØPath = path.join(__dirname, "..", "..", "fixtures", "library.ø") const libraryCore = path.join(__dirname, "..", "..", "fixtures", "sap.ui.core-evo"); const libraryCoreBuildtime = path.join(__dirname, "..", "..", "fixtures", "sap.ui.core-buildtime"); const themeJPath = path.join(__dirname, "..", "..", "fixtures", "theme.j"); +const themeLibraryEPath = path.join(__dirname, "..", "..", "fixtures", "theme.library.e"); const recursive = require("recursive-readdir"); @@ -111,9 +112,11 @@ test.serial("Build", async (t) => { getTag: getTagStub }); const isRootProjectStub = sinon.stub().returns(true); + const getOptionStub = sinon.stub().returns("Pony"); const dummyProjectContext = { getResourceTagCollection: getResourceTagCollectionStub, isRootProject: isRootProjectStub, + getOption: getOptionStub, STANDARD_TAGS: { OmitFromBuildResult: "👻" } @@ -930,6 +933,44 @@ test.serial("Build library.coreBuildtime: replaceBuildtime", (t) => { }); }); +test.serial("Build library with theme configured for CSS variables", (t) => { + const destPath = "./test/tmp/build/theme.j/dest-css-variables"; + const expectedPath = "./test/expected/build/theme.j/dest-css-variables"; + return builder.build({ + tree: themeJTree, + cssVariables: true, + destPath + }).then(() => { + return findFiles(expectedPath); + }).then((expectedFiles) => { + // Check for all directories and files + assert.directoryDeepEqual(destPath, expectedPath); + + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); + }).then(() => { + t.pass(); + }); +}); + +test.serial("Build theme-library with CSS variables", (t) => { + const destPath = "./test/tmp/build/theme.library.e/dest-css-variables"; + const expectedPath = "./test/expected/build/theme.library.e/dest-css-variables"; + return builder.build({ + tree: themeLibraryETree, + cssVariables: true, + destPath + }).then(() => { + return findFiles(expectedPath); + }).then((expectedFiles) => { + // Check for all directories and files + assert.directoryDeepEqual(destPath, expectedPath); + + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); + }).then(() => { + t.pass(); + }); +}); + test.serial("Cleanup", async (t) => { const BuildContext = require("../../../lib/builder/BuildContext"); const createProjectContextStub = sinon.spy(BuildContext.prototype, "createProjectContext"); @@ -1939,3 +1980,27 @@ const themeJTree = { } } }; + +const themeLibraryETree = { + "id": "theme.library.e.id", + "version": "1.0.0", + "path": themeLibraryEPath, + "dependencies": [], + "_level": 0, + "_isRoot": true, + "specVersion": "1.1", + "type": "theme-library", + "metadata": { + "name": "theme.library.e", + "namespace": "theme/library/e", + "copyright": "Some fancy copyright" + }, + "resources": { + "configuration": { + "paths": { + "src": "src", + "test": "test" + } + } + } +}; diff --git a/test/lib/tasks/TaskUtil.js b/test/lib/tasks/TaskUtil.js index 5f2aba82c..cdb2c3dc5 100644 --- a/test/lib/tasks/TaskUtil.js +++ b/test/lib/tasks/TaskUtil.js @@ -93,6 +93,21 @@ test("isRootProject", async (t) => { t.is(res, true, "Correct result"); }); +test("getBuildOption", (t) => { + const getOptionStub = sinon.stub().returns("Pony"); + const taskUtil = new TaskUtil({ + projectBuildContext: { + STANDARD_TAGS: ["some tag"], + getOption: getOptionStub + } + }); + + const res = taskUtil.getBuildOption("friend"); + + t.is(getOptionStub.callCount, 1, "ProjectBuildContext#getBuildOption got called once"); + t.is(res, "Pony", "Correct result"); +}); + test("registerCleanupTask", async (t) => { const registerCleanupTaskStub = sinon.stub(); const taskUtil = new TaskUtil({ diff --git a/test/lib/types/themeLibrary/ThemeLibraryBuilder.js b/test/lib/types/themeLibrary/ThemeLibraryBuilder.js index 687d77966..75e4d70af 100644 --- a/test/lib/types/themeLibrary/ThemeLibraryBuilder.js +++ b/test/lib/types/themeLibrary/ThemeLibraryBuilder.js @@ -44,6 +44,12 @@ test("tasks", async (t) => { taskUtil: { isRootProject: () => { return true; + }, + getBuildOptions: () => { + return {}; + }, + getBuildOption: (key) => { + return key; } } }); From 825bba412275137c44d3c000059bc47244fea0eb Mon Sep 17 00:00:00 2001 From: Florian Vogt Date: Wed, 30 Mar 2022 16:28:36 +0200 Subject: [PATCH 2/6] Fix test --- test/lib/builder/ProjectBuildContext.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/lib/builder/ProjectBuildContext.js b/test/lib/builder/ProjectBuildContext.js index da765408f..987318d7b 100644 --- a/test/lib/builder/ProjectBuildContext.js +++ b/test/lib/builder/ProjectBuildContext.js @@ -59,8 +59,10 @@ test("isRootProject: false", (t) => { test("getBuildOption", (t) => { const projectBuildContext = new ProjectBuildContext({ buildContext: { - getOption: () => "Pony" + getOption: () => "Pony", + getResourceTagCollection: () => t.context.resourceTagCollection }, + globalTags: {MyTag: "me:MyTag"}, project: "my project", resources: "resources" }); From 6baa6dc1e0810729858d6bda0198c5bef04550fb Mon Sep 17 00:00:00 2001 From: Florian Vogt Date: Thu, 31 Mar 2022 13:57:01 +0200 Subject: [PATCH 3/6] fix integration test --- .../theme/library/e/themes/my_theme/.theme | 9 +++++++ .../theme/library/e/themes}/my_theme/.theming | 0 .../e/themes/my_theme/css_variables.css | 3 +++ .../themes/my_theme/css_variables.source.less | 5 ++++ .../library/e/themes/my_theme/library-RTL.css | 5 ++++ .../e/themes/my_theme/library-parameters.json | 1 + .../library/e/themes/my_theme/library.css | 5 ++++ .../e/themes/my_theme/library.source.less | 9 +++++++ .../themes/my_theme/library_skeleton-RTL.css | 3 +++ .../e/themes/my_theme/library_skeleton.css | 3 +++ .../test-resources/theme/library/e/Test.html | 0 .../library/e/my_theme/library.source.less | 18 ------------- .../library/e/{ => themes}/my_theme/.theme | 0 .../theme/library/e/themes/my_theme/.theming | 27 +++++++++++++++++++ .../e/themes/my_theme/library.source.less | 9 +++++++ test/lib/builder/builder.js | 4 +++ 16 files changed, 83 insertions(+), 18 deletions(-) create mode 100644 test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/.theme rename test/{fixtures/theme.library.e/src/theme/library/e => expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes}/my_theme/.theming (100%) create mode 100644 test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/css_variables.css create mode 100644 test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/css_variables.source.less create mode 100644 test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library-RTL.css create mode 100644 test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library-parameters.json create mode 100644 test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library.css create mode 100644 test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library.source.less create mode 100644 test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library_skeleton-RTL.css create mode 100644 test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library_skeleton.css create mode 100644 test/expected/build/theme.library.e/dest-css-variables/test-resources/theme/library/e/Test.html delete mode 100644 test/fixtures/theme.library.e/src/theme/library/e/my_theme/library.source.less rename test/fixtures/theme.library.e/src/theme/library/e/{ => themes}/my_theme/.theme (100%) create mode 100644 test/fixtures/theme.library.e/src/theme/library/e/themes/my_theme/.theming create mode 100644 test/fixtures/theme.library.e/src/theme/library/e/themes/my_theme/library.source.less diff --git a/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/.theme b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/.theme new file mode 100644 index 000000000..4b4b1cf98 --- /dev/null +++ b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/.theme @@ -0,0 +1,9 @@ + + + + my_theme + me + Some fancy copyright + 1.0.0 + + \ No newline at end of file diff --git a/test/fixtures/theme.library.e/src/theme/library/e/my_theme/.theming b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/.theming similarity index 100% rename from test/fixtures/theme.library.e/src/theme/library/e/my_theme/.theming rename to test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/.theming diff --git a/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/css_variables.css b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/css_variables.css new file mode 100644 index 000000000..48bb66a3e --- /dev/null +++ b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/css_variables.css @@ -0,0 +1,3 @@ +:root{--mycolor:#00f} +/* Inline theming parameters */ +#sap-ui-theme-theme\.library\.e{background-image:url('data:text/plain;utf-8,%7B%22mycolor%22%3A%22%2300f%22%7D')} diff --git a/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/css_variables.source.less b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/css_variables.source.less new file mode 100644 index 000000000..28ed8727a --- /dev/null +++ b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/css_variables.source.less @@ -0,0 +1,5 @@ +@mycolor: #0000ff; + +:root { +--mycolor: @mycolor; +} diff --git a/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library-RTL.css b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library-RTL.css new file mode 100644 index 000000000..5eac03f06 --- /dev/null +++ b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library-RTL.css @@ -0,0 +1,5 @@ +/*! + * Some fancy copyright + */.sapUiBody{background-color:#00f} +/* Inline theming parameters */ +#sap-ui-theme-theme\.library\.e{background-image:url('data:text/plain;utf-8,%7B%22mycolor%22%3A%22%2300f%22%7D')} diff --git a/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library-parameters.json b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library-parameters.json new file mode 100644 index 000000000..a0c491380 --- /dev/null +++ b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library-parameters.json @@ -0,0 +1 @@ +{"mycolor":"#00f"} \ No newline at end of file diff --git a/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library.css b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library.css new file mode 100644 index 000000000..5eac03f06 --- /dev/null +++ b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library.css @@ -0,0 +1,5 @@ +/*! + * Some fancy copyright + */.sapUiBody{background-color:#00f} +/* Inline theming parameters */ +#sap-ui-theme-theme\.library\.e{background-image:url('data:text/plain;utf-8,%7B%22mycolor%22%3A%22%2300f%22%7D')} diff --git a/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library.source.less b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library.source.less new file mode 100644 index 000000000..d864e666d --- /dev/null +++ b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library.source.less @@ -0,0 +1,9 @@ +/*! + * Some fancy copyright + */ + +@mycolor: blue; + +.sapUiBody { + background-color: @mycolor; +} diff --git a/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library_skeleton-RTL.css b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library_skeleton-RTL.css new file mode 100644 index 000000000..654b3877e --- /dev/null +++ b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library_skeleton-RTL.css @@ -0,0 +1,3 @@ +/*! + * Some fancy copyright + */.sapUiBody{background-color:var(--mycolor)} \ No newline at end of file diff --git a/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library_skeleton.css b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library_skeleton.css new file mode 100644 index 000000000..654b3877e --- /dev/null +++ b/test/expected/build/theme.library.e/dest-css-variables/resources/theme/library/e/themes/my_theme/library_skeleton.css @@ -0,0 +1,3 @@ +/*! + * Some fancy copyright + */.sapUiBody{background-color:var(--mycolor)} \ No newline at end of file diff --git a/test/expected/build/theme.library.e/dest-css-variables/test-resources/theme/library/e/Test.html b/test/expected/build/theme.library.e/dest-css-variables/test-resources/theme/library/e/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/fixtures/theme.library.e/src/theme/library/e/my_theme/library.source.less b/test/fixtures/theme.library.e/src/theme/library/e/my_theme/library.source.less deleted file mode 100644 index ba66d46d7..000000000 --- a/test/fixtures/theme.library.e/src/theme/library/e/my_theme/library.source.less +++ /dev/null @@ -1,18 +0,0 @@ -/*! - * ${copyright} - */ - -* { - -webkit-tap-highlight-color: rgba(0, 0, 0, 0); - -webkit-touch-callout: none; - -webkit-text-size-adjust: none; - -ms-text-size-adjust: none; -} - -.sapUiBody { - width: 100%; - height: 100%; - margin: 0; - font-family: @sapUiFontFamily; - font-size: 1rem; -} diff --git a/test/fixtures/theme.library.e/src/theme/library/e/my_theme/.theme b/test/fixtures/theme.library.e/src/theme/library/e/themes/my_theme/.theme similarity index 100% rename from test/fixtures/theme.library.e/src/theme/library/e/my_theme/.theme rename to test/fixtures/theme.library.e/src/theme/library/e/themes/my_theme/.theme diff --git a/test/fixtures/theme.library.e/src/theme/library/e/themes/my_theme/.theming b/test/fixtures/theme.library.e/src/theme/library/e/themes/my_theme/.theming new file mode 100644 index 000000000..83b6c785a --- /dev/null +++ b/test/fixtures/theme.library.e/src/theme/library/e/themes/my_theme/.theming @@ -0,0 +1,27 @@ +{ + "sEntity": "Theme", + "sId": "sap_belize", + "oExtends": "base", + "sVendor": "SAP", + "aBundled": ["sap_belize_plus"], + "mCssScopes": { + "library": { + "sBaseFile": "library", + "sEmbeddingMethod": "APPEND", + "aScopes": [ + { + "sLabel": "Contrast", + "sSelector": "sapContrast", + "sEmbeddedFile": "sap_belize_plus.library", + "sEmbeddedCompareFile": "library", + "sThemeIdSuffix": "Contrast", + "sThemability": "PUBLIC", + "aThemabilityFilter": [ + "Color" + ], + "rExcludeSelector": "\\.sapContrastPlus\\W" + } + ] + } + } +} diff --git a/test/fixtures/theme.library.e/src/theme/library/e/themes/my_theme/library.source.less b/test/fixtures/theme.library.e/src/theme/library/e/themes/my_theme/library.source.less new file mode 100644 index 000000000..d3286002b --- /dev/null +++ b/test/fixtures/theme.library.e/src/theme/library/e/themes/my_theme/library.source.less @@ -0,0 +1,9 @@ +/*! + * ${copyright} + */ + +@mycolor: blue; + +.sapUiBody { + background-color: @mycolor; +} diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 1d807f1ab..1561f4e80 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -2001,6 +2001,10 @@ const themeLibraryETree = { "src": "src", "test": "test" } + }, + "pathMappings": { + "/resources/": "src", + "/test-resources/": "test" } } }; From c80883b40235aa5c307a197ce282fd81468c863f Mon Sep 17 00:00:00 2001 From: Florian Vogt Date: Thu, 31 Mar 2022 14:18:57 +0200 Subject: [PATCH 4/6] remove unused code --- test/lib/types/themeLibrary/ThemeLibraryBuilder.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/lib/types/themeLibrary/ThemeLibraryBuilder.js b/test/lib/types/themeLibrary/ThemeLibraryBuilder.js index 75e4d70af..a20bad8f3 100644 --- a/test/lib/types/themeLibrary/ThemeLibraryBuilder.js +++ b/test/lib/types/themeLibrary/ThemeLibraryBuilder.js @@ -45,9 +45,6 @@ test("tasks", async (t) => { isRootProject: () => { return true; }, - getBuildOptions: () => { - return {}; - }, getBuildOption: (key) => { return key; } From a896529c9ef104b5860c42afffb23529a1579b3f Mon Sep 17 00:00:00 2001 From: Florian Vogt Date: Mon, 4 Apr 2022 17:02:05 +0200 Subject: [PATCH 5/6] adjust jsdoc return value remove --- lib/tasks/TaskUtil.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/TaskUtil.js b/lib/tasks/TaskUtil.js index 97e8d2742..9096414f5 100644 --- a/lib/tasks/TaskUtil.js +++ b/lib/tasks/TaskUtil.js @@ -113,8 +113,8 @@ class TaskUtil { * If no option with the given key is stored, undefined is returned. * * @param {string} key The option key - * @returns {object|undefined} The build option (or undefined) - * @public + * @returns {any|undefined} The build option (or undefined) + * @private */ getBuildOption(key) { return this._projectBuildContext.getOption(key); From be326f5775c8c07483ae217e87ce902251e2c59c Mon Sep 17 00:00:00 2001 From: Florian Vogt Date: Tue, 5 Apr 2022 14:12:59 +0200 Subject: [PATCH 6/6] Adjust code to UA review --- lib/tasks/TaskUtil.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/TaskUtil.js b/lib/tasks/TaskUtil.js index 9096414f5..f751617c5 100644 --- a/lib/tasks/TaskUtil.js +++ b/lib/tasks/TaskUtil.js @@ -109,7 +109,7 @@ class TaskUtil { } /** - * Retrieves a build option defined by it's keykeykey is stored, undefined is returned. * * @param {string} key The option key