From 001183a4981bb5fe43039cedfbea70c2090b24db Mon Sep 17 00:00:00 2001 From: Merlin Beutlberger Date: Wed, 22 Jul 2020 18:23:04 +0200 Subject: [PATCH] [FEATURE] generateFlexChangesBundle: Hide bundle input from build result Flexibility changes files that are bundled are not part of the build result anymore. This feature is using the new resource tagging as per RFC 0008: https://github.com/SAP/ui5-tooling/pull/243 --- .../bundlers/generateFlexChangesBundle.js | 57 +++++++++---------- lib/types/application/ApplicationBuilder.js | 1 + .../dest/changes/id_123_addField.change | 20 ------- .../dest/changes/id_456_addField.change | 20 ------- .../dest/changes/id_111_appDescriptor.change | 21 ------- .../dest/changes/id_111_compVariants.variant | 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 ------- .../dest/changes/id_123_addField.change | 20 ------- .../dest/changes/id_456_addField.change | 20 ------- 12 files changed, 29 insertions(+), 232 deletions(-) delete mode 100644 test/expected/build/application.i/dest/changes/id_123_addField.change delete mode 100644 test/expected/build/application.i/dest/changes/id_456_addField.change delete mode 100644 test/expected/build/application.j/dest/changes/id_111_appDescriptor.change delete mode 100644 test/expected/build/application.j/dest/changes/id_111_compVariants.variant delete mode 100644 test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant delete mode 100644 test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant_change delete mode 100644 test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant_management_change delete mode 100644 test/expected/build/application.j/dest/changes/id_111_variantDependentControlChange.change delete mode 100644 test/expected/build/application.j/dest/changes/id_123_addField.change delete mode 100644 test/expected/build/application.j/dest/changes/id_456_addField.change diff --git a/lib/tasks/bundlers/generateFlexChangesBundle.js b/lib/tasks/bundlers/generateFlexChangesBundle.js index e0caea0dd..68a52766f 100644 --- a/lib/tasks/bundlers/generateFlexChangesBundle.js +++ b/lib/tasks/bundlers/generateFlexChangesBundle.js @@ -17,7 +17,7 @@ const flexChangesBundler = require("../../processors/bundlers/flexChangesBundler * @param {string} [parameters.options.namespace] Application Namespace * @returns {Promise} Promise resolving with undefined once data has been written */ -module.exports = function({workspace, options: {namespace}}) { +module.exports = async function({workspace, taskUtil, options: {namespace}}) { // Use the given namespace if available, otherwise use no namespace // (e.g. in case no manifest.json is present) let pathPrefix = ""; @@ -63,34 +63,33 @@ module.exports = function({workspace, options: {namespace}}) { } log.verbose("Collecting flexibility changes"); - return workspace.byGlob(`${pathPrefix}/changes/*.{change,variant,ctrl_variant,ctrl_variant_change,ctrl_variant_management_change}`) - .then((allResources) => { - 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 - } - }); - }); + const allResources = await workspace.byGlob( + `${pathPrefix}/changes/*.{change,variant,ctrl_variant,ctrl_variant_change,ctrl_variant_management_change}`); + if (allResources.length > 0) { + const version = await readManifestMinUI5Version(); + let hasFlexBundleVersion = false; + if (parseFloat(version) >= 1.73) { + hasFlexBundleVersion = true; + } + const processedResources = await flexChangesBundler({ + resources: allResources, + options: { + pathPrefix, + hasFlexBundleVersion } - return []; - }) - .then((processedResources) => { - return Promise.all(processedResources.map((resource) => { - log.verbose("Writing flexibility changes bundle"); - return workspace.write(resource); - })).then(async () => { - // Add the sap.ui.fl dependency if a bundle has been created - if (processedResources.length > 0) { - await updateFLdependency(); - } - }); }); + await Promise.all(processedResources.map((resource) => { + log.verbose("Writing flexibility changes bundle"); + return workspace.write(resource); + })); + // Add the sap.ui.fl dependency if a bundle has been created + if (processedResources.length > 0) { + await updateFLdependency(); + } + + // Do not write bundled source files to build result + allResources.forEach((resource) => { + taskUtil.setTag(resource, taskUtil.STANDARD_TAGS.HideFromBuildResult); + }); + } }; diff --git a/lib/types/application/ApplicationBuilder.js b/lib/types/application/ApplicationBuilder.js index 4c86ca890..7ff80869b 100644 --- a/lib/types/application/ApplicationBuilder.js +++ b/lib/types/application/ApplicationBuilder.js @@ -47,6 +47,7 @@ class ApplicationBuilder extends AbstractBuilder { const generateFlexChangesBundle = getTask("generateFlexChangesBundle").task; return generateFlexChangesBundle({ workspace: resourceCollections.workspace, + taskUtil, options: { namespace: project.metadata.namespace } diff --git a/test/expected/build/application.i/dest/changes/id_123_addField.change b/test/expected/build/application.i/dest/changes/id_123_addField.change deleted file mode 100644 index b1b1e9cda..000000000 --- a/test/expected/build/application.i/dest/changes/id_123_addField.change +++ /dev/null @@ -1,20 +0,0 @@ -{ - "fileName": "id_123_addField", - "fileType": "change", - "changeType": "hideControl", - "component": "application.i.Component", - "content": {}, - "selector": { - "id": "control1" - }, - "layer": "VENDOR", - "texts": {}, - "namespace": "apps/application.i.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.i/dest/changes/id_456_addField.change b/test/expected/build/application.i/dest/changes/id_456_addField.change deleted file mode 100644 index 0ca9acd3b..000000000 --- a/test/expected/build/application.i/dest/changes/id_456_addField.change +++ /dev/null @@ -1,20 +0,0 @@ -{ - "fileName": "id_456_addField", - "fileType": "change", - "changeType": "hideControl", - "component": "application.i.Component", - "content": {}, - "selector": { - "id": "control1" - }, - "layer": "VENDOR", - "texts": {}, - "namespace": "apps/application.i.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.j/dest/changes/id_111_appDescriptor.change b/test/expected/build/application.j/dest/changes/id_111_appDescriptor.change deleted file mode 100644 index 9c7f911b9..000000000 --- a/test/expected/build/application.j/dest/changes/id_111_appDescriptor.change +++ /dev/null @@ -1,21 +0,0 @@ -{ - "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_compVariants.variant b/test/expected/build/application.j/dest/changes/id_111_compVariants.variant deleted file mode 100644 index 26431d338..000000000 --- a/test/expected/build/application.j/dest/changes/id_111_compVariants.variant +++ /dev/null @@ -1,21 +0,0 @@ -{ - "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/expected/build/application.j/dest/changes/id_111_test.ctrl_variant b/test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant deleted file mode 100644 index 01d2bfb47..000000000 --- a/test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant +++ /dev/null @@ -1,20 +0,0 @@ -{ - "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 deleted file mode 100644 index 8691c2e82..000000000 --- a/test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant_change +++ /dev/null @@ -1,20 +0,0 @@ -{ - "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 deleted file mode 100644 index 1e1f585c8..000000000 --- a/test/expected/build/application.j/dest/changes/id_111_test.ctrl_variant_management_change +++ /dev/null @@ -1,20 +0,0 @@ -{ - "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 deleted file mode 100644 index bd733b67e..000000000 --- a/test/expected/build/application.j/dest/changes/id_111_variantDependentControlChange.change +++ /dev/null @@ -1,21 +0,0 @@ -{ - "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/changes/id_123_addField.change b/test/expected/build/application.j/dest/changes/id_123_addField.change deleted file mode 100644 index 41d9bb61c..000000000 --- a/test/expected/build/application.j/dest/changes/id_123_addField.change +++ /dev/null @@ -1,20 +0,0 @@ -{ - "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" - } -} diff --git a/test/expected/build/application.j/dest/changes/id_456_addField.change b/test/expected/build/application.j/dest/changes/id_456_addField.change deleted file mode 100644 index 4d4c73b51..000000000 --- a/test/expected/build/application.j/dest/changes/id_456_addField.change +++ /dev/null @@ -1,20 +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" - } -}