diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 5392cdfd1..e5196f31d 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -207,6 +207,8 @@ module.exports = { * @param {string} parameters.destPath Target path * @param {boolean} [parameters.cleanDest=false] Decides whether project should clean the target path before build * @param {boolean} [parameters.buildDependencies=false] Decides whether project dependencies are built as well + * @param {Array.} [parameters.includedDependencies=[]] List of build dependencies to be included if buildDependencies is true + * @param {Array.} [parameters.excludedDependencies=[]] List of build dependencies to be excluded if buildDependencies is true. If the wildcard '*' is provided, only the included dependencies will be built. * @param {boolean} [parameters.dev=false] Decides whether a development build should be activated (skips non-essential and time-intensive tasks) * @param {boolean} [parameters.selfContained=false] Flag to activate self contained build * @param {boolean} [parameters.jsdoc=false] Flag to activate JSDoc build @@ -217,7 +219,8 @@ module.exports = { */ async build({ tree, destPath, cleanDest = false, - buildDependencies = false, dev = false, selfContained = false, jsdoc = false, + buildDependencies = false, includedDependencies = [], excludedDependencies = [], + dev = false, selfContained = false, jsdoc = false, includedTasks = [], excludedTasks = [], devExcludeProject = [] }) { const startTime = process.hrtime(); @@ -237,11 +240,30 @@ module.exports = { const projects = {}; // Unique project index to prevent building the same project multiple times const projectWriters = {}; // Collection of memory adapters of already built libraries + function projectFilter(project) { + function projectMatchesAny(deps) { + return deps.some((dep) => dep instanceof RegExp ? + dep.test(project.metadata.name) : dep === project.metadata.name); + } + + // if everything is included, this overrules exclude lists + if (includedDependencies.includes("*")) return true; + let test = !excludedDependencies.includes("*"); // exclude everything? + + if (test && projectMatchesAny(excludedDependencies)) { + test = false; + } + if (!test && projectMatchesAny(includedDependencies)) { + test = true; + } + + return test; + } const projectCountMarker = {}; function projectCount(project, count = 0) { if (buildDependencies) { - count = project.dependencies.reduce((depCount, depProject) => { + count = project.dependencies.filter(projectFilter).reduce((depCount, depProject) => { return projectCount(depProject, depCount); }, count); } @@ -251,21 +273,22 @@ module.exports = { } return count; } - const iProjectCount = projectCount(tree); - const buildLogger = log.createTaskLogger("🛠 ", iProjectCount); + const buildLogger = log.createTaskLogger("🛠 ", projectCount(tree)); function buildProject(project) { let depPromise; let projectTasks = selectedTasks; + + // Build dependencies in sequence as it is far easier to detect issues and reduces + // side effects or other issues such as too many open files if (buildDependencies) { - // Build dependencies in sequence as it is far easier to detect issues and reduces - // side effects or other issues such as too many open files - depPromise = project.dependencies.reduce(function(p, depProject) { + depPromise = project.dependencies.filter(projectFilter).reduce(function(p, depProject) { return p.then(() => buildProject(depProject)); }, Promise.resolve()); } else { depPromise = Promise.resolve(); } + // Build the project after all dependencies have been built return depPromise.then(() => { if (projects[project.metadata.name]) { diff --git a/test/expected/build/application.a/dest-deps-excl/index.html b/test/expected/build/application.a/dest-deps-excl/index.html new file mode 100644 index 000000000..1523b1dc3 --- /dev/null +++ b/test/expected/build/application.a/dest-deps-excl/index.html @@ -0,0 +1,11 @@ + + + + Application A + + + + + + \ No newline at end of file diff --git a/test/expected/build/application.a/dest-deps-excl/resources/library/a/.library b/test/expected/build/application.a/dest-deps-excl/resources/library/a/.library new file mode 100644 index 000000000..cddfadd9a --- /dev/null +++ b/test/expected/build/application.a/dest-deps-excl/resources/library/a/.library @@ -0,0 +1,17 @@ + + + + library.a + SAP SE + Some fancy copyright ${currentYear} + 1.0.0 + + Library A + + + + library.d + + + + diff --git a/test/expected/build/application.a/dest-deps-excl/resources/library/a/themes/base/library-RTL.css b/test/expected/build/application.a/dest-deps-excl/resources/library/a/themes/base/library-RTL.css new file mode 100644 index 000000000..5398b3f08 --- /dev/null +++ b/test/expected/build/application.a/dest-deps-excl/resources/library/a/themes/base/library-RTL.css @@ -0,0 +1,3 @@ +.library-a-foo{color:#fafad2;padding:1px 4px 3px 2px} +/* Inline theming parameters */ +#sap-ui-theme-library\.a{background-image:url('data:text/plain;utf-8,%7B%22libraryAColor1%22%3A%22%23fafad2%22%7D')} diff --git a/test/expected/build/application.a/dest-deps-excl/resources/library/a/themes/base/library-parameters.json b/test/expected/build/application.a/dest-deps-excl/resources/library/a/themes/base/library-parameters.json new file mode 100644 index 000000000..da3b7a52f --- /dev/null +++ b/test/expected/build/application.a/dest-deps-excl/resources/library/a/themes/base/library-parameters.json @@ -0,0 +1 @@ +{"libraryAColor1":"#fafad2"} \ No newline at end of file diff --git a/test/expected/build/application.a/dest-deps-excl/resources/library/a/themes/base/library.css b/test/expected/build/application.a/dest-deps-excl/resources/library/a/themes/base/library.css new file mode 100644 index 000000000..ba056b3c0 --- /dev/null +++ b/test/expected/build/application.a/dest-deps-excl/resources/library/a/themes/base/library.css @@ -0,0 +1,3 @@ +.library-a-foo{color:#fafad2;padding:1px 2px 3px 4px} +/* Inline theming parameters */ +#sap-ui-theme-library\.a{background-image:url('data:text/plain;utf-8,%7B%22libraryAColor1%22%3A%22%23fafad2%22%7D')} diff --git a/test/expected/build/application.a/dest-deps-excl/resources/library/a/themes/base/library.source.less b/test/expected/build/application.a/dest-deps-excl/resources/library/a/themes/base/library.source.less new file mode 100644 index 000000000..ff0f1d5e3 --- /dev/null +++ b/test/expected/build/application.a/dest-deps-excl/resources/library/a/themes/base/library.source.less @@ -0,0 +1,6 @@ +@libraryAColor1: lightgoldenrodyellow; + +.library-a-foo { + color: @libraryAColor1; + padding: 1px 2px 3px 4px; +} diff --git a/test/expected/build/application.a/dest-deps-excl/resources/library/b/.library b/test/expected/build/application.a/dest-deps-excl/resources/library/b/.library new file mode 100644 index 000000000..8cfb124a9 --- /dev/null +++ b/test/expected/build/application.a/dest-deps-excl/resources/library/b/.library @@ -0,0 +1,17 @@ + + + + library.b + SAP SE + Some fancy copyright ${currentYear} + 1.0.0 + + Library B + + + + library.d + + + + diff --git a/test/expected/build/application.a/dest-deps-excl/resources/library/c/.library b/test/expected/build/application.a/dest-deps-excl/resources/library/c/.library new file mode 100644 index 000000000..3c011ecd6 --- /dev/null +++ b/test/expected/build/application.a/dest-deps-excl/resources/library/c/.library @@ -0,0 +1,17 @@ + + + + library.c + SAP SE + ${copyright} + 1.0.0 + + Library C + + + + library.d + + + + diff --git a/test/expected/build/application.a/dest-deps-excl/test-dbg.js b/test/expected/build/application.a/dest-deps-excl/test-dbg.js new file mode 100644 index 000000000..cb4595405 --- /dev/null +++ b/test/expected/build/application.a/dest-deps-excl/test-dbg.js @@ -0,0 +1,9 @@ +sap.ui.define([ + "library/d/some" +], function(someObject) { + function test(paramA) { + var variableA = paramA; + console.log(variableA); + } + test(); +}); diff --git a/test/expected/build/application.a/dest-deps-excl/test-resources/LibraryC/Test.html b/test/expected/build/application.a/dest-deps-excl/test-resources/LibraryC/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/application.a/dest-deps-excl/test-resources/library/a/Test.html b/test/expected/build/application.a/dest-deps-excl/test-resources/library/a/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/application.a/dest-deps-excl/test-resources/library/b/Test.html b/test/expected/build/application.a/dest-deps-excl/test-resources/library/b/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/application.a/dest-deps-excl/test.js b/test/expected/build/application.a/dest-deps-excl/test.js new file mode 100644 index 000000000..fd8278c6e --- /dev/null +++ b/test/expected/build/application.a/dest-deps-excl/test.js @@ -0,0 +1 @@ +sap.ui.define(["library/d/some"],function(n){function o(n){var o=n;console.log(o)}o()}); \ No newline at end of file diff --git a/test/expected/build/application.a/dest-deps/index.html b/test/expected/build/application.a/dest-deps/index.html new file mode 100644 index 000000000..1523b1dc3 --- /dev/null +++ b/test/expected/build/application.a/dest-deps/index.html @@ -0,0 +1,11 @@ + + + + Application A + + + + + + \ No newline at end of file diff --git a/test/expected/build/application.a/dest-deps/resources/library/a/.library b/test/expected/build/application.a/dest-deps/resources/library/a/.library new file mode 100644 index 000000000..cddfadd9a --- /dev/null +++ b/test/expected/build/application.a/dest-deps/resources/library/a/.library @@ -0,0 +1,17 @@ + + + + library.a + SAP SE + Some fancy copyright ${currentYear} + 1.0.0 + + Library A + + + + library.d + + + + diff --git a/test/expected/build/application.a/dest-deps/resources/library/a/themes/base/library-RTL.css b/test/expected/build/application.a/dest-deps/resources/library/a/themes/base/library-RTL.css new file mode 100644 index 000000000..5398b3f08 --- /dev/null +++ b/test/expected/build/application.a/dest-deps/resources/library/a/themes/base/library-RTL.css @@ -0,0 +1,3 @@ +.library-a-foo{color:#fafad2;padding:1px 4px 3px 2px} +/* Inline theming parameters */ +#sap-ui-theme-library\.a{background-image:url('data:text/plain;utf-8,%7B%22libraryAColor1%22%3A%22%23fafad2%22%7D')} diff --git a/test/expected/build/application.a/dest-deps/resources/library/a/themes/base/library-parameters.json b/test/expected/build/application.a/dest-deps/resources/library/a/themes/base/library-parameters.json new file mode 100644 index 000000000..da3b7a52f --- /dev/null +++ b/test/expected/build/application.a/dest-deps/resources/library/a/themes/base/library-parameters.json @@ -0,0 +1 @@ +{"libraryAColor1":"#fafad2"} \ No newline at end of file diff --git a/test/expected/build/application.a/dest-deps/resources/library/a/themes/base/library.css b/test/expected/build/application.a/dest-deps/resources/library/a/themes/base/library.css new file mode 100644 index 000000000..ba056b3c0 --- /dev/null +++ b/test/expected/build/application.a/dest-deps/resources/library/a/themes/base/library.css @@ -0,0 +1,3 @@ +.library-a-foo{color:#fafad2;padding:1px 2px 3px 4px} +/* Inline theming parameters */ +#sap-ui-theme-library\.a{background-image:url('data:text/plain;utf-8,%7B%22libraryAColor1%22%3A%22%23fafad2%22%7D')} diff --git a/test/expected/build/application.a/dest-deps/resources/library/a/themes/base/library.source.less b/test/expected/build/application.a/dest-deps/resources/library/a/themes/base/library.source.less new file mode 100644 index 000000000..ff0f1d5e3 --- /dev/null +++ b/test/expected/build/application.a/dest-deps/resources/library/a/themes/base/library.source.less @@ -0,0 +1,6 @@ +@libraryAColor1: lightgoldenrodyellow; + +.library-a-foo { + color: @libraryAColor1; + padding: 1px 2px 3px 4px; +} diff --git a/test/expected/build/application.a/dest-deps/resources/library/b/.library b/test/expected/build/application.a/dest-deps/resources/library/b/.library new file mode 100644 index 000000000..8cfb124a9 --- /dev/null +++ b/test/expected/build/application.a/dest-deps/resources/library/b/.library @@ -0,0 +1,17 @@ + + + + library.b + SAP SE + Some fancy copyright ${currentYear} + 1.0.0 + + Library B + + + + library.d + + + + diff --git a/test/expected/build/application.a/dest-deps/resources/library/c/.library b/test/expected/build/application.a/dest-deps/resources/library/c/.library new file mode 100644 index 000000000..3c011ecd6 --- /dev/null +++ b/test/expected/build/application.a/dest-deps/resources/library/c/.library @@ -0,0 +1,17 @@ + + + + library.c + SAP SE + ${copyright} + 1.0.0 + + Library C + + + + library.d + + + + diff --git a/test/expected/build/application.a/dest-deps/resources/library/d/.library b/test/expected/build/application.a/dest-deps/resources/library/d/.library new file mode 100644 index 000000000..d6a612a92 --- /dev/null +++ b/test/expected/build/application.a/dest-deps/resources/library/d/.library @@ -0,0 +1,11 @@ + + + + library.d + SAP SE + Some fancy copyright + 1.0.0 + + Library D + + diff --git a/test/expected/build/application.a/dest-deps/resources/library/d/some-dbg.js b/test/expected/build/application.a/dest-deps/resources/library/d/some-dbg.js new file mode 100644 index 000000000..1e8c6a2f9 --- /dev/null +++ b/test/expected/build/application.a/dest-deps/resources/library/d/some-dbg.js @@ -0,0 +1,7 @@ +/*! + * Some fancy copyright + */ +(function() { + var someNonUglifiedVariable = "World"; + console.log('Hello ' + someNonUglifiedVariable); +})(); diff --git a/test/expected/build/application.a/dest-deps/resources/library/d/some.js b/test/expected/build/application.a/dest-deps/resources/library/d/some.js new file mode 100644 index 000000000..c23f5f207 --- /dev/null +++ b/test/expected/build/application.a/dest-deps/resources/library/d/some.js @@ -0,0 +1,4 @@ +/*! + * Some fancy copyright + */ +(function(){var o="World";console.log("Hello "+o)})(); \ No newline at end of file diff --git a/test/expected/build/application.a/dest-deps/resources/ui5loader-dbg.js b/test/expected/build/application.a/dest-deps/resources/ui5loader-dbg.js new file mode 100644 index 000000000..0e76321fd --- /dev/null +++ b/test/expected/build/application.a/dest-deps/resources/ui5loader-dbg.js @@ -0,0 +1 @@ +// this is just a marker file to enable the EVO bundle format diff --git a/test/expected/build/application.a/dest-deps/resources/ui5loader.js b/test/expected/build/application.a/dest-deps/resources/ui5loader.js new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/application.a/dest-deps/test-dbg.js b/test/expected/build/application.a/dest-deps/test-dbg.js new file mode 100644 index 000000000..cb4595405 --- /dev/null +++ b/test/expected/build/application.a/dest-deps/test-dbg.js @@ -0,0 +1,9 @@ +sap.ui.define([ + "library/d/some" +], function(someObject) { + function test(paramA) { + var variableA = paramA; + console.log(variableA); + } + test(); +}); diff --git a/test/expected/build/application.a/dest-deps/test-resources/LibraryC/Test.html b/test/expected/build/application.a/dest-deps/test-resources/LibraryC/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/application.a/dest-deps/test-resources/library/a/Test.html b/test/expected/build/application.a/dest-deps/test-resources/library/a/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/application.a/dest-deps/test-resources/library/b/Test.html b/test/expected/build/application.a/dest-deps/test-resources/library/b/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/application.a/dest-deps/test-resources/library/d/Test.html b/test/expected/build/application.a/dest-deps/test-resources/library/d/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/application.a/dest-deps/test.js b/test/expected/build/application.a/dest-deps/test.js new file mode 100644 index 000000000..fd8278c6e --- /dev/null +++ b/test/expected/build/application.a/dest-deps/test.js @@ -0,0 +1 @@ +sap.ui.define(["library/d/some"],function(n){function o(n){var o=n;console.log(o)}o()}); \ No newline at end of file diff --git a/test/expected/build/application.a/dest-depself/index.html b/test/expected/build/application.a/dest-depself/index.html new file mode 100644 index 000000000..b0c4c25b7 --- /dev/null +++ b/test/expected/build/application.a/dest-depself/index.html @@ -0,0 +1,11 @@ + + + + Application A + + + + + + \ No newline at end of file diff --git a/test/expected/build/application.a/dest-depself/resources/library/a/.library b/test/expected/build/application.a/dest-depself/resources/library/a/.library new file mode 100644 index 000000000..cddfadd9a --- /dev/null +++ b/test/expected/build/application.a/dest-depself/resources/library/a/.library @@ -0,0 +1,17 @@ + + + + library.a + SAP SE + Some fancy copyright ${currentYear} + 1.0.0 + + Library A + + + + library.d + + + + diff --git a/test/expected/build/application.a/dest-depself/resources/library/a/themes/base/library-RTL.css b/test/expected/build/application.a/dest-depself/resources/library/a/themes/base/library-RTL.css new file mode 100644 index 000000000..5398b3f08 --- /dev/null +++ b/test/expected/build/application.a/dest-depself/resources/library/a/themes/base/library-RTL.css @@ -0,0 +1,3 @@ +.library-a-foo{color:#fafad2;padding:1px 4px 3px 2px} +/* Inline theming parameters */ +#sap-ui-theme-library\.a{background-image:url('data:text/plain;utf-8,%7B%22libraryAColor1%22%3A%22%23fafad2%22%7D')} diff --git a/test/expected/build/application.a/dest-depself/resources/library/a/themes/base/library-parameters.json b/test/expected/build/application.a/dest-depself/resources/library/a/themes/base/library-parameters.json new file mode 100644 index 000000000..da3b7a52f --- /dev/null +++ b/test/expected/build/application.a/dest-depself/resources/library/a/themes/base/library-parameters.json @@ -0,0 +1 @@ +{"libraryAColor1":"#fafad2"} \ No newline at end of file diff --git a/test/expected/build/application.a/dest-depself/resources/library/a/themes/base/library.css b/test/expected/build/application.a/dest-depself/resources/library/a/themes/base/library.css new file mode 100644 index 000000000..ba056b3c0 --- /dev/null +++ b/test/expected/build/application.a/dest-depself/resources/library/a/themes/base/library.css @@ -0,0 +1,3 @@ +.library-a-foo{color:#fafad2;padding:1px 2px 3px 4px} +/* Inline theming parameters */ +#sap-ui-theme-library\.a{background-image:url('data:text/plain;utf-8,%7B%22libraryAColor1%22%3A%22%23fafad2%22%7D')} diff --git a/test/expected/build/application.a/dest-depself/resources/library/a/themes/base/library.source.less b/test/expected/build/application.a/dest-depself/resources/library/a/themes/base/library.source.less new file mode 100644 index 000000000..ff0f1d5e3 --- /dev/null +++ b/test/expected/build/application.a/dest-depself/resources/library/a/themes/base/library.source.less @@ -0,0 +1,6 @@ +@libraryAColor1: lightgoldenrodyellow; + +.library-a-foo { + color: @libraryAColor1; + padding: 1px 2px 3px 4px; +} diff --git a/test/expected/build/application.a/dest-depself/resources/library/b/.library b/test/expected/build/application.a/dest-depself/resources/library/b/.library new file mode 100644 index 000000000..8cfb124a9 --- /dev/null +++ b/test/expected/build/application.a/dest-depself/resources/library/b/.library @@ -0,0 +1,17 @@ + + + + library.b + SAP SE + Some fancy copyright ${currentYear} + 1.0.0 + + Library B + + + + library.d + + + + diff --git a/test/expected/build/application.a/dest-depself/resources/library/c/.library b/test/expected/build/application.a/dest-depself/resources/library/c/.library new file mode 100644 index 000000000..3c011ecd6 --- /dev/null +++ b/test/expected/build/application.a/dest-depself/resources/library/c/.library @@ -0,0 +1,17 @@ + + + + library.c + SAP SE + ${copyright} + 1.0.0 + + Library C + + + + library.d + + + + diff --git a/test/expected/build/application.a/dest-depself/resources/library/d/.library b/test/expected/build/application.a/dest-depself/resources/library/d/.library new file mode 100644 index 000000000..d6a612a92 --- /dev/null +++ b/test/expected/build/application.a/dest-depself/resources/library/d/.library @@ -0,0 +1,11 @@ + + + + library.d + SAP SE + Some fancy copyright + 1.0.0 + + Library D + + diff --git a/test/expected/build/application.a/dest-depself/resources/library/d/some-dbg.js b/test/expected/build/application.a/dest-depself/resources/library/d/some-dbg.js new file mode 100644 index 000000000..1e8c6a2f9 --- /dev/null +++ b/test/expected/build/application.a/dest-depself/resources/library/d/some-dbg.js @@ -0,0 +1,7 @@ +/*! + * Some fancy copyright + */ +(function() { + var someNonUglifiedVariable = "World"; + console.log('Hello ' + someNonUglifiedVariable); +})(); diff --git a/test/expected/build/application.a/dest-depself/resources/library/d/some.js b/test/expected/build/application.a/dest-depself/resources/library/d/some.js new file mode 100644 index 000000000..c23f5f207 --- /dev/null +++ b/test/expected/build/application.a/dest-depself/resources/library/d/some.js @@ -0,0 +1,4 @@ +/*! + * Some fancy copyright + */ +(function(){var o="World";console.log("Hello "+o)})(); \ No newline at end of file diff --git a/test/expected/build/application.a/dest-depself/resources/sap-ui-custom-dbg.js b/test/expected/build/application.a/dest-depself/resources/sap-ui-custom-dbg.js new file mode 100644 index 000000000..456319972 --- /dev/null +++ b/test/expected/build/application.a/dest-depself/resources/sap-ui-custom-dbg.js @@ -0,0 +1 @@ +//@ui5-bundle sap-ui-custom-dbg.js diff --git a/test/expected/build/application.a/dest-depself/resources/sap-ui-custom.js b/test/expected/build/application.a/dest-depself/resources/sap-ui-custom.js new file mode 100644 index 000000000..c1aee5600 --- /dev/null +++ b/test/expected/build/application.a/dest-depself/resources/sap-ui-custom.js @@ -0,0 +1,10 @@ +//@ui5-bundle sap-ui-custom.js +sap.ui.require.preload({ + "application/a/test.js":function(){sap.ui.define(["library/d/some"],function(n){function o(n){var o=n;console.log(o)}o()}); +}, + "library/d/some.js":function(){/*! + * Some fancy copyright + */ +(function(){var o="World";console.log("Hello "+o)})(); +} +}); diff --git a/test/expected/build/application.a/dest-depself/resources/ui5loader-dbg.js b/test/expected/build/application.a/dest-depself/resources/ui5loader-dbg.js new file mode 100644 index 000000000..0e76321fd --- /dev/null +++ b/test/expected/build/application.a/dest-depself/resources/ui5loader-dbg.js @@ -0,0 +1 @@ +// this is just a marker file to enable the EVO bundle format diff --git a/test/expected/build/application.a/dest-depself/resources/ui5loader.js b/test/expected/build/application.a/dest-depself/resources/ui5loader.js new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/application.a/dest-depself/test-dbg.js b/test/expected/build/application.a/dest-depself/test-dbg.js new file mode 100644 index 000000000..cb4595405 --- /dev/null +++ b/test/expected/build/application.a/dest-depself/test-dbg.js @@ -0,0 +1,9 @@ +sap.ui.define([ + "library/d/some" +], function(someObject) { + function test(paramA) { + var variableA = paramA; + console.log(variableA); + } + test(); +}); diff --git a/test/expected/build/application.a/dest-depself/test-resources/LibraryC/Test.html b/test/expected/build/application.a/dest-depself/test-resources/LibraryC/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/application.a/dest-depself/test-resources/library/a/Test.html b/test/expected/build/application.a/dest-depself/test-resources/library/a/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/application.a/dest-depself/test-resources/library/b/Test.html b/test/expected/build/application.a/dest-depself/test-resources/library/b/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/application.a/dest-depself/test-resources/library/d/Test.html b/test/expected/build/application.a/dest-depself/test-resources/library/d/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/application.a/dest-depself/test.js b/test/expected/build/application.a/dest-depself/test.js new file mode 100644 index 000000000..fd8278c6e --- /dev/null +++ b/test/expected/build/application.a/dest-depself/test.js @@ -0,0 +1 @@ +sap.ui.define(["library/d/some"],function(n){function o(n){var o=n;console.log(o)}o()}); \ No newline at end of file diff --git a/test/expected/build/application.a/dest-dev/index.html b/test/expected/build/application.a/dest-dev/index.html index 77b0207cc..1523b1dc3 100644 --- a/test/expected/build/application.a/dest-dev/index.html +++ b/test/expected/build/application.a/dest-dev/index.html @@ -2,6 +2,8 @@ Application A + diff --git a/test/expected/build/application.a/dest-dev/test.js b/test/expected/build/application.a/dest-dev/test.js index a3df410c3..cb4595405 100644 --- a/test/expected/build/application.a/dest-dev/test.js +++ b/test/expected/build/application.a/dest-dev/test.js @@ -1,5 +1,9 @@ -function test(paramA) { - var variableA = paramA; - console.log(variableA); -} -test(); +sap.ui.define([ + "library/d/some" +], function(someObject) { + function test(paramA) { + var variableA = paramA; + console.log(variableA); + } + test(); +}); diff --git a/test/expected/build/application.a/dest-self/index.html b/test/expected/build/application.a/dest-self/index.html new file mode 100644 index 000000000..b0c4c25b7 --- /dev/null +++ b/test/expected/build/application.a/dest-self/index.html @@ -0,0 +1,11 @@ + + + + Application A + + + + + + \ No newline at end of file diff --git a/test/expected/build/application.a/dest-self/resources/sap-ui-custom-dbg.js b/test/expected/build/application.a/dest-self/resources/sap-ui-custom-dbg.js new file mode 100644 index 000000000..456319972 --- /dev/null +++ b/test/expected/build/application.a/dest-self/resources/sap-ui-custom-dbg.js @@ -0,0 +1 @@ +//@ui5-bundle sap-ui-custom-dbg.js diff --git a/test/expected/build/application.a/dest-self/resources/sap-ui-custom.js b/test/expected/build/application.a/dest-self/resources/sap-ui-custom.js new file mode 100644 index 000000000..7728d6932 --- /dev/null +++ b/test/expected/build/application.a/dest-self/resources/sap-ui-custom.js @@ -0,0 +1,10 @@ +//@ui5-bundle sap-ui-custom.js +sap.ui.require.preload({ + "application/a/test.js":function(){sap.ui.define(["library/d/some"],function(n){function o(n){var o=n;console.log(o)}o()}); +}, + "library/d/some.js":function(){/*! + * ${copyright} + */ +(function(){var o="World";console.log("Hello "+o)})(); +} +}); diff --git a/test/expected/build/application.a/dest-self/test-dbg.js b/test/expected/build/application.a/dest-self/test-dbg.js new file mode 100644 index 000000000..cb4595405 --- /dev/null +++ b/test/expected/build/application.a/dest-self/test-dbg.js @@ -0,0 +1,9 @@ +sap.ui.define([ + "library/d/some" +], function(someObject) { + function test(paramA) { + var variableA = paramA; + console.log(variableA); + } + test(); +}); diff --git a/test/expected/build/application.a/dest-self/test.js b/test/expected/build/application.a/dest-self/test.js new file mode 100644 index 000000000..fd8278c6e --- /dev/null +++ b/test/expected/build/application.a/dest-self/test.js @@ -0,0 +1 @@ +sap.ui.define(["library/d/some"],function(n){function o(n){var o=n;console.log(o)}o()}); \ No newline at end of file diff --git a/test/expected/build/application.a/dest/index.html b/test/expected/build/application.a/dest/index.html index 77b0207cc..1523b1dc3 100644 --- a/test/expected/build/application.a/dest/index.html +++ b/test/expected/build/application.a/dest/index.html @@ -2,6 +2,8 @@ Application A + diff --git a/test/expected/build/application.a/dest/test-dbg.js b/test/expected/build/application.a/dest/test-dbg.js index a3df410c3..cb4595405 100644 --- a/test/expected/build/application.a/dest/test-dbg.js +++ b/test/expected/build/application.a/dest/test-dbg.js @@ -1,5 +1,9 @@ -function test(paramA) { - var variableA = paramA; - console.log(variableA); -} -test(); +sap.ui.define([ + "library/d/some" +], function(someObject) { + function test(paramA) { + var variableA = paramA; + console.log(variableA); + } + test(); +}); diff --git a/test/expected/build/application.a/dest/test.js b/test/expected/build/application.a/dest/test.js index 387af3930..fd8278c6e 100644 --- a/test/expected/build/application.a/dest/test.js +++ b/test/expected/build/application.a/dest/test.js @@ -1 +1 @@ -function test(t){var o=t;console.log(o)}test(); \ No newline at end of file +sap.ui.define(["library/d/some"],function(n){function o(n){var o=n;console.log(o)}o()}); \ No newline at end of file diff --git a/test/expected/build/library.d/dest/resources/library/d/some-dbg.js b/test/expected/build/library.d/dest/resources/library/d/some-dbg.js index cb7722a38..1e8c6a2f9 100644 --- a/test/expected/build/library.d/dest/resources/library/d/some-dbg.js +++ b/test/expected/build/library.d/dest/resources/library/d/some-dbg.js @@ -1,4 +1,7 @@ /*! * Some fancy copyright */ -console.log('HelloWorld'); \ No newline at end of file +(function() { + var someNonUglifiedVariable = "World"; + console.log('Hello ' + someNonUglifiedVariable); +})(); diff --git a/test/expected/build/library.d/dest/resources/library/d/some.js b/test/expected/build/library.d/dest/resources/library/d/some.js index a5504d866..c23f5f207 100644 --- a/test/expected/build/library.d/dest/resources/library/d/some.js +++ b/test/expected/build/library.d/dest/resources/library/d/some.js @@ -1,4 +1,4 @@ /*! * Some fancy copyright */ -console.log("HelloWorld"); \ No newline at end of file +(function(){var o="World";console.log("Hello "+o)})(); \ No newline at end of file diff --git a/test/expected/build/library.d/preload/resources/library/d/library-preload.js b/test/expected/build/library.d/preload/resources/library/d/library-preload.js index 807feb583..3a8e66b86 100644 --- a/test/expected/build/library.d/preload/resources/library/d/library-preload.js +++ b/test/expected/build/library.d/preload/resources/library/d/library-preload.js @@ -5,6 +5,6 @@ jQuery.sap.registerPreloadedModules({ "library/d/some.js":function(){/*! * ${copyright} */ -console.log("HelloWorld"); +(function(){var o="World";console.log("Hello "+o)})(); } }}); diff --git a/test/expected/build/library.d/preload/resources/library/d/some.js b/test/expected/build/library.d/preload/resources/library/d/some.js index 81e734360..fa1d786f7 100644 --- a/test/expected/build/library.d/preload/resources/library/d/some.js +++ b/test/expected/build/library.d/preload/resources/library/d/some.js @@ -1,4 +1,7 @@ /*! * ${copyright} */ -console.log('HelloWorld'); \ No newline at end of file +(function() { + var someNonUglifiedVariable = "World"; + console.log('Hello ' + someNonUglifiedVariable); +})(); diff --git a/test/fixtures/application.a/webapp/index.html b/test/fixtures/application.a/webapp/index.html index 77b0207cc..1523b1dc3 100644 --- a/test/fixtures/application.a/webapp/index.html +++ b/test/fixtures/application.a/webapp/index.html @@ -2,6 +2,8 @@ Application A + diff --git a/test/fixtures/application.a/webapp/test.js b/test/fixtures/application.a/webapp/test.js index a3df410c3..cb4595405 100644 --- a/test/fixtures/application.a/webapp/test.js +++ b/test/fixtures/application.a/webapp/test.js @@ -1,5 +1,9 @@ -function test(paramA) { - var variableA = paramA; - console.log(variableA); -} -test(); +sap.ui.define([ + "library/d/some" +], function(someObject) { + function test(paramA) { + var variableA = paramA; + console.log(variableA); + } + test(); +}); diff --git a/test/fixtures/library.d/main/src/library/d/some.js b/test/fixtures/library.d/main/src/library/d/some.js index 81e734360..fa1d786f7 100644 --- a/test/fixtures/library.d/main/src/library/d/some.js +++ b/test/fixtures/library.d/main/src/library/d/some.js @@ -1,4 +1,7 @@ /*! * ${copyright} */ -console.log('HelloWorld'); \ No newline at end of file +(function() { + var someNonUglifiedVariable = "World"; + console.log('Hello ' + someNonUglifiedVariable); +})(); diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index fb64572b2..8b1bcf5d4 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 collectionPath = path.join(__dirname, "..", "..", "fixtures", "collection"); const libraryDPath = path.join(__dirname, "..", "..", "fixtures", "library.d"); const libraryEPath = path.join(__dirname, "..", "..", "fixtures", "library.e"); const libraryHPath = path.join(__dirname, "..", "..", "fixtures", "library.h"); @@ -98,7 +99,6 @@ test("Build application.a", (t) => { }); }); - test("Build application.a with error", async (t) => { const destPath = "./test/tmp/build/application.a/dest"; @@ -109,6 +109,112 @@ test("Build application.a with error", async (t) => { t.deepEqual(error.message, `Unknown type 'non existent'`); }); +test("Build application.a with dependencies", (t) => { + const destPath = "./test/tmp/build/application.a/dest-deps"; + const expectedPath = path.join("test", "expected", "build", "application.a", "dest-deps"); + + return builder.build({ + tree: applicationATree, + destPath, + excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest"], + buildDependencies: true + }).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 application.a with dependencies include", (t) => { + const destPath = "./test/tmp/build/application.a/dest-deps-incl"; + const expectedPath = path.join("test", "expected", "build", "application.a", "dest-deps"); + + return builder.build({ + tree: applicationATree, + destPath, + excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest"], + buildDependencies: true, includedDependencies: ["*"] + }).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 application.a with dependencies exclude", (t) => { + const destPath = "./test/tmp/build/application.a/dest-deps-excl"; + const expectedPath = path.join("test", "expected", "build", "application.a", "dest-deps-excl"); + + return builder.build({ + tree: applicationATree, + destPath, + excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest"], + buildDependencies: true, excludedDependencies: ["library.d"] + }).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 application.a self-contained", (t) => { + const destPath = "./test/tmp/build/application.a/dest-self"; + const expectedPath = path.join("test", "expected", "build", "application.a", "dest-self"); + + return builder.build({ + tree: applicationATree, + destPath, + excludedTasks: ["generateComponentPreload", "generateVersionInfo"], + selfContained: true + }).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 application.a with dependencies self-contained", (t) => { + const destPath = "./test/tmp/build/application.a/dest-depself"; + const expectedPath = path.join("test", "expected", "build", "application.a", "dest-depself"); + + return builder.build({ + tree: applicationATree, + destPath, + excludedTasks: ["generateComponentPreload", "generateVersionInfo", "escapeNonAsciiCharacters", "generateLibraryManifest"], + buildDependencies: true, + selfContained: true + }).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 application.a [dev mode]", (t) => { const destPath = "./test/tmp/build/application.a/dest-dev"; const expectedPath = path.join("test", "expected", "build", "application.a", "dest-dev"); @@ -462,41 +568,70 @@ test.serial("Cleanup", async (t) => { t.deepEqual(executeCleanupTasksStub.callCount, 2, "Cleanup called twice"); }); -const applicationATree = { - "id": "application.a", + +const libraryDTree = { + "id": "library.d", "version": "1.0.0", - "path": applicationAPath, + "path": libraryDPath, "dependencies": [ { - "id": "library.d", + "id": "sap.ui.core-evo", "version": "1.0.0", - "path": path.join(applicationAPath, "node_modules", "library.d"), + "path": libraryCore, "dependencies": [], "_level": 1, "specVersion": "0.1", "type": "library", "metadata": { - "name": "library.d", - "namespace": "library/d", + "name": "sap.ui.core", + "namespace": "sap/ui/core", "copyright": "Some fancy copyright" }, "resources": { "configuration": { "paths": { - "src": "main/src", - "test": "main/test" + "src": "main/src" } }, "pathMappings": { - "/resources/": "main/src", - "/test-resources/": "main/test" + "/resources/": "main/src" } } + } + ], + "_level": 0, + "specVersion": "0.1", + "type": "library", + "metadata": { + "name": "library.d", + "namespace": "library/d", + "copyright": "Some fancy copyright" + }, + "resources": { + "configuration": { + "paths": { + "src": "main/src", + "test": "main/test" + }, + "propertiesFileSourceEncoding": "ISO-8859-1" }, + "pathMappings": { + "/resources/": "main/src", + "/test-resources/": "main/test" + } + } +}; + +const applicationATree = { + "id": "application.a", + "version": "1.0.0", + "path": applicationAPath, + "dependencies": [ + libraryDTree, { "id": "library.a", "version": "1.0.0", - "path": path.join(applicationAPath, "node_modules", "collection", "library.a"), + "path": path.join(collectionPath, "library.a"), "dependencies": [], "_level": 1, "specVersion": "0.1", @@ -522,7 +657,7 @@ const applicationATree = { { "id": "library.b", "version": "1.0.0", - "path": path.join(applicationAPath, "node_modules", "collection", "library.b"), + "path": path.join(collectionPath, "library.b"), "dependencies": [], "_level": 1, "specVersion": "0.1", @@ -548,7 +683,7 @@ const applicationATree = { { "id": "library.c", "version": "1.0.0", - "path": path.join(applicationAPath, "node_modules", "collection", "library.c"), + "path": path.join(collectionPath, "library.c"), "dependencies": [], "_level": 1, "specVersion": "0.1", @@ -576,7 +711,8 @@ const applicationATree = { "specVersion": "0.1", "type": "application", "metadata": { - "name": "application.a" + "name": "application.a", + "namespace": "application/a" }, "resources": { "configuration": { @@ -835,59 +971,6 @@ const applicationJTree = { } }; -const libraryDTree = { - "id": "library.d", - "version": "1.0.0", - "path": libraryDPath, - "dependencies": [ - { - "id": "sap.ui.core-evo", - "version": "1.0.0", - "path": libraryCore, - "dependencies": [], - "_level": 1, - "specVersion": "0.1", - "type": "library", - "metadata": { - "name": "sap.ui.core", - "namespace": "sap/ui/core", - "copyright": "Some fancy copyright" - }, - "resources": { - "configuration": { - "paths": { - "src": "main/src" - } - }, - "pathMappings": { - "/resources/": "main/src" - } - } - } - ], - "_level": 0, - "specVersion": "0.1", - "type": "library", - "metadata": { - "name": "library.d", - "namespace": "library/d", - "copyright": "Some fancy copyright" - }, - "resources": { - "configuration": { - "paths": { - "src": "main/src", - "test": "main/test" - }, - "propertiesFileSourceEncoding": "ISO-8859-1" - }, - "pathMappings": { - "/resources/": "main/src", - "/test-resources/": "main/test" - } - } -}; - const libraryETree = { "id": "library.e", "version": "1.0.0",