From f2899e548c5a1ef1407eb9956a6636353c05b85d Mon Sep 17 00:00:00 2001 From: Thuy Boehm Date: Tue, 15 Oct 2019 10:46:21 +0200 Subject: [PATCH 1/7] add flexibility-bundle.json --- lib/processors/bundlers/flexChangesBundler.js | 55 ++++++++++++++++--- .../bundlers/generateFlexChangesBundle.js | 47 ++++++++++++++-- .../application.j/dest/Component-preload.js | 4 +- .../dest/changes/changes-bundle.json | 1 - .../dest/changes/flexibility-bundle.json | 1 + .../dest/changes/id_111_compVariants.change | 21 +++++++ .../dest/changes/id_111_test.ctrl_variant | 20 +++++++ .../changes/id_111_test.ctrl_variant_change | 20 +++++++ ...id_111_test.ctrl_variant_management_change | 20 +++++++ ...d_111_variantDependentControlChange.change | 21 +++++++ .../build/application.j/dest/manifest.json | 1 + .../application.k/dest/Component-preload.js | 12 ++++ .../build/application.k/dest/Component.js | 1 + .../dest/changes/coding/MyExtension.js | 1 + .../dest/changes/flexibility-bundle.json | 1 + .../changes/fragments/MyFragment.fragment.xml | 3 + .../dest/changes/id_123_addField.change | 20 +++++++ .../dest/changes/id_456_addField.change | 20 +++++++ .../build/application.k/dest/manifest.json | 26 +++++++++ .../webapp/changes/id_111_compVariants.change | 21 +++++++ .../webapp/changes/id_111_test.ctrl_variant | 20 +++++++ .../changes/id_111_test.ctrl_variant_change | 20 +++++++ ...id_111_test.ctrl_variant_management_change | 20 +++++++ ...d_111_variantDependentControlChange.change | 21 +++++++ .../application.j/webapp/manifest.json | 35 ++++++------ test/fixtures/application.k/package.json | 10 ++++ test/fixtures/application.k/ui5.yaml | 25 +++++++++ .../application.k/webapp/Component.js | 8 +++ .../webapp/changes/coding/MyExtension.js | 3 + .../changes/fragments/MyFragment.fragment.xml | 3 + .../webapp/changes/id_123_addField.change | 20 +++++++ .../webapp/changes/id_456_addField.change | 20 +++++++ .../application.k/webapp/manifest.json | 23 ++++++++ test/lib/builder/builder.js | 49 +++++++++++++++++ 34 files changed, 560 insertions(+), 33 deletions(-) delete mode 100644 test/expected/build/application.j/dest/changes/changes-bundle.json create mode 100644 test/expected/build/application.j/dest/changes/flexibility-bundle.json create mode 100644 test/expected/build/application.j/dest/changes/id_111_compVariants.change create mode 100644 test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant create mode 100644 test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant_change create mode 100644 test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant_management_change create mode 100644 test/expected/build/application.j/dest/changes/id_111_variantDependentControlChange.change create mode 100644 test/expected/build/application.k/dest/Component-preload.js create mode 100644 test/expected/build/application.k/dest/Component.js create mode 100644 test/expected/build/application.k/dest/changes/coding/MyExtension.js create mode 100644 test/expected/build/application.k/dest/changes/flexibility-bundle.json create mode 100644 test/expected/build/application.k/dest/changes/fragments/MyFragment.fragment.xml create mode 100644 test/expected/build/application.k/dest/changes/id_123_addField.change create mode 100644 test/expected/build/application.k/dest/changes/id_456_addField.change create mode 100644 test/expected/build/application.k/dest/manifest.json create mode 100644 test/fixtures/application.j/webapp/changes/id_111_compVariants.change create mode 100644 test/fixtures/application.j/webapp/changes/id_111_test.ctrl_variant create mode 100644 test/fixtures/application.j/webapp/changes/id_111_test.ctrl_variant_change create mode 100644 test/fixtures/application.j/webapp/changes/id_111_test.ctrl_variant_management_change create mode 100644 test/fixtures/application.j/webapp/changes/id_111_variantDependentControlChange.change create mode 100644 test/fixtures/application.k/package.json create mode 100644 test/fixtures/application.k/ui5.yaml create mode 100644 test/fixtures/application.k/webapp/Component.js create mode 100644 test/fixtures/application.k/webapp/changes/coding/MyExtension.js create mode 100644 test/fixtures/application.k/webapp/changes/fragments/MyFragment.fragment.xml create mode 100644 test/fixtures/application.k/webapp/changes/id_123_addField.change create mode 100644 test/fixtures/application.k/webapp/changes/id_456_addField.change create mode 100644 test/fixtures/application.k/webapp/manifest.json diff --git a/lib/processors/bundlers/flexChangesBundler.js b/lib/processors/bundlers/flexChangesBundler.js index 8f68ff3cc..a9632af93 100644 --- a/lib/processors/bundlers/flexChangesBundler.js +++ b/lib/processors/bundlers/flexChangesBundler.js @@ -10,19 +10,60 @@ const resourceFactory = require("@ui5/fs").resourceFactory; * @param {module:@ui5/fs.Resource[]} parameters.resources List of resources to be processed * @param {Object} parameters.options Options * @param {string} parameters.options.pathPrefix Prefix for bundle path + * @param {string} parameters.options.hasFlexBundleVersion true if minUI5Version >= 1.72 than create flexibility-bundle.json * @returns {Promise} Promise resolving with flex changes bundle resources */ module.exports = function({resources, options}) { + let bundleName = "changes-bundle.json"; + function sortByTimeStamp(a, b) { return a.creation > b.creation ? 1 : -1; } - function sortAndStringify(changesContent) { + function sortAndStringifyInFlexFormat(changesContent) { changesContent = changesContent.sort(sortByTimeStamp); - changesContent = changesContent.map(function(change) { - return JSON.stringify(change); + const changeList = []; + const variantDependentControlChangeList = []; + const compVariantList = []; + const variantList = []; + const variantChangeList = []; + const variantManagementChangeList = []; + + changesContent.forEach(function(content) { + if (content.fileType == "change") { + if (content.appDescriptorChange && (content.appDescriptorChange == "true" || content.appDescriptorChange == true)) { + compVariantList.push(content); + } else { + if (content.variantReference && content.variantReference != "") { + variantDependentControlChangeList.push(content); + } else { + changeList.push(content); + } + } + } else if (content.fileType == "ctrl_variant") { + variantList.push(content); + } else if (content.fileType == "ctrl_variant_change") { + variantChangeList.push(content); + } else if (content.fileType == "ctrl_variant_management_change") { + variantManagementChangeList.push(content); + } }); - return changesContent; + + // create changes-bundle.json + if (!options.hasFlexBundleVersion && compVariantList.length == 0 && variantList.length == 0 && variantChangeList.length == 0 && variantDependentControlChangeList.length == 0 && variantManagementChangeList.length == 0) { + return JSON.stringify(changeList); + } else { + bundleName = "flexibility-bundle.json"; + const newChangeFormat = {}; + newChangeFormat.changes = changeList; + newChangeFormat.compVariants = compVariantList; + newChangeFormat.variants = variantList; + newChangeFormat.variantChanges = variantChangeList; + newChangeFormat.variantDependentControlChanges = variantDependentControlChangeList; + newChangeFormat.variantManagementChanges = variantManagementChangeList; + + return JSON.stringify(newChangeFormat); + } } return Promise.all(resources.map((resource) => { @@ -34,10 +75,10 @@ module.exports = function({resources, options}) { log.info("Changes collected. Number of changes: " + nNumberOfChanges); const result = []; if (nNumberOfChanges > 0) { - changesContent = sortAndStringify(changesContent); + changesContent = sortAndStringifyInFlexFormat(changesContent); result.push(resourceFactory.createResource({ - path: `${options.pathPrefix}/changes/changes-bundle.json`, - string: "[" + changesContent.join(",") + "]" + path: `${options.pathPrefix}/changes/` + bundleName, + string: changesContent })); } return result; diff --git a/lib/tasks/bundlers/generateFlexChangesBundle.js b/lib/tasks/bundlers/generateFlexChangesBundle.js index b45fdfad5..c26faa340 100644 --- a/lib/tasks/bundlers/generateFlexChangesBundle.js +++ b/lib/tasks/bundlers/generateFlexChangesBundle.js @@ -6,6 +6,8 @@ const flexChangesBundler = require("../../processors/bundlers/flexChangesBundler * at runtime. * If a change bundle is created, "sap.ui.fl" is added as a dependency to the manifest.json if not already present - * if the dependency is already listed but lazy-loaded, lazy loading is disabled. + * If minUI5Version >= 1.72 flexibility-bundle.json will be create. + * If there a ctrl_variants minUI5Version will update to 1.72 if it is below and flexibility-bundle.json will be create. * * @public * @alias module:@ui5/builder.tasks.generateFlexChangesBundle @@ -22,6 +24,8 @@ module.exports = function({workspace, options}) { if (options && options.namespace) { pathPrefix = `/resources/${options.namespace}`; } + let hasVariant = false; + let hasFlexBundleVersion = false; function updateJson(data) { // ensure the existence of the libs section in the dependencies @@ -39,6 +43,12 @@ module.exports = function({workspace, options}) { log.verbose("sap.ui.fl not found in manifest.json, inserting it..."); mLibs["sap.ui.fl"] = {}; } + + // if there are ctrl variant and minUI5Version < 1.72 need to update minUI5Version to 1.72.0 + if (hasVariant && !hasFlexBundleVersion) { + log.verbose("minUI5Version < 1.72, updated it to 1.72.0"); + data["sap.ui5"].dependencies.minUI5Version = "1.72.0"; + } } async function updateFLdependency() { @@ -51,15 +61,36 @@ module.exports = function({workspace, options}) { await workspace.write(manifestResource); } + function readManifestMinUI5Version() { + return workspace.byPath(`${pathPrefix}/manifest.json`).then((manifestResource) => { + if (manifestResource) { + return manifestResource.getBuffer().then((buffer) => { + return JSON.parse(buffer.toString()); + }); + } + return {}; + }).then((manifestContent) => { + manifestContent["sap.ui5"] = manifestContent["sap.ui5"] || {}; + manifestContent["sap.ui5"].dependencies = manifestContent["sap.ui5"].dependencies || {}; + return manifestContent["sap.ui5"].dependencies.minUI5Version = manifestContent["sap.ui5"].dependencies.minUI5Version || ""; + }); + } + log.verbose("Collecting flexibility changes"); - return workspace.byGlob(`${pathPrefix}/changes/*.change`) + return workspace.byGlob(`${pathPrefix}/changes/*.{change,variant,ctrl_variant,ctrl_variant_change,ctrl_variant_management_change}`) .then((allResources) => { - return flexChangesBundler({ - resources: allResources, - options: { - namespace: options.namespace, - pathPrefix: pathPrefix + return readManifestMinUI5Version().then((version) => { + if (parseFloat(version) >= 1.72) { + hasFlexBundleVersion = true; } + return flexChangesBundler({ + resources: allResources, + options: { + namespace: options.namespace, + pathPrefix: pathPrefix, + hasFlexBundleVersion: hasFlexBundleVersion + } + }); }); }) .then((processedResources) => { @@ -69,6 +100,10 @@ module.exports = function({workspace, options}) { })).then(async () => { // Add the sap.ui.fl dependency if a bundle has been created if (processedResources.length > 0) { + // flexibility-bundle.json can be create when there are ctrl variant even though minUI5Version is below 1.72 + if (processedResources[0]._name == "flexibility-bundle.json") { + hasVariant = true; + } await updateFLdependency(); } }); diff --git a/test/expected/build/application.j/dest/Component-preload.js b/test/expected/build/application.j/dest/Component-preload.js index 8b4bc76e1..7b1c62e8b 100644 --- a/test/expected/build/application.j/dest/Component-preload.js +++ b/test/expected/build/application.j/dest/Component-preload.js @@ -4,9 +4,9 @@ jQuery.sap.registerPreloadedModules({ "modules":{ "application/j/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.j.Component",{metadata:{manifest:"json"}})}); }, - "application/j/changes/changes-bundle.json":'[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}]', "application/j/changes/coding/MyExtension.js":function(){sap.ui.define([],function(){return{}}); }, + "application/j/changes/flexibility-bundle.json":'{"changes":[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"compVariants":[{"fileName":"id_111_compVariants","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"appDescriptorChange":true}],"variants":[{"fileName":"id_111_test","fileType":"ctrl_variant","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantDependentControlChanges":[{"fileName":"id_111_variantDependentControlChange","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"variantReference":"someting here"}],"variantManagementChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_management_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}]}', "application/j/changes/fragments/MyFragment.fragment.xml":'', - "application/j/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.j","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"},"sap.ui5":{"dependencies":{"libs":{"sap.ui.layout":{},"sap.ui.core":{},"sap.m":{},"sap.ui.fl":{"lazy":false}}}}}' + "application/j/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.j","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"},"sap.ui5":{"dependencies":{"minUI5Version":"1.72.0","libs":{"sap.ui.layout":{},"sap.ui.core":{},"sap.m":{},"sap.ui.fl":{"lazy":false}}}}}' }}); diff --git a/test/expected/build/application.j/dest/changes/changes-bundle.json b/test/expected/build/application.j/dest/changes/changes-bundle.json deleted file mode 100644 index 0e270c459..000000000 --- a/test/expected/build/application.j/dest/changes/changes-bundle.json +++ /dev/null @@ -1 +0,0 @@ -[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}] \ No newline at end of file diff --git a/test/expected/build/application.j/dest/changes/flexibility-bundle.json b/test/expected/build/application.j/dest/changes/flexibility-bundle.json new file mode 100644 index 000000000..7caa00b9a --- /dev/null +++ b/test/expected/build/application.j/dest/changes/flexibility-bundle.json @@ -0,0 +1 @@ +{"changes":[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"compVariants":[{"fileName":"id_111_compVariants","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"appDescriptorChange":true}],"variants":[{"fileName":"id_111_test","fileType":"ctrl_variant","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantDependentControlChanges":[{"fileName":"id_111_variantDependentControlChange","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"variantReference":"someting here"}],"variantManagementChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_management_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}]} \ No newline at end of file diff --git a/test/expected/build/application.j/dest/changes/id_111_compVariants.change b/test/expected/build/application.j/dest/changes/id_111_compVariants.change new file mode 100644 index 000000000..9c7f911b9 --- /dev/null +++ b/test/expected/build/application.j/dest/changes/id_111_compVariants.change @@ -0,0 +1,21 @@ +{ + "fileName": "id_111_compVariants", + "fileType": "change", + "changeType": "hideControl", + "component": "application.j.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.j.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + }, + "appDescriptorChange": true +} diff --git a/test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant b/test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant new file mode 100644 index 000000000..01d2bfb47 --- /dev/null +++ b/test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant @@ -0,0 +1,20 @@ +{ + "fileName": "id_111_test", + "fileType": "ctrl_variant", + "changeType": "hideControl", + "component": "application.j.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.j.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + } +} diff --git a/test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant_change b/test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant_change new file mode 100644 index 000000000..8691c2e82 --- /dev/null +++ b/test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant_change @@ -0,0 +1,20 @@ +{ + "fileName": "id_111_test", + "fileType": "ctrl_variant_change", + "changeType": "hideControl", + "component": "application.j.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.j.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + } +} diff --git a/test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant_management_change b/test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant_management_change new file mode 100644 index 000000000..1e1f585c8 --- /dev/null +++ b/test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant_management_change @@ -0,0 +1,20 @@ +{ + "fileName": "id_111_test", + "fileType": "ctrl_variant_management_change", + "changeType": "hideControl", + "component": "application.j.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.j.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + } +} diff --git a/test/expected/build/application.j/dest/changes/id_111_variantDependentControlChange.change b/test/expected/build/application.j/dest/changes/id_111_variantDependentControlChange.change new file mode 100644 index 000000000..bd733b67e --- /dev/null +++ b/test/expected/build/application.j/dest/changes/id_111_variantDependentControlChange.change @@ -0,0 +1,21 @@ +{ + "fileName": "id_111_variantDependentControlChange", + "fileType": "change", + "changeType": "hideControl", + "component": "application.j.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.j.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + }, + "variantReference": "someting here" +} diff --git a/test/expected/build/application.j/dest/manifest.json b/test/expected/build/application.j/dest/manifest.json index eb1a2c611..3e85f9dad 100644 --- a/test/expected/build/application.j/dest/manifest.json +++ b/test/expected/build/application.j/dest/manifest.json @@ -14,6 +14,7 @@ }, "sap.ui5": { "dependencies": { + "minUI5Version": "1.72.0", "libs": { "sap.ui.layout": {}, "sap.ui.core": {}, diff --git a/test/expected/build/application.k/dest/Component-preload.js b/test/expected/build/application.k/dest/Component-preload.js new file mode 100644 index 000000000..90023265a --- /dev/null +++ b/test/expected/build/application.k/dest/Component-preload.js @@ -0,0 +1,12 @@ +//@ui5-bundle application/k/Component-preload.js +jQuery.sap.registerPreloadedModules({ +"version":"2.0", +"modules":{ + "application/k/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.k.Component",{metadata:{manifest:"json"}})}); +}, + "application/k/changes/coding/MyExtension.js":function(){sap.ui.define([],function(){return{}}); +}, + "application/k/changes/flexibility-bundle.json":'{"changes":[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.k.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.k.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.k.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.k.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"compVariants":[],"variants":[],"variantChanges":[],"variantDependentControlChanges":[],"variantManagementChanges":[]}', + "application/k/changes/fragments/MyFragment.fragment.xml":'', + "application/k/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.k","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"},"sap.ui5":{"dependencies":{"minUI5Version":"1.73.0","libs":{"sap.ui.layout":{},"sap.ui.core":{},"sap.m":{},"sap.ui.fl":{}}}}}' +}}); diff --git a/test/expected/build/application.k/dest/Component.js b/test/expected/build/application.k/dest/Component.js new file mode 100644 index 000000000..3da3da77e --- /dev/null +++ b/test/expected/build/application.k/dest/Component.js @@ -0,0 +1 @@ +sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.k.Component",{metadata:{manifest:"json"}})}); \ No newline at end of file diff --git a/test/expected/build/application.k/dest/changes/coding/MyExtension.js b/test/expected/build/application.k/dest/changes/coding/MyExtension.js new file mode 100644 index 000000000..b9e475d8e --- /dev/null +++ b/test/expected/build/application.k/dest/changes/coding/MyExtension.js @@ -0,0 +1 @@ +sap.ui.define([],function(){return{}}); \ No newline at end of file diff --git a/test/expected/build/application.k/dest/changes/flexibility-bundle.json b/test/expected/build/application.k/dest/changes/flexibility-bundle.json new file mode 100644 index 000000000..90315336c --- /dev/null +++ b/test/expected/build/application.k/dest/changes/flexibility-bundle.json @@ -0,0 +1 @@ +{"changes":[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.k.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.k.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.k.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.k.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"compVariants":[],"variants":[],"variantChanges":[],"variantDependentControlChanges":[],"variantManagementChanges":[]} \ No newline at end of file diff --git a/test/expected/build/application.k/dest/changes/fragments/MyFragment.fragment.xml b/test/expected/build/application.k/dest/changes/fragments/MyFragment.fragment.xml new file mode 100644 index 000000000..39ce6859b --- /dev/null +++ b/test/expected/build/application.k/dest/changes/fragments/MyFragment.fragment.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/test/expected/build/application.k/dest/changes/id_123_addField.change b/test/expected/build/application.k/dest/changes/id_123_addField.change new file mode 100644 index 000000000..e59ffd8b8 --- /dev/null +++ b/test/expected/build/application.k/dest/changes/id_123_addField.change @@ -0,0 +1,20 @@ +{ + "fileName": "id_123_addField", + "fileType": "change", + "changeType": "hideControl", + "component": "application.k.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.k.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + } +} diff --git a/test/expected/build/application.k/dest/changes/id_456_addField.change b/test/expected/build/application.k/dest/changes/id_456_addField.change new file mode 100644 index 000000000..4baa3fc0b --- /dev/null +++ b/test/expected/build/application.k/dest/changes/id_456_addField.change @@ -0,0 +1,20 @@ +{ + "fileName": "id_456_addField", + "fileType": "change", + "changeType": "hideControl", + "component": "application.k.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.k.Component/changes", + "creation": "2023-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + } +} diff --git a/test/expected/build/application.k/dest/manifest.json b/test/expected/build/application.k/dest/manifest.json new file mode 100644 index 000000000..653fec68d --- /dev/null +++ b/test/expected/build/application.k/dest/manifest.json @@ -0,0 +1,26 @@ +{ + "_version": "1.1.0", + "sap.app": { + "_version": "1.1.0", + "id": "application.k", + "type": "application", + "applicationVersion": { + "version": "1.2.2" + }, + "embeds": [ + "embedded" + ], + "title": "{{title}}" + }, + "sap.ui5": { + "dependencies": { + "minUI5Version": "1.73.0", + "libs": { + "sap.ui.layout": {}, + "sap.ui.core": {}, + "sap.m": {}, + "sap.ui.fl": {} + } + } + } +} \ No newline at end of file diff --git a/test/fixtures/application.j/webapp/changes/id_111_compVariants.change b/test/fixtures/application.j/webapp/changes/id_111_compVariants.change new file mode 100644 index 000000000..9c7f911b9 --- /dev/null +++ b/test/fixtures/application.j/webapp/changes/id_111_compVariants.change @@ -0,0 +1,21 @@ +{ + "fileName": "id_111_compVariants", + "fileType": "change", + "changeType": "hideControl", + "component": "application.j.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.j.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + }, + "appDescriptorChange": true +} diff --git a/test/fixtures/application.j/webapp/changes/id_111_test.ctrl_variant b/test/fixtures/application.j/webapp/changes/id_111_test.ctrl_variant new file mode 100644 index 000000000..01d2bfb47 --- /dev/null +++ b/test/fixtures/application.j/webapp/changes/id_111_test.ctrl_variant @@ -0,0 +1,20 @@ +{ + "fileName": "id_111_test", + "fileType": "ctrl_variant", + "changeType": "hideControl", + "component": "application.j.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.j.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + } +} diff --git a/test/fixtures/application.j/webapp/changes/id_111_test.ctrl_variant_change b/test/fixtures/application.j/webapp/changes/id_111_test.ctrl_variant_change new file mode 100644 index 000000000..8691c2e82 --- /dev/null +++ b/test/fixtures/application.j/webapp/changes/id_111_test.ctrl_variant_change @@ -0,0 +1,20 @@ +{ + "fileName": "id_111_test", + "fileType": "ctrl_variant_change", + "changeType": "hideControl", + "component": "application.j.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.j.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + } +} diff --git a/test/fixtures/application.j/webapp/changes/id_111_test.ctrl_variant_management_change b/test/fixtures/application.j/webapp/changes/id_111_test.ctrl_variant_management_change new file mode 100644 index 000000000..1e1f585c8 --- /dev/null +++ b/test/fixtures/application.j/webapp/changes/id_111_test.ctrl_variant_management_change @@ -0,0 +1,20 @@ +{ + "fileName": "id_111_test", + "fileType": "ctrl_variant_management_change", + "changeType": "hideControl", + "component": "application.j.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.j.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + } +} diff --git a/test/fixtures/application.j/webapp/changes/id_111_variantDependentControlChange.change b/test/fixtures/application.j/webapp/changes/id_111_variantDependentControlChange.change new file mode 100644 index 000000000..bd733b67e --- /dev/null +++ b/test/fixtures/application.j/webapp/changes/id_111_variantDependentControlChange.change @@ -0,0 +1,21 @@ +{ + "fileName": "id_111_variantDependentControlChange", + "fileType": "change", + "changeType": "hideControl", + "component": "application.j.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.j.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + }, + "variantReference": "someting here" +} diff --git a/test/fixtures/application.j/webapp/manifest.json b/test/fixtures/application.j/webapp/manifest.json index 476ebb972..8e3ee44e4 100644 --- a/test/fixtures/application.j/webapp/manifest.json +++ b/test/fixtures/application.j/webapp/manifest.json @@ -1,25 +1,26 @@ { - "_version": "1.1.0", - "sap.app": { - "_version": "1.1.0", - "id": "application.j", - "type": "application", - "applicationVersion": { - "version": "1.2.2" - }, - "embeds": ["embedded"], - "title": "{{title}}" - }, + "_version": "1.1.0", + "sap.app": { + "_version": "1.1.0", + "id": "application.j", + "type": "application", + "applicationVersion": { + "version": "1.2.2" + }, + "embeds": ["embedded"], + "title": "{{title}}" + }, "sap.ui5": { "dependencies": { + "minUI5Version": "1.70.0", "libs": { "sap.ui.layout": {}, "sap.ui.core": {}, - "sap.m": {}, - "sap.ui.fl": { - "lazy": true - } + "sap.m": {}, + "sap.ui.fl": { + "lazy": true + } } - } - } + } + } } diff --git a/test/fixtures/application.k/package.json b/test/fixtures/application.k/package.json new file mode 100644 index 000000000..e91bb56f8 --- /dev/null +++ b/test/fixtures/application.k/package.json @@ -0,0 +1,10 @@ +{ + "name": "application.k", + "version": "1.0.0", + "description": "Simple SAPUI5 based application", + "main": "index.html", + "dependencies": {}, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + } +} diff --git a/test/fixtures/application.k/ui5.yaml b/test/fixtures/application.k/ui5.yaml new file mode 100644 index 000000000..1254f8128 --- /dev/null +++ b/test/fixtures/application.k/ui5.yaml @@ -0,0 +1,25 @@ +--- +specVersion: "0.1" +type: application +metadata: + name: application.k +builder: + bundles: + - name: sap/ushell/bootstrap/cdm.js + defaultFileTypes: + - ".js" + sections: + - mode: raw + filters: + - ui5loader.js + - ui5loader-autoconfig.js + declareModules: false + resolve: true + - mode: preload + name: sap/ushell/bootstrap/common + filters: + - sap/ushell/bootstrap/cdm/cdm-def.js + resolve: true + - mode: require + filters: + - sap/ushell/bootstrap/cdm/cdm-def.js \ No newline at end of file diff --git a/test/fixtures/application.k/webapp/Component.js b/test/fixtures/application.k/webapp/Component.js new file mode 100644 index 000000000..b386a26a9 --- /dev/null +++ b/test/fixtures/application.k/webapp/Component.js @@ -0,0 +1,8 @@ +sap.ui.define(["sap/ui/core/UIComponent"], function(UIComponent){ + "use strict"; + return UIComponent.extend('application.k.Component', { + metadata: { + manifest: "json" + } + }); +}); diff --git a/test/fixtures/application.k/webapp/changes/coding/MyExtension.js b/test/fixtures/application.k/webapp/changes/coding/MyExtension.js new file mode 100644 index 000000000..dfb3da014 --- /dev/null +++ b/test/fixtures/application.k/webapp/changes/coding/MyExtension.js @@ -0,0 +1,3 @@ +sap.ui.define([],function () { + return {}; +}); diff --git a/test/fixtures/application.k/webapp/changes/fragments/MyFragment.fragment.xml b/test/fixtures/application.k/webapp/changes/fragments/MyFragment.fragment.xml new file mode 100644 index 000000000..39ce6859b --- /dev/null +++ b/test/fixtures/application.k/webapp/changes/fragments/MyFragment.fragment.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/test/fixtures/application.k/webapp/changes/id_123_addField.change b/test/fixtures/application.k/webapp/changes/id_123_addField.change new file mode 100644 index 000000000..e59ffd8b8 --- /dev/null +++ b/test/fixtures/application.k/webapp/changes/id_123_addField.change @@ -0,0 +1,20 @@ +{ + "fileName": "id_123_addField", + "fileType": "change", + "changeType": "hideControl", + "component": "application.k.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.k.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + } +} diff --git a/test/fixtures/application.k/webapp/changes/id_456_addField.change b/test/fixtures/application.k/webapp/changes/id_456_addField.change new file mode 100644 index 000000000..4baa3fc0b --- /dev/null +++ b/test/fixtures/application.k/webapp/changes/id_456_addField.change @@ -0,0 +1,20 @@ +{ + "fileName": "id_456_addField", + "fileType": "change", + "changeType": "hideControl", + "component": "application.k.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.k.Component/changes", + "creation": "2023-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + } +} diff --git a/test/fixtures/application.k/webapp/manifest.json b/test/fixtures/application.k/webapp/manifest.json new file mode 100644 index 000000000..3730534f7 --- /dev/null +++ b/test/fixtures/application.k/webapp/manifest.json @@ -0,0 +1,23 @@ +{ + "_version": "1.1.0", + "sap.app": { + "_version": "1.1.0", + "id": "application.k", + "type": "application", + "applicationVersion": { + "version": "1.2.2" + }, + "embeds": ["embedded"], + "title": "{{title}}" + }, + "sap.ui5": { + "dependencies": { + "minUI5Version": "1.73.0", + "libs": { + "sap.ui.layout": {}, + "sap.ui.core": {}, + "sap.m": {} + } + } + } +} diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 63bb671d1..52dddec44 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -16,6 +16,7 @@ const applicationGPath = path.join(__dirname, "..", "..", "fixtures", "applicati const applicationHPath = path.join(__dirname, "..", "..", "fixtures", "application.h"); const applicationIPath = path.join(__dirname, "..", "..", "fixtures", "application.i"); const applicationJPath = path.join(__dirname, "..", "..", "fixtures", "application.j"); +const applicationKPath = path.join(__dirname, "..", "..", "fixtures", "application.k"); const libraryDPath = path.join(__dirname, "..", "..", "fixtures", "library.d"); const libraryEPath = path.join(__dirname, "..", "..", "fixtures", "library.e"); const libraryHPath = path.join(__dirname, "..", "..", "fixtures", "library.h"); @@ -280,6 +281,26 @@ test("Build application.j", (t) => { }); }); +test("Build application.k", (t) => { + const destPath = "./test/tmp/build/application.k/dest"; + const expectedPath = path.join("test", "expected", "build", "application.k", "dest"); + + return builder.build({ + tree: applicationKTree, + destPath, + excludedTasks: ["createDebugFiles", "generateStandaloneAppBundle", "generateVersionInfo"] + }).then(() => { + return findFiles(expectedPath); + }).then((expectedFiles) => { + // Check for all directories and files + assert.directoryDeepEqual(destPath, expectedPath); + // Check for all file contents + return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + }).then(() => { + t.pass(); + }); +}); + test("Build library.d with copyright from .library file", (t) => { const destPath = "./test/tmp/build/library.d/dest"; const expectedPath = path.join("test", "expected", "build", "library.d", "dest"); @@ -836,6 +857,34 @@ const applicationJTree = { } }; +const applicationKTree = { + "id": "application.k", + "version": "1.0.0", + "path": applicationKPath, + "_level": 0, + "specVersion": "0.1", + "type": "application", + "metadata": { + "name": "application.k", + "namespace": "application/k" + }, + "dependencies": [], + "resources": { + "configuration": { + "paths": { + "webapp": "webapp" + }, + "propertiesFileSourceEncoding": "ISO-8859-1" + }, + "pathMappings": { + "/": "webapp" + } + }, + "builder": { + "bundles": [] + } +}; + const libraryDTree = { "id": "library.d", "version": "1.0.0", From 09c3ec00dde35bc4100b55f1b2e07ebd79efbc33 Mon Sep 17 00:00:00 2001 From: Thuy Boehm Date: Tue, 15 Oct 2019 16:14:07 +0200 Subject: [PATCH 2/7] [INTERNAL] throw error if there is a ctrl_variant and minUI5Version is below 1.72 --- lib/processors/bundlers/flexChangesBundler.js | 5 +- .../bundlers/generateFlexChangesBundle.js | 13 +- .../application.j/dest/Component-preload.js | 2 +- .../build/application.j/dest/manifest.json | 2 +- .../application.k/dest/Component-preload.js | 12 - .../build/application.k/dest/Component.js | 1 - .../dest/changes/coding/MyExtension.js | 1 - .../dest/changes/flexibility-bundle.json | 1 - .../changes/fragments/MyFragment.fragment.xml | 3 - .../dest/changes/id_123_addField.change | 20 - .../dest/changes/id_456_addField.change | 20 - .../build/application.k/dest/manifest.json | 26 -- .../application.j/webapp/manifest.json | 2 +- test/fixtures/application.k/package.json | 10 - test/fixtures/application.k/ui5.yaml | 25 -- .../application.k/webapp/Component.js | 8 - .../webapp/changes/coding/MyExtension.js | 3 - .../changes/fragments/MyFragment.fragment.xml | 3 - .../webapp/changes/id_123_addField.change | 20 - .../webapp/changes/id_456_addField.change | 20 - .../application.k/webapp/manifest.json | 23 -- test/lib/builder/builder.js | 50 --- .../processors/bundlers/flexChangesBundler.js | 380 ++++++++++++++++++ 23 files changed, 388 insertions(+), 262 deletions(-) delete mode 100644 test/expected/build/application.k/dest/Component-preload.js delete mode 100644 test/expected/build/application.k/dest/Component.js delete mode 100644 test/expected/build/application.k/dest/changes/coding/MyExtension.js delete mode 100644 test/expected/build/application.k/dest/changes/flexibility-bundle.json delete mode 100644 test/expected/build/application.k/dest/changes/fragments/MyFragment.fragment.xml delete mode 100644 test/expected/build/application.k/dest/changes/id_123_addField.change delete mode 100644 test/expected/build/application.k/dest/changes/id_456_addField.change delete mode 100644 test/expected/build/application.k/dest/manifest.json delete mode 100644 test/fixtures/application.k/package.json delete mode 100644 test/fixtures/application.k/ui5.yaml delete mode 100644 test/fixtures/application.k/webapp/Component.js delete mode 100644 test/fixtures/application.k/webapp/changes/coding/MyExtension.js delete mode 100644 test/fixtures/application.k/webapp/changes/fragments/MyFragment.fragment.xml delete mode 100644 test/fixtures/application.k/webapp/changes/id_123_addField.change delete mode 100644 test/fixtures/application.k/webapp/changes/id_456_addField.change delete mode 100644 test/fixtures/application.k/webapp/manifest.json diff --git a/lib/processors/bundlers/flexChangesBundler.js b/lib/processors/bundlers/flexChangesBundler.js index a9632af93..63ac3b65d 100644 --- a/lib/processors/bundlers/flexChangesBundler.js +++ b/lib/processors/bundlers/flexChangesBundler.js @@ -49,8 +49,11 @@ module.exports = function({resources, options}) { } }); + if (!options.hasFlexBundleVersion && (compVariantList.length != 0 || variantList.length != 0 || variantChangeList.length != 0 || variantDependentControlChangeList.length != 0 || variantManagementChangeList.length != 0)) { + throw new Error("There are some control variant change in the changes folder. This only works with a minUI5Version 1.72.0. Please update the minUI5Version in the manifest.json minimum to 1.72.0"); + } // create changes-bundle.json - if (!options.hasFlexBundleVersion && compVariantList.length == 0 && variantList.length == 0 && variantChangeList.length == 0 && variantDependentControlChangeList.length == 0 && variantManagementChangeList.length == 0) { + if (!options.hasFlexBundleVersion) { return JSON.stringify(changeList); } else { bundleName = "flexibility-bundle.json"; diff --git a/lib/tasks/bundlers/generateFlexChangesBundle.js b/lib/tasks/bundlers/generateFlexChangesBundle.js index c26faa340..22c17f9df 100644 --- a/lib/tasks/bundlers/generateFlexChangesBundle.js +++ b/lib/tasks/bundlers/generateFlexChangesBundle.js @@ -24,8 +24,6 @@ module.exports = function({workspace, options}) { if (options && options.namespace) { pathPrefix = `/resources/${options.namespace}`; } - let hasVariant = false; - let hasFlexBundleVersion = false; function updateJson(data) { // ensure the existence of the libs section in the dependencies @@ -43,12 +41,6 @@ module.exports = function({workspace, options}) { log.verbose("sap.ui.fl not found in manifest.json, inserting it..."); mLibs["sap.ui.fl"] = {}; } - - // if there are ctrl variant and minUI5Version < 1.72 need to update minUI5Version to 1.72.0 - if (hasVariant && !hasFlexBundleVersion) { - log.verbose("minUI5Version < 1.72, updated it to 1.72.0"); - data["sap.ui5"].dependencies.minUI5Version = "1.72.0"; - } } async function updateFLdependency() { @@ -80,6 +72,7 @@ module.exports = function({workspace, options}) { return workspace.byGlob(`${pathPrefix}/changes/*.{change,variant,ctrl_variant,ctrl_variant_change,ctrl_variant_management_change}`) .then((allResources) => { return readManifestMinUI5Version().then((version) => { + let hasFlexBundleVersion = false; if (parseFloat(version) >= 1.72) { hasFlexBundleVersion = true; } @@ -100,10 +93,6 @@ module.exports = function({workspace, options}) { })).then(async () => { // Add the sap.ui.fl dependency if a bundle has been created if (processedResources.length > 0) { - // flexibility-bundle.json can be create when there are ctrl variant even though minUI5Version is below 1.72 - if (processedResources[0]._name == "flexibility-bundle.json") { - hasVariant = true; - } await updateFLdependency(); } }); diff --git a/test/expected/build/application.j/dest/Component-preload.js b/test/expected/build/application.j/dest/Component-preload.js index 7b1c62e8b..2d5153a52 100644 --- a/test/expected/build/application.j/dest/Component-preload.js +++ b/test/expected/build/application.j/dest/Component-preload.js @@ -8,5 +8,5 @@ jQuery.sap.registerPreloadedModules({ }, "application/j/changes/flexibility-bundle.json":'{"changes":[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"compVariants":[{"fileName":"id_111_compVariants","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"appDescriptorChange":true}],"variants":[{"fileName":"id_111_test","fileType":"ctrl_variant","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantDependentControlChanges":[{"fileName":"id_111_variantDependentControlChange","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"variantReference":"someting here"}],"variantManagementChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_management_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}]}', "application/j/changes/fragments/MyFragment.fragment.xml":'', - "application/j/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.j","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"},"sap.ui5":{"dependencies":{"minUI5Version":"1.72.0","libs":{"sap.ui.layout":{},"sap.ui.core":{},"sap.m":{},"sap.ui.fl":{"lazy":false}}}}}' + "application/j/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.j","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"},"sap.ui5":{"dependencies":{"minUI5Version":"1.72.2","libs":{"sap.ui.layout":{},"sap.ui.core":{},"sap.m":{},"sap.ui.fl":{"lazy":false}}}}}' }}); diff --git a/test/expected/build/application.j/dest/manifest.json b/test/expected/build/application.j/dest/manifest.json index 3e85f9dad..465e1d9b9 100644 --- a/test/expected/build/application.j/dest/manifest.json +++ b/test/expected/build/application.j/dest/manifest.json @@ -14,7 +14,7 @@ }, "sap.ui5": { "dependencies": { - "minUI5Version": "1.72.0", + "minUI5Version": "1.72.2", "libs": { "sap.ui.layout": {}, "sap.ui.core": {}, diff --git a/test/expected/build/application.k/dest/Component-preload.js b/test/expected/build/application.k/dest/Component-preload.js deleted file mode 100644 index 90023265a..000000000 --- a/test/expected/build/application.k/dest/Component-preload.js +++ /dev/null @@ -1,12 +0,0 @@ -//@ui5-bundle application/k/Component-preload.js -jQuery.sap.registerPreloadedModules({ -"version":"2.0", -"modules":{ - "application/k/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.k.Component",{metadata:{manifest:"json"}})}); -}, - "application/k/changes/coding/MyExtension.js":function(){sap.ui.define([],function(){return{}}); -}, - "application/k/changes/flexibility-bundle.json":'{"changes":[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.k.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.k.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.k.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.k.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"compVariants":[],"variants":[],"variantChanges":[],"variantDependentControlChanges":[],"variantManagementChanges":[]}', - "application/k/changes/fragments/MyFragment.fragment.xml":'', - "application/k/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.k","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"},"sap.ui5":{"dependencies":{"minUI5Version":"1.73.0","libs":{"sap.ui.layout":{},"sap.ui.core":{},"sap.m":{},"sap.ui.fl":{}}}}}' -}}); diff --git a/test/expected/build/application.k/dest/Component.js b/test/expected/build/application.k/dest/Component.js deleted file mode 100644 index 3da3da77e..000000000 --- a/test/expected/build/application.k/dest/Component.js +++ /dev/null @@ -1 +0,0 @@ -sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.k.Component",{metadata:{manifest:"json"}})}); \ No newline at end of file diff --git a/test/expected/build/application.k/dest/changes/coding/MyExtension.js b/test/expected/build/application.k/dest/changes/coding/MyExtension.js deleted file mode 100644 index b9e475d8e..000000000 --- a/test/expected/build/application.k/dest/changes/coding/MyExtension.js +++ /dev/null @@ -1 +0,0 @@ -sap.ui.define([],function(){return{}}); \ No newline at end of file diff --git a/test/expected/build/application.k/dest/changes/flexibility-bundle.json b/test/expected/build/application.k/dest/changes/flexibility-bundle.json deleted file mode 100644 index 90315336c..000000000 --- a/test/expected/build/application.k/dest/changes/flexibility-bundle.json +++ /dev/null @@ -1 +0,0 @@ -{"changes":[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.k.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.k.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.k.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.k.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"compVariants":[],"variants":[],"variantChanges":[],"variantDependentControlChanges":[],"variantManagementChanges":[]} \ No newline at end of file diff --git a/test/expected/build/application.k/dest/changes/fragments/MyFragment.fragment.xml b/test/expected/build/application.k/dest/changes/fragments/MyFragment.fragment.xml deleted file mode 100644 index 39ce6859b..000000000 --- a/test/expected/build/application.k/dest/changes/fragments/MyFragment.fragment.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/test/expected/build/application.k/dest/changes/id_123_addField.change b/test/expected/build/application.k/dest/changes/id_123_addField.change deleted file mode 100644 index e59ffd8b8..000000000 --- a/test/expected/build/application.k/dest/changes/id_123_addField.change +++ /dev/null @@ -1,20 +0,0 @@ -{ - "fileName": "id_123_addField", - "fileType": "change", - "changeType": "hideControl", - "component": "application.k.Component", - "content": {}, - "selector": { - "id": "control1" - }, - "layer": "VENDOR", - "texts": {}, - "namespace": "apps/application.k.Component/changes", - "creation": "2025-10-30T13:52:40.4754350Z", - "originalLanguage": "", - "conditions": {}, - "support": { - "generator": "did it", - "user": "Max Mustermann" - } -} diff --git a/test/expected/build/application.k/dest/changes/id_456_addField.change b/test/expected/build/application.k/dest/changes/id_456_addField.change deleted file mode 100644 index 4baa3fc0b..000000000 --- a/test/expected/build/application.k/dest/changes/id_456_addField.change +++ /dev/null @@ -1,20 +0,0 @@ -{ - "fileName": "id_456_addField", - "fileType": "change", - "changeType": "hideControl", - "component": "application.k.Component", - "content": {}, - "selector": { - "id": "control1" - }, - "layer": "VENDOR", - "texts": {}, - "namespace": "apps/application.k.Component/changes", - "creation": "2023-10-30T13:52:40.4754350Z", - "originalLanguage": "", - "conditions": {}, - "support": { - "generator": "did it", - "user": "Max Mustermann" - } -} diff --git a/test/expected/build/application.k/dest/manifest.json b/test/expected/build/application.k/dest/manifest.json deleted file mode 100644 index 653fec68d..000000000 --- a/test/expected/build/application.k/dest/manifest.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "_version": "1.1.0", - "sap.app": { - "_version": "1.1.0", - "id": "application.k", - "type": "application", - "applicationVersion": { - "version": "1.2.2" - }, - "embeds": [ - "embedded" - ], - "title": "{{title}}" - }, - "sap.ui5": { - "dependencies": { - "minUI5Version": "1.73.0", - "libs": { - "sap.ui.layout": {}, - "sap.ui.core": {}, - "sap.m": {}, - "sap.ui.fl": {} - } - } - } -} \ No newline at end of file diff --git a/test/fixtures/application.j/webapp/manifest.json b/test/fixtures/application.j/webapp/manifest.json index 8e3ee44e4..d973b8507 100644 --- a/test/fixtures/application.j/webapp/manifest.json +++ b/test/fixtures/application.j/webapp/manifest.json @@ -12,7 +12,7 @@ }, "sap.ui5": { "dependencies": { - "minUI5Version": "1.70.0", + "minUI5Version": "1.72.2", "libs": { "sap.ui.layout": {}, "sap.ui.core": {}, diff --git a/test/fixtures/application.k/package.json b/test/fixtures/application.k/package.json deleted file mode 100644 index e91bb56f8..000000000 --- a/test/fixtures/application.k/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "application.k", - "version": "1.0.0", - "description": "Simple SAPUI5 based application", - "main": "index.html", - "dependencies": {}, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - } -} diff --git a/test/fixtures/application.k/ui5.yaml b/test/fixtures/application.k/ui5.yaml deleted file mode 100644 index 1254f8128..000000000 --- a/test/fixtures/application.k/ui5.yaml +++ /dev/null @@ -1,25 +0,0 @@ ---- -specVersion: "0.1" -type: application -metadata: - name: application.k -builder: - bundles: - - name: sap/ushell/bootstrap/cdm.js - defaultFileTypes: - - ".js" - sections: - - mode: raw - filters: - - ui5loader.js - - ui5loader-autoconfig.js - declareModules: false - resolve: true - - mode: preload - name: sap/ushell/bootstrap/common - filters: - - sap/ushell/bootstrap/cdm/cdm-def.js - resolve: true - - mode: require - filters: - - sap/ushell/bootstrap/cdm/cdm-def.js \ No newline at end of file diff --git a/test/fixtures/application.k/webapp/Component.js b/test/fixtures/application.k/webapp/Component.js deleted file mode 100644 index b386a26a9..000000000 --- a/test/fixtures/application.k/webapp/Component.js +++ /dev/null @@ -1,8 +0,0 @@ -sap.ui.define(["sap/ui/core/UIComponent"], function(UIComponent){ - "use strict"; - return UIComponent.extend('application.k.Component', { - metadata: { - manifest: "json" - } - }); -}); diff --git a/test/fixtures/application.k/webapp/changes/coding/MyExtension.js b/test/fixtures/application.k/webapp/changes/coding/MyExtension.js deleted file mode 100644 index dfb3da014..000000000 --- a/test/fixtures/application.k/webapp/changes/coding/MyExtension.js +++ /dev/null @@ -1,3 +0,0 @@ -sap.ui.define([],function () { - return {}; -}); diff --git a/test/fixtures/application.k/webapp/changes/fragments/MyFragment.fragment.xml b/test/fixtures/application.k/webapp/changes/fragments/MyFragment.fragment.xml deleted file mode 100644 index 39ce6859b..000000000 --- a/test/fixtures/application.k/webapp/changes/fragments/MyFragment.fragment.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/test/fixtures/application.k/webapp/changes/id_123_addField.change b/test/fixtures/application.k/webapp/changes/id_123_addField.change deleted file mode 100644 index e59ffd8b8..000000000 --- a/test/fixtures/application.k/webapp/changes/id_123_addField.change +++ /dev/null @@ -1,20 +0,0 @@ -{ - "fileName": "id_123_addField", - "fileType": "change", - "changeType": "hideControl", - "component": "application.k.Component", - "content": {}, - "selector": { - "id": "control1" - }, - "layer": "VENDOR", - "texts": {}, - "namespace": "apps/application.k.Component/changes", - "creation": "2025-10-30T13:52:40.4754350Z", - "originalLanguage": "", - "conditions": {}, - "support": { - "generator": "did it", - "user": "Max Mustermann" - } -} diff --git a/test/fixtures/application.k/webapp/changes/id_456_addField.change b/test/fixtures/application.k/webapp/changes/id_456_addField.change deleted file mode 100644 index 4baa3fc0b..000000000 --- a/test/fixtures/application.k/webapp/changes/id_456_addField.change +++ /dev/null @@ -1,20 +0,0 @@ -{ - "fileName": "id_456_addField", - "fileType": "change", - "changeType": "hideControl", - "component": "application.k.Component", - "content": {}, - "selector": { - "id": "control1" - }, - "layer": "VENDOR", - "texts": {}, - "namespace": "apps/application.k.Component/changes", - "creation": "2023-10-30T13:52:40.4754350Z", - "originalLanguage": "", - "conditions": {}, - "support": { - "generator": "did it", - "user": "Max Mustermann" - } -} diff --git a/test/fixtures/application.k/webapp/manifest.json b/test/fixtures/application.k/webapp/manifest.json deleted file mode 100644 index 3730534f7..000000000 --- a/test/fixtures/application.k/webapp/manifest.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "_version": "1.1.0", - "sap.app": { - "_version": "1.1.0", - "id": "application.k", - "type": "application", - "applicationVersion": { - "version": "1.2.2" - }, - "embeds": ["embedded"], - "title": "{{title}}" - }, - "sap.ui5": { - "dependencies": { - "minUI5Version": "1.73.0", - "libs": { - "sap.ui.layout": {}, - "sap.ui.core": {}, - "sap.m": {} - } - } - } -} diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 52dddec44..fb64572b2 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -16,7 +16,6 @@ const applicationGPath = path.join(__dirname, "..", "..", "fixtures", "applicati const applicationHPath = path.join(__dirname, "..", "..", "fixtures", "application.h"); const applicationIPath = path.join(__dirname, "..", "..", "fixtures", "application.i"); const applicationJPath = path.join(__dirname, "..", "..", "fixtures", "application.j"); -const applicationKPath = path.join(__dirname, "..", "..", "fixtures", "application.k"); const libraryDPath = path.join(__dirname, "..", "..", "fixtures", "library.d"); const libraryEPath = path.join(__dirname, "..", "..", "fixtures", "library.e"); const libraryHPath = path.join(__dirname, "..", "..", "fixtures", "library.h"); @@ -281,26 +280,6 @@ test("Build application.j", (t) => { }); }); -test("Build application.k", (t) => { - const destPath = "./test/tmp/build/application.k/dest"; - const expectedPath = path.join("test", "expected", "build", "application.k", "dest"); - - return builder.build({ - tree: applicationKTree, - destPath, - excludedTasks: ["createDebugFiles", "generateStandaloneAppBundle", "generateVersionInfo"] - }).then(() => { - return findFiles(expectedPath); - }).then((expectedFiles) => { - // Check for all directories and files - assert.directoryDeepEqual(destPath, expectedPath); - // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); - }).then(() => { - t.pass(); - }); -}); - test("Build library.d with copyright from .library file", (t) => { const destPath = "./test/tmp/build/library.d/dest"; const expectedPath = path.join("test", "expected", "build", "library.d", "dest"); @@ -612,7 +591,6 @@ const applicationATree = { } }; - const applicationATreeBadType = { "id": "application.a", "version": "1.0.0", @@ -857,34 +835,6 @@ const applicationJTree = { } }; -const applicationKTree = { - "id": "application.k", - "version": "1.0.0", - "path": applicationKPath, - "_level": 0, - "specVersion": "0.1", - "type": "application", - "metadata": { - "name": "application.k", - "namespace": "application/k" - }, - "dependencies": [], - "resources": { - "configuration": { - "paths": { - "webapp": "webapp" - }, - "propertiesFileSourceEncoding": "ISO-8859-1" - }, - "pathMappings": { - "/": "webapp" - } - }, - "builder": { - "bundles": [] - } -}; - const libraryDTree = { "id": "library.d", "version": "1.0.0", diff --git a/test/lib/processors/bundlers/flexChangesBundler.js b/test/lib/processors/bundlers/flexChangesBundler.js index 40e29c9d5..d107e581a 100644 --- a/test/lib/processors/bundlers/flexChangesBundler.js +++ b/test/lib/processors/bundlers/flexChangesBundler.js @@ -111,3 +111,383 @@ test("flexChangesBundler with 2 changes", async (t) => { const parsedContent = JSON.parse(content); t.deepEqual(parsedContent, flexBundle, "Result must contain the content"); }); + +test("flexChangesBundler has ctrl_variant and hasFlexBundleVersion = true", async (t) => { + const changeList = [ + { + "fileName": "id_1504764957630_7_rename2", + "fileType": "change", + "changeType": "rename", + "reference": "rta.performance.Component", + "packageName": "$TMP", + "content": { + "originalControlType": "sap.m.Label" + }, + "selector": { + "id": "initialLabel", + "idIsLocal": false + }, + "layer": "USER", + "texts": { + "newText": { + "value": "rename_5", + "type": "XFLD" + } + }, + "namespace": "apps/MyComponent/changes/", + "creation": "2017-09-01T11:54:55.238Z", + "originalLanguage": "EN", + "conditions": {}, + "context": "", + "support": { + "generator": "Change.createInitialFileContent", + "service": "", + "user": "", + "sapui5Version": "1.51.0-SNAPSHOT" + }, + "dependentSelector": {}, + "validAppVersions": { + "creation": "1.0.0", + "from": "1.0.0", + "to": "1.0.0" + } + }, { + "fileName": "id_1504764957625_7_rename1", + "fileType": "change", + "changeType": "rename", + "reference": "rta.performance.Component", + "packageName": "$TMP", + "content": { + "originalControlType": "sap.m.Label" + }, + "selector": { + "id": "initialLabel", + "idIsLocal": false + }, + "layer": "CUSTOMER", + "texts": { + "newText": { + "value": "rename_0", + "type": "XFLD" + } + }, + "namespace": "apps/MyComponent/changes/", + "creation": "2017-09-06T11:54:55.238Z", + "originalLanguage": "EN", + "conditions": {}, + "context": "", + "support": { + "generator": "Change.createInitialFileContent", + "service": "", + "user": "", + "sapui5Version": "1.51.0-SNAPSHOT" + }, + "dependentSelector": {}, + "validAppVersions": { + "creation": "1.0.0", + "from": "1.0.0", + "to": "1.0.0" + } + } + ]; + const compVariants = [{ + "fileName": "id_1504764957625_7_rename1", + "fileType": "change", + "changeType": "rename", + "reference": "rta.performance.Component", + "packageName": "$TMP", + "appDescriptorChange": true, + "content": { + "originalControlType": "sap.m.Label" + }, + "selector": { + "id": "initialLabel", + "idIsLocal": false + }, + "layer": "CUSTOMER", + "texts": { + "newText": { + "value": "rename_0", + "type": "XFLD" + } + }, + "namespace": "apps/MyComponent/changes/", + "creation": "2017-09-06T11:54:55.238Z", + "originalLanguage": "EN", + "conditions": {}, + "context": "", + "support": { + "generator": "Change.createInitialFileContent", + "service": "", + "user": "", + "sapui5Version": "1.51.0-SNAPSHOT" + }, + "dependentSelector": {}, + "validAppVersions": { + "creation": "1.0.0", + "from": "1.0.0", + "to": "1.0.0" + } + }]; + const variantDependentControlChange = [{ + "fileName": "id_1504764957625_7_rename1", + "fileType": "change", + "changeType": "rename", + "reference": "rta.performance.Component", + "packageName": "$TMP", + "variantReference": "someting", + "content": { + "originalControlType": "sap.m.Label" + }, + "selector": { + "id": "initialLabel", + "idIsLocal": false + }, + "layer": "CUSTOMER", + "texts": { + "newText": { + "value": "rename_0", + "type": "XFLD" + } + }, + "namespace": "apps/MyComponent/changes/", + "creation": "2017-09-06T11:54:55.238Z", + "originalLanguage": "EN", + "conditions": {}, + "context": "", + "support": { + "generator": "Change.createInitialFileContent", + "service": "", + "user": "", + "sapui5Version": "1.51.0-SNAPSHOT" + }, + "dependentSelector": {}, + "validAppVersions": { + "creation": "1.0.0", + "from": "1.0.0", + "to": "1.0.0" + } + }]; + const ctrlVariant = [{ + "fileName": "ctrl_variants_route_test_variant1", + "title": "variant1", + "variantManagementReference": "masterPageVariant", + "variantReference": "sap.ui.demo.todo.Component", + "fileType": "ctrl_variant", + "component": "lrep.mocha.test.ctrl.variants.route.Component", + "packageName": "$TMP", + "content": {}, + "selector": { + "id": "" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "lrep_unit_test_mocha/ctrl-variants-route-test/", + "creation": "20170705-12-00-00", + "originalLanguage": "EN", + "conditions": {}, + "support": { + "generator": "Change.createInitialFileContent", + "service": "", + "user": "" + } + }]; + const ctrlVariantChange = [{ + "fileName": "ctrl_variants_route_test_variant1", + "title": "variant1", + "variantManagementReference": "masterPageVariant", + "variantReference": "sap.ui.demo.todo.Component", + "fileType": "ctrl_variant_change", + "component": "lrep.mocha.test.ctrl.variants.route.Component", + "packageName": "$TMP", + "content": {}, + "selector": { + "id": "" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "lrep_unit_test_mocha/ctrl-variants-route-test/", + "creation": "20170705-12-00-00", + "originalLanguage": "EN", + "conditions": {}, + "support": { + "generator": "Change.createInitialFileContent", + "service": "", + "user": "" + } + }]; + const ctrlVariantManagementChange = [{ + "fileName": "ctrl_variants_route_test_variant1", + "title": "variant1", + "variantManagementReference": "masterPageVariant", + "variantReference": "sap.ui.demo.todo.Component", + "fileType": "ctrl_variant_management_change", + "component": "lrep.mocha.test.ctrl.variants.route.Component", + "packageName": "$TMP", + "content": {}, + "selector": { + "id": "" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "lrep_unit_test_mocha/ctrl-variants-route-test/", + "creation": "20170705-12-00-00", + "originalLanguage": "EN", + "conditions": {}, + "support": { + "generator": "Change.createInitialFileContent", + "service": "", + "user": "" + } + }]; + + const resources = []; + changeList.forEach((change) => { + resources.push({ + name: "flexChange", + getBuffer: async () => JSON.stringify(change) + }); + }); + compVariants.forEach((change) => { + resources.push({ + name: "flexChange", + getBuffer: async () => JSON.stringify(change) + }); + }); + variantDependentControlChange.forEach((change) => { + resources.push({ + name: "flexChange", + getBuffer: async () => JSON.stringify(change) + }); + }); + ctrlVariantChange.forEach((change) => { + resources.push({ + name: "flexChange", + getBuffer: async () => JSON.stringify(change) + }); + }); + ctrlVariantManagementChange.forEach((change) => { + resources.push({ + name: "flexChange", + getBuffer: async () => JSON.stringify(change) + }); + }); + ctrlVariant.forEach((change) => { + resources.push({ + name: "flexChange", + getBuffer: async () => JSON.stringify(change) + }); + }); + + const flexBundle = { + "changes": changeList, + "compVariants": compVariants, + "variantChanges": ctrlVariantChange, + "variantDependentControlChanges": variantDependentControlChange, + "variantManagementChanges": ctrlVariantManagementChange, + "variants": ctrlVariant + }; + + const options = { + pathPrefix: "mypath", + hasFlexBundleVersion: true + }; + const aResult = await flexChangesBundler({resources, options}); + t.deepEqual(aResult.length, 1, "There should be only one element"); + const oResult = aResult[0]; + + // check path + t.deepEqual(oResult.getPath(), "mypath/changes/flexibility-bundle.json", "path should be generated from options"); + + // check content + const content = await oResult.getString(); + const parsedContent = JSON.parse(content); + t.deepEqual(parsedContent, flexBundle, "Result must contain the content"); +}); + +test("flexChangesBundler has ctrl_variant and hasFlexBundleVersion = false", async (t) => { + const change = [{ + "fileName": "id_1504764957625_7_rename1", + "fileType": "change", + "changeType": "rename", + "reference": "rta.performance.Component", + "packageName": "$TMP", + "content": { + "originalControlType": "sap.m.Label" + }, + "selector": { + "id": "initialLabel", + "idIsLocal": false + }, + "layer": "CUSTOMER", + "texts": { + "newText": { + "value": "rename_0", + "type": "XFLD" + } + }, + "namespace": "apps/MyComponent/changes/", + "creation": "2017-09-06T11:54:55.238Z", + "originalLanguage": "EN", + "conditions": {}, + "context": "", + "support": { + "generator": "Change.createInitialFileContent", + "service": "", + "user": "", + "sapui5Version": "1.51.0-SNAPSHOT" + }, + "dependentSelector": {}, + "validAppVersions": { + "creation": "1.0.0", + "from": "1.0.0", + "to": "1.0.0" + } + }]; + const ctrlVariant = [{ + "fileName": "ctrl_variants_route_test_variant1", + "title": "variant1", + "variantManagementReference": "masterPageVariant", + "variantReference": "sap.ui.demo.todo.Component", + "fileType": "ctrl_variant", + "component": "lrep.mocha.test.ctrl.variants.route.Component", + "packageName": "$TMP", + "content": {}, + "selector": { + "id": "" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "lrep_unit_test_mocha/ctrl-variants-route-test/", + "creation": "20170705-12-00-00", + "originalLanguage": "EN", + "conditions": {}, + "support": { + "generator": "Change.createInitialFileContent", + "service": "", + "user": "" + } + }]; + + const resources = []; + change.forEach((change) => { + resources.push({ + name: "flexChange", + getBuffer: async () => JSON.stringify(change) + }); + }); + ctrlVariant.forEach((change) => { + resources.push({ + name: "flexChange", + getBuffer: async () => JSON.stringify(change) + }); + }); + + const options = { + pathPrefix: "mypath", + hasFlexBundleVersion: false + }; + + const error = await t.throwsAsync(flexChangesBundler({resources, options}), Error); + t.deepEqual(error.message, "There are some control variant change in the changes folder. This only works with a minUI5Version 1.72.0. Please update the minUI5Version in the manifest.json minimum to 1.72.0", "Correct exception thrown"); +}); From 021566eccd61b654814b9e73a00a644e29f09918 Mon Sep 17 00:00:00 2001 From: Thuy Boehm Date: Wed, 16 Oct 2019 08:35:36 +0200 Subject: [PATCH 3/7] [INTERNAL] update comment --- lib/tasks/bundlers/generateFlexChangesBundle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/bundlers/generateFlexChangesBundle.js b/lib/tasks/bundlers/generateFlexChangesBundle.js index 22c17f9df..ab7780f7e 100644 --- a/lib/tasks/bundlers/generateFlexChangesBundle.js +++ b/lib/tasks/bundlers/generateFlexChangesBundle.js @@ -7,7 +7,7 @@ const flexChangesBundler = require("../../processors/bundlers/flexChangesBundler * If a change bundle is created, "sap.ui.fl" is added as a dependency to the manifest.json if not already present - * if the dependency is already listed but lazy-loaded, lazy loading is disabled. * If minUI5Version >= 1.72 flexibility-bundle.json will be create. - * If there a ctrl_variants minUI5Version will update to 1.72 if it is below and flexibility-bundle.json will be create. + * If there a ctrl_variants and minUI5Version < 1.72 build will break and throw an error. * * @public * @alias module:@ui5/builder.tasks.generateFlexChangesBundle From e340e2a7a408e334d1f986c692d701331617fb0f Mon Sep 17 00:00:00 2001 From: Thuy Boehm Date: Tue, 22 Oct 2019 14:47:49 +0200 Subject: [PATCH 4/7] [INTERNAL] add file_type variant for compVariants --- lib/processors/bundlers/flexChangesBundler.js | 29 ++++++++++++------- .../application.j/dest/Component-preload.js | 2 +- .../dest/changes/flexibility-bundle.json | 2 +- ...nts.change => id_111_appDescriptor.change} | 0 .../dest/changes/id_111_compVariants.variant | 21 ++++++++++++++ ...nts.change => id_111_appDescriptor.change} | 0 .../changes/id_111_compVariants.variant | 21 ++++++++++++++ .../processors/bundlers/flexChangesBundler.js | 4 +-- 8 files changed, 64 insertions(+), 15 deletions(-) rename test/expected/build/application.j/dest/changes/{id_111_compVariants.change => id_111_appDescriptor.change} (100%) create mode 100644 test/expected/build/application.j/dest/changes/id_111_compVariants.variant rename test/fixtures/application.j/webapp/changes/{id_111_compVariants.change => id_111_appDescriptor.change} (100%) create mode 100644 test/fixtures/application.j/webapp/changes/id_111_compVariants.variant diff --git a/lib/processors/bundlers/flexChangesBundler.js b/lib/processors/bundlers/flexChangesBundler.js index 63ac3b65d..45512389e 100644 --- a/lib/processors/bundlers/flexChangesBundler.js +++ b/lib/processors/bundlers/flexChangesBundler.js @@ -30,22 +30,29 @@ module.exports = function({resources, options}) { const variantManagementChangeList = []; changesContent.forEach(function(content) { - if (content.fileType == "change") { - if (content.appDescriptorChange && (content.appDescriptorChange == "true" || content.appDescriptorChange == true)) { - compVariantList.push(content); + switch (content.fileType) { + case "change": + if (content.appDescriptorChange && (content.appDescriptorChange === "true" || content.appDescriptorChange == true)) { + break; + } + if (content.variantReference && content.variantReference !== "") { + variantDependentControlChangeList.push(content); } else { - if (content.variantReference && content.variantReference != "") { - variantDependentControlChangeList.push(content); - } else { - changeList.push(content); - } + changeList.push(content); } - } else if (content.fileType == "ctrl_variant") { + break; + case "variant": + compVariantList.push(content); + break; + case "ctrl_variant": variantList.push(content); - } else if (content.fileType == "ctrl_variant_change") { + break; + case "ctrl_variant_change": variantChangeList.push(content); - } else if (content.fileType == "ctrl_variant_management_change") { + break; + case "ctrl_variant_management_change": variantManagementChangeList.push(content); + break; } }); diff --git a/test/expected/build/application.j/dest/Component-preload.js b/test/expected/build/application.j/dest/Component-preload.js index 2d5153a52..1df632fa4 100644 --- a/test/expected/build/application.j/dest/Component-preload.js +++ b/test/expected/build/application.j/dest/Component-preload.js @@ -6,7 +6,7 @@ jQuery.sap.registerPreloadedModules({ }, "application/j/changes/coding/MyExtension.js":function(){sap.ui.define([],function(){return{}}); }, - "application/j/changes/flexibility-bundle.json":'{"changes":[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"compVariants":[{"fileName":"id_111_compVariants","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"appDescriptorChange":true}],"variants":[{"fileName":"id_111_test","fileType":"ctrl_variant","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantDependentControlChanges":[{"fileName":"id_111_variantDependentControlChange","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"variantReference":"someting here"}],"variantManagementChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_management_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}]}', + "application/j/changes/flexibility-bundle.json":'{"changes":[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"compVariants":[{"fileName":"id_111_compVariants","fileType":"variant","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"appDescriptorChange":false}],"variants":[{"fileName":"id_111_test","fileType":"ctrl_variant","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantDependentControlChanges":[{"fileName":"id_111_variantDependentControlChange","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"variantReference":"someting here"}],"variantManagementChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_management_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}]}', "application/j/changes/fragments/MyFragment.fragment.xml":'', "application/j/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.j","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"},"sap.ui5":{"dependencies":{"minUI5Version":"1.72.2","libs":{"sap.ui.layout":{},"sap.ui.core":{},"sap.m":{},"sap.ui.fl":{"lazy":false}}}}}' }}); diff --git a/test/expected/build/application.j/dest/changes/flexibility-bundle.json b/test/expected/build/application.j/dest/changes/flexibility-bundle.json index 7caa00b9a..b3a5c5b1e 100644 --- a/test/expected/build/application.j/dest/changes/flexibility-bundle.json +++ b/test/expected/build/application.j/dest/changes/flexibility-bundle.json @@ -1 +1 @@ -{"changes":[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"compVariants":[{"fileName":"id_111_compVariants","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"appDescriptorChange":true}],"variants":[{"fileName":"id_111_test","fileType":"ctrl_variant","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantDependentControlChanges":[{"fileName":"id_111_variantDependentControlChange","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"variantReference":"someting here"}],"variantManagementChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_management_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}]} \ No newline at end of file +{"changes":[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"compVariants":[{"fileName":"id_111_compVariants","fileType":"variant","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"appDescriptorChange":false}],"variants":[{"fileName":"id_111_test","fileType":"ctrl_variant","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantDependentControlChanges":[{"fileName":"id_111_variantDependentControlChange","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"variantReference":"someting here"}],"variantManagementChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_management_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}]} \ No newline at end of file diff --git a/test/expected/build/application.j/dest/changes/id_111_compVariants.change b/test/expected/build/application.j/dest/changes/id_111_appDescriptor.change similarity index 100% rename from test/expected/build/application.j/dest/changes/id_111_compVariants.change rename to test/expected/build/application.j/dest/changes/id_111_appDescriptor.change diff --git a/test/expected/build/application.j/dest/changes/id_111_compVariants.variant b/test/expected/build/application.j/dest/changes/id_111_compVariants.variant new file mode 100644 index 000000000..26431d338 --- /dev/null +++ b/test/expected/build/application.j/dest/changes/id_111_compVariants.variant @@ -0,0 +1,21 @@ +{ + "fileName": "id_111_compVariants", + "fileType": "variant", + "changeType": "hideControl", + "component": "application.j.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.j.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + }, + "appDescriptorChange": false +} diff --git a/test/fixtures/application.j/webapp/changes/id_111_compVariants.change b/test/fixtures/application.j/webapp/changes/id_111_appDescriptor.change similarity index 100% rename from test/fixtures/application.j/webapp/changes/id_111_compVariants.change rename to test/fixtures/application.j/webapp/changes/id_111_appDescriptor.change diff --git a/test/fixtures/application.j/webapp/changes/id_111_compVariants.variant b/test/fixtures/application.j/webapp/changes/id_111_compVariants.variant new file mode 100644 index 000000000..26431d338 --- /dev/null +++ b/test/fixtures/application.j/webapp/changes/id_111_compVariants.variant @@ -0,0 +1,21 @@ +{ + "fileName": "id_111_compVariants", + "fileType": "variant", + "changeType": "hideControl", + "component": "application.j.Component", + "content": {}, + "selector": { + "id": "control1" + }, + "layer": "VENDOR", + "texts": {}, + "namespace": "apps/application.j.Component/changes", + "creation": "2025-10-30T13:52:40.4754350Z", + "originalLanguage": "", + "conditions": {}, + "support": { + "generator": "did it", + "user": "Max Mustermann" + }, + "appDescriptorChange": false +} diff --git a/test/lib/processors/bundlers/flexChangesBundler.js b/test/lib/processors/bundlers/flexChangesBundler.js index d107e581a..71c3c5677 100644 --- a/test/lib/processors/bundlers/flexChangesBundler.js +++ b/test/lib/processors/bundlers/flexChangesBundler.js @@ -192,11 +192,11 @@ test("flexChangesBundler has ctrl_variant and hasFlexBundleVersion = true", asyn ]; const compVariants = [{ "fileName": "id_1504764957625_7_rename1", - "fileType": "change", + "fileType": "variant", "changeType": "rename", "reference": "rta.performance.Component", "packageName": "$TMP", - "appDescriptorChange": true, + "appDescriptorChange": false, "content": { "originalControlType": "sap.m.Label" }, From 3b9acc9bf08de07d2ac76b54d52f41ed26e0bb83 Mon Sep 17 00:00:00 2001 From: Thuy Boehm Date: Mon, 28 Oct 2019 09:59:41 +0100 Subject: [PATCH 5/7] [INTERNAL] change minUI5Version to 1.73 --- lib/processors/bundlers/flexChangesBundler.js | 4 ++-- lib/tasks/bundlers/generateFlexChangesBundle.js | 6 +++--- test/expected/build/application.j/dest/Component-preload.js | 2 +- test/expected/build/application.j/dest/manifest.json | 2 +- test/fixtures/application.j/webapp/manifest.json | 2 +- test/lib/processors/bundlers/flexChangesBundler.js | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/processors/bundlers/flexChangesBundler.js b/lib/processors/bundlers/flexChangesBundler.js index 45512389e..513737a06 100644 --- a/lib/processors/bundlers/flexChangesBundler.js +++ b/lib/processors/bundlers/flexChangesBundler.js @@ -10,7 +10,7 @@ const resourceFactory = require("@ui5/fs").resourceFactory; * @param {module:@ui5/fs.Resource[]} parameters.resources List of resources to be processed * @param {Object} parameters.options Options * @param {string} parameters.options.pathPrefix Prefix for bundle path - * @param {string} parameters.options.hasFlexBundleVersion true if minUI5Version >= 1.72 than create flexibility-bundle.json + * @param {string} parameters.options.hasFlexBundleVersion true if minUI5Version >= 1.73 than create flexibility-bundle.json * @returns {Promise} Promise resolving with flex changes bundle resources */ module.exports = function({resources, options}) { @@ -57,7 +57,7 @@ module.exports = function({resources, options}) { }); if (!options.hasFlexBundleVersion && (compVariantList.length != 0 || variantList.length != 0 || variantChangeList.length != 0 || variantDependentControlChangeList.length != 0 || variantManagementChangeList.length != 0)) { - throw new Error("There are some control variant change in the changes folder. This only works with a minUI5Version 1.72.0. Please update the minUI5Version in the manifest.json minimum to 1.72.0"); + throw new Error("There are some control variant change in the changes folder. This only works with a minUI5Version 1.73.0. Please update the minUI5Version in the manifest.json minimum to 1.73.0"); } // create changes-bundle.json if (!options.hasFlexBundleVersion) { diff --git a/lib/tasks/bundlers/generateFlexChangesBundle.js b/lib/tasks/bundlers/generateFlexChangesBundle.js index ab7780f7e..b0ef419ea 100644 --- a/lib/tasks/bundlers/generateFlexChangesBundle.js +++ b/lib/tasks/bundlers/generateFlexChangesBundle.js @@ -6,8 +6,8 @@ const flexChangesBundler = require("../../processors/bundlers/flexChangesBundler * at runtime. * If a change bundle is created, "sap.ui.fl" is added as a dependency to the manifest.json if not already present - * if the dependency is already listed but lazy-loaded, lazy loading is disabled. - * If minUI5Version >= 1.72 flexibility-bundle.json will be create. - * If there a ctrl_variants and minUI5Version < 1.72 build will break and throw an error. + * If minUI5Version >= 1.73 flexibility-bundle.json will be create. + * If there a ctrl_variants and minUI5Version < 1.73 build will break and throw an error. * * @public * @alias module:@ui5/builder.tasks.generateFlexChangesBundle @@ -73,7 +73,7 @@ module.exports = function({workspace, options}) { .then((allResources) => { return readManifestMinUI5Version().then((version) => { let hasFlexBundleVersion = false; - if (parseFloat(version) >= 1.72) { + if (parseFloat(version) >= 1.73) { hasFlexBundleVersion = true; } return flexChangesBundler({ diff --git a/test/expected/build/application.j/dest/Component-preload.js b/test/expected/build/application.j/dest/Component-preload.js index 1df632fa4..4e58fdf09 100644 --- a/test/expected/build/application.j/dest/Component-preload.js +++ b/test/expected/build/application.j/dest/Component-preload.js @@ -8,5 +8,5 @@ jQuery.sap.registerPreloadedModules({ }, "application/j/changes/flexibility-bundle.json":'{"changes":[{"fileName":"id_456_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2023-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}},{"fileName":"id_123_addField","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"compVariants":[{"fileName":"id_111_compVariants","fileType":"variant","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"appDescriptorChange":false}],"variants":[{"fileName":"id_111_test","fileType":"ctrl_variant","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}],"variantDependentControlChanges":[{"fileName":"id_111_variantDependentControlChange","fileType":"change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"},"variantReference":"someting here"}],"variantManagementChanges":[{"fileName":"id_111_test","fileType":"ctrl_variant_management_change","changeType":"hideControl","component":"application.j.Component","content":{},"selector":{"id":"control1"},"layer":"VENDOR","texts":{},"namespace":"apps/application.j.Component/changes","creation":"2025-10-30T13:52:40.4754350Z","originalLanguage":"","conditions":{},"support":{"generator":"did it","user":"Max Mustermann"}}]}', "application/j/changes/fragments/MyFragment.fragment.xml":'', - "application/j/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.j","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"},"sap.ui5":{"dependencies":{"minUI5Version":"1.72.2","libs":{"sap.ui.layout":{},"sap.ui.core":{},"sap.m":{},"sap.ui.fl":{"lazy":false}}}}}' + "application/j/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.j","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"},"sap.ui5":{"dependencies":{"minUI5Version":"1.73.2","libs":{"sap.ui.layout":{},"sap.ui.core":{},"sap.m":{},"sap.ui.fl":{"lazy":false}}}}}' }}); diff --git a/test/expected/build/application.j/dest/manifest.json b/test/expected/build/application.j/dest/manifest.json index 465e1d9b9..f82703903 100644 --- a/test/expected/build/application.j/dest/manifest.json +++ b/test/expected/build/application.j/dest/manifest.json @@ -14,7 +14,7 @@ }, "sap.ui5": { "dependencies": { - "minUI5Version": "1.72.2", + "minUI5Version": "1.73.2", "libs": { "sap.ui.layout": {}, "sap.ui.core": {}, diff --git a/test/fixtures/application.j/webapp/manifest.json b/test/fixtures/application.j/webapp/manifest.json index d973b8507..97ce1c9a7 100644 --- a/test/fixtures/application.j/webapp/manifest.json +++ b/test/fixtures/application.j/webapp/manifest.json @@ -12,7 +12,7 @@ }, "sap.ui5": { "dependencies": { - "minUI5Version": "1.72.2", + "minUI5Version": "1.73.2", "libs": { "sap.ui.layout": {}, "sap.ui.core": {}, diff --git a/test/lib/processors/bundlers/flexChangesBundler.js b/test/lib/processors/bundlers/flexChangesBundler.js index 71c3c5677..2e2bc4897 100644 --- a/test/lib/processors/bundlers/flexChangesBundler.js +++ b/test/lib/processors/bundlers/flexChangesBundler.js @@ -489,5 +489,5 @@ test("flexChangesBundler has ctrl_variant and hasFlexBundleVersion = false", asy }; const error = await t.throwsAsync(flexChangesBundler({resources, options}), Error); - t.deepEqual(error.message, "There are some control variant change in the changes folder. This only works with a minUI5Version 1.72.0. Please update the minUI5Version in the manifest.json minimum to 1.72.0", "Correct exception thrown"); + t.deepEqual(error.message, "There are some control variant change in the changes folder. This only works with a minUI5Version 1.73.0. Please update the minUI5Version in the manifest.json minimum to 1.73.0", "Correct exception thrown"); }); From 3f30fd0ec543255aef2949e43a648b886881532a Mon Sep 17 00:00:00 2001 From: Thuy Boehm Date: Mon, 4 Nov 2019 11:58:47 +0100 Subject: [PATCH 6/7] [INTERNAL] change comment, optimize some lines --- lib/processors/bundlers/flexChangesBundler.js | 53 +++++++++++-------- .../bundlers/generateFlexChangesBundle.js | 26 ++++----- .../application.i/dest/Component-preload.js | 2 +- .../build/application.i/dest/manifest.json | 3 +- .../application.i/webapp/manifest.json | 3 +- .../processors/bundlers/flexChangesBundler.js | 2 +- 6 files changed, 49 insertions(+), 40 deletions(-) diff --git a/lib/processors/bundlers/flexChangesBundler.js b/lib/processors/bundlers/flexChangesBundler.js index 513737a06..a74942936 100644 --- a/lib/processors/bundlers/flexChangesBundler.js +++ b/lib/processors/bundlers/flexChangesBundler.js @@ -20,14 +20,20 @@ module.exports = function({resources, options}) { return a.creation > b.creation ? 1 : -1; } + /** + * bundle changes resource to json string + * + * @param {Array} changesContent Array of resources files + * @returns {string} Json sting of changes and control variants + */ function sortAndStringifyInFlexFormat(changesContent) { changesContent = changesContent.sort(sortByTimeStamp); - const changeList = []; - const variantDependentControlChangeList = []; - const compVariantList = []; - const variantList = []; - const variantChangeList = []; - const variantManagementChangeList = []; + const changes = []; + const variantDependentControlChanges = []; + const compVariants = []; + const variants = []; + const variantChanges = []; + const variantManagementChanges = []; changesContent.forEach(function(content) { switch (content.fileType) { @@ -36,41 +42,42 @@ module.exports = function({resources, options}) { break; } if (content.variantReference && content.variantReference !== "") { - variantDependentControlChangeList.push(content); + variantDependentControlChanges.push(content); } else { - changeList.push(content); + changes.push(content); } break; case "variant": - compVariantList.push(content); + compVariants.push(content); break; case "ctrl_variant": - variantList.push(content); + variants.push(content); break; case "ctrl_variant_change": - variantChangeList.push(content); + variantChanges.push(content); break; case "ctrl_variant_management_change": - variantManagementChangeList.push(content); + variantManagementChanges.push(content); break; } }); - if (!options.hasFlexBundleVersion && (compVariantList.length != 0 || variantList.length != 0 || variantChangeList.length != 0 || variantDependentControlChangeList.length != 0 || variantManagementChangeList.length != 0)) { - throw new Error("There are some control variant change in the changes folder. This only works with a minUI5Version 1.73.0. Please update the minUI5Version in the manifest.json minimum to 1.73.0"); + if (!options.hasFlexBundleVersion && (compVariants.length != 0 || variants.length != 0 || variantChanges.length != 0 || variantDependentControlChanges.length != 0 || variantManagementChanges.length != 0)) { + throw new Error("There is some control variant changes in the changes folder. This only works with a minUI5Version 1.73.0. Please update the minUI5Version in the manifest.json to 1.73.0 or higher"); } // create changes-bundle.json if (!options.hasFlexBundleVersion) { - return JSON.stringify(changeList); + return JSON.stringify(changes); } else { bundleName = "flexibility-bundle.json"; - const newChangeFormat = {}; - newChangeFormat.changes = changeList; - newChangeFormat.compVariants = compVariantList; - newChangeFormat.variants = variantList; - newChangeFormat.variantChanges = variantChangeList; - newChangeFormat.variantDependentControlChanges = variantDependentControlChangeList; - newChangeFormat.variantManagementChanges = variantManagementChangeList; + const newChangeFormat = { + changes, + compVariants, + variants, + variantChanges, + variantDependentControlChanges, + variantManagementChanges + }; return JSON.stringify(newChangeFormat); } @@ -87,7 +94,7 @@ module.exports = function({resources, options}) { if (nNumberOfChanges > 0) { changesContent = sortAndStringifyInFlexFormat(changesContent); result.push(resourceFactory.createResource({ - path: `${options.pathPrefix}/changes/` + bundleName, + path: `${options.pathPrefix}/changes/${bundleName}`, string: changesContent })); } diff --git a/lib/tasks/bundlers/generateFlexChangesBundle.js b/lib/tasks/bundlers/generateFlexChangesBundle.js index b0ef419ea..232c65ab6 100644 --- a/lib/tasks/bundlers/generateFlexChangesBundle.js +++ b/lib/tasks/bundlers/generateFlexChangesBundle.js @@ -7,7 +7,7 @@ const flexChangesBundler = require("../../processors/bundlers/flexChangesBundler * If a change bundle is created, "sap.ui.fl" is added as a dependency to the manifest.json if not already present - * if the dependency is already listed but lazy-loaded, lazy loading is disabled. * If minUI5Version >= 1.73 flexibility-bundle.json will be create. - * If there a ctrl_variants and minUI5Version < 1.73 build will break and throw an error. + * If there a control variants and minUI5Version < 1.73 build will break and throw an error. * * @public * @alias module:@ui5/builder.tasks.generateFlexChangesBundle @@ -24,6 +24,8 @@ module.exports = function({workspace, options}) { if (options && options.namespace) { pathPrefix = `/resources/${options.namespace}`; } + let manifestResource = {}; + let manifestContent = {}; function updateJson(data) { // ensure the existence of the libs section in the dependencies @@ -44,27 +46,26 @@ module.exports = function({workspace, options}) { } async function updateFLdependency() { - const manifestResource = await workspace.byPath(`${pathPrefix}/manifest.json`); - const manifestContent = JSON.parse(await manifestResource.getString()); - updateJson(manifestContent); manifestResource.setString(JSON.stringify(manifestContent, null, "\t")); await workspace.write(manifestResource); } - function readManifestMinUI5Version() { - return workspace.byPath(`${pathPrefix}/manifest.json`).then((manifestResource) => { + async function readManifestMinUI5Version() { + return workspace.byPath(`${pathPrefix}/manifest.json`).then((manifestResourceResult) => { + manifestResource = manifestResourceResult; if (manifestResource) { return manifestResource.getBuffer().then((buffer) => { return JSON.parse(buffer.toString()); }); } return {}; - }).then((manifestContent) => { - manifestContent["sap.ui5"] = manifestContent["sap.ui5"] || {}; - manifestContent["sap.ui5"].dependencies = manifestContent["sap.ui5"].dependencies || {}; - return manifestContent["sap.ui5"].dependencies.minUI5Version = manifestContent["sap.ui5"].dependencies.minUI5Version || ""; + }).then((manifestContentResult) => { + manifestContent = Object.assign({}, manifestContentResult); + manifestContentResult["sap.ui5"] = manifestContentResult["sap.ui5"] || {}; + manifestContentResult["sap.ui5"].dependencies = manifestContentResult["sap.ui5"].dependencies || {}; + return manifestContentResult["sap.ui5"].dependencies.minUI5Version = manifestContentResult["sap.ui5"].dependencies.minUI5Version || ""; }); } @@ -79,9 +80,8 @@ module.exports = function({workspace, options}) { return flexChangesBundler({ resources: allResources, options: { - namespace: options.namespace, - pathPrefix: pathPrefix, - hasFlexBundleVersion: hasFlexBundleVersion + pathPrefix, + hasFlexBundleVersion } }); }); diff --git a/test/expected/build/application.i/dest/Component-preload.js b/test/expected/build/application.i/dest/Component-preload.js index 0c2c24167..e2b484305 100644 --- a/test/expected/build/application.i/dest/Component-preload.js +++ b/test/expected/build/application.i/dest/Component-preload.js @@ -8,5 +8,5 @@ jQuery.sap.registerPreloadedModules({ "application/i/changes/coding/MyExtension.js":function(){sap.ui.define([],function(){return{}}); }, "application/i/changes/fragments/MyFragment.fragment.xml":'', - "application/i/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.i","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"},"sap.ui5":{"dependencies":{"libs":{"sap.ui.layout":{},"sap.ui.core":{},"sap.m":{},"sap.ui.fl":{}}}}}' + "application/i/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.i","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"},"sap.ui5":{"dependencies":{"libs":{"sap.ui.layout":{},"sap.ui.core":{},"sap.m":{},"sap.ui.fl":{}},"minUI5Version":"1.72.0"}}}' }}); diff --git a/test/expected/build/application.i/dest/manifest.json b/test/expected/build/application.i/dest/manifest.json index 73ea616ee..b79d5bd16 100644 --- a/test/expected/build/application.i/dest/manifest.json +++ b/test/expected/build/application.i/dest/manifest.json @@ -19,7 +19,8 @@ "sap.ui.core": {}, "sap.m": {}, "sap.ui.fl": {} - } + }, + "minUI5Version": "1.72.0" } } } \ No newline at end of file diff --git a/test/fixtures/application.i/webapp/manifest.json b/test/fixtures/application.i/webapp/manifest.json index 557627fd4..66f6e5489 100644 --- a/test/fixtures/application.i/webapp/manifest.json +++ b/test/fixtures/application.i/webapp/manifest.json @@ -16,7 +16,8 @@ "sap.ui.layout": {}, "sap.ui.core": {}, "sap.m": {} - } + }, + "minUI5Version": "1.72.0" } } } diff --git a/test/lib/processors/bundlers/flexChangesBundler.js b/test/lib/processors/bundlers/flexChangesBundler.js index 2e2bc4897..bf83873cb 100644 --- a/test/lib/processors/bundlers/flexChangesBundler.js +++ b/test/lib/processors/bundlers/flexChangesBundler.js @@ -489,5 +489,5 @@ test("flexChangesBundler has ctrl_variant and hasFlexBundleVersion = false", asy }; const error = await t.throwsAsync(flexChangesBundler({resources, options}), Error); - t.deepEqual(error.message, "There are some control variant change in the changes folder. This only works with a minUI5Version 1.73.0. Please update the minUI5Version in the manifest.json minimum to 1.73.0", "Correct exception thrown"); + t.deepEqual(error.message, "There is some control variant changes in the changes folder. This only works with a minUI5Version 1.73.0. Please update the minUI5Version in the manifest.json to 1.73.0 or higher", "Correct exception thrown"); }); From 7d77213e90aec65a53a60c8117291a94b19c0325 Mon Sep 17 00:00:00 2001 From: Thuy Boehm Date: Thu, 7 Nov 2019 10:20:59 +0100 Subject: [PATCH 7/7] [INTERNAL] change comment and change read manifest --- lib/processors/bundlers/flexChangesBundler.js | 2 +- .../bundlers/generateFlexChangesBundle.js | 52 +++++++++---------- .../application.i/dest/Component-preload.js | 2 +- .../build/application.i/dest/manifest.json | 3 +- .../application.i/webapp/manifest.json | 3 +- .../processors/bundlers/flexChangesBundler.js | 2 +- 6 files changed, 29 insertions(+), 35 deletions(-) diff --git a/lib/processors/bundlers/flexChangesBundler.js b/lib/processors/bundlers/flexChangesBundler.js index a74942936..62d54a1db 100644 --- a/lib/processors/bundlers/flexChangesBundler.js +++ b/lib/processors/bundlers/flexChangesBundler.js @@ -63,7 +63,7 @@ module.exports = function({resources, options}) { }); if (!options.hasFlexBundleVersion && (compVariants.length != 0 || variants.length != 0 || variantChanges.length != 0 || variantDependentControlChanges.length != 0 || variantManagementChanges.length != 0)) { - throw new Error("There is some control variant changes in the changes folder. This only works with a minUI5Version 1.73.0. Please update the minUI5Version in the manifest.json to 1.73.0 or higher"); + throw new Error("There are some control variant changes in the changes folder. This only works with a minUI5Version 1.73.0. Please update the minUI5Version in the manifest.json to 1.73.0 or higher"); } // create changes-bundle.json if (!options.hasFlexBundleVersion) { diff --git a/lib/tasks/bundlers/generateFlexChangesBundle.js b/lib/tasks/bundlers/generateFlexChangesBundle.js index 232c65ab6..710753b4f 100644 --- a/lib/tasks/bundlers/generateFlexChangesBundle.js +++ b/lib/tasks/bundlers/generateFlexChangesBundle.js @@ -7,7 +7,7 @@ const flexChangesBundler = require("../../processors/bundlers/flexChangesBundler * If a change bundle is created, "sap.ui.fl" is added as a dependency to the manifest.json if not already present - * if the dependency is already listed but lazy-loaded, lazy loading is disabled. * If minUI5Version >= 1.73 flexibility-bundle.json will be create. - * If there a control variants and minUI5Version < 1.73 build will break and throw an error. + * If there are control variants and minUI5Version < 1.73 build will break and throw an error. * * @public * @alias module:@ui5/builder.tasks.generateFlexChangesBundle @@ -24,8 +24,6 @@ module.exports = function({workspace, options}) { if (options && options.namespace) { pathPrefix = `/resources/${options.namespace}`; } - let manifestResource = {}; - let manifestContent = {}; function updateJson(data) { // ensure the existence of the libs section in the dependencies @@ -46,6 +44,9 @@ module.exports = function({workspace, options}) { } async function updateFLdependency() { + const manifestResource = await workspace.byPath(`${pathPrefix}/manifest.json`); + const manifestContent = JSON.parse(await manifestResource.getString()); + updateJson(manifestContent); manifestResource.setString(JSON.stringify(manifestContent, null, "\t")); @@ -53,38 +54,33 @@ module.exports = function({workspace, options}) { } async function readManifestMinUI5Version() { - return workspace.byPath(`${pathPrefix}/manifest.json`).then((manifestResourceResult) => { - manifestResource = manifestResourceResult; - if (manifestResource) { - return manifestResource.getBuffer().then((buffer) => { - return JSON.parse(buffer.toString()); - }); - } - return {}; - }).then((manifestContentResult) => { - manifestContent = Object.assign({}, manifestContentResult); - manifestContentResult["sap.ui5"] = manifestContentResult["sap.ui5"] || {}; - manifestContentResult["sap.ui5"].dependencies = manifestContentResult["sap.ui5"].dependencies || {}; - return manifestContentResult["sap.ui5"].dependencies.minUI5Version = manifestContentResult["sap.ui5"].dependencies.minUI5Version || ""; - }); + const manifestResource = await workspace.byPath(`${pathPrefix}/manifest.json`); + const manifestContent = JSON.parse(await manifestResource.getString()); + + manifestContent["sap.ui5"] = manifestContent["sap.ui5"] || {}; + manifestContent["sap.ui5"].dependencies = manifestContent["sap.ui5"].dependencies || {}; + return manifestContent["sap.ui5"].dependencies.minUI5Version = manifestContent["sap.ui5"].dependencies.minUI5Version || ""; } log.verbose("Collecting flexibility changes"); return workspace.byGlob(`${pathPrefix}/changes/*.{change,variant,ctrl_variant,ctrl_variant_change,ctrl_variant_management_change}`) .then((allResources) => { - return readManifestMinUI5Version().then((version) => { - let hasFlexBundleVersion = false; - if (parseFloat(version) >= 1.73) { - hasFlexBundleVersion = true; - } - return flexChangesBundler({ - resources: allResources, - options: { - pathPrefix, - hasFlexBundleVersion + if (allResources.length > 0) { + return readManifestMinUI5Version().then((version) => { + let hasFlexBundleVersion = false; + if (parseFloat(version) >= 1.73) { + hasFlexBundleVersion = true; } + return flexChangesBundler({ + resources: allResources, + options: { + pathPrefix, + hasFlexBundleVersion + } + }); }); - }); + } + return []; }) .then((processedResources) => { return Promise.all(processedResources.map((resource) => { diff --git a/test/expected/build/application.i/dest/Component-preload.js b/test/expected/build/application.i/dest/Component-preload.js index e2b484305..0c2c24167 100644 --- a/test/expected/build/application.i/dest/Component-preload.js +++ b/test/expected/build/application.i/dest/Component-preload.js @@ -8,5 +8,5 @@ jQuery.sap.registerPreloadedModules({ "application/i/changes/coding/MyExtension.js":function(){sap.ui.define([],function(){return{}}); }, "application/i/changes/fragments/MyFragment.fragment.xml":'', - "application/i/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.i","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"},"sap.ui5":{"dependencies":{"libs":{"sap.ui.layout":{},"sap.ui.core":{},"sap.m":{},"sap.ui.fl":{}},"minUI5Version":"1.72.0"}}}' + "application/i/manifest.json":'{"_version":"1.1.0","sap.app":{"_version":"1.1.0","id":"application.i","type":"application","applicationVersion":{"version":"1.2.2"},"embeds":["embedded"],"title":"{{title}}"},"sap.ui5":{"dependencies":{"libs":{"sap.ui.layout":{},"sap.ui.core":{},"sap.m":{},"sap.ui.fl":{}}}}}' }}); diff --git a/test/expected/build/application.i/dest/manifest.json b/test/expected/build/application.i/dest/manifest.json index b79d5bd16..73ea616ee 100644 --- a/test/expected/build/application.i/dest/manifest.json +++ b/test/expected/build/application.i/dest/manifest.json @@ -19,8 +19,7 @@ "sap.ui.core": {}, "sap.m": {}, "sap.ui.fl": {} - }, - "minUI5Version": "1.72.0" + } } } } \ No newline at end of file diff --git a/test/fixtures/application.i/webapp/manifest.json b/test/fixtures/application.i/webapp/manifest.json index 66f6e5489..557627fd4 100644 --- a/test/fixtures/application.i/webapp/manifest.json +++ b/test/fixtures/application.i/webapp/manifest.json @@ -16,8 +16,7 @@ "sap.ui.layout": {}, "sap.ui.core": {}, "sap.m": {} - }, - "minUI5Version": "1.72.0" + } } } } diff --git a/test/lib/processors/bundlers/flexChangesBundler.js b/test/lib/processors/bundlers/flexChangesBundler.js index bf83873cb..f6068ff9f 100644 --- a/test/lib/processors/bundlers/flexChangesBundler.js +++ b/test/lib/processors/bundlers/flexChangesBundler.js @@ -489,5 +489,5 @@ test("flexChangesBundler has ctrl_variant and hasFlexBundleVersion = false", asy }; const error = await t.throwsAsync(flexChangesBundler({resources, options}), Error); - t.deepEqual(error.message, "There is some control variant changes in the changes folder. This only works with a minUI5Version 1.73.0. Please update the minUI5Version in the manifest.json to 1.73.0 or higher", "Correct exception thrown"); + t.deepEqual(error.message, "There are some control variant changes in the changes folder. This only works with a minUI5Version 1.73.0. Please update the minUI5Version in the manifest.json to 1.73.0 or higher", "Correct exception thrown"); });