From cdd459fde6446cf12cc289fb8f197eda7cce0f77 Mon Sep 17 00:00:00 2001 From: Frank Weigel Date: Sun, 29 Dec 2019 12:40:47 +0100 Subject: [PATCH 01/88] [FEATURE] Generate resources.json files for libs, components, themes --- lib/processors/resourceListCreator.js | 643 ++++++++++++++++++ lib/tasks/generateResourcesJson.js | 42 ++ lib/tasks/taskRepository.js | 1 + lib/types/library/LibraryBuilder.js | 19 +- .../dest/resources/library/d/resources.json | 12 + .../dest/resources/library/e/resources.json | 19 + .../library/h/components/resources.json | 37 + .../h/components/subcomponent1/resources.json | 12 + .../h/components/subcomponent2/resources.json | 12 + .../h/components/subcomponent3/resources.json | 12 + .../dest/resources/library/h/resources.json | 56 ++ .../dest/resources/library/i/resources.json | 15 + .../j/themes/somefancytheme/resources.json | 15 + test/lib/builder/builder.js | 8 +- 14 files changed, 898 insertions(+), 5 deletions(-) create mode 100644 lib/processors/resourceListCreator.js create mode 100644 lib/tasks/generateResourcesJson.js create mode 100644 test/expected/build/library.d/dest/resources/library/d/resources.json create mode 100644 test/expected/build/library.e/dest/resources/library/e/resources.json create mode 100644 test/expected/build/library.h/dest/resources/library/h/components/resources.json create mode 100644 test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json create mode 100644 test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json create mode 100644 test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json create mode 100644 test/expected/build/library.h/dest/resources/library/h/resources.json create mode 100644 test/expected/build/library.i/dest/resources/library/i/resources.json create mode 100644 test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js new file mode 100644 index 000000000..50dd53fbd --- /dev/null +++ b/lib/processors/resourceListCreator.js @@ -0,0 +1,643 @@ +"use strict"; + +const log = require("@ui5/logger").getLogger("builder:processors:resourceListCreator"); +const ResourceFilterList = require("../lbt/resources/ResourceFilterList"); +const Resource = require("../lbt/resources/Resource"); +const ResourcePool = require("../lbt/resources/ResourcePool"); +const EvoResource = require("@ui5/fs").Resource; + +const DEBUG_RESOURCES_PATTERN = /-dbg((?:\.view|\.fragment|\.controller|\.designtime|\.support)?\.js|\.css)$/; + +// TODO share with module bundler + +function extractName(path) { + return path.slice( "/resources/".length); +} + +class LocatorResource extends Resource { + constructor(pool, resource) { + super(pool, extractName(resource.getPath()), null, resource.getStatInfo()); + this.resource = resource; + } + + buffer() { + return this.resource.getBuffer(); + } + + getProject() { + return this.resource._project; + } +} + +class LocatorResourcePool extends ResourcePool { + constructor() { + super(); + } + + prepare(resources) { + resources = resources.filter( (res) => !res.getStatInfo().isDirectory() ); + // console.log(resources.map($ => $.getPath())); + return Promise.all( + resources.map( + (resource) => this.addResource( new LocatorResource(this, resource) ) + ).filter( (followUp) => followUp ) + ); + // .then( () => { + // console.log(" found %d resources", this.size); + // }); + } +} + +/** + * Information about a single resource as stored in the resources.json file. + * + * @author Frank Weigel + * @since 1.33.0 + */ +class ResourceInfo { + constructor(name) { + this.name = name; + this.i18nName = null; + this.i18nLocale = null; + this.isDebug = false; + this.theme = null; + this.merged = false; + this.designtime = false; + this.support = false; + this.module = null; + this.required = []; + this.condRequired = []; + this.included = []; + this.dynRequired = false; + } + + copyFrom(prefix, orig) { + this.i18nName = orig.i18nName == null ? null : ResourcesList.makePathRelativeTo(prefix, orig.i18nName); + this.i18nLocale = orig.i18nLocale; + this.isDebug = orig.isDebug; + this.theme = orig.theme; + this.merged = orig.merged; + this.designtime = orig.designtime; + this.support = orig.support; + if ( this.module == null ) { + this.module = orig.module; + } + if ( orig.required != null ) { + if ( this.required == null ) { + this.required = []; + } + this.required = this.required.concat(orig.required); // remove duplicates? + } + if ( orig.condRequired != null ) { + if ( this.condRequired == null ) { + this.condRequired = []; + } + this.condRequired = this.condRequired.concat(orig.condRequired); // remove duplicates? + } + this.dynRequired = orig.dynRequired; + if ( orig.included != null ) { + if ( this.included == null ) { + this.included = []; + } + this.included = this.included.concat(orig.included); // remove duplicates? + } + if ( this.included != null && this.included.length > 0 ) { + this.merged = true; + } + } + + toJSON() { + const result = { + name: this.name + }; + if ( this.module != null ) { + result.module = this.module; + } + if ( this.isDebug ) { + result.isDebug = this.isDebug; + } + if ( this.merged ) { + result.merged = this.merged; + } + if ( this.designtime ) { + result.designtime = this.designtime; + } + if ( this.support ) { + result.support = this.support; + } + if ( this.i18nLocale != null ) { + result.locale = this.i18nLocale; + result.raw = this.i18nName; + } + if ( this.theme != null ) { + result.theme = this.theme; + } + if ( this.required != null && this.required.length > 0 ) { + result.required = this.required.sort(); + } + if ( this.condRequired != null && this.condRequired.length > 0 ) { + result.condRequired = this.condRequired.sort(); + } + if ( this.dynRequired ) { + result.dynRequired = this.dynRequired; + } + if ( this.included != null && this.included.length > 0 ) { + result.included = this.included; + } + return result; + } + + isEmpty() { + return this.i18nLocale == null && this.i18nName == null && this.isDebug == false && this.theme == null && this.merged == false; + } +} + +/** + * A list of ResourceInfo objects, suitable for (but not dependent on) JSON serialization. + * + * @author Frank Weigel + * @since 1.33.0 + */ +class ResourcesList { + constructor(prefix) { + /** + * List of resources information objects + */ + this.resources = []; + + // --- transient state --- + this.name = prefix; + this.resourcesByName = new Map(); + } + + add(info) { + const relativeName = ResourcesList.makePathRelativeTo(this.name, info.name); + + // search for a resource with the same name + let myInfo = this.resourcesByName.get(relativeName); + + if ( myInfo == null ) { + // when not found, check if the given resource is a debug resource and share the information with the non-dbg version + const nondbg = ResourcesList.getNonDebugName(relativeName); + if ( nondbg != null && this.resourcesByName.has(nondbg) ) { + myInfo = new ResourceInfo(relativeName); + myInfo.copyFrom(this.name, this.resourcesByName.get(nondbg)); + this.resources.push(myInfo); + this.resourcesByName.set(relativeName, myInfo); + } + } + if ( myInfo == null ) { + myInfo = new ResourceInfo(relativeName); + this.resources.push(myInfo); + this.resourcesByName.set(relativeName, myInfo); + } + myInfo.copyFrom(this.name, info); + } + + toJSON() { + this.resources.sort((a, b) => { + if ( a.name === b.name ) { + return 0; + } + return a.name < b.name ? -1 : 1; + }); + return { + /** + * Version of the resources.json file format, must be 1.1.0 or higher to store dependencies + */ + _version: "1.1.0", + resources: this.resources + }; + } + + static makePathRelativeTo(prefix, name) { + let back = ""; + while ( !name.startsWith(prefix) ) { + const p = prefix.lastIndexOf("/", prefix.length - 2); + back = back + "../"; + if ( p >= 0 ) { + prefix = prefix.slice(0, p + 1); + } else { + prefix = ""; + break; + } + } + return back + name.slice(prefix.length); + } + + /** + * If the given module is a -dbg file, calculate and return the non-dbg name. + * + * @param {string} path + * @returns {string|null} Non-debug name of the module + */ + static getNonDebugName(path) { + if ( DEBUG_RESOURCES_PATTERN.test(path) ) { + return path.replace( DEBUG_RESOURCES_PATTERN, "$1"); + } + return null; + } +} + +/** + * Collects all resources in a set of resource folders or from an archive + * and writes a 'resources.json' file for each component or library + * that can be found in the resources. + * + * @since 1.29.0 + */ + +/* NODE-TODO + /** + * Global filters that should be taken into account when collecting resources. + * + * Each filter entry can be a comma separated list of simple filters. Each simple filter + * can be a pattern in resource name pattern syntax: A double asterisk '&0x2a;&0x2a;/' denotes an arbitrary + * number of resource name segments (folders) incl. a trailing slash, whereas a simple asterisk '*' + * denotes an arbitrary number of resource name characters, but not the segment separator '/'. + * A dot is interpreted as a dot, all other special regular expression characters keep their + * special meaning. This is a mixture of ANT-style path patterns and regular expressions. + * + * Excludes can be denoted by a leading '-' or '!', includes optionally by a leading '+'. + * Order of filters is significant, a later exclusion overrides an earlier inclusion + * and vice versa. + * + * Example: + *
+	 *	 !sap/ui/core/
+	 *	 +sap/ui/core/utils/
+	 * 
+ * excludes everything from sap/ui/core, but includes everything from the subpackage sap/ui/core/utils/. + * + * Note that the filter operates on the full name of each resource. If a resource name + * prefix is configured for a resource set, the filter will be applied + * to the combination of prefix and local file path and not only to the local file path. + * / + @Parameter + private String[] filters; + + /** + * Whether the default filters should be ignored when filters are given. + * / + @Parameter(defaultValue="true") + private boolean ignoreDefaultFilters = true; + + /** + * Comma separated list of components to which orphaned resources should be added. + * + * If a component contains a colon, everything behind the colon is interpreted as a semicolon + * separated list of resource patterns of orphans that should be added to the preceeding component. + * If no such list is given, any orphaned resource will be added to the component. + * The evaluation logic for the filter list is the same as for the filters + * parameters: excludes can be denoted with a leading '-' or '!' and order is significant. + * Later filters can override the result of earlier ones. + * + * If no component is given, orphans will only be reported but not added to any component (default). + * + * @since 1.29.1 + * / + @Parameter + private String externalResources; +*/ + +/** + * List of resource patterns that describe all debug resources. + * + * @since 1.29.1 + */ +const DEFAULT_DEBUG_RESOURCES_FILTER = [ + "**/*-dbg.js", + "**/*-dbg.controller.js", + "**/*-dbg.designtime.js", + "**/*-dbg.support.js", + "**/*-dbg.view.js", + "**/*-dbg.fragment.js", + "**/*-dbg.css", + "**/*.js.map" +]; + +/** + * List of resource patterns that describe bundled resources. + * + * @since 1.29.1 + */ +const DEFAULT_BUNDLE_RESOURCES_FILTER = [ + "**/Component-preload.js", + "**/library-preload.js", + "**/library-preload-dbg.js", + "**/library-preload.json", + "**/library-h2-preload.js", + "**/designtime/library-preload.designtime.js", + "**/library-preload.support.js", + "**/library-all.js", + "**/library-all-dbg.js" +]; + +/** + * List of resource patterns that describe all designtime resources. + * + * @since 1.31.0 + */ +const DEFAULT_DESIGNTIME_RESOURCES_FILTER = [ + "**/designtime/*", + "**/*.designtime.js", + "**/*.control", + "**/*.interface", + "**/*.type", + "**/themes/*/*.less", + "**/library.templates.xml", + "**/library.dependencies.xml", + "**/library.dependencies.json" +]; + +/** + * List of resource patterns that describe all support (assistant) resources. + * + * @since 1.53.0 + */ +const DEFAULT_SUPPORT_RESOURCES_FILTER = [ + "**/*.support.js" +]; + +const LOCALE = /^((?:[^/]+\/)*[^/]+?)_([A-Z]{2}(?:_[A-Z]{2}(?:_[A-Z0-9_]+)?)?)(\.properties|\.hdbtextbundle)$/i; +const THEME = /^((?:[^/]+\/)*)themes\/([^/]+)\//; + +class ResourceCollector { + constructor(pool, filter) { + this._pool = pool; + this._filter = filter != null ? filter : new ResourceFilterList(); + this._resources = new Map(); + this._components = new Map(); + this._themePackages = new Map(); + } + + setExternalResources(list) { + this._externalResources = list; + } + + visitResource(virPath) { + if ( !virPath.startsWith("/resources/") ) { + log.warn(`non-runtime resource ${virPath} ignored`); + return; + } + const name = virPath.slice("/resources/".length); + if ( this._filter.matches(name) ) { + this._resources.set(name, new ResourceInfo(name)); + + const p = name.lastIndexOf("/"); + const prefix = name.substring(0, p + 1); + const basename = name.substring(p + 1); + if ( basename.match("[^/]*\\.library|Component\\.js|manifest\\.json") && !this._components.has(prefix) ) { + this._components.set(prefix, new ResourcesList(prefix)); + } + // a .theme file within a theme folder indicates a library/theme package + // Note: ignores .theme files in library folders + if ( name.match("(?:[^/]+/)*themes/[^/]+/(?:\\.theming|library.source.less)") && !this._themePackages.has(prefix) ) { + // log.info("found new theme package %s", prefix); + this._themePackages.set(prefix, new ResourcesList(prefix)); + } + } + } + + async enrichWithDependencyInfo(resourceInfo) { + return this._pool.getModuleInfo(resourceInfo.name).then((info) => { + if ( info.name ) { + resourceInfo.module = info.name; + } + if ( info.dynamicDependencies ) { + resourceInfo.dynRequired = true; + } + info.dependencies.forEach((dep) => { + if ( info.isConditionalDependency(dep) ) { + resourceInfo.condRequired.push(dep); + } else if ( !info.isImplicitDependency(dep) ) { + resourceInfo.required.push(dep); + } + }); + info.subModules.forEach((mod) => { + resourceInfo.included.push(mod); + }); + }); + } + + async determineResourceDetails({pool, debugResources, mergedResources, designtimeResources, supportResources}) { + const baseNames = new Set(); + const debugFilter = ResourceFilterList.fromString(debugResources); + const mergeFilter = ResourceFilterList.fromString(mergedResources); + const designtimeFilter = ResourceFilterList.fromString(designtimeResources); + const supportFilter = ResourceFilterList.fromString(supportResources); + + const promises = []; + + for (const [name, info] of this._resources.entries()) { + // log.verbose(` checking ${name}`); + let m; + if ( m = LOCALE.exec(name) ) { + const baseName = m[1] + m[3]; + log.verbose(" found potential i18n resource '%s', base name is '%s', locale is %s", name, baseName, m[2]); + info.i18nName = baseName; + info.i18nLocale = m[2]; + baseNames.add(baseName); + } + + if ( m = THEME.exec(name) ) { + // log.verbose("found theme candidate %s with prefix %s", name, m[1]); + if ( this._themePackages.has(m[0]) ) { + const theme = m[2]; + info.theme = theme; + log.verbose(" found potential theme resource '%s', theme %s", name, theme); + } + } + + if ( /(?:\.js|\.view.xml|\.control.xml|\.fragment.xml)$/.test(name) ) { + promises.push( + this.enrichWithDependencyInfo(info) + ); + } + + if ( debugFilter.matches(name) ) { + info.isDebug = true; + log.verbose(" found potential debug resource '%s'", name); + } + + if ( mergeFilter.matches(name) ) { + info.merged = true; + log.verbose(" found potential merged resource '%s'", name); + } + + if ( designtimeFilter.matches(name) ) { + info.designtime = true; + log.verbose(" found potential designtime resource '%s'", name); + } + + if ( supportFilter.matches(name) ) { + info.support = true; + log.verbose(" found potential support resource '%s'", name); + } + } + + for (const baseName of baseNames) { + if ( this._resources.has(baseName) ) { + const info = this._resources.get(baseName); + info.i18nName = baseName; + info.i18nLocale = ""; + } + } + + return Promise.all(promises); + } + + createOrphanFilters() { + log.verbose(" configured external resources filters (resources outside the namespace): %s", this.externalResources == null ? "(none)" : this.externalResources); + + const filters = new Map(); + + if ( this._externalResources != null && !this._externalResources.isEmpty() ) { + /* + Collection componentsToProcess = new HashSet(Arrays.asList(this.externalResources.trim().split("\\s*,\\s*"))); + + for ( String component : componentsToProcess ) { + ResourceFilterList packageFilters = null; + int p = component.indexOf(':'); + if ( p > 0 ) { + String packages = component.substring(p+1).trim(); + component = component.substring(0, p).trim(); + if ( packages != null ) { + packageFilters = new ResourceFilterList().addFilters(packages.trim().split("\\s*;\\s*")); + } + } + if ( component.equals("/") || component.isEmpty() ) { + component = ""; + } else if ( !component.endsWith("/") ) { + component += "/"; + } + log.verbose(" resulting filter list for '%s': '%s'", component, packageFilters); + filters.put(component, packageFilters); + } + */ + } + return filters; + } + + groupResourcesByComponents() { + const orphanFilters = this.createOrphanFilters(); + + for (const resource of this._resources.values()) { + let contained = false; + for (const [prefix, list] of this._components.entries()) { + if ( resource.name.startsWith(prefix) ) { + list.add(resource); + contained = true; + } else if ( orphanFilters.has(prefix) ) { + // if ( log.isDebug() ) { + // log.verbose(" checking '%s' against orphan filter '%s' (%s)", resource.name, orphanFilters.get(prefix), prefix); + // } + if ( orphanFilters.get(prefix).matches(resource.name) ) { + list.add(resource); + contained = true; + } + } + } + + if ( resource.theme != null ) { + // assign theme resources additionally to theme packages + for (const [prefix, list] of this._themePackages.entries()) { + if ( resource.name.startsWith(prefix) ) { + list.add(resource); + contained = true; + } + } + } + + if ( contained ) { + this._resources.delete(resource.name); + } + } + } + + get resources() { + return new Set(this._resources.keys()); + } + + get components() { + return this._components; + } + + get themePackages() { + return this._themePackages; + } +} + +/** + * Whether the detection of orphans should result in a build failure. + * + * @since 1.29.1 + */ + +module.exports = async function({resources, dependencyResources}, options) { + options = Object.assign({ + failOnOrphans: true, + externalResources: undefined, + debugResources: DEFAULT_DEBUG_RESOURCES_FILTER.join(","), + mergedResources: DEFAULT_BUNDLE_RESOURCES_FILTER.join(","), + designtimeResources: DEFAULT_DESIGNTIME_RESOURCES_FILTER.join(","), + supportResources: DEFAULT_SUPPORT_RESOURCES_FILTER.join(",") + }, options); + + const pool = new LocatorResourcePool(); + await pool.prepare( resources.concat(dependencyResources) ); + + const collector = new ResourceCollector(pool); + resources.forEach((resource) => collector.visitResource(resource.getPath())); + log.info(" found %d resources", collector.resources.size); + + // determine additional information for the found resources + if ( options && options.externalResources ) { + collector.setExternalResources(options.externalResources); + } + await collector.determineResourceDetails({ + pool, + debugResources: options.debugResources, + mergedResources: options.mergedResources, + designtimeResources: options.designtimeResources, + supportResources: options.supportResources + }); + + // group resources by components and create ResourcesLists + collector.groupResourcesByComponents(); + + const resourceLists = []; + + // write out resources.json files + for (const [prefix, list] of collector.components.entries()) { + log.info(` writing '${prefix}resources.json'`); + resourceLists.push(new EvoResource({ + path: `/resources/${prefix}resources.json`, + string: JSON.stringify(list, null, "\t") + })); + } + for (const [prefix, list] of collector.themePackages.entries()) { + log.info(` writing '${prefix}resources.json'`); + resourceLists.push(new EvoResource({ + path: `/resources/${prefix}resources.json`, + string: JSON.stringify(list, null, "\t") + })); + } + const unassigned = collector.resources; + if ( unassigned.size > 0 ) { + log.warn(` found ${unassigned.size} resources not belonging to a component (orphans)`); + let n = 0; + for ( const resource of unassigned ) { + log.verbose(` ${resource} (orphan)`); + if ( ++n > 20 ) { + log.verbose(" ... (%d more)", unassigned.size - n); + break; + } + } + if ( options.failOnOrphans ) { + throw new Error("not all resources could be assigned to components"); + } + } + + return resourceLists; +}; diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js new file mode 100644 index 000000000..1dc6881a2 --- /dev/null +++ b/lib/tasks/generateResourcesJson.js @@ -0,0 +1,42 @@ +"use strict"; + +// const log = require("@ui5/logger").getLogger("builder:tasks:generateResourcesJson"); +const resourceListCreator = require("../processors/resourceListCreator"); + +const DEFAULT_EXCLUDES = [ + "!**/.DS_Store", + "!**/.eslintrc", + "!**/.eslintignore", + "!**/.gitignore" +]; + +/** + * Task for creating a library resources.json, describing all productive resources in the library. + * + * @public + * @alias module:@ui5/builder.tasks.generateResourcesJson + * @param {Object} parameters Parameters + * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files + * @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files + * @param {Object} parameters.options Options + * @param {string} parameters.options.projectName Project name + * @returns {Promise} Promise resolving with undefined once data has been written + */ +module.exports = async function({workspace, dependencies, options}) { + let resources; + if (workspace.byGlobSource) { // API only available on duplex collections + resources = await workspace.byGlobSource(["/resources/**/*.*", ...DEFAULT_EXCLUDES]); + } else { + resources = await workspace.byGlob(["/resources/**/*.*", ...DEFAULT_EXCLUDES]); + } + const dependencyResources = await dependencies.byGlob("/resources/**/*.{js,json,xml,html,properties,library}"); + + return resourceListCreator({ + resources, + dependencyResources + }).then((resourceLists) => + Promise.all( + resourceLists.map((resourceList) => workspace.write(resourceList)) + ) + ); +}; diff --git a/lib/tasks/taskRepository.js b/lib/tasks/taskRepository.js index 278c4dd40..7174c7036 100644 --- a/lib/tasks/taskRepository.js +++ b/lib/tasks/taskRepository.js @@ -14,6 +14,7 @@ const taskInfos = { generateManifestBundle: {path: "./bundlers/generateManifestBundle"}, generateFlexChangesBundle: {path: "./bundlers/generateFlexChangesBundle"}, generateComponentPreload: {path: "./bundlers/generateComponentPreload"}, + generateResourcesJson: require("./generateResourcesJson"), generateStandaloneAppBundle: {path: "./bundlers/generateStandaloneAppBundle"}, generateBundle: {path: "./bundlers/generateBundle"}, generateLibraryPreload: {path: "./bundlers/generateLibraryPreload"}, diff --git a/lib/types/library/LibraryBuilder.js b/lib/types/library/LibraryBuilder.js index a5b4935a4..7ec9bf97f 100644 --- a/lib/types/library/LibraryBuilder.js +++ b/lib/types/library/LibraryBuilder.js @@ -1,5 +1,22 @@ const AbstractBuilder = require("../AbstractBuilder"); -const {getTask} = require("../../tasks/taskRepository"); +const tasks = { // can't require index.js due to circular dependency + generateComponentPreload: require("../../tasks/bundlers/generateComponentPreload"), + generateFlexChangesBundle: require("../../tasks/bundlers/generateFlexChangesBundle"), + generateBundle: require("../../tasks/bundlers/generateBundle"), + generateLibraryPreload: require("../../tasks/bundlers/generateLibraryPreload"), + generateManifestBundle: require("../../tasks/bundlers/generateManifestBundle"), + generateStandaloneAppBundle: require("../../tasks/bundlers/generateStandaloneAppBundle"), + escapeNonAsciiCharacters: require("../../tasks/escapeNonAsciiCharacters"), + buildThemes: require("../../tasks/buildThemes"), + createDebugFiles: require("../../tasks/createDebugFiles"), + generateJsdoc: require("../../tasks/jsdoc/generateJsdoc"), + executeJsdocSdkTransformation: require("../../tasks/jsdoc/executeJsdocSdkTransformation"), + generateLibraryManifest: require("../../tasks/generateLibraryManifest"), + generateVersionInfo: require("../../tasks/generateVersionInfo"), + replaceCopyright: require("../../tasks/replaceCopyright"), + replaceVersion: require("../../tasks/replaceVersion"), + uglify: require("../../tasks/uglify") +}; class LibraryBuilder extends AbstractBuilder { addStandardTasks({resourceCollections, project, log, taskUtil}) { diff --git a/test/expected/build/library.d/dest/resources/library/d/resources.json b/test/expected/build/library.d/dest/resources/library/d/resources.json new file mode 100644 index 000000000..2fd9deb81 --- /dev/null +++ b/test/expected/build/library.d/dest/resources/library/d/resources.json @@ -0,0 +1,12 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": ".library" + }, + { + "name": "some.js", + "module": "library/d/some.js" + } + ] +} \ No newline at end of file diff --git a/test/expected/build/library.e/dest/resources/library/e/resources.json b/test/expected/build/library.e/dest/resources/library/e/resources.json new file mode 100644 index 000000000..fbfe2912c --- /dev/null +++ b/test/expected/build/library.e/dest/resources/library/e/resources.json @@ -0,0 +1,19 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": ".library" + }, + { + "name": "library.js", + "module": "library/e/library.js" + }, + { + "name": "manifest.json" + }, + { + "name": "some.js", + "module": "library/e/some.js" + } + ] +} \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/resources.json new file mode 100644 index 000000000..aafd01eb7 --- /dev/null +++ b/test/expected/build/library.h/dest/resources/library/h/components/resources.json @@ -0,0 +1,37 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": "Component.js", + "module": "library/h/components/Component.js", + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "TodoComponent.js", + "module": "library/h/components/TodoComponent.js" + }, + { + "name": "subcomponent1/Component.js", + "module": "library/h/components/subcomponent1/Component.js", + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "subcomponent2/Component.js", + "module": "library/h/components/subcomponent2/Component.js", + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "subcomponent3/Component.js", + "module": "library/h/components/subcomponent3/Component.js", + "required": [ + "sap/ui/core/UIComponent.js" + ] + } + ] +} \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json new file mode 100644 index 000000000..ad32c6ebb --- /dev/null +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json @@ -0,0 +1,12 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": "Component.js", + "module": "library/h/components/subcomponent1/Component.js", + "required": [ + "sap/ui/core/UIComponent.js" + ] + } + ] +} \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json new file mode 100644 index 000000000..5f4a1e384 --- /dev/null +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json @@ -0,0 +1,12 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": "Component.js", + "module": "library/h/components/subcomponent2/Component.js", + "required": [ + "sap/ui/core/UIComponent.js" + ] + } + ] +} \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json new file mode 100644 index 000000000..f294f44d7 --- /dev/null +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json @@ -0,0 +1,12 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": "Component.js", + "module": "library/h/components/subcomponent3/Component.js", + "required": [ + "sap/ui/core/UIComponent.js" + ] + } + ] +} \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/resources.json b/test/expected/build/library.h/dest/resources/library/h/resources.json new file mode 100644 index 000000000..b1a11fd43 --- /dev/null +++ b/test/expected/build/library.h/dest/resources/library/h/resources.json @@ -0,0 +1,56 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": ".library" + }, + { + "name": "components/Component.js", + "module": "library/h/components/Component.js", + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "components/TodoComponent.js", + "module": "library/h/components/TodoComponent.js" + }, + { + "name": "components/subcomponent1/Component.js", + "module": "library/h/components/subcomponent1/Component.js", + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "components/subcomponent2/Component.js", + "module": "library/h/components/subcomponent2/Component.js", + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "components/subcomponent3/Component.js", + "module": "library/h/components/subcomponent3/Component.js", + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "file.js", + "module": "library/h/file.js" + }, + { + "name": "library.js", + "module": "library/h/library.js" + }, + { + "name": "not.js", + "module": "library/h/not.js" + }, + { + "name": "some.js", + "module": "library/h/some.js" + } + ] +} \ No newline at end of file diff --git a/test/expected/build/library.i/dest/resources/library/i/resources.json b/test/expected/build/library.i/dest/resources/library/i/resources.json new file mode 100644 index 000000000..6c96e46fc --- /dev/null +++ b/test/expected/build/library.i/dest/resources/library/i/resources.json @@ -0,0 +1,15 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": ".library" + }, + { + "name": "library.js", + "module": "library/i/library.js", + "required": [ + "sap/ui/core/Core.js" + ] + } + ] +} \ No newline at end of file diff --git a/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json b/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json new file mode 100644 index 000000000..cf0522a74 --- /dev/null +++ b/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json @@ -0,0 +1,15 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": "Button.less", + "designtime": true, + "theme": "somefancytheme" + }, + { + "name": "library.source.less", + "designtime": true, + "theme": "somefancytheme" + } + ] +} \ No newline at end of file diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 4c3d19821..e6da4bc16 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -200,7 +200,7 @@ test("Build application.a with dependencies", (t) => { return builder.build({ tree: applicationATree, destPath, - excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest"], + excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest", "generateResourcesJson"], buildDependencies: true }).then(() => { return findFiles(expectedPath); @@ -221,7 +221,7 @@ test("Build application.a with dependencies include", (t) => { return builder.build({ tree: applicationATree, destPath, - excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest"], + excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest", "generateResourcesJson"], buildDependencies: true, includedDependencies: ["*"] }).then(() => { return findFiles(expectedPath); @@ -242,7 +242,7 @@ test("Build application.a with dependencies exclude", (t) => { return builder.build({ tree: applicationATree, destPath, - excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest"], + excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest", "generateResourcesJson"], buildDependencies: true, excludedDependencies: ["library.d"] }).then(() => { return findFiles(expectedPath); @@ -284,7 +284,7 @@ test("Build application.a with dependencies self-contained", (t) => { return builder.build({ tree: applicationATree, destPath, - excludedTasks: ["generateComponentPreload", "generateVersionInfo", "escapeNonAsciiCharacters", "generateLibraryManifest"], + excludedTasks: ["generateComponentPreload", "generateVersionInfo", "escapeNonAsciiCharacters", "generateLibraryManifest", "generateResourcesJson"], buildDependencies: true, selfContained: true }).then(() => { From caf63931e1e7aaf89e9d456d91acaec9aa3784eb Mon Sep 17 00:00:00 2001 From: Frank Weigel Date: Sun, 29 Dec 2019 15:11:37 +0100 Subject: [PATCH 02/88] Add integration test tailored for resourceListCreator --- lib/processors/resourceListCreator.js | 59 ++++--- lib/tasks/generateResourcesJson.js | 7 + .../dest/resources/library/d/resources.json | 8 + .../dest/resources/library/e/resources.json | 10 ++ .../library/h/components/resources.json | 33 ++++ .../h/components/subcomponent1/resources.json | 8 + .../h/components/subcomponent2/resources.json | 8 + .../h/components/subcomponent3/resources.json | 8 + .../dest/resources/library/h/resources.json | 46 ++++++ .../dest/resources/library/i/resources.json | 3 + .../dest/resources/library/n/.library | 19 +++ .../dest/resources/library/n/Button-dbg.js | 50 ++++++ .../dest/resources/library/n/Button.js | 6 + .../n/changeHandler/SplitButton-dbg.js | 29 ++++ .../library/n/changeHandler/SplitButton.js | 6 + .../n/designtime/Button-dbg.designtime.js | 45 ++++++ .../n/designtime/Button.create.fragment.xml | 10 ++ .../library/n/designtime/Button.designtime.js | 6 + .../library/n/designtime/Button.icon.svg | 26 +++ .../n/designtime/library-dbg.designtime.js | 10 ++ .../n/designtime/library.designtime.js | 6 + .../n/flexibility/Button.flexibility-dbg.js | 22 +++ .../n/flexibility/Button.flexibility.js | 6 + .../dest/resources/library/n/library-dbg.js | 40 +++++ .../library/n/library-dbg.support.js | 23 +++ .../dest/resources/library/n/library.js | 6 + .../resources/library/n/library.support.js | 6 + .../dest/resources/library/n/manifest.json | 38 +++++ .../library/n/messagebundle.properties | 1 + .../library/n/messagebundle_de.properties | 1 + .../dest/resources/library/n/resources.json | 153 ++++++++++++++++++ .../library/n/rules/Button-dbg.support.js | 6 + .../library/n/rules/Button.support.js | 6 + .../j/themes/somefancytheme/resources.json | 12 ++ test/fixtures/library.n/package.json | 8 + .../fixtures/library.n/src/library/n/.library | 17 ++ .../library.n/src/library/n/Button.js | 48 ++++++ .../library/n/changeHandler/SplitButton.js | 27 ++++ .../n/designtime/Button.create.fragment.xml | 10 ++ .../library/n/designtime/Button.designtime.js | 43 +++++ .../src/library/n/designtime/Button.icon.svg | 26 +++ .../n/designtime/library.designtime.js | 8 + .../n/flexibility/Button.flexibility.js | 20 +++ .../library.n/src/library/n/library.js | 38 +++++ .../src/library/n/library.support.js | 21 +++ .../src/library/n/messagebundle.properties | 1 + .../src/library/n/messagebundle_de.properties | 1 + .../src/library/n/rules/Button.support.js | 4 + test/fixtures/library.n/ui5.yaml | 5 + test/lib/builder/builder.js | 77 +++++++++ 50 files changed, 1051 insertions(+), 26 deletions(-) create mode 100644 test/expected/build/library.n/dest/resources/library/n/.library create mode 100644 test/expected/build/library.n/dest/resources/library/n/Button-dbg.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/Button.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/designtime/Button.create.fragment.xml create mode 100644 test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/designtime/Button.icon.svg create mode 100644 test/expected/build/library.n/dest/resources/library/n/designtime/library-dbg.designtime.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/designtime/library.designtime.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/library-dbg.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/library.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/library.support.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/manifest.json create mode 100644 test/expected/build/library.n/dest/resources/library/n/messagebundle.properties create mode 100644 test/expected/build/library.n/dest/resources/library/n/messagebundle_de.properties create mode 100644 test/expected/build/library.n/dest/resources/library/n/resources.json create mode 100644 test/expected/build/library.n/dest/resources/library/n/rules/Button-dbg.support.js create mode 100644 test/expected/build/library.n/dest/resources/library/n/rules/Button.support.js create mode 100644 test/fixtures/library.n/package.json create mode 100644 test/fixtures/library.n/src/library/n/.library create mode 100644 test/fixtures/library.n/src/library/n/Button.js create mode 100644 test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js create mode 100644 test/fixtures/library.n/src/library/n/designtime/Button.create.fragment.xml create mode 100644 test/fixtures/library.n/src/library/n/designtime/Button.designtime.js create mode 100644 test/fixtures/library.n/src/library/n/designtime/Button.icon.svg create mode 100644 test/fixtures/library.n/src/library/n/designtime/library.designtime.js create mode 100644 test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js create mode 100644 test/fixtures/library.n/src/library/n/library.js create mode 100644 test/fixtures/library.n/src/library/n/library.support.js create mode 100644 test/fixtures/library.n/src/library/n/messagebundle.properties create mode 100644 test/fixtures/library.n/src/library/n/messagebundle_de.properties create mode 100644 test/fixtures/library.n/src/library/n/rules/Button.support.js create mode 100644 test/fixtures/library.n/ui5.yaml diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 50dd53fbd..653a2a845 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -65,9 +65,9 @@ class ResourceInfo { this.designtime = false; this.support = false; this.module = null; - this.required = []; - this.condRequired = []; - this.included = []; + this.required = null; + this.condRequired = null; + this.included = null; this.dynRequired = false; } @@ -84,24 +84,24 @@ class ResourceInfo { } if ( orig.required != null ) { if ( this.required == null ) { - this.required = []; + this.required = new Set(); } - this.required = this.required.concat(orig.required); // remove duplicates? + orig.required.forEach(this.required.add, this.required); } if ( orig.condRequired != null ) { if ( this.condRequired == null ) { - this.condRequired = []; + this.condRequired = new Set(); } - this.condRequired = this.condRequired.concat(orig.condRequired); // remove duplicates? + orig.condRequired.forEach(this.condRequired.add, this.condRequired); } this.dynRequired = orig.dynRequired; if ( orig.included != null ) { if ( this.included == null ) { - this.included = []; + this.included = new Set(); } - this.included = this.included.concat(orig.included); // remove duplicates? + orig.included.forEach(this.included.add, this.included); } - if ( this.included != null && this.included.length > 0 ) { + if ( this.included != null && this.included.size > 0 ) { this.merged = true; } } @@ -132,17 +132,17 @@ class ResourceInfo { if ( this.theme != null ) { result.theme = this.theme; } - if ( this.required != null && this.required.length > 0 ) { - result.required = this.required.sort(); + if ( this.required != null && this.required.size > 0 ) { + result.required = [...this.required].sort(); } - if ( this.condRequired != null && this.condRequired.length > 0 ) { - result.condRequired = this.condRequired.sort(); + if ( this.condRequired != null && this.condRequired.size > 0 ) { + result.condRequired = [...this.condRequired].sort(); } if ( this.dynRequired ) { result.dynRequired = this.dynRequired; } - if ( this.included != null && this.included.length > 0 ) { - result.included = this.included; + if ( this.included != null && this.included.size > 0 ) { + result.included = [...this.included]; } return result; } @@ -407,16 +407,23 @@ class ResourceCollector { if ( info.dynamicDependencies ) { resourceInfo.dynRequired = true; } - info.dependencies.forEach((dep) => { - if ( info.isConditionalDependency(dep) ) { - resourceInfo.condRequired.push(dep); - } else if ( !info.isImplicitDependency(dep) ) { - resourceInfo.required.push(dep); - } - }); - info.subModules.forEach((mod) => { - resourceInfo.included.push(mod); - }); + if ( info.dependencies.length > 0 ) { + resourceInfo.required = resourceInfo.required || new Set(); + resourceInfo.condRequired = resourceInfo.condRequired || new Set(); + info.dependencies.forEach((dep) => { + if ( info.isConditionalDependency(dep) ) { + resourceInfo.condRequired.push(dep); + } else if ( !info.isImplicitDependency(dep) ) { + resourceInfo.required.add(dep); + } + }); + } + if ( info.subModules.length > 0 ) { + resourceInfo.included = resourceInfo.included || new Set(); + info.subModules.forEach((mod) => { + resourceInfo.included.add(mod); + }); + } }); } diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index 1dc6881a2..d5c2cea04 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -26,6 +26,13 @@ module.exports = async function({workspace, dependencies, options}) { let resources; if (workspace.byGlobSource) { // API only available on duplex collections resources = await workspace.byGlobSource(["/resources/**/*.*", ...DEFAULT_EXCLUDES]); + // HACK add resources from internal writer of workspace + const writtenResources = await workspace._writer.byGlob(["/resources/**/*.*", ...DEFAULT_EXCLUDES]); + writtenResources.forEach((res) => { + if ( resources.indexOf(res) < 0 ) { + resources.push(res); + } + }); } else { resources = await workspace.byGlob(["/resources/**/*.*", ...DEFAULT_EXCLUDES]); } diff --git a/test/expected/build/library.d/dest/resources/library/d/resources.json b/test/expected/build/library.d/dest/resources/library/d/resources.json index 2fd9deb81..101273255 100644 --- a/test/expected/build/library.d/dest/resources/library/d/resources.json +++ b/test/expected/build/library.d/dest/resources/library/d/resources.json @@ -4,6 +4,14 @@ { "name": ".library" }, + { + "name": "manifest.json" + }, + { + "name": "some-dbg.js", + "module": "library/d/some.js", + "isDebug": true + }, { "name": "some.js", "module": "library/d/some.js" diff --git a/test/expected/build/library.e/dest/resources/library/e/resources.json b/test/expected/build/library.e/dest/resources/library/e/resources.json index fbfe2912c..941b6e52d 100644 --- a/test/expected/build/library.e/dest/resources/library/e/resources.json +++ b/test/expected/build/library.e/dest/resources/library/e/resources.json @@ -4,6 +4,11 @@ { "name": ".library" }, + { + "name": "library-dbg.js", + "module": "library/e/library.js", + "isDebug": true + }, { "name": "library.js", "module": "library/e/library.js" @@ -11,6 +16,11 @@ { "name": "manifest.json" }, + { + "name": "some-dbg.js", + "module": "library/e/some.js", + "isDebug": true + }, { "name": "some.js", "module": "library/e/some.js" diff --git a/test/expected/build/library.h/dest/resources/library/h/components/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/resources.json index aafd01eb7..d3a6e34bc 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/resources.json @@ -1,6 +1,15 @@ { "_version": "1.1.0", "resources": [ + { + "name": "Component-preload.js", + "module": "library/h/components/Component-preload.js", + "merged": true, + "included": [ + "library/h/components/Component.js", + "library/h/components/TodoComponent.js" + ] + }, { "name": "Component.js", "module": "library/h/components/Component.js", @@ -12,6 +21,14 @@ "name": "TodoComponent.js", "module": "library/h/components/TodoComponent.js" }, + { + "name": "subcomponent1/Component-preload.js", + "module": "library/h/components/subcomponent1/Component-preload.js", + "merged": true, + "included": [ + "library/h/components/subcomponent1/Component.js" + ] + }, { "name": "subcomponent1/Component.js", "module": "library/h/components/subcomponent1/Component.js", @@ -19,6 +36,14 @@ "sap/ui/core/UIComponent.js" ] }, + { + "name": "subcomponent2/Component-preload.js", + "module": "library/h/components/subcomponent2/Component-preload.js", + "merged": true, + "included": [ + "library/h/components/subcomponent2/Component.js" + ] + }, { "name": "subcomponent2/Component.js", "module": "library/h/components/subcomponent2/Component.js", @@ -26,6 +51,14 @@ "sap/ui/core/UIComponent.js" ] }, + { + "name": "subcomponent3/Component-preload.js", + "module": "library/h/components/subcomponent3/Component-preload.js", + "merged": true, + "included": [ + "library/h/components/subcomponent3/Component.js" + ] + }, { "name": "subcomponent3/Component.js", "module": "library/h/components/subcomponent3/Component.js", diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json index ad32c6ebb..b50be1417 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json @@ -1,6 +1,14 @@ { "_version": "1.1.0", "resources": [ + { + "name": "Component-preload.js", + "module": "library/h/components/subcomponent1/Component-preload.js", + "merged": true, + "included": [ + "library/h/components/subcomponent1/Component.js" + ] + }, { "name": "Component.js", "module": "library/h/components/subcomponent1/Component.js", diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json index 5f4a1e384..39a00361e 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json @@ -1,6 +1,14 @@ { "_version": "1.1.0", "resources": [ + { + "name": "Component-preload.js", + "module": "library/h/components/subcomponent2/Component-preload.js", + "merged": true, + "included": [ + "library/h/components/subcomponent2/Component.js" + ] + }, { "name": "Component.js", "module": "library/h/components/subcomponent2/Component.js", diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json index f294f44d7..836795791 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json @@ -1,6 +1,14 @@ { "_version": "1.1.0", "resources": [ + { + "name": "Component-preload.js", + "module": "library/h/components/subcomponent3/Component-preload.js", + "merged": true, + "included": [ + "library/h/components/subcomponent3/Component.js" + ] + }, { "name": "Component.js", "module": "library/h/components/subcomponent3/Component.js", diff --git a/test/expected/build/library.h/dest/resources/library/h/resources.json b/test/expected/build/library.h/dest/resources/library/h/resources.json index b1a11fd43..db99ed8fa 100644 --- a/test/expected/build/library.h/dest/resources/library/h/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/resources.json @@ -4,6 +4,15 @@ { "name": ".library" }, + { + "name": "components/Component-preload.js", + "module": "library/h/components/Component-preload.js", + "merged": true, + "included": [ + "library/h/components/Component.js", + "library/h/components/TodoComponent.js" + ] + }, { "name": "components/Component.js", "module": "library/h/components/Component.js", @@ -15,6 +24,14 @@ "name": "components/TodoComponent.js", "module": "library/h/components/TodoComponent.js" }, + { + "name": "components/subcomponent1/Component-preload.js", + "module": "library/h/components/subcomponent1/Component-preload.js", + "merged": true, + "included": [ + "library/h/components/subcomponent1/Component.js" + ] + }, { "name": "components/subcomponent1/Component.js", "module": "library/h/components/subcomponent1/Component.js", @@ -22,6 +39,14 @@ "sap/ui/core/UIComponent.js" ] }, + { + "name": "components/subcomponent2/Component-preload.js", + "module": "library/h/components/subcomponent2/Component-preload.js", + "merged": true, + "included": [ + "library/h/components/subcomponent2/Component.js" + ] + }, { "name": "components/subcomponent2/Component.js", "module": "library/h/components/subcomponent2/Component.js", @@ -29,6 +54,14 @@ "sap/ui/core/UIComponent.js" ] }, + { + "name": "components/subcomponent3/Component-preload.js", + "module": "library/h/components/subcomponent3/Component-preload.js", + "merged": true, + "included": [ + "library/h/components/subcomponent3/Component.js" + ] + }, { "name": "components/subcomponent3/Component.js", "module": "library/h/components/subcomponent3/Component.js", @@ -36,6 +69,16 @@ "sap/ui/core/UIComponent.js" ] }, + { + "name": "customBundle.js", + "module": "library/h/customBundle.js", + "merged": true, + "included": [ + "library/h/file.js", + "library/h/library.js", + "library/h/some.js" + ] + }, { "name": "file.js", "module": "library/h/file.js" @@ -44,6 +87,9 @@ "name": "library.js", "module": "library/h/library.js" }, + { + "name": "manifest.json" + }, { "name": "not.js", "module": "library/h/not.js" diff --git a/test/expected/build/library.i/dest/resources/library/i/resources.json b/test/expected/build/library.i/dest/resources/library/i/resources.json index 6c96e46fc..50894081d 100644 --- a/test/expected/build/library.i/dest/resources/library/i/resources.json +++ b/test/expected/build/library.i/dest/resources/library/i/resources.json @@ -10,6 +10,9 @@ "required": [ "sap/ui/core/Core.js" ] + }, + { + "name": "manifest.json" } ] } \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/.library b/test/expected/build/library.n/dest/resources/library/n/.library new file mode 100644 index 000000000..bb3db51ef --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/.library @@ -0,0 +1,19 @@ + + + + library.n + SAP SE + UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + 1.0.0 + + Library N + + + + sap.ui.core + + + + diff --git a/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js b/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js new file mode 100644 index 000000000..ca43eff95 --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js @@ -0,0 +1,50 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ + +// Provides control library.N.Button. +sap.ui.define([ + './library', + 'sap/ui/core/Control' +], function( + library, + Control +) { + "use strict"; + + return Control.extend("library.n.Button", { + metadata : { + library : "library.n", + properties : { + text: {type: "string", group: "Misc", defaultValue: "" } + }, + aggregations: { + icon: {type: "sap.ui.core.Control", cardinality: "0..1" } + }, + events: { + press: {} + } + }, + designtime: "library/n/designtime/Button.designtime", + renderer: { + apiVersion: 2, + render: function(oRm, oButton) { + oRm.openStart("button", oButton); + oRm.class("libNBtnBase"); + oRm.openEnd(); + if ( oButton.getIcon() ) { + oRm.renderControl(oButton.getIcon()); + } + oRm.openStart("span", oButton.getId() + "-content"); + oRm.class("libNBtnContent"); + oRm.openEnd(); + oRm.text(sText); + oRm.close("span"); + oRm.close("button"); + } + } + }); + +}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/Button.js b/test/expected/build/library.n/dest/resources/library/n/Button.js new file mode 100644 index 000000000..9b2547fdf --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/Button.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define(["./library","sap/ui/core/Control"],function(e,t){"use strict";return t.extend("library.n.Button",{metadata:{library:"library.n",properties:{text:{type:"string",group:"Misc",defaultValue:""}},aggregations:{icon:{type:"sap.ui.core.Control",cardinality:"0..1"}},events:{press:{}}},designtime:"library/n/designtime/Button.designtime",renderer:{apiVersion:2,render:function(e,t){e.openStart("button",t);e.class("libNBtnBase");e.openEnd();if(t.getIcon()){e.renderControl(t.getIcon())}e.openStart("span",t.getId()+"-content");e.class("libNBtnContent");e.openEnd();e.text(sText);e.close("span");e.close("button")}}})}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js new file mode 100644 index 000000000..08302deee --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js @@ -0,0 +1,29 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ + +sap.ui.define([ + "sap/ui/core/util/reflection/JsControlTreeModifier" +], function ( + JsControlTreeModifier +) { + "use strict"; + + var ButtonCH = {}; + + SplitButton.applyChange = function(oChange, oControl, mPropertyBag) { + if (mPropertyBag.modifier.targets !== "jsControlTree") { + throw new Error("SplitButton change can't be applied on XML tree"); + } + return true; + }; + + SplitButton.revertChange = function(oChange, oControl, mPropertyBag) { + oChange.resetRevertData(); + return true; + }; + + return ButtonCH; +}); diff --git a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js new file mode 100644 index 000000000..4ba21a98a --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define(["sap/ui/core/util/reflection/JsControlTreeModifier"],function(e){"use strict";var t={};SplitButton.applyChange=function(e,t,r){if(r.modifier.targets!=="jsControlTree"){throw new Error("SplitButton change can't be applied on XML tree")}return true};SplitButton.revertChange=function(e,t,r){e.resetRevertData();return true};return t}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js new file mode 100644 index 000000000..b4f1f4dc0 --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js @@ -0,0 +1,45 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ + +// Provides the Design Time Metadata for the library.n.Button control +sap.ui.define([], + function () { + "use strict"; + + return { + palette: { + group: "ACTION", + icons: { + svg: "library/n/designtime/Button.icon.svg" + } + }, + actions: { + combine: { + changeType: "combineButtons", + changeOnRelevantContainer : true, + isEnabled : true + }, + remove: { + changeType: "hideControl" + }, + split: { + changeType: "split" + }, + rename: { + changeType: "rename", + domRef: function (oControl) { + return oControl.$().find(".libNBtnContent")[0]; + } + }, + reveal: { + changeType: "unhideControl" + } + }, + templates: { + create: "library/n/designtime/Button.create.fragment.xml" + } + }; + }); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.create.fragment.xml b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.create.fragment.xml new file mode 100644 index 000000000..50988ae74 --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.create.fragment.xml @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js new file mode 100644 index 000000000..604978178 --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define([],function(){"use strict";return{palette:{group:"ACTION",icons:{svg:"library/n/designtime/Button.icon.svg"}},actions:{combine:{changeType:"combineButtons",changeOnRelevantContainer:true,isEnabled:true},remove:{changeType:"hideControl"},split:{changeType:"split"},rename:{changeType:"rename",domRef:function(e){return e.$().find(".libNBtnContent")[0]}},reveal:{changeType:"unhideControl"}},templates:{create:"library/n/designtime/Button.create.fragment.xml"}}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.icon.svg b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.icon.svg new file mode 100644 index 000000000..db8fc2011 --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.icon.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/library-dbg.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/library-dbg.designtime.js new file mode 100644 index 000000000..723a087bd --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/library-dbg.designtime.js @@ -0,0 +1,10 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ + +sap.ui.define([], function() { + "use strict"; + return {}; +}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/library.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/library.designtime.js new file mode 100644 index 000000000..2e8bb38c4 --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/library.designtime.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js new file mode 100644 index 000000000..a22f5d6eb --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js @@ -0,0 +1,22 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ + +sap.ui.define([ + "sap/ui/fl/changeHandler/BaseRename", + "../changeHandler/SplitButton" +], function (BaseRename, SplitButton) { + "use strict"; + + return { + "hideControl": "default", + "split": SplitButton, + "rename": BaseRename.createRenameChangeHandler({ + propertyName: "text", + translationTextType: "XBUT" + }), + "unhideControl": "default" + }; +}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js new file mode 100644 index 000000000..91714752b --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define(["sap/ui/fl/changeHandler/BaseRename","../changeHandler/SplitButton"],function(e,n){"use strict";return{hideControl:"default",split:n,rename:e.createRenameChangeHandler({propertyName:"text",translationTextType:"XBUT"}),unhideControl:"default"}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/library-dbg.js b/test/expected/build/library.n/dest/resources/library/n/library-dbg.js new file mode 100644 index 000000000..be08e1816 --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/library-dbg.js @@ -0,0 +1,40 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ + +sap.ui.define([ + 'sap/ui/core/Core', + 'sap/ui/core/library', + 'sap/m/library' +], function( + Core, + coreLibrary, + mobileLibrary +) { + "use strict"; + + // delegate further initialization of this library to the Core + sap.ui.getCore().initLibrary({ + name : "library.n", + version: "1.0.0", + dependencies : ["sap.ui.core", "sap.m"], + designtime: "library/n/designtime/library.designtime", + types: [], + interfaces: [], + controls: [], + elements: [], + extensions: { + flChangeHandlers: { + "library.n.Button": "library/n/flexibility/Button" + }, + "sap.ui.support": { + publicRules:true, + internalRules:false + } + } + }); + + return sap.m; +}); diff --git a/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js b/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js new file mode 100644 index 000000000..b5d45a041 --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js @@ -0,0 +1,23 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define([ + "sap/ui/support/library", + "./rules/Button.support" +], function( + SupportLib, + ButtonSupport, + ) { + "use strict"; + + return { + name: "library.n", + niceName: "Library N", + ruleset: [ + ButtonSupport + ] + }; + +}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/library.js b/test/expected/build/library.n/dest/resources/library/n/library.js new file mode 100644 index 000000000..9bb8f0e2f --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/library.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define(["sap/ui/core/Core","sap/ui/core/library","sap/m/library"],function(e,i,r){"use strict";sap.ui.getCore().initLibrary({name:"library.n",version:"1.0.0",dependencies:["sap.ui.core","sap.m"],designtime:"library/n/designtime/library.designtime",types:[],interfaces:[],controls:[],elements:[],extensions:{flChangeHandlers:{"library.n.Button":"library/n/flexibility/Button"},"sap.ui.support":{publicRules:true,internalRules:false}}});return sap.m}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/library.support.js b/test/expected/build/library.n/dest/resources/library/n/library.support.js new file mode 100644 index 000000000..aa01ff9b5 --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/library.support.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define(["sap/ui/support/library","./rules/Button.support"],function(r,e){"use strict";return{name:"library.n",niceName:"Library N",ruleset:[e]}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/manifest.json b/test/expected/build/library.n/dest/resources/library/n/manifest.json new file mode 100644 index 000000000..6cfe875b0 --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/manifest.json @@ -0,0 +1,38 @@ +{ + "_version": "1.9.0", + "sap.app": { + "id": "library.n", + "type": "library", + "embeds": [], + "applicationVersion": { + "version": "1.0.0" + }, + "title": "Library N", + "description": "Library N", + "resources": "resources.json", + "offline": true + }, + "sap.ui": { + "technology": "UI5", + "supportedThemes": [] + }, + "sap.ui5": { + "dependencies": { + "minUI5Version": "1.0", + "libs": { + "sap.ui.core": { + "minVersion": "1.0.0" + } + } + }, + "library": { + "i18n": "messagebundle.properties", + "content": { + "controls": [], + "elements": [], + "types": [], + "interfaces": [] + } + } + } +} \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/messagebundle.properties b/test/expected/build/library.n/dest/resources/library/n/messagebundle.properties new file mode 100644 index 000000000..2fb1d609b --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/messagebundle.properties @@ -0,0 +1 @@ +PRESS=Click! diff --git a/test/expected/build/library.n/dest/resources/library/n/messagebundle_de.properties b/test/expected/build/library.n/dest/resources/library/n/messagebundle_de.properties new file mode 100644 index 000000000..985400feb --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/messagebundle_de.properties @@ -0,0 +1 @@ +PRESS=Hier clicken! diff --git a/test/expected/build/library.n/dest/resources/library/n/resources.json b/test/expected/build/library.n/dest/resources/library/n/resources.json new file mode 100644 index 000000000..da7f5a806 --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/resources.json @@ -0,0 +1,153 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": ".library" + }, + { + "name": "Button-dbg.js", + "module": "library/n/Button.js", + "isDebug": true, + "required": [ + "library/n/library.js", + "sap/ui/core/Control.js" + ] + }, + { + "name": "Button.js", + "module": "library/n/Button.js", + "required": [ + "library/n/library.js", + "sap/ui/core/Control.js" + ] + }, + { + "name": "changeHandler/SplitButton-dbg.js", + "module": "library/n/changeHandler/SplitButton.js", + "isDebug": true, + "required": [ + "sap/ui/core/util/reflection/JsControlTreeModifier.js" + ] + }, + { + "name": "changeHandler/SplitButton.js", + "module": "library/n/changeHandler/SplitButton.js", + "required": [ + "sap/ui/core/util/reflection/JsControlTreeModifier.js" + ] + }, + { + "name": "designtime/Button-dbg.designtime.js", + "module": "library/n/designtime/Button.designtime.js", + "isDebug": true, + "designtime": true + }, + { + "name": "designtime/Button.create.fragment.xml", + "module": "library/n/designtime/Button.create.fragment.xml", + "designtime": true, + "required": [ + "library/n/Button.js" + ] + }, + { + "name": "designtime/Button.designtime.js", + "module": "library/n/designtime/Button.designtime.js", + "designtime": true + }, + { + "name": "designtime/Button.icon.svg", + "designtime": true + }, + { + "name": "designtime/library-dbg.designtime.js", + "module": "library/n/designtime/library.designtime.js", + "isDebug": true, + "designtime": true + }, + { + "name": "designtime/library.designtime.js", + "module": "library/n/designtime/library.designtime.js", + "designtime": true + }, + { + "name": "flexibility/Button.flexibility-dbg.js", + "module": "library/n/flexibility/Button.flexibility.js", + "isDebug": true, + "required": [ + "library/n/changeHandler/SplitButton.js", + "sap/ui/fl/changeHandler/BaseRename.js" + ] + }, + { + "name": "flexibility/Button.flexibility.js", + "module": "library/n/flexibility/Button.flexibility.js", + "required": [ + "library/n/changeHandler/SplitButton.js", + "sap/ui/fl/changeHandler/BaseRename.js" + ] + }, + { + "name": "library-dbg.js", + "module": "library/n/library.js", + "isDebug": true, + "required": [ + "sap/m/library.js", + "sap/ui/core/Core.js", + "sap/ui/core/library.js" + ] + }, + { + "name": "library-dbg.support.js", + "module": "library/n/library.support.js", + "isDebug": true, + "support": true, + "required": [ + "library/n/rules/Button.support.js", + "sap/ui/support/library.js" + ] + }, + { + "name": "library.js", + "module": "library/n/library.js", + "required": [ + "sap/m/library.js", + "sap/ui/core/Core.js", + "sap/ui/core/library.js" + ] + }, + { + "name": "library.support.js", + "module": "library/n/library.support.js", + "support": true, + "required": [ + "library/n/rules/Button.support.js", + "sap/ui/support/library.js" + ] + }, + { + "name": "manifest.json" + }, + { + "name": "messagebundle.properties", + "locale": "", + "raw": "messagebundle.properties" + }, + { + "name": "messagebundle_de.properties", + "locale": "de", + "raw": "messagebundle.properties" + }, + { + "name": "rules/Button-dbg.support.js", + "module": "library/n/rules/Button.support.js", + "isDebug": true, + "support": true + }, + { + "name": "rules/Button.support.js", + "module": "library/n/rules/Button.support.js", + "support": true + } + ] +} \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/rules/Button-dbg.support.js b/test/expected/build/library.n/dest/resources/library/n/rules/Button-dbg.support.js new file mode 100644 index 000000000..dc9e1fc91 --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/rules/Button-dbg.support.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +console.log('HelloWorld'); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/rules/Button.support.js b/test/expected/build/library.n/dest/resources/library/n/rules/Button.support.js new file mode 100644 index 000000000..39e3277ce --- /dev/null +++ b/test/expected/build/library.n/dest/resources/library/n/rules/Button.support.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +console.log("HelloWorld"); \ No newline at end of file diff --git a/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json b/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json index cf0522a74..a113b66df 100644 --- a/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json +++ b/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json @@ -6,6 +6,18 @@ "designtime": true, "theme": "somefancytheme" }, + { + "name": "library-RTL.css", + "theme": "somefancytheme" + }, + { + "name": "library-parameters.json", + "theme": "somefancytheme" + }, + { + "name": "library.css", + "theme": "somefancytheme" + }, { "name": "library.source.less", "designtime": true, diff --git a/test/fixtures/library.n/package.json b/test/fixtures/library.n/package.json new file mode 100644 index 000000000..bd37ccd0b --- /dev/null +++ b/test/fixtures/library.n/package.json @@ -0,0 +1,8 @@ +{ + "name": "library.n", + "version": "1.0.0", + "description": "Simple SAPUI5 based library - test for resourceListCreator", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + } +} diff --git a/test/fixtures/library.n/src/library/n/.library b/test/fixtures/library.n/src/library/n/.library new file mode 100644 index 000000000..02ec88b73 --- /dev/null +++ b/test/fixtures/library.n/src/library/n/.library @@ -0,0 +1,17 @@ + + + + library.n + SAP SE + ${copyright} + ${version} + + Library N + + + + sap.ui.core + + + + diff --git a/test/fixtures/library.n/src/library/n/Button.js b/test/fixtures/library.n/src/library/n/Button.js new file mode 100644 index 000000000..7259cde38 --- /dev/null +++ b/test/fixtures/library.n/src/library/n/Button.js @@ -0,0 +1,48 @@ +/*! + * ${copyright} + */ + +// Provides control library.N.Button. +sap.ui.define([ + './library', + 'sap/ui/core/Control' +], function( + library, + Control +) { + "use strict"; + + return Control.extend("library.n.Button", { + metadata : { + library : "library.n", + properties : { + text: {type: "string", group: "Misc", defaultValue: "" } + }, + aggregations: { + icon: {type: "sap.ui.core.Control", cardinality: "0..1" } + }, + events: { + press: {} + } + }, + designtime: "library/n/designtime/Button.designtime", + renderer: { + apiVersion: 2, + render: function(oRm, oButton) { + oRm.openStart("button", oButton); + oRm.class("libNBtnBase"); + oRm.openEnd(); + if ( oButton.getIcon() ) { + oRm.renderControl(oButton.getIcon()); + } + oRm.openStart("span", oButton.getId() + "-content"); + oRm.class("libNBtnContent"); + oRm.openEnd(); + oRm.text(sText); + oRm.close("span"); + oRm.close("button"); + } + } + }); + +}); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js b/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js new file mode 100644 index 000000000..f42a60c9e --- /dev/null +++ b/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js @@ -0,0 +1,27 @@ +/*! + * ${copyright} + */ + +sap.ui.define([ + "sap/ui/core/util/reflection/JsControlTreeModifier" +], function ( + JsControlTreeModifier +) { + "use strict"; + + var ButtonCH = {}; + + SplitButton.applyChange = function(oChange, oControl, mPropertyBag) { + if (mPropertyBag.modifier.targets !== "jsControlTree") { + throw new Error("SplitButton change can't be applied on XML tree"); + } + return true; + }; + + SplitButton.revertChange = function(oChange, oControl, mPropertyBag) { + oChange.resetRevertData(); + return true; + }; + + return ButtonCH; +}); diff --git a/test/fixtures/library.n/src/library/n/designtime/Button.create.fragment.xml b/test/fixtures/library.n/src/library/n/designtime/Button.create.fragment.xml new file mode 100644 index 000000000..50988ae74 --- /dev/null +++ b/test/fixtures/library.n/src/library/n/designtime/Button.create.fragment.xml @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js b/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js new file mode 100644 index 000000000..d6d669833 --- /dev/null +++ b/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js @@ -0,0 +1,43 @@ +/*! + * ${copyright} + */ + +// Provides the Design Time Metadata for the library.n.Button control +sap.ui.define([], + function () { + "use strict"; + + return { + palette: { + group: "ACTION", + icons: { + svg: "library/n/designtime/Button.icon.svg" + } + }, + actions: { + combine: { + changeType: "combineButtons", + changeOnRelevantContainer : true, + isEnabled : true + }, + remove: { + changeType: "hideControl" + }, + split: { + changeType: "split" + }, + rename: { + changeType: "rename", + domRef: function (oControl) { + return oControl.$().find(".libNBtnContent")[0]; + } + }, + reveal: { + changeType: "unhideControl" + } + }, + templates: { + create: "library/n/designtime/Button.create.fragment.xml" + } + }; + }); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/designtime/Button.icon.svg b/test/fixtures/library.n/src/library/n/designtime/Button.icon.svg new file mode 100644 index 000000000..db8fc2011 --- /dev/null +++ b/test/fixtures/library.n/src/library/n/designtime/Button.icon.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/test/fixtures/library.n/src/library/n/designtime/library.designtime.js b/test/fixtures/library.n/src/library/n/designtime/library.designtime.js new file mode 100644 index 000000000..6c8c315f3 --- /dev/null +++ b/test/fixtures/library.n/src/library/n/designtime/library.designtime.js @@ -0,0 +1,8 @@ +/*! + * ${copyright} + */ + +sap.ui.define([], function() { + "use strict"; + return {}; +}); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js b/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js new file mode 100644 index 000000000..bbce17aea --- /dev/null +++ b/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js @@ -0,0 +1,20 @@ +/*! + * ${copyright} + */ + +sap.ui.define([ + "sap/ui/fl/changeHandler/BaseRename", + "../changeHandler/SplitButton" +], function (BaseRename, SplitButton) { + "use strict"; + + return { + "hideControl": "default", + "split": SplitButton, + "rename": BaseRename.createRenameChangeHandler({ + propertyName: "text", + translationTextType: "XBUT" + }), + "unhideControl": "default" + }; +}); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/library.js b/test/fixtures/library.n/src/library/n/library.js new file mode 100644 index 000000000..292583ba1 --- /dev/null +++ b/test/fixtures/library.n/src/library/n/library.js @@ -0,0 +1,38 @@ +/*! + * ${copyright} + */ + +sap.ui.define([ + 'sap/ui/core/Core', + 'sap/ui/core/library', + 'sap/m/library' +], function( + Core, + coreLibrary, + mobileLibrary +) { + "use strict"; + + // delegate further initialization of this library to the Core + sap.ui.getCore().initLibrary({ + name : "library.n", + version: "${version}", + dependencies : ["sap.ui.core", "sap.m"], + designtime: "library/n/designtime/library.designtime", + types: [], + interfaces: [], + controls: [], + elements: [], + extensions: { + flChangeHandlers: { + "library.n.Button": "library/n/flexibility/Button" + }, + "sap.ui.support": { + publicRules:true, + internalRules:false + } + } + }); + + return sap.m; +}); diff --git a/test/fixtures/library.n/src/library/n/library.support.js b/test/fixtures/library.n/src/library/n/library.support.js new file mode 100644 index 000000000..634d4fa8f --- /dev/null +++ b/test/fixtures/library.n/src/library/n/library.support.js @@ -0,0 +1,21 @@ +/*! + * ${copyright} + */ +sap.ui.define([ + "sap/ui/support/library", + "./rules/Button.support" +], function( + SupportLib, + ButtonSupport, + ) { + "use strict"; + + return { + name: "library.n", + niceName: "Library N", + ruleset: [ + ButtonSupport + ] + }; + +}); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/messagebundle.properties b/test/fixtures/library.n/src/library/n/messagebundle.properties new file mode 100644 index 000000000..2fb1d609b --- /dev/null +++ b/test/fixtures/library.n/src/library/n/messagebundle.properties @@ -0,0 +1 @@ +PRESS=Click! diff --git a/test/fixtures/library.n/src/library/n/messagebundle_de.properties b/test/fixtures/library.n/src/library/n/messagebundle_de.properties new file mode 100644 index 000000000..985400feb --- /dev/null +++ b/test/fixtures/library.n/src/library/n/messagebundle_de.properties @@ -0,0 +1 @@ +PRESS=Hier clicken! diff --git a/test/fixtures/library.n/src/library/n/rules/Button.support.js b/test/fixtures/library.n/src/library/n/rules/Button.support.js new file mode 100644 index 000000000..81e734360 --- /dev/null +++ b/test/fixtures/library.n/src/library/n/rules/Button.support.js @@ -0,0 +1,4 @@ +/*! + * ${copyright} + */ +console.log('HelloWorld'); \ No newline at end of file diff --git a/test/fixtures/library.n/ui5.yaml b/test/fixtures/library.n/ui5.yaml new file mode 100644 index 000000000..648905669 --- /dev/null +++ b/test/fixtures/library.n/ui5.yaml @@ -0,0 +1,5 @@ +--- +specVersion: "0.1" +type: library +metadata: + name: library.m diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index e6da4bc16..c4e3987b3 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -22,6 +22,7 @@ const libraryEPath = path.join(__dirname, "..", "..", "fixtures", "library.e"); const libraryHPath = path.join(__dirname, "..", "..", "fixtures", "library.h"); const libraryIPath = path.join(__dirname, "..", "..", "fixtures", "library.i"); const libraryJPath = path.join(__dirname, "..", "..", "fixtures", "library.j"); +const libraryNPath = path.join(__dirname, "..", "..", "fixtures", "library.n"); const libraryCore = path.join(__dirname, "..", "..", "fixtures", "sap.ui.core-evo"); const themeJPath = path.join(__dirname, "..", "..", "fixtures", "theme.j"); @@ -598,6 +599,28 @@ test("Build theme.j even without an library", (t) => { }); }); +test("Build library.n", (t) => { + const destPath = path.join("test", "tmp", "build", "library.n", "dest"); + const expectedPath = path.join("test", "expected", "build", "library.n", "dest"); + + return builder.build({ + tree: libraryNTree, + destPath, + excludedTasks: ["generateLibraryPreload"] + }).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.serial("Cleanup", async (t) => { const BuildContext = require("../../../lib/builder/BuildContext"); const createProjectContextStub = sinon.spy(BuildContext.prototype, "createProjectContext"); @@ -1311,3 +1334,57 @@ const themeJTree = { } } }; + +const libraryNTree = { + "id": "library.n", + "version": "1.0.0", + "path": libraryNPath, + "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.n", + "namespace": "library/n", + "copyright": "UI development toolkit for HTML5 (OpenUI5)\n * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.\n * Licensed under the Apache License, Version 2.0 - see LICENSE.txt." + }, + "resources": { + "configuration": { + "paths": { + "src": "src", + "test": "test" + }, + "propertiesFileSourceEncoding": "ISO-8859-1" + }, + "pathMappings": { + "/resources/": "src", + "/test-resources/": "test" + } + } +}; + From f0770dc4a2680c84b4b9b69f8e312e909542184f Mon Sep 17 00:00:00 2001 From: Frank Weigel Date: Sun, 29 Dec 2019 22:18:01 +0100 Subject: [PATCH 03/88] Fix issue in dependency handling, improve tests --- lib/processors/resourceListCreator.js | 6 +--- lib/types/library/LibraryBuilder.js | 28 +++++++------------ .../dest/resources/library/n/Button-dbg.js | 9 +++++- .../dest/resources/library/n/Button.js | 2 +- .../dest/resources/library/n/resources.json | 12 ++++++-- .../library.n/src/library/n/Button.js | 9 +++++- 6 files changed, 38 insertions(+), 28 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 653a2a845..1f46b713d 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -146,10 +146,6 @@ class ResourceInfo { } return result; } - - isEmpty() { - return this.i18nLocale == null && this.i18nName == null && this.isDebug == false && this.theme == null && this.merged == false; - } } /** @@ -412,7 +408,7 @@ class ResourceCollector { resourceInfo.condRequired = resourceInfo.condRequired || new Set(); info.dependencies.forEach((dep) => { if ( info.isConditionalDependency(dep) ) { - resourceInfo.condRequired.push(dep); + resourceInfo.condRequired.add(dep); } else if ( !info.isImplicitDependency(dep) ) { resourceInfo.required.add(dep); } diff --git a/lib/types/library/LibraryBuilder.js b/lib/types/library/LibraryBuilder.js index 7ec9bf97f..427c21ee4 100644 --- a/lib/types/library/LibraryBuilder.js +++ b/lib/types/library/LibraryBuilder.js @@ -1,22 +1,5 @@ const AbstractBuilder = require("../AbstractBuilder"); -const tasks = { // can't require index.js due to circular dependency - generateComponentPreload: require("../../tasks/bundlers/generateComponentPreload"), - generateFlexChangesBundle: require("../../tasks/bundlers/generateFlexChangesBundle"), - generateBundle: require("../../tasks/bundlers/generateBundle"), - generateLibraryPreload: require("../../tasks/bundlers/generateLibraryPreload"), - generateManifestBundle: require("../../tasks/bundlers/generateManifestBundle"), - generateStandaloneAppBundle: require("../../tasks/bundlers/generateStandaloneAppBundle"), - escapeNonAsciiCharacters: require("../../tasks/escapeNonAsciiCharacters"), - buildThemes: require("../../tasks/buildThemes"), - createDebugFiles: require("../../tasks/createDebugFiles"), - generateJsdoc: require("../../tasks/jsdoc/generateJsdoc"), - executeJsdocSdkTransformation: require("../../tasks/jsdoc/executeJsdocSdkTransformation"), - generateLibraryManifest: require("../../tasks/generateLibraryManifest"), - generateVersionInfo: require("../../tasks/generateVersionInfo"), - replaceCopyright: require("../../tasks/replaceCopyright"), - replaceVersion: require("../../tasks/replaceVersion"), - uglify: require("../../tasks/uglify") -}; +const {getTask} = require("../../tasks/taskRepository"); class LibraryBuilder extends AbstractBuilder { addStandardTasks({resourceCollections, project, log, taskUtil}) { @@ -194,6 +177,15 @@ class LibraryBuilder extends AbstractBuilder { } }); }); + + this.addTask("generateResourcesJson", () => { + return getTask("generateResourcesJson").task({ + workspace: resourceCollections.workspace, + dependencies: resourceCollections.dependencies, + options: { + } + }); + }); } } diff --git a/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js b/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js index ca43eff95..274df4a28 100644 --- a/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js @@ -14,7 +14,7 @@ sap.ui.define([ ) { "use strict"; - return Control.extend("library.n.Button", { + return Control.extend("library.n.Button", { metadata : { library : "library.n", properties : { @@ -44,6 +44,13 @@ sap.ui.define([ oRm.close("span"); oRm.close("button"); } + }, + helper: function(sCalendarType) { + var sCalendar = "sap/ui/core/date/" + sCalendarType; + sap.ui.require(["sap/ui/core/format/DateFormat", sCalendar], function(DateFormat, Calendar) { + DateFormat.getInstance(); + new Calendar(); + }); } }); diff --git a/test/expected/build/library.n/dest/resources/library/n/Button.js b/test/expected/build/library.n/dest/resources/library/n/Button.js index 9b2547fdf..58360358b 100644 --- a/test/expected/build/library.n/dest/resources/library/n/Button.js +++ b/test/expected/build/library.n/dest/resources/library/n/Button.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["./library","sap/ui/core/Control"],function(e,t){"use strict";return t.extend("library.n.Button",{metadata:{library:"library.n",properties:{text:{type:"string",group:"Misc",defaultValue:""}},aggregations:{icon:{type:"sap.ui.core.Control",cardinality:"0..1"}},events:{press:{}}},designtime:"library/n/designtime/Button.designtime",renderer:{apiVersion:2,render:function(e,t){e.openStart("button",t);e.class("libNBtnBase");e.openEnd();if(t.getIcon()){e.renderControl(t.getIcon())}e.openStart("span",t.getId()+"-content");e.class("libNBtnContent");e.openEnd();e.text(sText);e.close("span");e.close("button")}}})}); \ No newline at end of file +sap.ui.define(["./library","sap/ui/core/Control"],function(e,t){"use strict";return t.extend("library.n.Button",{metadata:{library:"library.n",properties:{text:{type:"string",group:"Misc",defaultValue:""}},aggregations:{icon:{type:"sap.ui.core.Control",cardinality:"0..1"}},events:{press:{}}},designtime:"library/n/designtime/Button.designtime",renderer:{apiVersion:2,render:function(e,t){e.openStart("button",t);e.class("libNBtnBase");e.openEnd();if(t.getIcon()){e.renderControl(t.getIcon())}e.openStart("span",t.getId()+"-content");e.class("libNBtnContent");e.openEnd();e.text(sText);e.close("span");e.close("button")}},helper:function(e){var t="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",t],function(e,t){e.getInstance();new t})}})}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/resources.json b/test/expected/build/library.n/dest/resources/library/n/resources.json index da7f5a806..659f88e8f 100644 --- a/test/expected/build/library.n/dest/resources/library/n/resources.json +++ b/test/expected/build/library.n/dest/resources/library/n/resources.json @@ -11,7 +11,11 @@ "required": [ "library/n/library.js", "sap/ui/core/Control.js" - ] + ], + "condRequired": [ + "sap/ui/core/format/DateFormat.js" + ], + "dynRequired": true }, { "name": "Button.js", @@ -19,7 +23,11 @@ "required": [ "library/n/library.js", "sap/ui/core/Control.js" - ] + ], + "condRequired": [ + "sap/ui/core/format/DateFormat.js" + ], + "dynRequired": true }, { "name": "changeHandler/SplitButton-dbg.js", diff --git a/test/fixtures/library.n/src/library/n/Button.js b/test/fixtures/library.n/src/library/n/Button.js index 7259cde38..70f7b4918 100644 --- a/test/fixtures/library.n/src/library/n/Button.js +++ b/test/fixtures/library.n/src/library/n/Button.js @@ -12,7 +12,7 @@ sap.ui.define([ ) { "use strict"; - return Control.extend("library.n.Button", { + return Control.extend("library.n.Button", { metadata : { library : "library.n", properties : { @@ -42,6 +42,13 @@ sap.ui.define([ oRm.close("span"); oRm.close("button"); } + }, + helper: function(sCalendarType) { + var sCalendar = "sap/ui/core/date/" + sCalendarType; + sap.ui.require(["sap/ui/core/format/DateFormat", sCalendar], function(DateFormat, Calendar) { + DateFormat.getInstance(); + new Calendar(); + }); } }); From 4f229bb8c5bbde8824686e5a5e67d1fe0adb84af Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 22 Jun 2020 15:19:15 +0200 Subject: [PATCH 04/88] fixed jsdoc and taskRepository --- lib/tasks/generateResourcesJson.js | 4 ++-- lib/tasks/taskRepository.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index d5c2cea04..030e2e735 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -15,10 +15,10 @@ const DEFAULT_EXCLUDES = [ * * @public * @alias module:@ui5/builder.tasks.generateResourcesJson - * @param {Object} parameters Parameters + * @param {object} parameters Parameters * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files * @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files - * @param {Object} parameters.options Options + * @param {object} parameters.options Options * @param {string} parameters.options.projectName Project name * @returns {Promise} Promise resolving with undefined once data has been written */ diff --git a/lib/tasks/taskRepository.js b/lib/tasks/taskRepository.js index 7174c7036..aa45af249 100644 --- a/lib/tasks/taskRepository.js +++ b/lib/tasks/taskRepository.js @@ -14,7 +14,7 @@ const taskInfos = { generateManifestBundle: {path: "./bundlers/generateManifestBundle"}, generateFlexChangesBundle: {path: "./bundlers/generateFlexChangesBundle"}, generateComponentPreload: {path: "./bundlers/generateComponentPreload"}, - generateResourcesJson: require("./generateResourcesJson"), + generateResourcesJson: {path: "./generateResourcesJson"}, generateStandaloneAppBundle: {path: "./bundlers/generateStandaloneAppBundle"}, generateBundle: {path: "./bundlers/generateBundle"}, generateLibraryPreload: {path: "./bundlers/generateLibraryPreload"}, From 492e26751567333b9df58e58db25b72f5e9ae5cd Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 23 Jun 2020 12:27:43 +0200 Subject: [PATCH 05/88] add size information --- lib/processors/resourceListCreator.js | 41 +++++++++++++++-- .../dest/resources/library/d/resources.json | 12 +++-- .../dest/resources/library/e/resources.json | 18 +++++--- .../library/h/components/resources.json | 11 ++++- .../h/components/subcomponent1/resources.json | 2 + .../h/components/subcomponent2/resources.json | 2 + .../h/components/subcomponent3/resources.json | 2 + .../dest/resources/library/h/resources.json | 30 ++++++++++--- .../dest/resources/library/i/resources.json | 7 ++- .../dest/resources/library/n/resources.json | 44 ++++++++++++++----- .../j/themes/somefancytheme/resources.json | 15 ++++--- 11 files changed, 145 insertions(+), 39 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 1f46b713d..3af91cecf 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -55,6 +55,13 @@ class LocatorResourcePool extends ResourcePool { * @since 1.33.0 */ class ResourceInfo { + get size() { + return this._size; + } + + set size(value) { + this._size = value; + } constructor(name) { this.name = name; this.i18nName = null; @@ -69,6 +76,7 @@ class ResourceInfo { this.condRequired = null; this.included = null; this.dynRequired = false; + this._size = 0; } copyFrom(prefix, orig) { @@ -79,6 +87,7 @@ class ResourceInfo { this.merged = orig.merged; this.designtime = orig.designtime; this.support = orig.support; + this.size = orig.size; if ( this.module == null ) { this.module = orig.module; } @@ -132,6 +141,9 @@ class ResourceInfo { if ( this.theme != null ) { result.theme = this.theme; } + if ( this.size > 0 ) { + result.size = this.size; + } if ( this.required != null && this.required.size > 0 ) { result.required = [...this.required].sort(); } @@ -184,6 +196,7 @@ class ResourcesList { } if ( myInfo == null ) { myInfo = new ResourceInfo(relativeName); + myInfo.size = info.size; this.resources.push(myInfo); this.resourcesByName.set(relativeName, myInfo); } @@ -371,14 +384,22 @@ class ResourceCollector { this._externalResources = list; } - visitResource(virPath) { + /** + * Processes a resource + * + * @param {string} virPath virtual path of the resource + * @param {number} sizeBytes size in bytes + */ + visitResource(virPath, sizeBytes) { if ( !virPath.startsWith("/resources/") ) { log.warn(`non-runtime resource ${virPath} ignored`); return; } const name = virPath.slice("/resources/".length); if ( this._filter.matches(name) ) { - this._resources.set(name, new ResourceInfo(name)); + const resource = new ResourceInfo(name); + resource.size = sizeBytes; + this._resources.set(name, resource); const p = name.lastIndexOf("/"); const prefix = name.substring(0, p + 1); @@ -577,6 +598,15 @@ class ResourceCollector { * @since 1.29.1 */ + +const getResourceSize = async (resource) => { + if (resource.getStatInfo().size !== undefined) { + return resource.getStatInfo().size; + } + const content = await resource.getString(); + return Buffer.byteLength(content, "utf8"); +}; + module.exports = async function({resources, dependencyResources}, options) { options = Object.assign({ failOnOrphans: true, @@ -591,7 +621,12 @@ module.exports = async function({resources, dependencyResources}, options) { await pool.prepare( resources.concat(dependencyResources) ); const collector = new ResourceCollector(pool); - resources.forEach((resource) => collector.visitResource(resource.getPath())); + const visitorsPromise = resources.map((resource) => { + return getResourceSize(resource).then((size) => { + return collector.visitResource(resource.getPath(), size); + }); + }); + await Promise.all(visitorsPromise); log.info(" found %d resources", collector.resources.size); // determine additional information for the found resources diff --git a/test/expected/build/library.d/dest/resources/library/d/resources.json b/test/expected/build/library.d/dest/resources/library/d/resources.json index 101273255..34fd200a8 100644 --- a/test/expected/build/library.d/dest/resources/library/d/resources.json +++ b/test/expected/build/library.d/dest/resources/library/d/resources.json @@ -2,19 +2,23 @@ "_version": "1.1.0", "resources": [ { - "name": ".library" + "name": ".library", + "size": 278 }, { - "name": "manifest.json" + "name": "manifest.json", + "size": 491 }, { "name": "some-dbg.js", "module": "library/d/some.js", - "isDebug": true + "isDebug": true, + "size": 134 }, { "name": "some.js", - "module": "library/d/some.js" + "module": "library/d/some.js", + "size": 134 } ] } \ No newline at end of file diff --git a/test/expected/build/library.e/dest/resources/library/e/resources.json b/test/expected/build/library.e/dest/resources/library/e/resources.json index 941b6e52d..f65cafa76 100644 --- a/test/expected/build/library.e/dest/resources/library/e/resources.json +++ b/test/expected/build/library.e/dest/resources/library/e/resources.json @@ -2,28 +2,34 @@ "_version": "1.1.0", "resources": [ { - "name": ".library" + "name": ".library", + "size": 270 }, { "name": "library-dbg.js", "module": "library/e/library.js", - "isDebug": true + "isDebug": true, + "size": 51 }, { "name": "library.js", - "module": "library/e/library.js" + "module": "library/e/library.js", + "size": 51 }, { - "name": "manifest.json" + "name": "manifest.json", + "size": 443 }, { "name": "some-dbg.js", "module": "library/e/some.js", - "isDebug": true + "isDebug": true, + "size": 50 }, { "name": "some.js", - "module": "library/e/some.js" + "module": "library/e/some.js", + "size": 50 } ] } \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/resources.json index d3a6e34bc..e76ff06f6 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/resources.json @@ -5,6 +5,7 @@ "name": "Component-preload.js", "module": "library/h/components/Component-preload.js", "merged": true, + "size": 361, "included": [ "library/h/components/Component.js", "library/h/components/TodoComponent.js" @@ -13,18 +14,21 @@ { "name": "Component.js", "module": "library/h/components/Component.js", + "size": 146, "required": [ "sap/ui/core/UIComponent.js" ] }, { "name": "TodoComponent.js", - "module": "library/h/components/TodoComponent.js" + "module": "library/h/components/TodoComponent.js", + "size": 47 }, { "name": "subcomponent1/Component-preload.js", "module": "library/h/components/subcomponent1/Component-preload.js", "merged": true, + "size": 279, "included": [ "library/h/components/subcomponent1/Component.js" ] @@ -32,6 +36,7 @@ { "name": "subcomponent1/Component.js", "module": "library/h/components/subcomponent1/Component.js", + "size": 146, "required": [ "sap/ui/core/UIComponent.js" ] @@ -40,6 +45,7 @@ "name": "subcomponent2/Component-preload.js", "module": "library/h/components/subcomponent2/Component-preload.js", "merged": true, + "size": 279, "included": [ "library/h/components/subcomponent2/Component.js" ] @@ -47,6 +53,7 @@ { "name": "subcomponent2/Component.js", "module": "library/h/components/subcomponent2/Component.js", + "size": 146, "required": [ "sap/ui/core/UIComponent.js" ] @@ -55,6 +62,7 @@ "name": "subcomponent3/Component-preload.js", "module": "library/h/components/subcomponent3/Component-preload.js", "merged": true, + "size": 279, "included": [ "library/h/components/subcomponent3/Component.js" ] @@ -62,6 +70,7 @@ { "name": "subcomponent3/Component.js", "module": "library/h/components/subcomponent3/Component.js", + "size": 146, "required": [ "sap/ui/core/UIComponent.js" ] diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json index b50be1417..70697852f 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json @@ -5,6 +5,7 @@ "name": "Component-preload.js", "module": "library/h/components/subcomponent1/Component-preload.js", "merged": true, + "size": 279, "included": [ "library/h/components/subcomponent1/Component.js" ] @@ -12,6 +13,7 @@ { "name": "Component.js", "module": "library/h/components/subcomponent1/Component.js", + "size": 146, "required": [ "sap/ui/core/UIComponent.js" ] diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json index 39a00361e..f22439ed7 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json @@ -5,6 +5,7 @@ "name": "Component-preload.js", "module": "library/h/components/subcomponent2/Component-preload.js", "merged": true, + "size": 279, "included": [ "library/h/components/subcomponent2/Component.js" ] @@ -12,6 +13,7 @@ { "name": "Component.js", "module": "library/h/components/subcomponent2/Component.js", + "size": 146, "required": [ "sap/ui/core/UIComponent.js" ] diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json index 836795791..5bf570961 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json @@ -5,6 +5,7 @@ "name": "Component-preload.js", "module": "library/h/components/subcomponent3/Component-preload.js", "merged": true, + "size": 279, "included": [ "library/h/components/subcomponent3/Component.js" ] @@ -12,6 +13,7 @@ { "name": "Component.js", "module": "library/h/components/subcomponent3/Component.js", + "size": 146, "required": [ "sap/ui/core/UIComponent.js" ] diff --git a/test/expected/build/library.h/dest/resources/library/h/resources.json b/test/expected/build/library.h/dest/resources/library/h/resources.json index db99ed8fa..f6f80ac2b 100644 --- a/test/expected/build/library.h/dest/resources/library/h/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/resources.json @@ -2,12 +2,14 @@ "_version": "1.1.0", "resources": [ { - "name": ".library" + "name": ".library", + "size": 278 }, { "name": "components/Component-preload.js", "module": "library/h/components/Component-preload.js", "merged": true, + "size": 361, "included": [ "library/h/components/Component.js", "library/h/components/TodoComponent.js" @@ -16,18 +18,21 @@ { "name": "components/Component.js", "module": "library/h/components/Component.js", + "size": 146, "required": [ "sap/ui/core/UIComponent.js" ] }, { "name": "components/TodoComponent.js", - "module": "library/h/components/TodoComponent.js" + "module": "library/h/components/TodoComponent.js", + "size": 47 }, { "name": "components/subcomponent1/Component-preload.js", "module": "library/h/components/subcomponent1/Component-preload.js", "merged": true, + "size": 279, "included": [ "library/h/components/subcomponent1/Component.js" ] @@ -35,6 +40,7 @@ { "name": "components/subcomponent1/Component.js", "module": "library/h/components/subcomponent1/Component.js", + "size": 146, "required": [ "sap/ui/core/UIComponent.js" ] @@ -43,6 +49,7 @@ "name": "components/subcomponent2/Component-preload.js", "module": "library/h/components/subcomponent2/Component-preload.js", "merged": true, + "size": 279, "included": [ "library/h/components/subcomponent2/Component.js" ] @@ -50,6 +57,7 @@ { "name": "components/subcomponent2/Component.js", "module": "library/h/components/subcomponent2/Component.js", + "size": 146, "required": [ "sap/ui/core/UIComponent.js" ] @@ -58,6 +66,7 @@ "name": "components/subcomponent3/Component-preload.js", "module": "library/h/components/subcomponent3/Component-preload.js", "merged": true, + "size": 279, "included": [ "library/h/components/subcomponent3/Component.js" ] @@ -65,6 +74,7 @@ { "name": "components/subcomponent3/Component.js", "module": "library/h/components/subcomponent3/Component.js", + "size": 146, "required": [ "sap/ui/core/UIComponent.js" ] @@ -73,6 +83,7 @@ "name": "customBundle.js", "module": "library/h/customBundle.js", "merged": true, + "size": 344, "included": [ "library/h/file.js", "library/h/library.js", @@ -81,22 +92,27 @@ }, { "name": "file.js", - "module": "library/h/file.js" + "module": "library/h/file.js", + "size": 47 }, { "name": "library.js", - "module": "library/h/library.js" + "module": "library/h/library.js", + "size": 50 }, { - "name": "manifest.json" + "name": "manifest.json", + "size": 739 }, { "name": "not.js", - "module": "library/h/not.js" + "module": "library/h/not.js", + "size": 56 }, { "name": "some.js", - "module": "library/h/some.js" + "module": "library/h/some.js", + "size": 47 } ] } \ No newline at end of file diff --git a/test/expected/build/library.i/dest/resources/library/i/resources.json b/test/expected/build/library.i/dest/resources/library/i/resources.json index 50894081d..e2b6cad04 100644 --- a/test/expected/build/library.i/dest/resources/library/i/resources.json +++ b/test/expected/build/library.i/dest/resources/library/i/resources.json @@ -2,17 +2,20 @@ "_version": "1.1.0", "resources": [ { - "name": ".library" + "name": ".library", + "size": 1371 }, { "name": "library.js", "module": "library/i/library.js", + "size": 594, "required": [ "sap/ui/core/Core.js" ] }, { - "name": "manifest.json" + "name": "manifest.json", + "size": 1740 } ] } \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/resources.json b/test/expected/build/library.n/dest/resources/library/n/resources.json index 659f88e8f..d3f3ec6d2 100644 --- a/test/expected/build/library.n/dest/resources/library/n/resources.json +++ b/test/expected/build/library.n/dest/resources/library/n/resources.json @@ -2,12 +2,14 @@ "_version": "1.1.0", "resources": [ { - "name": ".library" + "name": ".library", + "size": 404 }, { "name": "Button-dbg.js", "module": "library/n/Button.js", "isDebug": true, + "size": 1201, "required": [ "library/n/library.js", "sap/ui/core/Control.js" @@ -20,6 +22,7 @@ { "name": "Button.js", "module": "library/n/Button.js", + "size": 1201, "required": [ "library/n/library.js", "sap/ui/core/Control.js" @@ -33,6 +36,7 @@ "name": "changeHandler/SplitButton-dbg.js", "module": "library/n/changeHandler/SplitButton.js", "isDebug": true, + "size": 540, "required": [ "sap/ui/core/util/reflection/JsControlTreeModifier.js" ] @@ -40,6 +44,7 @@ { "name": "changeHandler/SplitButton.js", "module": "library/n/changeHandler/SplitButton.js", + "size": 540, "required": [ "sap/ui/core/util/reflection/JsControlTreeModifier.js" ] @@ -48,12 +53,14 @@ "name": "designtime/Button-dbg.designtime.js", "module": "library/n/designtime/Button.designtime.js", "isDebug": true, - "designtime": true + "designtime": true, + "size": 789 }, { "name": "designtime/Button.create.fragment.xml", "module": "library/n/designtime/Button.create.fragment.xml", "designtime": true, + "size": 172, "required": [ "library/n/Button.js" ] @@ -61,27 +68,32 @@ { "name": "designtime/Button.designtime.js", "module": "library/n/designtime/Button.designtime.js", - "designtime": true + "designtime": true, + "size": 789 }, { "name": "designtime/Button.icon.svg", - "designtime": true + "designtime": true, + "size": 1386 }, { "name": "designtime/library-dbg.designtime.js", "module": "library/n/designtime/library.designtime.js", "isDebug": true, - "designtime": true + "designtime": true, + "size": 86 }, { "name": "designtime/library.designtime.js", "module": "library/n/designtime/library.designtime.js", - "designtime": true + "designtime": true, + "size": 86 }, { "name": "flexibility/Button.flexibility-dbg.js", "module": "library/n/flexibility/Button.flexibility.js", "isDebug": true, + "size": 379, "required": [ "library/n/changeHandler/SplitButton.js", "sap/ui/fl/changeHandler/BaseRename.js" @@ -90,6 +102,7 @@ { "name": "flexibility/Button.flexibility.js", "module": "library/n/flexibility/Button.flexibility.js", + "size": 379, "required": [ "library/n/changeHandler/SplitButton.js", "sap/ui/fl/changeHandler/BaseRename.js" @@ -99,6 +112,7 @@ "name": "library-dbg.js", "module": "library/n/library.js", "isDebug": true, + "size": 681, "required": [ "sap/m/library.js", "sap/ui/core/Core.js", @@ -110,6 +124,7 @@ "module": "library/n/library.support.js", "isDebug": true, "support": true, + "size": 256, "required": [ "library/n/rules/Button.support.js", "sap/ui/support/library.js" @@ -118,6 +133,7 @@ { "name": "library.js", "module": "library/n/library.js", + "size": 681, "required": [ "sap/m/library.js", "sap/ui/core/Core.js", @@ -128,34 +144,40 @@ "name": "library.support.js", "module": "library/n/library.support.js", "support": true, + "size": 256, "required": [ "library/n/rules/Button.support.js", "sap/ui/support/library.js" ] }, { - "name": "manifest.json" + "name": "manifest.json", + "size": 708 }, { "name": "messagebundle.properties", "locale": "", - "raw": "messagebundle.properties" + "raw": "messagebundle.properties", + "size": 13 }, { "name": "messagebundle_de.properties", "locale": "de", - "raw": "messagebundle.properties" + "raw": "messagebundle.properties", + "size": 20 }, { "name": "rules/Button-dbg.support.js", "module": "library/n/rules/Button.support.js", "isDebug": true, - "support": true + "support": true, + "size": 50 }, { "name": "rules/Button.support.js", "module": "library/n/rules/Button.support.js", - "support": true + "support": true, + "size": 50 } ] } \ No newline at end of file diff --git a/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json b/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json index a113b66df..43be440a0 100644 --- a/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json +++ b/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json @@ -4,24 +4,29 @@ { "name": "Button.less", "designtime": true, - "theme": "somefancytheme" + "theme": "somefancytheme", + "size": 34 }, { "name": "library-RTL.css", - "theme": "somefancytheme" + "theme": "somefancytheme", + "size": 162 }, { "name": "library-parameters.json", - "theme": "somefancytheme" + "theme": "somefancytheme", + "size": 20 }, { "name": "library.css", - "theme": "somefancytheme" + "theme": "somefancytheme", + "size": 162 }, { "name": "library.source.less", "designtime": true, - "theme": "somefancytheme" + "theme": "somefancytheme", + "size": 42 } ] } \ No newline at end of file From 9faf8ce70a07bca2dfb29e7f9a8e2218ae218513 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 23 Jun 2020 14:57:59 +0200 Subject: [PATCH 06/88] Add additional information to resources.json * requiresTopLevelScope * exposedGlobalNames * format --- lib/processors/resourceListCreator.js | 69 ++++++++++++++++--- .../dest/resources/library/d/resources.json | 6 +- .../dest/resources/library/e/resources.json | 12 ++-- .../library/h/components/resources.json | 3 +- .../dest/resources/library/h/customBundle.js | 6 +- .../dest/resources/library/h/resources.json | 21 ++++-- .../dest/resources/library/h/some.js | 2 +- .../dest/resources/library/n/resources.json | 6 +- .../library.h/main/src/library/h/some.js | 10 ++- 9 files changed, 102 insertions(+), 33 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 3af91cecf..aa91a7dcb 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -55,13 +55,6 @@ class LocatorResourcePool extends ResourcePool { * @since 1.33.0 */ class ResourceInfo { - get size() { - return this._size; - } - - set size(value) { - this._size = value; - } constructor(name) { this.name = name; this.i18nName = null; @@ -76,9 +69,26 @@ class ResourceInfo { this.condRequired = null; this.included = null; this.dynRequired = false; - this._size = 0; + this.requiresTopLevelScope = false; + this.exposedGlobalNames = null; + this.format = null; + this._size = -1; } + get size() { + return this._size; + } + + set size(value) { + this._size = value; + } + + /** + * Copies the properties of the given ResourceInfo into this + * + * @param {string} prefix + * @param {ResourceInfo} orig + */ copyFrom(prefix, orig) { this.i18nName = orig.i18nName == null ? null : ResourcesList.makePathRelativeTo(prefix, orig.i18nName); this.i18nLocale = orig.i18nLocale; @@ -87,7 +97,6 @@ class ResourceInfo { this.merged = orig.merged; this.designtime = orig.designtime; this.support = orig.support; - this.size = orig.size; if ( this.module == null ) { this.module = orig.module; } @@ -103,7 +112,9 @@ class ResourceInfo { } orig.condRequired.forEach(this.condRequired.add, this.condRequired); } - this.dynRequired = orig.dynRequired; + if ( orig.dynRequired ) { + this.dynRequired = orig.dynRequired; + } if ( orig.included != null ) { if ( this.included == null ) { this.included = new Set(); @@ -113,6 +124,21 @@ class ResourceInfo { if ( this.included != null && this.included.size > 0 ) { this.merged = true; } + if (orig.size > 0) { + this.size = orig.size; + } + if ( orig.requiresTopLevelScope ) { + this.requiresTopLevelScope = orig.requiresTopLevelScope; + } + if ( orig.exposedGlobalNames != null ) { + if ( this.exposedGlobalNames == null ) { + this.exposedGlobalNames = new Set(); + } + orig.exposedGlobalNames.forEach(this.exposedGlobalNames.add, this.exposedGlobalNames); + } + if ( orig.format != null ) { + this.format = orig.format; + } } toJSON() { @@ -156,6 +182,15 @@ class ResourceInfo { if ( this.included != null && this.included.size > 0 ) { result.included = [...this.included]; } + if ( this.requiresTopLevelScope ) { + result.requiresTopLevelScope = this.requiresTopLevelScope; + } + if ( this.exposedGlobalNames != null && this.exposedGlobalNames.size > 0 ) { + result.exposedGlobals = [...this.exposedGlobalNames]; + } + if ( this.format ) { + result.format = this.format; + } return result; } } @@ -441,6 +476,20 @@ class ResourceCollector { resourceInfo.included.add(mod); }); } + + if (info.requiresTopLevelScope) { + resourceInfo.requiresTopLevelScope = true; + } + if (info.exposedGlobals != null && info.exposedGlobals.length) { + resourceInfo.exposedGlobalNames = resourceInfo.exposedGlobalNames || new Set(); + info.exposedGlobals.forEach((exposedGlobalName) => { + resourceInfo.exposedGlobalNames.add(exposedGlobalName); + }); + } + + if (info.rawModule) { + resourceInfo.format = "raw"; + } }); } diff --git a/test/expected/build/library.d/dest/resources/library/d/resources.json b/test/expected/build/library.d/dest/resources/library/d/resources.json index 34fd200a8..3ab29492e 100644 --- a/test/expected/build/library.d/dest/resources/library/d/resources.json +++ b/test/expected/build/library.d/dest/resources/library/d/resources.json @@ -13,12 +13,14 @@ "name": "some-dbg.js", "module": "library/d/some.js", "isDebug": true, - "size": 134 + "size": 134, + "format": "raw" }, { "name": "some.js", "module": "library/d/some.js", - "size": 134 + "size": 134, + "format": "raw" } ] } \ No newline at end of file diff --git a/test/expected/build/library.e/dest/resources/library/e/resources.json b/test/expected/build/library.e/dest/resources/library/e/resources.json index f65cafa76..f4d7d7e78 100644 --- a/test/expected/build/library.e/dest/resources/library/e/resources.json +++ b/test/expected/build/library.e/dest/resources/library/e/resources.json @@ -9,12 +9,14 @@ "name": "library-dbg.js", "module": "library/e/library.js", "isDebug": true, - "size": 51 + "size": 51, + "format": "raw" }, { "name": "library.js", "module": "library/e/library.js", - "size": 51 + "size": 51, + "format": "raw" }, { "name": "manifest.json", @@ -24,12 +26,14 @@ "name": "some-dbg.js", "module": "library/e/some.js", "isDebug": true, - "size": 50 + "size": 50, + "format": "raw" }, { "name": "some.js", "module": "library/e/some.js", - "size": 50 + "size": 50, + "format": "raw" } ] } \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/resources.json index e76ff06f6..d11df21f8 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/resources.json @@ -22,7 +22,8 @@ { "name": "TodoComponent.js", "module": "library/h/components/TodoComponent.js", - "size": 47 + "size": 47, + "format": "raw" }, { "name": "subcomponent1/Component-preload.js", diff --git a/test/expected/build/library.h/dest/resources/library/h/customBundle.js b/test/expected/build/library.h/dest/resources/library/h/customBundle.js index 21db087bb..5859d335b 100644 --- a/test/expected/build/library.h/dest/resources/library/h/customBundle.js +++ b/test/expected/build/library.h/dest/resources/library/h/customBundle.js @@ -10,9 +10,5 @@ console.log(" File "); */ console.log(" Library "); }, - "library/h/some.js":function(){/*! - * Some fancy copyright - */ -console.log(" Some "); -} + "library/h/some.js":'/*!\n * Some fancy copyright\n */\nvar myexport=function(){"use strict";String("asd")}();' }); diff --git a/test/expected/build/library.h/dest/resources/library/h/resources.json b/test/expected/build/library.h/dest/resources/library/h/resources.json index f6f80ac2b..0e695f026 100644 --- a/test/expected/build/library.h/dest/resources/library/h/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/resources.json @@ -26,7 +26,8 @@ { "name": "components/TodoComponent.js", "module": "library/h/components/TodoComponent.js", - "size": 47 + "size": 47, + "format": "raw" }, { "name": "components/subcomponent1/Component-preload.js", @@ -83,7 +84,7 @@ "name": "customBundle.js", "module": "library/h/customBundle.js", "merged": true, - "size": 344, + "size": 368, "included": [ "library/h/file.js", "library/h/library.js", @@ -93,12 +94,14 @@ { "name": "file.js", "module": "library/h/file.js", - "size": 47 + "size": 47, + "format": "raw" }, { "name": "library.js", "module": "library/h/library.js", - "size": 50 + "size": 50, + "format": "raw" }, { "name": "manifest.json", @@ -107,12 +110,18 @@ { "name": "not.js", "module": "library/h/not.js", - "size": 56 + "size": 56, + "format": "raw" }, { "name": "some.js", "module": "library/h/some.js", - "size": 47 + "size": 101, + "requiresTopLevelScope": true, + "exposedGlobals": [ + "myexport" + ], + "format": "raw" } ] } \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/some.js b/test/expected/build/library.h/dest/resources/library/h/some.js index 98e1e6665..9b135171d 100644 --- a/test/expected/build/library.h/dest/resources/library/h/some.js +++ b/test/expected/build/library.h/dest/resources/library/h/some.js @@ -1,4 +1,4 @@ /*! * Some fancy copyright */ -console.log(" Some "); \ No newline at end of file +var myexport=function(){"use strict";String("asd")}(); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/resources.json b/test/expected/build/library.n/dest/resources/library/n/resources.json index d3f3ec6d2..e3bf21541 100644 --- a/test/expected/build/library.n/dest/resources/library/n/resources.json +++ b/test/expected/build/library.n/dest/resources/library/n/resources.json @@ -171,13 +171,15 @@ "module": "library/n/rules/Button.support.js", "isDebug": true, "support": true, - "size": 50 + "size": 50, + "format": "raw" }, { "name": "rules/Button.support.js", "module": "library/n/rules/Button.support.js", "support": true, - "size": 50 + "size": 50, + "format": "raw" } ] } \ No newline at end of file diff --git a/test/fixtures/library.h/main/src/library/h/some.js b/test/fixtures/library.h/main/src/library/h/some.js index f14efacd4..dffe6bd28 100644 --- a/test/fixtures/library.h/main/src/library/h/some.js +++ b/test/fixtures/library.h/main/src/library/h/some.js @@ -1,4 +1,10 @@ /*! - * ${copyright} + * Some fancy copyright */ -console.log(' Some '); +var myexport = (function() { + + "use strict"; + + String("asd"); + +}()); From 97cd12bcbe3d8b418d587c93fcafd7484edbf78d Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 24 Jun 2020 10:52:18 +0200 Subject: [PATCH 07/88] Fix size for compressed files Use always buffer bytelength because this reflect the correct size --- lib/processors/resourceListCreator.js | 10 ++++-- .../dest/resources/library/d/resources.json | 6 ++-- .../dest/resources/library/e/resources.json | 10 +++--- .../library/h/components/resources.json | 10 +++--- .../h/components/subcomponent1/resources.json | 2 +- .../h/components/subcomponent2/resources.json | 2 +- .../h/components/subcomponent3/resources.json | 2 +- .../dest/resources/library/h/resources.json | 20 +++++------ .../dest/resources/library/i/resources.json | 4 +-- .../dest/resources/library/n/resources.json | 34 +++++++++---------- 10 files changed, 53 insertions(+), 47 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index aa91a7dcb..54c624438 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -649,11 +649,17 @@ class ResourceCollector { const getResourceSize = async (resource) => { + try { + const content = await resource.getString(); + return Buffer.byteLength(content, "utf8"); + } catch (e) { + // ignore error + } + if (resource.getStatInfo().size !== undefined) { return resource.getStatInfo().size; } - const content = await resource.getString(); - return Buffer.byteLength(content, "utf8"); + return -1; }; module.exports = async function({resources, dependencyResources}, options) { diff --git a/test/expected/build/library.d/dest/resources/library/d/resources.json b/test/expected/build/library.d/dest/resources/library/d/resources.json index 3ab29492e..d4a592dc7 100644 --- a/test/expected/build/library.d/dest/resources/library/d/resources.json +++ b/test/expected/build/library.d/dest/resources/library/d/resources.json @@ -3,7 +3,7 @@ "resources": [ { "name": ".library", - "size": 278 + "size": 273 }, { "name": "manifest.json", @@ -13,13 +13,13 @@ "name": "some-dbg.js", "module": "library/d/some.js", "isDebug": true, - "size": 134, + "size": 142, "format": "raw" }, { "name": "some.js", "module": "library/d/some.js", - "size": 134, + "size": 86, "format": "raw" } ] diff --git a/test/expected/build/library.e/dest/resources/library/e/resources.json b/test/expected/build/library.e/dest/resources/library/e/resources.json index f4d7d7e78..57e89ca88 100644 --- a/test/expected/build/library.e/dest/resources/library/e/resources.json +++ b/test/expected/build/library.e/dest/resources/library/e/resources.json @@ -3,19 +3,19 @@ "resources": [ { "name": ".library", - "size": 270 + "size": 426 }, { "name": "library-dbg.js", "module": "library/e/library.js", "isDebug": true, - "size": 51, + "size": 212, "format": "raw" }, { "name": "library.js", "module": "library/e/library.js", - "size": 51, + "size": 211, "format": "raw" }, { @@ -26,13 +26,13 @@ "name": "some-dbg.js", "module": "library/e/some.js", "isDebug": true, - "size": 50, + "size": 211, "format": "raw" }, { "name": "some.js", "module": "library/e/some.js", - "size": 50, + "size": 211, "format": "raw" } ] diff --git a/test/expected/build/library.h/dest/resources/library/h/components/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/resources.json index d11df21f8..0c4f0d3e3 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/resources.json @@ -14,7 +14,7 @@ { "name": "Component.js", "module": "library/h/components/Component.js", - "size": 146, + "size": 115, "required": [ "sap/ui/core/UIComponent.js" ] @@ -22,7 +22,7 @@ { "name": "TodoComponent.js", "module": "library/h/components/TodoComponent.js", - "size": 47, + "size": 54, "format": "raw" }, { @@ -37,7 +37,7 @@ { "name": "subcomponent1/Component.js", "module": "library/h/components/subcomponent1/Component.js", - "size": 146, + "size": 115, "required": [ "sap/ui/core/UIComponent.js" ] @@ -54,7 +54,7 @@ { "name": "subcomponent2/Component.js", "module": "library/h/components/subcomponent2/Component.js", - "size": 146, + "size": 115, "required": [ "sap/ui/core/UIComponent.js" ] @@ -71,7 +71,7 @@ { "name": "subcomponent3/Component.js", "module": "library/h/components/subcomponent3/Component.js", - "size": 146, + "size": 115, "required": [ "sap/ui/core/UIComponent.js" ] diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json index 70697852f..75b3a4fea 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json @@ -13,7 +13,7 @@ { "name": "Component.js", "module": "library/h/components/subcomponent1/Component.js", - "size": 146, + "size": 115, "required": [ "sap/ui/core/UIComponent.js" ] diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json index f22439ed7..99149a2a2 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json @@ -13,7 +13,7 @@ { "name": "Component.js", "module": "library/h/components/subcomponent2/Component.js", - "size": 146, + "size": 115, "required": [ "sap/ui/core/UIComponent.js" ] diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json index 5bf570961..e77b9a5a1 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json @@ -13,7 +13,7 @@ { "name": "Component.js", "module": "library/h/components/subcomponent3/Component.js", - "size": 146, + "size": 115, "required": [ "sap/ui/core/UIComponent.js" ] diff --git a/test/expected/build/library.h/dest/resources/library/h/resources.json b/test/expected/build/library.h/dest/resources/library/h/resources.json index 0e695f026..ad9cdc05b 100644 --- a/test/expected/build/library.h/dest/resources/library/h/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/resources.json @@ -3,7 +3,7 @@ "resources": [ { "name": ".library", - "size": 278 + "size": 273 }, { "name": "components/Component-preload.js", @@ -18,7 +18,7 @@ { "name": "components/Component.js", "module": "library/h/components/Component.js", - "size": 146, + "size": 115, "required": [ "sap/ui/core/UIComponent.js" ] @@ -26,7 +26,7 @@ { "name": "components/TodoComponent.js", "module": "library/h/components/TodoComponent.js", - "size": 47, + "size": 54, "format": "raw" }, { @@ -41,7 +41,7 @@ { "name": "components/subcomponent1/Component.js", "module": "library/h/components/subcomponent1/Component.js", - "size": 146, + "size": 115, "required": [ "sap/ui/core/UIComponent.js" ] @@ -58,7 +58,7 @@ { "name": "components/subcomponent2/Component.js", "module": "library/h/components/subcomponent2/Component.js", - "size": 146, + "size": 115, "required": [ "sap/ui/core/UIComponent.js" ] @@ -75,7 +75,7 @@ { "name": "components/subcomponent3/Component.js", "module": "library/h/components/subcomponent3/Component.js", - "size": 146, + "size": 115, "required": [ "sap/ui/core/UIComponent.js" ] @@ -94,13 +94,13 @@ { "name": "file.js", "module": "library/h/file.js", - "size": 47, + "size": 54, "format": "raw" }, { "name": "library.js", "module": "library/h/library.js", - "size": 50, + "size": 57, "format": "raw" }, { @@ -110,13 +110,13 @@ { "name": "not.js", "module": "library/h/not.js", - "size": 56, + "size": 63, "format": "raw" }, { "name": "some.js", "module": "library/h/some.js", - "size": 101, + "size": 86, "requiresTopLevelScope": true, "exposedGlobals": [ "myexport" diff --git a/test/expected/build/library.i/dest/resources/library/i/resources.json b/test/expected/build/library.i/dest/resources/library/i/resources.json index e2b6cad04..f826d45bc 100644 --- a/test/expected/build/library.i/dest/resources/library/i/resources.json +++ b/test/expected/build/library.i/dest/resources/library/i/resources.json @@ -3,12 +3,12 @@ "resources": [ { "name": ".library", - "size": 1371 + "size": 1374 }, { "name": "library.js", "module": "library/i/library.js", - "size": 594, + "size": 597, "required": [ "sap/ui/core/Core.js" ] diff --git a/test/expected/build/library.n/dest/resources/library/n/resources.json b/test/expected/build/library.n/dest/resources/library/n/resources.json index e3bf21541..5f414e920 100644 --- a/test/expected/build/library.n/dest/resources/library/n/resources.json +++ b/test/expected/build/library.n/dest/resources/library/n/resources.json @@ -3,13 +3,13 @@ "resources": [ { "name": ".library", - "size": 404 + "size": 560 }, { "name": "Button-dbg.js", "module": "library/n/Button.js", "isDebug": true, - "size": 1201, + "size": 1362, "required": [ "library/n/library.js", "sap/ui/core/Control.js" @@ -22,7 +22,7 @@ { "name": "Button.js", "module": "library/n/Button.js", - "size": 1201, + "size": 948, "required": [ "library/n/library.js", "sap/ui/core/Control.js" @@ -36,7 +36,7 @@ "name": "changeHandler/SplitButton-dbg.js", "module": "library/n/changeHandler/SplitButton.js", "isDebug": true, - "size": 540, + "size": 701, "required": [ "sap/ui/core/util/reflection/JsControlTreeModifier.js" ] @@ -44,7 +44,7 @@ { "name": "changeHandler/SplitButton.js", "module": "library/n/changeHandler/SplitButton.js", - "size": 540, + "size": 533, "required": [ "sap/ui/core/util/reflection/JsControlTreeModifier.js" ] @@ -54,7 +54,7 @@ "module": "library/n/designtime/Button.designtime.js", "isDebug": true, "designtime": true, - "size": 789 + "size": 950 }, { "name": "designtime/Button.create.fragment.xml", @@ -69,7 +69,7 @@ "name": "designtime/Button.designtime.js", "module": "library/n/designtime/Button.designtime.js", "designtime": true, - "size": 789 + "size": 661 }, { "name": "designtime/Button.icon.svg", @@ -81,19 +81,19 @@ "module": "library/n/designtime/library.designtime.js", "isDebug": true, "designtime": true, - "size": 86 + "size": 247 }, { "name": "designtime/library.designtime.js", "module": "library/n/designtime/library.designtime.js", "designtime": true, - "size": 86 + "size": 237 }, { "name": "flexibility/Button.flexibility-dbg.js", "module": "library/n/flexibility/Button.flexibility.js", "isDebug": true, - "size": 379, + "size": 540, "required": [ "library/n/changeHandler/SplitButton.js", "sap/ui/fl/changeHandler/BaseRename.js" @@ -102,7 +102,7 @@ { "name": "flexibility/Button.flexibility.js", "module": "library/n/flexibility/Button.flexibility.js", - "size": 379, + "size": 445, "required": [ "library/n/changeHandler/SplitButton.js", "sap/ui/fl/changeHandler/BaseRename.js" @@ -112,7 +112,7 @@ "name": "library-dbg.js", "module": "library/n/library.js", "isDebug": true, - "size": 681, + "size": 837, "required": [ "sap/m/library.js", "sap/ui/core/Core.js", @@ -124,7 +124,7 @@ "module": "library/n/library.support.js", "isDebug": true, "support": true, - "size": 256, + "size": 417, "required": [ "library/n/rules/Button.support.js", "sap/ui/support/library.js" @@ -133,7 +133,7 @@ { "name": "library.js", "module": "library/n/library.js", - "size": 681, + "size": 642, "required": [ "sap/m/library.js", "sap/ui/core/Core.js", @@ -144,7 +144,7 @@ "name": "library.support.js", "module": "library/n/library.support.js", "support": true, - "size": 256, + "size": 338, "required": [ "library/n/rules/Button.support.js", "sap/ui/support/library.js" @@ -171,14 +171,14 @@ "module": "library/n/rules/Button.support.js", "isDebug": true, "support": true, - "size": 50, + "size": 211, "format": "raw" }, { "name": "rules/Button.support.js", "module": "library/n/rules/Button.support.js", "support": true, - "size": 50, + "size": 211, "format": "raw" } ] From 071c3e30dba642d679cef0d761db48af991e1823 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 24 Jun 2020 14:12:26 +0200 Subject: [PATCH 08/88] Refactoring Refactored LocatorResource and LocatorResourcePool into separate files under lbt folder removed unused getProject function --- lib/lbt/LocatorResource.js | 20 +++++++++++ lib/lbt/LocatorResourcePool.js | 24 +++++++++++++ lib/processors/bundlers/moduleBundler.js | 40 +-------------------- lib/processors/resourceListCreator.js | 45 ++---------------------- 4 files changed, 48 insertions(+), 81 deletions(-) create mode 100644 lib/lbt/LocatorResource.js create mode 100644 lib/lbt/LocatorResourcePool.js diff --git a/lib/lbt/LocatorResource.js b/lib/lbt/LocatorResource.js new file mode 100644 index 000000000..8a924a30b --- /dev/null +++ b/lib/lbt/LocatorResource.js @@ -0,0 +1,20 @@ +const Resource = require("./resources/Resource"); + + +function extractName(path) { + return path.slice( "/resources/".length); +} + + +class LocatorResource extends Resource { + constructor(pool, resource) { + super(pool, extractName(resource.getPath()), null, resource.getStatInfo()); + this.resource = resource; + } + + buffer() { + return this.resource.getBuffer(); + } +} + +module.exports = LocatorResource; diff --git a/lib/lbt/LocatorResourcePool.js b/lib/lbt/LocatorResourcePool.js new file mode 100644 index 000000000..851fe28b0 --- /dev/null +++ b/lib/lbt/LocatorResourcePool.js @@ -0,0 +1,24 @@ +const ResourcePool = require("./resources/ResourcePool"); +const LocatorResource = require("./LocatorResource"); + + +class LocatorResourcePool extends ResourcePool { + constructor() { + super(); + } + + prepare(resources) { + resources = resources.filter( (res) => !res.getStatInfo().isDirectory() ); + // console.log(resources.map($ => $.getPath())); + return Promise.all( + resources.map( + (resource) => this.addResource( new LocatorResource(this, resource) ) + ).filter( (followUp) => followUp ) + ); + // .then( () => { + // console.log(" found %d resources", this.size); + // }); + } +} + +module.exports = LocatorResourcePool; diff --git a/lib/processors/bundlers/moduleBundler.js b/lib/processors/bundlers/moduleBundler.js index 673e2e1f8..eef5b4c8d 100644 --- a/lib/processors/bundlers/moduleBundler.js +++ b/lib/processors/bundlers/moduleBundler.js @@ -1,45 +1,7 @@ const BundleBuilder = require("../../lbt/bundle/Builder"); -const Resource = require("../../lbt/resources/Resource"); -const ResourcePool = require("../../lbt/resources/ResourcePool"); +const LocatorResourcePool = require("../../lbt/LocatorResourcePool"); const EvoResource = require("@ui5/fs").Resource; -function extractName(path) { - return path.slice( "/resources/".length); -} - -class LocatorResource extends Resource { - constructor(pool, resource) { - super(pool, extractName(resource.getPath()), null, resource.getStatInfo()); - this.resource = resource; - } - - buffer() { - return this.resource.getBuffer(); - } - - getProject() { - return this.resource._project; - } -} - -class LocatorResourcePool extends ResourcePool { - constructor({ignoreMissingModules}) { - super({ignoreMissingModules}); - } - - prepare(resources) { - resources = resources.filter( (res) => !res.getStatInfo().isDirectory() ); - // console.log(resources.map($ => $.getPath())); - return Promise.all( - resources.map( - (resource) => this.addResource( new LocatorResource(this, resource) ) - ).filter( (followUp) => followUp ) - ); - // .then( () => { - // console.log(" found %d resources", this.size); - // }); - } -} /** * A ModuleBundleDefinitionSection specifies the embedding mode ('provided', 'raw', 'preload' or 'require') diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 54c624438..a72dcf440 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -2,51 +2,12 @@ const log = require("@ui5/logger").getLogger("builder:processors:resourceListCreator"); const ResourceFilterList = require("../lbt/resources/ResourceFilterList"); -const Resource = require("../lbt/resources/Resource"); -const ResourcePool = require("../lbt/resources/ResourcePool"); -const EvoResource = require("@ui5/fs").Resource; - -const DEBUG_RESOURCES_PATTERN = /-dbg((?:\.view|\.fragment|\.controller|\.designtime|\.support)?\.js|\.css)$/; +const LocatorResourcePool = require("../lbt/resources/LocatorResourcePool"); -// TODO share with module bundler - -function extractName(path) { - return path.slice( "/resources/".length); -} - -class LocatorResource extends Resource { - constructor(pool, resource) { - super(pool, extractName(resource.getPath()), null, resource.getStatInfo()); - this.resource = resource; - } - - buffer() { - return this.resource.getBuffer(); - } - getProject() { - return this.resource._project; - } -} - -class LocatorResourcePool extends ResourcePool { - constructor() { - super(); - } +const EvoResource = require("@ui5/fs").Resource; - prepare(resources) { - resources = resources.filter( (res) => !res.getStatInfo().isDirectory() ); - // console.log(resources.map($ => $.getPath())); - return Promise.all( - resources.map( - (resource) => this.addResource( new LocatorResource(this, resource) ) - ).filter( (followUp) => followUp ) - ); - // .then( () => { - // console.log(" found %d resources", this.size); - // }); - } -} +const DEBUG_RESOURCES_PATTERN = /-dbg((?:\.view|\.fragment|\.controller|\.designtime|\.support)?\.js|\.css)$/; /** * Information about a single resource as stored in the resources.json file. From 092f8847dc8c5f8cde2e356a5bac29d5c4f5e9f2 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 24 Jun 2020 15:01:10 +0200 Subject: [PATCH 09/88] Add function getProject used by lib/lbt/utils/escapePropertiesFile.js:14:27 --- lib/lbt/LocatorResource.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/lbt/LocatorResource.js b/lib/lbt/LocatorResource.js index 8a924a30b..b4d47d7c2 100644 --- a/lib/lbt/LocatorResource.js +++ b/lib/lbt/LocatorResource.js @@ -15,6 +15,10 @@ class LocatorResource extends Resource { buffer() { return this.resource.getBuffer(); } + + getProject() { + return this.resource._project; + } } module.exports = LocatorResource; From cc53063b4b9d87f7faccebf853e884b1998c49e5 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 24 Jun 2020 15:20:26 +0200 Subject: [PATCH 10/88] fixed import --- lib/processors/resourceListCreator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index a72dcf440..f31c44764 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -2,7 +2,7 @@ const log = require("@ui5/logger").getLogger("builder:processors:resourceListCreator"); const ResourceFilterList = require("../lbt/resources/ResourceFilterList"); -const LocatorResourcePool = require("../lbt/resources/LocatorResourcePool"); +const LocatorResourcePool = require("../lbt/LocatorResourcePool"); const EvoResource = require("@ui5/fs").Resource; From ee70a855f40c49e8bbfff183f03e0a72d3e73c19 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 25 Jun 2020 08:44:20 +0200 Subject: [PATCH 11/88] updated size retrieval use buffer.length instead of Buffer.byteLength(string) for more performance --- lib/lbt/LocatorResourcePool.js | 2 +- lib/processors/resourceListCreator.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/lbt/LocatorResourcePool.js b/lib/lbt/LocatorResourcePool.js index 851fe28b0..c0cac0a60 100644 --- a/lib/lbt/LocatorResourcePool.js +++ b/lib/lbt/LocatorResourcePool.js @@ -13,7 +13,7 @@ class LocatorResourcePool extends ResourcePool { return Promise.all( resources.map( (resource) => this.addResource( new LocatorResource(this, resource) ) - ).filter( (followUp) => followUp ) + ).filter(Boolean) ); // .then( () => { // console.log(" found %d resources", this.size); diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index f31c44764..6fc6c8e85 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -85,7 +85,7 @@ class ResourceInfo { if ( this.included != null && this.included.size > 0 ) { this.merged = true; } - if (orig.size > 0) { + if (orig.size >= 0) { this.size = orig.size; } if ( orig.requiresTopLevelScope ) { @@ -128,7 +128,7 @@ class ResourceInfo { if ( this.theme != null ) { result.theme = this.theme; } - if ( this.size > 0 ) { + if ( this.size >= 0 ) { result.size = this.size; } if ( this.required != null && this.required.size > 0 ) { @@ -611,8 +611,10 @@ class ResourceCollector { const getResourceSize = async (resource) => { try { - const content = await resource.getString(); - return Buffer.byteLength(content, "utf8"); + // buffer already contains utf8 characters + // therefore there is no need to use Buffer.byteLength(await resource.getString(), "utf8") + const buffer = await resource.getBuffer(); + return buffer.length; } catch (e) { // ignore error } From fc54d2b2b28e6a0be3db30c208dab6f071c93398 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 25 Jun 2020 12:35:28 +0200 Subject: [PATCH 12/88] improved size retrieval code --- lib/processors/resourceListCreator.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 6fc6c8e85..f4c791b0e 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -611,10 +611,10 @@ class ResourceCollector { const getResourceSize = async (resource) => { try { - // buffer already contains utf8 characters - // therefore there is no need to use Buffer.byteLength(await resource.getString(), "utf8") + // this retrieves the byteSize of the resource + // @see https://nodejs.org/api/buffer.html#buffer_class_method_buffer_bytelength_string_encoding const buffer = await resource.getBuffer(); - return buffer.length; + return Buffer.byteLength(buffer); } catch (e) { // ignore error } From de860acf2c4716cbeac9fb994412e7ccc5e89aa5 Mon Sep 17 00:00:00 2001 From: Frank Weigel Date: Thu, 25 Jun 2020 16:16:36 +0200 Subject: [PATCH 13/88] Implement missing handling for orphaned resources. This part was left out in the initial commit, but it is required when building sap.ui.core (where many resources exist outside the library's namespace). More TODOs: - migrate all logs to template strings - filter options of the processor should accept arrays of filter strings, not comma separated strings as in the original Maven implementation --- lib/processors/resourceListCreator.js | 29 +++++++++----------------- lib/tasks/generateResourcesJson.js | 30 ++++++++++++++++++++++++++- lib/types/library/LibraryBuilder.js | 1 + 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index f4c791b0e..2999ce6a4 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -522,33 +522,23 @@ class ResourceCollector { } createOrphanFilters() { - log.verbose(" configured external resources filters (resources outside the namespace): %s", this.externalResources == null ? "(none)" : this.externalResources); + log.verbose( + " configured external resources filters (resources outside the namespace): %s", + this._externalResources == null ? "(none)" : this._externalResources); const filters = new Map(); - if ( this._externalResources != null && !this._externalResources.isEmpty() ) { - /* - Collection componentsToProcess = new HashSet(Arrays.asList(this.externalResources.trim().split("\\s*,\\s*"))); - - for ( String component : componentsToProcess ) { - ResourceFilterList packageFilters = null; - int p = component.indexOf(':'); - if ( p > 0 ) { - String packages = component.substring(p+1).trim(); - component = component.substring(0, p).trim(); - if ( packages != null ) { - packageFilters = new ResourceFilterList().addFilters(packages.trim().split("\\s*;\\s*")); - } - } - if ( component.equals("/") || component.isEmpty() ) { + if ( this._externalResources != null ) { + for ( let component in this._externalResources ) { + const packageFilters = new ResourceFilterList(this._externalResources[component]); + if ( component === "/" || component === "" ) { component = ""; } else if ( !component.endsWith("/") ) { component += "/"; } - log.verbose(" resulting filter list for '%s': '%s'", component, packageFilters); - filters.put(component, packageFilters); + log.verbose(` resulting filter list for '${component}': '${packageFilters}'`); + filters.set(component, packageFilters); } - */ } return filters; } @@ -651,6 +641,7 @@ module.exports = async function({resources, dependencyResources}, options) { if ( options && options.externalResources ) { collector.setExternalResources(options.externalResources); } + await collector.determineResourceDetails({ pool, debugResources: options.debugResources, diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index 030e2e735..f1030ac3b 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -10,6 +10,34 @@ const DEFAULT_EXCLUDES = [ "!**/.gitignore" ]; +function getCreatorOptions(taskOptions) { + const creatorOptions = {}; + if ( taskOptions.projectName === "sap.ui.core" ) { + Object.assign(creatorOptions, { + externalResources: { + "sap/ui/core": [ + "*", + "sap/base/", + "sap/ui/" + ] + }, + mergedResourcesFilters: [ + "jquery-sap*.js", + "sap-ui-core*.js", + "**/Component-preload.js", + "**/library-preload.js", + "**/library-preload-dbg.js", + "**/library-preload.json", + "**/library-all.js", + "**/library-all-dbg.js", + "**/designtime/library-preload.designtime.js", + "**/library-preload.support.js" + ].join(",") + }); + } + return creatorOptions; +} + /** * Task for creating a library resources.json, describing all productive resources in the library. * @@ -41,7 +69,7 @@ module.exports = async function({workspace, dependencies, options}) { return resourceListCreator({ resources, dependencyResources - }).then((resourceLists) => + }, getCreatorOptions(options)).then((resourceLists) => Promise.all( resourceLists.map((resourceList) => workspace.write(resourceList)) ) diff --git a/lib/types/library/LibraryBuilder.js b/lib/types/library/LibraryBuilder.js index 427c21ee4..9e1833037 100644 --- a/lib/types/library/LibraryBuilder.js +++ b/lib/types/library/LibraryBuilder.js @@ -183,6 +183,7 @@ class LibraryBuilder extends AbstractBuilder { workspace: resourceCollections.workspace, dependencies: resourceCollections.dependencies, options: { + projectName: project.metadata.name } }); }); From f92aeee39d260c9861221c4ea3c649594c1a7004 Mon Sep 17 00:00:00 2001 From: Frank Weigel Date: Thu, 25 Jun 2020 16:36:22 +0200 Subject: [PATCH 14/88] Convert log statements to template strings and fix 1 eslint error --- lib/processors/resourceListCreator.js | 39 +++++++++++++-------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 2999ce6a4..62e989882 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -468,7 +468,7 @@ class ResourceCollector { let m; if ( m = LOCALE.exec(name) ) { const baseName = m[1] + m[3]; - log.verbose(" found potential i18n resource '%s', base name is '%s', locale is %s", name, baseName, m[2]); + log.verbose(` found potential i18n resource '${name}', base name is '${baseName}', locale is ${m[2]}`); info.i18nName = baseName; info.i18nLocale = m[2]; baseNames.add(baseName); @@ -479,7 +479,7 @@ class ResourceCollector { if ( this._themePackages.has(m[0]) ) { const theme = m[2]; info.theme = theme; - log.verbose(" found potential theme resource '%s', theme %s", name, theme); + log.verbose(` found potential theme resource '${name}', theme ${theme}`); } } @@ -491,22 +491,22 @@ class ResourceCollector { if ( debugFilter.matches(name) ) { info.isDebug = true; - log.verbose(" found potential debug resource '%s'", name); + log.verbose(` found potential debug resource '${name}'`); } if ( mergeFilter.matches(name) ) { info.merged = true; - log.verbose(" found potential merged resource '%s'", name); + log.verbose(` found potential merged resource '${name}'`); } if ( designtimeFilter.matches(name) ) { info.designtime = true; - log.verbose(" found potential designtime resource '%s'", name); + log.verbose(` found potential designtime resource '${name}'`); } if ( supportFilter.matches(name) ) { info.support = true; - log.verbose(" found potential support resource '%s'", name); + log.verbose(` found potential support resource '${name}'`); } } @@ -523,24 +523,23 @@ class ResourceCollector { createOrphanFilters() { log.verbose( - " configured external resources filters (resources outside the namespace): %s", - this._externalResources == null ? "(none)" : this._externalResources); + ` configured external resources filters (resources outside the namespace): ${this._externalResources == null ? "(none)" : this._externalResources}`); - const filters = new Map(); + const filtersByComponent = new Map(); if ( this._externalResources != null ) { - for ( let component in this._externalResources ) { - const packageFilters = new ResourceFilterList(this._externalResources[component]); + for ( let [component, filters] of Object.entries(this._externalResources) ) { + const packageFilters = new ResourceFilterList(filters); if ( component === "/" || component === "" ) { component = ""; } else if ( !component.endsWith("/") ) { component += "/"; } log.verbose(` resulting filter list for '${component}': '${packageFilters}'`); - filters.set(component, packageFilters); + filtersByComponent.set(component, packageFilters); } } - return filters; + return filtersByComponent; } groupResourcesByComponents() { @@ -553,9 +552,7 @@ class ResourceCollector { list.add(resource); contained = true; } else if ( orphanFilters.has(prefix) ) { - // if ( log.isDebug() ) { - // log.verbose(" checking '%s' against orphan filter '%s' (%s)", resource.name, orphanFilters.get(prefix), prefix); - // } + // log.verbose(` checking '${resource.name}' against orphan filter '${orphanFilters.get(prefix)}' (${prefix})`); if ( orphanFilters.get(prefix).matches(resource.name) ) { list.add(resource); contained = true; @@ -635,7 +632,7 @@ module.exports = async function({resources, dependencyResources}, options) { }); }); await Promise.all(visitorsPromise); - log.info(" found %d resources", collector.resources.size); + log.verbose(` found ${collector.resources.size} resources`); // determine additional information for the found resources if ( options && options.externalResources ) { @@ -657,14 +654,14 @@ module.exports = async function({resources, dependencyResources}, options) { // write out resources.json files for (const [prefix, list] of collector.components.entries()) { - log.info(` writing '${prefix}resources.json'`); + log.verbose(` writing '${prefix}resources.json'`); resourceLists.push(new EvoResource({ path: `/resources/${prefix}resources.json`, string: JSON.stringify(list, null, "\t") })); } for (const [prefix, list] of collector.themePackages.entries()) { - log.info(` writing '${prefix}resources.json'`); + log.verbose(` writing '${prefix}resources.json'`); resourceLists.push(new EvoResource({ path: `/resources/${prefix}resources.json`, string: JSON.stringify(list, null, "\t") @@ -672,12 +669,12 @@ module.exports = async function({resources, dependencyResources}, options) { } const unassigned = collector.resources; if ( unassigned.size > 0 ) { - log.warn(` found ${unassigned.size} resources not belonging to a component (orphans)`); + log.verbose(` found ${unassigned.size} resources not belonging to a component (orphans)`); let n = 0; for ( const resource of unassigned ) { log.verbose(` ${resource} (orphan)`); if ( ++n > 20 ) { - log.verbose(" ... (%d more)", unassigned.size - n); + log.verbose(` ... (${unassigned.size - n} more)`); break; } } From 47675e20d3bc4bdb6741e3cddd152516804a396e Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Fri, 26 Jun 2020 12:16:46 +0200 Subject: [PATCH 15/88] refactoring --- lib/lbt/{ => resources}/LocatorResource.js | 2 +- lib/lbt/{ => resources}/LocatorResourcePool.js | 2 +- lib/processors/bundlers/moduleBundler.js | 2 +- lib/processors/resourceListCreator.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename lib/lbt/{ => resources}/LocatorResource.js (88%) rename lib/lbt/{ => resources}/LocatorResourcePool.js (90%) diff --git a/lib/lbt/LocatorResource.js b/lib/lbt/resources/LocatorResource.js similarity index 88% rename from lib/lbt/LocatorResource.js rename to lib/lbt/resources/LocatorResource.js index b4d47d7c2..0724e6698 100644 --- a/lib/lbt/LocatorResource.js +++ b/lib/lbt/resources/LocatorResource.js @@ -1,4 +1,4 @@ -const Resource = require("./resources/Resource"); +const Resource = require("./Resource"); function extractName(path) { diff --git a/lib/lbt/LocatorResourcePool.js b/lib/lbt/resources/LocatorResourcePool.js similarity index 90% rename from lib/lbt/LocatorResourcePool.js rename to lib/lbt/resources/LocatorResourcePool.js index c0cac0a60..564e3e9a3 100644 --- a/lib/lbt/LocatorResourcePool.js +++ b/lib/lbt/resources/LocatorResourcePool.js @@ -1,4 +1,4 @@ -const ResourcePool = require("./resources/ResourcePool"); +const ResourcePool = require("./ResourcePool"); const LocatorResource = require("./LocatorResource"); diff --git a/lib/processors/bundlers/moduleBundler.js b/lib/processors/bundlers/moduleBundler.js index eef5b4c8d..62e7f24c0 100644 --- a/lib/processors/bundlers/moduleBundler.js +++ b/lib/processors/bundlers/moduleBundler.js @@ -1,5 +1,5 @@ const BundleBuilder = require("../../lbt/bundle/Builder"); -const LocatorResourcePool = require("../../lbt/LocatorResourcePool"); +const LocatorResourcePool = require("../../lbt/resources/LocatorResourcePool"); const EvoResource = require("@ui5/fs").Resource; diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 62e989882..c9bb69cfb 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -2,7 +2,7 @@ const log = require("@ui5/logger").getLogger("builder:processors:resourceListCreator"); const ResourceFilterList = require("../lbt/resources/ResourceFilterList"); -const LocatorResourcePool = require("../lbt/LocatorResourcePool"); +const LocatorResourcePool = require("../lbt/resources/LocatorResourcePool"); const EvoResource = require("@ui5/fs").Resource; From 231d3e011d351e803f2ac4ebe710cd3a84a35ed0 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Fri, 3 Jul 2020 09:37:48 +0200 Subject: [PATCH 16/88] remove dependency resources resources.json is per library and should not contain dependency resources. --- lib/processors/resourceListCreator.js | 4 ++-- lib/tasks/generateResourcesJson.js | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index c9bb69cfb..7b1543e4a 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -612,7 +612,7 @@ const getResourceSize = async (resource) => { return -1; }; -module.exports = async function({resources, dependencyResources}, options) { +module.exports = async function({resources}, options) { options = Object.assign({ failOnOrphans: true, externalResources: undefined, @@ -623,7 +623,7 @@ module.exports = async function({resources, dependencyResources}, options) { }, options); const pool = new LocatorResourcePool(); - await pool.prepare( resources.concat(dependencyResources) ); + await pool.prepare( resources ); const collector = new ResourceCollector(pool); const visitorsPromise = resources.map((resource) => { diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index f1030ac3b..323211f5e 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -64,11 +64,9 @@ module.exports = async function({workspace, dependencies, options}) { } else { resources = await workspace.byGlob(["/resources/**/*.*", ...DEFAULT_EXCLUDES]); } - const dependencyResources = await dependencies.byGlob("/resources/**/*.{js,json,xml,html,properties,library}"); return resourceListCreator({ - resources, - dependencyResources + resources }, getCreatorOptions(options)).then((resourceLists) => Promise.all( resourceLists.map((resourceList) => workspace.write(resourceList)) From 518910b105a0b1d3b4cdd630757886f604a8e4cf Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Fri, 3 Jul 2020 10:01:19 +0200 Subject: [PATCH 17/88] remove commented out code Use size property of resource statInfo --- lib/lbt/resources/LocatorResourcePool.js | 4 ---- lib/processors/resourceListCreator.js | 23 ++--------------------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/lib/lbt/resources/LocatorResourcePool.js b/lib/lbt/resources/LocatorResourcePool.js index 564e3e9a3..c617bac4b 100644 --- a/lib/lbt/resources/LocatorResourcePool.js +++ b/lib/lbt/resources/LocatorResourcePool.js @@ -9,15 +9,11 @@ class LocatorResourcePool extends ResourcePool { prepare(resources) { resources = resources.filter( (res) => !res.getStatInfo().isDirectory() ); - // console.log(resources.map($ => $.getPath())); return Promise.all( resources.map( (resource) => this.addResource( new LocatorResource(this, resource) ) ).filter(Boolean) ); - // .then( () => { - // console.log(" found %d resources", this.size); - // }); } } diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 7b1543e4a..e333fc703 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -596,22 +596,6 @@ class ResourceCollector { */ -const getResourceSize = async (resource) => { - try { - // this retrieves the byteSize of the resource - // @see https://nodejs.org/api/buffer.html#buffer_class_method_buffer_bytelength_string_encoding - const buffer = await resource.getBuffer(); - return Buffer.byteLength(buffer); - } catch (e) { - // ignore error - } - - if (resource.getStatInfo().size !== undefined) { - return resource.getStatInfo().size; - } - return -1; -}; - module.exports = async function({resources}, options) { options = Object.assign({ failOnOrphans: true, @@ -626,12 +610,9 @@ module.exports = async function({resources}, options) { await pool.prepare( resources ); const collector = new ResourceCollector(pool); - const visitorsPromise = resources.map((resource) => { - return getResourceSize(resource).then((size) => { - return collector.visitResource(resource.getPath(), size); - }); + resources.forEach((resource) => { + collector.visitResource(resource.getPath(), resource.getStatInfo().size); }); - await Promise.all(visitorsPromise); log.verbose(` found ${collector.resources.size} resources`); // determine additional information for the found resources From 34971fbd05a3154d21e7668c400d1b362bcd59db Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 6 Jul 2020 13:20:33 +0200 Subject: [PATCH 18/88] Adjusted order of json content add module for .properties files --- lib/processors/resourceListCreator.js | 88 +++++-- package.json | 2 +- .../dest/resources/library/d/resources.json | 4 +- .../dest/resources/library/e/resources.json | 8 +- .../dest/resources/library/h/.library | 10 +- .../library/h/components/resources.json | 8 +- .../h/components/subcomponent1/resources.json | 2 +- .../h/components/subcomponent2/resources.json | 2 +- .../h/components/subcomponent3/resources.json | 2 +- .../h/designtime/library.designtime.js | 4 + .../h/designtime/messagebundle.properties | 1 + .../h/designtime/messagebundle_en.properties | 1 + .../dest/resources/library/h/manifest.json | 4 +- .../library.h/dest/resources/library/h/not.js | 2 +- .../dest/resources/library/h/resources.json | 36 ++- .../dest/resources/library/n/resources.json | 54 ++-- .../j/themes/somefancytheme/resources.json | 20 +- .../library.h/main/src/library/h/.library | 10 +- .../h/designtime/library.designtime.js | 11 + .../h/designtime/messagebundle.properties | 1 + .../h/designtime/messagebundle_en.properties | 1 + .../library.h/main/src/library/h/not.js | 235 +++++++++++++++++- test/lib/builder/builder.js | 64 ++--- test/lib/processors/resourceListCreator.js | 7 + 24 files changed, 464 insertions(+), 113 deletions(-) create mode 100644 test/expected/build/library.h/dest/resources/library/h/designtime/library.designtime.js create mode 100644 test/expected/build/library.h/dest/resources/library/h/designtime/messagebundle.properties create mode 100644 test/expected/build/library.h/dest/resources/library/h/designtime/messagebundle_en.properties create mode 100644 test/fixtures/library.h/main/src/library/h/designtime/library.designtime.js create mode 100644 test/fixtures/library.h/main/src/library/h/designtime/messagebundle.properties create mode 100644 test/fixtures/library.h/main/src/library/h/designtime/messagebundle_en.properties create mode 100644 test/lib/processors/resourceListCreator.js diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index e333fc703..bc6771def 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -25,17 +25,34 @@ class ResourceInfo { this.merged = false; this.designtime = false; this.support = false; - this.module = null; + this._module = null; this.required = null; this.condRequired = null; this.included = null; this.dynRequired = false; this.requiresTopLevelScope = false; this.exposedGlobalNames = null; - this.format = null; + this._format = null; this._size = -1; } + + get module() { + return this._module; + } + + set module(value) { + this._module = value; + } + + get format() { + return this._format; + } + + set format(value) { + this._format = value; + } + get size() { return this._size; } @@ -58,8 +75,8 @@ class ResourceInfo { this.merged = orig.merged; this.designtime = orig.designtime; this.support = orig.support; - if ( this.module == null ) { - this.module = orig.module; + if ( this._module == null ) { + this._module = orig._module; } if ( orig.required != null ) { if ( this.required == null ) { @@ -97,18 +114,38 @@ class ResourceInfo { } orig.exposedGlobalNames.forEach(this.exposedGlobalNames.add, this.exposedGlobalNames); } - if ( orig.format != null ) { - this.format = orig.format; + if ( orig._format != null ) { + this._format = orig._format; } } + /** + * called from JSON.stringify() + * + * @returns {{name: *}} + */ toJSON() { const result = { name: this.name }; - if ( this.module != null ) { - result.module = this.module; + if ( this._module != null ) { + result.module = this._module; + } + if ( this.size >= 0 ) { + result.size = this.size; + } + if ( this.requiresTopLevelScope ) { + result.requiresTopLevelScope = this.requiresTopLevelScope; + } + if ( this.exposedGlobalNames != null && this.exposedGlobalNames.size > 0 ) { + result.exposedGlobals = [...this.exposedGlobalNames]; } + if ( this._format ) { + result.format = this._format; + } + + // + if ( this.isDebug ) { result.isDebug = this.isDebug; } @@ -128,9 +165,9 @@ class ResourceInfo { if ( this.theme != null ) { result.theme = this.theme; } - if ( this.size >= 0 ) { - result.size = this.size; - } + + // + if ( this.required != null && this.required.size > 0 ) { result.required = [...this.required].sort(); } @@ -143,15 +180,7 @@ class ResourceInfo { if ( this.included != null && this.included.size > 0 ) { result.included = [...this.included]; } - if ( this.requiresTopLevelScope ) { - result.requiresTopLevelScope = this.requiresTopLevelScope; - } - if ( this.exposedGlobalNames != null && this.exposedGlobalNames.size > 0 ) { - result.exposedGlobals = [...this.exposedGlobalNames]; - } - if ( this.format ) { - result.format = this.format; - } + return result; } } @@ -371,6 +400,11 @@ class ResourceCollector { constructor(pool, filter) { this._pool = pool; this._filter = filter != null ? filter : new ResourceFilterList(); + /** + * name to resource info + * + * @type {Map} + */ this._resources = new Map(); this._components = new Map(); this._themePackages = new Map(); @@ -405,6 +439,8 @@ class ResourceCollector { } // a .theme file within a theme folder indicates a library/theme package // Note: ignores .theme files in library folders + + // .theming files are not always present therefore this check is relevant for the library.source.less if ( name.match("(?:[^/]+/)*themes/[^/]+/(?:\\.theming|library.source.less)") && !this._themePackages.has(prefix) ) { // log.info("found new theme package %s", prefix); this._themePackages.set(prefix, new ResourcesList(prefix)); @@ -489,6 +525,18 @@ class ResourceCollector { ); } + // set the module name for .properties + if ( /(?:\.properties)$/.test(name) ) { + promises.push(new Promise((resolve) => { + return this._pool.getModuleInfo(info.name).then((moduleInfo) => { + if (moduleInfo.name) { + info.module = moduleInfo.name; + } + resolve(); + }); + })); + } + if ( debugFilter.matches(name) ) { info.isDebug = true; log.verbose(` found potential debug resource '${name}'`); diff --git a/package.json b/package.json index 910363327..319338b58 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "test": "npm run lint && npm run jsdoc-generate && npm run coverage", "test-azure": "npm run lint && npm run jsdoc-generate && npm run coverage-xunit", "lint": "eslint ./", - "unit": "rimraf test/tmp && ava", + "unit": "rimraf test/tmp && ava -v", "unit-verbose": "rimraf test/tmp && cross-env UI5_LOG_LVL=verbose ava --verbose --serial", "unit-watch": "rimraf test/tmp && ava --watch", "unit-nyan": "rimraf test/tmp && ava --tap | tnyan", diff --git a/test/expected/build/library.d/dest/resources/library/d/resources.json b/test/expected/build/library.d/dest/resources/library/d/resources.json index d4a592dc7..a9a2cbbcf 100644 --- a/test/expected/build/library.d/dest/resources/library/d/resources.json +++ b/test/expected/build/library.d/dest/resources/library/d/resources.json @@ -12,9 +12,9 @@ { "name": "some-dbg.js", "module": "library/d/some.js", - "isDebug": true, "size": 142, - "format": "raw" + "format": "raw", + "isDebug": true }, { "name": "some.js", diff --git a/test/expected/build/library.e/dest/resources/library/e/resources.json b/test/expected/build/library.e/dest/resources/library/e/resources.json index 57e89ca88..55af2a20d 100644 --- a/test/expected/build/library.e/dest/resources/library/e/resources.json +++ b/test/expected/build/library.e/dest/resources/library/e/resources.json @@ -8,9 +8,9 @@ { "name": "library-dbg.js", "module": "library/e/library.js", - "isDebug": true, "size": 212, - "format": "raw" + "format": "raw", + "isDebug": true }, { "name": "library.js", @@ -25,9 +25,9 @@ { "name": "some-dbg.js", "module": "library/e/some.js", - "isDebug": true, "size": 211, - "format": "raw" + "format": "raw", + "isDebug": true }, { "name": "some.js", diff --git a/test/expected/build/library.h/dest/resources/library/h/.library b/test/expected/build/library.h/dest/resources/library/h/.library index 2b110f205..9084728e8 100644 --- a/test/expected/build/library.h/dest/resources/library/h/.library +++ b/test/expected/build/library.h/dest/resources/library/h/.library @@ -6,6 +6,14 @@ Some fancy copyright 1.0.0 - Library D + Library H + + + + + + + + diff --git a/test/expected/build/library.h/dest/resources/library/h/components/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/resources.json index 0c4f0d3e3..7bba59743 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/resources.json @@ -4,8 +4,8 @@ { "name": "Component-preload.js", "module": "library/h/components/Component-preload.js", - "merged": true, "size": 361, + "merged": true, "included": [ "library/h/components/Component.js", "library/h/components/TodoComponent.js" @@ -28,8 +28,8 @@ { "name": "subcomponent1/Component-preload.js", "module": "library/h/components/subcomponent1/Component-preload.js", - "merged": true, "size": 279, + "merged": true, "included": [ "library/h/components/subcomponent1/Component.js" ] @@ -45,8 +45,8 @@ { "name": "subcomponent2/Component-preload.js", "module": "library/h/components/subcomponent2/Component-preload.js", - "merged": true, "size": 279, + "merged": true, "included": [ "library/h/components/subcomponent2/Component.js" ] @@ -62,8 +62,8 @@ { "name": "subcomponent3/Component-preload.js", "module": "library/h/components/subcomponent3/Component-preload.js", - "merged": true, "size": 279, + "merged": true, "included": [ "library/h/components/subcomponent3/Component.js" ] diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json index 75b3a4fea..9afe29e64 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json @@ -4,8 +4,8 @@ { "name": "Component-preload.js", "module": "library/h/components/subcomponent1/Component-preload.js", - "merged": true, "size": 279, + "merged": true, "included": [ "library/h/components/subcomponent1/Component.js" ] diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json index 99149a2a2..7b13482f5 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json @@ -4,8 +4,8 @@ { "name": "Component-preload.js", "module": "library/h/components/subcomponent2/Component-preload.js", - "merged": true, "size": 279, + "merged": true, "included": [ "library/h/components/subcomponent2/Component.js" ] diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json index e77b9a5a1..1aaa401b4 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json @@ -4,8 +4,8 @@ { "name": "Component-preload.js", "module": "library/h/components/subcomponent3/Component-preload.js", - "merged": true, "size": 279, + "merged": true, "included": [ "library/h/components/subcomponent3/Component.js" ] diff --git a/test/expected/build/library.h/dest/resources/library/h/designtime/library.designtime.js b/test/expected/build/library.h/dest/resources/library/h/designtime/library.designtime.js new file mode 100644 index 000000000..9b3a27111 --- /dev/null +++ b/test/expected/build/library.h/dest/resources/library/h/designtime/library.designtime.js @@ -0,0 +1,4 @@ +/*! + * Some fancy copyright + */ +sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/designtime/messagebundle.properties b/test/expected/build/library.h/dest/resources/library/h/designtime/messagebundle.properties new file mode 100644 index 000000000..1c6a1a9e8 --- /dev/null +++ b/test/expected/build/library.h/dest/resources/library/h/designtime/messagebundle.properties @@ -0,0 +1 @@ +a=b \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/designtime/messagebundle_en.properties b/test/expected/build/library.h/dest/resources/library/h/designtime/messagebundle_en.properties new file mode 100644 index 000000000..1c6a1a9e8 --- /dev/null +++ b/test/expected/build/library.h/dest/resources/library/h/designtime/messagebundle_en.properties @@ -0,0 +1 @@ +a=b \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/manifest.json b/test/expected/build/library.h/dest/resources/library/h/manifest.json index 2e67ab58d..2b6c457ad 100644 --- a/test/expected/build/library.h/dest/resources/library/h/manifest.json +++ b/test/expected/build/library.h/dest/resources/library/h/manifest.json @@ -12,8 +12,8 @@ "applicationVersion": { "version": "1.0.0" }, - "title": "Library D", - "description": "Library D", + "title": "Library H", + "description": "Library H", "resources": "resources.json", "offline": true }, diff --git a/test/expected/build/library.h/dest/resources/library/h/not.js b/test/expected/build/library.h/dest/resources/library/h/not.js index c249a10c8..952b507ad 100644 --- a/test/expected/build/library.h/dest/resources/library/h/not.js +++ b/test/expected/build/library.h/dest/resources/library/h/not.js @@ -1,4 +1,4 @@ /*! * Some fancy copyright */ -console.log(" Not including "); \ No newline at end of file +(function(e,t){"use strict";var i,n,r;i=document.querySelector("[src$='createSuite.js']");if(i){n=/^(.*\/)?createSuite.js/.exec(i.getAttribute("src"));if(n){r=n[1]+"../../../../"}}if(r==null){throw new Error("createSuite.js: could not identify script tag!")}function s(e,t){var i=e.length,n=0;if(i===0){t();return}function s(e){i--;if(e.type==="error"){n++}e.target.removeEventListener("load",s);e.target.removeEventListener("error",s);if(i===0&&n===0&&t){t()}}for(var a=0;a"+"

"+"
"+""+"
"+"
    ";n.sortedTests.forEach(function(e){var t=sap.ui.require.toUrl("")+"/../"+e.page;r+="
  1. "+(e.skip?"skipped":"")+""+(e.group?""+e.group+": ":"")+""+e.name+"
  2. "});r+="
"+"
"+"
Tests will start in
"+"
*
"+"
Click or press 'ESC' to cancel
";t(r).then(function(){var t=10*(parseInt(e.getAttribute("data-sap-ui-delay"))||2)+9;function n(){if(t===6){i()}else if(t>6){document.getElementById("remaining-time").textContent=String(Math.floor(t/10));t--;setTimeout(n,100)}else{document.removeEventListener("click",r);document.removeEventListener("keydown",r);var e=document.getElementById("redirect-hint");e.parentNode.removeChild(e)}}function r(e){if(e.type==="click"||e.key==="Escape"){t=-1;e.preventDefault()}}document.addEventListener("keydown",r);document.addEventListener("click",r);document.getElementById("redirect").addEventListener("click",i);n()})}function r(i){t("

Failed to load Testsuite

"+"

"+"
    "+"
  1. "+e.encode(i.message||String(i))+"
  2. "+"
")}var s=e.getAttribute("data-sap-ui-testsuite");var a=e.getSuiteConfig(s);var o=parent.jsUnitTestSuite;if(!o){a.then(n).catch(r);return}window.suite=function(){function e(e){var t="/"+window.location.pathname.split("/")[1]+"/";var i=new o;e.sortedTests.forEach(function(e){if(!e.skip){i.addTestPage(t+e.page,e)}});return i}return a.then(e).catch(function(e){r(e);throw e})};var u=document.createEvent("CustomEvent");u.initCustomEvent("sap-ui-testsuite-ready",true,true,{});window.dispatchEvent(u)}); \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/resources.json b/test/expected/build/library.h/dest/resources/library/h/resources.json index ad9cdc05b..5cf945bf5 100644 --- a/test/expected/build/library.h/dest/resources/library/h/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/resources.json @@ -3,13 +3,13 @@ "resources": [ { "name": ".library", - "size": 273 + "size": 473 }, { "name": "components/Component-preload.js", "module": "library/h/components/Component-preload.js", - "merged": true, "size": 361, + "merged": true, "included": [ "library/h/components/Component.js", "library/h/components/TodoComponent.js" @@ -32,8 +32,8 @@ { "name": "components/subcomponent1/Component-preload.js", "module": "library/h/components/subcomponent1/Component-preload.js", - "merged": true, "size": 279, + "merged": true, "included": [ "library/h/components/subcomponent1/Component.js" ] @@ -49,8 +49,8 @@ { "name": "components/subcomponent2/Component-preload.js", "module": "library/h/components/subcomponent2/Component-preload.js", - "merged": true, "size": 279, + "merged": true, "included": [ "library/h/components/subcomponent2/Component.js" ] @@ -66,8 +66,8 @@ { "name": "components/subcomponent3/Component-preload.js", "module": "library/h/components/subcomponent3/Component-preload.js", - "merged": true, "size": 279, + "merged": true, "included": [ "library/h/components/subcomponent3/Component.js" ] @@ -83,14 +83,36 @@ { "name": "customBundle.js", "module": "library/h/customBundle.js", - "merged": true, "size": 368, + "merged": true, "included": [ "library/h/file.js", "library/h/library.js", "library/h/some.js" ] }, + { + "name": "designtime/library.designtime.js", + "module": "library/h/designtime/library.designtime.js", + "size": 84, + "designtime": true + }, + { + "name": "designtime/messagebundle.properties", + "module": "library/h/designtime/messagebundle.properties", + "size": 3, + "designtime": true, + "locale": "", + "raw": "designtime/messagebundle.properties" + }, + { + "name": "designtime/messagebundle_en.properties", + "module": "library/h/designtime/messagebundle_en.properties", + "size": 3, + "designtime": true, + "locale": "en", + "raw": "designtime/messagebundle.properties" + }, { "name": "file.js", "module": "library/h/file.js", @@ -110,7 +132,7 @@ { "name": "not.js", "module": "library/h/not.js", - "size": 63, + "size": 4151, "format": "raw" }, { diff --git a/test/expected/build/library.n/dest/resources/library/n/resources.json b/test/expected/build/library.n/dest/resources/library/n/resources.json index 5f414e920..598303af5 100644 --- a/test/expected/build/library.n/dest/resources/library/n/resources.json +++ b/test/expected/build/library.n/dest/resources/library/n/resources.json @@ -8,8 +8,8 @@ { "name": "Button-dbg.js", "module": "library/n/Button.js", - "isDebug": true, "size": 1362, + "isDebug": true, "required": [ "library/n/library.js", "sap/ui/core/Control.js" @@ -35,8 +35,8 @@ { "name": "changeHandler/SplitButton-dbg.js", "module": "library/n/changeHandler/SplitButton.js", - "isDebug": true, "size": 701, + "isDebug": true, "required": [ "sap/ui/core/util/reflection/JsControlTreeModifier.js" ] @@ -52,15 +52,15 @@ { "name": "designtime/Button-dbg.designtime.js", "module": "library/n/designtime/Button.designtime.js", + "size": 950, "isDebug": true, - "designtime": true, - "size": 950 + "designtime": true }, { "name": "designtime/Button.create.fragment.xml", "module": "library/n/designtime/Button.create.fragment.xml", - "designtime": true, "size": 172, + "designtime": true, "required": [ "library/n/Button.js" ] @@ -68,32 +68,32 @@ { "name": "designtime/Button.designtime.js", "module": "library/n/designtime/Button.designtime.js", - "designtime": true, - "size": 661 + "size": 661, + "designtime": true }, { "name": "designtime/Button.icon.svg", - "designtime": true, - "size": 1386 + "size": 1386, + "designtime": true }, { "name": "designtime/library-dbg.designtime.js", "module": "library/n/designtime/library.designtime.js", + "size": 247, "isDebug": true, - "designtime": true, - "size": 247 + "designtime": true }, { "name": "designtime/library.designtime.js", "module": "library/n/designtime/library.designtime.js", - "designtime": true, - "size": 237 + "size": 237, + "designtime": true }, { "name": "flexibility/Button.flexibility-dbg.js", "module": "library/n/flexibility/Button.flexibility.js", - "isDebug": true, "size": 540, + "isDebug": true, "required": [ "library/n/changeHandler/SplitButton.js", "sap/ui/fl/changeHandler/BaseRename.js" @@ -111,8 +111,8 @@ { "name": "library-dbg.js", "module": "library/n/library.js", - "isDebug": true, "size": 837, + "isDebug": true, "required": [ "sap/m/library.js", "sap/ui/core/Core.js", @@ -122,9 +122,9 @@ { "name": "library-dbg.support.js", "module": "library/n/library.support.js", + "size": 417, "isDebug": true, "support": true, - "size": 417, "required": [ "library/n/rules/Button.support.js", "sap/ui/support/library.js" @@ -143,8 +143,8 @@ { "name": "library.support.js", "module": "library/n/library.support.js", - "support": true, "size": 338, + "support": true, "required": [ "library/n/rules/Button.support.js", "sap/ui/support/library.js" @@ -156,30 +156,32 @@ }, { "name": "messagebundle.properties", + "module": "library/n/messagebundle.properties", + "size": 13, "locale": "", - "raw": "messagebundle.properties", - "size": 13 + "raw": "messagebundle.properties" }, { "name": "messagebundle_de.properties", + "module": "library/n/messagebundle_de.properties", + "size": 20, "locale": "de", - "raw": "messagebundle.properties", - "size": 20 + "raw": "messagebundle.properties" }, { "name": "rules/Button-dbg.support.js", "module": "library/n/rules/Button.support.js", - "isDebug": true, - "support": true, "size": 211, - "format": "raw" + "format": "raw", + "isDebug": true, + "support": true }, { "name": "rules/Button.support.js", "module": "library/n/rules/Button.support.js", - "support": true, "size": 211, - "format": "raw" + "format": "raw", + "support": true } ] } \ No newline at end of file diff --git a/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json b/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json index 43be440a0..afbb8b99a 100644 --- a/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json +++ b/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json @@ -3,30 +3,30 @@ "resources": [ { "name": "Button.less", + "size": 34, "designtime": true, - "theme": "somefancytheme", - "size": 34 + "theme": "somefancytheme" }, { "name": "library-RTL.css", - "theme": "somefancytheme", - "size": 162 + "size": 162, + "theme": "somefancytheme" }, { "name": "library-parameters.json", - "theme": "somefancytheme", - "size": 20 + "size": 20, + "theme": "somefancytheme" }, { "name": "library.css", - "theme": "somefancytheme", - "size": 162 + "size": 162, + "theme": "somefancytheme" }, { "name": "library.source.less", + "size": 42, "designtime": true, - "theme": "somefancytheme", - "size": 42 + "theme": "somefancytheme" } ] } \ No newline at end of file diff --git a/test/fixtures/library.h/main/src/library/h/.library b/test/fixtures/library.h/main/src/library/h/.library index 8d1e46775..38501ff40 100644 --- a/test/fixtures/library.h/main/src/library/h/.library +++ b/test/fixtures/library.h/main/src/library/h/.library @@ -6,6 +6,14 @@ Some fancy copyright ${version} - Library D + Library H + + + + + + + + diff --git a/test/fixtures/library.h/main/src/library/h/designtime/library.designtime.js b/test/fixtures/library.h/main/src/library/h/designtime/library.designtime.js new file mode 100644 index 000000000..e3434b297 --- /dev/null +++ b/test/fixtures/library.h/main/src/library/h/designtime/library.designtime.js @@ -0,0 +1,11 @@ +/*! + * ${copyright} + */ + +/** + * Initialization of designtime Code and shared classes for the library sap.ui.core. + */ +sap.ui.define([], function() { + "use strict"; + return {}; +}); \ No newline at end of file diff --git a/test/fixtures/library.h/main/src/library/h/designtime/messagebundle.properties b/test/fixtures/library.h/main/src/library/h/designtime/messagebundle.properties new file mode 100644 index 000000000..1c6a1a9e8 --- /dev/null +++ b/test/fixtures/library.h/main/src/library/h/designtime/messagebundle.properties @@ -0,0 +1 @@ +a=b \ No newline at end of file diff --git a/test/fixtures/library.h/main/src/library/h/designtime/messagebundle_en.properties b/test/fixtures/library.h/main/src/library/h/designtime/messagebundle_en.properties new file mode 100644 index 000000000..1c6a1a9e8 --- /dev/null +++ b/test/fixtures/library.h/main/src/library/h/designtime/messagebundle_en.properties @@ -0,0 +1 @@ +a=b \ No newline at end of file diff --git a/test/fixtures/library.h/main/src/library/h/not.js b/test/fixtures/library.h/main/src/library/h/not.js index 778bfa1f5..0dd3410f9 100644 --- a/test/fixtures/library.h/main/src/library/h/not.js +++ b/test/fixtures/library.h/main/src/library/h/not.js @@ -1,4 +1,237 @@ /*! * ${copyright} */ -console.log(' Not including '); + +/* + * IMPORTANT: This is a private module, its API must not be used and is subject to change. + * Code other than the Core tests must not yet introduce dependencies to this module. + */ + +/*global document, sap */ +(function(deps, callback) { + + "use strict"; + + //extract base URL from script tag + var oScriptTag, mMatch, sBaseUrl; + + oScriptTag = document.querySelector("[src$='createSuite.js']"); + if (oScriptTag) { + mMatch = /^(.*\/)?createSuite.js/.exec(oScriptTag.getAttribute("src")); + if (mMatch) { + sBaseUrl = mMatch[1] + "../../../../"; + } + } + + if (sBaseUrl == null) { + throw new Error("createSuite.js: could not identify script tag!"); + } + + function loadScripts(urls, callback) { + var pending = urls.length, + errors = 0; + + if (pending === 0) { + callback(); + return; + } + + function listener(e) { + pending--; + if ( e.type === 'error' ) { + errors++; + } + e.target.removeEventListener("load", listener); + e.target.removeEventListener("error", listener); + if ( pending === 0 && errors === 0 && callback ) { + callback(); + } + } + + for ( var i = 0; i < urls.length; i++ ) { + var script = document.createElement("script"); + script.addEventListener("load", listener); + script.addEventListener("error", listener); + script.src = sBaseUrl + urls[i]; + document.head.appendChild(script); + } + } + + // check for optimized sources + window["sap-ui-optimized"] = window["sap-ui-optimized"] + || (/\.head/.test(loadScripts) && !/pending/.test(loadScripts)); + + // prevent a reboot in full debug mode as this would invalidate our listeners + window["sap-ui-debug-no-reboot"] = true; + + // define the necessary polyfills to be loaded + var aPolyfills = []; + if (/(trident)\/[\w.]+;.*rv:([\w.]+)/i.test(window.navigator.userAgent)) { + // add polyfills for IE11 + aPolyfills.push("sap/ui/thirdparty/baseuri.js"); + aPolyfills.push("sap/ui/thirdparty/es6-promise.js"); + aPolyfills.push("sap/ui/thirdparty/es6-shim-nopromise.js"); + } else if (/(edge)[ \/]([\w.]+)/i.test(window.navigator.userAgent) || + /Version\/(11\.0).*Safari/.test(window.navigator.userAgent)) { + // for Microsoft Edge and Safari 11.0 the Promise polyfill is still needed + aPolyfills.push("sap/ui/thirdparty/es6-promise.js"); + } + + // cascade 1: polyfills, can all be loaded in parallel + loadScripts(aPolyfills, function() { + // cascade 2: the loader + loadScripts([ + "ui5loader.js" + ], function() { + // cascade 3: the loader configuration script + sap.ui.loader.config({ + async:true + }); + loadScripts([ + "ui5loader-autoconfig.js" + ], function() { + sap.ui.require(deps, callback); + }); + }); + }); + +}([ + "sap/ui/test/starter/_utils" +], function(utils) { + "use strict"; + + function render(sHTML) { + // style is added to the head, no need to wait for DOM ready + utils.addStylesheet("sap/ui/thirdparty/qunit-2.css"); + utils.addStylesheet("sap/ui/test/starter/testsuite.css"); + return utils.whenDOMReady().then(function() { + var elem = document.body.querySelector("#qunit"); + if ( elem == null ) { + elem = document.createElement("div"); + elem.id = "qunit"; + document.body.insertBefore(elem, document.body.firstChild); + } + elem.innerHTML = sHTML; + }); + } + + function redirectToTestRunner() { + // As IE11 doesn't properly resolve relative URLs when assigning to location.href, use an anchor tag + var anchor = document.createElement("A"); + document.head.appendChild(anchor); + anchor.href = sap.ui.require.toUrl("") + "/../test-resources/sap/ui/qunit/testrunner.html" + + "?testpage=" + encodeURIComponent(window.location.pathname) + "&autostart=true"; + window.location.href = anchor.href; + } + + function renderList(oSuiteConfig) { + + document.title = "Available Unit Tests - " + oSuiteConfig.name; + + var sLinkHTML = "

" + document.title + "

" + + "

" + + "
" + + "" + + "
" + + "
    "; + oSuiteConfig.sortedTests.forEach(function(oTestConfig) { + var sPageUrl = sap.ui.require.toUrl("") + "/../" + oTestConfig.page; + sLinkHTML += "
  1. " + + (oTestConfig.skip ? "skipped" : "") + + "" + + (oTestConfig.group ? "" + oTestConfig.group + ": " : "") + + "" + oTestConfig.name + "
  2. "; + }); + sLinkHTML += "
" + + "
" + + "
Tests will start in
" + + "
*
" + + "
Click or press 'ESC' to cancel
"; + + render(sLinkHTML).then(function() { + // Note: we use a 0.1 second timer resolution so that the blocking div disappears quickly + var count = 10 * (parseInt(utils.getAttribute("data-sap-ui-delay")) || 2) + 9; + + function countDown() { + if ( count === 6 ) { + redirectToTestRunner(); + } else if ( count > 6 ){ + document.getElementById("remaining-time").textContent = String(Math.floor(count / 10)); + count--; + setTimeout(countDown, 100); + } else { + document.removeEventListener("click", maybeStop); + document.removeEventListener("keydown", maybeStop); + var hintOverlay = document.getElementById("redirect-hint"); + hintOverlay.parentNode.removeChild(hintOverlay); + } + } + + function maybeStop(e) { + if ( e.type === "click" || e.key === "Escape" ) { + count = -1; + e.preventDefault(); + } + } + + document.addEventListener("keydown", maybeStop); + document.addEventListener("click", maybeStop); + document.getElementById("redirect").addEventListener("click", redirectToTestRunner); + countDown(); + }); + + } + + function renderError(oErr) { + + render( + "

Failed to load Testsuite

" + + "

" + + "
    " + + "
  1. " + utils.encode(oErr.message || String(oErr)) + "
  2. " + + "
" + ); + + } + + var sSuiteName = utils.getAttribute("data-sap-ui-testsuite"); + var whenLoaded = utils.getSuiteConfig(sSuiteName); + + + var JSUnitSuite = parent.jsUnitTestSuite; + if ( !JSUnitSuite ) { + // If running in top window, render list and redirect to testrunner after a while + whenLoaded.then(renderList).catch(renderError); + return; + } + + /* + * Note: the window.suite function must be provided early, + * only its answer can be a promise. The TestRunner.js will call this method + * immediately after the window load event. + */ + window.suite = function() { + + function createSuite(oSuiteConfig) { + var sContextPath = "/" + window.location.pathname.split("/")[1] + "/"; + var oSuite = new JSUnitSuite(); + oSuiteConfig.sortedTests.forEach(function(oTestConfig) { + if (!oTestConfig.skip) { + oSuite.addTestPage(sContextPath + oTestConfig.page, oTestConfig); + } + }); + return oSuite; + } + + return whenLoaded.then(createSuite).catch(function(oErr) { + renderError(oErr); + throw oErr; // rethrow to make testrunner aware of issue + }); + + }; + + var oSuiteReadyEvent = document.createEvent("CustomEvent"); + oSuiteReadyEvent.initCustomEvent("sap-ui-testsuite-ready", true, true, {}); + window.dispatchEvent(oSuiteReadyEvent); + +})); diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index c4e3987b3..7d81b43ad 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -56,7 +56,7 @@ function cloneProjectTree(tree) { return clone; } -async function checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath) { +async function checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath) { for (let i = 0; i < expectedFiles.length; i++) { const expectedFile = expectedFiles[i]; const relativeFile = path.relative(expectedPath, expectedFile); @@ -67,9 +67,16 @@ async function checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, des if (expectedFile.endsWith("sap-ui-cachebuster-info.json")) { currentContent = JSON.parse(currentContent.replace(/(:\s+)(\d+)/g, ": 0")); expectedContent = JSON.parse(expectedContent.replace(/(:\s+)(\d+)/g, ": 0")); - assert.deepEqual(currentContent, expectedContent); + t.deepEqual(currentContent, expectedContent); } else { - assert.equal(currentContent.replace(newLineRegexp, "\n"), expectedContent.replace(newLineRegexp, "\n")); + if (expectedFile.endsWith(".json")) { + try { + t.deepEqual(JSON.parse(currentContent), JSON.parse(expectedContent), expectedFile); + } catch (e) { + t.falsy(e, expectedFile); + } + } + t.is(currentContent.replace(newLineRegexp, "\n"), expectedContent.replace(newLineRegexp, "\n"), relativeFile); } }; await Promise.all([currentFileContentPromise, expectedFileContentPromise]).then(assertContents); @@ -178,7 +185,7 @@ test("Build application.a", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -209,7 +216,7 @@ test("Build application.a with dependencies", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -230,7 +237,7 @@ test("Build application.a with dependencies include", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -251,7 +258,7 @@ test("Build application.a with dependencies exclude", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -272,7 +279,7 @@ test("Build application.a self-contained", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -294,7 +301,7 @@ test("Build application.a with dependencies self-contained", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -315,7 +322,7 @@ test("Build application.a [dev mode]", (t) => { assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -343,7 +350,7 @@ test("Build application.a and clean target path [dev mode]", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -363,7 +370,7 @@ test("Build application.g", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -383,7 +390,7 @@ test("Build application.g with component preload paths", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -404,7 +411,7 @@ test("Build application.g with excludes", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -425,7 +432,7 @@ test("Build application.h", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -445,7 +452,7 @@ test("Build application.i", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -465,7 +472,7 @@ test("Build application.j", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -486,7 +493,7 @@ test("Build library.d with copyright from .library file", (t) => { assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -507,7 +514,7 @@ test("Build library.e with copyright from settings of ui5.yaml", (t) => { assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -528,7 +535,7 @@ test("Build library.h with custom bundles and component-preloads", (t) => { assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -549,7 +556,7 @@ test("Build library.i with manifest info taken from .library and library.js", (t assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -571,7 +578,7 @@ test("Build library.j with JSDoc build only", (t) => { assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); @@ -589,13 +596,10 @@ test("Build theme.j even without an library", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); - // Check for all file contents - expectedFiles.forEach((expectedFile) => { - const relativeFile = path.relative(expectedPath, expectedFile); - const destFile = path.join(destPath, relativeFile); - assert.fileEqual(destFile, expectedFile); - t.pass(); - }); + + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); + }).then(() => { + t.pass(); }); }); @@ -614,7 +618,7 @@ test("Build library.n", (t) => { assert.directoryDeepEqual(destPath, expectedPath); // Check for all file contents - return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath); + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); }); diff --git a/test/lib/processors/resourceListCreator.js b/test/lib/processors/resourceListCreator.js new file mode 100644 index 000000000..f95358c60 --- /dev/null +++ b/test/lib/processors/resourceListCreator.js @@ -0,0 +1,7 @@ +const test = require("ava"); + +const resourceListCreator = require("../../../lib/processors/resourceListCreator"); + +test("Replaces string pattern from resource stream", async (t) => { + t.truthy(resourceListCreator); +}); From 03462f0857ea71ddae1876f664f80157cf34b4ce Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 6 Jul 2020 15:23:47 +0200 Subject: [PATCH 19/88] add resources.json entry to the resources.json size for it is good, hits most of the time the right value. --- lib/processors/resourceListCreator.js | 34 ++++++++++++++++++- .../dest/resources/library/d/resources.json | 4 +++ .../dest/resources/library/e/resources.json | 4 +++ .../library/h/components/resources.json | 4 +++ .../h/components/subcomponent1/resources.json | 4 +++ .../h/components/subcomponent2/resources.json | 4 +++ .../h/components/subcomponent3/resources.json | 4 +++ .../dest/resources/library/h/resources.json | 4 +++ .../dest/resources/library/i/resources.json | 4 +++ .../dest/resources/library/n/resources.json | 4 +++ 10 files changed, 69 insertions(+), 1 deletion(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index bc6771def..a70af874e 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -203,6 +203,10 @@ class ResourcesList { this.resourcesByName = new Map(); } + /** + * + * @param {ResourceInfo} info + */ add(info) { const relativeName = ResourcesList.makePathRelativeTo(this.name, info.name); @@ -406,6 +410,13 @@ class ResourceCollector { * @type {Map} */ this._resources = new Map(); + + /** + * prefix to ResourcesList + * + * @type {Map} + * @private + */ this._components = new Map(); this._themePackages = new Map(); } @@ -628,6 +639,10 @@ class ResourceCollector { return new Set(this._resources.keys()); } + /** + * + * @returns {Map} + */ get components() { return this._components; } @@ -684,9 +699,26 @@ module.exports = async function({resources}, options) { // write out resources.json files for (const [prefix, list] of collector.components.entries()) { log.verbose(` writing '${prefix}resources.json'`); + + // having the file size entry part of the file is a bit like the chicken egg scenario + // you can't change the value of the file size without changing the file size + // so this part here tries to cope with that. + + // try to add resources.json entry with previous size of the list string. + // get the content to be added (resources.json entry) + // modify the size of the entry from the calculated one + + const prevContentString = JSON.stringify(list, null, "\t"); + const resourcesJson = new ResourceInfo(prefix + "resources.json"); + resourcesJson.size = Buffer.from(prevContentString).byteLength; + const stringEntryToAdd = JSON.stringify(resourcesJson, null, "\t"); + resourcesJson.size = Buffer.from(prevContentString + stringEntryToAdd).byteLength; + list.add(resourcesJson); + + const contentString = JSON.stringify(list, null, "\t"); resourceLists.push(new EvoResource({ path: `/resources/${prefix}resources.json`, - string: JSON.stringify(list, null, "\t") + string: contentString })); } for (const [prefix, list] of collector.themePackages.entries()) { diff --git a/test/expected/build/library.d/dest/resources/library/d/resources.json b/test/expected/build/library.d/dest/resources/library/d/resources.json index a9a2cbbcf..973958d06 100644 --- a/test/expected/build/library.d/dest/resources/library/d/resources.json +++ b/test/expected/build/library.d/dest/resources/library/d/resources.json @@ -9,6 +9,10 @@ "name": "manifest.json", "size": 491 }, + { + "name": "resources.json", + "size": 418 + }, { "name": "some-dbg.js", "module": "library/d/some.js", diff --git a/test/expected/build/library.e/dest/resources/library/e/resources.json b/test/expected/build/library.e/dest/resources/library/e/resources.json index 55af2a20d..17c74dbb4 100644 --- a/test/expected/build/library.e/dest/resources/library/e/resources.json +++ b/test/expected/build/library.e/dest/resources/library/e/resources.json @@ -22,6 +22,10 @@ "name": "manifest.json", "size": 443 }, + { + "name": "resources.json", + "size": 655 + }, { "name": "some-dbg.js", "module": "library/e/some.js", diff --git a/test/expected/build/library.h/dest/resources/library/h/components/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/resources.json index 7bba59743..0f311850f 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/resources.json @@ -25,6 +25,10 @@ "size": 54, "format": "raw" }, + { + "name": "resources.json", + "size": 1915 + }, { "name": "subcomponent1/Component-preload.js", "module": "library/h/components/subcomponent1/Component-preload.js", diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json index 9afe29e64..f0ae43589 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json @@ -17,6 +17,10 @@ "required": [ "sap/ui/core/UIComponent.js" ] + }, + { + "name": "resources.json", + "size": 519 } ] } \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json index 7b13482f5..bde4fe528 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json @@ -17,6 +17,10 @@ "required": [ "sap/ui/core/UIComponent.js" ] + }, + { + "name": "resources.json", + "size": 519 } ] } \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json index 1aaa401b4..50da30f69 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json @@ -17,6 +17,10 @@ "required": [ "sap/ui/core/UIComponent.js" ] + }, + { + "name": "resources.json", + "size": 519 } ] } \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/resources.json b/test/expected/build/library.h/dest/resources/library/h/resources.json index 5cf945bf5..236659ea2 100644 --- a/test/expected/build/library.h/dest/resources/library/h/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/resources.json @@ -135,6 +135,10 @@ "size": 4151, "format": "raw" }, + { + "name": "resources.json", + "size": 3403 + }, { "name": "some.js", "module": "library/h/some.js", diff --git a/test/expected/build/library.i/dest/resources/library/i/resources.json b/test/expected/build/library.i/dest/resources/library/i/resources.json index f826d45bc..62e45b8b2 100644 --- a/test/expected/build/library.i/dest/resources/library/i/resources.json +++ b/test/expected/build/library.i/dest/resources/library/i/resources.json @@ -16,6 +16,10 @@ { "name": "manifest.json", "size": 1740 + }, + { + "name": "resources.json", + "size": 332 } ] } \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/resources.json b/test/expected/build/library.n/dest/resources/library/n/resources.json index 598303af5..59fcbcbf7 100644 --- a/test/expected/build/library.n/dest/resources/library/n/resources.json +++ b/test/expected/build/library.n/dest/resources/library/n/resources.json @@ -168,6 +168,10 @@ "locale": "de", "raw": "messagebundle.properties" }, + { + "name": "resources.json", + "size": 4166 + }, { "name": "rules/Button-dbg.support.js", "module": "library/n/rules/Button.support.js", From 34e6e30781db4207c8d577a81050de5ff4833e9f Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 7 Jul 2020 10:28:14 +0200 Subject: [PATCH 20/88] Make the size of resources.json correct --- lib/processors/resourceListCreator.js | 31 ++++++++++++++----- .../library/h/components/resources.json | 2 +- .../h/components/subcomponent1/resources.json | 2 +- .../h/components/subcomponent2/resources.json | 2 +- .../h/components/subcomponent3/resources.json | 2 +- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index a70af874e..3010614c4 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -414,7 +414,7 @@ class ResourceCollector { /** * prefix to ResourcesList * - * @type {Map} + * @type {Map} * @private */ this._components = new Map(); @@ -640,8 +640,9 @@ class ResourceCollector { } /** + * Components * - * @returns {Map} + * @returns {Map} */ get components() { return this._components; @@ -708,14 +709,30 @@ module.exports = async function({resources}, options) { // get the content to be added (resources.json entry) // modify the size of the entry from the calculated one - const prevContentString = JSON.stringify(list, null, "\t"); + let contentString = JSON.stringify(list, null, "\t"); const resourcesJson = new ResourceInfo(prefix + "resources.json"); - resourcesJson.size = Buffer.from(prevContentString).byteLength; - const stringEntryToAdd = JSON.stringify(resourcesJson, null, "\t"); - resourcesJson.size = Buffer.from(prevContentString + stringEntryToAdd).byteLength; + // initial size + resourcesJson.size = Buffer.from(contentString).byteLength; list.add(resourcesJson); - const contentString = JSON.stringify(list, null, "\t"); + contentString = JSON.stringify(list, null, "\t"); + + let newLength = Buffer.from(contentString).byteLength; + + // Adjust size until it is correct + // This entry's size depends on the file size which depends on this entry's size,... + // Updating the number of the size in the content might influence the size of the file itself + // This is deterministic because e.g. in the content -> "size": 1000 has the same amount of bytes as "size": 9999 + // the difference might only come for: + // * adding the initial entry of resources.json + // * changes when the number of digits of the number changes, e.g. 100 -> 1000 + while (resourcesJson.size !== newLength) { + resourcesJson.size = newLength; + list.add(resourcesJson); + contentString = JSON.stringify(list, null, "\t"); + newLength = Buffer.from(contentString).byteLength; + } + resourceLists.push(new EvoResource({ path: `/resources/${prefix}resources.json`, string: contentString diff --git a/test/expected/build/library.h/dest/resources/library/h/components/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/resources.json index 0f311850f..a1dda2e2d 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/resources.json @@ -27,7 +27,7 @@ }, { "name": "resources.json", - "size": 1915 + "size": 1904 }, { "name": "subcomponent1/Component-preload.js", diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json index f0ae43589..5de7b8334 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json @@ -20,7 +20,7 @@ }, { "name": "resources.json", - "size": 519 + "size": 494 } ] } \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json index bde4fe528..ba1172a4c 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json @@ -20,7 +20,7 @@ }, { "name": "resources.json", - "size": 519 + "size": 494 } ] } \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json index 50da30f69..b24c48464 100644 --- a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json @@ -20,7 +20,7 @@ }, { "name": "resources.json", - "size": 519 + "size": 494 } ] } \ No newline at end of file From 1ce41e9ecd5dc3e97c858bc6d92adf6b21d56647 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 9 Jul 2020 13:22:09 +0200 Subject: [PATCH 21/88] add module path for json files --- lib/processors/resourceListCreator.js | 4 +- lib/tasks/bundlers/generateLibraryPreload.js | 2 +- .../dest/resources/library/a/.library | 17 +++++ .../dest/resources/library/a/manifest.json | 34 +++++++++ .../dest/resources/library/a/resources.json | 40 ++++++++++ .../library/a/themes/base/library-RTL.css | 3 + .../a/themes/base/library-parameters.json | 1 + .../library/a/themes/base/library.css | 3 + .../library/a/themes/base/library.source.less | 6 ++ .../library/a/themes/base/resources.json | 27 +++++++ .../dest/test-resources/library/a/Test.html | 0 .../dest/resources/library/d/resources.json | 3 +- .../dest/resources/library/e/resources.json | 3 +- .../dest/resources/library/h/resources.json | 3 +- .../dest/resources/library/i/resources.json | 3 +- .../dest/resources/library/n/resources.json | 3 +- .../j/themes/somefancytheme/resources.json | 1 + test/fixtures/library.n/ui5.yaml | 2 +- test/lib/builder/builder.js | 75 +++++++++++++++++++ 19 files changed, 221 insertions(+), 9 deletions(-) create mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/.library create mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/manifest.json create mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/resources.json create mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library-RTL.css create mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library-parameters.json create mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library.css create mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library.source.less create mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/themes/base/resources.json create mode 100644 test/expected/build/collection/library.a/dest/test-resources/library/a/Test.html diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 3010614c4..9f600d380 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -536,8 +536,8 @@ class ResourceCollector { ); } - // set the module name for .properties - if ( /(?:\.properties)$/.test(name) ) { + // set the module name for .properties and .json + if ( /(?:\.properties|\.json)$/.test(name) ) { promises.push(new Promise((resolve) => { return this._pool.getModuleInfo(info.name).then((moduleInfo) => { if (moduleInfo.name) { diff --git a/lib/tasks/bundlers/generateLibraryPreload.js b/lib/tasks/bundlers/generateLibraryPreload.js index 23334cf95..b4158825e 100644 --- a/lib/tasks/bundlers/generateLibraryPreload.js +++ b/lib/tasks/bundlers/generateLibraryPreload.js @@ -48,7 +48,7 @@ function getBundleDefinition(namespace) { // include only thirdparty that is very likely to be used "sap/ui/thirdparty/crossroads.js", - "sap/ui/thirdparty/caja-htmlsanitizer.js", + "sap/ui/thirdparty/caja-html-sanitizer.js", "sap/ui/thirdparty/hasher.js", "sap/ui/thirdparty/signals.js", "sap/ui/thirdparty/jquery-mobile-custom.js", diff --git a/test/expected/build/collection/library.a/dest/resources/library/a/.library b/test/expected/build/collection/library.a/dest/resources/library/a/.library new file mode 100644 index 000000000..cddfadd9a --- /dev/null +++ b/test/expected/build/collection/library.a/dest/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/collection/library.a/dest/resources/library/a/manifest.json b/test/expected/build/collection/library.a/dest/resources/library/a/manifest.json new file mode 100644 index 000000000..935e866ce --- /dev/null +++ b/test/expected/build/collection/library.a/dest/resources/library/a/manifest.json @@ -0,0 +1,34 @@ +{ + "_version": "1.9.0", + "sap.app": { + "id": "library.a", + "type": "library", + "embeds": [], + "applicationVersion": { + "version": "1.0.0" + }, + "title": "Library A", + "description": "Library A", + "resources": "resources.json", + "offline": true + }, + "sap.ui": { + "technology": "UI5", + "supportedThemes": [ + "base" + ] + }, + "sap.ui5": { + "dependencies": { + "minUI5Version": "1.0", + "libs": { + "library.d": { + "minVersion": "1.0.0" + } + } + }, + "library": { + "i18n": false + } + } +} \ No newline at end of file diff --git a/test/expected/build/collection/library.a/dest/resources/library/a/resources.json b/test/expected/build/collection/library.a/dest/resources/library/a/resources.json new file mode 100644 index 000000000..63084c02c --- /dev/null +++ b/test/expected/build/collection/library.a/dest/resources/library/a/resources.json @@ -0,0 +1,40 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": ".library", + "size": 393 + }, + { + "name": "manifest.json", + "module": "library/a/manifest.json", + "size": 581 + }, + { + "name": "resources.json", + "size": 671 + }, + { + "name": "themes/base/library-RTL.css", + "size": 203, + "theme": "base" + }, + { + "name": "themes/base/library-parameters.json", + "module": "library/a/themes/base/library-parameters.json", + "size": 28, + "theme": "base" + }, + { + "name": "themes/base/library.css", + "size": 203, + "theme": "base" + }, + { + "name": "themes/base/library.source.less", + "size": 111, + "designtime": true, + "theme": "base" + } + ] +} \ No newline at end of file diff --git a/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library-RTL.css b/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library-RTL.css new file mode 100644 index 000000000..5398b3f08 --- /dev/null +++ b/test/expected/build/collection/library.a/dest/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/collection/library.a/dest/resources/library/a/themes/base/library-parameters.json b/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library-parameters.json new file mode 100644 index 000000000..da3b7a52f --- /dev/null +++ b/test/expected/build/collection/library.a/dest/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/collection/library.a/dest/resources/library/a/themes/base/library.css b/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library.css new file mode 100644 index 000000000..ba056b3c0 --- /dev/null +++ b/test/expected/build/collection/library.a/dest/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/collection/library.a/dest/resources/library/a/themes/base/library.source.less b/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library.source.less new file mode 100644 index 000000000..ff0f1d5e3 --- /dev/null +++ b/test/expected/build/collection/library.a/dest/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/collection/library.a/dest/resources/library/a/themes/base/resources.json b/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/resources.json new file mode 100644 index 000000000..5ef2a50bb --- /dev/null +++ b/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/resources.json @@ -0,0 +1,27 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": "library-RTL.css", + "size": 203, + "theme": "base" + }, + { + "name": "library-parameters.json", + "module": "library/a/themes/base/library-parameters.json", + "size": 28, + "theme": "base" + }, + { + "name": "library.css", + "size": 203, + "theme": "base" + }, + { + "name": "library.source.less", + "size": 111, + "designtime": true, + "theme": "base" + } + ] +} \ No newline at end of file diff --git a/test/expected/build/collection/library.a/dest/test-resources/library/a/Test.html b/test/expected/build/collection/library.a/dest/test-resources/library/a/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/library.d/dest/resources/library/d/resources.json b/test/expected/build/library.d/dest/resources/library/d/resources.json index 973958d06..cca622ad3 100644 --- a/test/expected/build/library.d/dest/resources/library/d/resources.json +++ b/test/expected/build/library.d/dest/resources/library/d/resources.json @@ -7,11 +7,12 @@ }, { "name": "manifest.json", + "module": "library/d/manifest.json", "size": 491 }, { "name": "resources.json", - "size": 418 + "size": 458 }, { "name": "some-dbg.js", diff --git a/test/expected/build/library.e/dest/resources/library/e/resources.json b/test/expected/build/library.e/dest/resources/library/e/resources.json index 17c74dbb4..b20b1ba7f 100644 --- a/test/expected/build/library.e/dest/resources/library/e/resources.json +++ b/test/expected/build/library.e/dest/resources/library/e/resources.json @@ -20,11 +20,12 @@ }, { "name": "manifest.json", + "module": "library/e/manifest.json", "size": 443 }, { "name": "resources.json", - "size": 655 + "size": 695 }, { "name": "some-dbg.js", diff --git a/test/expected/build/library.h/dest/resources/library/h/resources.json b/test/expected/build/library.h/dest/resources/library/h/resources.json index 236659ea2..8e4a09ce5 100644 --- a/test/expected/build/library.h/dest/resources/library/h/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/resources.json @@ -127,6 +127,7 @@ }, { "name": "manifest.json", + "module": "library/h/manifest.json", "size": 739 }, { @@ -137,7 +138,7 @@ }, { "name": "resources.json", - "size": 3403 + "size": 3443 }, { "name": "some.js", diff --git a/test/expected/build/library.i/dest/resources/library/i/resources.json b/test/expected/build/library.i/dest/resources/library/i/resources.json index 62e45b8b2..415dfc571 100644 --- a/test/expected/build/library.i/dest/resources/library/i/resources.json +++ b/test/expected/build/library.i/dest/resources/library/i/resources.json @@ -15,11 +15,12 @@ }, { "name": "manifest.json", + "module": "library/i/manifest.json", "size": 1740 }, { "name": "resources.json", - "size": 332 + "size": 372 } ] } \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/resources.json b/test/expected/build/library.n/dest/resources/library/n/resources.json index 59fcbcbf7..f12e52638 100644 --- a/test/expected/build/library.n/dest/resources/library/n/resources.json +++ b/test/expected/build/library.n/dest/resources/library/n/resources.json @@ -152,6 +152,7 @@ }, { "name": "manifest.json", + "module": "library/n/manifest.json", "size": 708 }, { @@ -170,7 +171,7 @@ }, { "name": "resources.json", - "size": 4166 + "size": 4206 }, { "name": "rules/Button-dbg.support.js", diff --git a/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json b/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json index afbb8b99a..68c643959 100644 --- a/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json +++ b/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json @@ -14,6 +14,7 @@ }, { "name": "library-parameters.json", + "module": "theme/j/themes/somefancytheme/library-parameters.json", "size": 20, "theme": "somefancytheme" }, diff --git a/test/fixtures/library.n/ui5.yaml b/test/fixtures/library.n/ui5.yaml index 648905669..48c70435e 100644 --- a/test/fixtures/library.n/ui5.yaml +++ b/test/fixtures/library.n/ui5.yaml @@ -2,4 +2,4 @@ specVersion: "0.1" type: library metadata: - name: library.m + name: library.n diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 7d81b43ad..67b553dd0 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -624,6 +624,27 @@ test("Build library.n", (t) => { }); }); +test("Build collection library.a", (t) => { + const destPath = path.join("test", "tmp", "build", "collection", "library.a", "dest"); + const expectedPath = path.join("test", "expected", "build", "collection", "library.a", "dest"); + + return builder.build({ + tree: collectionLibraryATree, + destPath, + excludedTasks: ["generateLibraryPreload"] + }).then(() => { + return findFiles(expectedPath); + }).then((expectedFiles) => { + // Check for all directories and files + assert.directoryDeepEqual(destPath, expectedPath); + + // Check for all file contents + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); + }).then(() => { + t.pass(); + }); +}); + test.serial("Cleanup", async (t) => { const BuildContext = require("../../../lib/builder/BuildContext"); @@ -1392,3 +1413,57 @@ const libraryNTree = { } }; +const collectionLibraryATree = { + "id": "library.a", + "version": "1.0.0", + "path": path.join(collectionPath, "library.a"), + "dependencies": [ + libraryDTree, + { + "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": 1, + "specVersion": "0.1", + "type": "library", + "metadata": { + "name": "library.a", + "namespace": "library/a", + "copyright": "${copyright}" + }, + "resources": { + "configuration": { + "paths": { + "src": "src", + "test": "test" + }, + "propertiesFileSourceEncoding": "ISO-8859-1" + }, + "pathMappings": { + "/resources/": "src", + "/test-resources/": "test" + } + } +}; + From e6b4a289d28c84848e30e3f1d4059041bc46e06d Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 13 Jul 2020 09:22:48 +0200 Subject: [PATCH 22/88] use latest ui5-fs size retrieval change --- lib/processors/resourceListCreator.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 9f600d380..334cac73f 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -674,9 +674,13 @@ module.exports = async function({resources}, options) { await pool.prepare( resources ); const collector = new ResourceCollector(pool); - resources.forEach((resource) => { - collector.visitResource(resource.getPath(), resource.getStatInfo().size); + const visitPromises = resources.map((resource) => { + return resource.getSize().then((size) => { + collector.visitResource(resource.getPath(), size); + }); }); + + await Promise.all(visitPromises); log.verbose(` found ${collector.resources.size} resources`); // determine additional information for the found resources From 7dd45ee7d337d60ec08be1ffc9a30a33f57abc1d Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 13 Jul 2020 14:08:34 +0200 Subject: [PATCH 23/88] Add dependencies of preloads --- lib/lbt/analyzer/JSModuleAnalyzer.js | 8 + .../preload/resources/library/n/.library | 17 ++ .../preload/resources/library/n/Button.js | 55 +++++ .../library/n/changeHandler/SplitButton.js | 27 +++ .../n/designtime/Button.create.fragment.xml | 10 + .../library/n/designtime/Button.designtime.js | 43 ++++ .../library/n/designtime/Button.icon.svg | 26 +++ .../n/designtime/library.designtime.js | 8 + .../n/flexibility/Button.flexibility.js | 20 ++ .../resources/library/n/library-preload.js | 5 + .../preload/resources/library/n/library.js | 38 ++++ .../resources/library/n/library.support.js | 21 ++ .../library/n/messagebundle.properties | 1 + .../library/n/messagebundle_de.properties | 1 + .../resources/library/n/resources.json | 132 +++++++++++ .../library/n/rules/Button.support.js | 4 + test/lib/lbt/analyzer/JSModuleAnalyzer.js | 169 +++++++++++++- .../tasks/bundlers/generateLibraryPreload.js | 210 ++++++++++++++++++ 18 files changed, 792 insertions(+), 3 deletions(-) create mode 100644 test/expected/build/library.n/preload/resources/library/n/.library create mode 100644 test/expected/build/library.n/preload/resources/library/n/Button.js create mode 100644 test/expected/build/library.n/preload/resources/library/n/changeHandler/SplitButton.js create mode 100644 test/expected/build/library.n/preload/resources/library/n/designtime/Button.create.fragment.xml create mode 100644 test/expected/build/library.n/preload/resources/library/n/designtime/Button.designtime.js create mode 100644 test/expected/build/library.n/preload/resources/library/n/designtime/Button.icon.svg create mode 100644 test/expected/build/library.n/preload/resources/library/n/designtime/library.designtime.js create mode 100644 test/expected/build/library.n/preload/resources/library/n/flexibility/Button.flexibility.js create mode 100644 test/expected/build/library.n/preload/resources/library/n/library-preload.js create mode 100644 test/expected/build/library.n/preload/resources/library/n/library.js create mode 100644 test/expected/build/library.n/preload/resources/library/n/library.support.js create mode 100644 test/expected/build/library.n/preload/resources/library/n/messagebundle.properties create mode 100644 test/expected/build/library.n/preload/resources/library/n/messagebundle_de.properties create mode 100644 test/expected/build/library.n/preload/resources/library/n/resources.json create mode 100644 test/expected/build/library.n/preload/resources/library/n/rules/Button.support.js diff --git a/lib/lbt/analyzer/JSModuleAnalyzer.js b/lib/lbt/analyzer/JSModuleAnalyzer.js index a25694fe8..ed03431de 100644 --- a/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -578,6 +578,14 @@ class JSModuleAnalyzer { if ( i < nArgs && isString(args[i]) ) { const moduleName = ModuleName.fromRequireJSName( args[i++].value ); info.addSubModule(moduleName); + + const elementArg = args[i++]; + if (Array.isArray(elementArg.elements)) { + elementArg.elements.forEach((element) => { + const name = element.value; + info.addDependency(name, false); + }); + } } else { log.warn("sap.ui.predefine call is missing a module name (ignored)"); } diff --git a/test/expected/build/library.n/preload/resources/library/n/.library b/test/expected/build/library.n/preload/resources/library/n/.library new file mode 100644 index 000000000..02ec88b73 --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/.library @@ -0,0 +1,17 @@ + + + + library.n + SAP SE + ${copyright} + ${version} + + Library N + + + + sap.ui.core + + + + diff --git a/test/expected/build/library.n/preload/resources/library/n/Button.js b/test/expected/build/library.n/preload/resources/library/n/Button.js new file mode 100644 index 000000000..70f7b4918 --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/Button.js @@ -0,0 +1,55 @@ +/*! + * ${copyright} + */ + +// Provides control library.N.Button. +sap.ui.define([ + './library', + 'sap/ui/core/Control' +], function( + library, + Control +) { + "use strict"; + + return Control.extend("library.n.Button", { + metadata : { + library : "library.n", + properties : { + text: {type: "string", group: "Misc", defaultValue: "" } + }, + aggregations: { + icon: {type: "sap.ui.core.Control", cardinality: "0..1" } + }, + events: { + press: {} + } + }, + designtime: "library/n/designtime/Button.designtime", + renderer: { + apiVersion: 2, + render: function(oRm, oButton) { + oRm.openStart("button", oButton); + oRm.class("libNBtnBase"); + oRm.openEnd(); + if ( oButton.getIcon() ) { + oRm.renderControl(oButton.getIcon()); + } + oRm.openStart("span", oButton.getId() + "-content"); + oRm.class("libNBtnContent"); + oRm.openEnd(); + oRm.text(sText); + oRm.close("span"); + oRm.close("button"); + } + }, + helper: function(sCalendarType) { + var sCalendar = "sap/ui/core/date/" + sCalendarType; + sap.ui.require(["sap/ui/core/format/DateFormat", sCalendar], function(DateFormat, Calendar) { + DateFormat.getInstance(); + new Calendar(); + }); + } + }); + +}); \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/changeHandler/SplitButton.js b/test/expected/build/library.n/preload/resources/library/n/changeHandler/SplitButton.js new file mode 100644 index 000000000..f42a60c9e --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/changeHandler/SplitButton.js @@ -0,0 +1,27 @@ +/*! + * ${copyright} + */ + +sap.ui.define([ + "sap/ui/core/util/reflection/JsControlTreeModifier" +], function ( + JsControlTreeModifier +) { + "use strict"; + + var ButtonCH = {}; + + SplitButton.applyChange = function(oChange, oControl, mPropertyBag) { + if (mPropertyBag.modifier.targets !== "jsControlTree") { + throw new Error("SplitButton change can't be applied on XML tree"); + } + return true; + }; + + SplitButton.revertChange = function(oChange, oControl, mPropertyBag) { + oChange.resetRevertData(); + return true; + }; + + return ButtonCH; +}); diff --git a/test/expected/build/library.n/preload/resources/library/n/designtime/Button.create.fragment.xml b/test/expected/build/library.n/preload/resources/library/n/designtime/Button.create.fragment.xml new file mode 100644 index 000000000..50988ae74 --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/designtime/Button.create.fragment.xml @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/designtime/Button.designtime.js b/test/expected/build/library.n/preload/resources/library/n/designtime/Button.designtime.js new file mode 100644 index 000000000..d6d669833 --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/designtime/Button.designtime.js @@ -0,0 +1,43 @@ +/*! + * ${copyright} + */ + +// Provides the Design Time Metadata for the library.n.Button control +sap.ui.define([], + function () { + "use strict"; + + return { + palette: { + group: "ACTION", + icons: { + svg: "library/n/designtime/Button.icon.svg" + } + }, + actions: { + combine: { + changeType: "combineButtons", + changeOnRelevantContainer : true, + isEnabled : true + }, + remove: { + changeType: "hideControl" + }, + split: { + changeType: "split" + }, + rename: { + changeType: "rename", + domRef: function (oControl) { + return oControl.$().find(".libNBtnContent")[0]; + } + }, + reveal: { + changeType: "unhideControl" + } + }, + templates: { + create: "library/n/designtime/Button.create.fragment.xml" + } + }; + }); \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/designtime/Button.icon.svg b/test/expected/build/library.n/preload/resources/library/n/designtime/Button.icon.svg new file mode 100644 index 000000000..db8fc2011 --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/designtime/Button.icon.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/test/expected/build/library.n/preload/resources/library/n/designtime/library.designtime.js b/test/expected/build/library.n/preload/resources/library/n/designtime/library.designtime.js new file mode 100644 index 000000000..6c8c315f3 --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/designtime/library.designtime.js @@ -0,0 +1,8 @@ +/*! + * ${copyright} + */ + +sap.ui.define([], function() { + "use strict"; + return {}; +}); \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/flexibility/Button.flexibility.js b/test/expected/build/library.n/preload/resources/library/n/flexibility/Button.flexibility.js new file mode 100644 index 000000000..bbce17aea --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/flexibility/Button.flexibility.js @@ -0,0 +1,20 @@ +/*! + * ${copyright} + */ + +sap.ui.define([ + "sap/ui/fl/changeHandler/BaseRename", + "../changeHandler/SplitButton" +], function (BaseRename, SplitButton) { + "use strict"; + + return { + "hideControl": "default", + "split": SplitButton, + "rename": BaseRename.createRenameChangeHandler({ + propertyName: "text", + translationTextType: "XBUT" + }), + "unhideControl": "default" + }; +}); \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/library-preload.js b/test/expected/build/library.n/preload/resources/library/n/library-preload.js new file mode 100644 index 000000000..cfc73a43a --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/library-preload.js @@ -0,0 +1,5 @@ +//@ui5-bundle library/n/library-preload.js +sap.ui.predefine("library/n/Button",["./library","sap/ui/core/Control"],function(e,t){"use strict";return t.extend("library.n.Button",{metadata:{library:"library.n",properties:{text:{type:"string",group:"Misc",defaultValue:""}},aggregations:{icon:{type:"sap.ui.core.Control",cardinality:"0..1"}},events:{press:{}}},designtime:"library/n/designtime/Button.designtime",renderer:{apiVersion:2,render:function(e,t){e.openStart("button",t);e.class("libNBtnBase");e.openEnd();if(t.getIcon()){e.renderControl(t.getIcon())}e.openStart("span",t.getId()+"-content");e.class("libNBtnContent");e.openEnd();e.text(sText);e.close("span");e.close("button")}},helper:function(e){var t="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",t],function(e,t){e.getInstance();new t})}})}); +sap.ui.predefine("library/n/changeHandler/SplitButton",["sap/ui/core/util/reflection/JsControlTreeModifier"],function(e){"use strict";var t={};SplitButton.applyChange=function(e,t,r){if(r.modifier.targets!=="jsControlTree"){throw new Error("SplitButton change can't be applied on XML tree")}return true};SplitButton.revertChange=function(e,t,r){e.resetRevertData();return true};return t}); +sap.ui.predefine("library/n/flexibility/Button.flexibility",["sap/ui/fl/changeHandler/BaseRename","../changeHandler/SplitButton"],function(e,t){"use strict";return{hideControl:"default",split:t,rename:e.createRenameChangeHandler({propertyName:"text",translationTextType:"XBUT"}),unhideControl:"default"}}); +sap.ui.predefine("library/n/library",["sap/ui/core/Core","sap/ui/core/library","sap/m/library"],function(e,i,r){"use strict";sap.ui.getCore().initLibrary({name:"library.n",version:"${version}",dependencies:["sap.ui.core","sap.m"],designtime:"library/n/designtime/library.designtime",types:[],interfaces:[],controls:[],elements:[],extensions:{flChangeHandlers:{"library.n.Button":"library/n/flexibility/Button"},"sap.ui.support":{publicRules:true,internalRules:false}}});return sap.m}); diff --git a/test/expected/build/library.n/preload/resources/library/n/library.js b/test/expected/build/library.n/preload/resources/library/n/library.js new file mode 100644 index 000000000..292583ba1 --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/library.js @@ -0,0 +1,38 @@ +/*! + * ${copyright} + */ + +sap.ui.define([ + 'sap/ui/core/Core', + 'sap/ui/core/library', + 'sap/m/library' +], function( + Core, + coreLibrary, + mobileLibrary +) { + "use strict"; + + // delegate further initialization of this library to the Core + sap.ui.getCore().initLibrary({ + name : "library.n", + version: "${version}", + dependencies : ["sap.ui.core", "sap.m"], + designtime: "library/n/designtime/library.designtime", + types: [], + interfaces: [], + controls: [], + elements: [], + extensions: { + flChangeHandlers: { + "library.n.Button": "library/n/flexibility/Button" + }, + "sap.ui.support": { + publicRules:true, + internalRules:false + } + } + }); + + return sap.m; +}); diff --git a/test/expected/build/library.n/preload/resources/library/n/library.support.js b/test/expected/build/library.n/preload/resources/library/n/library.support.js new file mode 100644 index 000000000..634d4fa8f --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/library.support.js @@ -0,0 +1,21 @@ +/*! + * ${copyright} + */ +sap.ui.define([ + "sap/ui/support/library", + "./rules/Button.support" +], function( + SupportLib, + ButtonSupport, + ) { + "use strict"; + + return { + name: "library.n", + niceName: "Library N", + ruleset: [ + ButtonSupport + ] + }; + +}); \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/messagebundle.properties b/test/expected/build/library.n/preload/resources/library/n/messagebundle.properties new file mode 100644 index 000000000..2fb1d609b --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/messagebundle.properties @@ -0,0 +1 @@ +PRESS=Click! diff --git a/test/expected/build/library.n/preload/resources/library/n/messagebundle_de.properties b/test/expected/build/library.n/preload/resources/library/n/messagebundle_de.properties new file mode 100644 index 000000000..985400feb --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/messagebundle_de.properties @@ -0,0 +1 @@ +PRESS=Hier clicken! diff --git a/test/expected/build/library.n/preload/resources/library/n/resources.json b/test/expected/build/library.n/preload/resources/library/n/resources.json new file mode 100644 index 000000000..d3cefd70e --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/resources.json @@ -0,0 +1,132 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": ".library", + "size": 404 + }, + { + "name": "Button.js", + "module": "library/n/Button.js", + "size": 1201, + "required": [ + "library/n/library.js", + "sap/ui/core/Control.js" + ], + "condRequired": [ + "sap/ui/core/format/DateFormat.js" + ], + "dynRequired": true + }, + { + "name": "changeHandler/SplitButton.js", + "module": "library/n/changeHandler/SplitButton.js", + "size": 540, + "required": [ + "sap/ui/core/util/reflection/JsControlTreeModifier.js" + ] + }, + { + "name": "designtime/Button.create.fragment.xml", + "module": "library/n/designtime/Button.create.fragment.xml", + "size": 172, + "designtime": true, + "required": [ + "library/n/Button.js" + ] + }, + { + "name": "designtime/Button.designtime.js", + "module": "library/n/designtime/Button.designtime.js", + "size": 789, + "designtime": true + }, + { + "name": "designtime/Button.icon.svg", + "size": 1386, + "designtime": true + }, + { + "name": "designtime/library.designtime.js", + "module": "library/n/designtime/library.designtime.js", + "size": 86, + "designtime": true + }, + { + "name": "flexibility/Button.flexibility.js", + "module": "library/n/flexibility/Button.flexibility.js", + "size": 379, + "required": [ + "library/n/changeHandler/SplitButton.js", + "sap/ui/fl/changeHandler/BaseRename.js" + ] + }, + { + "name": "library-preload.js", + "module": "library/n/library-preload.js", + "size": 2012, + "merged": true, + "required": [ + "../changeHandler/SplitButton", + "./library", + "sap/m/library", + "sap/ui/core/Control", + "sap/ui/core/Core", + "sap/ui/core/library", + "sap/ui/core/util/reflection/JsControlTreeModifier", + "sap/ui/fl/changeHandler/BaseRename" + ], + "included": [ + "library/n/Button.js", + "library/n/changeHandler/SplitButton.js", + "library/n/flexibility/Button.flexibility.js", + "library/n/library.js" + ] + }, + { + "name": "library.js", + "module": "library/n/library.js", + "size": 681, + "required": [ + "sap/m/library.js", + "sap/ui/core/Core.js", + "sap/ui/core/library.js" + ] + }, + { + "name": "library.support.js", + "module": "library/n/library.support.js", + "size": 256, + "support": true, + "required": [ + "library/n/rules/Button.support.js", + "sap/ui/support/library.js" + ] + }, + { + "name": "messagebundle.properties", + "module": "library/n/messagebundle.properties", + "size": 13, + "locale": "", + "raw": "messagebundle.properties" + }, + { + "name": "messagebundle_de.properties", + "module": "library/n/messagebundle_de.properties", + "size": 20, + "locale": "de", + "raw": "messagebundle.properties" + }, + { + "name": "resources.json", + "size": 2923 + }, + { + "name": "rules/Button.support.js", + "module": "library/n/rules/Button.support.js", + "size": 50, + "format": "raw", + "support": true + } + ] +} \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/rules/Button.support.js b/test/expected/build/library.n/preload/resources/library/n/rules/Button.support.js new file mode 100644 index 000000000..81e734360 --- /dev/null +++ b/test/expected/build/library.n/preload/resources/library/n/rules/Button.support.js @@ -0,0 +1,4 @@ +/*! + * ${copyright} + */ +console.log('HelloWorld'); \ No newline at end of file diff --git a/test/lib/lbt/analyzer/JSModuleAnalyzer.js b/test/lib/lbt/analyzer/JSModuleAnalyzer.js index 23a1b4be1..2b752c34a 100644 --- a/test/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/test/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -239,7 +239,54 @@ test.cb("OldStyleBundle", (t) => { analyzeModule(t, "modules/bundle-oldstyle.js", "sap-ui-core.js", - [], + [ + "../model/BindingMode", + "../model/CompositeBinding", + "../model/Context", + "../model/FormatException", + "../model/ListBinding", + "../model/Model", + "../model/ParseException", + "../model/TreeBinding", + "../model/Type", + "../model/ValidateException", + "./BindingParser", + "./Component", + "./Configuration", + "./Control", + "./DataType", + "./Element", + "./ElementMetadata", + "./EventProvider", + "./FocusHandler", + "./ManagedObjectMetadata", + "./Object", + "./RenderManager", + "./ResizeHandler", + "./ThemeCheck", + "./UIArea", + "./message/MessageManager", + "jquery.sap.act", + "jquery.sap.dom", + "jquery.sap.events", + "jquery.sap.global", + "jquery.sap.keycodes", + "jquery.sap.mobile", + "jquery.sap.properties", + "jquery.sap.resources", + "jquery.sap.script", + "jquery.sap.sjax", + "jquery.sap.strings", + "sap/ui/Device", + "sap/ui/Global", + "sap/ui/base/BindingParser", + "sap/ui/base/DataType", + "sap/ui/base/EventProvider", + "sap/ui/base/Interface", + "sap/ui/base/ManagedObject", + "sap/ui/base/Object", + "sap/ui/thirdparty/jquery-mobile-custom" + ], [], [ "sap/ui/Device.js", @@ -266,7 +313,54 @@ test.cb("OldStyleBundleV2", (t) => { analyzeModule(t, "modules/bundle-oldstyle-v2.js", "sap-ui-core.js", - [], + [ + "../model/BindingMode", + "../model/CompositeBinding", + "../model/Context", + "../model/FormatException", + "../model/ListBinding", + "../model/Model", + "../model/ParseException", + "../model/TreeBinding", + "../model/Type", + "../model/ValidateException", + "./BindingParser", + "./Component", + "./Configuration", + "./Control", + "./DataType", + "./Element", + "./ElementMetadata", + "./EventProvider", + "./FocusHandler", + "./ManagedObjectMetadata", + "./Object", + "./RenderManager", + "./ResizeHandler", + "./ThemeCheck", + "./UIArea", + "./message/MessageManager", + "jquery.sap.act", + "jquery.sap.dom", + "jquery.sap.events", + "jquery.sap.global", + "jquery.sap.keycodes", + "jquery.sap.mobile", + "jquery.sap.properties", + "jquery.sap.resources", + "jquery.sap.script", + "jquery.sap.sjax", + "jquery.sap.strings", + "sap/ui/Device", + "sap/ui/Global", + "sap/ui/base/BindingParser", + "sap/ui/base/DataType", + "sap/ui/base/EventProvider", + "sap/ui/base/Interface", + "sap/ui/base/ManagedObject", + "sap/ui/base/Object", + "sap/ui/thirdparty/jquery-mobile-custom" + ], [], [ "sap/ui/Device.js", @@ -293,7 +387,76 @@ test.cb("EvoBundle", (t) => { analyzeModule(t, "modules/bundle-evo.js", "sap-ui-core.js", - [], + [ + "../model/BindingMode", + "../model/CompositeBinding", + "../model/Context", + "../model/FormatException", + "../model/ParseException", + "../model/StaticBinding", + "../model/Type", + "../model/ValidateException", + "./BindingParser", + "./Component", + "./Configuration", + "./Control", + "./DataType", + "./Element", + "./ElementMetadata", + "./EventProvider", + "./FocusHandler", + "./Log", + "./ManagedObjectMetadata", + "./Object", + "./RenderManager", + "./ResizeHandler", + "./ThemeCheck", + "./UIArea", + "./message/MessageManager", + "jquery.sap.global", + "jquery.sap.stubs", + "sap/base/Log", + "sap/base/assert", + "sap/base/i18n/ResourceBundle", + "sap/base/util/LoaderExtensions", + "sap/base/util/ObjectPath", + "sap/base/util/Version", + "sap/base/util/array/uniqueSort", + "sap/base/util/deepClone", + "sap/base/util/deepEqual", + "sap/base/util/defineLazyProperty", + "sap/base/util/each", + "sap/base/util/isEmptyObject", + "sap/base/util/isPlainObject", + "sap/base/util/now", + "sap/base/util/uid", + "sap/ui/Device", + "sap/ui/Global", + "sap/ui/base/BindingParser", + "sap/ui/base/DataType", + "sap/ui/base/EventProvider", + "sap/ui/base/Interface", + "sap/ui/base/ManagedObject", + "sap/ui/base/Object", + "sap/ui/base/SyncPromise", + "sap/ui/base/syncXHRFix", + "sap/ui/core/support/Hotkeys", + "sap/ui/dom/activeElementFix", + "sap/ui/dom/getComputedStyleFix", + "sap/ui/dom/getScrollbarSize", + "sap/ui/dom/includeScript", + "sap/ui/dom/includeStylesheet", + "sap/ui/events/jquery/EventSimulation", + "sap/ui/performance/Measurement", + "sap/ui/performance/trace/Interaction", + "sap/ui/performance/trace/initTraces", + "sap/ui/security/FrameOptions", + "sap/ui/thirdparty/URI", + "sap/ui/thirdparty/jquery", + "sap/ui/thirdparty/jqueryui/jquery-ui-position", + "sap/ui/util/ActivityDetection", + "ui5loader-autoconfig" + ], [], [ "sap/ui/thirdparty/baseuri.js", diff --git a/test/lib/tasks/bundlers/generateLibraryPreload.js b/test/lib/tasks/bundlers/generateLibraryPreload.js index da3867e7a..db14500a2 100644 --- a/test/lib/tasks/bundlers/generateLibraryPreload.js +++ b/test/lib/tasks/bundlers/generateLibraryPreload.js @@ -1,7 +1,34 @@ const test = require("ava"); +const path = require("path"); +const chai = require("chai"); +chai.use(require("chai-fs")); +const fs = require("graceful-fs"); +const {promisify} = require("util"); +const readFile = promisify(fs.readFile); +const assert = chai.assert; const sinon = require("sinon"); const mock = require("mock-require"); +const ui5Builder = require("../../../../"); +const builder = ui5Builder.builder; +const libraryDPath = path.join(__dirname, "..", "..", "..", "fixtures", "library.d"); +const libraryNPath = path.join(__dirname, "..", "..", "..", "fixtures", "library.n"); +const sapUiCorePath = path.join(__dirname, "..", "..", "..", "fixtures", "sap.ui.core"); + +const recursive = require("recursive-readdir"); + +const findFiles = (folder) => { + return new Promise((resolve, reject) => { + recursive(folder, (err, files) => { + if (err) { + reject(err); + } else { + resolve(files); + } + }); + }); +}; + test.beforeEach((t) => { t.context.workspace = { byGlob: sinon.stub().resolves([]), @@ -633,3 +660,186 @@ test("generateLibraryPreload for sap.ui.core (/w ui5loader.js)", async (t) => { t.true(ReaderCollectionPrioritizedStub.calledWithNew(), "ReaderCollectionPrioritized should have been called with 'new'"); }); + + +test("integration: build library.d with library preload", async (t) => { + const destPath = "./test/tmp/build/library.d/preload"; + const expectedPath = "./test/expected/build/library.d/preload"; + const excludedTasks = ["*"]; + const includedTasks = ["generateLibraryPreload"]; + + return t.notThrowsAsync(builder.build({ + tree: libraryDTree, + destPath, + excludedTasks, + includedTasks + }).then(() => { + return findFiles(expectedPath); + }).then((expectedFiles) => { + // Check for all directories and files + assert.directoryDeepEqual(destPath, expectedPath); + + // Check for all file contents + t.deepEqual(expectedFiles.length, 4, "4 files are expected"); + expectedFiles.forEach((expectedFile) => { + const relativeFile = path.relative(expectedPath, expectedFile); + const destFile = path.join(destPath, relativeFile); + assert.fileEqual(destFile, expectedFile); + }); + })); +}); + +const libraryDTree = { + "id": "library.d", + "version": "1.0.0", + "path": libraryDPath, + "dependencies": [], + "_level": 1, + "specVersion": "0.1", + "type": "library", + "metadata": { + "name": "library.d", + "copyright": "Some fancy copyright" + }, + "resources": { + "configuration": { + "paths": { + "src": "main/src", + "test": "main/test" + } + }, + "pathMappings": { + "/resources/": "main/src", + "/test-resources/": "main/test" + } + } +}; + +test("integration: build library.n with library preload", (t) => { + const destPath = "./test/tmp/build/library.n/preload"; + const expectedPath = "./test/expected/build/library.n/preload"; + const excludedTasks = ["*"]; + const includedTasks = ["generateLibraryPreload", "generateResourcesJson"]; + + return builder.build({ + tree: libraryNTree, + destPath, + excludedTasks, + includedTasks + }).then(() => { + return findFiles(expectedPath); + }).then((expectedFiles) => { + // Check for all directories and files + assert.directoryDeepEqual(destPath, expectedPath); + + // Check for all file contents + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); + }).then(() => { + t.pass(); + }); +}); + +const libraryNTree = { + "id": "library.n", + "version": "1.0.0", + "path": libraryNPath, + "dependencies": [], + "_level": 0, + "specVersion": "0.1", + "type": "library", + "metadata": { + "name": "library.n", + "namespace": "library/n", + "copyright": "UI development toolkit for HTML5 (OpenUI5)\n * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.\n * Licensed under the Apache License, Version 2.0 - see LICENSE.txt." + }, + "resources": { + "configuration": { + "paths": { + "src": "src", + "test": "test" + }, + "propertiesFileSourceEncoding": "ISO-8859-1" + }, + "pathMappings": { + "/resources/": "src", + "/test-resources/": "test" + } + } +}; + + +test("integration: build sap.ui.core with library preload", async (t) => { + const destPath = "./test/tmp/build/sap.ui.core/preload"; + const expectedPath = "./test/expected/build/sap.ui.core/preload"; + const excludedTasks = ["*"]; + const includedTasks = ["generateLibraryPreload"]; + + return t.notThrowsAsync(builder.build({ + tree: sapUiCoreTree, + destPath, + excludedTasks, + includedTasks + }).then(() => { + return findFiles(expectedPath); + }).then((expectedFiles) => { + // Check for all directories and files + assert.directoryDeepEqual(destPath, expectedPath); + + // Check for all file contents + t.deepEqual(expectedFiles.length, 9, "9 files are expected"); + expectedFiles.forEach((expectedFile) => { + const relativeFile = path.relative(expectedPath, expectedFile); + const destFile = path.join(destPath, relativeFile); + assert.fileEqual(destFile, expectedFile); + }); + })); +}); + +const sapUiCoreTree = { + "id": "sap.ui.core", + "version": "1.0.0", + "path": sapUiCorePath, + "dependencies": [], + "_level": 1, + "specVersion": "0.1", + "type": "library", + "metadata": { + "name": "sap.ui.core", + "copyright": "Some fancy copyright" + }, + "resources": { + "configuration": { + "paths": { + "src": "main/src", + "test": "main/test" + } + }, + "pathMappings": { + "/resources/": "main/src", + "/test-resources/": "main/test" + } + } +}; + +const newLineRegexp = /\r?\n|\r/g; + +async function checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath) { + for (let i = 0; i < expectedFiles.length; i++) { + const expectedFile = expectedFiles[i]; + const relativeFile = path.relative(expectedPath, expectedFile); + const destFile = path.join(destPath, relativeFile); + const currentFileContentPromise = readFile(destFile, "utf8"); + const expectedFileContentPromise = readFile(expectedFile, "utf8"); + const assertContents = ([currentContent, expectedContent]) => { + if (expectedFile.endsWith(".json")) { + try { + t.deepEqual(JSON.parse(currentContent), JSON.parse(expectedContent), expectedFile); + } catch (e) { + t.falsy(e, expectedFile); + } + } + t.is(currentContent.replace(newLineRegexp, "\n"), expectedContent.replace(newLineRegexp, "\n"), relativeFile); + }; + await Promise.all([currentFileContentPromise, expectedFileContentPromise]).then(assertContents); + } +} From ed38d148fe19e38e3a974d957f52138970504a0b Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 13 Jul 2020 14:28:46 +0200 Subject: [PATCH 24/88] add condRequired and dynRequired to preloads --- lib/lbt/analyzer/JSModuleAnalyzer.js | 21 +++++++++++++++---- .../resources/library/n/resources.json | 6 +++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/lbt/analyzer/JSModuleAnalyzer.js b/lib/lbt/analyzer/JSModuleAnalyzer.js index ed03431de..187e9730e 100644 --- a/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -381,7 +381,20 @@ class JSModuleAnalyzer { } else if ( isMethodCall(node, CALL_REQUIRE_PREDEFINE) || isMethodCall(node, CALL_SAP_UI_PREDEFINE) ) { // recognized a call to require.predefine() or sap.ui.predefine() info.setFormat(ModuleFormat.UI5_DEFINE); - onSapUiPredefine(node); + onSapUiPredefine(node, conditional); + + const args = node.arguments; + let iArg = 0; + if ( iArg < args.length && isString(args[iArg]) ) { + iArg++; + } + if ( iArg < args.length && args[iArg].type == Syntax.ArrayExpression ) { + iArg++; + } + if ( iArg < args.length && isCallableExpression(args[iArg]) ) { + // unconditionally execute the factory function + visit(args[iArg].body, conditional); + } } else if ( isMethodCall(node, CALL_SAP_UI_REQUIRE) || isMethodCall(node, CALL_AMD_REQUIRE) ) { // recognized a call to require() or sap.ui.require() if ( isMethodCall(node, CALL_SAP_UI_REQUIRE) ) { @@ -569,7 +582,7 @@ class JSModuleAnalyzer { } } - function onSapUiPredefine(predefineCall) { + function onSapUiPredefine(predefineCall, conditional) { const args = predefineCall.arguments; const nArgs = args.length; let i = 0; @@ -580,10 +593,10 @@ class JSModuleAnalyzer { info.addSubModule(moduleName); const elementArg = args[i++]; - if (Array.isArray(elementArg.elements)) { + if (elementArg && elementArg.type === Syntax.ArrayExpression) { elementArg.elements.forEach((element) => { const name = element.value; - info.addDependency(name, false); + info.addDependency(name, conditional); }); } } else { diff --git a/test/expected/build/library.n/preload/resources/library/n/resources.json b/test/expected/build/library.n/preload/resources/library/n/resources.json index d3cefd70e..6c7ad7f7c 100644 --- a/test/expected/build/library.n/preload/resources/library/n/resources.json +++ b/test/expected/build/library.n/preload/resources/library/n/resources.json @@ -76,6 +76,10 @@ "sap/ui/core/util/reflection/JsControlTreeModifier", "sap/ui/fl/changeHandler/BaseRename" ], + "condRequired": [ + "sap/ui/core/format/DateFormat.js" + ], + "dynRequired": true, "included": [ "library/n/Button.js", "library/n/changeHandler/SplitButton.js", @@ -119,7 +123,7 @@ }, { "name": "resources.json", - "size": 2923 + "size": 3013 }, { "name": "rules/Button.support.js", From d009f47acb038633583c4fe2587e3c0e157fea9f Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 13 Jul 2020 14:50:46 +0200 Subject: [PATCH 25/88] Made preload dependency names requirejs names --- lib/lbt/analyzer/JSModuleAnalyzer.js | 4 +- .../resources/library/n/resources.json | 18 +- test/lib/lbt/analyzer/JSModuleAnalyzer.js | 293 ++++++++---------- 3 files changed, 144 insertions(+), 171 deletions(-) diff --git a/lib/lbt/analyzer/JSModuleAnalyzer.js b/lib/lbt/analyzer/JSModuleAnalyzer.js index 187e9730e..1998c8fb2 100644 --- a/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -595,8 +595,8 @@ class JSModuleAnalyzer { const elementArg = args[i++]; if (elementArg && elementArg.type === Syntax.ArrayExpression) { elementArg.elements.forEach((element) => { - const name = element.value; - info.addDependency(name, conditional); + const moduleName = ModuleName.fromRequireJSName( element.value ); + info.addDependency(moduleName, conditional); }); } } else { diff --git a/test/expected/build/library.n/preload/resources/library/n/resources.json b/test/expected/build/library.n/preload/resources/library/n/resources.json index 6c7ad7f7c..dd9c9ec94 100644 --- a/test/expected/build/library.n/preload/resources/library/n/resources.json +++ b/test/expected/build/library.n/preload/resources/library/n/resources.json @@ -67,14 +67,14 @@ "size": 2012, "merged": true, "required": [ - "../changeHandler/SplitButton", - "./library", - "sap/m/library", - "sap/ui/core/Control", - "sap/ui/core/Core", - "sap/ui/core/library", - "sap/ui/core/util/reflection/JsControlTreeModifier", - "sap/ui/fl/changeHandler/BaseRename" + "../changeHandler/SplitButton.js", + "./library.js", + "sap/m/library.js", + "sap/ui/core/Control.js", + "sap/ui/core/Core.js", + "sap/ui/core/library.js", + "sap/ui/core/util/reflection/JsControlTreeModifier.js", + "sap/ui/fl/changeHandler/BaseRename.js" ], "condRequired": [ "sap/ui/core/format/DateFormat.js" @@ -123,7 +123,7 @@ }, { "name": "resources.json", - "size": 3013 + "size": 3037 }, { "name": "rules/Button.support.js", diff --git a/test/lib/lbt/analyzer/JSModuleAnalyzer.js b/test/lib/lbt/analyzer/JSModuleAnalyzer.js index 2b752c34a..d659808dd 100644 --- a/test/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/test/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -240,52 +240,44 @@ test.cb("OldStyleBundle", (t) => { "modules/bundle-oldstyle.js", "sap-ui-core.js", [ - "../model/BindingMode", - "../model/CompositeBinding", - "../model/Context", - "../model/FormatException", - "../model/ListBinding", - "../model/Model", - "../model/ParseException", - "../model/TreeBinding", - "../model/Type", - "../model/ValidateException", - "./BindingParser", - "./Component", - "./Configuration", - "./Control", - "./DataType", - "./Element", - "./ElementMetadata", - "./EventProvider", - "./FocusHandler", - "./ManagedObjectMetadata", - "./Object", - "./RenderManager", - "./ResizeHandler", - "./ThemeCheck", - "./UIArea", - "./message/MessageManager", - "jquery.sap.act", - "jquery.sap.dom", - "jquery.sap.events", - "jquery.sap.global", - "jquery.sap.keycodes", - "jquery.sap.mobile", - "jquery.sap.properties", - "jquery.sap.resources", - "jquery.sap.script", - "jquery.sap.sjax", - "jquery.sap.strings", - "sap/ui/Device", - "sap/ui/Global", - "sap/ui/base/BindingParser", - "sap/ui/base/DataType", - "sap/ui/base/EventProvider", - "sap/ui/base/Interface", - "sap/ui/base/ManagedObject", - "sap/ui/base/Object", - "sap/ui/thirdparty/jquery-mobile-custom" + "../model/BindingMode.js", + "../model/CompositeBinding.js", + "../model/Context.js", + "../model/FormatException.js", + "../model/ListBinding.js", + "../model/Model.js", + "../model/ParseException.js", + "../model/TreeBinding.js", + "../model/Type.js", + "../model/ValidateException.js", + "./BindingParser.js", + "./Component.js", + "./Configuration.js", + "./Control.js", + "./DataType.js", + "./Element.js", + "./ElementMetadata.js", + "./EventProvider.js", + "./FocusHandler.js", + "./ManagedObjectMetadata.js", + "./Object.js", + "./RenderManager.js", + "./ResizeHandler.js", + "./ThemeCheck.js", + "./UIArea.js", + "./message/MessageManager.js", + "jquery.sap.dom.js", + "jquery.sap.mobile.js", + "jquery.sap.properties.js", + "jquery.sap.resources.js", + "jquery.sap.script.js", + "jquery.sap.sjax.js", + "jquery.sap.strings.js", + "sap/ui/Global.js", + "sap/ui/base/BindingParser.js", + "sap/ui/base/EventProvider.js", + "sap/ui/base/Interface.js", + "sap/ui/base/Object.js" ], [], [ @@ -314,52 +306,44 @@ test.cb("OldStyleBundleV2", (t) => { "modules/bundle-oldstyle-v2.js", "sap-ui-core.js", [ - "../model/BindingMode", - "../model/CompositeBinding", - "../model/Context", - "../model/FormatException", - "../model/ListBinding", - "../model/Model", - "../model/ParseException", - "../model/TreeBinding", - "../model/Type", - "../model/ValidateException", - "./BindingParser", - "./Component", - "./Configuration", - "./Control", - "./DataType", - "./Element", - "./ElementMetadata", - "./EventProvider", - "./FocusHandler", - "./ManagedObjectMetadata", - "./Object", - "./RenderManager", - "./ResizeHandler", - "./ThemeCheck", - "./UIArea", - "./message/MessageManager", - "jquery.sap.act", - "jquery.sap.dom", - "jquery.sap.events", - "jquery.sap.global", - "jquery.sap.keycodes", - "jquery.sap.mobile", - "jquery.sap.properties", - "jquery.sap.resources", - "jquery.sap.script", - "jquery.sap.sjax", - "jquery.sap.strings", - "sap/ui/Device", - "sap/ui/Global", - "sap/ui/base/BindingParser", - "sap/ui/base/DataType", - "sap/ui/base/EventProvider", - "sap/ui/base/Interface", - "sap/ui/base/ManagedObject", - "sap/ui/base/Object", - "sap/ui/thirdparty/jquery-mobile-custom" + "../model/BindingMode.js", + "../model/CompositeBinding.js", + "../model/Context.js", + "../model/FormatException.js", + "../model/ListBinding.js", + "../model/Model.js", + "../model/ParseException.js", + "../model/TreeBinding.js", + "../model/Type.js", + "../model/ValidateException.js", + "./BindingParser.js", + "./Component.js", + "./Configuration.js", + "./Control.js", + "./DataType.js", + "./Element.js", + "./ElementMetadata.js", + "./EventProvider.js", + "./FocusHandler.js", + "./ManagedObjectMetadata.js", + "./Object.js", + "./RenderManager.js", + "./ResizeHandler.js", + "./ThemeCheck.js", + "./UIArea.js", + "./message/MessageManager.js", + "jquery.sap.dom.js", + "jquery.sap.mobile.js", + "jquery.sap.properties.js", + "jquery.sap.resources.js", + "jquery.sap.script.js", + "jquery.sap.sjax.js", + "jquery.sap.strings.js", + "sap/ui/Global.js", + "sap/ui/base/BindingParser.js", + "sap/ui/base/EventProvider.js", + "sap/ui/base/Interface.js", + "sap/ui/base/Object.js" ], [], [ @@ -388,74 +372,63 @@ test.cb("EvoBundle", (t) => { "modules/bundle-evo.js", "sap-ui-core.js", [ - "../model/BindingMode", - "../model/CompositeBinding", - "../model/Context", - "../model/FormatException", - "../model/ParseException", - "../model/StaticBinding", - "../model/Type", - "../model/ValidateException", - "./BindingParser", - "./Component", - "./Configuration", - "./Control", - "./DataType", - "./Element", - "./ElementMetadata", - "./EventProvider", - "./FocusHandler", - "./Log", - "./ManagedObjectMetadata", - "./Object", - "./RenderManager", - "./ResizeHandler", - "./ThemeCheck", - "./UIArea", - "./message/MessageManager", - "jquery.sap.global", - "jquery.sap.stubs", - "sap/base/Log", - "sap/base/assert", - "sap/base/i18n/ResourceBundle", - "sap/base/util/LoaderExtensions", - "sap/base/util/ObjectPath", - "sap/base/util/Version", - "sap/base/util/array/uniqueSort", - "sap/base/util/deepClone", - "sap/base/util/deepEqual", - "sap/base/util/defineLazyProperty", - "sap/base/util/each", - "sap/base/util/isEmptyObject", - "sap/base/util/isPlainObject", - "sap/base/util/now", - "sap/base/util/uid", - "sap/ui/Device", - "sap/ui/Global", - "sap/ui/base/BindingParser", - "sap/ui/base/DataType", - "sap/ui/base/EventProvider", - "sap/ui/base/Interface", - "sap/ui/base/ManagedObject", - "sap/ui/base/Object", - "sap/ui/base/SyncPromise", - "sap/ui/base/syncXHRFix", - "sap/ui/core/support/Hotkeys", - "sap/ui/dom/activeElementFix", - "sap/ui/dom/getComputedStyleFix", - "sap/ui/dom/getScrollbarSize", - "sap/ui/dom/includeScript", - "sap/ui/dom/includeStylesheet", - "sap/ui/events/jquery/EventSimulation", - "sap/ui/performance/Measurement", - "sap/ui/performance/trace/Interaction", - "sap/ui/performance/trace/initTraces", - "sap/ui/security/FrameOptions", - "sap/ui/thirdparty/URI", - "sap/ui/thirdparty/jquery", - "sap/ui/thirdparty/jqueryui/jquery-ui-position", - "sap/ui/util/ActivityDetection", - "ui5loader-autoconfig" + "../model/BindingMode.js", + "../model/CompositeBinding.js", + "../model/Context.js", + "../model/FormatException.js", + "../model/ParseException.js", + "../model/StaticBinding.js", + "../model/Type.js", + "../model/ValidateException.js", + "./BindingParser.js", + "./Component.js", + "./Configuration.js", + "./Control.js", + "./DataType.js", + "./Element.js", + "./ElementMetadata.js", + "./EventProvider.js", + "./FocusHandler.js", + "./Log.js", + "./ManagedObjectMetadata.js", + "./Object.js", + "./RenderManager.js", + "./ResizeHandler.js", + "./ThemeCheck.js", + "./UIArea.js", + "./message/MessageManager.js", + "sap/base/i18n/ResourceBundle.js", + "sap/base/util/LoaderExtensions.js", + "sap/base/util/ObjectPath.js", + "sap/base/util/Version.js", + "sap/base/util/array/uniqueSort.js", + "sap/base/util/deepClone.js", + "sap/base/util/deepEqual.js", + "sap/base/util/defineLazyProperty.js", + "sap/base/util/each.js", + "sap/base/util/isEmptyObject.js", + "sap/base/util/isPlainObject.js", + "sap/base/util/now.js", + "sap/base/util/uid.js", + "sap/ui/Global.js", + "sap/ui/base/BindingParser.js", + "sap/ui/base/EventProvider.js", + "sap/ui/base/Interface.js", + "sap/ui/base/Object.js", + "sap/ui/base/SyncPromise.js", + "sap/ui/base/syncXHRFix.js", + "sap/ui/core/support/Hotkeys.js", + "sap/ui/dom/activeElementFix.js", + "sap/ui/dom/getComputedStyleFix.js", + "sap/ui/dom/getScrollbarSize.js", + "sap/ui/dom/includeScript.js", + "sap/ui/dom/includeStylesheet.js", + "sap/ui/events/jquery/EventSimulation.js", + "sap/ui/performance/Measurement.js", + "sap/ui/performance/trace/Interaction.js", + "sap/ui/performance/trace/initTraces.js", + "sap/ui/security/FrameOptions.js", + "sap/ui/util/ActivityDetection.js" ], [], [ From 02bd83b6e720241c11d85265f2a108e63ecc5c26 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 14 Jul 2020 12:48:57 +0200 Subject: [PATCH 26/88] change from exposedGlobals to exposedGlobalNames --- lib/lbt/analyzer/JSModuleAnalyzer.js | 7 +++++ lib/lbt/resources/ResourcePool.js | 6 ++++ lib/processors/resourceListCreator.js | 30 +++++++++---------- .../dest/resources/library/h/resources.json | 4 +-- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/lib/lbt/analyzer/JSModuleAnalyzer.js b/lib/lbt/analyzer/JSModuleAnalyzer.js index 1998c8fb2..98152dd1c 100644 --- a/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -239,6 +239,13 @@ function getDocumentation(node) { * @private */ class JSModuleAnalyzer { + /** + * Analyzes the JS AST + * + * @param {object} ast js ast + * @param {string} defaultName default name + * @param {ModuleInfo} info module info + */ analyze(ast, defaultName, info) { let mainModuleFound = false; /** diff --git a/lib/lbt/resources/ResourcePool.js b/lib/lbt/resources/ResourcePool.js index 0e0e478b2..ed7e45239 100644 --- a/lib/lbt/resources/ResourcePool.js +++ b/lib/lbt/resources/ResourcePool.js @@ -161,6 +161,12 @@ class ResourcePool { } } + /** + * Retrieves the module info + * + * @param {string} name module name + * @returns {Promise} + */ async getModuleInfo(name) { let info = this._dependencyInfos.get(name); if ( info == null ) { diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 334cac73f..7310f64da 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -138,7 +138,7 @@ class ResourceInfo { result.requiresTopLevelScope = this.requiresTopLevelScope; } if ( this.exposedGlobalNames != null && this.exposedGlobalNames.size > 0 ) { - result.exposedGlobals = [...this.exposedGlobalNames]; + result.exposedGlobalNames = [...this.exposedGlobalNames]; } if ( this._format ) { result.format = this._format; @@ -460,42 +460,42 @@ class ResourceCollector { } async enrichWithDependencyInfo(resourceInfo) { - return this._pool.getModuleInfo(resourceInfo.name).then((info) => { - if ( info.name ) { - resourceInfo.module = info.name; + return this._pool.getModuleInfo(resourceInfo.name).then((moduleInfo) => { + if ( moduleInfo.name ) { + resourceInfo.module = moduleInfo.name; } - if ( info.dynamicDependencies ) { + if ( moduleInfo.dynamicDependencies ) { resourceInfo.dynRequired = true; } - if ( info.dependencies.length > 0 ) { + if ( moduleInfo.dependencies.length > 0 ) { resourceInfo.required = resourceInfo.required || new Set(); resourceInfo.condRequired = resourceInfo.condRequired || new Set(); - info.dependencies.forEach((dep) => { - if ( info.isConditionalDependency(dep) ) { + moduleInfo.dependencies.forEach((dep) => { + if ( moduleInfo.isConditionalDependency(dep) ) { resourceInfo.condRequired.add(dep); - } else if ( !info.isImplicitDependency(dep) ) { + } else if ( !moduleInfo.isImplicitDependency(dep) ) { resourceInfo.required.add(dep); } }); } - if ( info.subModules.length > 0 ) { + if ( moduleInfo.subModules.length > 0 ) { resourceInfo.included = resourceInfo.included || new Set(); - info.subModules.forEach((mod) => { + moduleInfo.subModules.forEach((mod) => { resourceInfo.included.add(mod); }); } - if (info.requiresTopLevelScope) { + if (moduleInfo.requiresTopLevelScope) { resourceInfo.requiresTopLevelScope = true; } - if (info.exposedGlobals != null && info.exposedGlobals.length) { + if (moduleInfo.exposedGlobals != null && moduleInfo.exposedGlobals.length) { resourceInfo.exposedGlobalNames = resourceInfo.exposedGlobalNames || new Set(); - info.exposedGlobals.forEach((exposedGlobalName) => { + moduleInfo.exposedGlobals.forEach((exposedGlobalName) => { resourceInfo.exposedGlobalNames.add(exposedGlobalName); }); } - if (info.rawModule) { + if (moduleInfo.rawModule) { resourceInfo.format = "raw"; } }); diff --git a/test/expected/build/library.h/dest/resources/library/h/resources.json b/test/expected/build/library.h/dest/resources/library/h/resources.json index 8e4a09ce5..4001d2aff 100644 --- a/test/expected/build/library.h/dest/resources/library/h/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/resources.json @@ -138,14 +138,14 @@ }, { "name": "resources.json", - "size": 3443 + "size": 3447 }, { "name": "some.js", "module": "library/h/some.js", "size": 86, "requiresTopLevelScope": true, - "exposedGlobals": [ + "exposedGlobalNames": [ "myexport" ], "format": "raw" From 79dce880b0e2a35287f62c5d7a022b3e3b8564a0 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 15 Jul 2020 08:44:26 +0200 Subject: [PATCH 27/88] add generateResourcesJson for application and theme --- lib/types/application/ApplicationBuilder.js | 10 ++ lib/types/themeLibrary/ThemeLibraryBuilder.js | 10 ++ .../build/application.g/dest/resources.json | 105 ++++++++++++++++++ .../dest/subcomponentA/resources.json | 41 +++++++ .../dest/subcomponentB/resources.json | 41 +++++++ .../build/application.h/dest/resources.json | 91 +++++++++++++++ .../build/application.i/dest/resources.json | 62 +++++++++++ .../build/application.j/dest/resources.json | 86 ++++++++++++++ test/lib/builder/builder.js | 4 +- test/lib/tasks/generateCachebusterInfo.js | 4 +- .../types/application/ApplicationBuilder.js | 12 +- 11 files changed, 458 insertions(+), 8 deletions(-) create mode 100644 test/expected/build/application.g/dest/resources.json create mode 100644 test/expected/build/application.g/dest/subcomponentA/resources.json create mode 100644 test/expected/build/application.g/dest/subcomponentB/resources.json create mode 100644 test/expected/build/application.h/dest/resources.json create mode 100644 test/expected/build/application.i/dest/resources.json create mode 100644 test/expected/build/application.j/dest/resources.json diff --git a/lib/types/application/ApplicationBuilder.js b/lib/types/application/ApplicationBuilder.js index 7ff80869b..ec5d11358 100644 --- a/lib/types/application/ApplicationBuilder.js +++ b/lib/types/application/ApplicationBuilder.js @@ -187,6 +187,16 @@ class ApplicationBuilder extends AbstractBuilder { } }); }); + + this.addTask("generateResourcesJson", () => { + return getTask("generateResourcesJson").task({ + workspace: resourceCollections.workspace, + dependencies: resourceCollections.dependencies, + options: { + projectName: project.metadata.name + } + }); + }); } } diff --git a/lib/types/themeLibrary/ThemeLibraryBuilder.js b/lib/types/themeLibrary/ThemeLibraryBuilder.js index 29baabb31..b1b8799a5 100644 --- a/lib/types/themeLibrary/ThemeLibraryBuilder.js +++ b/lib/types/themeLibrary/ThemeLibraryBuilder.js @@ -35,6 +35,16 @@ class ThemeLibraryBuilder extends AbstractBuilder { } }); }); + + this.addTask("generateResourcesJson", () => { + return getTask("generateResourcesJson").task({ + workspace: resourceCollections.workspace, + dependencies: resourceCollections.dependencies, + options: { + projectName: project.metadata.name + } + }); + }); } } diff --git a/test/expected/build/application.g/dest/resources.json b/test/expected/build/application.g/dest/resources.json new file mode 100644 index 000000000..ec5810807 --- /dev/null +++ b/test/expected/build/application.g/dest/resources.json @@ -0,0 +1,105 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": "Component-dbg.js", + "module": "application/g/Component.js", + "size": 183, + "isDebug": true, + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "Component-preload.js", + "module": "application/g/Component-preload.js", + "size": 564, + "merged": true, + "included": [ + "application/g/Component.js", + "application/g/manifest.json" + ] + }, + { + "name": "Component.js", + "module": "application/g/Component.js", + "size": 141, + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "manifest.json", + "module": "application/g/manifest.json", + "size": 331 + }, + { + "name": "resources.json", + "size": 2297 + }, + { + "name": "subcomponentA/Component-dbg.js", + "module": "application/g/subcomponentA/Component.js", + "size": 197, + "isDebug": true, + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "subcomponentA/Component-preload.js", + "module": "application/g/subcomponentA/Component-preload.js", + "size": 587, + "merged": true, + "included": [ + "application/g/subcomponentA/Component.js", + "application/g/subcomponentA/manifest.json" + ] + }, + { + "name": "subcomponentA/Component.js", + "module": "application/g/subcomponentA/Component.js", + "size": 155, + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "subcomponentA/manifest.json", + "module": "application/g/subcomponentA/manifest.json", + "size": 291 + }, + { + "name": "subcomponentB/Component-dbg.js", + "module": "application/g/subcomponentB/Component.js", + "size": 197, + "isDebug": true, + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "subcomponentB/Component-preload.js", + "module": "application/g/subcomponentB/Component-preload.js", + "size": 587, + "merged": true, + "included": [ + "application/g/subcomponentB/Component.js", + "application/g/subcomponentB/manifest.json" + ] + }, + { + "name": "subcomponentB/Component.js", + "module": "application/g/subcomponentB/Component.js", + "size": 155, + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "subcomponentB/manifest.json", + "module": "application/g/subcomponentB/manifest.json", + "size": 291 + } + ] +} \ No newline at end of file diff --git a/test/expected/build/application.g/dest/subcomponentA/resources.json b/test/expected/build/application.g/dest/subcomponentA/resources.json new file mode 100644 index 000000000..33147302f --- /dev/null +++ b/test/expected/build/application.g/dest/subcomponentA/resources.json @@ -0,0 +1,41 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": "Component-dbg.js", + "module": "application/g/subcomponentA/Component.js", + "size": 197, + "isDebug": true, + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "Component-preload.js", + "module": "application/g/subcomponentA/Component-preload.js", + "size": 587, + "merged": true, + "included": [ + "application/g/subcomponentA/Component.js", + "application/g/subcomponentA/manifest.json" + ] + }, + { + "name": "Component.js", + "module": "application/g/subcomponentA/Component.js", + "size": 155, + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "manifest.json", + "module": "application/g/subcomponentA/manifest.json", + "size": 291 + }, + { + "name": "resources.json", + "size": 820 + } + ] +} \ No newline at end of file diff --git a/test/expected/build/application.g/dest/subcomponentB/resources.json b/test/expected/build/application.g/dest/subcomponentB/resources.json new file mode 100644 index 000000000..2ae6b4d1c --- /dev/null +++ b/test/expected/build/application.g/dest/subcomponentB/resources.json @@ -0,0 +1,41 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": "Component-dbg.js", + "module": "application/g/subcomponentB/Component.js", + "size": 197, + "isDebug": true, + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "Component-preload.js", + "module": "application/g/subcomponentB/Component-preload.js", + "size": 587, + "merged": true, + "included": [ + "application/g/subcomponentB/Component.js", + "application/g/subcomponentB/manifest.json" + ] + }, + { + "name": "Component.js", + "module": "application/g/subcomponentB/Component.js", + "size": 155, + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "manifest.json", + "module": "application/g/subcomponentB/manifest.json", + "size": 291 + }, + { + "name": "resources.json", + "size": 820 + } + ] +} \ No newline at end of file diff --git a/test/expected/build/application.h/dest/resources.json b/test/expected/build/application.h/dest/resources.json new file mode 100644 index 000000000..db8db8421 --- /dev/null +++ b/test/expected/build/application.h/dest/resources.json @@ -0,0 +1,91 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": "Component.js", + "module": "application/h/Component.js", + "size": 141, + "required": [ + "sap/ui/core/UIComponent.js" + ] + }, + { + "name": "manifest.json", + "module": "application/h/manifest.json", + "size": 278 + }, + { + "name": "resources.json", + "size": 1816 + }, + { + "name": "sectionsA/customBundle.js", + "module": "application/h/sectionsA/customBundle.js", + "size": 391, + "merged": true, + "included": [ + "application/h/sectionsA/section1.js", + "application/h/sectionsA/section3.js" + ] + }, + { + "name": "sectionsA/section1.js", + "module": "application/h/sectionsA/section1.js", + "size": 79, + "required": [ + "sap/m/Button.js" + ] + }, + { + "name": "sectionsA/section2.js", + "module": "application/h/sectionsA/section2.js", + "size": 79, + "required": [ + "sap/m/Button.js" + ] + }, + { + "name": "sectionsA/section3.js", + "module": "application/h/sectionsA/section3.js", + "size": 79, + "required": [ + "sap/m/Button.js" + ] + }, + { + "name": "sectionsB/customBundle.js", + "module": "application/h/sectionsB/customBundle.js", + "size": 524, + "merged": true, + "included": [ + "application/h/sectionsB/section1.js", + "application/h/sectionsB/section2.js", + "application/h/sectionsB/section3.js" + ] + }, + { + "name": "sectionsB/section1.js", + "module": "application/h/sectionsB/section1.js", + "size": 79, + "required": [ + "sap/m/Button.js" + ] + }, + { + "name": "sectionsB/section2.js", + "module": "application/h/sectionsB/section2.js", + "size": 79, + "required": [ + "sap/m/Button.js" + ] + }, + { + "name": "sectionsB/section3.js", + "module": "application/h/sectionsB/section3.js", + "size": 79, + "required": [ + "sap/m/Button.js" + ] + } + ] +} \ No newline at end of file diff --git a/test/expected/build/application.i/dest/resources.json b/test/expected/build/application.i/dest/resources.json new file mode 100644 index 000000000..083bcd52f --- /dev/null +++ b/test/expected/build/application.i/dest/resources.json @@ -0,0 +1,62 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": "Component-preload.js", + "module": "application/i/Component-preload.js", + "size": 1590, + "merged": true, + "included": [ + "application/i/Component.js", + "application/i/changes/changes-bundle.json", + "application/i/changes/coding/MyExtension.js", + "application/i/changes/fragments/MyFragment.fragment.xml", + "application/i/manifest.json" + ] + }, + { + "name": "Component.js", + "module": "application/i/Component.js", + "size": 141, + "required": [ + "sap/m/library.js", + "sap/ui/core/UIComponent.js", + "sap/ui/core/library.js", + "sap/ui/fl/library.js", + "sap/ui/layout/library.js" + ] + }, + { + "name": "changes/changes-bundle.json", + "module": "application/i/changes/changes-bundle.json", + "size": 749 + }, + { + "name": "changes/coding/MyExtension.js", + "module": "application/i/changes/coding/MyExtension.js", + "size": 39 + }, + { + "name": "changes/fragments/MyFragment.fragment.xml", + "module": "application/i/changes/fragments/MyFragment.fragment.xml", + "size": 13 + }, + { + "name": "changes/id_123_addField.change", + "size": 430 + }, + { + "name": "changes/id_456_addField.change", + "size": 430 + }, + { + "name": "manifest.json", + "module": "application/i/manifest.json", + "size": 369 + }, + { + "name": "resources.json", + "size": 1381 + } + ] +} \ No newline at end of file diff --git a/test/expected/build/application.j/dest/resources.json b/test/expected/build/application.j/dest/resources.json new file mode 100644 index 000000000..6cc8eb8a7 --- /dev/null +++ b/test/expected/build/application.j/dest/resources.json @@ -0,0 +1,86 @@ +{ + "_version": "1.1.0", + "resources": [ + { + "name": "Component-preload.js", + "module": "application/j/Component-preload.js", + "size": 3746, + "merged": true, + "included": [ + "application/j/Component.js", + "application/j/changes/coding/MyExtension.js", + "application/j/changes/flexibility-bundle.json", + "application/j/changes/fragments/MyFragment.fragment.xml", + "application/j/manifest.json" + ] + }, + { + "name": "Component.js", + "module": "application/j/Component.js", + "size": 141, + "required": [ + "sap/m/library.js", + "sap/ui/core/UIComponent.js", + "sap/ui/core/library.js", + "sap/ui/fl/library.js", + "sap/ui/layout/library.js" + ] + }, + { + "name": "changes/coding/MyExtension.js", + "module": "application/j/changes/coding/MyExtension.js", + "size": 39 + }, + { + "name": "changes/flexibility-bundle.json", + "module": "application/j/changes/flexibility-bundle.json", + "size": 2864 + }, + { + "name": "changes/fragments/MyFragment.fragment.xml", + "module": "application/j/changes/fragments/MyFragment.fragment.xml", + "size": 13 + }, + { + "name": "changes/id_111_appDescriptor.change", + "size": 464 + }, + { + "name": "changes/id_111_compVariants.variant", + "size": 466 + }, + { + "name": "changes/id_111_test.ctrl_variant", + "size": 432 + }, + { + "name": "changes/id_111_test.ctrl_variant_change", + "size": 439 + }, + { + "name": "changes/id_111_test.ctrl_variant_management_change", + "size": 450 + }, + { + "name": "changes/id_111_variantDependentControlChange.change", + "size": 489 + }, + { + "name": "changes/id_123_addField.change", + "size": 430 + }, + { + "name": "changes/id_456_addField.change", + "size": 430 + }, + { + "name": "manifest.json", + "module": "application/j/manifest.json", + "size": 423 + }, + { + "name": "resources.json", + "size": 1870 + } + ] +} \ No newline at end of file diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 67b553dd0..e3cb5ff21 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -178,7 +178,7 @@ test("Build application.a", (t) => { return builder.build({ tree: applicationATree, destPath, - excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo"] + excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateResourcesJson"] }).then(() => { return findFiles(expectedPath); }).then((expectedFiles) => { @@ -271,7 +271,7 @@ test("Build application.a self-contained", (t) => { return builder.build({ tree: applicationATree, destPath, - excludedTasks: ["generateComponentPreload", "generateVersionInfo"], + excludedTasks: ["generateComponentPreload", "generateVersionInfo", "generateResourcesJson"], selfContained: true }).then(() => { return findFiles(expectedPath); diff --git a/test/lib/tasks/generateCachebusterInfo.js b/test/lib/tasks/generateCachebusterInfo.js index ec9d52b7c..c114da53a 100644 --- a/test/lib/tasks/generateCachebusterInfo.js +++ b/test/lib/tasks/generateCachebusterInfo.js @@ -27,7 +27,7 @@ const findFiles = (folder) => { test("integration: Build application.g with manifestBundler", (t) => { const destPath = path.join("test", "tmp", "build", "application.g", "cachebuster"); const expectedPath = path.join("test", "expected", "build", "application.g", "cachebuster"); - const excludedTasks = ["escapeNonAsciiCharacters", "generateVersionInfo"]; + const excludedTasks = ["escapeNonAsciiCharacters", "generateVersionInfo", "generateResourcesJson"]; const includedTasks = ["generateCachebusterInfo"]; return builder.build({ @@ -60,7 +60,7 @@ test("integration: Build application.g with manifestBundler", (t) => { test("integration: Build application.g with manifestBundler and cachebuster using hashes", (t) => { const destPath = path.join("test", "tmp", "build", "application.g", "cachebuster_hash"); const expectedPath = path.join("test", "expected", "build", "application.g", "cachebuster"); - const excludedTasks = ["escapeNonAsciiCharacters", "generateVersionInfo"]; + const excludedTasks = ["escapeNonAsciiCharacters", "generateVersionInfo", "generateResourcesJson"]; const includedTasks = ["generateCachebusterInfo"]; return builder.build({ diff --git a/test/lib/types/application/ApplicationBuilder.js b/test/lib/types/application/ApplicationBuilder.js index f05d56552..b37cb222f 100644 --- a/test/lib/types/application/ApplicationBuilder.js +++ b/test/lib/types/application/ApplicationBuilder.js @@ -70,7 +70,8 @@ test("Instantiation", (t) => { "uglify", "generateVersionInfo", "generateCachebusterInfo", - "generateApiIndex" + "generateApiIndex", + "generateResourcesJson" ], "ApplicationBuilder is instantiated with standard tasks"); }); @@ -93,7 +94,8 @@ test("Instantiation without component preload project configuration", (t) => { "uglify", "generateVersionInfo", "generateCachebusterInfo", - "generateApiIndex" + "generateApiIndex", + "generateResourcesJson" ], "ApplicationBuilder is still instantiated with standard tasks"); }); @@ -114,7 +116,8 @@ test("Instantiation without project namespace", (t) => { "createDebugFiles", "uglify", "generateVersionInfo", - "generateApiIndex" + "generateApiIndex", + "generateResourcesJson" ], "All standard tasks but generateComponentPreload will be executed"); }); @@ -142,6 +145,7 @@ test("Instantiation with custom tasks", (t) => { "replaceVersion--1", "generateVersionInfo", "generateCachebusterInfo", - "generateApiIndex" + "generateApiIndex", + "generateResourcesJson" ], "ApplicationBuilder is still instantiated with standard tasks"); }); From a6a11b3ee04961d87c1c83eb0972e43431edfdf1 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 15 Jul 2020 11:12:14 +0200 Subject: [PATCH 28/88] Add conditional require to relative module library.n Add logic to ensure requires are resolved with an absolute path e.g. "./Log.js" -> "sap/base/Log.js" --- lib/lbt/analyzer/JSModuleAnalyzer.js | 15 +- .../dest/resources/library/n/Button-dbg.js | 1 + .../dest/resources/library/n/Button.js | 2 +- .../dest/resources/library/n/resources.json | 8 +- .../preload/resources/library/n/Button.js | 1 + .../resources/library/n/library-preload.js | 2 +- .../resources/library/n/resources.json | 9 +- .../library.n/src/library/n/Button.js | 1 + test/lib/lbt/analyzer/JSModuleAnalyzer.js | 215 ++++++++---------- 9 files changed, 125 insertions(+), 129 deletions(-) diff --git a/lib/lbt/analyzer/JSModuleAnalyzer.js b/lib/lbt/analyzer/JSModuleAnalyzer.js index 98152dd1c..8665dbb4e 100644 --- a/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -424,7 +424,7 @@ class JSModuleAnalyzer { } else if ( isMethodCall(node, CALL_REQUIRE_SYNC) || isMethodCall(node, CALL_SAP_UI_REQUIRE_SYNC) ) { // recognizes a call to sap.ui.requireSync info.setFormat(ModuleFormat.UI5_DEFINE); - onSapUiRequireSync(node, conditional); + onSapUiRequireSync(node, conditional, info.name); } else if ( isMethodCall(node, CALL_JQUERY_SAP_REQUIRE) ) { // recognizes a call to jQuery.sap.require info.setFormat(ModuleFormat.UI5_LEGACY); @@ -573,14 +573,19 @@ class JSModuleAnalyzer { } } - function onSapUiRequireSync(node, conditional) { + function onSapUiRequireSync(node, conditional, name) { const args = node.arguments; const nArgs = args.length; const i = 0; if ( i < nArgs ) { if ( isString(args[i]) ) { - const moduleName = ModuleName.fromRequireJSName( args[i].value ); + let moduleName; + if (name == null) { + moduleName = ModuleName.fromRequireJSName( args[i].value ); + } else { + moduleName = ModuleName.resolveRelativeRequireJSName(name, args[i].value); + } info.addDependency(moduleName, conditional); } else { log.verbose("sap.ui.requireSync: cannot evaluate dynamic arguments: ", args[i] && args[i].type); @@ -602,8 +607,8 @@ class JSModuleAnalyzer { const elementArg = args[i++]; if (elementArg && elementArg.type === Syntax.ArrayExpression) { elementArg.elements.forEach((element) => { - const moduleName = ModuleName.fromRequireJSName( element.value ); - info.addDependency(moduleName, conditional); + const dependencyName = ModuleName.resolveRelativeRequireJSName(moduleName, element.value); + info.addDependency(dependencyName, conditional); }); } } else { diff --git a/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js b/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js index 274df4a28..d2a3bd81c 100644 --- a/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js @@ -31,6 +31,7 @@ sap.ui.define([ renderer: { apiVersion: 2, render: function(oRm, oButton) { + sap.ui.requireSync("./changeHandler/SplitButton"); oRm.openStart("button", oButton); oRm.class("libNBtnBase"); oRm.openEnd(); diff --git a/test/expected/build/library.n/dest/resources/library/n/Button.js b/test/expected/build/library.n/dest/resources/library/n/Button.js index 58360358b..5555f3917 100644 --- a/test/expected/build/library.n/dest/resources/library/n/Button.js +++ b/test/expected/build/library.n/dest/resources/library/n/Button.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["./library","sap/ui/core/Control"],function(e,t){"use strict";return t.extend("library.n.Button",{metadata:{library:"library.n",properties:{text:{type:"string",group:"Misc",defaultValue:""}},aggregations:{icon:{type:"sap.ui.core.Control",cardinality:"0..1"}},events:{press:{}}},designtime:"library/n/designtime/Button.designtime",renderer:{apiVersion:2,render:function(e,t){e.openStart("button",t);e.class("libNBtnBase");e.openEnd();if(t.getIcon()){e.renderControl(t.getIcon())}e.openStart("span",t.getId()+"-content");e.class("libNBtnContent");e.openEnd();e.text(sText);e.close("span");e.close("button")}},helper:function(e){var t="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",t],function(e,t){e.getInstance();new t})}})}); \ No newline at end of file +sap.ui.define(["./library","sap/ui/core/Control"],function(e,t){"use strict";return t.extend("library.n.Button",{metadata:{library:"library.n",properties:{text:{type:"string",group:"Misc",defaultValue:""}},aggregations:{icon:{type:"sap.ui.core.Control",cardinality:"0..1"}},events:{press:{}}},designtime:"library/n/designtime/Button.designtime",renderer:{apiVersion:2,render:function(e,t){sap.ui.requireSync("./changeHandler/SplitButton");e.openStart("button",t);e.class("libNBtnBase");e.openEnd();if(t.getIcon()){e.renderControl(t.getIcon())}e.openStart("span",t.getId()+"-content");e.class("libNBtnContent");e.openEnd();e.text(sText);e.close("span");e.close("button")}},helper:function(e){var t="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",t],function(e,t){e.getInstance();new t})}})}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/resources.json b/test/expected/build/library.n/dest/resources/library/n/resources.json index f12e52638..7bd0c7a08 100644 --- a/test/expected/build/library.n/dest/resources/library/n/resources.json +++ b/test/expected/build/library.n/dest/resources/library/n/resources.json @@ -8,13 +8,14 @@ { "name": "Button-dbg.js", "module": "library/n/Button.js", - "size": 1362, + "size": 1417, "isDebug": true, "required": [ "library/n/library.js", "sap/ui/core/Control.js" ], "condRequired": [ + "library/n/changeHandler/SplitButton.js", "sap/ui/core/format/DateFormat.js" ], "dynRequired": true @@ -22,12 +23,13 @@ { "name": "Button.js", "module": "library/n/Button.js", - "size": 948, + "size": 998, "required": [ "library/n/library.js", "sap/ui/core/Control.js" ], "condRequired": [ + "library/n/changeHandler/SplitButton.js", "sap/ui/core/format/DateFormat.js" ], "dynRequired": true @@ -171,7 +173,7 @@ }, { "name": "resources.json", - "size": 4206 + "size": 4298 }, { "name": "rules/Button-dbg.support.js", diff --git a/test/expected/build/library.n/preload/resources/library/n/Button.js b/test/expected/build/library.n/preload/resources/library/n/Button.js index 70f7b4918..5f4c66781 100644 --- a/test/expected/build/library.n/preload/resources/library/n/Button.js +++ b/test/expected/build/library.n/preload/resources/library/n/Button.js @@ -29,6 +29,7 @@ sap.ui.define([ renderer: { apiVersion: 2, render: function(oRm, oButton) { + sap.ui.requireSync("./changeHandler/SplitButton"); oRm.openStart("button", oButton); oRm.class("libNBtnBase"); oRm.openEnd(); diff --git a/test/expected/build/library.n/preload/resources/library/n/library-preload.js b/test/expected/build/library.n/preload/resources/library/n/library-preload.js index cfc73a43a..dec5578e2 100644 --- a/test/expected/build/library.n/preload/resources/library/n/library-preload.js +++ b/test/expected/build/library.n/preload/resources/library/n/library-preload.js @@ -1,5 +1,5 @@ //@ui5-bundle library/n/library-preload.js -sap.ui.predefine("library/n/Button",["./library","sap/ui/core/Control"],function(e,t){"use strict";return t.extend("library.n.Button",{metadata:{library:"library.n",properties:{text:{type:"string",group:"Misc",defaultValue:""}},aggregations:{icon:{type:"sap.ui.core.Control",cardinality:"0..1"}},events:{press:{}}},designtime:"library/n/designtime/Button.designtime",renderer:{apiVersion:2,render:function(e,t){e.openStart("button",t);e.class("libNBtnBase");e.openEnd();if(t.getIcon()){e.renderControl(t.getIcon())}e.openStart("span",t.getId()+"-content");e.class("libNBtnContent");e.openEnd();e.text(sText);e.close("span");e.close("button")}},helper:function(e){var t="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",t],function(e,t){e.getInstance();new t})}})}); +sap.ui.predefine("library/n/Button",["./library","sap/ui/core/Control"],function(e,t){"use strict";return t.extend("library.n.Button",{metadata:{library:"library.n",properties:{text:{type:"string",group:"Misc",defaultValue:""}},aggregations:{icon:{type:"sap.ui.core.Control",cardinality:"0..1"}},events:{press:{}}},designtime:"library/n/designtime/Button.designtime",renderer:{apiVersion:2,render:function(e,t){sap.ui.requireSync("./changeHandler/SplitButton");e.openStart("button",t);e.class("libNBtnBase");e.openEnd();if(t.getIcon()){e.renderControl(t.getIcon())}e.openStart("span",t.getId()+"-content");e.class("libNBtnContent");e.openEnd();e.text(sText);e.close("span");e.close("button")}},helper:function(e){var t="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",t],function(e,t){e.getInstance();new t})}})}); sap.ui.predefine("library/n/changeHandler/SplitButton",["sap/ui/core/util/reflection/JsControlTreeModifier"],function(e){"use strict";var t={};SplitButton.applyChange=function(e,t,r){if(r.modifier.targets!=="jsControlTree"){throw new Error("SplitButton change can't be applied on XML tree")}return true};SplitButton.revertChange=function(e,t,r){e.resetRevertData();return true};return t}); sap.ui.predefine("library/n/flexibility/Button.flexibility",["sap/ui/fl/changeHandler/BaseRename","../changeHandler/SplitButton"],function(e,t){"use strict";return{hideControl:"default",split:t,rename:e.createRenameChangeHandler({propertyName:"text",translationTextType:"XBUT"}),unhideControl:"default"}}); sap.ui.predefine("library/n/library",["sap/ui/core/Core","sap/ui/core/library","sap/m/library"],function(e,i,r){"use strict";sap.ui.getCore().initLibrary({name:"library.n",version:"${version}",dependencies:["sap.ui.core","sap.m"],designtime:"library/n/designtime/library.designtime",types:[],interfaces:[],controls:[],elements:[],extensions:{flChangeHandlers:{"library.n.Button":"library/n/flexibility/Button"},"sap.ui.support":{publicRules:true,internalRules:false}}});return sap.m}); diff --git a/test/expected/build/library.n/preload/resources/library/n/resources.json b/test/expected/build/library.n/preload/resources/library/n/resources.json index dd9c9ec94..f53fe5ec9 100644 --- a/test/expected/build/library.n/preload/resources/library/n/resources.json +++ b/test/expected/build/library.n/preload/resources/library/n/resources.json @@ -8,12 +8,13 @@ { "name": "Button.js", "module": "library/n/Button.js", - "size": 1201, + "size": 1256, "required": [ "library/n/library.js", "sap/ui/core/Control.js" ], "condRequired": [ + "library/n/changeHandler/SplitButton.js", "sap/ui/core/format/DateFormat.js" ], "dynRequired": true @@ -64,11 +65,9 @@ { "name": "library-preload.js", "module": "library/n/library-preload.js", - "size": 2012, + "size": 2062, "merged": true, "required": [ - "../changeHandler/SplitButton.js", - "./library.js", "sap/m/library.js", "sap/ui/core/Control.js", "sap/ui/core/Core.js", @@ -123,7 +122,7 @@ }, { "name": "resources.json", - "size": 3037 + "size": 3024 }, { "name": "rules/Button.support.js", diff --git a/test/fixtures/library.n/src/library/n/Button.js b/test/fixtures/library.n/src/library/n/Button.js index 70f7b4918..5f4c66781 100644 --- a/test/fixtures/library.n/src/library/n/Button.js +++ b/test/fixtures/library.n/src/library/n/Button.js @@ -29,6 +29,7 @@ sap.ui.define([ renderer: { apiVersion: 2, render: function(oRm, oButton) { + sap.ui.requireSync("./changeHandler/SplitButton"); oRm.openStart("button", oButton); oRm.class("libNBtnBase"); oRm.openEnd(); diff --git a/test/lib/lbt/analyzer/JSModuleAnalyzer.js b/test/lib/lbt/analyzer/JSModuleAnalyzer.js index d659808dd..0975f5b14 100644 --- a/test/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/test/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -240,44 +240,40 @@ test.cb("OldStyleBundle", (t) => { "modules/bundle-oldstyle.js", "sap-ui-core.js", [ - "../model/BindingMode.js", - "../model/CompositeBinding.js", - "../model/Context.js", - "../model/FormatException.js", - "../model/ListBinding.js", - "../model/Model.js", - "../model/ParseException.js", - "../model/TreeBinding.js", - "../model/Type.js", - "../model/ValidateException.js", - "./BindingParser.js", - "./Component.js", - "./Configuration.js", - "./Control.js", - "./DataType.js", - "./Element.js", - "./ElementMetadata.js", - "./EventProvider.js", - "./FocusHandler.js", - "./ManagedObjectMetadata.js", - "./Object.js", - "./RenderManager.js", - "./ResizeHandler.js", - "./ThemeCheck.js", - "./UIArea.js", - "./message/MessageManager.js", "jquery.sap.dom.js", - "jquery.sap.mobile.js", - "jquery.sap.properties.js", - "jquery.sap.resources.js", "jquery.sap.script.js", - "jquery.sap.sjax.js", - "jquery.sap.strings.js", - "sap/ui/Global.js", + "sap/ui/base/Object.js", "sap/ui/base/BindingParser.js", "sap/ui/base/EventProvider.js", + "sap/ui/base/ManagedObjectMetadata.js", + "sap/ui/model/BindingMode.js", + "sap/ui/model/CompositeBinding.js", + "sap/ui/model/Context.js", + "sap/ui/model/FormatException.js", + "sap/ui/model/ListBinding.js", + "sap/ui/model/Model.js", + "sap/ui/model/ParseException.js", + "sap/ui/model/TreeBinding.js", + "sap/ui/model/Type.js", + "sap/ui/model/ValidateException.js", + "jquery.sap.strings.js", + "sap/ui/Global.js", "sap/ui/base/Interface.js", - "sap/ui/base/Object.js" + "sap/ui/core/Component.js", + "sap/ui/core/Configuration.js", + "sap/ui/core/Control.js", + "sap/ui/core/Element.js", + "sap/ui/core/ElementMetadata.js", + "sap/ui/core/FocusHandler.js", + "sap/ui/core/RenderManager.js", + "sap/ui/core/ResizeHandler.js", + "sap/ui/core/ThemeCheck.js", + "sap/ui/core/UIArea.js", + "sap/ui/core/message/MessageManager.js", + "jquery.sap.mobile.js", + "jquery.sap.properties.js", + "jquery.sap.resources.js", + "jquery.sap.sjax.js" ], [], [ @@ -306,44 +302,40 @@ test.cb("OldStyleBundleV2", (t) => { "modules/bundle-oldstyle-v2.js", "sap-ui-core.js", [ - "../model/BindingMode.js", - "../model/CompositeBinding.js", - "../model/Context.js", - "../model/FormatException.js", - "../model/ListBinding.js", - "../model/Model.js", - "../model/ParseException.js", - "../model/TreeBinding.js", - "../model/Type.js", - "../model/ValidateException.js", - "./BindingParser.js", - "./Component.js", - "./Configuration.js", - "./Control.js", - "./DataType.js", - "./Element.js", - "./ElementMetadata.js", - "./EventProvider.js", - "./FocusHandler.js", - "./ManagedObjectMetadata.js", - "./Object.js", - "./RenderManager.js", - "./ResizeHandler.js", - "./ThemeCheck.js", - "./UIArea.js", - "./message/MessageManager.js", "jquery.sap.dom.js", - "jquery.sap.mobile.js", - "jquery.sap.properties.js", - "jquery.sap.resources.js", "jquery.sap.script.js", - "jquery.sap.sjax.js", - "jquery.sap.strings.js", - "sap/ui/Global.js", + "sap/ui/base/Object.js", "sap/ui/base/BindingParser.js", "sap/ui/base/EventProvider.js", + "sap/ui/base/ManagedObjectMetadata.js", + "sap/ui/model/BindingMode.js", + "sap/ui/model/CompositeBinding.js", + "sap/ui/model/Context.js", + "sap/ui/model/FormatException.js", + "sap/ui/model/ListBinding.js", + "sap/ui/model/Model.js", + "sap/ui/model/ParseException.js", + "sap/ui/model/TreeBinding.js", + "sap/ui/model/Type.js", + "sap/ui/model/ValidateException.js", + "jquery.sap.strings.js", + "sap/ui/Global.js", "sap/ui/base/Interface.js", - "sap/ui/base/Object.js" + "sap/ui/core/Component.js", + "sap/ui/core/Configuration.js", + "sap/ui/core/Control.js", + "sap/ui/core/Element.js", + "sap/ui/core/ElementMetadata.js", + "sap/ui/core/FocusHandler.js", + "sap/ui/core/RenderManager.js", + "sap/ui/core/ResizeHandler.js", + "sap/ui/core/ThemeCheck.js", + "sap/ui/core/UIArea.js", + "sap/ui/core/message/MessageManager.js", + "jquery.sap.mobile.js", + "jquery.sap.properties.js", + "jquery.sap.resources.js", + "jquery.sap.sjax.js" ], [], [ @@ -372,63 +364,58 @@ test.cb("EvoBundle", (t) => { "modules/bundle-evo.js", "sap-ui-core.js", [ - "../model/BindingMode.js", - "../model/CompositeBinding.js", - "../model/Context.js", - "../model/FormatException.js", - "../model/ParseException.js", - "../model/StaticBinding.js", - "../model/Type.js", - "../model/ValidateException.js", - "./BindingParser.js", - "./Component.js", - "./Configuration.js", - "./Control.js", - "./DataType.js", - "./Element.js", - "./ElementMetadata.js", - "./EventProvider.js", - "./FocusHandler.js", - "./Log.js", - "./ManagedObjectMetadata.js", - "./Object.js", - "./RenderManager.js", - "./ResizeHandler.js", - "./ThemeCheck.js", - "./UIArea.js", - "./message/MessageManager.js", - "sap/base/i18n/ResourceBundle.js", + "sap/base/util/now.js", + "sap/base/util/Version.js", + "sap/ui/dom/getComputedStyleFix.js", + "sap/ui/dom/activeElementFix.js", + "sap/ui/dom/includeScript.js", + "sap/ui/dom/includeStylesheet.js", + "sap/ui/core/support/Hotkeys.js", + "sap/ui/security/FrameOptions.js", + "sap/ui/performance/Measurement.js", + "sap/ui/performance/trace/Interaction.js", + "sap/ui/base/syncXHRFix.js", "sap/base/util/LoaderExtensions.js", + "sap/base/util/defineLazyProperty.js", "sap/base/util/ObjectPath.js", - "sap/base/util/Version.js", - "sap/base/util/array/uniqueSort.js", + "sap/base/util/isPlainObject.js", + "sap/ui/base/Object.js", + "sap/ui/base/BindingParser.js", + "sap/ui/base/EventProvider.js", + "sap/ui/base/ManagedObjectMetadata.js", + "sap/ui/model/BindingMode.js", + "sap/ui/model/StaticBinding.js", + "sap/ui/model/CompositeBinding.js", + "sap/ui/model/Context.js", + "sap/ui/model/FormatException.js", + "sap/ui/model/ParseException.js", + "sap/ui/model/Type.js", + "sap/ui/model/ValidateException.js", + "sap/ui/base/SyncPromise.js", + "sap/ui/util/ActivityDetection.js", "sap/base/util/deepClone.js", "sap/base/util/deepEqual.js", - "sap/base/util/defineLazyProperty.js", - "sap/base/util/each.js", - "sap/base/util/isEmptyObject.js", - "sap/base/util/isPlainObject.js", - "sap/base/util/now.js", "sap/base/util/uid.js", "sap/ui/Global.js", - "sap/ui/base/BindingParser.js", - "sap/ui/base/EventProvider.js", "sap/ui/base/Interface.js", - "sap/ui/base/Object.js", - "sap/ui/base/SyncPromise.js", - "sap/ui/base/syncXHRFix.js", - "sap/ui/core/support/Hotkeys.js", - "sap/ui/dom/activeElementFix.js", - "sap/ui/dom/getComputedStyleFix.js", + "sap/ui/core/Component.js", + "sap/ui/core/Configuration.js", + "sap/ui/core/Control.js", + "sap/ui/core/Element.js", + "sap/ui/core/ElementMetadata.js", + "sap/ui/core/FocusHandler.js", + "sap/ui/core/RenderManager.js", + "sap/ui/core/ResizeHandler.js", + "sap/ui/core/ThemeCheck.js", + "sap/ui/core/UIArea.js", + "sap/ui/core/message/MessageManager.js", "sap/ui/dom/getScrollbarSize.js", - "sap/ui/dom/includeScript.js", - "sap/ui/dom/includeStylesheet.js", - "sap/ui/events/jquery/EventSimulation.js", - "sap/ui/performance/Measurement.js", - "sap/ui/performance/trace/Interaction.js", + "sap/base/i18n/ResourceBundle.js", + "sap/base/util/array/uniqueSort.js", "sap/ui/performance/trace/initTraces.js", - "sap/ui/security/FrameOptions.js", - "sap/ui/util/ActivityDetection.js" + "sap/base/util/isEmptyObject.js", + "sap/base/util/each.js", + "sap/ui/events/jquery/EventSimulation.js" ], [], [ From b5aebfe2ec4d3c787cd052e1cc6b14c754c9b4e2 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 15 Jul 2020 12:32:14 +0200 Subject: [PATCH 29/88] make sure dbg files are not just copied but evaluated on their own --- lib/processors/resourceListCreator.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 7310f64da..38446af4b 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -200,6 +200,10 @@ class ResourcesList { // --- transient state --- this.name = prefix; + /** + * + * @type {Map} + */ this.resourcesByName = new Map(); } @@ -213,18 +217,15 @@ class ResourcesList { // search for a resource with the same name let myInfo = this.resourcesByName.get(relativeName); + // this is the assumption, that the debug one is the same as the non-dbg one if ( myInfo == null ) { + myInfo = new ResourceInfo(relativeName); + const nonDebugName = ResourcesList.getNonDebugName(relativeName); // when not found, check if the given resource is a debug resource and share the information with the non-dbg version - const nondbg = ResourcesList.getNonDebugName(relativeName); - if ( nondbg != null && this.resourcesByName.has(nondbg) ) { - myInfo = new ResourceInfo(relativeName); - myInfo.copyFrom(this.name, this.resourcesByName.get(nondbg)); - this.resources.push(myInfo); - this.resourcesByName.set(relativeName, myInfo); + if ( nonDebugName != null && this.resourcesByName.has(nonDebugName)) { + const nonDbgResource = this.resourcesByName.get(nonDebugName); + myInfo.module = nonDbgResource.module; } - } - if ( myInfo == null ) { - myInfo = new ResourceInfo(relativeName); myInfo.size = info.size; this.resources.push(myInfo); this.resourcesByName.set(relativeName, myInfo); From a5f39576e5c37d159e585b33332fb469e3ffbfb3 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 15 Jul 2020 14:30:46 +0200 Subject: [PATCH 30/88] ensure that ResourceInfo#format is also copied from original to dbg resource --- lib/lbt/resources/ModuleInfo.js | 10 +++++++++- lib/processors/resourceListCreator.js | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/lbt/resources/ModuleInfo.js b/lib/lbt/resources/ModuleInfo.js index bcdb3011e..5c8182e7d 100644 --- a/lib/lbt/resources/ModuleInfo.js +++ b/lib/lbt/resources/ModuleInfo.js @@ -59,7 +59,7 @@ class ModuleInfo { * 'raw' modules are modules that don't use UI5's module system (require/declare) * TODO align with module format (ui5, amd, es6, raw) */ - this.rawModule = false; + this._rawModule = false; /** * Whether the module requires top level scope (true) or whether it can be embedded @@ -192,6 +192,14 @@ class ModuleInfo { } } + get rawModule() { + return this._rawModule; + } + + set rawModule(value) { + this._rawModule = value; + } + get dependencies() { return Object.keys(this._dependencies); } diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 38446af4b..3172d99b2 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -221,10 +221,12 @@ class ResourcesList { if ( myInfo == null ) { myInfo = new ResourceInfo(relativeName); const nonDebugName = ResourcesList.getNonDebugName(relativeName); - // when not found, check if the given resource is a debug resource and share the information with the non-dbg version + // when not found, check if the given resource is a debug resource and + // share the information with the non-dbg version if ( nonDebugName != null && this.resourcesByName.has(nonDebugName)) { const nonDbgResource = this.resourcesByName.get(nonDebugName); myInfo.module = nonDbgResource.module; + myInfo.format = nonDbgResource.format; } myInfo.size = info.size; this.resources.push(myInfo); From d567d5473276cb0d667722811565973b16339ade Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 16 Jul 2020 07:34:46 +0200 Subject: [PATCH 31/88] restore adding the debug information the original and the debug resources should be the same. This was changed because sap-ui-core-dbg.js is not the same as its source sap-ui-core.js. sap-ui-core-dbg.js is a bundle and not the corresponding debug file of sap-ui-core.js --- lib/processors/resourceListCreator.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 3172d99b2..d01eb2182 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -217,17 +217,20 @@ class ResourcesList { // search for a resource with the same name let myInfo = this.resourcesByName.get(relativeName); + if ( myInfo == null ) { + // when not found, check if the given resource is a debug resource and share the information with the non-dbg version + const nondbg = ResourcesList.getNonDebugName(relativeName); + if ( nondbg != null && this.resourcesByName.has(nondbg) ) { + myInfo = new ResourceInfo(relativeName); + myInfo.copyFrom(this.name, this.resourcesByName.get(nondbg)); + this.resources.push(myInfo); + this.resourcesByName.set(relativeName, myInfo); + } + } + // this is the assumption, that the debug one is the same as the non-dbg one if ( myInfo == null ) { myInfo = new ResourceInfo(relativeName); - const nonDebugName = ResourcesList.getNonDebugName(relativeName); - // when not found, check if the given resource is a debug resource and - // share the information with the non-dbg version - if ( nonDebugName != null && this.resourcesByName.has(nonDebugName)) { - const nonDbgResource = this.resourcesByName.get(nonDebugName); - myInfo.module = nonDbgResource.module; - myInfo.format = nonDbgResource.format; - } myInfo.size = info.size; this.resources.push(myInfo); this.resourcesByName.set(relativeName, myInfo); From 538e9c18f3cb3ff2678ba3ccfb85ae25d39c7979 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 27 Jul 2020 13:59:32 +0200 Subject: [PATCH 32/88] Make terser leave @ui5-bundle-raw-include comment @ui5-bundle-raw-include comment is required to identify the module as raw-include. --- lib/processors/uglifier.js | 4 +- test/lib/tasks/uglify.js | 94 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/lib/processors/uglifier.js b/lib/processors/uglifier.js index a20707397..82a09a927 100644 --- a/lib/processors/uglifier.js +++ b/lib/processors/uglifier.js @@ -1,5 +1,5 @@ const terser = require("terser"); -const copyrightCommentsPattern = /copyright|\(c\)(?:[0-9]+|\s+[0-9A-za-z])|released under|license|\u00a9/i; +const copyrightCommentsAndRawIncludePattern = /copyright|\(c\)(?:[0-9]+|\s+[0-9A-za-z])|released under|license|\u00a9|@ui5-bundle-raw-include/i; /** * Minifies the supplied resources. @@ -18,7 +18,7 @@ module.exports = function({resources}) { }, { warnings: false, output: { - comments: copyrightCommentsPattern, + comments: copyrightCommentsAndRawIncludePattern, wrap_func_args: false }, compress: false diff --git a/test/lib/tasks/uglify.js b/test/lib/tasks/uglify.js index fe397df7d..fed2b8347 100644 --- a/test/lib/tasks/uglify.js +++ b/test/lib/tasks/uglify.js @@ -47,3 +47,97 @@ test();`; return t.deepEqual(buffer.toString(), expected, "Correct content"); }); }); + +test("integration: uglify copyright", (t) => { + const reader = resourceFactory.createAdapter({ + virBasePath: "/" + }); + const writer = resourceFactory.createAdapter({ + virBasePath: "/" + }); + const duplexCollection = new DuplexCollection({reader: reader, writer: writer}); + const content = ` +/* + * Copyright jQuery Foundation and other contributors + */ +function test(paramA) { + var variableA = paramA; + console.log(variableA); +} +test();`; + const testResource = resourceFactory.createResource({ + path: "/test.js", + string: content + }); + const expected = `/* + * Copyright jQuery Foundation and other contributors + */ +function test(t){var o=t;console.log(o)}test();`; + + return reader.write(testResource) + .then(() => { + return reader.byPath("/test.js"); + }).then(() => { + return uglify({ + workspace: duplexCollection, + options: { + pattern: "/test.js" + } + }); + }).then(() => { + return writer.byPath("/test.js").then((resource) => { + if (!resource) { + t.fail("Could not find /test.js in target locator"); + } else { + return resource.getBuffer(); + } + }); + }).then((buffer) => { + return t.deepEqual(buffer.toString(), expected, "Correct content"); + }); +}); + +test("integration: uglify raw module (@ui5-bundle-raw-include)", (t) => { + const reader = resourceFactory.createAdapter({ + virBasePath: "/" + }); + const writer = resourceFactory.createAdapter({ + virBasePath: "/" + }); + const duplexCollection = new DuplexCollection({reader: reader, writer: writer}); + const content = ` +//@ui5-bundle-raw-include sap/ui/my/module.js +function test(paramA) { + var variableA = paramA; + console.log(variableA); +} +test();`; + const testResource = resourceFactory.createResource({ + path: "/test.js", + string: content + }); + const expected = `//@ui5-bundle-raw-include sap/ui/my/module.js +function test(t){var o=t;console.log(o)}test();`; + + return reader.write(testResource) + .then(() => { + return reader.byPath("/test.js"); + }).then(() => { + return uglify({ + workspace: duplexCollection, + options: { + pattern: "/test.js" + } + }); + }).then(() => { + return writer.byPath("/test.js").then((resource) => { + if (!resource) { + t.fail("Could not find /test.js in target locator"); + } else { + return resource.getBuffer(); + } + }); + }).then((buffer) => { + return t.deepEqual(buffer.toString(), expected, "Correct content"); + }); +}); From c28add248bc5d965046f09235abe0b069621e580 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 29 Jul 2020 17:28:37 +0200 Subject: [PATCH 33/88] Add hard coded sap-ui-core-dbg.js analysis sap-ui-core-dbg.js is a bundle with different content than source file --- lib/processors/resourceListCreator.js | 32 ++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index d01eb2182..60b163dc7 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -208,16 +208,18 @@ class ResourcesList { } /** + * Add ResourceInfo to list * * @param {ResourceInfo} info + * @param {boolean} shareDebugInformation */ - add(info) { + add(info, shareDebugInformation=true) { const relativeName = ResourcesList.makePathRelativeTo(this.name, info.name); // search for a resource with the same name let myInfo = this.resourcesByName.get(relativeName); - if ( myInfo == null ) { + if ( myInfo == null && shareDebugInformation) { // when not found, check if the given resource is a debug resource and share the information with the non-dbg version const nondbg = ResourcesList.getNonDebugName(relativeName); if ( nondbg != null && this.resourcesByName.has(nondbg) ) { @@ -403,6 +405,16 @@ const DEFAULT_SUPPORT_RESOURCES_FILTER = [ "**/*.support.js" ]; +/** + * Hard coded debug bundle, to trigger separate analysis for this __filename + * because sap-ui-core.js and sap-ui-core-dbg.js have different includes + * + * @type {string[]} + */ +const DEBUG_BUNDLES = [ + "sap-ui-core-dbg.js" +]; + const LOCALE = /^((?:[^/]+\/)*[^/]+?)_([A-Z]{2}(?:_[A-Z]{2}(?:_[A-Z0-9_]+)?)?)(\.properties|\.hdbtextbundle)$/i; const THEME = /^((?:[^/]+\/)*)themes\/([^/]+)\//; @@ -607,19 +619,20 @@ class ResourceCollector { return filtersByComponent; } - groupResourcesByComponents() { + groupResourcesByComponents(options) { const orphanFilters = this.createOrphanFilters(); - + const debugBundlesFilter = ResourceFilterList.fromString(options.debugBundles); for (const resource of this._resources.values()) { let contained = false; for (const [prefix, list] of this._components.entries()) { + const isDebugBundle = debugBundlesFilter.matches(resource.name); if ( resource.name.startsWith(prefix) ) { - list.add(resource); + list.add(resource, !isDebugBundle); contained = true; } else if ( orphanFilters.has(prefix) ) { // log.verbose(` checking '${resource.name}' against orphan filter '${orphanFilters.get(prefix)}' (${prefix})`); if ( orphanFilters.get(prefix).matches(resource.name) ) { - list.add(resource); + list.add(resource, !isDebugBundle); contained = true; } } @@ -673,7 +686,8 @@ module.exports = async function({resources}, options) { debugResources: DEFAULT_DEBUG_RESOURCES_FILTER.join(","), mergedResources: DEFAULT_BUNDLE_RESOURCES_FILTER.join(","), designtimeResources: DEFAULT_DESIGNTIME_RESOURCES_FILTER.join(","), - supportResources: DEFAULT_SUPPORT_RESOURCES_FILTER.join(",") + supportResources: DEFAULT_SUPPORT_RESOURCES_FILTER.join(","), + debugBundles: DEBUG_BUNDLES.join(",") }, options); const pool = new LocatorResourcePool(); @@ -703,7 +717,9 @@ module.exports = async function({resources}, options) { }); // group resources by components and create ResourcesLists - collector.groupResourcesByComponents(); + collector.groupResourcesByComponents({ + debugBundles: options.debugBundles + }); const resourceLists = []; From c9cff7450c37f1113eb845148c9dae0a81cbe11f Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Fri, 31 Jul 2020 13:46:19 +0200 Subject: [PATCH 34/88] Improve analysis for sap.ui.require calls use depths to distinguish nested sap.ui.require calls from top level ones --- lib/lbt/analyzer/JSModuleAnalyzer.js | 63 ++++++++++----- test/fixtures/lbt/modules/functionDefine.js | 67 +++++++++++++++ test/fixtures/lbt/modules/nestedRequire.js | 90 +++++++++++++++++++++ test/lib/lbt/analyzer/JSModuleAnalyzer.js | 36 ++++++++- 4 files changed, 235 insertions(+), 21 deletions(-) create mode 100644 test/fixtures/lbt/modules/functionDefine.js create mode 100644 test/fixtures/lbt/modules/nestedRequire.js diff --git a/lib/lbt/analyzer/JSModuleAnalyzer.js b/lib/lbt/analyzer/JSModuleAnalyzer.js index 8665dbb4e..b2110103e 100644 --- a/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -268,7 +268,11 @@ class JSModuleAnalyzer { let nModuleDeclarations = 0; // first analyze the whole AST... - visit(ast, false); + const rootNode = { + node: null, + parent: null + }; + visit(ast, false, rootNode); // ...then all the comments if ( Array.isArray(ast.comments) ) { @@ -341,15 +345,19 @@ class JSModuleAnalyzer { } } - function visit(node, conditional) { + function visit(node, conditional, parentNode) { // console.log("visiting ", node); + const nodeToAdd = { + node, + parent: parentNode + }; if ( node == null ) { return; } if ( Array.isArray(node) ) { - node.forEach((child) => visit(child, conditional)); + node.forEach((child) => visit(child, conditional, nodeToAdd)); return; } @@ -383,7 +391,7 @@ class JSModuleAnalyzer { } if ( iArg < args.length && isCallableExpression(args[iArg]) ) { // unconditionally execute the factory function - visit(args[iArg].body, conditional); + visit(args[iArg].body, conditional, nodeToAdd); } } else if ( isMethodCall(node, CALL_REQUIRE_PREDEFINE) || isMethodCall(node, CALL_SAP_UI_PREDEFINE) ) { // recognized a call to require.predefine() or sap.ui.predefine() @@ -400,14 +408,16 @@ class JSModuleAnalyzer { } if ( iArg < args.length && isCallableExpression(args[iArg]) ) { // unconditionally execute the factory function - visit(args[iArg].body, conditional); + visit(args[iArg].body, conditional, nodeToAdd); } } else if ( isMethodCall(node, CALL_SAP_UI_REQUIRE) || isMethodCall(node, CALL_AMD_REQUIRE) ) { // recognized a call to require() or sap.ui.require() - if ( isMethodCall(node, CALL_SAP_UI_REQUIRE) ) { - info.setFormat(ModuleFormat.UI5_DEFINE); - } else { - info.setFormat(ModuleFormat.AMD); + if (info.format || calculateDepths(parentNode) < 5) { + if ( isMethodCall(node, CALL_SAP_UI_REQUIRE) ) { + info.setFormat(ModuleFormat.UI5_DEFINE); + } else { + info.setFormat(ModuleFormat.AMD); + } } let iArg = 0; const args = node.arguments; @@ -419,15 +429,20 @@ class JSModuleAnalyzer { } if ( iArg < args.length && isCallableExpression(args[iArg]) ) { // analyze the callback function - visit(args[iArg].body, conditional); + visit(args[iArg].body, conditional, nodeToAdd); } } else if ( isMethodCall(node, CALL_REQUIRE_SYNC) || isMethodCall(node, CALL_SAP_UI_REQUIRE_SYNC) ) { // recognizes a call to sap.ui.requireSync - info.setFormat(ModuleFormat.UI5_DEFINE); + if (info.format || calculateDepths(parentNode) < 5) { + info.setFormat(ModuleFormat.UI5_DEFINE); + } + onSapUiRequireSync(node, conditional, info.name); } else if ( isMethodCall(node, CALL_JQUERY_SAP_REQUIRE) ) { // recognizes a call to jQuery.sap.require - info.setFormat(ModuleFormat.UI5_LEGACY); + if (info.format || calculateDepths(parentNode) < 5) { + info.setFormat(ModuleFormat.UI5_LEGACY); + } onJQuerySapRequire(node, conditional); } else if ( isMethodCall(node, CALL_JQUERY_SAP_REGISTER_PRELOADED_MODULES) ) { // recognizes a call to jQuery.sap.registerPreloadedModules @@ -439,13 +454,13 @@ class JSModuleAnalyzer { onRegisterPreloadedModules(node, /* evoSyntax= */ true); } else if ( isCallableExpression(node.callee) ) { // recognizes a scope function declaration + argument - visit(node.arguments, conditional); + visit(node.arguments, conditional, nodeToAdd); // NODE-TODO defaults of callee? - visit(node.callee.body, conditional); + visit(node.callee.body, conditional, nodeToAdd); } else { // default visit for ( const key of condKeys ) { - visit(node[key.key], key.conditional || conditional); + visit(node[key.key], key.conditional || conditional, nodeToAdd); } } break; @@ -460,12 +475,12 @@ class JSModuleAnalyzer { if ( node.test.type == Syntax.UnaryExpression && node.test.operator === "!" && isMethodCall(node.test.argument, CALL_JQUERY_SAP_IS_DECLARED ) ) { - visit(node.consequent, conditional); - visit(node.alternate, true); + visit(node.consequent, conditional, nodeToAdd); + visit(node.alternate, true, nodeToAdd); } else { // default visit for ( const key of condKeys ) { - visit(node[key.key], key.conditional || conditional); + visit(node[key.key], key.conditional || conditional, nodeToAdd); } } break; @@ -477,12 +492,22 @@ class JSModuleAnalyzer { } // default visit for ( const key of condKeys ) { - visit(node[key.key], key.conditional || conditional); + visit(node[key.key], key.conditional || conditional, nodeToAdd); } break; } } + function calculateDepths(nodeWrapper) { + let count = 0; + let parent = nodeWrapper.parent; + while (parent) { + count++; + parent = parent.parent; + } + return count; + } + function onDeclare(node) { const args = node.arguments; if ( args.length > 0 && isString(args[0]) ) { diff --git a/test/fixtures/lbt/modules/functionDefine.js b/test/fixtures/lbt/modules/functionDefine.js new file mode 100644 index 000000000..d8e4f61e3 --- /dev/null +++ b/test/fixtures/lbt/modules/functionDefine.js @@ -0,0 +1,67 @@ +/*! + * ${copyright} + */ + +/** + * FEATURE TO INCREASE DEVELOPMENT EXPERIENCE! NO PRODUCTIVE USAGE ALLOWED! + */ +(function() { + "use strict"; + + /** + * wraps the definition of the MyFile in order to be able to delay + * the definition until the body is loaded and sap.ui.define is available + */ + function defineMyFile() { + + // Provides class sap.ui.core.plugin.MyFile + sap.ui.define('sap/ui/core/plugin/MyFile', [ + 'sap/ui/thirdparty/jquery'], + function(jQuery) { + + /** + * Creates an instance of the class sap.ui.core.plugin.MyFile + * + * @version ${version} + * @private + * @alias sap.ui.core.plugin.MyFile + */ + var MyFile = function() { + }; + + + /** + * Create the sap.ui.core.plugin.MyFile plugin and + * register it within the sap.ui.core.Core. + */ + var oThis = new MyFile(); + sap.ui.getCore().registerPlugin(oThis); + + /** + * Triggers a less refresh and updates the theming parameters. + * + * @private + */ + MyFile.refresh = function() { + }; + + return MyFile; + + }); + + } + + // check for "sap.ui.define" being already available + // - when available immediately define the MyFile + // - if not we delay the definition till the body is loaded + if (!(window.sap && window.sap.ui && window.sap.ui.define)) { + var fnHandler = function() { + document.removeEventListener("DOMContentLoaded", fnHandler, false); + defineMyFile(); + }; + document.addEventListener("DOMContentLoaded", fnHandler, false); + } else { + defineMyFile(); + } + +}()); \ No newline at end of file diff --git a/test/fixtures/lbt/modules/nestedRequire.js b/test/fixtures/lbt/modules/nestedRequire.js new file mode 100644 index 000000000..ca6d3001e --- /dev/null +++ b/test/fixtures/lbt/modules/nestedRequire.js @@ -0,0 +1,90 @@ +/*! + * ${copyright} + */ + +/* + * IMPORTANT: This is a private module, its API must not be used and is subject to change. + * Code other than the Core tests must not yet introduce dependencies to this module. + */ + +/*global document, sap */ +(function(deps, callback) { + + "use strict"; + + //extract base URL from script tag + var oScriptTag, mMatch, sBaseUrl; + + oScriptTag = document.querySelector("[src$='myfile.js']"); + if (oScriptTag) { + mMatch = /^(.*\/)?myfile.js/.exec(oScriptTag.getAttribute("src")); + if (mMatch) { + sBaseUrl = mMatch[1] + "../../../../"; + } + } + + if (sBaseUrl == null) { + throw new Error("myfile.js: could not identify script tag!"); + } + + function loadScripts(urls, callback) { + var pending = urls.length, + errors = 0; + + if (pending === 0) { + callback(); + return; + } + + function listener(e) { + pending--; + if ( e.type === 'error' ) { + errors++; + } + e.target.removeEventListener("load", listener); + e.target.removeEventListener("error", listener); + if ( pending === 0 && errors === 0 && callback ) { + callback(); + } + } + + for ( var i = 0; i < urls.length; i++ ) { + var script = document.createElement("script"); + script.addEventListener("load", listener); + script.addEventListener("error", listener); + script.src = sBaseUrl + urls[i]; + document.head.appendChild(script); + } + } + + // define the necessary polyfills to be loaded + var aPolyfills = []; + + // cascade 1: polyfills, can all be loaded in parallel + loadScripts(aPolyfills, function() { + // cascade 2: the loader + loadScripts([ + "ui5loader.js" + ], function() { + // cascade 3: the loader configuration script + sap.ui.loader.config({ + async:true + }); + loadScripts([ + "ui5loader-autoconfig.js" + ], function() { + sap.ui.require(deps, callback); + }); + }); + }); + +}([ + "sap/ui/test/starter/_utils" +], function(utils) { + "use strict"; + + var oSuiteReadyEvent = document.createEvent("CustomEvent"); + oSuiteReadyEvent.initCustomEvent("sap-ui-testsuite-ready", true, true, {}); + window.dispatchEvent(oSuiteReadyEvent); + +})); \ No newline at end of file diff --git a/test/lib/lbt/analyzer/JSModuleAnalyzer.js b/test/lib/lbt/analyzer/JSModuleAnalyzer.js index 0975f5b14..c6043c1dd 100644 --- a/test/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/test/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -67,7 +67,8 @@ function analyzeModule( expectedDependencies, expectedConditionalDependencies, expectedSubmodules, - ignoreImplicitDependencies + ignoreImplicitDependencies, + rawModule ) { // analyze(file, name).then( (info) => { @@ -96,6 +97,13 @@ function analyzeModule( } t.false(info.dynamicDependencies, "no use of dynamic dependencies should have been detected"); + if (rawModule) { + t.true(info.rawModule, + "raw module"); + } else { + t.false(info.rawModule, + "ui5 module"); + } }).then(() => t.end(), (e) => t.fail(`failed to analyze module with error: ${e.message}`)); } @@ -114,6 +122,7 @@ test.cb("DefineWithLegacyCalls", analyzeModule, "modules/define_with_legacy_call test.cb("OldStyleModuleWithoutDeclare", function(t) { analyze("modules/no_declare_but_requires.js", null).then((info) => { t.is(info.name, null, "module name should be null"); + t.false(info.rawModule, "ui5 module"); assertModuleNamesEqual(t, info.dependencies, ["dependency1.js", "dependency2.js", "jquery.sap.global.js"], @@ -122,7 +131,7 @@ test.cb("OldStyleModuleWithoutDeclare", function(t) { }); }); -test.cb("NotAnUI5Module", analyzeModule, "modules/not_a_module.js", "modules/not_a_module.js", NO_DEPENDENCIES); +test.cb("NotAnUI5Module", analyzeModule, "modules/not_a_module.js", "modules/not_a_module.js", NO_DEPENDENCIES, NO_DEPENDENCIES, NO_DEPENDENCIES, NO_DEPENDENCIES, true); test.cb("AMDSpecialDependenciesShouldBeIgnored", (t) => { analyzeModule(t, @@ -456,6 +465,8 @@ test("Bundle", (t) => { ]; t.deepEqual(info.subModules, expected, "module dependencies should match"); t.truthy(info.dependencies.every((dep) => !info.isConditionalDependency(dep)), "none of the dependencies must be 'conditional'"); + t.false(info.rawModule, + "ui5 module"); }); }); @@ -483,6 +494,8 @@ test("ES6 Syntax", (t) => { "all dependencies other than 'conditional/*' and 'static/*' should be implicit"); t.false(info.dynamicDependencies, "no use of dynamic dependencies should have been detected"); + t.false(info.rawModule, + "ui5 module"); }); }); }); @@ -491,6 +504,8 @@ test("Dynamic import (declare/require)", (t) => { return analyze("modules/declare_dynamic_require.js").then((info) => { t.true(info.dynamicDependencies, "the use of dynamic dependencies should have been detected"); + t.false(info.rawModule, + "ui5 module"); }); }); @@ -498,6 +513,8 @@ test("Dynamic import (define/require)", (t) => { return analyze("modules/amd_dynamic_require.js").then((info) => { t.true(info.dynamicDependencies, "the use of dynamic dependencies should have been detected"); + t.false(info.rawModule, + "ui5 module"); }); }); @@ -505,7 +522,22 @@ test("Dynamic import (define/requireSync)", (t) => { return analyze("modules/amd_dynamic_require_sync.js").then((info) => { t.true(info.dynamicDependencies, "the use of dynamic dependencies should have been detected"); + t.false(info.rawModule, + "ui5 module"); + }); +}); + +test("Nested require", (t) => { + return analyze("modules/nestedRequire.js").then((info) => { + t.true(info.rawModule, + "raw module"); }); }); +test("Toplevel define", (t) => { + return analyze("modules/functionDefine.js").then((info) => { + t.true(info.rawModule, + "raw module"); + }); +}); From 2ab91f6626ed8f10d62d1b576f2c60fd3e5d86b3 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Fri, 31 Jul 2020 16:24:32 +0200 Subject: [PATCH 35/88] Adjust Analysis logic Identify ui5 modules base don module declaration --- lib/lbt/analyzer/JSModuleAnalyzer.js | 83 ++++++++++++----------- lib/lbt/resources/ModuleInfo.js | 6 ++ test/lib/lbt/analyzer/JSModuleAnalyzer.js | 2 +- 3 files changed, 51 insertions(+), 40 deletions(-) diff --git a/lib/lbt/analyzer/JSModuleAnalyzer.js b/lib/lbt/analyzer/JSModuleAnalyzer.js index b2110103e..557e931fe 100644 --- a/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -267,6 +267,20 @@ class JSModuleAnalyzer { */ let nModuleDeclarations = 0; + /** + * Whether or not this is a UI5 module + * + * When in the non-conditional module execution there is a call to: + *
    + *
  • sap.ui.define call
  • + *
  • jQuery.sap.declare call
  • + *
+ * this value is true + * + * @type {boolean} + */ + let bIsUi5Module = false; + // first analyze the whole AST... const rootNode = { node: null, @@ -318,7 +332,7 @@ class JSModuleAnalyzer { info.addImplicitDependency(UI5ClientConstants.MODULE__UI5LOADER_AUTOCONFIG); } - if ( nModuleDeclarations === 0 && info.dependencies.length === 0 && info.subModules.length === 0 ) { + if ( !bIsUi5Module ) { // when there are no indicators for module APIs, mark the module as 'raw' module info.rawModule = true; } @@ -345,19 +359,15 @@ class JSModuleAnalyzer { } } - function visit(node, conditional, parentNode) { + function visit(node, conditional) { // console.log("visiting ", node); - const nodeToAdd = { - node, - parent: parentNode - }; if ( node == null ) { return; } if ( Array.isArray(node) ) { - node.forEach((child) => visit(child, conditional, nodeToAdd)); + node.forEach((child) => visit(child, conditional)); return; } @@ -368,6 +378,7 @@ class JSModuleAnalyzer { // recognized a call to jQuery.sap.declare() nModuleDeclarations++; info.setFormat(ModuleFormat.UI5_LEGACY); + bIsUi5Module = true; onDeclare(node); } else if ( !conditional && (isMethodCall(node, CALL_SAP_UI_DEFINE) || isMethodCall(node, CALL_AMD_DEFINE)) ) { @@ -379,6 +390,7 @@ class JSModuleAnalyzer { } else { info.setFormat(ModuleFormat.AMD); } + bIsUi5Module = true; onDefine(node); const args = node.arguments; @@ -391,10 +403,13 @@ class JSModuleAnalyzer { } if ( iArg < args.length && isCallableExpression(args[iArg]) ) { // unconditionally execute the factory function - visit(args[iArg].body, conditional, nodeToAdd); + visit(args[iArg].body, conditional); } } else if ( isMethodCall(node, CALL_REQUIRE_PREDEFINE) || isMethodCall(node, CALL_SAP_UI_PREDEFINE) ) { // recognized a call to require.predefine() or sap.ui.predefine() + if (!conditional) { + bIsUi5Module = true; + } info.setFormat(ModuleFormat.UI5_DEFINE); onSapUiPredefine(node, conditional); @@ -408,16 +423,14 @@ class JSModuleAnalyzer { } if ( iArg < args.length && isCallableExpression(args[iArg]) ) { // unconditionally execute the factory function - visit(args[iArg].body, conditional, nodeToAdd); + visit(args[iArg].body, conditional); } } else if ( isMethodCall(node, CALL_SAP_UI_REQUIRE) || isMethodCall(node, CALL_AMD_REQUIRE) ) { // recognized a call to require() or sap.ui.require() - if (info.format || calculateDepths(parentNode) < 5) { - if ( isMethodCall(node, CALL_SAP_UI_REQUIRE) ) { - info.setFormat(ModuleFormat.UI5_DEFINE); - } else { - info.setFormat(ModuleFormat.AMD); - } + if ( isMethodCall(node, CALL_SAP_UI_REQUIRE) ) { + info.setFormat(ModuleFormat.UI5_DEFINE); + } else { + info.setFormat(ModuleFormat.AMD); } let iArg = 0; const args = node.arguments; @@ -429,38 +442,40 @@ class JSModuleAnalyzer { } if ( iArg < args.length && isCallableExpression(args[iArg]) ) { // analyze the callback function - visit(args[iArg].body, conditional, nodeToAdd); + visit(args[iArg].body, conditional); } } else if ( isMethodCall(node, CALL_REQUIRE_SYNC) || isMethodCall(node, CALL_SAP_UI_REQUIRE_SYNC) ) { // recognizes a call to sap.ui.requireSync - if (info.format || calculateDepths(parentNode) < 5) { - info.setFormat(ModuleFormat.UI5_DEFINE); - } + info.setFormat(ModuleFormat.UI5_DEFINE); onSapUiRequireSync(node, conditional, info.name); } else if ( isMethodCall(node, CALL_JQUERY_SAP_REQUIRE) ) { // recognizes a call to jQuery.sap.require - if (info.format || calculateDepths(parentNode) < 5) { - info.setFormat(ModuleFormat.UI5_LEGACY); - } + info.setFormat(ModuleFormat.UI5_LEGACY); onJQuerySapRequire(node, conditional); } else if ( isMethodCall(node, CALL_JQUERY_SAP_REGISTER_PRELOADED_MODULES) ) { // recognizes a call to jQuery.sap.registerPreloadedModules + if (!conditional) { + bIsUi5Module = true; + } info.setFormat(ModuleFormat.UI5_LEGACY); onRegisterPreloadedModules(node, /* evoSyntax= */ false); } else if ( isMethodCall(node, CALL_SAP_UI_REQUIRE_PRELOAD) ) { // recognizes a call to sap.ui.require.preload + if (!conditional) { + bIsUi5Module = true; + } info.setFormat(ModuleFormat.UI5_DEFINE); onRegisterPreloadedModules(node, /* evoSyntax= */ true); } else if ( isCallableExpression(node.callee) ) { // recognizes a scope function declaration + argument - visit(node.arguments, conditional, nodeToAdd); + visit(node.arguments, conditional); // NODE-TODO defaults of callee? - visit(node.callee.body, conditional, nodeToAdd); + visit(node.callee.body, conditional); } else { // default visit for ( const key of condKeys ) { - visit(node[key.key], key.conditional || conditional, nodeToAdd); + visit(node[key.key], key.conditional || conditional); } } break; @@ -475,12 +490,12 @@ class JSModuleAnalyzer { if ( node.test.type == Syntax.UnaryExpression && node.test.operator === "!" && isMethodCall(node.test.argument, CALL_JQUERY_SAP_IS_DECLARED ) ) { - visit(node.consequent, conditional, nodeToAdd); - visit(node.alternate, true, nodeToAdd); + visit(node.consequent, conditional); + visit(node.alternate, true); } else { // default visit for ( const key of condKeys ) { - visit(node[key.key], key.conditional || conditional, nodeToAdd); + visit(node[key.key], key.conditional || conditional); } } break; @@ -492,22 +507,12 @@ class JSModuleAnalyzer { } // default visit for ( const key of condKeys ) { - visit(node[key.key], key.conditional || conditional, nodeToAdd); + visit(node[key.key], key.conditional || conditional); } break; } } - function calculateDepths(nodeWrapper) { - let count = 0; - let parent = nodeWrapper.parent; - while (parent) { - count++; - parent = parent.parent; - } - return count; - } - function onDeclare(node) { const args = node.arguments; if ( args.length > 0 && isString(args[0]) ) { diff --git a/lib/lbt/resources/ModuleInfo.js b/lib/lbt/resources/ModuleInfo.js index 5c8182e7d..8c7271ab3 100644 --- a/lib/lbt/resources/ModuleInfo.js +++ b/lib/lbt/resources/ModuleInfo.js @@ -58,6 +58,12 @@ class ModuleInfo { /** * 'raw' modules are modules that don't use UI5's module system (require/declare) * TODO align with module format (ui5, amd, es6, raw) + * + * A raw module is a module which does not have in its non-conditional execution: + *
    + *
  • sap.ui.define call
  • + *
  • jQuery.sap.declare call
  • + *
*/ this._rawModule = false; diff --git a/test/lib/lbt/analyzer/JSModuleAnalyzer.js b/test/lib/lbt/analyzer/JSModuleAnalyzer.js index c6043c1dd..e372701d7 100644 --- a/test/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/test/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -122,7 +122,7 @@ test.cb("DefineWithLegacyCalls", analyzeModule, "modules/define_with_legacy_call test.cb("OldStyleModuleWithoutDeclare", function(t) { analyze("modules/no_declare_but_requires.js", null).then((info) => { t.is(info.name, null, "module name should be null"); - t.false(info.rawModule, "ui5 module"); + t.true(info.rawModule, "raw module"); assertModuleNamesEqual(t, info.dependencies, ["dependency1.js", "dependency2.js", "jquery.sap.global.js"], From df86c758ac679c4624fef982dd7df156d360ad38 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 4 Aug 2020 12:35:53 +0200 Subject: [PATCH 36/88] refactored and fixed tests --- .../generateLibraryPreload.integration.js | 58 +++++ .../tasks/bundlers/generateLibraryPreload.js | 214 +----------------- 2 files changed, 60 insertions(+), 212 deletions(-) diff --git a/test/lib/tasks/bundlers/generateLibraryPreload.integration.js b/test/lib/tasks/bundlers/generateLibraryPreload.integration.js index 11790e88d..9d1eac662 100644 --- a/test/lib/tasks/bundlers/generateLibraryPreload.integration.js +++ b/test/lib/tasks/bundlers/generateLibraryPreload.integration.js @@ -8,6 +8,7 @@ const assert = chai.assert; const ui5Builder = require("../../../../"); const builder = ui5Builder.builder; const libraryDPath = path.join(__dirname, "..", "..", "..", "fixtures", "library.d"); +const libraryNPath = path.join(__dirname, "..", "..", "..", "fixtures", "library.n"); const sapUiCorePath = path.join(__dirname, "..", "..", "..", "fixtures", "sap.ui.core"); const recursive = require("recursive-readdir"); @@ -129,3 +130,60 @@ const sapUiCoreTree = { } } }; + +test("integration: build library.n with library preload", (t) => { + const destPath = "./test/tmp/build/library.n/preload"; + const expectedPath = "./test/expected/build/library.n/preload"; + const excludedTasks = ["*"]; + const includedTasks = ["generateLibraryPreload", "generateResourcesJson"]; + + return builder.build({ + tree: libraryNTree, + destPath, + excludedTasks, + includedTasks + }).then(() => { + return findFiles(expectedPath); + }).then((expectedFiles) => { + // Check for all directories and files + assert.directoryDeepEqual(destPath, expectedPath); + + // Check for all file contents + t.deepEqual(expectedFiles.length, 15, "15 files are expected"); + expectedFiles.forEach((expectedFile) => { + const relativeFile = path.relative(expectedPath, expectedFile); + const destFile = path.join(destPath, relativeFile); + assert.fileEqual(destFile, expectedFile); + }); + }).then(() => { + t.pass(); + }); +}); + +const libraryNTree = { + "id": "library.n", + "version": "1.0.0", + "path": libraryNPath, + "dependencies": [], + "_level": 0, + "specVersion": "0.1", + "type": "library", + "metadata": { + "name": "library.n", + "namespace": "library/n", + "copyright": "UI development toolkit for HTML5 (OpenUI5)\n * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.\n * Licensed under the Apache License, Version 2.0 - see LICENSE.txt." + }, + "resources": { + "configuration": { + "paths": { + "src": "src", + "test": "test" + }, + "propertiesFileSourceEncoding": "ISO-8859-1" + }, + "pathMappings": { + "/resources/": "src", + "/test-resources/": "test" + } + } +}; diff --git a/test/lib/tasks/bundlers/generateLibraryPreload.js b/test/lib/tasks/bundlers/generateLibraryPreload.js index db14500a2..64ff0f3e2 100644 --- a/test/lib/tasks/bundlers/generateLibraryPreload.js +++ b/test/lib/tasks/bundlers/generateLibraryPreload.js @@ -1,34 +1,7 @@ const test = require("ava"); -const path = require("path"); -const chai = require("chai"); -chai.use(require("chai-fs")); -const fs = require("graceful-fs"); -const {promisify} = require("util"); -const readFile = promisify(fs.readFile); -const assert = chai.assert; const sinon = require("sinon"); const mock = require("mock-require"); -const ui5Builder = require("../../../../"); -const builder = ui5Builder.builder; -const libraryDPath = path.join(__dirname, "..", "..", "..", "fixtures", "library.d"); -const libraryNPath = path.join(__dirname, "..", "..", "..", "fixtures", "library.n"); -const sapUiCorePath = path.join(__dirname, "..", "..", "..", "fixtures", "sap.ui.core"); - -const recursive = require("recursive-readdir"); - -const findFiles = (folder) => { - return new Promise((resolve, reject) => { - recursive(folder, (err, files) => { - if (err) { - reject(err); - } else { - resolve(files); - } - }); - }); -}; - test.beforeEach((t) => { t.context.workspace = { byGlob: sinon.stub().resolves([]), @@ -356,7 +329,7 @@ test("generateLibraryPreload for sap.ui.core (w/o ui5loader.js)", async (t) => { "sap/ui/util/", "sap/ui/Global.js", "sap/ui/thirdparty/crossroads.js", - "sap/ui/thirdparty/caja-htmlsanitizer.js", + "sap/ui/thirdparty/caja-html-sanitizer.js", "sap/ui/thirdparty/hasher.js", "sap/ui/thirdparty/signals.js", "sap/ui/thirdparty/jquery-mobile-custom.js", @@ -623,7 +596,7 @@ test("generateLibraryPreload for sap.ui.core (/w ui5loader.js)", async (t) => { "sap/ui/util/", "sap/ui/Global.js", "sap/ui/thirdparty/crossroads.js", - "sap/ui/thirdparty/caja-htmlsanitizer.js", + "sap/ui/thirdparty/caja-html-sanitizer.js", "sap/ui/thirdparty/hasher.js", "sap/ui/thirdparty/signals.js", "sap/ui/thirdparty/jquery-mobile-custom.js", @@ -660,186 +633,3 @@ test("generateLibraryPreload for sap.ui.core (/w ui5loader.js)", async (t) => { t.true(ReaderCollectionPrioritizedStub.calledWithNew(), "ReaderCollectionPrioritized should have been called with 'new'"); }); - - -test("integration: build library.d with library preload", async (t) => { - const destPath = "./test/tmp/build/library.d/preload"; - const expectedPath = "./test/expected/build/library.d/preload"; - const excludedTasks = ["*"]; - const includedTasks = ["generateLibraryPreload"]; - - return t.notThrowsAsync(builder.build({ - tree: libraryDTree, - destPath, - excludedTasks, - includedTasks - }).then(() => { - return findFiles(expectedPath); - }).then((expectedFiles) => { - // Check for all directories and files - assert.directoryDeepEqual(destPath, expectedPath); - - // Check for all file contents - t.deepEqual(expectedFiles.length, 4, "4 files are expected"); - expectedFiles.forEach((expectedFile) => { - const relativeFile = path.relative(expectedPath, expectedFile); - const destFile = path.join(destPath, relativeFile); - assert.fileEqual(destFile, expectedFile); - }); - })); -}); - -const libraryDTree = { - "id": "library.d", - "version": "1.0.0", - "path": libraryDPath, - "dependencies": [], - "_level": 1, - "specVersion": "0.1", - "type": "library", - "metadata": { - "name": "library.d", - "copyright": "Some fancy copyright" - }, - "resources": { - "configuration": { - "paths": { - "src": "main/src", - "test": "main/test" - } - }, - "pathMappings": { - "/resources/": "main/src", - "/test-resources/": "main/test" - } - } -}; - -test("integration: build library.n with library preload", (t) => { - const destPath = "./test/tmp/build/library.n/preload"; - const expectedPath = "./test/expected/build/library.n/preload"; - const excludedTasks = ["*"]; - const includedTasks = ["generateLibraryPreload", "generateResourcesJson"]; - - return builder.build({ - tree: libraryNTree, - destPath, - excludedTasks, - includedTasks - }).then(() => { - return findFiles(expectedPath); - }).then((expectedFiles) => { - // Check for all directories and files - assert.directoryDeepEqual(destPath, expectedPath); - - // Check for all file contents - return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); - }).then(() => { - t.pass(); - }); -}); - -const libraryNTree = { - "id": "library.n", - "version": "1.0.0", - "path": libraryNPath, - "dependencies": [], - "_level": 0, - "specVersion": "0.1", - "type": "library", - "metadata": { - "name": "library.n", - "namespace": "library/n", - "copyright": "UI development toolkit for HTML5 (OpenUI5)\n * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.\n * Licensed under the Apache License, Version 2.0 - see LICENSE.txt." - }, - "resources": { - "configuration": { - "paths": { - "src": "src", - "test": "test" - }, - "propertiesFileSourceEncoding": "ISO-8859-1" - }, - "pathMappings": { - "/resources/": "src", - "/test-resources/": "test" - } - } -}; - - -test("integration: build sap.ui.core with library preload", async (t) => { - const destPath = "./test/tmp/build/sap.ui.core/preload"; - const expectedPath = "./test/expected/build/sap.ui.core/preload"; - const excludedTasks = ["*"]; - const includedTasks = ["generateLibraryPreload"]; - - return t.notThrowsAsync(builder.build({ - tree: sapUiCoreTree, - destPath, - excludedTasks, - includedTasks - }).then(() => { - return findFiles(expectedPath); - }).then((expectedFiles) => { - // Check for all directories and files - assert.directoryDeepEqual(destPath, expectedPath); - - // Check for all file contents - t.deepEqual(expectedFiles.length, 9, "9 files are expected"); - expectedFiles.forEach((expectedFile) => { - const relativeFile = path.relative(expectedPath, expectedFile); - const destFile = path.join(destPath, relativeFile); - assert.fileEqual(destFile, expectedFile); - }); - })); -}); - -const sapUiCoreTree = { - "id": "sap.ui.core", - "version": "1.0.0", - "path": sapUiCorePath, - "dependencies": [], - "_level": 1, - "specVersion": "0.1", - "type": "library", - "metadata": { - "name": "sap.ui.core", - "copyright": "Some fancy copyright" - }, - "resources": { - "configuration": { - "paths": { - "src": "main/src", - "test": "main/test" - } - }, - "pathMappings": { - "/resources/": "main/src", - "/test-resources/": "main/test" - } - } -}; - -const newLineRegexp = /\r?\n|\r/g; - -async function checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath) { - for (let i = 0; i < expectedFiles.length; i++) { - const expectedFile = expectedFiles[i]; - const relativeFile = path.relative(expectedPath, expectedFile); - const destFile = path.join(destPath, relativeFile); - const currentFileContentPromise = readFile(destFile, "utf8"); - const expectedFileContentPromise = readFile(expectedFile, "utf8"); - const assertContents = ([currentContent, expectedContent]) => { - if (expectedFile.endsWith(".json")) { - try { - t.deepEqual(JSON.parse(currentContent), JSON.parse(expectedContent), expectedFile); - } catch (e) { - t.falsy(e, expectedFile); - } - } - t.is(currentContent.replace(newLineRegexp, "\n"), expectedContent.replace(newLineRegexp, "\n"), relativeFile); - }; - await Promise.all([currentFileContentPromise, expectedFileContentPromise]).then(assertContents); - } -} From 71d0c58064fdeddd11eb61d34b6ef51fcca85d00 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 4 Aug 2020 13:50:19 +0200 Subject: [PATCH 37/88] improved failOnOrphans error --- lib/processors/resourceListCreator.js | 25 +++++------- test/lib/processors/resourceListCreator.js | 46 ++++++++++++++++++++-- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 60b163dc7..9d7c69e4e 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -654,6 +654,10 @@ class ResourceCollector { } } + /** + * + * @returns {Set} resource names + */ get resources() { return new Set(this._resources.keys()); } @@ -676,9 +680,10 @@ class ResourceCollector { * Whether the detection of orphans should result in a build failure. * * @since 1.29.1 + * @param {object} configuration + * @param {module:@ui5/fs.Resource[]} configuration.resources + * @param {object} [options] configuration options */ - - module.exports = async function({resources}, options) { options = Object.assign({ failOnOrphans: true, @@ -772,19 +777,9 @@ module.exports = async function({resources}, options) { })); } const unassigned = collector.resources; - if ( unassigned.size > 0 ) { - log.verbose(` found ${unassigned.size} resources not belonging to a component (orphans)`); - let n = 0; - for ( const resource of unassigned ) { - log.verbose(` ${resource} (orphan)`); - if ( ++n > 20 ) { - log.verbose(` ... (${unassigned.size - n} more)`); - break; - } - } - if ( options.failOnOrphans ) { - throw new Error("not all resources could be assigned to components"); - } + if ( unassigned.size > 0 && options.failOnOrphans ) { + log.error(`resources.json generation failed because of unassigned resources: ${[...unassigned].join(", ")}`); + throw new Error(`resources.json generation failed with error: There are ${unassigned.size} resources which could not be assigned to components.`); } return resourceLists; diff --git a/test/lib/processors/resourceListCreator.js b/test/lib/processors/resourceListCreator.js index f95358c60..5a2e18988 100644 --- a/test/lib/processors/resourceListCreator.js +++ b/test/lib/processors/resourceListCreator.js @@ -1,7 +1,47 @@ const test = require("ava"); +const sinon = require("sinon"); +const mock = require("mock-require"); -const resourceListCreator = require("../../../lib/processors/resourceListCreator"); +let resourceListCreator = require("../../../lib/processors/resourceListCreator"); +const resourceFactory = require("@ui5/fs").resourceFactory; -test("Replaces string pattern from resource stream", async (t) => { - t.truthy(resourceListCreator); +test.beforeEach((t) => { + // Spying logger of processors/bootstrapHtmlTransformer + const log = require("@ui5/logger"); + const loggerInstance = log.getLogger("builder:processors:resourceListCreator"); + mock("@ui5/logger", { + getLogger: () => loggerInstance + }); + mock.reRequire("@ui5/logger"); + t.context.logErrorSpy = sinon.spy(loggerInstance, "error"); + + // Re-require tested module + resourceListCreator = mock.reRequire("../../../lib/processors/resourceListCreator"); +}); + +test.afterEach.always((t) => { + mock.stop("@ui5/logger"); + t.context.logErrorSpy.restore(); +}); + +test.serial("Empty resources", async (t) => { + const result = await resourceListCreator({ + resources: [] + }); + t.deepEqual(result, []); +}); + +test.serial("Orphaned resources", async (t) => { + const resource = resourceFactory.createResource({ + path: "/resources/nomodule.foo", + string: "bar content" + }); + const errorObject = await t.throwsAsync(() => { + return resourceListCreator({ + resources: [resource] + }); + }); + t.is(errorObject.message, "resources.json generation failed with error: There are 1 resources which could not be assigned to components."); + t.is(t.context.logErrorSpy.callCount, 1); + t.is(t.context.logErrorSpy.getCall(0).args[0], "resources.json generation failed because of unassigned resources: nomodule.foo"); }); From 7c2c423d413a204e3c763e4b2c60e7bbb8cb8827 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 4 Aug 2020 13:52:20 +0200 Subject: [PATCH 38/88] restored package.json run script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 319338b58..910363327 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "test": "npm run lint && npm run jsdoc-generate && npm run coverage", "test-azure": "npm run lint && npm run jsdoc-generate && npm run coverage-xunit", "lint": "eslint ./", - "unit": "rimraf test/tmp && ava -v", + "unit": "rimraf test/tmp && ava", "unit-verbose": "rimraf test/tmp && cross-env UI5_LOG_LVL=verbose ava --verbose --serial", "unit-watch": "rimraf test/tmp && ava --watch", "unit-nyan": "rimraf test/tmp && ava --tap | tnyan", From 6bcc7f172fecc64bcbfd5d1a8d0a6a8e79eef566 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 4 Aug 2020 14:54:17 +0200 Subject: [PATCH 39/88] remove excludes --- lib/tasks/generateResourcesJson.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index 323211f5e..7f8ab53e8 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -3,13 +3,6 @@ // const log = require("@ui5/logger").getLogger("builder:tasks:generateResourcesJson"); const resourceListCreator = require("../processors/resourceListCreator"); -const DEFAULT_EXCLUDES = [ - "!**/.DS_Store", - "!**/.eslintrc", - "!**/.eslintignore", - "!**/.gitignore" -]; - function getCreatorOptions(taskOptions) { const creatorOptions = {}; if ( taskOptions.projectName === "sap.ui.core" ) { @@ -53,16 +46,17 @@ function getCreatorOptions(taskOptions) { module.exports = async function({workspace, dependencies, options}) { let resources; if (workspace.byGlobSource) { // API only available on duplex collections - resources = await workspace.byGlobSource(["/resources/**/*.*", ...DEFAULT_EXCLUDES]); + resources = await workspace.byGlobSource(["/resources/**/*.*"]); // HACK add resources from internal writer of workspace - const writtenResources = await workspace._writer.byGlob(["/resources/**/*.*", ...DEFAULT_EXCLUDES]); + // "byGlobSource" also returns the dbg resources while "byGlob" doesn't + const writtenResources = await workspace._writer.byGlob(["/resources/**/*.*"]); writtenResources.forEach((res) => { if ( resources.indexOf(res) < 0 ) { resources.push(res); } }); } else { - resources = await workspace.byGlob(["/resources/**/*.*", ...DEFAULT_EXCLUDES]); + resources = await workspace.byGlob(["/resources/**/*.*"]); } return resourceListCreator({ From dfd54b2b735422678f02ea2605c6a52bf40774d8 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 4 Aug 2020 15:17:37 +0200 Subject: [PATCH 40/88] restored file not.js --- .../library.h/dest/resources/library/h/not.js | 2 +- .../dest/resources/library/h/resources.json | 4 +- .../library.h/main/src/library/h/not.js | 235 +----------------- 3 files changed, 4 insertions(+), 237 deletions(-) diff --git a/test/expected/build/library.h/dest/resources/library/h/not.js b/test/expected/build/library.h/dest/resources/library/h/not.js index 952b507ad..c249a10c8 100644 --- a/test/expected/build/library.h/dest/resources/library/h/not.js +++ b/test/expected/build/library.h/dest/resources/library/h/not.js @@ -1,4 +1,4 @@ /*! * Some fancy copyright */ -(function(e,t){"use strict";var i,n,r;i=document.querySelector("[src$='createSuite.js']");if(i){n=/^(.*\/)?createSuite.js/.exec(i.getAttribute("src"));if(n){r=n[1]+"../../../../"}}if(r==null){throw new Error("createSuite.js: could not identify script tag!")}function s(e,t){var i=e.length,n=0;if(i===0){t();return}function s(e){i--;if(e.type==="error"){n++}e.target.removeEventListener("load",s);e.target.removeEventListener("error",s);if(i===0&&n===0&&t){t()}}for(var a=0;a"+"

"+"
"+""+"
"+"
    ";n.sortedTests.forEach(function(e){var t=sap.ui.require.toUrl("")+"/../"+e.page;r+="
  1. "+(e.skip?"skipped":"")+""+(e.group?""+e.group+": ":"")+""+e.name+"
  2. "});r+="
"+"
"+"
Tests will start in
"+"
*
"+"
Click or press 'ESC' to cancel
";t(r).then(function(){var t=10*(parseInt(e.getAttribute("data-sap-ui-delay"))||2)+9;function n(){if(t===6){i()}else if(t>6){document.getElementById("remaining-time").textContent=String(Math.floor(t/10));t--;setTimeout(n,100)}else{document.removeEventListener("click",r);document.removeEventListener("keydown",r);var e=document.getElementById("redirect-hint");e.parentNode.removeChild(e)}}function r(e){if(e.type==="click"||e.key==="Escape"){t=-1;e.preventDefault()}}document.addEventListener("keydown",r);document.addEventListener("click",r);document.getElementById("redirect").addEventListener("click",i);n()})}function r(i){t("

Failed to load Testsuite

"+"

"+"
    "+"
  1. "+e.encode(i.message||String(i))+"
  2. "+"
")}var s=e.getAttribute("data-sap-ui-testsuite");var a=e.getSuiteConfig(s);var o=parent.jsUnitTestSuite;if(!o){a.then(n).catch(r);return}window.suite=function(){function e(e){var t="/"+window.location.pathname.split("/")[1]+"/";var i=new o;e.sortedTests.forEach(function(e){if(!e.skip){i.addTestPage(t+e.page,e)}});return i}return a.then(e).catch(function(e){r(e);throw e})};var u=document.createEvent("CustomEvent");u.initCustomEvent("sap-ui-testsuite-ready",true,true,{});window.dispatchEvent(u)}); \ No newline at end of file +console.log(" Not including "); \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/resources.json b/test/expected/build/library.h/dest/resources/library/h/resources.json index 4001d2aff..c4c5fb06a 100644 --- a/test/expected/build/library.h/dest/resources/library/h/resources.json +++ b/test/expected/build/library.h/dest/resources/library/h/resources.json @@ -133,12 +133,12 @@ { "name": "not.js", "module": "library/h/not.js", - "size": 4151, + "size": 63, "format": "raw" }, { "name": "resources.json", - "size": 3447 + "size": 3445 }, { "name": "some.js", diff --git a/test/fixtures/library.h/main/src/library/h/not.js b/test/fixtures/library.h/main/src/library/h/not.js index 0dd3410f9..778bfa1f5 100644 --- a/test/fixtures/library.h/main/src/library/h/not.js +++ b/test/fixtures/library.h/main/src/library/h/not.js @@ -1,237 +1,4 @@ /*! * ${copyright} */ - -/* - * IMPORTANT: This is a private module, its API must not be used and is subject to change. - * Code other than the Core tests must not yet introduce dependencies to this module. - */ - -/*global document, sap */ -(function(deps, callback) { - - "use strict"; - - //extract base URL from script tag - var oScriptTag, mMatch, sBaseUrl; - - oScriptTag = document.querySelector("[src$='createSuite.js']"); - if (oScriptTag) { - mMatch = /^(.*\/)?createSuite.js/.exec(oScriptTag.getAttribute("src")); - if (mMatch) { - sBaseUrl = mMatch[1] + "../../../../"; - } - } - - if (sBaseUrl == null) { - throw new Error("createSuite.js: could not identify script tag!"); - } - - function loadScripts(urls, callback) { - var pending = urls.length, - errors = 0; - - if (pending === 0) { - callback(); - return; - } - - function listener(e) { - pending--; - if ( e.type === 'error' ) { - errors++; - } - e.target.removeEventListener("load", listener); - e.target.removeEventListener("error", listener); - if ( pending === 0 && errors === 0 && callback ) { - callback(); - } - } - - for ( var i = 0; i < urls.length; i++ ) { - var script = document.createElement("script"); - script.addEventListener("load", listener); - script.addEventListener("error", listener); - script.src = sBaseUrl + urls[i]; - document.head.appendChild(script); - } - } - - // check for optimized sources - window["sap-ui-optimized"] = window["sap-ui-optimized"] - || (/\.head/.test(loadScripts) && !/pending/.test(loadScripts)); - - // prevent a reboot in full debug mode as this would invalidate our listeners - window["sap-ui-debug-no-reboot"] = true; - - // define the necessary polyfills to be loaded - var aPolyfills = []; - if (/(trident)\/[\w.]+;.*rv:([\w.]+)/i.test(window.navigator.userAgent)) { - // add polyfills for IE11 - aPolyfills.push("sap/ui/thirdparty/baseuri.js"); - aPolyfills.push("sap/ui/thirdparty/es6-promise.js"); - aPolyfills.push("sap/ui/thirdparty/es6-shim-nopromise.js"); - } else if (/(edge)[ \/]([\w.]+)/i.test(window.navigator.userAgent) || - /Version\/(11\.0).*Safari/.test(window.navigator.userAgent)) { - // for Microsoft Edge and Safari 11.0 the Promise polyfill is still needed - aPolyfills.push("sap/ui/thirdparty/es6-promise.js"); - } - - // cascade 1: polyfills, can all be loaded in parallel - loadScripts(aPolyfills, function() { - // cascade 2: the loader - loadScripts([ - "ui5loader.js" - ], function() { - // cascade 3: the loader configuration script - sap.ui.loader.config({ - async:true - }); - loadScripts([ - "ui5loader-autoconfig.js" - ], function() { - sap.ui.require(deps, callback); - }); - }); - }); - -}([ - "sap/ui/test/starter/_utils" -], function(utils) { - "use strict"; - - function render(sHTML) { - // style is added to the head, no need to wait for DOM ready - utils.addStylesheet("sap/ui/thirdparty/qunit-2.css"); - utils.addStylesheet("sap/ui/test/starter/testsuite.css"); - return utils.whenDOMReady().then(function() { - var elem = document.body.querySelector("#qunit"); - if ( elem == null ) { - elem = document.createElement("div"); - elem.id = "qunit"; - document.body.insertBefore(elem, document.body.firstChild); - } - elem.innerHTML = sHTML; - }); - } - - function redirectToTestRunner() { - // As IE11 doesn't properly resolve relative URLs when assigning to location.href, use an anchor tag - var anchor = document.createElement("A"); - document.head.appendChild(anchor); - anchor.href = sap.ui.require.toUrl("") + "/../test-resources/sap/ui/qunit/testrunner.html" - + "?testpage=" + encodeURIComponent(window.location.pathname) + "&autostart=true"; - window.location.href = anchor.href; - } - - function renderList(oSuiteConfig) { - - document.title = "Available Unit Tests - " + oSuiteConfig.name; - - var sLinkHTML = "

" + document.title + "

" - + "

" - + "
" - + "" - + "
" - + "
    "; - oSuiteConfig.sortedTests.forEach(function(oTestConfig) { - var sPageUrl = sap.ui.require.toUrl("") + "/../" + oTestConfig.page; - sLinkHTML += "
  1. " + - (oTestConfig.skip ? "skipped" : "") + - "" + - (oTestConfig.group ? "" + oTestConfig.group + ": " : "") + - "" + oTestConfig.name + "
  2. "; - }); - sLinkHTML += "
" - + "
" - + "
Tests will start in
" - + "
*
" - + "
Click or press 'ESC' to cancel
"; - - render(sLinkHTML).then(function() { - // Note: we use a 0.1 second timer resolution so that the blocking div disappears quickly - var count = 10 * (parseInt(utils.getAttribute("data-sap-ui-delay")) || 2) + 9; - - function countDown() { - if ( count === 6 ) { - redirectToTestRunner(); - } else if ( count > 6 ){ - document.getElementById("remaining-time").textContent = String(Math.floor(count / 10)); - count--; - setTimeout(countDown, 100); - } else { - document.removeEventListener("click", maybeStop); - document.removeEventListener("keydown", maybeStop); - var hintOverlay = document.getElementById("redirect-hint"); - hintOverlay.parentNode.removeChild(hintOverlay); - } - } - - function maybeStop(e) { - if ( e.type === "click" || e.key === "Escape" ) { - count = -1; - e.preventDefault(); - } - } - - document.addEventListener("keydown", maybeStop); - document.addEventListener("click", maybeStop); - document.getElementById("redirect").addEventListener("click", redirectToTestRunner); - countDown(); - }); - - } - - function renderError(oErr) { - - render( - "

Failed to load Testsuite

" - + "

" - + "
    " - + "
  1. " + utils.encode(oErr.message || String(oErr)) + "
  2. " - + "
" - ); - - } - - var sSuiteName = utils.getAttribute("data-sap-ui-testsuite"); - var whenLoaded = utils.getSuiteConfig(sSuiteName); - - - var JSUnitSuite = parent.jsUnitTestSuite; - if ( !JSUnitSuite ) { - // If running in top window, render list and redirect to testrunner after a while - whenLoaded.then(renderList).catch(renderError); - return; - } - - /* - * Note: the window.suite function must be provided early, - * only its answer can be a promise. The TestRunner.js will call this method - * immediately after the window load event. - */ - window.suite = function() { - - function createSuite(oSuiteConfig) { - var sContextPath = "/" + window.location.pathname.split("/")[1] + "/"; - var oSuite = new JSUnitSuite(); - oSuiteConfig.sortedTests.forEach(function(oTestConfig) { - if (!oTestConfig.skip) { - oSuite.addTestPage(sContextPath + oTestConfig.page, oTestConfig); - } - }); - return oSuite; - } - - return whenLoaded.then(createSuite).catch(function(oErr) { - renderError(oErr); - throw oErr; // rethrow to make testrunner aware of issue - }); - - }; - - var oSuiteReadyEvent = document.createEvent("CustomEvent"); - oSuiteReadyEvent.initCustomEvent("sap-ui-testsuite-ready", true, true, {}); - window.dispatchEvent(oSuiteReadyEvent); - -})); +console.log(' Not including '); From 85ed400361ef2aa08a8f66ba708b979305d40b60 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 6 Aug 2020 08:39:57 +0200 Subject: [PATCH 41/88] Add tests for JSModuleAnalyzer to increase coverage --- .../lbt/modules/bundle-evo_invalid_comment.js | 7 +++++ .../fixtures/lbt/modules/declare_times_two.js | 7 +++++ test/fixtures/lbt/modules/declare_unnamed.js | 6 +++++ test/lib/lbt/analyzer/JSModuleAnalyzer.js | 26 +++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 test/fixtures/lbt/modules/bundle-evo_invalid_comment.js create mode 100644 test/fixtures/lbt/modules/declare_times_two.js create mode 100644 test/fixtures/lbt/modules/declare_unnamed.js diff --git a/test/fixtures/lbt/modules/bundle-evo_invalid_comment.js b/test/fixtures/lbt/modules/bundle-evo_invalid_comment.js new file mode 100644 index 000000000..8eff0e436 --- /dev/null +++ b/test/fixtures/lbt/modules/bundle-evo_invalid_comment.js @@ -0,0 +1,7 @@ +//@ui5-bundles sap/ui/thirdparty/baseuri.js +if(!('baseURI'in Node.prototype)){} +//@ui5-bundle-raw-includes sap/ui/thirdparty/es6-promise.js +(function(g,f){ + g.ES6Promise=f();}(this,(function(){}))); + +sap.ui.define("my/module", ["sap/ui/core/UIComponent"],function(n){"use strict";return 47+n}); \ No newline at end of file diff --git a/test/fixtures/lbt/modules/declare_times_two.js b/test/fixtures/lbt/modules/declare_times_two.js new file mode 100644 index 000000000..c15d36f86 --- /dev/null +++ b/test/fixtures/lbt/modules/declare_times_two.js @@ -0,0 +1,7 @@ +jQuery.sap.declare("sap.ui.testmodule"); + +sap.ui.testmodule.load = function(modName) { + jQuery.sap.require(modName); +}; + +jQuery.sap.declare("sap.ui.testmodule"); \ No newline at end of file diff --git a/test/fixtures/lbt/modules/declare_unnamed.js b/test/fixtures/lbt/modules/declare_unnamed.js new file mode 100644 index 000000000..37f14907b --- /dev/null +++ b/test/fixtures/lbt/modules/declare_unnamed.js @@ -0,0 +1,6 @@ +var sCommonName = "sap.ui" +jQuery.sap.declare(sCommonName + ".testmodule"); + +sap.ui.testmodule.load = function(modName) { + jQuery.sap.require(modName); +}; diff --git a/test/lib/lbt/analyzer/JSModuleAnalyzer.js b/test/lib/lbt/analyzer/JSModuleAnalyzer.js index e372701d7..61111d1be 100644 --- a/test/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/test/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -541,3 +541,29 @@ test("Toplevel define", (t) => { }); }); +test("Invalid ui5 bundle comment", (t) => { + return analyze("modules/bundle-evo_invalid_comment.js").then((info) => { + t.is(info.name, "my/module.js", + "module name matches"); + t.deepEqual(info.subModules, [], + "no submodules"); + }); +}); + +test("Declare two times", (t) => { + return analyze("modules/declare_times_two.js").then((info) => { + t.is(info.name, "sap/ui/testmodule.js", + "module name matches"); + t.deepEqual(info.subModules, [], + "no submodules"); + }); +}); + +test("Declare unnamed", (t) => { + return analyze("modules/declare_unnamed.js").then((info) => { + t.is(info.name, "modules/declare_unnamed.js", + "module name matches"); + t.deepEqual(info.subModules, [], + "no submodules"); + }); +}); From eb1c949bcc22054f300023e3a525a0abccdff044 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 6 Aug 2020 11:56:43 +0200 Subject: [PATCH 42/88] add test for generateResourcesJson --- test/lib/tasks/generateResourcesJson.js | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 test/lib/tasks/generateResourcesJson.js diff --git a/test/lib/tasks/generateResourcesJson.js b/test/lib/tasks/generateResourcesJson.js new file mode 100644 index 000000000..3ce3967ec --- /dev/null +++ b/test/lib/tasks/generateResourcesJson.js @@ -0,0 +1,68 @@ +const test = require("ava"); +const sinon = require("sinon"); +const mock = require("mock-require"); + + +const ui5Fs = require("@ui5/fs"); +const resourceFactory = ui5Fs.resourceFactory; + +function createWorkspace() { + return resourceFactory.createAdapter({ + virBasePath: "/", + project: { + metadata: { + name: "test.lib" + }, + version: "2.0.0", + dependencies: [ + { + metadata: { + name: "sap.ui.core" + }, + version: "1.0.0" + } + ] + } + }); +} + +test.beforeEach((t) => { + t.context.resourceListCreatorStub = sinon.stub(); + t.context.resourceListCreatorStub.returns(Promise.resolve([])); + mock("../../../lib/processors/resourceListCreator", t.context.resourceListCreatorStub); + mock.reRequire("../../../lib/processors/resourceListCreator"); +}); + +test.afterEach.always((t) => { + mock.stop("../../../lib/processors/resourceListCreator"); +}); + +test.serial("empty resources", async (t) => { + const generateResourcesJson = require("../../../lib/tasks/generateResourcesJson"); + + const result = await generateResourcesJson({workspace: createWorkspace(), dependencies: undefined, options: {projectName: "sap.ui.core"}}); + t.deepEqual(result, [], "empty resources"); + t.is(t.context.resourceListCreatorStub.callCount, 1); + const expectedOptions = { + externalResources: { + "sap/ui/core": [ + "*", + "sap/base/", + "sap/ui/" + ] + }, + mergedResourcesFilters: [ + "jquery-sap*.js", + "sap-ui-core*.js", + "**/Component-preload.js", + "**/library-preload.js", + "**/library-preload-dbg.js", + "**/library-preload.json", + "**/library-all.js", + "**/library-all-dbg.js", + "**/designtime/library-preload.designtime.js", + "**/library-preload.support.js" + ].join(",") + }; + t.deepEqual(t.context.resourceListCreatorStub.getCall(0).args[1], expectedOptions, "options match"); +}); From 5bd062a311542ed1fbfb5a6250353e98895f9919 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 6 Aug 2020 14:24:49 +0200 Subject: [PATCH 43/88] improves documentation add ui5-bundle to the preserved comments --- lib/lbt/analyzer/JSModuleAnalyzer.js | 12 +++---- lib/lbt/resources/ModuleInfo.js | 10 +----- lib/processors/uglifier.js | 15 +++++++-- test/lib/tasks/generateResourcesJson.js | 2 +- test/lib/tasks/uglify.js | 45 +++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 18 deletions(-) diff --git a/lib/lbt/analyzer/JSModuleAnalyzer.js b/lib/lbt/analyzer/JSModuleAnalyzer.js index 557e931fe..ecfd34549 100644 --- a/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -282,11 +282,7 @@ class JSModuleAnalyzer { let bIsUi5Module = false; // first analyze the whole AST... - const rootNode = { - node: null, - parent: null - }; - visit(ast, false, rootNode); + visit(ast, false); // ...then all the comments if ( Array.isArray(ast.comments) ) { @@ -345,7 +341,7 @@ class JSModuleAnalyzer { // console.log(info.name, "exposed globals", info.exposedGlobals, "ignoredGlobals", info.ignoredGlobals); } - return; + // hoisted functions function setMainModuleInfo(name, description) { @@ -610,6 +606,8 @@ class JSModuleAnalyzer { if ( i < nArgs ) { if ( isString(args[i]) ) { + // resolve dependencies absolute: e.g. "library/n/changeHandler/SplitButton.js" + // instead of "./changeHandler/SplitButton.js" let moduleName; if (name == null) { moduleName = ModuleName.fromRequireJSName( args[i].value ); @@ -634,6 +632,8 @@ class JSModuleAnalyzer { const moduleName = ModuleName.fromRequireJSName( args[i++].value ); info.addSubModule(moduleName); + // add dependencies + // to correctly identify dependencies e.g. of a library-preload const elementArg = args[i++]; if (elementArg && elementArg.type === Syntax.ArrayExpression) { elementArg.elements.forEach((element) => { diff --git a/lib/lbt/resources/ModuleInfo.js b/lib/lbt/resources/ModuleInfo.js index 8c7271ab3..1e0a2b8b2 100644 --- a/lib/lbt/resources/ModuleInfo.js +++ b/lib/lbt/resources/ModuleInfo.js @@ -65,7 +65,7 @@ class ModuleInfo { *
  • jQuery.sap.declare call
  • * */ - this._rawModule = false; + this.rawModule = false; /** * Whether the module requires top level scope (true) or whether it can be embedded @@ -198,14 +198,6 @@ class ModuleInfo { } } - get rawModule() { - return this._rawModule; - } - - set rawModule(value) { - this._rawModule = value; - } - get dependencies() { return Object.keys(this._dependencies); } diff --git a/lib/processors/uglifier.js b/lib/processors/uglifier.js index 82a09a927..f5c4c9591 100644 --- a/lib/processors/uglifier.js +++ b/lib/processors/uglifier.js @@ -1,5 +1,16 @@ const terser = require("terser"); -const copyrightCommentsAndRawIncludePattern = /copyright|\(c\)(?:[0-9]+|\s+[0-9A-za-z])|released under|license|\u00a9|@ui5-bundle-raw-include/i; +/** + * Preserve comments which contain: + *
      + *
    • copyright notice
    • + *
    • license terms
    • + *
    • "@ui5-bundle"
    • + *
    • "@ui5-bundle-raw-include"
    • + *
    + * + * @type {RegExp} + */ +const copyrightCommentsAndBundleCommentPattern = /copyright|\(c\)(?:[0-9]+|\s+[0-9A-za-z])|released under|license|\u00a9|^@ui5-bundle-raw-include |^@ui5-bundle /i; /** * Minifies the supplied resources. @@ -18,7 +29,7 @@ module.exports = function({resources}) { }, { warnings: false, output: { - comments: copyrightCommentsAndRawIncludePattern, + comments: copyrightCommentsAndBundleCommentPattern, wrap_func_args: false }, compress: false diff --git a/test/lib/tasks/generateResourcesJson.js b/test/lib/tasks/generateResourcesJson.js index 3ce3967ec..2a6d87ba2 100644 --- a/test/lib/tasks/generateResourcesJson.js +++ b/test/lib/tasks/generateResourcesJson.js @@ -37,7 +37,7 @@ test.afterEach.always((t) => { mock.stop("../../../lib/processors/resourceListCreator"); }); -test.serial("empty resources", async (t) => { +test("empty resources", async (t) => { const generateResourcesJson = require("../../../lib/tasks/generateResourcesJson"); const result = await generateResourcesJson({workspace: createWorkspace(), dependencies: undefined, options: {projectName: "sap.ui.core"}}); diff --git a/test/lib/tasks/uglify.js b/test/lib/tasks/uglify.js index fed2b8347..135743494 100644 --- a/test/lib/tasks/uglify.js +++ b/test/lib/tasks/uglify.js @@ -141,3 +141,48 @@ function test(t){var o=t;console.log(o)}test();`; return t.deepEqual(buffer.toString(), expected, "Correct content"); }); }); + +test("integration: uglify raw module (@ui5-bundle)", (t) => { + const reader = resourceFactory.createAdapter({ + virBasePath: "/" + }); + const writer = resourceFactory.createAdapter({ + virBasePath: "/" + }); + const duplexCollection = new DuplexCollection({reader: reader, writer: writer}); + const content = ` +//@ui5-bundle sap/ui/my/module.js +function test(paramA) { + var variableA = paramA; + console.log(variableA); +} +test();`; + const testResource = resourceFactory.createResource({ + path: "/test.js", + string: content + }); + const expected = `//@ui5-bundle sap/ui/my/module.js +function test(t){var o=t;console.log(o)}test();`; + + return reader.write(testResource) + .then(() => { + return reader.byPath("/test.js"); + }).then(() => { + return uglify({ + workspace: duplexCollection, + options: { + pattern: "/test.js" + } + }); + }).then(() => { + return writer.byPath("/test.js").then((resource) => { + if (!resource) { + t.fail("Could not find /test.js in target locator"); + } else { + return resource.getBuffer(); + } + }); + }).then((buffer) => { + return t.deepEqual(buffer.toString(), expected, "Correct content"); + }); +}); From 91a80774f5b3ea12a5f46bfa845117808c110c71 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 6 Aug 2020 16:05:08 +0200 Subject: [PATCH 44/88] use byGlob instead of a combination of byGlobSource and byGlob the logic for adding resource infos made the assumption that debug files were at the end of the list and they copied their information from the non-debug ones. This logic is adjusted such that it does not depend on the order of the resources. --- lib/lbt/analyzer/JSModuleAnalyzer.js | 1 - lib/processors/resourceListCreator.js | 35 ++++++++++++++++++++++----- lib/tasks/generateResourcesJson.js | 15 +----------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/lib/lbt/analyzer/JSModuleAnalyzer.js b/lib/lbt/analyzer/JSModuleAnalyzer.js index ecfd34549..242b30fd7 100644 --- a/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -342,7 +342,6 @@ class JSModuleAnalyzer { } - // hoisted functions function setMainModuleInfo(name, description) { if ( mainModuleFound ) { diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 9d7c69e4e..0c9e929e9 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -8,6 +8,7 @@ const LocatorResourcePool = require("../lbt/resources/LocatorResourcePool"); const EvoResource = require("@ui5/fs").Resource; const DEBUG_RESOURCES_PATTERN = /-dbg((?:\.view|\.fragment|\.controller|\.designtime|\.support)?\.js|\.css)$/; +const RESOURCES_PATTERN = /((?:\.view|\.fragment|\.controller|\.designtime|\.support)?\.js|\.css)$/; /** * Information about a single resource as stored in the resources.json file. @@ -129,7 +130,7 @@ class ResourceInfo { name: this.name }; if ( this._module != null ) { - result.module = this._module; + result.module = this.module; } if ( this.size >= 0 ) { result.size = this.size; @@ -221,10 +222,21 @@ class ResourcesList { if ( myInfo == null && shareDebugInformation) { // when not found, check if the given resource is a debug resource and share the information with the non-dbg version - const nondbg = ResourcesList.getNonDebugName(relativeName); - if ( nondbg != null && this.resourcesByName.has(nondbg) ) { + const nonDbgName = ResourcesList.getNonDebugName(relativeName); + const dbgName = ResourcesList.getDebugName(relativeName); + if ( nonDbgName != null && this.resourcesByName.has(nonDbgName) ) { + // copy from source myInfo = new ResourceInfo(relativeName); - myInfo.copyFrom(this.name, this.resourcesByName.get(nondbg)); + const source = this.resourcesByName.get(nonDbgName); + myInfo.copyFrom(this.name, source); + this.resources.push(myInfo); + this.resourcesByName.set(relativeName, myInfo); + } else if (dbgName != null && this.resourcesByName.has(dbgName)) { + // copy from debug + myInfo = new ResourceInfo(relativeName); + const source = this.resourcesByName.get(dbgName); + myInfo.copyFrom(this.name, source); + myInfo.module = ResourcesList.getNonDebugName(source.module); this.resources.push(myInfo); this.resourcesByName.set(relativeName, myInfo); } @@ -234,6 +246,8 @@ class ResourcesList { if ( myInfo == null ) { myInfo = new ResourceInfo(relativeName); myInfo.size = info.size; + const sourceName = ResourcesList.getNonDebugName(info.name); + myInfo.module = sourceName; this.resources.push(myInfo); this.resourcesByName.set(relativeName, myInfo); } @@ -283,6 +297,15 @@ class ResourcesList { } return null; } + + static getDebugName(path) { + if ( RESOURCES_PATTERN.test(path) ) { + if (!path.replace(RESOURCES_PATTERN, "").endsWith("-dbg")) { + return path.replace( RESOURCES_PATTERN, "-dbg$1"); + } + } + return null; + } } /** @@ -432,7 +455,7 @@ class ResourceCollector { /** * prefix to ResourcesList * - * @type {Map} + * @type {Map} * @private */ this._components = new Map(); @@ -665,7 +688,7 @@ class ResourceCollector { /** * Components * - * @returns {Map} + * @returns {Map} */ get components() { return this._components; diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index 7f8ab53e8..d51d82fd2 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -44,20 +44,7 @@ function getCreatorOptions(taskOptions) { * @returns {Promise} Promise resolving with undefined once data has been written */ module.exports = async function({workspace, dependencies, options}) { - let resources; - if (workspace.byGlobSource) { // API only available on duplex collections - resources = await workspace.byGlobSource(["/resources/**/*.*"]); - // HACK add resources from internal writer of workspace - // "byGlobSource" also returns the dbg resources while "byGlob" doesn't - const writtenResources = await workspace._writer.byGlob(["/resources/**/*.*"]); - writtenResources.forEach((res) => { - if ( resources.indexOf(res) < 0 ) { - resources.push(res); - } - }); - } else { - resources = await workspace.byGlob(["/resources/**/*.*"]); - } + const resources = await workspace.byGlob(["/resources/**/*.*"]); return resourceListCreator({ resources From d64046c2038c9619bb28f23a3e7160350d0220e9 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Fri, 7 Aug 2020 08:51:22 +0200 Subject: [PATCH 45/88] Refactoring separated classes into separate files separated each class in resourceListCreator into own file. This not only makes it more fine granular but also dependencies become clear. ResourcesList <-> ResourceInfo: dependency is now one way --- lib/lbt/resources/ResourceCollector.js | 346 ++++++++++++++ lib/lbt/resources/ResourceInfo.js | 180 +++++++ lib/lbt/resources/ResourcesList.js | 152 ++++++ lib/processors/resourceListCreator.js | 628 +------------------------ 4 files changed, 681 insertions(+), 625 deletions(-) create mode 100644 lib/lbt/resources/ResourceCollector.js create mode 100644 lib/lbt/resources/ResourceInfo.js create mode 100644 lib/lbt/resources/ResourcesList.js diff --git a/lib/lbt/resources/ResourceCollector.js b/lib/lbt/resources/ResourceCollector.js new file mode 100644 index 000000000..b643f5f27 --- /dev/null +++ b/lib/lbt/resources/ResourceCollector.js @@ -0,0 +1,346 @@ +const ResourcesList = require("./ResourcesList"); +const ResourceFilterList = require("./ResourceFilterList"); +const ResourceInfo = require("./ResourceInfo"); + + +const LOCALE = /^((?:[^/]+\/)*[^/]+?)_([A-Z]{2}(?:_[A-Z]{2}(?:_[A-Z0-9_]+)?)?)(\.properties|\.hdbtextbundle)$/i; +const THEME = /^((?:[^/]+\/)*)themes\/([^/]+)\//; + +const log = require("@ui5/logger").getLogger("lbt:resources:ResourceCollector"); + +/* NODE-TODO + /** + * Global filters that should be taken into account when collecting resources. + * + * Each filter entry can be a comma separated list of simple filters. Each simple filter + * can be a pattern in resource name pattern syntax: A double asterisk '&0x2a;&0x2a;/' denotes an arbitrary + * number of resource name segments (folders) incl. a trailing slash, whereas a simple asterisk '*' + * denotes an arbitrary number of resource name characters, but not the segment separator '/'. + * A dot is interpreted as a dot, all other special regular expression characters keep their + * special meaning. This is a mixture of ANT-style path patterns and regular expressions. + * + * Excludes can be denoted by a leading '-' or '!', includes optionally by a leading '+'. + * Order of filters is significant, a later exclusion overrides an earlier inclusion + * and vice versa. + * + * Example: + *
    +	 *	 !sap/ui/core/
    +	 *	 +sap/ui/core/utils/
    +	 * 
    + * excludes everything from sap/ui/core, but includes everything from the subpackage sap/ui/core/utils/. + * + * Note that the filter operates on the full name of each resource. If a resource name + * prefix is configured for a resource set, the filter will be applied + * to the combination of prefix and local file path and not only to the local file path. + * / + @Parameter + private String[] filters; + + /** + * Whether the default filters should be ignored when filters are given. + * / + @Parameter(defaultValue="true") + private boolean ignoreDefaultFilters = true; + + /** + * Comma separated list of components to which orphaned resources should be added. + * + * If a component contains a colon, everything behind the colon is interpreted as a semicolon + * separated list of resource patterns of orphans that should be added to the preceeding component. + * If no such list is given, any orphaned resource will be added to the component. + * The evaluation logic for the filter list is the same as for the filters + * parameters: excludes can be denoted with a leading '-' or '!' and order is significant. + * Later filters can override the result of earlier ones. + * + * If no component is given, orphans will only be reported but not added to any component (default). + * + * @since 1.29.1 + * / + @Parameter + private String externalResources; +*/ + + +/** + * Collects all resources in a set of resource folders or from an archive + * and writes a 'resources.json' file for each component or library + * that can be found in the resources. + * + * @since 1.29.0 + */ +class ResourceCollector { + /** + * Collects resources + * + * @param {ResourcePool} pool + * @param {ResourceFilterList} [filter] used to filter the resources based on their name + */ + constructor(pool, filter) { + this._pool = pool; + this._filter = filter != null ? filter : new ResourceFilterList(); + /** + * name to resource info + * + * @type {Map} + */ + this._resources = new Map(); + + /** + * prefix to ResourcesList + * + * @type {Map} + * @private + */ + this._components = new Map(); + + /** + * prefix to ResourcesList + * + * @type {Map} + * @private + */ + this._themePackages = new Map(); + } + + setExternalResources(list) { + this._externalResources = list; + } + + /** + * Processes a resource + * + * @param {string} virPath virtual path of the resource + * @param {number} sizeBytes size in bytes + */ + visitResource(virPath, sizeBytes) { + if ( !virPath.startsWith("/resources/") ) { + log.warn(`non-runtime resource ${virPath} ignored`); + return; + } + const name = virPath.slice("/resources/".length); + if ( this._filter.matches(name) ) { + const resource = new ResourceInfo(name); + resource.size = sizeBytes; + this._resources.set(name, resource); + + const p = name.lastIndexOf("/"); + const prefix = name.substring(0, p + 1); + const basename = name.substring(p + 1); + if ( basename.match("[^/]*\\.library|Component\\.js|manifest\\.json") && !this._components.has(prefix) ) { + this._components.set(prefix, new ResourcesList(prefix)); + } + // a .theme file within a theme folder indicates a library/theme package + // Note: ignores .theme files in library folders + + // .theming files are not always present therefore this check is relevant for the library.source.less + if ( name.match("(?:[^/]+/)*themes/[^/]+/(?:\\.theming|library.source.less)") && !this._themePackages.has(prefix) ) { + // log.info("found new theme package %s", prefix); + this._themePackages.set(prefix, new ResourcesList(prefix)); + } + } + } + + async enrichWithDependencyInfo(resourceInfo) { + return this._pool.getModuleInfo(resourceInfo.name).then((moduleInfo) => { + if ( moduleInfo.name ) { + resourceInfo.module = moduleInfo.name; + } + if ( moduleInfo.dynamicDependencies ) { + resourceInfo.dynRequired = true; + } + if ( moduleInfo.dependencies.length > 0 ) { + resourceInfo.required = resourceInfo.required || new Set(); + resourceInfo.condRequired = resourceInfo.condRequired || new Set(); + moduleInfo.dependencies.forEach((dep) => { + if ( moduleInfo.isConditionalDependency(dep) ) { + resourceInfo.condRequired.add(dep); + } else if ( !moduleInfo.isImplicitDependency(dep) ) { + resourceInfo.required.add(dep); + } + }); + } + if ( moduleInfo.subModules.length > 0 ) { + resourceInfo.included = resourceInfo.included || new Set(); + moduleInfo.subModules.forEach((mod) => { + resourceInfo.included.add(mod); + }); + } + + if (moduleInfo.requiresTopLevelScope) { + resourceInfo.requiresTopLevelScope = true; + } + if (moduleInfo.exposedGlobals != null && moduleInfo.exposedGlobals.length) { + resourceInfo.exposedGlobalNames = resourceInfo.exposedGlobalNames || new Set(); + moduleInfo.exposedGlobals.forEach((exposedGlobalName) => { + resourceInfo.exposedGlobalNames.add(exposedGlobalName); + }); + } + + if (moduleInfo.rawModule) { + resourceInfo.format = "raw"; + } + }); + } + + async determineResourceDetails({pool, debugResources, mergedResources, designtimeResources, supportResources}) { + const baseNames = new Set(); + const debugFilter = ResourceFilterList.fromString(debugResources); + const mergeFilter = ResourceFilterList.fromString(mergedResources); + const designtimeFilter = ResourceFilterList.fromString(designtimeResources); + const supportFilter = ResourceFilterList.fromString(supportResources); + + const promises = []; + + for (const [name, info] of this._resources.entries()) { + // log.verbose(` checking ${name}`); + let m; + if ( m = LOCALE.exec(name) ) { + const baseName = m[1] + m[3]; + log.verbose(` found potential i18n resource '${name}', base name is '${baseName}', locale is ${m[2]}`); + info.i18nName = baseName; + info.i18nLocale = m[2]; + baseNames.add(baseName); + } + + if ( m = THEME.exec(name) ) { + // log.verbose("found theme candidate %s with prefix %s", name, m[1]); + if ( this._themePackages.has(m[0]) ) { + const theme = m[2]; + info.theme = theme; + log.verbose(` found potential theme resource '${name}', theme ${theme}`); + } + } + + if ( /(?:\.js|\.view.xml|\.control.xml|\.fragment.xml)$/.test(name) ) { + promises.push( + this.enrichWithDependencyInfo(info) + ); + } + + // set the module name for .properties and .json + if ( /(?:\.properties|\.json)$/.test(name) ) { + promises.push(new Promise((resolve) => { + return this._pool.getModuleInfo(info.name).then((moduleInfo) => { + if (moduleInfo.name) { + info.module = moduleInfo.name; + } + resolve(); + }); + })); + } + + if ( debugFilter.matches(name) ) { + info.isDebug = true; + log.verbose(` found potential debug resource '${name}'`); + } + + if ( mergeFilter.matches(name) ) { + info.merged = true; + log.verbose(` found potential merged resource '${name}'`); + } + + if ( designtimeFilter.matches(name) ) { + info.designtime = true; + log.verbose(` found potential designtime resource '${name}'`); + } + + if ( supportFilter.matches(name) ) { + info.support = true; + log.verbose(` found potential support resource '${name}'`); + } + } + + for (const baseName of baseNames) { + if ( this._resources.has(baseName) ) { + const info = this._resources.get(baseName); + info.i18nName = baseName; + info.i18nLocale = ""; + } + } + + return Promise.all(promises); + } + + createOrphanFilters() { + log.verbose( + ` configured external resources filters (resources outside the namespace): ${this._externalResources == null ? "(none)" : this._externalResources}`); + + const filtersByComponent = new Map(); + + if ( this._externalResources != null ) { + for ( let [component, filters] of Object.entries(this._externalResources) ) { + const packageFilters = new ResourceFilterList(filters); + if ( component === "/" || component === "" ) { + component = ""; + } else if ( !component.endsWith("/") ) { + component += "/"; + } + log.verbose(` resulting filter list for '${component}': '${packageFilters}'`); + filtersByComponent.set(component, packageFilters); + } + } + return filtersByComponent; + } + + groupResourcesByComponents(options) { + const orphanFilters = this.createOrphanFilters(); + const debugBundlesFilter = ResourceFilterList.fromString(options.debugBundles); + for (const resource of this._resources.values()) { + let contained = false; + for (const [prefix, list] of this._components.entries()) { + const isDebugBundle = debugBundlesFilter.matches(resource.name); + if ( resource.name.startsWith(prefix) ) { + list.add(resource, !isDebugBundle); + contained = true; + } else if ( orphanFilters.has(prefix) ) { + // log.verbose(` checking '${resource.name}' against orphan filter '${orphanFilters.get(prefix)}' (${prefix})`); + if ( orphanFilters.get(prefix).matches(resource.name) ) { + list.add(resource, !isDebugBundle); + contained = true; + } + } + } + + if ( resource.theme != null ) { + // assign theme resources additionally to theme packages + for (const [prefix, list] of this._themePackages.entries()) { + if ( resource.name.startsWith(prefix) ) { + list.add(resource); + contained = true; + } + } + } + + if ( contained ) { + this._resources.delete(resource.name); + } + } + } + + /** + * + * @returns {Set} resource names + */ + get resources() { + return new Set(this._resources.keys()); + } + + /** + * Components + * + * @returns {Map} + */ + get components() { + return this._components; + } + + /** + * @returns {Map} + */ + get themePackages() { + return this._themePackages; + } +} + +module.exports = ResourceCollector; diff --git a/lib/lbt/resources/ResourceInfo.js b/lib/lbt/resources/ResourceInfo.js new file mode 100644 index 000000000..c921082c1 --- /dev/null +++ b/lib/lbt/resources/ResourceInfo.js @@ -0,0 +1,180 @@ +/** + * Information about a single resource as stored in the resources.json file. + * + * @author Frank Weigel + * @since 1.33.0 + */ +class ResourceInfo { + /** + * @param {string} name name of the resource + */ + constructor(name) { + this.name = name; + this.i18nName = null; + this.i18nLocale = null; + this.isDebug = false; + this.theme = null; + this.merged = false; + this.designtime = false; + this.support = false; + this._module = null; + this.required = null; + this.condRequired = null; + this.included = null; + this.dynRequired = false; + this.requiresTopLevelScope = false; + this.exposedGlobalNames = null; + this._format = null; + this._size = -1; + } + + + get module() { + return this._module; + } + + set module(value) { + this._module = value; + } + + get format() { + return this._format; + } + + set format(value) { + this._format = value; + } + + get size() { + return this._size; + } + + set size(value) { + this._size = value; + } + + /** + * Copies the properties of the given ResourceInfo into this + * + * @param {string} prefix + * @param {ResourceInfo} orig + */ + copyFrom(prefix, orig) { + this.i18nName = orig.i18nName; + this.i18nLocale = orig.i18nLocale; + this.isDebug = orig.isDebug; + this.theme = orig.theme; + this.merged = orig.merged; + this.designtime = orig.designtime; + this.support = orig.support; + if ( this._module == null ) { + this._module = orig._module; + } + if ( orig.required != null ) { + if ( this.required == null ) { + this.required = new Set(); + } + orig.required.forEach(this.required.add, this.required); + } + if ( orig.condRequired != null ) { + if ( this.condRequired == null ) { + this.condRequired = new Set(); + } + orig.condRequired.forEach(this.condRequired.add, this.condRequired); + } + if ( orig.dynRequired ) { + this.dynRequired = orig.dynRequired; + } + if ( orig.included != null ) { + if ( this.included == null ) { + this.included = new Set(); + } + orig.included.forEach(this.included.add, this.included); + } + if ( this.included != null && this.included.size > 0 ) { + this.merged = true; + } + if (orig.size >= 0) { + this.size = orig.size; + } + if ( orig.requiresTopLevelScope ) { + this.requiresTopLevelScope = orig.requiresTopLevelScope; + } + if ( orig.exposedGlobalNames != null ) { + if ( this.exposedGlobalNames == null ) { + this.exposedGlobalNames = new Set(); + } + orig.exposedGlobalNames.forEach(this.exposedGlobalNames.add, this.exposedGlobalNames); + } + if ( orig._format != null ) { + this._format = orig._format; + } + } + + /** + * called from JSON.stringify() + * + * @returns {{name: *}} + */ + toJSON() { + const result = { + name: this.name + }; + if ( this._module != null ) { + result.module = this.module; + } + if ( this.size >= 0 ) { + result.size = this.size; + } + if ( this.requiresTopLevelScope ) { + result.requiresTopLevelScope = this.requiresTopLevelScope; + } + if ( this.exposedGlobalNames != null && this.exposedGlobalNames.size > 0 ) { + result.exposedGlobalNames = [...this.exposedGlobalNames]; + } + if ( this._format ) { + result.format = this._format; + } + + // + + if ( this.isDebug ) { + result.isDebug = this.isDebug; + } + if ( this.merged ) { + result.merged = this.merged; + } + if ( this.designtime ) { + result.designtime = this.designtime; + } + if ( this.support ) { + result.support = this.support; + } + if ( this.i18nLocale != null ) { + result.locale = this.i18nLocale; + result.raw = this.i18nName; + } + if ( this.theme != null ) { + result.theme = this.theme; + } + + // + + if ( this.required != null && this.required.size > 0 ) { + result.required = [...this.required].sort(); + } + if ( this.condRequired != null && this.condRequired.size > 0 ) { + result.condRequired = [...this.condRequired].sort(); + } + if ( this.dynRequired ) { + result.dynRequired = this.dynRequired; + } + if ( this.included != null && this.included.size > 0 ) { + result.included = [...this.included]; + } + + return result; + } +} + +module.exports = ResourceInfo; diff --git a/lib/lbt/resources/ResourcesList.js b/lib/lbt/resources/ResourcesList.js new file mode 100644 index 000000000..88335c527 --- /dev/null +++ b/lib/lbt/resources/ResourcesList.js @@ -0,0 +1,152 @@ +const ResourceInfo = require("./ResourceInfo"); + +const DEBUG_RESOURCES_PATTERN = /-dbg((?:\.view|\.fragment|\.controller|\.designtime|\.support)?\.js|\.css)$/; +const RESOURCES_PATTERN = /((?:\.view|\.fragment|\.controller|\.designtime|\.support)?\.js|\.css)$/; + +/** + * A list of ResourceInfo objects, suitable for (but not dependent on) JSON serialization. + * + * @author Frank Weigel + * @since 1.33.0 + */ +class ResourcesList { + /** + * Holds ResourceInfos + * + * @param {string} prefix + */ + constructor(prefix) { + /** + * List of resources information objects + * + * @type {ResourceInfo[]} + */ + this.resources = []; + + // --- transient state --- + /** + * @type {string} name of the resource + */ + this.name = prefix; + /** + * + * @type {Map} + */ + this.resourcesByName = new Map(); + } + + /** + * Add ResourceInfo to list + * + * @param {ResourceInfo} info + * @param {boolean} shareDebugInformation + */ + add(info, shareDebugInformation=true) { + const relativeName = ResourcesList.makePathRelativeTo(this.name, info.name); + + // search for a resource with the same name + let myInfo = this.resourcesByName.get(relativeName); + + if ( myInfo == null && shareDebugInformation) { + // when not found, check if the given resource is a debug resource and + // share the information with the non-dbg version + const nonDbgName = ResourcesList.getNonDebugName(relativeName); + const dbgName = ResourcesList.getDebugName(relativeName); + if ( nonDbgName != null && this.resourcesByName.has(nonDbgName) ) { + // copy from source + myInfo = new ResourceInfo(relativeName); + const source = this.resourcesByName.get(nonDbgName); + myInfo.copyFrom(this.name, source); + if (source.i18nName) { + myInfo.i18nName = ResourcesList.makePathRelativeTo(this.name, source.i18nName); + } + this.resources.push(myInfo); + this.resourcesByName.set(relativeName, myInfo); + } else if (dbgName != null && this.resourcesByName.has(dbgName)) { + // copy from debug + myInfo = new ResourceInfo(relativeName); + const source = this.resourcesByName.get(dbgName); + myInfo.copyFrom(this.name, source); + if (source.i18nName) { + myInfo.i18nName = ResourcesList.makePathRelativeTo(this.name, source.i18nName); + } + myInfo.module = ResourcesList.getNonDebugName(source.module); + this.resources.push(myInfo); + this.resourcesByName.set(relativeName, myInfo); + } + } + + // this is the assumption, that the debug one is the same as the non-dbg one + if ( myInfo == null ) { + myInfo = new ResourceInfo(relativeName); + myInfo.size = info.size; + myInfo.module = ResourcesList.getNonDebugName(info.name); + this.resources.push(myInfo); + this.resourcesByName.set(relativeName, myInfo); + } + myInfo.copyFrom(this.name, info); + if (info.i18nName) { + myInfo.i18nName = ResourcesList.makePathRelativeTo(this.name, info.i18nName); + } + } + + /** + * Serializes its content to JSON format + * + * @returns {{resources: ResourceInfo[], _version: string}} + */ + toJSON() { + this.resources.sort((a, b) => { + if ( a.name === b.name ) { + return 0; + } + return a.name < b.name ? -1 : 1; + }); + return { + /** + * Version of the resources.json file format, must be 1.1.0 or higher to store dependencies + */ + _version: "1.1.0", + resources: this.resources + }; + } + + static makePathRelativeTo(prefix, name) { + let back = ""; + while ( !name.startsWith(prefix) ) { + const p = prefix.lastIndexOf("/", prefix.length - 2); + back = back + "../"; + if ( p >= 0 ) { + prefix = prefix.slice(0, p + 1); + } else { + prefix = ""; + break; + } + } + return back + name.slice(prefix.length); + } + + /** + * If the given module is a -dbg file, calculate and return the non-dbg name. + * + * @param {string} path + * @returns {string|null} Non-debug name of the module + */ + static getNonDebugName(path) { + if ( DEBUG_RESOURCES_PATTERN.test(path) ) { + return path.replace( DEBUG_RESOURCES_PATTERN, "$1"); + } + return null; + } + + static getDebugName(path) { + if ( RESOURCES_PATTERN.test(path) ) { + if (!path.replace(RESOURCES_PATTERN, "").endsWith("-dbg")) { + return path.replace( RESOURCES_PATTERN, "-dbg$1"); + } + } + return null; + } +} + +module.exports = ResourcesList; diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 0c9e929e9..ff7afd9eb 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -1,374 +1,12 @@ "use strict"; const log = require("@ui5/logger").getLogger("builder:processors:resourceListCreator"); -const ResourceFilterList = require("../lbt/resources/ResourceFilterList"); +const ResourceCollector = require("../lbt/resources/ResourceCollector"); const LocatorResourcePool = require("../lbt/resources/LocatorResourcePool"); - +const ResourceInfo = require("../lbt/resources/ResourceInfo"); const EvoResource = require("@ui5/fs").Resource; -const DEBUG_RESOURCES_PATTERN = /-dbg((?:\.view|\.fragment|\.controller|\.designtime|\.support)?\.js|\.css)$/; -const RESOURCES_PATTERN = /((?:\.view|\.fragment|\.controller|\.designtime|\.support)?\.js|\.css)$/; - -/** - * Information about a single resource as stored in the resources.json file. - * - * @author Frank Weigel - * @since 1.33.0 - */ -class ResourceInfo { - constructor(name) { - this.name = name; - this.i18nName = null; - this.i18nLocale = null; - this.isDebug = false; - this.theme = null; - this.merged = false; - this.designtime = false; - this.support = false; - this._module = null; - this.required = null; - this.condRequired = null; - this.included = null; - this.dynRequired = false; - this.requiresTopLevelScope = false; - this.exposedGlobalNames = null; - this._format = null; - this._size = -1; - } - - - get module() { - return this._module; - } - - set module(value) { - this._module = value; - } - - get format() { - return this._format; - } - - set format(value) { - this._format = value; - } - - get size() { - return this._size; - } - - set size(value) { - this._size = value; - } - - /** - * Copies the properties of the given ResourceInfo into this - * - * @param {string} prefix - * @param {ResourceInfo} orig - */ - copyFrom(prefix, orig) { - this.i18nName = orig.i18nName == null ? null : ResourcesList.makePathRelativeTo(prefix, orig.i18nName); - this.i18nLocale = orig.i18nLocale; - this.isDebug = orig.isDebug; - this.theme = orig.theme; - this.merged = orig.merged; - this.designtime = orig.designtime; - this.support = orig.support; - if ( this._module == null ) { - this._module = orig._module; - } - if ( orig.required != null ) { - if ( this.required == null ) { - this.required = new Set(); - } - orig.required.forEach(this.required.add, this.required); - } - if ( orig.condRequired != null ) { - if ( this.condRequired == null ) { - this.condRequired = new Set(); - } - orig.condRequired.forEach(this.condRequired.add, this.condRequired); - } - if ( orig.dynRequired ) { - this.dynRequired = orig.dynRequired; - } - if ( orig.included != null ) { - if ( this.included == null ) { - this.included = new Set(); - } - orig.included.forEach(this.included.add, this.included); - } - if ( this.included != null && this.included.size > 0 ) { - this.merged = true; - } - if (orig.size >= 0) { - this.size = orig.size; - } - if ( orig.requiresTopLevelScope ) { - this.requiresTopLevelScope = orig.requiresTopLevelScope; - } - if ( orig.exposedGlobalNames != null ) { - if ( this.exposedGlobalNames == null ) { - this.exposedGlobalNames = new Set(); - } - orig.exposedGlobalNames.forEach(this.exposedGlobalNames.add, this.exposedGlobalNames); - } - if ( orig._format != null ) { - this._format = orig._format; - } - } - - /** - * called from JSON.stringify() - * - * @returns {{name: *}} - */ - toJSON() { - const result = { - name: this.name - }; - if ( this._module != null ) { - result.module = this.module; - } - if ( this.size >= 0 ) { - result.size = this.size; - } - if ( this.requiresTopLevelScope ) { - result.requiresTopLevelScope = this.requiresTopLevelScope; - } - if ( this.exposedGlobalNames != null && this.exposedGlobalNames.size > 0 ) { - result.exposedGlobalNames = [...this.exposedGlobalNames]; - } - if ( this._format ) { - result.format = this._format; - } - - // - - if ( this.isDebug ) { - result.isDebug = this.isDebug; - } - if ( this.merged ) { - result.merged = this.merged; - } - if ( this.designtime ) { - result.designtime = this.designtime; - } - if ( this.support ) { - result.support = this.support; - } - if ( this.i18nLocale != null ) { - result.locale = this.i18nLocale; - result.raw = this.i18nName; - } - if ( this.theme != null ) { - result.theme = this.theme; - } - - // - - if ( this.required != null && this.required.size > 0 ) { - result.required = [...this.required].sort(); - } - if ( this.condRequired != null && this.condRequired.size > 0 ) { - result.condRequired = [...this.condRequired].sort(); - } - if ( this.dynRequired ) { - result.dynRequired = this.dynRequired; - } - if ( this.included != null && this.included.size > 0 ) { - result.included = [...this.included]; - } - - return result; - } -} - -/** - * A list of ResourceInfo objects, suitable for (but not dependent on) JSON serialization. - * - * @author Frank Weigel - * @since 1.33.0 - */ -class ResourcesList { - constructor(prefix) { - /** - * List of resources information objects - */ - this.resources = []; - - // --- transient state --- - this.name = prefix; - /** - * - * @type {Map} - */ - this.resourcesByName = new Map(); - } - - /** - * Add ResourceInfo to list - * - * @param {ResourceInfo} info - * @param {boolean} shareDebugInformation - */ - add(info, shareDebugInformation=true) { - const relativeName = ResourcesList.makePathRelativeTo(this.name, info.name); - - // search for a resource with the same name - let myInfo = this.resourcesByName.get(relativeName); - - if ( myInfo == null && shareDebugInformation) { - // when not found, check if the given resource is a debug resource and share the information with the non-dbg version - const nonDbgName = ResourcesList.getNonDebugName(relativeName); - const dbgName = ResourcesList.getDebugName(relativeName); - if ( nonDbgName != null && this.resourcesByName.has(nonDbgName) ) { - // copy from source - myInfo = new ResourceInfo(relativeName); - const source = this.resourcesByName.get(nonDbgName); - myInfo.copyFrom(this.name, source); - this.resources.push(myInfo); - this.resourcesByName.set(relativeName, myInfo); - } else if (dbgName != null && this.resourcesByName.has(dbgName)) { - // copy from debug - myInfo = new ResourceInfo(relativeName); - const source = this.resourcesByName.get(dbgName); - myInfo.copyFrom(this.name, source); - myInfo.module = ResourcesList.getNonDebugName(source.module); - this.resources.push(myInfo); - this.resourcesByName.set(relativeName, myInfo); - } - } - - // this is the assumption, that the debug one is the same as the non-dbg one - if ( myInfo == null ) { - myInfo = new ResourceInfo(relativeName); - myInfo.size = info.size; - const sourceName = ResourcesList.getNonDebugName(info.name); - myInfo.module = sourceName; - this.resources.push(myInfo); - this.resourcesByName.set(relativeName, myInfo); - } - myInfo.copyFrom(this.name, info); - } - - toJSON() { - this.resources.sort((a, b) => { - if ( a.name === b.name ) { - return 0; - } - return a.name < b.name ? -1 : 1; - }); - return { - /** - * Version of the resources.json file format, must be 1.1.0 or higher to store dependencies - */ - _version: "1.1.0", - resources: this.resources - }; - } - - static makePathRelativeTo(prefix, name) { - let back = ""; - while ( !name.startsWith(prefix) ) { - const p = prefix.lastIndexOf("/", prefix.length - 2); - back = back + "../"; - if ( p >= 0 ) { - prefix = prefix.slice(0, p + 1); - } else { - prefix = ""; - break; - } - } - return back + name.slice(prefix.length); - } - - /** - * If the given module is a -dbg file, calculate and return the non-dbg name. - * - * @param {string} path - * @returns {string|null} Non-debug name of the module - */ - static getNonDebugName(path) { - if ( DEBUG_RESOURCES_PATTERN.test(path) ) { - return path.replace( DEBUG_RESOURCES_PATTERN, "$1"); - } - return null; - } - - static getDebugName(path) { - if ( RESOURCES_PATTERN.test(path) ) { - if (!path.replace(RESOURCES_PATTERN, "").endsWith("-dbg")) { - return path.replace( RESOURCES_PATTERN, "-dbg$1"); - } - } - return null; - } -} - -/** - * Collects all resources in a set of resource folders or from an archive - * and writes a 'resources.json' file for each component or library - * that can be found in the resources. - * - * @since 1.29.0 - */ - -/* NODE-TODO - /** - * Global filters that should be taken into account when collecting resources. - * - * Each filter entry can be a comma separated list of simple filters. Each simple filter - * can be a pattern in resource name pattern syntax: A double asterisk '&0x2a;&0x2a;/' denotes an arbitrary - * number of resource name segments (folders) incl. a trailing slash, whereas a simple asterisk '*' - * denotes an arbitrary number of resource name characters, but not the segment separator '/'. - * A dot is interpreted as a dot, all other special regular expression characters keep their - * special meaning. This is a mixture of ANT-style path patterns and regular expressions. - * - * Excludes can be denoted by a leading '-' or '!', includes optionally by a leading '+'. - * Order of filters is significant, a later exclusion overrides an earlier inclusion - * and vice versa. - * - * Example: - *
    -	 *	 !sap/ui/core/
    -	 *	 +sap/ui/core/utils/
    -	 * 
    - * excludes everything from sap/ui/core, but includes everything from the subpackage sap/ui/core/utils/. - * - * Note that the filter operates on the full name of each resource. If a resource name - * prefix is configured for a resource set, the filter will be applied - * to the combination of prefix and local file path and not only to the local file path. - * / - @Parameter - private String[] filters; - - /** - * Whether the default filters should be ignored when filters are given. - * / - @Parameter(defaultValue="true") - private boolean ignoreDefaultFilters = true; - - /** - * Comma separated list of components to which orphaned resources should be added. - * - * If a component contains a colon, everything behind the colon is interpreted as a semicolon - * separated list of resource patterns of orphans that should be added to the preceeding component. - * If no such list is given, any orphaned resource will be added to the component. - * The evaluation logic for the filter list is the same as for the filters - * parameters: excludes can be denoted with a leading '-' or '!' and order is significant. - * Later filters can override the result of earlier ones. - * - * If no component is given, orphans will only be reported but not added to any component (default). - * - * @since 1.29.1 - * / - @Parameter - private String externalResources; -*/ - /** * List of resource patterns that describe all debug resources. * @@ -429,7 +67,7 @@ const DEFAULT_SUPPORT_RESOURCES_FILTER = [ ]; /** - * Hard coded debug bundle, to trigger separate analysis for this __filename + * Hard coded debug bundle, to trigger separate analysis for this filename * because sap-ui-core.js and sap-ui-core-dbg.js have different includes * * @type {string[]} @@ -438,266 +76,6 @@ const DEBUG_BUNDLES = [ "sap-ui-core-dbg.js" ]; -const LOCALE = /^((?:[^/]+\/)*[^/]+?)_([A-Z]{2}(?:_[A-Z]{2}(?:_[A-Z0-9_]+)?)?)(\.properties|\.hdbtextbundle)$/i; -const THEME = /^((?:[^/]+\/)*)themes\/([^/]+)\//; - -class ResourceCollector { - constructor(pool, filter) { - this._pool = pool; - this._filter = filter != null ? filter : new ResourceFilterList(); - /** - * name to resource info - * - * @type {Map} - */ - this._resources = new Map(); - - /** - * prefix to ResourcesList - * - * @type {Map} - * @private - */ - this._components = new Map(); - this._themePackages = new Map(); - } - - setExternalResources(list) { - this._externalResources = list; - } - - /** - * Processes a resource - * - * @param {string} virPath virtual path of the resource - * @param {number} sizeBytes size in bytes - */ - visitResource(virPath, sizeBytes) { - if ( !virPath.startsWith("/resources/") ) { - log.warn(`non-runtime resource ${virPath} ignored`); - return; - } - const name = virPath.slice("/resources/".length); - if ( this._filter.matches(name) ) { - const resource = new ResourceInfo(name); - resource.size = sizeBytes; - this._resources.set(name, resource); - - const p = name.lastIndexOf("/"); - const prefix = name.substring(0, p + 1); - const basename = name.substring(p + 1); - if ( basename.match("[^/]*\\.library|Component\\.js|manifest\\.json") && !this._components.has(prefix) ) { - this._components.set(prefix, new ResourcesList(prefix)); - } - // a .theme file within a theme folder indicates a library/theme package - // Note: ignores .theme files in library folders - - // .theming files are not always present therefore this check is relevant for the library.source.less - if ( name.match("(?:[^/]+/)*themes/[^/]+/(?:\\.theming|library.source.less)") && !this._themePackages.has(prefix) ) { - // log.info("found new theme package %s", prefix); - this._themePackages.set(prefix, new ResourcesList(prefix)); - } - } - } - - async enrichWithDependencyInfo(resourceInfo) { - return this._pool.getModuleInfo(resourceInfo.name).then((moduleInfo) => { - if ( moduleInfo.name ) { - resourceInfo.module = moduleInfo.name; - } - if ( moduleInfo.dynamicDependencies ) { - resourceInfo.dynRequired = true; - } - if ( moduleInfo.dependencies.length > 0 ) { - resourceInfo.required = resourceInfo.required || new Set(); - resourceInfo.condRequired = resourceInfo.condRequired || new Set(); - moduleInfo.dependencies.forEach((dep) => { - if ( moduleInfo.isConditionalDependency(dep) ) { - resourceInfo.condRequired.add(dep); - } else if ( !moduleInfo.isImplicitDependency(dep) ) { - resourceInfo.required.add(dep); - } - }); - } - if ( moduleInfo.subModules.length > 0 ) { - resourceInfo.included = resourceInfo.included || new Set(); - moduleInfo.subModules.forEach((mod) => { - resourceInfo.included.add(mod); - }); - } - - if (moduleInfo.requiresTopLevelScope) { - resourceInfo.requiresTopLevelScope = true; - } - if (moduleInfo.exposedGlobals != null && moduleInfo.exposedGlobals.length) { - resourceInfo.exposedGlobalNames = resourceInfo.exposedGlobalNames || new Set(); - moduleInfo.exposedGlobals.forEach((exposedGlobalName) => { - resourceInfo.exposedGlobalNames.add(exposedGlobalName); - }); - } - - if (moduleInfo.rawModule) { - resourceInfo.format = "raw"; - } - }); - } - - async determineResourceDetails({pool, debugResources, mergedResources, designtimeResources, supportResources}) { - const baseNames = new Set(); - const debugFilter = ResourceFilterList.fromString(debugResources); - const mergeFilter = ResourceFilterList.fromString(mergedResources); - const designtimeFilter = ResourceFilterList.fromString(designtimeResources); - const supportFilter = ResourceFilterList.fromString(supportResources); - - const promises = []; - - for (const [name, info] of this._resources.entries()) { - // log.verbose(` checking ${name}`); - let m; - if ( m = LOCALE.exec(name) ) { - const baseName = m[1] + m[3]; - log.verbose(` found potential i18n resource '${name}', base name is '${baseName}', locale is ${m[2]}`); - info.i18nName = baseName; - info.i18nLocale = m[2]; - baseNames.add(baseName); - } - - if ( m = THEME.exec(name) ) { - // log.verbose("found theme candidate %s with prefix %s", name, m[1]); - if ( this._themePackages.has(m[0]) ) { - const theme = m[2]; - info.theme = theme; - log.verbose(` found potential theme resource '${name}', theme ${theme}`); - } - } - - if ( /(?:\.js|\.view.xml|\.control.xml|\.fragment.xml)$/.test(name) ) { - promises.push( - this.enrichWithDependencyInfo(info) - ); - } - - // set the module name for .properties and .json - if ( /(?:\.properties|\.json)$/.test(name) ) { - promises.push(new Promise((resolve) => { - return this._pool.getModuleInfo(info.name).then((moduleInfo) => { - if (moduleInfo.name) { - info.module = moduleInfo.name; - } - resolve(); - }); - })); - } - - if ( debugFilter.matches(name) ) { - info.isDebug = true; - log.verbose(` found potential debug resource '${name}'`); - } - - if ( mergeFilter.matches(name) ) { - info.merged = true; - log.verbose(` found potential merged resource '${name}'`); - } - - if ( designtimeFilter.matches(name) ) { - info.designtime = true; - log.verbose(` found potential designtime resource '${name}'`); - } - - if ( supportFilter.matches(name) ) { - info.support = true; - log.verbose(` found potential support resource '${name}'`); - } - } - - for (const baseName of baseNames) { - if ( this._resources.has(baseName) ) { - const info = this._resources.get(baseName); - info.i18nName = baseName; - info.i18nLocale = ""; - } - } - - return Promise.all(promises); - } - - createOrphanFilters() { - log.verbose( - ` configured external resources filters (resources outside the namespace): ${this._externalResources == null ? "(none)" : this._externalResources}`); - - const filtersByComponent = new Map(); - - if ( this._externalResources != null ) { - for ( let [component, filters] of Object.entries(this._externalResources) ) { - const packageFilters = new ResourceFilterList(filters); - if ( component === "/" || component === "" ) { - component = ""; - } else if ( !component.endsWith("/") ) { - component += "/"; - } - log.verbose(` resulting filter list for '${component}': '${packageFilters}'`); - filtersByComponent.set(component, packageFilters); - } - } - return filtersByComponent; - } - - groupResourcesByComponents(options) { - const orphanFilters = this.createOrphanFilters(); - const debugBundlesFilter = ResourceFilterList.fromString(options.debugBundles); - for (const resource of this._resources.values()) { - let contained = false; - for (const [prefix, list] of this._components.entries()) { - const isDebugBundle = debugBundlesFilter.matches(resource.name); - if ( resource.name.startsWith(prefix) ) { - list.add(resource, !isDebugBundle); - contained = true; - } else if ( orphanFilters.has(prefix) ) { - // log.verbose(` checking '${resource.name}' against orphan filter '${orphanFilters.get(prefix)}' (${prefix})`); - if ( orphanFilters.get(prefix).matches(resource.name) ) { - list.add(resource, !isDebugBundle); - contained = true; - } - } - } - - if ( resource.theme != null ) { - // assign theme resources additionally to theme packages - for (const [prefix, list] of this._themePackages.entries()) { - if ( resource.name.startsWith(prefix) ) { - list.add(resource); - contained = true; - } - } - } - - if ( contained ) { - this._resources.delete(resource.name); - } - } - } - - /** - * - * @returns {Set} resource names - */ - get resources() { - return new Set(this._resources.keys()); - } - - /** - * Components - * - * @returns {Map} - */ - get components() { - return this._components; - } - - get themePackages() { - return this._themePackages; - } -} /** * Whether the detection of orphans should result in a build failure. From e102acfc1faba9f03b742eabe3b1ab6fa2dfc92c Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Fri, 7 Aug 2020 10:39:06 +0200 Subject: [PATCH 46/88] add unit tests for ResourcesList use setter and getter instead of private fields in ResourceInfo --- lib/lbt/resources/ResourceCollector.js | 4 +- lib/lbt/resources/ResourceInfo.js | 12 ++--- lib/lbt/resources/ResourcesList.js | 6 --- test/lib/lbt/resources/ResourcesList.js | 62 +++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 14 deletions(-) create mode 100644 test/lib/lbt/resources/ResourcesList.js diff --git a/lib/lbt/resources/ResourceCollector.js b/lib/lbt/resources/ResourceCollector.js index b643f5f27..feb989d1f 100644 --- a/lib/lbt/resources/ResourceCollector.js +++ b/lib/lbt/resources/ResourceCollector.js @@ -198,8 +198,8 @@ class ResourceCollector { if ( m = LOCALE.exec(name) ) { const baseName = m[1] + m[3]; log.verbose(` found potential i18n resource '${name}', base name is '${baseName}', locale is ${m[2]}`); - info.i18nName = baseName; - info.i18nLocale = m[2]; + info.i18nName = baseName; // e.g. "i18n.properties" + info.i18nLocale = m[2]; // e.g. "de" baseNames.add(baseName); } diff --git a/lib/lbt/resources/ResourceInfo.js b/lib/lbt/resources/ResourceInfo.js index c921082c1..a6a378473 100644 --- a/lib/lbt/resources/ResourceInfo.js +++ b/lib/lbt/resources/ResourceInfo.js @@ -67,8 +67,8 @@ class ResourceInfo { this.merged = orig.merged; this.designtime = orig.designtime; this.support = orig.support; - if ( this._module == null ) { - this._module = orig._module; + if ( this.module == null ) { + this.module = orig.module; } if ( orig.required != null ) { if ( this.required == null ) { @@ -106,8 +106,8 @@ class ResourceInfo { } orig.exposedGlobalNames.forEach(this.exposedGlobalNames.add, this.exposedGlobalNames); } - if ( orig._format != null ) { - this._format = orig._format; + if ( orig.format != null ) { + this.format = orig.format; } } @@ -132,8 +132,8 @@ class ResourceInfo { if ( this.exposedGlobalNames != null && this.exposedGlobalNames.size > 0 ) { result.exposedGlobalNames = [...this.exposedGlobalNames]; } - if ( this._format ) { - result.format = this._format; + if ( this.format ) { + result.format = this.format; } // diff --git a/lib/lbt/resources/ResourcesList.js b/lib/lbt/resources/ResourcesList.js index 88335c527..5da51a81b 100644 --- a/lib/lbt/resources/ResourcesList.js +++ b/lib/lbt/resources/ResourcesList.js @@ -57,9 +57,6 @@ class ResourcesList { myInfo = new ResourceInfo(relativeName); const source = this.resourcesByName.get(nonDbgName); myInfo.copyFrom(this.name, source); - if (source.i18nName) { - myInfo.i18nName = ResourcesList.makePathRelativeTo(this.name, source.i18nName); - } this.resources.push(myInfo); this.resourcesByName.set(relativeName, myInfo); } else if (dbgName != null && this.resourcesByName.has(dbgName)) { @@ -67,9 +64,6 @@ class ResourcesList { myInfo = new ResourceInfo(relativeName); const source = this.resourcesByName.get(dbgName); myInfo.copyFrom(this.name, source); - if (source.i18nName) { - myInfo.i18nName = ResourcesList.makePathRelativeTo(this.name, source.i18nName); - } myInfo.module = ResourcesList.getNonDebugName(source.module); this.resources.push(myInfo); this.resourcesByName.set(relativeName, myInfo); diff --git a/test/lib/lbt/resources/ResourcesList.js b/test/lib/lbt/resources/ResourcesList.js new file mode 100644 index 000000000..8ace77d50 --- /dev/null +++ b/test/lib/lbt/resources/ResourcesList.js @@ -0,0 +1,62 @@ +const test = require("ava"); + +const ResourcesList = require("../../../../lib/lbt/resources/ResourcesList"); + +test("add: add new resources", (t) => { + const resourcesList = new ResourcesList("prefix"); + + const myInfo = {name: "myfile.js", size: 13}; + t.deepEqual(resourcesList.resources, [], "empty list"); + + resourcesList.add(myInfo); + + t.is(resourcesList.resources.length, 1, "one entry"); + + const result = resourcesList.resources[0]; + t.falsy(result.module, "module is not set"); +}); + +test("add: add source then debug resources", (t) => { + const resourcesList = new ResourcesList("prefix"); + + resourcesList.add({name: "myfile.js", module: "myfile.js", size: 13}); + + const myInfo = {name: "myfile-dbg.js", size: 13}; + resourcesList.add(myInfo); + + t.is(resourcesList.resources.length, 2, "two entries"); + + const result = resourcesList.resourcesByName.get("../myfile.js"); + t.is(result.module, "myfile.js", "module is set"); + + const resultDbg = resourcesList.resourcesByName.get("../myfile-dbg.js"); + t.is(resultDbg.module, "myfile.js", "module is set"); +}); + +test("add: add debug then source resources", (t) => { + const resourcesList = new ResourcesList("prefix"); + + resourcesList.add({name: "myfile-dbg.js", size: 13}); + + const myInfo = {name: "myfile.js", module: "myfile.js", size: 13}; + resourcesList.add(myInfo); + + t.is(resourcesList.resources.length, 2, "two entries"); + + const result = resourcesList.resourcesByName.get("../myfile.js"); + t.is(result.module, "myfile.js", "module is set"); + + const resultDbg = resourcesList.resourcesByName.get("../myfile-dbg.js"); + t.is(resultDbg.module, "myfile.js", "module is set"); +}); + +test("add: add i18n resource", (t) => { + const resourcesList = new ResourcesList("prefix"); + + resourcesList.add({name: "i18n_en.properties", i18nName: "i18n.properties", size: 13}); + + t.is(resourcesList.resources.length, 1, "one entry"); + + const result = resourcesList.resourcesByName.get("../i18n_en.properties"); + t.is(result.i18nName, "../i18n.properties", "i18n name is set relative"); +}); From dcac57c504deed895d0f54fb9ea1f49b2227ed8d Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Fri, 7 Aug 2020 11:33:00 +0200 Subject: [PATCH 47/88] add unit tests for ResourcesList: toJSON and makePathRelativeTo --- lib/lbt/resources/ResourcesList.js | 7 +++++ test/lib/lbt/resources/ResourcesList.js | 39 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/lib/lbt/resources/ResourcesList.js b/lib/lbt/resources/ResourcesList.js index 5da51a81b..56f96ccb3 100644 --- a/lib/lbt/resources/ResourcesList.js +++ b/lib/lbt/resources/ResourcesList.js @@ -105,6 +105,13 @@ class ResourcesList { }; } + /** + * Retrieves the relative path + * + * @param {string} prefix + * @param {string} name + * @returns {string} + */ static makePathRelativeTo(prefix, name) { let back = ""; while ( !name.startsWith(prefix) ) { diff --git a/test/lib/lbt/resources/ResourcesList.js b/test/lib/lbt/resources/ResourcesList.js index 8ace77d50..e05ede24a 100644 --- a/test/lib/lbt/resources/ResourcesList.js +++ b/test/lib/lbt/resources/ResourcesList.js @@ -60,3 +60,42 @@ test("add: add i18n resource", (t) => { const result = resourcesList.resourcesByName.get("../i18n_en.properties"); t.is(result.i18nName, "../i18n.properties", "i18n name is set relative"); }); + +test("add: resource with the same name", (t) => { + const resourcesList = new ResourcesList("prefix"); + + resourcesList.add({name: "myfile.js", size: 13}); + resourcesList.add({name: "myfile.js", size: 13}); + + t.is(resourcesList.resources.length, 1, "one entry"); + + const result = resourcesList.resourcesByName.get("../myfile.js"); + t.is(result.name, "../myfile.js", "name is set relative"); +}); + +test("toJSON: resource with the same name", (t) => { + const resourcesList = new ResourcesList("prefix"); + + resourcesList.resources.push({name: "myfile.js", size: 13}); + resourcesList.resources.push({name: "myfile.js", size: 13}); + + t.deepEqual(resourcesList.toJSON(), { + _version: "1.1.0", + resources: [ + { + name: "myfile.js", + size: 13, + }, + { + name: "myfile.js", + size: 13, + }, + ], + }, "one entry"); +}); + +test("makePathRelativeTo: same prefix", (t) => { + const relativePath = ResourcesList.makePathRelativeTo("am/bn/cf", "args/myfile.js"); + + t.is(relativePath, "../../../args/myfile.js", "relative path"); +}); From 97e93364bc48df3758b61233957d51a80b03d390 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Fri, 7 Aug 2020 13:01:16 +0200 Subject: [PATCH 48/88] add ResourceCollector unit tests --- lib/lbt/resources/ResourceCollector.js | 4 +++ test/lib/lbt/resources/ResourceCollector.js | 35 +++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 test/lib/lbt/resources/ResourceCollector.js diff --git a/lib/lbt/resources/ResourceCollector.js b/lib/lbt/resources/ResourceCollector.js index feb989d1f..5ca2349cf 100644 --- a/lib/lbt/resources/ResourceCollector.js +++ b/lib/lbt/resources/ResourceCollector.js @@ -103,6 +103,10 @@ class ResourceCollector { this._themePackages = new Map(); } + /** + * + * @param {object} list + */ setExternalResources(list) { this._externalResources = list; } diff --git a/test/lib/lbt/resources/ResourceCollector.js b/test/lib/lbt/resources/ResourceCollector.js new file mode 100644 index 000000000..9b27539a6 --- /dev/null +++ b/test/lib/lbt/resources/ResourceCollector.js @@ -0,0 +1,35 @@ +const test = require("ava"); + +const ResourceCollector = require("../../../../lib/lbt/resources/ResourceCollector"); + +test("add: empty constructor dummy params", (t) => { + const resourceCollector = new ResourceCollector({}, {}); + t.is(resourceCollector.resources.size, 0, "empty"); +}); + +test("add: empty constructor", (t) => { + const resourceCollector = new ResourceCollector(); + t.is(resourceCollector.resources.size, 0, "empty"); +}); + +test("setExternalResources: empty filters", (t) => { + const resourceCollector = new ResourceCollector(); + resourceCollector.setExternalResources({ + "testcomp": [] + }); + const orphanFilters = resourceCollector.createOrphanFilters(); + t.is(orphanFilters.size, 1, "1 filter"); +}); + +test("createOrphanFilters: filters", (t) => { + const resourceCollector = new ResourceCollector(); + resourceCollector.setExternalResources({ + "testcomp": ["test"], + "/": ["test"], + "": ["test"], + "a/": ["test"], + "b": ["test"], + }); + const orphanFilters = resourceCollector.createOrphanFilters(); + t.is(orphanFilters.size, 4, "4 filters"); +}); From 2ab886899d9946ec4574b8f867c759a59db96169 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Fri, 7 Aug 2020 15:43:34 +0200 Subject: [PATCH 49/88] add ResourceCollector unit tests * groupResourcesByComponents * visitResource --- test/lib/lbt/resources/ResourceCollector.js | 50 ++++++++++++++++++--- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/test/lib/lbt/resources/ResourceCollector.js b/test/lib/lbt/resources/ResourceCollector.js index 9b27539a6..de7c979d4 100644 --- a/test/lib/lbt/resources/ResourceCollector.js +++ b/test/lib/lbt/resources/ResourceCollector.js @@ -1,18 +1,40 @@ const test = require("ava"); +const sinon = require("sinon"); +const mock = require("mock-require"); -const ResourceCollector = require("../../../../lib/lbt/resources/ResourceCollector"); +let ResourceCollector = require("../../../../lib/lbt/resources/ResourceCollector"); -test("add: empty constructor dummy params", (t) => { +test.beforeEach((t) => { + // Spying logger of processors/bootstrapHtmlTransformer + const log = require("@ui5/logger"); + const loggerInstance = log.getLogger("lbt:resources:ResourceCollector"); + mock("@ui5/logger", { + getLogger: () => loggerInstance + }); + mock.reRequire("@ui5/logger"); + t.context.logWarnSpy = sinon.spy(loggerInstance, "warn"); + + // Re-require tested module + ResourceCollector = mock.reRequire("../../../../lib/lbt/resources/ResourceCollector"); +}); + +test.afterEach.always((t) => { + mock.stop("@ui5/logger"); + t.context.logWarnSpy.restore(); +}); + + +test.serial("add: empty constructor dummy params", (t) => { const resourceCollector = new ResourceCollector({}, {}); t.is(resourceCollector.resources.size, 0, "empty"); }); -test("add: empty constructor", (t) => { +test.serial("add: empty constructor", (t) => { const resourceCollector = new ResourceCollector(); t.is(resourceCollector.resources.size, 0, "empty"); }); -test("setExternalResources: empty filters", (t) => { +test.serial("setExternalResources: empty filters", (t) => { const resourceCollector = new ResourceCollector(); resourceCollector.setExternalResources({ "testcomp": [] @@ -21,7 +43,7 @@ test("setExternalResources: empty filters", (t) => { t.is(orphanFilters.size, 1, "1 filter"); }); -test("createOrphanFilters: filters", (t) => { +test.serial("createOrphanFilters: filters", (t) => { const resourceCollector = new ResourceCollector(); resourceCollector.setExternalResources({ "testcomp": ["test"], @@ -33,3 +55,21 @@ test("createOrphanFilters: filters", (t) => { const orphanFilters = resourceCollector.createOrphanFilters(); t.is(orphanFilters.size, 4, "4 filters"); }); + +test.serial("visitResource: path", (t) => { + const resourceCollector = new ResourceCollector(); + resourceCollector.visitResource("mypath", 13); + t.is(t.context.logWarnSpy.callCount, 1); + t.is(t.context.logWarnSpy.getCall(0).args[0], "non-runtime resource mypath ignored"); +}); + +test.serial("groupResourcesByComponents: debugBundles", (t) => { + const resourceCollector = new ResourceCollector(); + resourceCollector.setExternalResources({ + "testcomp": ["my/file.js"] + }); + resourceCollector.visitResource("/resources/testcomp/Component.js", 13); + resourceCollector.visitResource("/resources/my/file.js", 13); + resourceCollector.groupResourcesByComponents({debugBundles: ".*-dbg.js"}); + t.is(resourceCollector.resources.size, 0, "all resources were deleted"); +}); From 2b8409d64b9af016353a82ebe8c4a696d3e2febd Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 10 Aug 2020 08:31:41 +0200 Subject: [PATCH 50/88] Add test for ThemeLibraryBuilder --- .../types/themeLibrary/ThemeLibraryBuilder.js | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/lib/types/themeLibrary/ThemeLibraryBuilder.js diff --git a/test/lib/types/themeLibrary/ThemeLibraryBuilder.js b/test/lib/types/themeLibrary/ThemeLibraryBuilder.js new file mode 100644 index 000000000..6b55e3c86 --- /dev/null +++ b/test/lib/types/themeLibrary/ThemeLibraryBuilder.js @@ -0,0 +1,41 @@ +const test = require("ava"); + +const ThemeLibraryBuilder = require("../../../../lib/types/themeLibrary/ThemeLibraryBuilder"); + +test("tasks", async (t) => { + const themeLibraryBuilder = new ThemeLibraryBuilder({ + resourceCollections: { + workspace: { + byGlob: async () => { + return []; + } + } + }, + buildContext: { + isRootProject: () => { + return true; + } + }, + project: { + metadata: { + name: "name", + copyright: "copyright" + }, + type: "type" + }, + parentLogger: { + createSubLogger: () => { + return { + createTaskLogger: () => { + + } + }; + } + } + }); + const asyncTasks = Object.keys(themeLibraryBuilder.tasks).map((taskKey) => { + return themeLibraryBuilder.tasks[taskKey](); + }); + + t.is(asyncTasks.length, 4, "all 4 tasks should be added"); +}); From ed1e9d18eecfdd0f32321dbfa8e903b8a6665d0c Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 10 Aug 2020 09:36:38 +0200 Subject: [PATCH 51/88] Add tests for ResourceCollector Fix regexps by using the explicit point instead of single character --- lib/lbt/resources/ResourceCollector.js | 4 +- test/lib/lbt/resources/ResourceCollector.js | 86 +++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/lib/lbt/resources/ResourceCollector.js b/lib/lbt/resources/ResourceCollector.js index 5ca2349cf..4978c0880 100644 --- a/lib/lbt/resources/ResourceCollector.js +++ b/lib/lbt/resources/ResourceCollector.js @@ -138,7 +138,7 @@ class ResourceCollector { // Note: ignores .theme files in library folders // .theming files are not always present therefore this check is relevant for the library.source.less - if ( name.match("(?:[^/]+/)*themes/[^/]+/(?:\\.theming|library.source.less)") && !this._themePackages.has(prefix) ) { + if ( name.match("(?:[^/]+/)*themes/[^/]+/(?:\\.theming|library\\.source\\.less)") && !this._themePackages.has(prefix) ) { // log.info("found new theme package %s", prefix); this._themePackages.set(prefix, new ResourcesList(prefix)); } @@ -216,7 +216,7 @@ class ResourceCollector { } } - if ( /(?:\.js|\.view.xml|\.control.xml|\.fragment.xml)$/.test(name) ) { + if ( /(?:\.js|\.view\.xml|\.control\.xml|\.fragment\.xml)$/.test(name) ) { promises.push( this.enrichWithDependencyInfo(info) ); diff --git a/test/lib/lbt/resources/ResourceCollector.js b/test/lib/lbt/resources/ResourceCollector.js index de7c979d4..3f555141d 100644 --- a/test/lib/lbt/resources/ResourceCollector.js +++ b/test/lib/lbt/resources/ResourceCollector.js @@ -63,6 +63,13 @@ test.serial("visitResource: path", (t) => { t.is(t.context.logWarnSpy.getCall(0).args[0], "non-runtime resource mypath ignored"); }); +test.serial("visitResource: library.source.less", (t) => { + const resourceCollector = new ResourceCollector(); + t.is(resourceCollector.themePackages.size, 0, "initially there is no theme package"); + resourceCollector.visitResource("/resources/themes/a/library.source.less", 13); + t.is(resourceCollector.themePackages.size, 1, "theme package was added"); +}); + test.serial("groupResourcesByComponents: debugBundles", (t) => { const resourceCollector = new ResourceCollector(); resourceCollector.setExternalResources({ @@ -73,3 +80,82 @@ test.serial("groupResourcesByComponents: debugBundles", (t) => { resourceCollector.groupResourcesByComponents({debugBundles: ".*-dbg.js"}); t.is(resourceCollector.resources.size, 0, "all resources were deleted"); }); + +test.serial("groupResourcesByComponents: theme", async (t) => { + const resourceCollector = new ResourceCollector(); + resourceCollector.visitResource("/resources/themes/a/.theming", 13); + t.is(resourceCollector.themePackages.size, 1, "1 theme was added"); + await resourceCollector.determineResourceDetails({}); + resourceCollector.groupResourcesByComponents({}); + t.is(resourceCollector.themePackages.get("themes/a/").resources.length, 1, "1 theme was grouped"); +}); + +test.serial("determineResourceDetails: properties", async (t) => { + const resourceCollector = new ResourceCollector({ + getModuleInfo: async (moduleInfo) => { + return { + name: "myName" + }; + } + }); + resourceCollector.visitResource("/resources/mylib/manifest.json", 13); + resourceCollector.visitResource("/resources/mylib/i18n/i18n_de.properties", 13); + resourceCollector.visitResource("/resources/mylib/i18n/i18n.properties", 13); + await resourceCollector.determineResourceDetails({}); + resourceCollector.groupResourcesByComponents({}); + const resources = resourceCollector.components.get("mylib/").resources; + t.deepEqual(resources.map((res) => res.i18nName), [null, "i18n/i18n.properties", "i18n/i18n.properties"], "i18nName was set"); +}); + +test.serial("determineResourceDetails: view.xml", async (t) => { + const resourceCollector = new ResourceCollector({ + getModuleInfo: async (moduleInfo) => { + return { + name: "myName" + }; + } + }); + const enrichWithDependencyInfoStub = sinon.stub(resourceCollector, "enrichWithDependencyInfo").returns(Promise.resolve()); + resourceCollector.visitResource("/resources/mylib/my.view.xml", 13); + await resourceCollector.determineResourceDetails({}); + t.is(enrichWithDependencyInfoStub.callCount, 1, "is called once"); + t.is(enrichWithDependencyInfoStub.getCall(0).args[0].name, "mylib/my.view.xml", "is called with view"); +}); + +test.serial("enrichWithDependencyInfo: add infos to resourceinfo", async (t) => { + const resourceCollector = new ResourceCollector({ + getModuleInfo: async () => { + return { + name: "myname", + dynamicDependencies: true, + isConditionalDependency: (dep) => { + return dep.includes("conditional"); + }, + isImplicitDependency: (dep) => { + return dep.includes("implicit"); + }, + dependencies: [ + "mydependency.conditional", "mydependency.implicit", "mydependency" + ], + subModules: [ + "mySubmodule" + ], + requiresTopLevelScope: true, + exposedGlobals: ["myGlobal"], + rawModule: true + }; + } + }); + const resourceInfo = {}; + await resourceCollector.enrichWithDependencyInfo(resourceInfo); + t.deepEqual(resourceInfo, { + condRequired: new Set(["mydependency.conditional"]), + dynRequired: true, + exposedGlobalNames: new Set(["myGlobal"]), + format: "raw", + included: new Set(["mySubmodule"]), + module: "myname", + required: new Set(["mydependency"]), + requiresTopLevelScope: true + }, "all information gets used for the resourceInfo"); +}); From bfd0a048962b8616e2f8b9a0d9a1241f02922aa0 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 10 Aug 2020 10:55:20 +0200 Subject: [PATCH 52/88] Add tests for Resource --- test/lib/lbt/resources/Resource.js | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/lib/lbt/resources/Resource.js diff --git a/test/lib/lbt/resources/Resource.js b/test/lib/lbt/resources/Resource.js new file mode 100644 index 000000000..b6e0670ce --- /dev/null +++ b/test/lib/lbt/resources/Resource.js @@ -0,0 +1,33 @@ +const test = require("ava"); +const sinon = require("sinon"); +const mock = require("mock-require"); + +let Resource = require("../../../../lib/lbt/resources/Resource"); + +test.serial("Resource: buffer", async (t) => { + const readFileStub = sinon.stub().callsArg(1); + mock("graceful-fs", { + readFile: readFileStub + }); + mock.reRequire("graceful-fs"); + + // Re-require tested module + Resource = mock.reRequire("../../../../lib/lbt/resources/Resource"); + const resource = new Resource({}, "name", "file"); + await resource.buffer(); + + mock.stop("graceful-fs"); + + t.is(readFileStub.callCount, 1, "called once"); + t.is(readFileStub.getCall(0).args[0], "file", "called with file parameter"); +}); + +test.serial("Resource: constructor", async (t) => { + const resource = new Resource({}, "name", "file"); + t.is(resource.fileSize, -1, "called once"); +}); + +test.serial("Resource: constructor with stat", async (t) => { + const resource = new Resource({}, "name", "file", {size: 47}); + t.is(resource.fileSize, 47, "called once"); +}); From 27d69e26cedd5e2a6098222e2a658ad4ae608afa Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 10 Aug 2020 11:23:53 +0200 Subject: [PATCH 53/88] Add tests for ResourceInfo --- test/lib/lbt/resources/ResourceInfo.js | 101 +++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 test/lib/lbt/resources/ResourceInfo.js diff --git a/test/lib/lbt/resources/ResourceInfo.js b/test/lib/lbt/resources/ResourceInfo.js new file mode 100644 index 000000000..67d264520 --- /dev/null +++ b/test/lib/lbt/resources/ResourceInfo.js @@ -0,0 +1,101 @@ +const test = require("ava"); + +const ResourceInfo = require("../../../../lib/lbt/resources/ResourceInfo"); + +test("ResourceInfo: constructor", async (t) => { + const resourceInfo = new ResourceInfo("myName"); + t.falsy(resourceInfo.module, "module not set"); + t.falsy(resourceInfo.format, "format not set"); + t.is(resourceInfo.size, -1, "size not set"); +}); + +test("ResourceInfo: copyFrom", async (t) => { + // setup + const resourceInfo = new ResourceInfo("myName"); + const origResourceInfo = new ResourceInfo("origMyName"); + origResourceInfo.i18nName = "i18nName"; + origResourceInfo.i18nLocale = "i18nLocale"; + origResourceInfo.isDebug = false; + origResourceInfo.theme = "theme"; + origResourceInfo.merged = false; + origResourceInfo.designtime = false; + origResourceInfo.support = false; + origResourceInfo.module = "module"; + origResourceInfo.required = new Set(["required"]); + origResourceInfo.condRequired = new Set(["condRequired"]); + origResourceInfo.included = new Set(["included"]); + origResourceInfo.dynRequired = false; + origResourceInfo.requiresTopLevelScope = false; + origResourceInfo.exposedGlobalNames = new Set(["myGlobal"]); + origResourceInfo.format = "raw"; + origResourceInfo.size = 13; + + // action + resourceInfo.copyFrom("prefix", origResourceInfo); + + // expectation + t.is(resourceInfo.i18nName, "i18nName", "value is copied over"); + t.is(resourceInfo.i18nLocale, "i18nLocale", "value is copied over"); + t.is(resourceInfo.isDebug, false, "value is copied over"); + t.is(resourceInfo.theme, "theme", "value is copied over"); + t.is(resourceInfo.merged, true, "value is copied over"); + t.is(resourceInfo.designtime, false, "value is copied over"); + t.is(resourceInfo.support, false, "value is copied over"); + t.is(resourceInfo.module, "module", "value is copied over"); + t.deepEqual(resourceInfo.required, new Set(["required"]), "value is copied over"); + t.deepEqual(resourceInfo.condRequired, new Set(["condRequired"]), "value is copied over"); + t.deepEqual(resourceInfo.included, new Set(["included"]), "value is copied over"); + t.is(resourceInfo.dynRequired, false, "value is copied over"); + t.is(resourceInfo.requiresTopLevelScope, false, "value is copied over"); + t.deepEqual(resourceInfo.exposedGlobalNames, new Set(["myGlobal"]), "value is copied over"); + t.is(resourceInfo.format, "raw", "value is copied over"); + t.is(resourceInfo.size, 13, "value is copied over"); +}); + +test("ResourceInfo: toJSON", async (t) => { + const resourceInfo = new ResourceInfo("myName"); + resourceInfo.i18nName = "i18nName"; + resourceInfo.i18nLocale = "i18nLocale"; + resourceInfo.isDebug = true; + resourceInfo.theme = "theme"; + resourceInfo.merged = true; + resourceInfo.designtime = true; + resourceInfo.support = true; + resourceInfo.module = "module"; + resourceInfo.required = new Set(["required"]); + resourceInfo.condRequired = new Set(["condRequired"]); + resourceInfo.included = new Set(["included"]); + resourceInfo.dynRequired = true; + resourceInfo.requiresTopLevelScope = true; + resourceInfo.exposedGlobalNames = new Set(["myGlobal"]); + resourceInfo.format = "raw"; + resourceInfo.size = 13; + + t.deepEqual(resourceInfo.toJSON(), { + condRequired: [ + "condRequired", + ], + designtime: true, + dynRequired: true, + exposedGlobalNames: [ + "myGlobal", + ], + format: "raw", + included: [ + "included", + ], + isDebug: true, + locale: "i18nLocale", + merged: true, + module: "module", + name: "myName", + raw: "i18nName", + required: [ + "required", + ], + requiresTopLevelScope: true, + size: 13, + support: true, + theme: "theme", + }, "json content is correct"); +}); From 487609aa1192fe0df23f6caa8fa5491c05df9028 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 10 Aug 2020 12:24:23 +0200 Subject: [PATCH 54/88] Add tests for ResourceListCreator Added resources.json entry for theme resources.json file --- lib/processors/resourceListCreator.js | 79 +++++++++++-------- .../library/a/themes/base/resources.json | 4 + .../j/themes/somefancytheme/resources.json | 4 + test/lib/processors/resourceListCreator.js | 64 +++++++++++++++ 4 files changed, 119 insertions(+), 32 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index ff7afd9eb..81809e80e 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -76,6 +76,47 @@ const DEBUG_BUNDLES = [ "sap-ui-core-dbg.js" ]; +/** + * Adds resources.json itself to the list + * + * @param {ResourcesList} list resources list + * @param {string} prefix + * @returns {string} new content with resources.json entry + */ +function addResourcesJsonToList(list, prefix) { + // having the file size entry part of the file is a bit like the chicken egg scenario + // you can't change the value of the file size without changing the file size + // so this part here tries to cope with that. + + // try to add resources.json entry with previous size of the list string. + // get the content to be added (resources.json entry) + // modify the size of the entry from the calculated one + + let contentString = JSON.stringify(list, null, "\t"); + const resourcesJson = new ResourceInfo(prefix + "resources.json"); + // initial size + resourcesJson.size = Buffer.from(contentString).byteLength; + list.add(resourcesJson); + + contentString = JSON.stringify(list, null, "\t"); + + let newLength = Buffer.from(contentString).byteLength; + + // Adjust size until it is correct + // This entry's size depends on the file size which depends on this entry's size,... + // Updating the number of the size in the content might influence the size of the file itself + // This is deterministic because e.g. in the content -> "size": 1000 has the same amount of bytes as "size": 9999 + // the difference might only come for: + // * adding the initial entry of resources.json + // * changes when the number of digits of the number changes, e.g. 100 -> 1000 + while (resourcesJson.size !== newLength) { + resourcesJson.size = newLength; + list.add(resourcesJson); + contentString = JSON.stringify(list, null, "\t"); + newLength = Buffer.from(contentString).byteLength; + } + return contentString; +} /** * Whether the detection of orphans should result in a build failure. @@ -84,6 +125,7 @@ const DEBUG_BUNDLES = [ * @param {object} configuration * @param {module:@ui5/fs.Resource[]} configuration.resources * @param {object} [options] configuration options + * @returns {module:@ui5/fs.Resource[]} list of resources.json files */ module.exports = async function({resources}, options) { options = Object.assign({ @@ -133,37 +175,7 @@ module.exports = async function({resources}, options) { for (const [prefix, list] of collector.components.entries()) { log.verbose(` writing '${prefix}resources.json'`); - // having the file size entry part of the file is a bit like the chicken egg scenario - // you can't change the value of the file size without changing the file size - // so this part here tries to cope with that. - - // try to add resources.json entry with previous size of the list string. - // get the content to be added (resources.json entry) - // modify the size of the entry from the calculated one - - let contentString = JSON.stringify(list, null, "\t"); - const resourcesJson = new ResourceInfo(prefix + "resources.json"); - // initial size - resourcesJson.size = Buffer.from(contentString).byteLength; - list.add(resourcesJson); - - contentString = JSON.stringify(list, null, "\t"); - - let newLength = Buffer.from(contentString).byteLength; - - // Adjust size until it is correct - // This entry's size depends on the file size which depends on this entry's size,... - // Updating the number of the size in the content might influence the size of the file itself - // This is deterministic because e.g. in the content -> "size": 1000 has the same amount of bytes as "size": 9999 - // the difference might only come for: - // * adding the initial entry of resources.json - // * changes when the number of digits of the number changes, e.g. 100 -> 1000 - while (resourcesJson.size !== newLength) { - resourcesJson.size = newLength; - list.add(resourcesJson); - contentString = JSON.stringify(list, null, "\t"); - newLength = Buffer.from(contentString).byteLength; - } + const contentString = addResourcesJsonToList(list, prefix); resourceLists.push(new EvoResource({ path: `/resources/${prefix}resources.json`, @@ -172,9 +184,12 @@ module.exports = async function({resources}, options) { } for (const [prefix, list] of collector.themePackages.entries()) { log.verbose(` writing '${prefix}resources.json'`); + + const contentString = addResourcesJsonToList(list, prefix); + resourceLists.push(new EvoResource({ path: `/resources/${prefix}resources.json`, - string: JSON.stringify(list, null, "\t") + string: contentString })); } const unassigned = collector.resources; diff --git a/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/resources.json b/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/resources.json index 5ef2a50bb..ab347b8a7 100644 --- a/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/resources.json +++ b/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/resources.json @@ -22,6 +22,10 @@ "size": 111, "designtime": true, "theme": "base" + }, + { + "name": "resources.json", + "size": 484 } ] } \ No newline at end of file diff --git a/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json b/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json index 68c643959..d4c81a925 100644 --- a/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json +++ b/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json @@ -28,6 +28,10 @@ "size": 42, "designtime": true, "theme": "somefancytheme" + }, + { + "name": "resources.json", + "size": 633 } ] } \ No newline at end of file diff --git a/test/lib/processors/resourceListCreator.js b/test/lib/processors/resourceListCreator.js index 5a2e18988..27547de6c 100644 --- a/test/lib/processors/resourceListCreator.js +++ b/test/lib/processors/resourceListCreator.js @@ -31,6 +31,17 @@ test.serial("Empty resources", async (t) => { t.deepEqual(result, []); }); +test.serial("Empty resources but options", async (t) => { + const result = await resourceListCreator({ + resources: [] + }, { + externalResources: { + "mycomp": [".*dbg.js"] + } + }); + t.deepEqual(result, []); +}); + test.serial("Orphaned resources", async (t) => { const resource = resourceFactory.createResource({ path: "/resources/nomodule.foo", @@ -45,3 +56,56 @@ test.serial("Orphaned resources", async (t) => { t.is(t.context.logErrorSpy.callCount, 1); t.is(t.context.logErrorSpy.getCall(0).args[0], "resources.json generation failed because of unassigned resources: nomodule.foo"); }); + +// 114,134-168,174-175 + +test.serial("components and themes", async (t) => { + const componentResource = resourceFactory.createResource({ + path: "/resources/mylib/manifest.json", + string: "bar content" + }); + const themeResource = resourceFactory.createResource({ + path: "/resources/themes/a/.theming", + string: "base less content" + }); + const resources = await resourceListCreator({ + resources: [componentResource, themeResource] + }); + + t.is(resources.length, 2); + const libResourceJson = resources[0]; + const themeResourceJson = resources[1]; + t.is(libResourceJson.getPath(), "/resources/mylib/resources.json"); + t.is(themeResourceJson.getPath(), "/resources/themes/a/resources.json"); + + const libResourcesJsonContent = await libResourceJson.getString(); + const themeResourcesJsonContent = await themeResourceJson.getString(); + t.is(libResourcesJsonContent, `{ + "_version": "1.1.0", + "resources": [ + { + "name": "manifest.json", + "module": "mylib/manifest.json", + "size": 11 + }, + { + "name": "resources.json", + "size": 183 + } + ] +}`); + t.is(themeResourcesJsonContent, `{ + "_version": "1.1.0", + "resources": [ + { + "name": ".theming", + "size": 17, + "theme": "a" + }, + { + "name": "resources.json", + "size": 159 + } + ] +}`); +}); From 5286cf13e5702c4a7c8955d1708ea224aba42a0a Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 10 Aug 2020 13:42:09 +0200 Subject: [PATCH 55/88] Exclude generateResourcesJson from default active tasks --- lib/builder/builder.js | 1 + test/lib/builder/builder.js | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 8ea6caa99..221e9a27d 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -59,6 +59,7 @@ function composeTaskList({dev, selfContained, jsdoc, includedTasks, excludedTask selectedTasks.executeJsdocSdkTransformation = false; selectedTasks.generateCachebusterInfo = false; selectedTasks.generateApiIndex = false; + selectedTasks.generateResourcesJson = false; if (selfContained) { // No preloads, bundle only diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index e3cb5ff21..576fc0436 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -361,6 +361,9 @@ test("Build application.g", (t) => { const expectedPath = path.join("test", "expected", "build", "application.g", "dest"); return builder.build({ + includedTasks: [ + "generateResourcesJson" + ], tree: applicationGTree, destPath, excludedTasks: ["generateStandaloneAppBundle", "generateVersionInfo"] @@ -381,6 +384,9 @@ test("Build application.g with component preload paths", (t) => { const expectedPath = path.join("test", "expected", "build", "application.g", "dest"); return builder.build({ + includedTasks: [ + "generateResourcesJson" + ], tree: applicationGTreeComponentPreloadPaths, destPath, excludedTasks: ["generateStandaloneAppBundle", "generateVersionInfo"] @@ -424,6 +430,9 @@ test("Build application.h", (t) => { return builder.build({ tree: applicationHTree, destPath, + includedTasks: [ + "generateResourcesJson" + ], excludedTasks: ["createDebugFiles", "generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo"] }).then(() => { @@ -443,6 +452,9 @@ test("Build application.i", (t) => { const expectedPath = path.join("test", "expected", "build", "application.i", "dest"); return builder.build({ + includedTasks: [ + "generateResourcesJson" + ], tree: applicationITree, destPath, excludedTasks: ["createDebugFiles", "generateStandaloneAppBundle", "generateVersionInfo"] @@ -463,7 +475,9 @@ test("Build application.j", (t) => { const expectedPath = path.join("test", "expected", "build", "application.j", "dest"); return builder.build({ - tree: applicationJTree, + includedTasks: [ + "generateResourcesJson" + ], tree: applicationJTree, destPath, excludedTasks: ["createDebugFiles", "generateStandaloneAppBundle", "generateVersionInfo"] }).then(() => { @@ -483,6 +497,9 @@ test("Build library.d with copyright from .library file", (t) => { const expectedPath = path.join("test", "expected", "build", "library.d", "dest"); return builder.build({ + includedTasks: [ + "generateResourcesJson" + ], tree: libraryDTree, destPath, excludedTasks: ["generateLibraryPreload"] @@ -504,6 +521,9 @@ test("Build library.e with copyright from settings of ui5.yaml", (t) => { const expectedPath = path.join("test", "expected", "build", "library.e", "dest"); return builder.build({ + includedTasks: [ + "generateResourcesJson" + ], tree: libraryETree, destPath, excludedTasks: ["generateLibraryPreload"] @@ -525,6 +545,9 @@ test("Build library.h with custom bundles and component-preloads", (t) => { const expectedPath = path.join("test", "expected", "build", "library.h", "dest"); return builder.build({ + includedTasks: [ + "generateResourcesJson" + ], tree: libraryHTree, destPath, excludedTasks: ["createDebugFiles", "generateLibraryPreload"] @@ -546,6 +569,9 @@ test("Build library.i with manifest info taken from .library and library.js", (t const expectedPath = path.join("test", "expected", "build", "library.i", "dest"); return builder.build({ + includedTasks: [ + "generateResourcesJson" + ], tree: libraryITree, destPath, excludedTasks: ["createDebugFiles", "generateLibraryPreload", "uglify"] @@ -588,6 +614,9 @@ test("Build theme.j even without an library", (t) => { const destPath = "./test/tmp/build/theme.j/dest"; const expectedPath = "./test/expected/build/theme.j/dest"; return builder.build({ + includedTasks: [ + "generateResourcesJson" + ], tree: themeJTree, destPath }).then(() => { @@ -608,6 +637,9 @@ test("Build library.n", (t) => { const expectedPath = path.join("test", "expected", "build", "library.n", "dest"); return builder.build({ + includedTasks: [ + "generateResourcesJson" + ], tree: libraryNTree, destPath, excludedTasks: ["generateLibraryPreload"] @@ -629,6 +661,9 @@ test("Build collection library.a", (t) => { const expectedPath = path.join("test", "expected", "build", "collection", "library.a", "dest"); return builder.build({ + includedTasks: [ + "generateResourcesJson" + ], tree: collectionLibraryATree, destPath, excludedTasks: ["generateLibraryPreload"] From f22be4a8b904bbc052c8e4daeab78212adbee6cb Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 10 Aug 2020 15:01:13 +0200 Subject: [PATCH 56/88] distributed integration tests for generateResourcesJson task --- .../build/application.g/dest/resources.json | 105 ------------------ .../dest/subcomponentA/resources.json | 41 ------- .../dest/subcomponentB/resources.json | 41 ------- .../build/application.h/dest/resources.json | 91 --------------- .../build/application.i/dest/resources.json | 62 ----------- .../dest-resources-json/Component-preload.js | 12 ++ .../dest-resources-json/Component.js | 1 + .../changes/coding/MyExtension.js | 1 + .../changes/flexibility-bundle.json | 1 + .../changes/fragments/MyFragment.fragment.xml | 3 + .../changes/id_111_appDescriptor.change | 21 ++++ .../changes/id_111_compVariants.variant | 21 ++++ .../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 ++++ .../changes/id_123_addField.change | 20 ++++ .../changes/id_456_addField.change | 20 ++++ .../dest-resources-json/manifest.json | 28 +++++ .../resources.json | 0 .../dest/resources/library/d/resources.json | 31 ------ .../dest/resources/library/e/resources.json | 44 -------- .../resources/library/h/.library | 19 ++++ .../library/h/components/Component-preload.js | 10 ++ .../library/h/components/Component.js | 1 + .../library/h/components/TodoComponent.js | 4 + .../library/h/components/resources.json | 0 .../subcomponent1/Component-preload.js | 5 + .../h/components/subcomponent1/Component.js | 1 + .../h/components/subcomponent1/resources.json | 0 .../subcomponent2/Component-preload.js | 5 + .../h/components/subcomponent2/Component.js | 1 + .../h/components/subcomponent2/resources.json | 0 .../subcomponent3/Component-preload.js | 5 + .../h/components/subcomponent3/Component.js | 1 + .../h/components/subcomponent3/resources.json | 0 .../resources/library/h/customBundle.js | 14 +++ .../h/designtime/library.designtime.js | 4 + .../h/designtime/messagebundle.properties | 1 + .../h/designtime/messagebundle_en.properties | 1 + .../resources/library/h/file.js | 4 + .../resources/library/h/library.js | 4 + .../resources/library/h/manifest.json | 39 +++++++ .../resources/library/h/not.js | 4 + .../resources/library/h/resources.json | 0 .../resources/library/h/some.js | 4 + .../test-resources/library/d/Test.html | 0 .../resources/library/n/.library | 19 ++++ .../resources/library/n/Button-dbg.js | 58 ++++++++++ .../resources/library/n/Button.js | 6 + .../n/changeHandler/SplitButton-dbg.js | 29 +++++ .../library/n/changeHandler/SplitButton.js | 6 + .../n/designtime/Button-dbg.designtime.js | 45 ++++++++ .../n/designtime/Button.create.fragment.xml | 10 ++ .../library/n/designtime/Button.designtime.js | 6 + .../library/n/designtime/Button.icon.svg | 26 +++++ .../n/designtime/library-dbg.designtime.js | 10 ++ .../n/designtime/library.designtime.js | 6 + .../n/flexibility/Button.flexibility-dbg.js | 22 ++++ .../n/flexibility/Button.flexibility.js | 6 + .../resources/library/n/library-dbg.js | 40 +++++++ .../library/n/library-dbg.support.js | 23 ++++ .../resources/library/n/library.js | 6 + .../resources/library/n/library.support.js | 6 + .../resources/library/n/manifest.json | 38 +++++++ .../library/n/messagebundle.properties | 1 + .../library/n/messagebundle_de.properties | 1 + .../resources/library/n/resources.json | 0 .../library/n/rules/Button-dbg.support.js | 6 + .../library/n/rules/Button.support.js | 6 + test/lib/builder/builder.js | 83 ++++++++++---- 71 files changed, 776 insertions(+), 434 deletions(-) delete mode 100644 test/expected/build/application.g/dest/resources.json delete mode 100644 test/expected/build/application.g/dest/subcomponentA/resources.json delete mode 100644 test/expected/build/application.g/dest/subcomponentB/resources.json delete mode 100644 test/expected/build/application.h/dest/resources.json delete mode 100644 test/expected/build/application.i/dest/resources.json create mode 100644 test/expected/build/application.j/dest-resources-json/Component-preload.js create mode 100644 test/expected/build/application.j/dest-resources-json/Component.js create mode 100644 test/expected/build/application.j/dest-resources-json/changes/coding/MyExtension.js create mode 100644 test/expected/build/application.j/dest-resources-json/changes/flexibility-bundle.json create mode 100644 test/expected/build/application.j/dest-resources-json/changes/fragments/MyFragment.fragment.xml create mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_111_appDescriptor.change create mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_111_compVariants.variant create mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_111_test.ctrl_variant create mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_111_test.ctrl_variant_change create mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_111_test.ctrl_variant_management_change create mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_111_variantDependentControlChange.change create mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_123_addField.change create mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_456_addField.change create mode 100644 test/expected/build/application.j/dest-resources-json/manifest.json rename test/expected/build/application.j/{dest => dest-resources-json}/resources.json (100%) delete mode 100644 test/expected/build/library.d/dest/resources/library/d/resources.json delete mode 100644 test/expected/build/library.e/dest/resources/library/e/resources.json create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/.library create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/components/Component-preload.js create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/components/Component.js create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/components/TodoComponent.js rename test/expected/build/library.h/{dest => dest-resources-json}/resources/library/h/components/resources.json (100%) create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent1/Component-preload.js create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent1/Component.js rename test/expected/build/library.h/{dest => dest-resources-json}/resources/library/h/components/subcomponent1/resources.json (100%) create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent2/Component-preload.js create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent2/Component.js rename test/expected/build/library.h/{dest => dest-resources-json}/resources/library/h/components/subcomponent2/resources.json (100%) create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent3/Component-preload.js create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent3/Component.js rename test/expected/build/library.h/{dest => dest-resources-json}/resources/library/h/components/subcomponent3/resources.json (100%) create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/customBundle.js create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/library.designtime.js create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/messagebundle.properties create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/messagebundle_en.properties create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/file.js create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/library.js create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/manifest.json create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/not.js rename test/expected/build/library.h/{dest => dest-resources-json}/resources/library/h/resources.json (100%) create mode 100644 test/expected/build/library.h/dest-resources-json/resources/library/h/some.js create mode 100644 test/expected/build/library.h/dest-resources-json/test-resources/library/d/Test.html create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/.library create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.create.fragment.xml create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.icon.svg create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library-dbg.designtime.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library.designtime.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/library.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/manifest.json create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle.properties create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle_de.properties rename test/expected/build/library.n/{dest => dest-resources-json}/resources/library/n/resources.json (100%) create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button-dbg.support.js create mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button.support.js diff --git a/test/expected/build/application.g/dest/resources.json b/test/expected/build/application.g/dest/resources.json deleted file mode 100644 index ec5810807..000000000 --- a/test/expected/build/application.g/dest/resources.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "_version": "1.1.0", - "resources": [ - { - "name": "Component-dbg.js", - "module": "application/g/Component.js", - "size": 183, - "isDebug": true, - "required": [ - "sap/ui/core/UIComponent.js" - ] - }, - { - "name": "Component-preload.js", - "module": "application/g/Component-preload.js", - "size": 564, - "merged": true, - "included": [ - "application/g/Component.js", - "application/g/manifest.json" - ] - }, - { - "name": "Component.js", - "module": "application/g/Component.js", - "size": 141, - "required": [ - "sap/ui/core/UIComponent.js" - ] - }, - { - "name": "manifest.json", - "module": "application/g/manifest.json", - "size": 331 - }, - { - "name": "resources.json", - "size": 2297 - }, - { - "name": "subcomponentA/Component-dbg.js", - "module": "application/g/subcomponentA/Component.js", - "size": 197, - "isDebug": true, - "required": [ - "sap/ui/core/UIComponent.js" - ] - }, - { - "name": "subcomponentA/Component-preload.js", - "module": "application/g/subcomponentA/Component-preload.js", - "size": 587, - "merged": true, - "included": [ - "application/g/subcomponentA/Component.js", - "application/g/subcomponentA/manifest.json" - ] - }, - { - "name": "subcomponentA/Component.js", - "module": "application/g/subcomponentA/Component.js", - "size": 155, - "required": [ - "sap/ui/core/UIComponent.js" - ] - }, - { - "name": "subcomponentA/manifest.json", - "module": "application/g/subcomponentA/manifest.json", - "size": 291 - }, - { - "name": "subcomponentB/Component-dbg.js", - "module": "application/g/subcomponentB/Component.js", - "size": 197, - "isDebug": true, - "required": [ - "sap/ui/core/UIComponent.js" - ] - }, - { - "name": "subcomponentB/Component-preload.js", - "module": "application/g/subcomponentB/Component-preload.js", - "size": 587, - "merged": true, - "included": [ - "application/g/subcomponentB/Component.js", - "application/g/subcomponentB/manifest.json" - ] - }, - { - "name": "subcomponentB/Component.js", - "module": "application/g/subcomponentB/Component.js", - "size": 155, - "required": [ - "sap/ui/core/UIComponent.js" - ] - }, - { - "name": "subcomponentB/manifest.json", - "module": "application/g/subcomponentB/manifest.json", - "size": 291 - } - ] -} \ No newline at end of file diff --git a/test/expected/build/application.g/dest/subcomponentA/resources.json b/test/expected/build/application.g/dest/subcomponentA/resources.json deleted file mode 100644 index 33147302f..000000000 --- a/test/expected/build/application.g/dest/subcomponentA/resources.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "_version": "1.1.0", - "resources": [ - { - "name": "Component-dbg.js", - "module": "application/g/subcomponentA/Component.js", - "size": 197, - "isDebug": true, - "required": [ - "sap/ui/core/UIComponent.js" - ] - }, - { - "name": "Component-preload.js", - "module": "application/g/subcomponentA/Component-preload.js", - "size": 587, - "merged": true, - "included": [ - "application/g/subcomponentA/Component.js", - "application/g/subcomponentA/manifest.json" - ] - }, - { - "name": "Component.js", - "module": "application/g/subcomponentA/Component.js", - "size": 155, - "required": [ - "sap/ui/core/UIComponent.js" - ] - }, - { - "name": "manifest.json", - "module": "application/g/subcomponentA/manifest.json", - "size": 291 - }, - { - "name": "resources.json", - "size": 820 - } - ] -} \ No newline at end of file diff --git a/test/expected/build/application.g/dest/subcomponentB/resources.json b/test/expected/build/application.g/dest/subcomponentB/resources.json deleted file mode 100644 index 2ae6b4d1c..000000000 --- a/test/expected/build/application.g/dest/subcomponentB/resources.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "_version": "1.1.0", - "resources": [ - { - "name": "Component-dbg.js", - "module": "application/g/subcomponentB/Component.js", - "size": 197, - "isDebug": true, - "required": [ - "sap/ui/core/UIComponent.js" - ] - }, - { - "name": "Component-preload.js", - "module": "application/g/subcomponentB/Component-preload.js", - "size": 587, - "merged": true, - "included": [ - "application/g/subcomponentB/Component.js", - "application/g/subcomponentB/manifest.json" - ] - }, - { - "name": "Component.js", - "module": "application/g/subcomponentB/Component.js", - "size": 155, - "required": [ - "sap/ui/core/UIComponent.js" - ] - }, - { - "name": "manifest.json", - "module": "application/g/subcomponentB/manifest.json", - "size": 291 - }, - { - "name": "resources.json", - "size": 820 - } - ] -} \ No newline at end of file diff --git a/test/expected/build/application.h/dest/resources.json b/test/expected/build/application.h/dest/resources.json deleted file mode 100644 index db8db8421..000000000 --- a/test/expected/build/application.h/dest/resources.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "_version": "1.1.0", - "resources": [ - { - "name": "Component.js", - "module": "application/h/Component.js", - "size": 141, - "required": [ - "sap/ui/core/UIComponent.js" - ] - }, - { - "name": "manifest.json", - "module": "application/h/manifest.json", - "size": 278 - }, - { - "name": "resources.json", - "size": 1816 - }, - { - "name": "sectionsA/customBundle.js", - "module": "application/h/sectionsA/customBundle.js", - "size": 391, - "merged": true, - "included": [ - "application/h/sectionsA/section1.js", - "application/h/sectionsA/section3.js" - ] - }, - { - "name": "sectionsA/section1.js", - "module": "application/h/sectionsA/section1.js", - "size": 79, - "required": [ - "sap/m/Button.js" - ] - }, - { - "name": "sectionsA/section2.js", - "module": "application/h/sectionsA/section2.js", - "size": 79, - "required": [ - "sap/m/Button.js" - ] - }, - { - "name": "sectionsA/section3.js", - "module": "application/h/sectionsA/section3.js", - "size": 79, - "required": [ - "sap/m/Button.js" - ] - }, - { - "name": "sectionsB/customBundle.js", - "module": "application/h/sectionsB/customBundle.js", - "size": 524, - "merged": true, - "included": [ - "application/h/sectionsB/section1.js", - "application/h/sectionsB/section2.js", - "application/h/sectionsB/section3.js" - ] - }, - { - "name": "sectionsB/section1.js", - "module": "application/h/sectionsB/section1.js", - "size": 79, - "required": [ - "sap/m/Button.js" - ] - }, - { - "name": "sectionsB/section2.js", - "module": "application/h/sectionsB/section2.js", - "size": 79, - "required": [ - "sap/m/Button.js" - ] - }, - { - "name": "sectionsB/section3.js", - "module": "application/h/sectionsB/section3.js", - "size": 79, - "required": [ - "sap/m/Button.js" - ] - } - ] -} \ No newline at end of file diff --git a/test/expected/build/application.i/dest/resources.json b/test/expected/build/application.i/dest/resources.json deleted file mode 100644 index 083bcd52f..000000000 --- a/test/expected/build/application.i/dest/resources.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "_version": "1.1.0", - "resources": [ - { - "name": "Component-preload.js", - "module": "application/i/Component-preload.js", - "size": 1590, - "merged": true, - "included": [ - "application/i/Component.js", - "application/i/changes/changes-bundle.json", - "application/i/changes/coding/MyExtension.js", - "application/i/changes/fragments/MyFragment.fragment.xml", - "application/i/manifest.json" - ] - }, - { - "name": "Component.js", - "module": "application/i/Component.js", - "size": 141, - "required": [ - "sap/m/library.js", - "sap/ui/core/UIComponent.js", - "sap/ui/core/library.js", - "sap/ui/fl/library.js", - "sap/ui/layout/library.js" - ] - }, - { - "name": "changes/changes-bundle.json", - "module": "application/i/changes/changes-bundle.json", - "size": 749 - }, - { - "name": "changes/coding/MyExtension.js", - "module": "application/i/changes/coding/MyExtension.js", - "size": 39 - }, - { - "name": "changes/fragments/MyFragment.fragment.xml", - "module": "application/i/changes/fragments/MyFragment.fragment.xml", - "size": 13 - }, - { - "name": "changes/id_123_addField.change", - "size": 430 - }, - { - "name": "changes/id_456_addField.change", - "size": 430 - }, - { - "name": "manifest.json", - "module": "application/i/manifest.json", - "size": 369 - }, - { - "name": "resources.json", - "size": 1381 - } - ] -} \ No newline at end of file diff --git a/test/expected/build/application.j/dest-resources-json/Component-preload.js b/test/expected/build/application.j/dest-resources-json/Component-preload.js new file mode 100644 index 000000000..4e58fdf09 --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/Component-preload.js @@ -0,0 +1,12 @@ +//@ui5-bundle application/j/Component-preload.js +jQuery.sap.registerPreloadedModules({ +"version":"2.0", +"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/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":"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.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-resources-json/Component.js b/test/expected/build/application.j/dest-resources-json/Component.js new file mode 100644 index 000000000..984f96eaf --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/Component.js @@ -0,0 +1 @@ +sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.j.Component",{metadata:{manifest:"json"}})}); \ No newline at end of file diff --git a/test/expected/build/application.j/dest-resources-json/changes/coding/MyExtension.js b/test/expected/build/application.j/dest-resources-json/changes/coding/MyExtension.js new file mode 100644 index 000000000..b9e475d8e --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/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.j/dest-resources-json/changes/flexibility-bundle.json b/test/expected/build/application.j/dest-resources-json/changes/flexibility-bundle.json new file mode 100644 index 000000000..b3a5c5b1e --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/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":"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-resources-json/changes/fragments/MyFragment.fragment.xml b/test/expected/build/application.j/dest-resources-json/changes/fragments/MyFragment.fragment.xml new file mode 100644 index 000000000..39ce6859b --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/changes/fragments/MyFragment.fragment.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/test/expected/build/application.j/dest-resources-json/changes/id_111_appDescriptor.change b/test/expected/build/application.j/dest-resources-json/changes/id_111_appDescriptor.change new file mode 100644 index 000000000..9c7f911b9 --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/changes/id_111_appDescriptor.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-resources-json/changes/id_111_compVariants.variant b/test/expected/build/application.j/dest-resources-json/changes/id_111_compVariants.variant new file mode 100644 index 000000000..26431d338 --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/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/expected/build/application.j/dest-resources-json/changes/id_111_test.ctrl_variant b/test/expected/build/application.j/dest-resources-json/changes/id_111_test.ctrl_variant new file mode 100644 index 000000000..01d2bfb47 --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/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-resources-json/changes/id_111_test.ctrl_variant_change b/test/expected/build/application.j/dest-resources-json/changes/id_111_test.ctrl_variant_change new file mode 100644 index 000000000..8691c2e82 --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/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-resources-json/changes/id_111_test.ctrl_variant_management_change b/test/expected/build/application.j/dest-resources-json/changes/id_111_test.ctrl_variant_management_change new file mode 100644 index 000000000..1e1f585c8 --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/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-resources-json/changes/id_111_variantDependentControlChange.change b/test/expected/build/application.j/dest-resources-json/changes/id_111_variantDependentControlChange.change new file mode 100644 index 000000000..bd733b67e --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/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-resources-json/changes/id_123_addField.change b/test/expected/build/application.j/dest-resources-json/changes/id_123_addField.change new file mode 100644 index 000000000..41d9bb61c --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/changes/id_123_addField.change @@ -0,0 +1,20 @@ +{ + "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-resources-json/changes/id_456_addField.change b/test/expected/build/application.j/dest-resources-json/changes/id_456_addField.change new file mode 100644 index 000000000..4d4c73b51 --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/changes/id_456_addField.change @@ -0,0 +1,20 @@ +{ + "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" + } +} diff --git a/test/expected/build/application.j/dest-resources-json/manifest.json b/test/expected/build/application.j/dest-resources-json/manifest.json new file mode 100644 index 000000000..f82703903 --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/manifest.json @@ -0,0 +1,28 @@ +{ + "_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 + } + } + } + } +} \ No newline at end of file diff --git a/test/expected/build/application.j/dest/resources.json b/test/expected/build/application.j/dest-resources-json/resources.json similarity index 100% rename from test/expected/build/application.j/dest/resources.json rename to test/expected/build/application.j/dest-resources-json/resources.json diff --git a/test/expected/build/library.d/dest/resources/library/d/resources.json b/test/expected/build/library.d/dest/resources/library/d/resources.json deleted file mode 100644 index cca622ad3..000000000 --- a/test/expected/build/library.d/dest/resources/library/d/resources.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "_version": "1.1.0", - "resources": [ - { - "name": ".library", - "size": 273 - }, - { - "name": "manifest.json", - "module": "library/d/manifest.json", - "size": 491 - }, - { - "name": "resources.json", - "size": 458 - }, - { - "name": "some-dbg.js", - "module": "library/d/some.js", - "size": 142, - "format": "raw", - "isDebug": true - }, - { - "name": "some.js", - "module": "library/d/some.js", - "size": 86, - "format": "raw" - } - ] -} \ No newline at end of file diff --git a/test/expected/build/library.e/dest/resources/library/e/resources.json b/test/expected/build/library.e/dest/resources/library/e/resources.json deleted file mode 100644 index b20b1ba7f..000000000 --- a/test/expected/build/library.e/dest/resources/library/e/resources.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "_version": "1.1.0", - "resources": [ - { - "name": ".library", - "size": 426 - }, - { - "name": "library-dbg.js", - "module": "library/e/library.js", - "size": 212, - "format": "raw", - "isDebug": true - }, - { - "name": "library.js", - "module": "library/e/library.js", - "size": 211, - "format": "raw" - }, - { - "name": "manifest.json", - "module": "library/e/manifest.json", - "size": 443 - }, - { - "name": "resources.json", - "size": 695 - }, - { - "name": "some-dbg.js", - "module": "library/e/some.js", - "size": 211, - "format": "raw", - "isDebug": true - }, - { - "name": "some.js", - "module": "library/e/some.js", - "size": 211, - "format": "raw" - } - ] -} \ No newline at end of file diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/.library b/test/expected/build/library.h/dest-resources-json/resources/library/h/.library new file mode 100644 index 000000000..9084728e8 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/.library @@ -0,0 +1,19 @@ + + + + library.h + SAP SE + Some fancy copyright + 1.0.0 + + Library H + + + + + + + + + + diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/components/Component-preload.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/Component-preload.js new file mode 100644 index 000000000..f66daec7d --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/Component-preload.js @@ -0,0 +1,10 @@ +//@ui5-bundle library/h/components/Component-preload.js +sap.ui.require.preload({ + "library/h/components/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.Component",{})}); +}, + "library/h/components/TodoComponent.js":function(){/*! + * Some fancy copyright + */ +console.log(" File "); +} +}); diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/components/Component.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/Component.js new file mode 100644 index 000000000..422a97071 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/Component.js @@ -0,0 +1 @@ +sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.Component",{})}); \ No newline at end of file diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/components/TodoComponent.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/TodoComponent.js new file mode 100644 index 000000000..bcf866e67 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/TodoComponent.js @@ -0,0 +1,4 @@ +/*! + * Some fancy copyright + */ +console.log(" File "); \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/resources.json b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/resources.json similarity index 100% rename from test/expected/build/library.h/dest/resources/library/h/components/resources.json rename to test/expected/build/library.h/dest-resources-json/resources/library/h/components/resources.json diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent1/Component-preload.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent1/Component-preload.js new file mode 100644 index 000000000..d2309dcdf --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent1/Component-preload.js @@ -0,0 +1,5 @@ +//@ui5-bundle library/h/components/subcomponent1/Component-preload.js +sap.ui.require.preload({ + "library/h/components/subcomponent1/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.Component",{})}); +} +}); diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent1/Component.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent1/Component.js new file mode 100644 index 000000000..422a97071 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent1/Component.js @@ -0,0 +1 @@ +sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.Component",{})}); \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent1/resources.json similarity index 100% rename from test/expected/build/library.h/dest/resources/library/h/components/subcomponent1/resources.json rename to test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent1/resources.json diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent2/Component-preload.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent2/Component-preload.js new file mode 100644 index 000000000..ce88226b9 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent2/Component-preload.js @@ -0,0 +1,5 @@ +//@ui5-bundle library/h/components/subcomponent2/Component-preload.js +sap.ui.require.preload({ + "library/h/components/subcomponent2/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.Component",{})}); +} +}); diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent2/Component.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent2/Component.js new file mode 100644 index 000000000..422a97071 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent2/Component.js @@ -0,0 +1 @@ +sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.Component",{})}); \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent2/resources.json similarity index 100% rename from test/expected/build/library.h/dest/resources/library/h/components/subcomponent2/resources.json rename to test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent2/resources.json diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent3/Component-preload.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent3/Component-preload.js new file mode 100644 index 000000000..4b88fc476 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent3/Component-preload.js @@ -0,0 +1,5 @@ +//@ui5-bundle library/h/components/subcomponent3/Component-preload.js +sap.ui.require.preload({ + "library/h/components/subcomponent3/Component.js":function(){sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.Component",{})}); +} +}); diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent3/Component.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent3/Component.js new file mode 100644 index 000000000..422a97071 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent3/Component.js @@ -0,0 +1 @@ +sap.ui.define(["sap/ui/core/UIComponent"],function(n){"use strict";return n.extend("application.g.Component",{})}); \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json b/test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent3/resources.json similarity index 100% rename from test/expected/build/library.h/dest/resources/library/h/components/subcomponent3/resources.json rename to test/expected/build/library.h/dest-resources-json/resources/library/h/components/subcomponent3/resources.json diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/customBundle.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/customBundle.js new file mode 100644 index 000000000..5859d335b --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/customBundle.js @@ -0,0 +1,14 @@ +//@ui5-bundle library/h/customBundle.js +sap.ui.require.preload({ + "library/h/file.js":function(){/*! + * Some fancy copyright + */ +console.log(" File "); +}, + "library/h/library.js":function(){/*! + * Some fancy copyright + */ +console.log(" Library "); +}, + "library/h/some.js":'/*!\n * Some fancy copyright\n */\nvar myexport=function(){"use strict";String("asd")}();' +}); diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/library.designtime.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/library.designtime.js new file mode 100644 index 000000000..9b3a27111 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/library.designtime.js @@ -0,0 +1,4 @@ +/*! + * Some fancy copyright + */ +sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/messagebundle.properties b/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/messagebundle.properties new file mode 100644 index 000000000..1c6a1a9e8 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/messagebundle.properties @@ -0,0 +1 @@ +a=b \ No newline at end of file diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/messagebundle_en.properties b/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/messagebundle_en.properties new file mode 100644 index 000000000..1c6a1a9e8 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/messagebundle_en.properties @@ -0,0 +1 @@ +a=b \ No newline at end of file diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/file.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/file.js new file mode 100644 index 000000000..bcf866e67 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/file.js @@ -0,0 +1,4 @@ +/*! + * Some fancy copyright + */ +console.log(" File "); \ No newline at end of file diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/library.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/library.js new file mode 100644 index 000000000..6900e2218 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/library.js @@ -0,0 +1,4 @@ +/*! + * Some fancy copyright + */ +console.log(" Library "); \ No newline at end of file diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/manifest.json b/test/expected/build/library.h/dest-resources-json/resources/library/h/manifest.json new file mode 100644 index 000000000..2b6c457ad --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/manifest.json @@ -0,0 +1,39 @@ +{ + "_version": "1.9.0", + "sap.app": { + "id": "library.h", + "type": "library", + "embeds": [ + "components", + "components/subcomponent1", + "components/subcomponent2", + "components/subcomponent3" + ], + "applicationVersion": { + "version": "1.0.0" + }, + "title": "Library H", + "description": "Library H", + "resources": "resources.json", + "offline": true + }, + "sap.ui": { + "technology": "UI5", + "supportedThemes": [] + }, + "sap.ui5": { + "dependencies": { + "minUI5Version": "1.0", + "libs": {} + }, + "library": { + "i18n": false, + "content": { + "controls": [], + "elements": [], + "types": [], + "interfaces": [] + } + } + } +} \ No newline at end of file diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/not.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/not.js new file mode 100644 index 000000000..c249a10c8 --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/not.js @@ -0,0 +1,4 @@ +/*! + * Some fancy copyright + */ +console.log(" Not including "); \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/resources.json b/test/expected/build/library.h/dest-resources-json/resources/library/h/resources.json similarity index 100% rename from test/expected/build/library.h/dest/resources/library/h/resources.json rename to test/expected/build/library.h/dest-resources-json/resources/library/h/resources.json diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/some.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/some.js new file mode 100644 index 000000000..9b135171d --- /dev/null +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/some.js @@ -0,0 +1,4 @@ +/*! + * Some fancy copyright + */ +var myexport=function(){"use strict";String("asd")}(); \ No newline at end of file diff --git a/test/expected/build/library.h/dest-resources-json/test-resources/library/d/Test.html b/test/expected/build/library.h/dest-resources-json/test-resources/library/d/Test.html new file mode 100644 index 000000000..e69de29bb diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/.library b/test/expected/build/library.n/dest-resources-json/resources/library/n/.library new file mode 100644 index 000000000..bb3db51ef --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/.library @@ -0,0 +1,19 @@ + + + + library.n + SAP SE + UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + 1.0.0 + + Library N + + + + sap.ui.core + + + + diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js new file mode 100644 index 000000000..d2a3bd81c --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js @@ -0,0 +1,58 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ + +// Provides control library.N.Button. +sap.ui.define([ + './library', + 'sap/ui/core/Control' +], function( + library, + Control +) { + "use strict"; + + return Control.extend("library.n.Button", { + metadata : { + library : "library.n", + properties : { + text: {type: "string", group: "Misc", defaultValue: "" } + }, + aggregations: { + icon: {type: "sap.ui.core.Control", cardinality: "0..1" } + }, + events: { + press: {} + } + }, + designtime: "library/n/designtime/Button.designtime", + renderer: { + apiVersion: 2, + render: function(oRm, oButton) { + sap.ui.requireSync("./changeHandler/SplitButton"); + oRm.openStart("button", oButton); + oRm.class("libNBtnBase"); + oRm.openEnd(); + if ( oButton.getIcon() ) { + oRm.renderControl(oButton.getIcon()); + } + oRm.openStart("span", oButton.getId() + "-content"); + oRm.class("libNBtnContent"); + oRm.openEnd(); + oRm.text(sText); + oRm.close("span"); + oRm.close("button"); + } + }, + helper: function(sCalendarType) { + var sCalendar = "sap/ui/core/date/" + sCalendarType; + sap.ui.require(["sap/ui/core/format/DateFormat", sCalendar], function(DateFormat, Calendar) { + DateFormat.getInstance(); + new Calendar(); + }); + } + }); + +}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js new file mode 100644 index 000000000..5555f3917 --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define(["./library","sap/ui/core/Control"],function(e,t){"use strict";return t.extend("library.n.Button",{metadata:{library:"library.n",properties:{text:{type:"string",group:"Misc",defaultValue:""}},aggregations:{icon:{type:"sap.ui.core.Control",cardinality:"0..1"}},events:{press:{}}},designtime:"library/n/designtime/Button.designtime",renderer:{apiVersion:2,render:function(e,t){sap.ui.requireSync("./changeHandler/SplitButton");e.openStart("button",t);e.class("libNBtnBase");e.openEnd();if(t.getIcon()){e.renderControl(t.getIcon())}e.openStart("span",t.getId()+"-content");e.class("libNBtnContent");e.openEnd();e.text(sText);e.close("span");e.close("button")}},helper:function(e){var t="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",t],function(e,t){e.getInstance();new t})}})}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js new file mode 100644 index 000000000..08302deee --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js @@ -0,0 +1,29 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ + +sap.ui.define([ + "sap/ui/core/util/reflection/JsControlTreeModifier" +], function ( + JsControlTreeModifier +) { + "use strict"; + + var ButtonCH = {}; + + SplitButton.applyChange = function(oChange, oControl, mPropertyBag) { + if (mPropertyBag.modifier.targets !== "jsControlTree") { + throw new Error("SplitButton change can't be applied on XML tree"); + } + return true; + }; + + SplitButton.revertChange = function(oChange, oControl, mPropertyBag) { + oChange.resetRevertData(); + return true; + }; + + return ButtonCH; +}); diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js new file mode 100644 index 000000000..4ba21a98a --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define(["sap/ui/core/util/reflection/JsControlTreeModifier"],function(e){"use strict";var t={};SplitButton.applyChange=function(e,t,r){if(r.modifier.targets!=="jsControlTree"){throw new Error("SplitButton change can't be applied on XML tree")}return true};SplitButton.revertChange=function(e,t,r){e.resetRevertData();return true};return t}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js new file mode 100644 index 000000000..b4f1f4dc0 --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js @@ -0,0 +1,45 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ + +// Provides the Design Time Metadata for the library.n.Button control +sap.ui.define([], + function () { + "use strict"; + + return { + palette: { + group: "ACTION", + icons: { + svg: "library/n/designtime/Button.icon.svg" + } + }, + actions: { + combine: { + changeType: "combineButtons", + changeOnRelevantContainer : true, + isEnabled : true + }, + remove: { + changeType: "hideControl" + }, + split: { + changeType: "split" + }, + rename: { + changeType: "rename", + domRef: function (oControl) { + return oControl.$().find(".libNBtnContent")[0]; + } + }, + reveal: { + changeType: "unhideControl" + } + }, + templates: { + create: "library/n/designtime/Button.create.fragment.xml" + } + }; + }); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.create.fragment.xml b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.create.fragment.xml new file mode 100644 index 000000000..50988ae74 --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.create.fragment.xml @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js new file mode 100644 index 000000000..604978178 --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define([],function(){"use strict";return{palette:{group:"ACTION",icons:{svg:"library/n/designtime/Button.icon.svg"}},actions:{combine:{changeType:"combineButtons",changeOnRelevantContainer:true,isEnabled:true},remove:{changeType:"hideControl"},split:{changeType:"split"},rename:{changeType:"rename",domRef:function(e){return e.$().find(".libNBtnContent")[0]}},reveal:{changeType:"unhideControl"}},templates:{create:"library/n/designtime/Button.create.fragment.xml"}}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.icon.svg b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.icon.svg new file mode 100644 index 000000000..db8fc2011 --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.icon.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library-dbg.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library-dbg.designtime.js new file mode 100644 index 000000000..723a087bd --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library-dbg.designtime.js @@ -0,0 +1,10 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ + +sap.ui.define([], function() { + "use strict"; + return {}; +}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library.designtime.js new file mode 100644 index 000000000..2e8bb38c4 --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library.designtime.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js new file mode 100644 index 000000000..a22f5d6eb --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js @@ -0,0 +1,22 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ + +sap.ui.define([ + "sap/ui/fl/changeHandler/BaseRename", + "../changeHandler/SplitButton" +], function (BaseRename, SplitButton) { + "use strict"; + + return { + "hideControl": "default", + "split": SplitButton, + "rename": BaseRename.createRenameChangeHandler({ + propertyName: "text", + translationTextType: "XBUT" + }), + "unhideControl": "default" + }; +}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js new file mode 100644 index 000000000..91714752b --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define(["sap/ui/fl/changeHandler/BaseRename","../changeHandler/SplitButton"],function(e,n){"use strict";return{hideControl:"default",split:n,rename:e.createRenameChangeHandler({propertyName:"text",translationTextType:"XBUT"}),unhideControl:"default"}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js new file mode 100644 index 000000000..be08e1816 --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js @@ -0,0 +1,40 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ + +sap.ui.define([ + 'sap/ui/core/Core', + 'sap/ui/core/library', + 'sap/m/library' +], function( + Core, + coreLibrary, + mobileLibrary +) { + "use strict"; + + // delegate further initialization of this library to the Core + sap.ui.getCore().initLibrary({ + name : "library.n", + version: "1.0.0", + dependencies : ["sap.ui.core", "sap.m"], + designtime: "library/n/designtime/library.designtime", + types: [], + interfaces: [], + controls: [], + elements: [], + extensions: { + flChangeHandlers: { + "library.n.Button": "library/n/flexibility/Button" + }, + "sap.ui.support": { + publicRules:true, + internalRules:false + } + } + }); + + return sap.m; +}); diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js new file mode 100644 index 000000000..b5d45a041 --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js @@ -0,0 +1,23 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define([ + "sap/ui/support/library", + "./rules/Button.support" +], function( + SupportLib, + ButtonSupport, + ) { + "use strict"; + + return { + name: "library.n", + niceName: "Library N", + ruleset: [ + ButtonSupport + ] + }; + +}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js new file mode 100644 index 000000000..9bb8f0e2f --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define(["sap/ui/core/Core","sap/ui/core/library","sap/m/library"],function(e,i,r){"use strict";sap.ui.getCore().initLibrary({name:"library.n",version:"1.0.0",dependencies:["sap.ui.core","sap.m"],designtime:"library/n/designtime/library.designtime",types:[],interfaces:[],controls:[],elements:[],extensions:{flChangeHandlers:{"library.n.Button":"library/n/flexibility/Button"},"sap.ui.support":{publicRules:true,internalRules:false}}});return sap.m}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js new file mode 100644 index 000000000..aa01ff9b5 --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +sap.ui.define(["sap/ui/support/library","./rules/Button.support"],function(r,e){"use strict";return{name:"library.n",niceName:"Library N",ruleset:[e]}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/manifest.json b/test/expected/build/library.n/dest-resources-json/resources/library/n/manifest.json new file mode 100644 index 000000000..6cfe875b0 --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/manifest.json @@ -0,0 +1,38 @@ +{ + "_version": "1.9.0", + "sap.app": { + "id": "library.n", + "type": "library", + "embeds": [], + "applicationVersion": { + "version": "1.0.0" + }, + "title": "Library N", + "description": "Library N", + "resources": "resources.json", + "offline": true + }, + "sap.ui": { + "technology": "UI5", + "supportedThemes": [] + }, + "sap.ui5": { + "dependencies": { + "minUI5Version": "1.0", + "libs": { + "sap.ui.core": { + "minVersion": "1.0.0" + } + } + }, + "library": { + "i18n": "messagebundle.properties", + "content": { + "controls": [], + "elements": [], + "types": [], + "interfaces": [] + } + } + } +} \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle.properties b/test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle.properties new file mode 100644 index 000000000..2fb1d609b --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle.properties @@ -0,0 +1 @@ +PRESS=Click! diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle_de.properties b/test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle_de.properties new file mode 100644 index 000000000..985400feb --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle_de.properties @@ -0,0 +1 @@ +PRESS=Hier clicken! diff --git a/test/expected/build/library.n/dest/resources/library/n/resources.json b/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json similarity index 100% rename from test/expected/build/library.n/dest/resources/library/n/resources.json rename to test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button-dbg.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button-dbg.support.js new file mode 100644 index 000000000..dc9e1fc91 --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button-dbg.support.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +console.log('HelloWorld'); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button.support.js new file mode 100644 index 000000000..39e3277ce --- /dev/null +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button.support.js @@ -0,0 +1,6 @@ +/*! + * UI development toolkit for HTML5 (OpenUI5) + * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. + * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + */ +console.log("HelloWorld"); \ No newline at end of file diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 576fc0436..27db2e66d 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -361,9 +361,6 @@ test("Build application.g", (t) => { const expectedPath = path.join("test", "expected", "build", "application.g", "dest"); return builder.build({ - includedTasks: [ - "generateResourcesJson" - ], tree: applicationGTree, destPath, excludedTasks: ["generateStandaloneAppBundle", "generateVersionInfo"] @@ -384,9 +381,6 @@ test("Build application.g with component preload paths", (t) => { const expectedPath = path.join("test", "expected", "build", "application.g", "dest"); return builder.build({ - includedTasks: [ - "generateResourcesJson" - ], tree: applicationGTreeComponentPreloadPaths, destPath, excludedTasks: ["generateStandaloneAppBundle", "generateVersionInfo"] @@ -430,9 +424,6 @@ test("Build application.h", (t) => { return builder.build({ tree: applicationHTree, destPath, - includedTasks: [ - "generateResourcesJson" - ], excludedTasks: ["createDebugFiles", "generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo"] }).then(() => { @@ -452,9 +443,6 @@ test("Build application.i", (t) => { const expectedPath = path.join("test", "expected", "build", "application.i", "dest"); return builder.build({ - includedTasks: [ - "generateResourcesJson" - ], tree: applicationITree, destPath, excludedTasks: ["createDebugFiles", "generateStandaloneAppBundle", "generateVersionInfo"] @@ -474,10 +462,31 @@ test("Build application.j", (t) => { const destPath = "./test/tmp/build/application.j/dest"; const expectedPath = path.join("test", "expected", "build", "application.j", "dest"); + return builder.build({ + tree: applicationJTree, + 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(t, expectedFiles, expectedPath, destPath); + }).then(() => { + t.pass(); + }); +}); + +test("Build application.j with resources.json", (t) => { + const destPath = "./test/tmp/build/application.j/dest-resources-json"; + const expectedPath = path.join("test", "expected", "build", "application.j", "dest-resources-json"); + return builder.build({ includedTasks: [ "generateResourcesJson" - ], tree: applicationJTree, + ], + tree: applicationJTree, destPath, excludedTasks: ["createDebugFiles", "generateStandaloneAppBundle", "generateVersionInfo"] }).then(() => { @@ -497,9 +506,6 @@ test("Build library.d with copyright from .library file", (t) => { const expectedPath = path.join("test", "expected", "build", "library.d", "dest"); return builder.build({ - includedTasks: [ - "generateResourcesJson" - ], tree: libraryDTree, destPath, excludedTasks: ["generateLibraryPreload"] @@ -521,9 +527,6 @@ test("Build library.e with copyright from settings of ui5.yaml", (t) => { const expectedPath = path.join("test", "expected", "build", "library.e", "dest"); return builder.build({ - includedTasks: [ - "generateResourcesJson" - ], tree: libraryETree, destPath, excludedTasks: ["generateLibraryPreload"] @@ -544,6 +547,27 @@ test("Build library.h with custom bundles and component-preloads", (t) => { const destPath = path.join("test", "tmp", "build", "library.h", "dest"); const expectedPath = path.join("test", "expected", "build", "library.h", "dest"); + return builder.build({ + tree: libraryHTree, + destPath, + excludedTasks: ["createDebugFiles", "generateLibraryPreload"] + }).then(() => { + return findFiles(expectedPath); + }).then((expectedFiles) => { + // Check for all directories and files + assert.directoryDeepEqual(destPath, expectedPath); + + // Check for all file contents + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); + }).then(() => { + t.pass(); + }); +}); + +test("Build library.h with custom bundles and component-preloads with resources.json", (t) => { + const destPath = path.join("test", "tmp", "build", "library.h", "dest-resources-json"); + const expectedPath = path.join("test", "expected", "build", "library.h", "dest-resources-json"); + return builder.build({ includedTasks: [ "generateResourcesJson" @@ -636,6 +660,27 @@ test("Build library.n", (t) => { const destPath = path.join("test", "tmp", "build", "library.n", "dest"); const expectedPath = path.join("test", "expected", "build", "library.n", "dest"); + return builder.build({ + tree: libraryNTree, + destPath, + excludedTasks: ["generateLibraryPreload"] + }).then(() => { + return findFiles(expectedPath); + }).then((expectedFiles) => { + // Check for all directories and files + assert.directoryDeepEqual(destPath, expectedPath); + + // Check for all file contents + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); + }).then(() => { + t.pass(); + }); +}); + +test("Build library.n with resources.json", (t) => { + const destPath = path.join("test", "tmp", "build", "library.n", "dest-resources-json"); + const expectedPath = path.join("test", "expected", "build", "library.n", "dest-resources-json"); + return builder.build({ includedTasks: [ "generateResourcesJson" From eae29fcd90123d89e09065d2249dda6589a3c364 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 10 Aug 2020 15:11:58 +0200 Subject: [PATCH 57/88] removed generateResourcesJson task from excludes it not part of the default tasks anymore --- test/lib/builder/builder.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 27db2e66d..2a5228dcb 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -178,7 +178,7 @@ test("Build application.a", (t) => { return builder.build({ tree: applicationATree, destPath, - excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateResourcesJson"] + excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo"] }).then(() => { return findFiles(expectedPath); }).then((expectedFiles) => { @@ -208,7 +208,7 @@ test("Build application.a with dependencies", (t) => { return builder.build({ tree: applicationATree, destPath, - excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest", "generateResourcesJson"], + excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest"], buildDependencies: true }).then(() => { return findFiles(expectedPath); @@ -229,7 +229,7 @@ test("Build application.a with dependencies include", (t) => { return builder.build({ tree: applicationATree, destPath, - excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest", "generateResourcesJson"], + excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest"], buildDependencies: true, includedDependencies: ["*"] }).then(() => { return findFiles(expectedPath); @@ -250,7 +250,7 @@ test("Build application.a with dependencies exclude", (t) => { return builder.build({ tree: applicationATree, destPath, - excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest", "generateResourcesJson"], + excludedTasks: ["generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo", "generateLibraryPreload", "escapeNonAsciiCharacters", "generateLibraryManifest"], buildDependencies: true, excludedDependencies: ["library.d"] }).then(() => { return findFiles(expectedPath); @@ -271,7 +271,7 @@ test("Build application.a self-contained", (t) => { return builder.build({ tree: applicationATree, destPath, - excludedTasks: ["generateComponentPreload", "generateVersionInfo", "generateResourcesJson"], + excludedTasks: ["generateComponentPreload", "generateVersionInfo"], selfContained: true }).then(() => { return findFiles(expectedPath); @@ -292,7 +292,7 @@ test("Build application.a with dependencies self-contained", (t) => { return builder.build({ tree: applicationATree, destPath, - excludedTasks: ["generateComponentPreload", "generateVersionInfo", "escapeNonAsciiCharacters", "generateLibraryManifest", "generateResourcesJson"], + excludedTasks: ["generateComponentPreload", "generateVersionInfo", "escapeNonAsciiCharacters", "generateLibraryManifest"], buildDependencies: true, selfContained: true }).then(() => { From 132ef33f2201a22d11efad5dac7d5130c466ffa0 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 11 Aug 2020 08:15:36 +0200 Subject: [PATCH 58/88] created separate theme test for resources.json --- .../theme/j/themes/somefancytheme/Button.less | 3 +++ .../j/themes/somefancytheme/library-RTL.css | 3 +++ .../somefancytheme/library-parameters.json | 1 + .../theme/j/themes/somefancytheme/library.css | 3 +++ .../themes/somefancytheme/library.source.less | 2 ++ .../j/themes/somefancytheme/resources.json | 0 test/lib/builder/builder.js | 19 ++++++++++++++++++- 7 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/Button.less create mode 100644 test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library-RTL.css create mode 100644 test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library-parameters.json create mode 100644 test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library.css create mode 100644 test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library.source.less rename test/expected/build/theme.j/{dest => dest-resources-json}/resources/theme/j/themes/somefancytheme/resources.json (100%) diff --git a/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/Button.less b/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/Button.less new file mode 100644 index 000000000..ca968183f --- /dev/null +++ b/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/Button.less @@ -0,0 +1,3 @@ +.someClass { + color: @someColor +} diff --git a/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library-RTL.css b/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library-RTL.css new file mode 100644 index 000000000..5009ca50e --- /dev/null +++ b/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library-RTL.css @@ -0,0 +1,3 @@ +.someClass{color:#000} +/* Inline theming parameters */ +#sap-ui-theme-theme\.j{background-image:url('data:text/plain;utf-8,%7B%22someColor%22%3A%22%23000%22%7D')} diff --git a/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library-parameters.json b/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library-parameters.json new file mode 100644 index 000000000..a190cda03 --- /dev/null +++ b/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library-parameters.json @@ -0,0 +1 @@ +{"someColor":"#000"} \ No newline at end of file diff --git a/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library.css b/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library.css new file mode 100644 index 000000000..5009ca50e --- /dev/null +++ b/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library.css @@ -0,0 +1,3 @@ +.someClass{color:#000} +/* Inline theming parameters */ +#sap-ui-theme-theme\.j{background-image:url('data:text/plain;utf-8,%7B%22someColor%22%3A%22%23000%22%7D')} diff --git a/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library.source.less b/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library.source.less new file mode 100644 index 000000000..834de919e --- /dev/null +++ b/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/library.source.less @@ -0,0 +1,2 @@ +@someColor: black; +@import "Button.less"; diff --git a/test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json b/test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/resources.json similarity index 100% rename from test/expected/build/theme.j/dest/resources/theme/j/themes/somefancytheme/resources.json rename to test/expected/build/theme.j/dest-resources-json/resources/theme/j/themes/somefancytheme/resources.json diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 2a5228dcb..5c7a52477 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -637,6 +637,24 @@ test("Build library.j with JSDoc build only", (t) => { test("Build theme.j even without an library", (t) => { const destPath = "./test/tmp/build/theme.j/dest"; const expectedPath = "./test/expected/build/theme.j/dest"; + return builder.build({ + tree: themeJTree, + destPath + }).then(() => { + return findFiles(expectedPath); + }).then((expectedFiles) => { + // Check for all directories and files + assert.directoryDeepEqual(destPath, expectedPath); + + return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); + }).then(() => { + t.pass(); + }); +}); + +test("Build theme.j even without an library with resources.json", (t) => { + const destPath = "./test/tmp/build/theme.j/dest-resources-json"; + const expectedPath = "./test/expected/build/theme.j/dest-resources-json"; return builder.build({ includedTasks: [ "generateResourcesJson" @@ -649,7 +667,6 @@ test("Build theme.j even without an library", (t) => { // Check for all directories and files assert.directoryDeepEqual(destPath, expectedPath); - return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); }).then(() => { t.pass(); From b36f8f6b5fb1d8d1e7247bd725a7deb28b1648b0 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 11 Aug 2020 08:27:05 +0200 Subject: [PATCH 59/88] refactored code for eslint --- lib/tasks/generateResourcesJson.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index d51d82fd2..28302c0ce 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -3,9 +3,9 @@ // const log = require("@ui5/logger").getLogger("builder:tasks:generateResourcesJson"); const resourceListCreator = require("../processors/resourceListCreator"); -function getCreatorOptions(taskOptions) { +function getCreatorOptions(projectName) { const creatorOptions = {}; - if ( taskOptions.projectName === "sap.ui.core" ) { + if ( projectName === "sap.ui.core" ) { Object.assign(creatorOptions, { externalResources: { "sap/ui/core": [ @@ -38,17 +38,16 @@ function getCreatorOptions(taskOptions) { * @alias module:@ui5/builder.tasks.generateResourcesJson * @param {object} parameters Parameters * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files - * @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files * @param {object} parameters.options Options * @param {string} parameters.options.projectName Project name * @returns {Promise} Promise resolving with undefined once data has been written */ -module.exports = async function({workspace, dependencies, options}) { +module.exports = async function({workspace, options}) { const resources = await workspace.byGlob(["/resources/**/*.*"]); return resourceListCreator({ resources - }, getCreatorOptions(options)).then((resourceLists) => + }, getCreatorOptions(options.projectName)).then((resourceLists) => Promise.all( resourceLists.map((resourceList) => workspace.write(resourceList)) ) From 45aa4e47fda718a0c5f91e801f6b5000a07d5c47 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 11 Aug 2020 08:42:00 +0200 Subject: [PATCH 60/88] eslint fix: jsdoc/check-param-names rule --- lib/tasks/generateResourcesJson.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index 28302c0ce..b12bbaf02 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -38,8 +38,7 @@ function getCreatorOptions(projectName) { * @alias module:@ui5/builder.tasks.generateResourcesJson * @param {object} parameters Parameters * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files - * @param {object} parameters.options Options - * @param {string} parameters.options.projectName Project name + * @param {object} parameters.options Options with property projectName * @returns {Promise} Promise resolving with undefined once data has been written */ module.exports = async function({workspace, options}) { From d1adff85c8530689676a968a8bd56362da242681 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 11 Aug 2020 08:51:09 +0200 Subject: [PATCH 61/88] eslint fix: jsdoc/check-param-names rule --- lib/tasks/generateResourcesJson.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index b12bbaf02..cf12a1eec 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -38,15 +38,16 @@ function getCreatorOptions(projectName) { * @alias module:@ui5/builder.tasks.generateResourcesJson * @param {object} parameters Parameters * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files - * @param {object} parameters.options Options with property projectName + * @param {object} parameters.options Options + * @param {string} parameters.options.projectName Project name * @returns {Promise} Promise resolving with undefined once data has been written */ -module.exports = async function({workspace, options}) { +module.exports = async function({workspace, options: {projectName}}) { const resources = await workspace.byGlob(["/resources/**/*.*"]); return resourceListCreator({ resources - }, getCreatorOptions(options.projectName)).then((resourceLists) => + }, getCreatorOptions(projectName)).then((resourceLists) => Promise.all( resourceLists.map((resourceList) => workspace.write(resourceList)) ) From f1ac55ca70243c84e7804c5fd382c77b558fbe5d Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 11 Aug 2020 10:22:20 +0200 Subject: [PATCH 62/88] Added example to task code cleanup * ensure that async function resolves with undefined --- lib/tasks/generateResourcesJson.js | 53 ++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index cf12a1eec..63a324629 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -1,6 +1,5 @@ "use strict"; -// const log = require("@ui5/logger").getLogger("builder:tasks:generateResourcesJson"); const resourceListCreator = require("../processors/resourceListCreator"); function getCreatorOptions(projectName) { @@ -32,7 +31,48 @@ function getCreatorOptions(projectName) { } /** - * Task for creating a library resources.json, describing all productive resources in the library. + * Task for creating a resources.json file, describing all productive build resources. + * + * @example sample resources.json + * { + * "_version": "1.1.0", + * "resources": [ + * { + * "name": "Component-preload.js", + * "module": "application/mine/Component-preload.js", + * "size": 3746, + * "merged": true, + * "included": [ + * "application/mine/Component.js", + * "application/mine/changes/coding/MyExtension.js", + * "application/mine/changes/flexibility-bundle.json", + * "application/mine/changes/fragments/MyFragment.fragment.xml", + * "application/mine/manifest.json" + * ] + * }, + * { + * "name": "resources.json", + * "size": 1870 + * }, + * { + * "name": "rules/Button-dbg.support.js", + * "module": "application/mine/rules/Button.support.js", + * "size": 211, + * "format": "raw", + * "isDebug": true, + * "required": [ + * "application/mine/library.js", + * "sap/ui/core/Control.js" + * ], + * "condRequired": [ + * "application/mine/changeHandler/SplitButton.js", + * "sap/ui/core/format/DateFormat.js" + * ], + * "dynRequired": true, + * "support": true + * } + * ] + * } * * @public * @alias module:@ui5/builder.tasks.generateResourcesJson @@ -45,11 +85,10 @@ function getCreatorOptions(projectName) { module.exports = async function({workspace, options: {projectName}}) { const resources = await workspace.byGlob(["/resources/**/*.*"]); - return resourceListCreator({ + const resourceLists = await resourceListCreator({ resources - }, getCreatorOptions(projectName)).then((resourceLists) => - Promise.all( - resourceLists.map((resourceList) => workspace.write(resourceList)) - ) + }, getCreatorOptions(projectName)); + await Promise.all( + resourceLists.map((resourceList) => workspace.write(resourceList)) ); }; From ebb0acacba6d4235cdd9bf1828cc36068074fb30 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 11 Aug 2020 12:48:02 +0200 Subject: [PATCH 63/88] fix tests for return type remove resources.json from library.i --- .../dest/resources/library/i/resources.json | 26 ------------------- test/lib/builder/builder.js | 3 --- test/lib/tasks/generateResourcesJson.js | 2 +- 3 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 test/expected/build/library.i/dest/resources/library/i/resources.json diff --git a/test/expected/build/library.i/dest/resources/library/i/resources.json b/test/expected/build/library.i/dest/resources/library/i/resources.json deleted file mode 100644 index 415dfc571..000000000 --- a/test/expected/build/library.i/dest/resources/library/i/resources.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "_version": "1.1.0", - "resources": [ - { - "name": ".library", - "size": 1374 - }, - { - "name": "library.js", - "module": "library/i/library.js", - "size": 597, - "required": [ - "sap/ui/core/Core.js" - ] - }, - { - "name": "manifest.json", - "module": "library/i/manifest.json", - "size": 1740 - }, - { - "name": "resources.json", - "size": 372 - } - ] -} \ No newline at end of file diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 5c7a52477..0963906f3 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -593,9 +593,6 @@ test("Build library.i with manifest info taken from .library and library.js", (t const expectedPath = path.join("test", "expected", "build", "library.i", "dest"); return builder.build({ - includedTasks: [ - "generateResourcesJson" - ], tree: libraryITree, destPath, excludedTasks: ["createDebugFiles", "generateLibraryPreload", "uglify"] diff --git a/test/lib/tasks/generateResourcesJson.js b/test/lib/tasks/generateResourcesJson.js index 2a6d87ba2..d9fa6e4b9 100644 --- a/test/lib/tasks/generateResourcesJson.js +++ b/test/lib/tasks/generateResourcesJson.js @@ -41,7 +41,7 @@ test("empty resources", async (t) => { const generateResourcesJson = require("../../../lib/tasks/generateResourcesJson"); const result = await generateResourcesJson({workspace: createWorkspace(), dependencies: undefined, options: {projectName: "sap.ui.core"}}); - t.deepEqual(result, [], "empty resources"); + t.deepEqual(result, undefined, "no resources returned"); t.is(t.context.resourceListCreatorStub.callCount, 1); const expectedOptions = { externalResources: { From 46bce5ba575b3c403fd9c061ec42ce837a72bd74 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 11 Aug 2020 14:22:53 +0200 Subject: [PATCH 64/88] removed unnecessary duplicate test removed integration test for library preload with resources.json --- .../preload/resources/library/n/.library | 17 --- .../preload/resources/library/n/Button.js | 56 -------- .../library/n/changeHandler/SplitButton.js | 27 ---- .../n/designtime/Button.create.fragment.xml | 10 -- .../library/n/designtime/Button.designtime.js | 43 ------ .../library/n/designtime/Button.icon.svg | 26 ---- .../n/designtime/library.designtime.js | 8 -- .../n/flexibility/Button.flexibility.js | 20 --- .../resources/library/n/library-preload.js | 5 - .../preload/resources/library/n/library.js | 38 ----- .../resources/library/n/library.support.js | 21 --- .../library/n/messagebundle.properties | 1 - .../library/n/messagebundle_de.properties | 1 - .../resources/library/n/resources.json | 135 ------------------ .../library/n/rules/Button.support.js | 4 - .../generateLibraryPreload.integration.js | 58 -------- test/lib/tasks/generateCachebusterInfo.js | 4 +- 17 files changed, 2 insertions(+), 472 deletions(-) delete mode 100644 test/expected/build/library.n/preload/resources/library/n/.library delete mode 100644 test/expected/build/library.n/preload/resources/library/n/Button.js delete mode 100644 test/expected/build/library.n/preload/resources/library/n/changeHandler/SplitButton.js delete mode 100644 test/expected/build/library.n/preload/resources/library/n/designtime/Button.create.fragment.xml delete mode 100644 test/expected/build/library.n/preload/resources/library/n/designtime/Button.designtime.js delete mode 100644 test/expected/build/library.n/preload/resources/library/n/designtime/Button.icon.svg delete mode 100644 test/expected/build/library.n/preload/resources/library/n/designtime/library.designtime.js delete mode 100644 test/expected/build/library.n/preload/resources/library/n/flexibility/Button.flexibility.js delete mode 100644 test/expected/build/library.n/preload/resources/library/n/library-preload.js delete mode 100644 test/expected/build/library.n/preload/resources/library/n/library.js delete mode 100644 test/expected/build/library.n/preload/resources/library/n/library.support.js delete mode 100644 test/expected/build/library.n/preload/resources/library/n/messagebundle.properties delete mode 100644 test/expected/build/library.n/preload/resources/library/n/messagebundle_de.properties delete mode 100644 test/expected/build/library.n/preload/resources/library/n/resources.json delete mode 100644 test/expected/build/library.n/preload/resources/library/n/rules/Button.support.js diff --git a/test/expected/build/library.n/preload/resources/library/n/.library b/test/expected/build/library.n/preload/resources/library/n/.library deleted file mode 100644 index 02ec88b73..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/.library +++ /dev/null @@ -1,17 +0,0 @@ - - - - library.n - SAP SE - ${copyright} - ${version} - - Library N - - - - sap.ui.core - - - - diff --git a/test/expected/build/library.n/preload/resources/library/n/Button.js b/test/expected/build/library.n/preload/resources/library/n/Button.js deleted file mode 100644 index 5f4c66781..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/Button.js +++ /dev/null @@ -1,56 +0,0 @@ -/*! - * ${copyright} - */ - -// Provides control library.N.Button. -sap.ui.define([ - './library', - 'sap/ui/core/Control' -], function( - library, - Control -) { - "use strict"; - - return Control.extend("library.n.Button", { - metadata : { - library : "library.n", - properties : { - text: {type: "string", group: "Misc", defaultValue: "" } - }, - aggregations: { - icon: {type: "sap.ui.core.Control", cardinality: "0..1" } - }, - events: { - press: {} - } - }, - designtime: "library/n/designtime/Button.designtime", - renderer: { - apiVersion: 2, - render: function(oRm, oButton) { - sap.ui.requireSync("./changeHandler/SplitButton"); - oRm.openStart("button", oButton); - oRm.class("libNBtnBase"); - oRm.openEnd(); - if ( oButton.getIcon() ) { - oRm.renderControl(oButton.getIcon()); - } - oRm.openStart("span", oButton.getId() + "-content"); - oRm.class("libNBtnContent"); - oRm.openEnd(); - oRm.text(sText); - oRm.close("span"); - oRm.close("button"); - } - }, - helper: function(sCalendarType) { - var sCalendar = "sap/ui/core/date/" + sCalendarType; - sap.ui.require(["sap/ui/core/format/DateFormat", sCalendar], function(DateFormat, Calendar) { - DateFormat.getInstance(); - new Calendar(); - }); - } - }); - -}); \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/changeHandler/SplitButton.js b/test/expected/build/library.n/preload/resources/library/n/changeHandler/SplitButton.js deleted file mode 100644 index f42a60c9e..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/changeHandler/SplitButton.js +++ /dev/null @@ -1,27 +0,0 @@ -/*! - * ${copyright} - */ - -sap.ui.define([ - "sap/ui/core/util/reflection/JsControlTreeModifier" -], function ( - JsControlTreeModifier -) { - "use strict"; - - var ButtonCH = {}; - - SplitButton.applyChange = function(oChange, oControl, mPropertyBag) { - if (mPropertyBag.modifier.targets !== "jsControlTree") { - throw new Error("SplitButton change can't be applied on XML tree"); - } - return true; - }; - - SplitButton.revertChange = function(oChange, oControl, mPropertyBag) { - oChange.resetRevertData(); - return true; - }; - - return ButtonCH; -}); diff --git a/test/expected/build/library.n/preload/resources/library/n/designtime/Button.create.fragment.xml b/test/expected/build/library.n/preload/resources/library/n/designtime/Button.create.fragment.xml deleted file mode 100644 index 50988ae74..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/designtime/Button.create.fragment.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/designtime/Button.designtime.js b/test/expected/build/library.n/preload/resources/library/n/designtime/Button.designtime.js deleted file mode 100644 index d6d669833..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/designtime/Button.designtime.js +++ /dev/null @@ -1,43 +0,0 @@ -/*! - * ${copyright} - */ - -// Provides the Design Time Metadata for the library.n.Button control -sap.ui.define([], - function () { - "use strict"; - - return { - palette: { - group: "ACTION", - icons: { - svg: "library/n/designtime/Button.icon.svg" - } - }, - actions: { - combine: { - changeType: "combineButtons", - changeOnRelevantContainer : true, - isEnabled : true - }, - remove: { - changeType: "hideControl" - }, - split: { - changeType: "split" - }, - rename: { - changeType: "rename", - domRef: function (oControl) { - return oControl.$().find(".libNBtnContent")[0]; - } - }, - reveal: { - changeType: "unhideControl" - } - }, - templates: { - create: "library/n/designtime/Button.create.fragment.xml" - } - }; - }); \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/designtime/Button.icon.svg b/test/expected/build/library.n/preload/resources/library/n/designtime/Button.icon.svg deleted file mode 100644 index db8fc2011..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/designtime/Button.icon.svg +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/test/expected/build/library.n/preload/resources/library/n/designtime/library.designtime.js b/test/expected/build/library.n/preload/resources/library/n/designtime/library.designtime.js deleted file mode 100644 index 6c8c315f3..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/designtime/library.designtime.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! - * ${copyright} - */ - -sap.ui.define([], function() { - "use strict"; - return {}; -}); \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/flexibility/Button.flexibility.js b/test/expected/build/library.n/preload/resources/library/n/flexibility/Button.flexibility.js deleted file mode 100644 index bbce17aea..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/flexibility/Button.flexibility.js +++ /dev/null @@ -1,20 +0,0 @@ -/*! - * ${copyright} - */ - -sap.ui.define([ - "sap/ui/fl/changeHandler/BaseRename", - "../changeHandler/SplitButton" -], function (BaseRename, SplitButton) { - "use strict"; - - return { - "hideControl": "default", - "split": SplitButton, - "rename": BaseRename.createRenameChangeHandler({ - propertyName: "text", - translationTextType: "XBUT" - }), - "unhideControl": "default" - }; -}); \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/library-preload.js b/test/expected/build/library.n/preload/resources/library/n/library-preload.js deleted file mode 100644 index dec5578e2..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/library-preload.js +++ /dev/null @@ -1,5 +0,0 @@ -//@ui5-bundle library/n/library-preload.js -sap.ui.predefine("library/n/Button",["./library","sap/ui/core/Control"],function(e,t){"use strict";return t.extend("library.n.Button",{metadata:{library:"library.n",properties:{text:{type:"string",group:"Misc",defaultValue:""}},aggregations:{icon:{type:"sap.ui.core.Control",cardinality:"0..1"}},events:{press:{}}},designtime:"library/n/designtime/Button.designtime",renderer:{apiVersion:2,render:function(e,t){sap.ui.requireSync("./changeHandler/SplitButton");e.openStart("button",t);e.class("libNBtnBase");e.openEnd();if(t.getIcon()){e.renderControl(t.getIcon())}e.openStart("span",t.getId()+"-content");e.class("libNBtnContent");e.openEnd();e.text(sText);e.close("span");e.close("button")}},helper:function(e){var t="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",t],function(e,t){e.getInstance();new t})}})}); -sap.ui.predefine("library/n/changeHandler/SplitButton",["sap/ui/core/util/reflection/JsControlTreeModifier"],function(e){"use strict";var t={};SplitButton.applyChange=function(e,t,r){if(r.modifier.targets!=="jsControlTree"){throw new Error("SplitButton change can't be applied on XML tree")}return true};SplitButton.revertChange=function(e,t,r){e.resetRevertData();return true};return t}); -sap.ui.predefine("library/n/flexibility/Button.flexibility",["sap/ui/fl/changeHandler/BaseRename","../changeHandler/SplitButton"],function(e,t){"use strict";return{hideControl:"default",split:t,rename:e.createRenameChangeHandler({propertyName:"text",translationTextType:"XBUT"}),unhideControl:"default"}}); -sap.ui.predefine("library/n/library",["sap/ui/core/Core","sap/ui/core/library","sap/m/library"],function(e,i,r){"use strict";sap.ui.getCore().initLibrary({name:"library.n",version:"${version}",dependencies:["sap.ui.core","sap.m"],designtime:"library/n/designtime/library.designtime",types:[],interfaces:[],controls:[],elements:[],extensions:{flChangeHandlers:{"library.n.Button":"library/n/flexibility/Button"},"sap.ui.support":{publicRules:true,internalRules:false}}});return sap.m}); diff --git a/test/expected/build/library.n/preload/resources/library/n/library.js b/test/expected/build/library.n/preload/resources/library/n/library.js deleted file mode 100644 index 292583ba1..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/library.js +++ /dev/null @@ -1,38 +0,0 @@ -/*! - * ${copyright} - */ - -sap.ui.define([ - 'sap/ui/core/Core', - 'sap/ui/core/library', - 'sap/m/library' -], function( - Core, - coreLibrary, - mobileLibrary -) { - "use strict"; - - // delegate further initialization of this library to the Core - sap.ui.getCore().initLibrary({ - name : "library.n", - version: "${version}", - dependencies : ["sap.ui.core", "sap.m"], - designtime: "library/n/designtime/library.designtime", - types: [], - interfaces: [], - controls: [], - elements: [], - extensions: { - flChangeHandlers: { - "library.n.Button": "library/n/flexibility/Button" - }, - "sap.ui.support": { - publicRules:true, - internalRules:false - } - } - }); - - return sap.m; -}); diff --git a/test/expected/build/library.n/preload/resources/library/n/library.support.js b/test/expected/build/library.n/preload/resources/library/n/library.support.js deleted file mode 100644 index 634d4fa8f..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/library.support.js +++ /dev/null @@ -1,21 +0,0 @@ -/*! - * ${copyright} - */ -sap.ui.define([ - "sap/ui/support/library", - "./rules/Button.support" -], function( - SupportLib, - ButtonSupport, - ) { - "use strict"; - - return { - name: "library.n", - niceName: "Library N", - ruleset: [ - ButtonSupport - ] - }; - -}); \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/messagebundle.properties b/test/expected/build/library.n/preload/resources/library/n/messagebundle.properties deleted file mode 100644 index 2fb1d609b..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/messagebundle.properties +++ /dev/null @@ -1 +0,0 @@ -PRESS=Click! diff --git a/test/expected/build/library.n/preload/resources/library/n/messagebundle_de.properties b/test/expected/build/library.n/preload/resources/library/n/messagebundle_de.properties deleted file mode 100644 index 985400feb..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/messagebundle_de.properties +++ /dev/null @@ -1 +0,0 @@ -PRESS=Hier clicken! diff --git a/test/expected/build/library.n/preload/resources/library/n/resources.json b/test/expected/build/library.n/preload/resources/library/n/resources.json deleted file mode 100644 index f53fe5ec9..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/resources.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "_version": "1.1.0", - "resources": [ - { - "name": ".library", - "size": 404 - }, - { - "name": "Button.js", - "module": "library/n/Button.js", - "size": 1256, - "required": [ - "library/n/library.js", - "sap/ui/core/Control.js" - ], - "condRequired": [ - "library/n/changeHandler/SplitButton.js", - "sap/ui/core/format/DateFormat.js" - ], - "dynRequired": true - }, - { - "name": "changeHandler/SplitButton.js", - "module": "library/n/changeHandler/SplitButton.js", - "size": 540, - "required": [ - "sap/ui/core/util/reflection/JsControlTreeModifier.js" - ] - }, - { - "name": "designtime/Button.create.fragment.xml", - "module": "library/n/designtime/Button.create.fragment.xml", - "size": 172, - "designtime": true, - "required": [ - "library/n/Button.js" - ] - }, - { - "name": "designtime/Button.designtime.js", - "module": "library/n/designtime/Button.designtime.js", - "size": 789, - "designtime": true - }, - { - "name": "designtime/Button.icon.svg", - "size": 1386, - "designtime": true - }, - { - "name": "designtime/library.designtime.js", - "module": "library/n/designtime/library.designtime.js", - "size": 86, - "designtime": true - }, - { - "name": "flexibility/Button.flexibility.js", - "module": "library/n/flexibility/Button.flexibility.js", - "size": 379, - "required": [ - "library/n/changeHandler/SplitButton.js", - "sap/ui/fl/changeHandler/BaseRename.js" - ] - }, - { - "name": "library-preload.js", - "module": "library/n/library-preload.js", - "size": 2062, - "merged": true, - "required": [ - "sap/m/library.js", - "sap/ui/core/Control.js", - "sap/ui/core/Core.js", - "sap/ui/core/library.js", - "sap/ui/core/util/reflection/JsControlTreeModifier.js", - "sap/ui/fl/changeHandler/BaseRename.js" - ], - "condRequired": [ - "sap/ui/core/format/DateFormat.js" - ], - "dynRequired": true, - "included": [ - "library/n/Button.js", - "library/n/changeHandler/SplitButton.js", - "library/n/flexibility/Button.flexibility.js", - "library/n/library.js" - ] - }, - { - "name": "library.js", - "module": "library/n/library.js", - "size": 681, - "required": [ - "sap/m/library.js", - "sap/ui/core/Core.js", - "sap/ui/core/library.js" - ] - }, - { - "name": "library.support.js", - "module": "library/n/library.support.js", - "size": 256, - "support": true, - "required": [ - "library/n/rules/Button.support.js", - "sap/ui/support/library.js" - ] - }, - { - "name": "messagebundle.properties", - "module": "library/n/messagebundle.properties", - "size": 13, - "locale": "", - "raw": "messagebundle.properties" - }, - { - "name": "messagebundle_de.properties", - "module": "library/n/messagebundle_de.properties", - "size": 20, - "locale": "de", - "raw": "messagebundle.properties" - }, - { - "name": "resources.json", - "size": 3024 - }, - { - "name": "rules/Button.support.js", - "module": "library/n/rules/Button.support.js", - "size": 50, - "format": "raw", - "support": true - } - ] -} \ No newline at end of file diff --git a/test/expected/build/library.n/preload/resources/library/n/rules/Button.support.js b/test/expected/build/library.n/preload/resources/library/n/rules/Button.support.js deleted file mode 100644 index 81e734360..000000000 --- a/test/expected/build/library.n/preload/resources/library/n/rules/Button.support.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * ${copyright} - */ -console.log('HelloWorld'); \ No newline at end of file diff --git a/test/lib/tasks/bundlers/generateLibraryPreload.integration.js b/test/lib/tasks/bundlers/generateLibraryPreload.integration.js index 9d1eac662..11790e88d 100644 --- a/test/lib/tasks/bundlers/generateLibraryPreload.integration.js +++ b/test/lib/tasks/bundlers/generateLibraryPreload.integration.js @@ -8,7 +8,6 @@ const assert = chai.assert; const ui5Builder = require("../../../../"); const builder = ui5Builder.builder; const libraryDPath = path.join(__dirname, "..", "..", "..", "fixtures", "library.d"); -const libraryNPath = path.join(__dirname, "..", "..", "..", "fixtures", "library.n"); const sapUiCorePath = path.join(__dirname, "..", "..", "..", "fixtures", "sap.ui.core"); const recursive = require("recursive-readdir"); @@ -130,60 +129,3 @@ const sapUiCoreTree = { } } }; - -test("integration: build library.n with library preload", (t) => { - const destPath = "./test/tmp/build/library.n/preload"; - const expectedPath = "./test/expected/build/library.n/preload"; - const excludedTasks = ["*"]; - const includedTasks = ["generateLibraryPreload", "generateResourcesJson"]; - - return builder.build({ - tree: libraryNTree, - destPath, - excludedTasks, - includedTasks - }).then(() => { - return findFiles(expectedPath); - }).then((expectedFiles) => { - // Check for all directories and files - assert.directoryDeepEqual(destPath, expectedPath); - - // Check for all file contents - t.deepEqual(expectedFiles.length, 15, "15 files are expected"); - expectedFiles.forEach((expectedFile) => { - const relativeFile = path.relative(expectedPath, expectedFile); - const destFile = path.join(destPath, relativeFile); - assert.fileEqual(destFile, expectedFile); - }); - }).then(() => { - t.pass(); - }); -}); - -const libraryNTree = { - "id": "library.n", - "version": "1.0.0", - "path": libraryNPath, - "dependencies": [], - "_level": 0, - "specVersion": "0.1", - "type": "library", - "metadata": { - "name": "library.n", - "namespace": "library/n", - "copyright": "UI development toolkit for HTML5 (OpenUI5)\n * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.\n * Licensed under the Apache License, Version 2.0 - see LICENSE.txt." - }, - "resources": { - "configuration": { - "paths": { - "src": "src", - "test": "test" - }, - "propertiesFileSourceEncoding": "ISO-8859-1" - }, - "pathMappings": { - "/resources/": "src", - "/test-resources/": "test" - } - } -}; diff --git a/test/lib/tasks/generateCachebusterInfo.js b/test/lib/tasks/generateCachebusterInfo.js index c114da53a..ec9d52b7c 100644 --- a/test/lib/tasks/generateCachebusterInfo.js +++ b/test/lib/tasks/generateCachebusterInfo.js @@ -27,7 +27,7 @@ const findFiles = (folder) => { test("integration: Build application.g with manifestBundler", (t) => { const destPath = path.join("test", "tmp", "build", "application.g", "cachebuster"); const expectedPath = path.join("test", "expected", "build", "application.g", "cachebuster"); - const excludedTasks = ["escapeNonAsciiCharacters", "generateVersionInfo", "generateResourcesJson"]; + const excludedTasks = ["escapeNonAsciiCharacters", "generateVersionInfo"]; const includedTasks = ["generateCachebusterInfo"]; return builder.build({ @@ -60,7 +60,7 @@ test("integration: Build application.g with manifestBundler", (t) => { test("integration: Build application.g with manifestBundler and cachebuster using hashes", (t) => { const destPath = path.join("test", "tmp", "build", "application.g", "cachebuster_hash"); const expectedPath = path.join("test", "expected", "build", "application.g", "cachebuster"); - const excludedTasks = ["escapeNonAsciiCharacters", "generateVersionInfo", "generateResourcesJson"]; + const excludedTasks = ["escapeNonAsciiCharacters", "generateVersionInfo"]; const includedTasks = ["generateCachebusterInfo"]; return builder.build({ From e9fc145747734ff42f5dbe094bb16201ae2962ce Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 11 Aug 2020 14:36:27 +0200 Subject: [PATCH 65/88] removed unnecessary duplicate test removed integration test for collection with resources.json --- .../dest/resources/library/a/.library | 17 ---- .../dest/resources/library/a/manifest.json | 34 -------- .../dest/resources/library/a/resources.json | 40 ---------- .../library/a/themes/base/library-RTL.css | 3 - .../a/themes/base/library-parameters.json | 1 - .../library/a/themes/base/library.css | 3 - .../library/a/themes/base/library.source.less | 6 -- .../library/a/themes/base/resources.json | 31 ------- .../dest/test-resources/library/a/Test.html | 0 test/lib/builder/builder.js | 80 ------------------- 10 files changed, 215 deletions(-) delete mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/.library delete mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/manifest.json delete mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/resources.json delete mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library-RTL.css delete mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library-parameters.json delete mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library.css delete mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library.source.less delete mode 100644 test/expected/build/collection/library.a/dest/resources/library/a/themes/base/resources.json delete mode 100644 test/expected/build/collection/library.a/dest/test-resources/library/a/Test.html diff --git a/test/expected/build/collection/library.a/dest/resources/library/a/.library b/test/expected/build/collection/library.a/dest/resources/library/a/.library deleted file mode 100644 index cddfadd9a..000000000 --- a/test/expected/build/collection/library.a/dest/resources/library/a/.library +++ /dev/null @@ -1,17 +0,0 @@ - - - - library.a - SAP SE - Some fancy copyright ${currentYear} - 1.0.0 - - Library A - - - - library.d - - - - diff --git a/test/expected/build/collection/library.a/dest/resources/library/a/manifest.json b/test/expected/build/collection/library.a/dest/resources/library/a/manifest.json deleted file mode 100644 index 935e866ce..000000000 --- a/test/expected/build/collection/library.a/dest/resources/library/a/manifest.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "_version": "1.9.0", - "sap.app": { - "id": "library.a", - "type": "library", - "embeds": [], - "applicationVersion": { - "version": "1.0.0" - }, - "title": "Library A", - "description": "Library A", - "resources": "resources.json", - "offline": true - }, - "sap.ui": { - "technology": "UI5", - "supportedThemes": [ - "base" - ] - }, - "sap.ui5": { - "dependencies": { - "minUI5Version": "1.0", - "libs": { - "library.d": { - "minVersion": "1.0.0" - } - } - }, - "library": { - "i18n": false - } - } -} \ No newline at end of file diff --git a/test/expected/build/collection/library.a/dest/resources/library/a/resources.json b/test/expected/build/collection/library.a/dest/resources/library/a/resources.json deleted file mode 100644 index 63084c02c..000000000 --- a/test/expected/build/collection/library.a/dest/resources/library/a/resources.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "_version": "1.1.0", - "resources": [ - { - "name": ".library", - "size": 393 - }, - { - "name": "manifest.json", - "module": "library/a/manifest.json", - "size": 581 - }, - { - "name": "resources.json", - "size": 671 - }, - { - "name": "themes/base/library-RTL.css", - "size": 203, - "theme": "base" - }, - { - "name": "themes/base/library-parameters.json", - "module": "library/a/themes/base/library-parameters.json", - "size": 28, - "theme": "base" - }, - { - "name": "themes/base/library.css", - "size": 203, - "theme": "base" - }, - { - "name": "themes/base/library.source.less", - "size": 111, - "designtime": true, - "theme": "base" - } - ] -} \ No newline at end of file diff --git a/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library-RTL.css b/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library-RTL.css deleted file mode 100644 index 5398b3f08..000000000 --- a/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library-RTL.css +++ /dev/null @@ -1,3 +0,0 @@ -.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/collection/library.a/dest/resources/library/a/themes/base/library-parameters.json b/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library-parameters.json deleted file mode 100644 index da3b7a52f..000000000 --- a/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library-parameters.json +++ /dev/null @@ -1 +0,0 @@ -{"libraryAColor1":"#fafad2"} \ No newline at end of file diff --git a/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library.css b/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library.css deleted file mode 100644 index ba056b3c0..000000000 --- a/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library.css +++ /dev/null @@ -1,3 +0,0 @@ -.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/collection/library.a/dest/resources/library/a/themes/base/library.source.less b/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library.source.less deleted file mode 100644 index ff0f1d5e3..000000000 --- a/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/library.source.less +++ /dev/null @@ -1,6 +0,0 @@ -@libraryAColor1: lightgoldenrodyellow; - -.library-a-foo { - color: @libraryAColor1; - padding: 1px 2px 3px 4px; -} diff --git a/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/resources.json b/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/resources.json deleted file mode 100644 index ab347b8a7..000000000 --- a/test/expected/build/collection/library.a/dest/resources/library/a/themes/base/resources.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "_version": "1.1.0", - "resources": [ - { - "name": "library-RTL.css", - "size": 203, - "theme": "base" - }, - { - "name": "library-parameters.json", - "module": "library/a/themes/base/library-parameters.json", - "size": 28, - "theme": "base" - }, - { - "name": "library.css", - "size": 203, - "theme": "base" - }, - { - "name": "library.source.less", - "size": 111, - "designtime": true, - "theme": "base" - }, - { - "name": "resources.json", - "size": 484 - } - ] -} \ No newline at end of file diff --git a/test/expected/build/collection/library.a/dest/test-resources/library/a/Test.html b/test/expected/build/collection/library.a/dest/test-resources/library/a/Test.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 0963906f3..d9ad99998 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -715,31 +715,6 @@ test("Build library.n with resources.json", (t) => { }); }); -test("Build collection library.a", (t) => { - const destPath = path.join("test", "tmp", "build", "collection", "library.a", "dest"); - const expectedPath = path.join("test", "expected", "build", "collection", "library.a", "dest"); - - return builder.build({ - includedTasks: [ - "generateResourcesJson" - ], - tree: collectionLibraryATree, - destPath, - excludedTasks: ["generateLibraryPreload"] - }).then(() => { - return findFiles(expectedPath); - }).then((expectedFiles) => { - // Check for all directories and files - assert.directoryDeepEqual(destPath, expectedPath); - - // Check for all file contents - return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); - }).then(() => { - t.pass(); - }); -}); - - test.serial("Cleanup", async (t) => { const BuildContext = require("../../../lib/builder/BuildContext"); const createProjectContextStub = sinon.spy(BuildContext.prototype, "createProjectContext"); @@ -1506,58 +1481,3 @@ const libraryNTree = { } } }; - -const collectionLibraryATree = { - "id": "library.a", - "version": "1.0.0", - "path": path.join(collectionPath, "library.a"), - "dependencies": [ - libraryDTree, - { - "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": 1, - "specVersion": "0.1", - "type": "library", - "metadata": { - "name": "library.a", - "namespace": "library/a", - "copyright": "${copyright}" - }, - "resources": { - "configuration": { - "paths": { - "src": "src", - "test": "test" - }, - "propertiesFileSourceEncoding": "ISO-8859-1" - }, - "pathMappings": { - "/resources/": "src", - "/test-resources/": "test" - } - } -}; - From 7ad646b80d0c7393b616900ad94e5adfa7328467 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 11 Aug 2020 16:12:42 +0200 Subject: [PATCH 66/88] fixed tests --- .../changes/id_111_appDescriptor.change | 21 ------------------- .../changes/id_111_compVariants.variant | 21 ------------------- .../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 ------------------- .../changes/id_123_addField.change | 20 ------------------ .../changes/id_456_addField.change | 20 ------------------ .../types/themeLibrary/ThemeLibraryBuilder.js | 5 +++++ 9 files changed, 5 insertions(+), 163 deletions(-) delete mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_111_appDescriptor.change delete mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_111_compVariants.variant delete mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_111_test.ctrl_variant delete mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_111_test.ctrl_variant_change delete mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_111_test.ctrl_variant_management_change delete mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_111_variantDependentControlChange.change delete mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_123_addField.change delete mode 100644 test/expected/build/application.j/dest-resources-json/changes/id_456_addField.change diff --git a/test/expected/build/application.j/dest-resources-json/changes/id_111_appDescriptor.change b/test/expected/build/application.j/dest-resources-json/changes/id_111_appDescriptor.change deleted file mode 100644 index 9c7f911b9..000000000 --- a/test/expected/build/application.j/dest-resources-json/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-resources-json/changes/id_111_compVariants.variant b/test/expected/build/application.j/dest-resources-json/changes/id_111_compVariants.variant deleted file mode 100644 index 26431d338..000000000 --- a/test/expected/build/application.j/dest-resources-json/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-resources-json/changes/id_111_test.ctrl_variant b/test/expected/build/application.j/dest-resources-json/changes/id_111_test.ctrl_variant deleted file mode 100644 index 01d2bfb47..000000000 --- a/test/expected/build/application.j/dest-resources-json/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-resources-json/changes/id_111_test.ctrl_variant_change b/test/expected/build/application.j/dest-resources-json/changes/id_111_test.ctrl_variant_change deleted file mode 100644 index 8691c2e82..000000000 --- a/test/expected/build/application.j/dest-resources-json/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-resources-json/changes/id_111_test.ctrl_variant_management_change b/test/expected/build/application.j/dest-resources-json/changes/id_111_test.ctrl_variant_management_change deleted file mode 100644 index 1e1f585c8..000000000 --- a/test/expected/build/application.j/dest-resources-json/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-resources-json/changes/id_111_variantDependentControlChange.change b/test/expected/build/application.j/dest-resources-json/changes/id_111_variantDependentControlChange.change deleted file mode 100644 index bd733b67e..000000000 --- a/test/expected/build/application.j/dest-resources-json/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-resources-json/changes/id_123_addField.change b/test/expected/build/application.j/dest-resources-json/changes/id_123_addField.change deleted file mode 100644 index 41d9bb61c..000000000 --- a/test/expected/build/application.j/dest-resources-json/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-resources-json/changes/id_456_addField.change b/test/expected/build/application.j/dest-resources-json/changes/id_456_addField.change deleted file mode 100644 index 4d4c73b51..000000000 --- a/test/expected/build/application.j/dest-resources-json/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" - } -} diff --git a/test/lib/types/themeLibrary/ThemeLibraryBuilder.js b/test/lib/types/themeLibrary/ThemeLibraryBuilder.js index 6b55e3c86..261623d7d 100644 --- a/test/lib/types/themeLibrary/ThemeLibraryBuilder.js +++ b/test/lib/types/themeLibrary/ThemeLibraryBuilder.js @@ -31,6 +31,11 @@ test("tasks", async (t) => { } }; } + }, + taskUtil: { + isRootProject: () => { + return true; + } } }); const asyncTasks = Object.keys(themeLibraryBuilder.tasks).map((taskKey) => { From 4e8c8761738b1f667e6817f2aefccbdabdbff98c Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 11 Aug 2020 16:27:32 +0200 Subject: [PATCH 67/88] Add ModuleInfo tests --- test/lib/lbt/resources/ModuleInfo.js | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/lib/lbt/resources/ModuleInfo.js diff --git a/test/lib/lbt/resources/ModuleInfo.js b/test/lib/lbt/resources/ModuleInfo.js new file mode 100644 index 000000000..272572f0b --- /dev/null +++ b/test/lib/lbt/resources/ModuleInfo.js @@ -0,0 +1,31 @@ +const test = require("ava"); + +const ModuleInfo = require("../../../../lib/lbt/resources/ModuleInfo"); + +test("ModuleInfo: constructor", async (t) => { + const moduleInfo = new ModuleInfo("myName"); + t.falsy(moduleInfo.exposedGlobals, "exposedGlobals is not set"); + t.falsy(moduleInfo.format, "format is not set"); + t.falsy(moduleInfo.description, "description is not set"); + t.false(moduleInfo.requiresTopLevelScope, "requiresTopLevelScope is false"); + t.false(moduleInfo.rawModule, "rawModule is false"); + t.false(moduleInfo.dynamicDependencies, "dynamicDependencies is false"); + t.deepEqual(moduleInfo.subModules, [], "submodules are empty"); +}); + +test("ModuleInfo: addSubModule", async (t) => { + // setup + const moduleInfo = new ModuleInfo("myName"); + moduleInfo.addDependency("otherModule", false); + const otherModuleInfo = new ModuleInfo("otherModule"); + otherModuleInfo.addDependency("unknownModule", false); + otherModuleInfo.dynamicDependencies = true; + + // action + moduleInfo.addSubModule(otherModuleInfo); + + // expectation + t.true(moduleInfo.dynamicDependencies, "dynamicDependencies is set"); + t.deepEqual(moduleInfo.subModules, ["otherModule"], "submodule is set"); + t.deepEqual(moduleInfo.dependencies, ["unknownModule"], "unknownModule dependency is copied over"); +}); From d0190bb706effe27f4c9aede3bf7e0096f74af66 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Tue, 11 Aug 2020 16:43:45 +0200 Subject: [PATCH 68/88] Add additional ModuleInfo tests --- test/lib/lbt/resources/ModuleInfo.js | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/lib/lbt/resources/ModuleInfo.js b/test/lib/lbt/resources/ModuleInfo.js index 272572f0b..9ecc16569 100644 --- a/test/lib/lbt/resources/ModuleInfo.js +++ b/test/lib/lbt/resources/ModuleInfo.js @@ -29,3 +29,35 @@ test("ModuleInfo: addSubModule", async (t) => { t.deepEqual(moduleInfo.subModules, ["otherModule"], "submodule is set"); t.deepEqual(moduleInfo.dependencies, ["unknownModule"], "unknownModule dependency is copied over"); }); + +test("ModuleInfo: name", async (t) => { + // setup + const moduleInfo = new ModuleInfo("myName"); + + // action + moduleInfo.addDependency("newName", false); + moduleInfo.name = "newName"; + + moduleInfo.addSubModule("newName2"); + moduleInfo.name = "newName2"; + + // expectation + t.deepEqual(moduleInfo.subModules, [], "submodule is empty"); + t.deepEqual(moduleInfo.dependencies, [], "dependencies is empty"); + t.is(moduleInfo.name, "newName2", "name was set"); +}); + +test("ModuleInfo: toString", async (t) => { + // setup + const moduleInfo = new ModuleInfo("myName"); + + // action + moduleInfo.addDependency("dep1", false); + moduleInfo.addDependency("dep2", false); + moduleInfo.addSubModule("sub1"); + moduleInfo.addSubModule("sub2"); + const stringContent = moduleInfo.toString(); + + // expectation + t.is(stringContent, "ModuleInfo(myName, dependencies=dep1,dep2, includes=sub1,sub2)", "string value is correct"); +}); From c95007b49ebba26e628ce4dc285366adbacb0acf Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 12 Aug 2020 08:26:48 +0200 Subject: [PATCH 69/88] Refactoring I sap.ui.requireSync remove relative path resolve logic test file, unnecessary code removal Rename ResourcesList to ResourceInfoList link to doku in generateResourcesJson --- lib/lbt/analyzer/JSModuleAnalyzer.js | 14 +-- lib/lbt/resources/ResourceCollector.js | 18 ++-- .../{ResourcesList.js => ResourceInfoList.js} | 16 +-- lib/processors/resourceListCreator.js | 4 +- lib/tasks/generateResourcesJson.js | 3 + .../resources/library/n/Button-dbg.js | 35 +----- .../resources/library/n/Button.js | 2 +- .../resources/library/n/resources.json | 8 +- .../dest/resources/library/n/Button-dbg.js | 35 +----- .../dest/resources/library/n/Button.js | 2 +- .../library.n/src/library/n/Button.js | 35 +----- test/lib/lbt/resources/ResourceInfoList.js | 101 ++++++++++++++++++ test/lib/lbt/resources/ResourcesList.js | 101 ------------------ 13 files changed, 144 insertions(+), 230 deletions(-) rename lib/lbt/resources/{ResourcesList.js => ResourceInfoList.js} (88%) create mode 100644 test/lib/lbt/resources/ResourceInfoList.js delete mode 100644 test/lib/lbt/resources/ResourcesList.js diff --git a/lib/lbt/analyzer/JSModuleAnalyzer.js b/lib/lbt/analyzer/JSModuleAnalyzer.js index 242b30fd7..67821e3a2 100644 --- a/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -443,7 +443,7 @@ class JSModuleAnalyzer { // recognizes a call to sap.ui.requireSync info.setFormat(ModuleFormat.UI5_DEFINE); - onSapUiRequireSync(node, conditional, info.name); + onSapUiRequireSync(node, conditional); } else if ( isMethodCall(node, CALL_JQUERY_SAP_REQUIRE) ) { // recognizes a call to jQuery.sap.require info.setFormat(ModuleFormat.UI5_LEGACY); @@ -598,21 +598,15 @@ class JSModuleAnalyzer { } } - function onSapUiRequireSync(node, conditional, name) { + function onSapUiRequireSync(node, conditional) { const args = node.arguments; const nArgs = args.length; const i = 0; if ( i < nArgs ) { if ( isString(args[i]) ) { - // resolve dependencies absolute: e.g. "library/n/changeHandler/SplitButton.js" - // instead of "./changeHandler/SplitButton.js" - let moduleName; - if (name == null) { - moduleName = ModuleName.fromRequireJSName( args[i].value ); - } else { - moduleName = ModuleName.resolveRelativeRequireJSName(name, args[i].value); - } + // sap.ui.requireSync does not support relative dependencies + const moduleName = ModuleName.fromRequireJSName( args[i].value ); info.addDependency(moduleName, conditional); } else { log.verbose("sap.ui.requireSync: cannot evaluate dynamic arguments: ", args[i] && args[i].type); diff --git a/lib/lbt/resources/ResourceCollector.js b/lib/lbt/resources/ResourceCollector.js index 4978c0880..058405624 100644 --- a/lib/lbt/resources/ResourceCollector.js +++ b/lib/lbt/resources/ResourceCollector.js @@ -1,4 +1,4 @@ -const ResourcesList = require("./ResourcesList"); +const ResourceInfoList = require("./ResourceInfoList"); const ResourceFilterList = require("./ResourceFilterList"); const ResourceInfo = require("./ResourceInfo"); @@ -87,17 +87,17 @@ class ResourceCollector { this._resources = new Map(); /** - * prefix to ResourcesList + * prefix to ResourceInfoList * - * @type {Map} + * @type {Map} * @private */ this._components = new Map(); /** - * prefix to ResourcesList + * prefix to ResourceInfoList * - * @type {Map} + * @type {Map} * @private */ this._themePackages = new Map(); @@ -132,7 +132,7 @@ class ResourceCollector { const prefix = name.substring(0, p + 1); const basename = name.substring(p + 1); if ( basename.match("[^/]*\\.library|Component\\.js|manifest\\.json") && !this._components.has(prefix) ) { - this._components.set(prefix, new ResourcesList(prefix)); + this._components.set(prefix, new ResourceInfoList(prefix)); } // a .theme file within a theme folder indicates a library/theme package // Note: ignores .theme files in library folders @@ -140,7 +140,7 @@ class ResourceCollector { // .theming files are not always present therefore this check is relevant for the library.source.less if ( name.match("(?:[^/]+/)*themes/[^/]+/(?:\\.theming|library\\.source\\.less)") && !this._themePackages.has(prefix) ) { // log.info("found new theme package %s", prefix); - this._themePackages.set(prefix, new ResourcesList(prefix)); + this._themePackages.set(prefix, new ResourceInfoList(prefix)); } } } @@ -333,14 +333,14 @@ class ResourceCollector { /** * Components * - * @returns {Map} + * @returns {Map} */ get components() { return this._components; } /** - * @returns {Map} + * @returns {Map} */ get themePackages() { return this._themePackages; diff --git a/lib/lbt/resources/ResourcesList.js b/lib/lbt/resources/ResourceInfoList.js similarity index 88% rename from lib/lbt/resources/ResourcesList.js rename to lib/lbt/resources/ResourceInfoList.js index 56f96ccb3..af5b655ea 100644 --- a/lib/lbt/resources/ResourcesList.js +++ b/lib/lbt/resources/ResourceInfoList.js @@ -9,7 +9,7 @@ const RESOURCES_PATTERN = /((?:\.view|\.fragment|\.controller|\.designtime|\.sup * @author Frank Weigel * @since 1.33.0 */ -class ResourcesList { +class ResourceInfoList { /** * Holds ResourceInfos * @@ -42,7 +42,7 @@ class ResourcesList { * @param {boolean} shareDebugInformation */ add(info, shareDebugInformation=true) { - const relativeName = ResourcesList.makePathRelativeTo(this.name, info.name); + const relativeName = ResourceInfoList.makePathRelativeTo(this.name, info.name); // search for a resource with the same name let myInfo = this.resourcesByName.get(relativeName); @@ -50,8 +50,8 @@ class ResourcesList { if ( myInfo == null && shareDebugInformation) { // when not found, check if the given resource is a debug resource and // share the information with the non-dbg version - const nonDbgName = ResourcesList.getNonDebugName(relativeName); - const dbgName = ResourcesList.getDebugName(relativeName); + const nonDbgName = ResourceInfoList.getNonDebugName(relativeName); + const dbgName = ResourceInfoList.getDebugName(relativeName); if ( nonDbgName != null && this.resourcesByName.has(nonDbgName) ) { // copy from source myInfo = new ResourceInfo(relativeName); @@ -64,7 +64,7 @@ class ResourcesList { myInfo = new ResourceInfo(relativeName); const source = this.resourcesByName.get(dbgName); myInfo.copyFrom(this.name, source); - myInfo.module = ResourcesList.getNonDebugName(source.module); + myInfo.module = ResourceInfoList.getNonDebugName(source.module); this.resources.push(myInfo); this.resourcesByName.set(relativeName, myInfo); } @@ -74,13 +74,13 @@ class ResourcesList { if ( myInfo == null ) { myInfo = new ResourceInfo(relativeName); myInfo.size = info.size; - myInfo.module = ResourcesList.getNonDebugName(info.name); + myInfo.module = ResourceInfoList.getNonDebugName(info.name); this.resources.push(myInfo); this.resourcesByName.set(relativeName, myInfo); } myInfo.copyFrom(this.name, info); if (info.i18nName) { - myInfo.i18nName = ResourcesList.makePathRelativeTo(this.name, info.i18nName); + myInfo.i18nName = ResourceInfoList.makePathRelativeTo(this.name, info.i18nName); } } @@ -150,4 +150,4 @@ class ResourcesList { } } -module.exports = ResourcesList; +module.exports = ResourceInfoList; diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index 81809e80e..ef0a203e1 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -79,7 +79,7 @@ const DEBUG_BUNDLES = [ /** * Adds resources.json itself to the list * - * @param {ResourcesList} list resources list + * @param {ResourceInfoList} list resources list * @param {string} prefix * @returns {string} new content with resources.json entry */ @@ -164,7 +164,7 @@ module.exports = async function({resources}, options) { supportResources: options.supportResources }); - // group resources by components and create ResourcesLists + // group resources by components and create ResourceInfoLists collector.groupResourcesByComponents({ debugBundles: options.debugBundles }); diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index 63a324629..ef21fbbe7 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -33,6 +33,9 @@ function getCreatorOptions(projectName) { /** * Task for creating a resources.json file, describing all productive build resources. * + * The detailed structure can be found in the documentation: + * https://openui5.hana.ondemand.com/#topic/adcbcf8b50924556ab3f321fcd9353ea + * * @example sample resources.json * { * "_version": "1.1.0", diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js index d2a3bd81c..d75eb4240 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js @@ -6,53 +6,26 @@ // Provides control library.N.Button. sap.ui.define([ - './library', 'sap/ui/core/Control' ], function( - library, Control ) { "use strict"; return Control.extend("library.n.Button", { - metadata : { - library : "library.n", - properties : { - text: {type: "string", group: "Misc", defaultValue: "" } - }, - aggregations: { - icon: {type: "sap.ui.core.Control", cardinality: "0..1" } - }, - events: { - press: {} - } - }, - designtime: "library/n/designtime/Button.designtime", renderer: { - apiVersion: 2, render: function(oRm, oButton) { - sap.ui.requireSync("./changeHandler/SplitButton"); - oRm.openStart("button", oButton); - oRm.class("libNBtnBase"); - oRm.openEnd(); - if ( oButton.getIcon() ) { - oRm.renderControl(oButton.getIcon()); - } - oRm.openStart("span", oButton.getId() + "-content"); - oRm.class("libNBtnContent"); - oRm.openEnd(); - oRm.text(sText); - oRm.close("span"); - oRm.close("button"); + // requireSync Dependency + sap.ui.requireSync("library/n/changeHandler/SplitButton"); } }, helper: function(sCalendarType) { var sCalendar = "sap/ui/core/date/" + sCalendarType; + // dynamicDependency sap.ui.require(["sap/ui/core/format/DateFormat", sCalendar], function(DateFormat, Calendar) { DateFormat.getInstance(); new Calendar(); }); } }); - -}); \ No newline at end of file +}); diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js index 5555f3917..4dff24f7b 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["./library","sap/ui/core/Control"],function(e,t){"use strict";return t.extend("library.n.Button",{metadata:{library:"library.n",properties:{text:{type:"string",group:"Misc",defaultValue:""}},aggregations:{icon:{type:"sap.ui.core.Control",cardinality:"0..1"}},events:{press:{}}},designtime:"library/n/designtime/Button.designtime",renderer:{apiVersion:2,render:function(e,t){sap.ui.requireSync("./changeHandler/SplitButton");e.openStart("button",t);e.class("libNBtnBase");e.openEnd();if(t.getIcon()){e.renderControl(t.getIcon())}e.openStart("span",t.getId()+"-content");e.class("libNBtnContent");e.openEnd();e.text(sText);e.close("span");e.close("button")}},helper:function(e){var t="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",t],function(e,t){e.getInstance();new t})}})}); \ No newline at end of file +sap.ui.define(["sap/ui/core/Control"],function(e){"use strict";return e.extend("library.n.Button",{renderer:{render:function(e,r){sap.ui.requireSync("library/n/changeHandler/SplitButton")}},helper:function(e){var r="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",r],function(e,r){e.getInstance();new r})}})}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json b/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json index 7bd0c7a08..912986bbc 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json @@ -8,10 +8,9 @@ { "name": "Button-dbg.js", "module": "library/n/Button.js", - "size": 1417, + "size": 786, "isDebug": true, "required": [ - "library/n/library.js", "sap/ui/core/Control.js" ], "condRequired": [ @@ -23,9 +22,8 @@ { "name": "Button.js", "module": "library/n/Button.js", - "size": 998, + "size": 516, "required": [ - "library/n/library.js", "sap/ui/core/Control.js" ], "condRequired": [ @@ -173,7 +171,7 @@ }, { "name": "resources.json", - "size": 4298 + "size": 4241 }, { "name": "rules/Button-dbg.support.js", diff --git a/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js b/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js index d2a3bd81c..d75eb4240 100644 --- a/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js @@ -6,53 +6,26 @@ // Provides control library.N.Button. sap.ui.define([ - './library', 'sap/ui/core/Control' ], function( - library, Control ) { "use strict"; return Control.extend("library.n.Button", { - metadata : { - library : "library.n", - properties : { - text: {type: "string", group: "Misc", defaultValue: "" } - }, - aggregations: { - icon: {type: "sap.ui.core.Control", cardinality: "0..1" } - }, - events: { - press: {} - } - }, - designtime: "library/n/designtime/Button.designtime", renderer: { - apiVersion: 2, render: function(oRm, oButton) { - sap.ui.requireSync("./changeHandler/SplitButton"); - oRm.openStart("button", oButton); - oRm.class("libNBtnBase"); - oRm.openEnd(); - if ( oButton.getIcon() ) { - oRm.renderControl(oButton.getIcon()); - } - oRm.openStart("span", oButton.getId() + "-content"); - oRm.class("libNBtnContent"); - oRm.openEnd(); - oRm.text(sText); - oRm.close("span"); - oRm.close("button"); + // requireSync Dependency + sap.ui.requireSync("library/n/changeHandler/SplitButton"); } }, helper: function(sCalendarType) { var sCalendar = "sap/ui/core/date/" + sCalendarType; + // dynamicDependency sap.ui.require(["sap/ui/core/format/DateFormat", sCalendar], function(DateFormat, Calendar) { DateFormat.getInstance(); new Calendar(); }); } }); - -}); \ No newline at end of file +}); diff --git a/test/expected/build/library.n/dest/resources/library/n/Button.js b/test/expected/build/library.n/dest/resources/library/n/Button.js index 5555f3917..4dff24f7b 100644 --- a/test/expected/build/library.n/dest/resources/library/n/Button.js +++ b/test/expected/build/library.n/dest/resources/library/n/Button.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["./library","sap/ui/core/Control"],function(e,t){"use strict";return t.extend("library.n.Button",{metadata:{library:"library.n",properties:{text:{type:"string",group:"Misc",defaultValue:""}},aggregations:{icon:{type:"sap.ui.core.Control",cardinality:"0..1"}},events:{press:{}}},designtime:"library/n/designtime/Button.designtime",renderer:{apiVersion:2,render:function(e,t){sap.ui.requireSync("./changeHandler/SplitButton");e.openStart("button",t);e.class("libNBtnBase");e.openEnd();if(t.getIcon()){e.renderControl(t.getIcon())}e.openStart("span",t.getId()+"-content");e.class("libNBtnContent");e.openEnd();e.text(sText);e.close("span");e.close("button")}},helper:function(e){var t="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",t],function(e,t){e.getInstance();new t})}})}); \ No newline at end of file +sap.ui.define(["sap/ui/core/Control"],function(e){"use strict";return e.extend("library.n.Button",{renderer:{render:function(e,r){sap.ui.requireSync("library/n/changeHandler/SplitButton")}},helper:function(e){var r="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",r],function(e,r){e.getInstance();new r})}})}); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/Button.js b/test/fixtures/library.n/src/library/n/Button.js index 5f4c66781..29599a350 100644 --- a/test/fixtures/library.n/src/library/n/Button.js +++ b/test/fixtures/library.n/src/library/n/Button.js @@ -4,53 +4,26 @@ // Provides control library.N.Button. sap.ui.define([ - './library', 'sap/ui/core/Control' ], function( - library, Control ) { "use strict"; return Control.extend("library.n.Button", { - metadata : { - library : "library.n", - properties : { - text: {type: "string", group: "Misc", defaultValue: "" } - }, - aggregations: { - icon: {type: "sap.ui.core.Control", cardinality: "0..1" } - }, - events: { - press: {} - } - }, - designtime: "library/n/designtime/Button.designtime", renderer: { - apiVersion: 2, render: function(oRm, oButton) { - sap.ui.requireSync("./changeHandler/SplitButton"); - oRm.openStart("button", oButton); - oRm.class("libNBtnBase"); - oRm.openEnd(); - if ( oButton.getIcon() ) { - oRm.renderControl(oButton.getIcon()); - } - oRm.openStart("span", oButton.getId() + "-content"); - oRm.class("libNBtnContent"); - oRm.openEnd(); - oRm.text(sText); - oRm.close("span"); - oRm.close("button"); + // requireSync Dependency + sap.ui.requireSync("library/n/changeHandler/SplitButton"); } }, helper: function(sCalendarType) { var sCalendar = "sap/ui/core/date/" + sCalendarType; + // dynamicDependency sap.ui.require(["sap/ui/core/format/DateFormat", sCalendar], function(DateFormat, Calendar) { DateFormat.getInstance(); new Calendar(); }); } }); - -}); \ No newline at end of file +}); diff --git a/test/lib/lbt/resources/ResourceInfoList.js b/test/lib/lbt/resources/ResourceInfoList.js new file mode 100644 index 000000000..8a0be81af --- /dev/null +++ b/test/lib/lbt/resources/ResourceInfoList.js @@ -0,0 +1,101 @@ +const test = require("ava"); + +const ResourceInfoList = require("../../../../lib/lbt/resources/ResourceInfoList"); + +test("add: add new resources", (t) => { + const resourceInfoList = new ResourceInfoList("prefix"); + + const myInfo = {name: "myfile.js", size: 13}; + t.deepEqual(resourceInfoList.resources, [], "empty list"); + + resourceInfoList.add(myInfo); + + t.is(resourceInfoList.resources.length, 1, "one entry"); + + const result = resourceInfoList.resources[0]; + t.falsy(result.module, "module is not set"); +}); + +test("add: add source then debug resources", (t) => { + const resourceInfoList = new ResourceInfoList("prefix"); + + resourceInfoList.add({name: "myfile.js", module: "myfile.js", size: 13}); + + const myInfo = {name: "myfile-dbg.js", size: 13}; + resourceInfoList.add(myInfo); + + t.is(resourceInfoList.resources.length, 2, "two entries"); + + const result = resourceInfoList.resourcesByName.get("../myfile.js"); + t.is(result.module, "myfile.js", "module is set"); + + const resultDbg = resourceInfoList.resourcesByName.get("../myfile-dbg.js"); + t.is(resultDbg.module, "myfile.js", "module is set"); +}); + +test("add: add debug then source resources", (t) => { + const resourceInfoList = new ResourceInfoList("prefix"); + + resourceInfoList.add({name: "myfile-dbg.js", size: 13}); + + const myInfo = {name: "myfile.js", module: "myfile.js", size: 13}; + resourceInfoList.add(myInfo); + + t.is(resourceInfoList.resources.length, 2, "two entries"); + + const result = resourceInfoList.resourcesByName.get("../myfile.js"); + t.is(result.module, "myfile.js", "module is set"); + + const resultDbg = resourceInfoList.resourcesByName.get("../myfile-dbg.js"); + t.is(resultDbg.module, "myfile.js", "module is set"); +}); + +test("add: add i18n resource", (t) => { + const resourceInfoList = new ResourceInfoList("prefix"); + + resourceInfoList.add({name: "i18n_en.properties", i18nName: "i18n.properties", size: 13}); + + t.is(resourceInfoList.resources.length, 1, "one entry"); + + const result = resourceInfoList.resourcesByName.get("../i18n_en.properties"); + t.is(result.i18nName, "../i18n.properties", "i18n name is set relative"); +}); + +test("add: resource with the same name", (t) => { + const resourceInfoList = new ResourceInfoList("prefix"); + + resourceInfoList.add({name: "myfile.js", size: 13}); + resourceInfoList.add({name: "myfile.js", size: 13}); + + t.is(resourceInfoList.resources.length, 1, "one entry"); + + const result = resourceInfoList.resourcesByName.get("../myfile.js"); + t.is(result.name, "../myfile.js", "name is set relative"); +}); + +test("toJSON: resource with the same name", (t) => { + const resourceInfoList = new ResourceInfoList("prefix"); + + resourceInfoList.resources.push({name: "myfile.js", size: 13}); + resourceInfoList.resources.push({name: "myfile.js", size: 13}); + + t.deepEqual(resourceInfoList.toJSON(), { + _version: "1.1.0", + resources: [ + { + name: "myfile.js", + size: 13, + }, + { + name: "myfile.js", + size: 13, + }, + ], + }, "one entry"); +}); + +test("makePathRelativeTo: same prefix", (t) => { + const relativePath = ResourceInfoList.makePathRelativeTo("am/bn/cf", "args/myfile.js"); + + t.is(relativePath, "../../../args/myfile.js", "relative path"); +}); diff --git a/test/lib/lbt/resources/ResourcesList.js b/test/lib/lbt/resources/ResourcesList.js deleted file mode 100644 index e05ede24a..000000000 --- a/test/lib/lbt/resources/ResourcesList.js +++ /dev/null @@ -1,101 +0,0 @@ -const test = require("ava"); - -const ResourcesList = require("../../../../lib/lbt/resources/ResourcesList"); - -test("add: add new resources", (t) => { - const resourcesList = new ResourcesList("prefix"); - - const myInfo = {name: "myfile.js", size: 13}; - t.deepEqual(resourcesList.resources, [], "empty list"); - - resourcesList.add(myInfo); - - t.is(resourcesList.resources.length, 1, "one entry"); - - const result = resourcesList.resources[0]; - t.falsy(result.module, "module is not set"); -}); - -test("add: add source then debug resources", (t) => { - const resourcesList = new ResourcesList("prefix"); - - resourcesList.add({name: "myfile.js", module: "myfile.js", size: 13}); - - const myInfo = {name: "myfile-dbg.js", size: 13}; - resourcesList.add(myInfo); - - t.is(resourcesList.resources.length, 2, "two entries"); - - const result = resourcesList.resourcesByName.get("../myfile.js"); - t.is(result.module, "myfile.js", "module is set"); - - const resultDbg = resourcesList.resourcesByName.get("../myfile-dbg.js"); - t.is(resultDbg.module, "myfile.js", "module is set"); -}); - -test("add: add debug then source resources", (t) => { - const resourcesList = new ResourcesList("prefix"); - - resourcesList.add({name: "myfile-dbg.js", size: 13}); - - const myInfo = {name: "myfile.js", module: "myfile.js", size: 13}; - resourcesList.add(myInfo); - - t.is(resourcesList.resources.length, 2, "two entries"); - - const result = resourcesList.resourcesByName.get("../myfile.js"); - t.is(result.module, "myfile.js", "module is set"); - - const resultDbg = resourcesList.resourcesByName.get("../myfile-dbg.js"); - t.is(resultDbg.module, "myfile.js", "module is set"); -}); - -test("add: add i18n resource", (t) => { - const resourcesList = new ResourcesList("prefix"); - - resourcesList.add({name: "i18n_en.properties", i18nName: "i18n.properties", size: 13}); - - t.is(resourcesList.resources.length, 1, "one entry"); - - const result = resourcesList.resourcesByName.get("../i18n_en.properties"); - t.is(result.i18nName, "../i18n.properties", "i18n name is set relative"); -}); - -test("add: resource with the same name", (t) => { - const resourcesList = new ResourcesList("prefix"); - - resourcesList.add({name: "myfile.js", size: 13}); - resourcesList.add({name: "myfile.js", size: 13}); - - t.is(resourcesList.resources.length, 1, "one entry"); - - const result = resourcesList.resourcesByName.get("../myfile.js"); - t.is(result.name, "../myfile.js", "name is set relative"); -}); - -test("toJSON: resource with the same name", (t) => { - const resourcesList = new ResourcesList("prefix"); - - resourcesList.resources.push({name: "myfile.js", size: 13}); - resourcesList.resources.push({name: "myfile.js", size: 13}); - - t.deepEqual(resourcesList.toJSON(), { - _version: "1.1.0", - resources: [ - { - name: "myfile.js", - size: 13, - }, - { - name: "myfile.js", - size: 13, - }, - ], - }, "one entry"); -}); - -test("makePathRelativeTo: same prefix", (t) => { - const relativePath = ResourcesList.makePathRelativeTo("am/bn/cf", "args/myfile.js"); - - t.is(relativePath, "../../../args/myfile.js", "relative path"); -}); From 7a88642dcac7e9fef925303d51f90d55aad714c4 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 12 Aug 2020 09:08:42 +0200 Subject: [PATCH 70/88] Refactoring II Moved size retrieval from listCreator to collector Avoid unnecessary join/split by directly using the array --- lib/lbt/resources/ResourceCollector.js | 24 +++++++++---------- lib/processors/resourceListCreator.js | 16 +++++-------- lib/tasks/generateResourcesJson.js | 2 +- test/lib/lbt/resources/ResourceCollector.js | 26 ++++++++++----------- test/lib/tasks/generateResourcesJson.js | 2 +- 5 files changed, 33 insertions(+), 37 deletions(-) diff --git a/lib/lbt/resources/ResourceCollector.js b/lib/lbt/resources/ResourceCollector.js index 058405624..375074b80 100644 --- a/lib/lbt/resources/ResourceCollector.js +++ b/lib/lbt/resources/ResourceCollector.js @@ -71,7 +71,7 @@ const log = require("@ui5/logger").getLogger("lbt:resources:ResourceCollector"); */ class ResourceCollector { /** - * Collects resources + * Collects a set of ResourceInfo objects and groups them by components, libraries and themes. * * @param {ResourcePool} pool * @param {ResourceFilterList} [filter] used to filter the resources based on their name @@ -114,19 +114,19 @@ class ResourceCollector { /** * Processes a resource * - * @param {string} virPath virtual path of the resource - * @param {number} sizeBytes size in bytes + * @param {module:@ui5/fs.Resource} resource */ - visitResource(virPath, sizeBytes) { + async visitResource(resource) { + const virPath = resource.getPath(); if ( !virPath.startsWith("/resources/") ) { log.warn(`non-runtime resource ${virPath} ignored`); return; } const name = virPath.slice("/resources/".length); if ( this._filter.matches(name) ) { - const resource = new ResourceInfo(name); - resource.size = sizeBytes; - this._resources.set(name, resource); + const resourceInfo = new ResourceInfo(name); + resourceInfo.size = await resource.getSize(); + this._resources.set(name, resourceInfo); const p = name.lastIndexOf("/"); const prefix = name.substring(0, p + 1); @@ -189,10 +189,10 @@ class ResourceCollector { async determineResourceDetails({pool, debugResources, mergedResources, designtimeResources, supportResources}) { const baseNames = new Set(); - const debugFilter = ResourceFilterList.fromString(debugResources); - const mergeFilter = ResourceFilterList.fromString(mergedResources); - const designtimeFilter = ResourceFilterList.fromString(designtimeResources); - const supportFilter = ResourceFilterList.fromString(supportResources); + const debugFilter = new ResourceFilterList(debugResources); + const mergeFilter = new ResourceFilterList(mergedResources); + const designtimeFilter = new ResourceFilterList(designtimeResources); + const supportFilter = new ResourceFilterList(supportResources); const promises = []; @@ -289,7 +289,7 @@ class ResourceCollector { groupResourcesByComponents(options) { const orphanFilters = this.createOrphanFilters(); - const debugBundlesFilter = ResourceFilterList.fromString(options.debugBundles); + const debugBundlesFilter = new ResourceFilterList(options.debugBundles); for (const resource of this._resources.values()) { let contained = false; for (const [prefix, list] of this._components.entries()) { diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index ef0a203e1..a4dfe03d1 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -131,22 +131,18 @@ module.exports = async function({resources}, options) { options = Object.assign({ failOnOrphans: true, externalResources: undefined, - debugResources: DEFAULT_DEBUG_RESOURCES_FILTER.join(","), - mergedResources: DEFAULT_BUNDLE_RESOURCES_FILTER.join(","), - designtimeResources: DEFAULT_DESIGNTIME_RESOURCES_FILTER.join(","), - supportResources: DEFAULT_SUPPORT_RESOURCES_FILTER.join(","), - debugBundles: DEBUG_BUNDLES.join(",") + debugResources: DEFAULT_DEBUG_RESOURCES_FILTER, + mergedResources: DEFAULT_BUNDLE_RESOURCES_FILTER, + designtimeResources: DEFAULT_DESIGNTIME_RESOURCES_FILTER, + supportResources: DEFAULT_SUPPORT_RESOURCES_FILTER, + debugBundles: DEBUG_BUNDLES }, options); const pool = new LocatorResourcePool(); await pool.prepare( resources ); const collector = new ResourceCollector(pool); - const visitPromises = resources.map((resource) => { - return resource.getSize().then((size) => { - collector.visitResource(resource.getPath(), size); - }); - }); + const visitPromises = resources.map((resource) => collector.visitResource(resource)); await Promise.all(visitPromises); log.verbose(` found ${collector.resources.size} resources`); diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index ef21fbbe7..4d79fda5e 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -24,7 +24,7 @@ function getCreatorOptions(projectName) { "**/library-all-dbg.js", "**/designtime/library-preload.designtime.js", "**/library-preload.support.js" - ].join(",") + ] }); } return creatorOptions; diff --git a/test/lib/lbt/resources/ResourceCollector.js b/test/lib/lbt/resources/ResourceCollector.js index 3f555141d..6bd5763a6 100644 --- a/test/lib/lbt/resources/ResourceCollector.js +++ b/test/lib/lbt/resources/ResourceCollector.js @@ -56,34 +56,34 @@ test.serial("createOrphanFilters: filters", (t) => { t.is(orphanFilters.size, 4, "4 filters"); }); -test.serial("visitResource: path", (t) => { +test.serial("visitResource: path", async (t) => { const resourceCollector = new ResourceCollector(); - resourceCollector.visitResource("mypath", 13); + await resourceCollector.visitResource({getPath: () => "mypath", getSize: async () => 13}); t.is(t.context.logWarnSpy.callCount, 1); t.is(t.context.logWarnSpy.getCall(0).args[0], "non-runtime resource mypath ignored"); }); -test.serial("visitResource: library.source.less", (t) => { +test.serial("visitResource: library.source.less", async (t) => { const resourceCollector = new ResourceCollector(); t.is(resourceCollector.themePackages.size, 0, "initially there is no theme package"); - resourceCollector.visitResource("/resources/themes/a/library.source.less", 13); + await resourceCollector.visitResource({getPath: () => "/resources/themes/a/library.source.less", getSize: async () => 13}); t.is(resourceCollector.themePackages.size, 1, "theme package was added"); }); -test.serial("groupResourcesByComponents: debugBundles", (t) => { +test.serial("groupResourcesByComponents: debugBundles", async (t) => { const resourceCollector = new ResourceCollector(); resourceCollector.setExternalResources({ "testcomp": ["my/file.js"] }); - resourceCollector.visitResource("/resources/testcomp/Component.js", 13); - resourceCollector.visitResource("/resources/my/file.js", 13); - resourceCollector.groupResourcesByComponents({debugBundles: ".*-dbg.js"}); + await resourceCollector.visitResource({getPath: () => "/resources/testcomp/Component.js", getSize: async () => 13}); + await resourceCollector.visitResource({getPath: () => "/resources/my/file.js", getSize: async () => 13}); + resourceCollector.groupResourcesByComponents({debugBundles: [".*-dbg.js"]}); t.is(resourceCollector.resources.size, 0, "all resources were deleted"); }); test.serial("groupResourcesByComponents: theme", async (t) => { const resourceCollector = new ResourceCollector(); - resourceCollector.visitResource("/resources/themes/a/.theming", 13); + await resourceCollector.visitResource({getPath: () => "/resources/themes/a/.theming", getSize: async () => 13}); t.is(resourceCollector.themePackages.size, 1, "1 theme was added"); await resourceCollector.determineResourceDetails({}); resourceCollector.groupResourcesByComponents({}); @@ -98,9 +98,9 @@ test.serial("determineResourceDetails: properties", async (t) => { }; } }); - resourceCollector.visitResource("/resources/mylib/manifest.json", 13); - resourceCollector.visitResource("/resources/mylib/i18n/i18n_de.properties", 13); - resourceCollector.visitResource("/resources/mylib/i18n/i18n.properties", 13); + await resourceCollector.visitResource({getPath: () => "/resources/mylib/manifest.json", getSize: async () => 13}); + await resourceCollector.visitResource({getPath: () => "/resources/mylib/i18n/i18n_de.properties", getSize: async () => 13}); + await resourceCollector.visitResource({getPath: () => "/resources/mylib/i18n/i18n.properties", getSize: async () => 13}); await resourceCollector.determineResourceDetails({}); resourceCollector.groupResourcesByComponents({}); const resources = resourceCollector.components.get("mylib/").resources; @@ -116,7 +116,7 @@ test.serial("determineResourceDetails: view.xml", async (t) => { } }); const enrichWithDependencyInfoStub = sinon.stub(resourceCollector, "enrichWithDependencyInfo").returns(Promise.resolve()); - resourceCollector.visitResource("/resources/mylib/my.view.xml", 13); + await resourceCollector.visitResource({getPath: () => "/resources/mylib/my.view.xml", getSize: async () => 13}); await resourceCollector.determineResourceDetails({}); t.is(enrichWithDependencyInfoStub.callCount, 1, "is called once"); t.is(enrichWithDependencyInfoStub.getCall(0).args[0].name, "mylib/my.view.xml", "is called with view"); diff --git a/test/lib/tasks/generateResourcesJson.js b/test/lib/tasks/generateResourcesJson.js index d9fa6e4b9..992f20bc3 100644 --- a/test/lib/tasks/generateResourcesJson.js +++ b/test/lib/tasks/generateResourcesJson.js @@ -62,7 +62,7 @@ test("empty resources", async (t) => { "**/library-all-dbg.js", "**/designtime/library-preload.designtime.js", "**/library-preload.support.js" - ].join(",") + ] }; t.deepEqual(t.context.resourceListCreatorStub.getCall(0).args[1], expectedOptions, "options match"); }); From 393a7750252018a2411e634aaf6d88e56050dae1 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 12 Aug 2020 09:41:28 +0200 Subject: [PATCH 71/88] version info exclude Excluded version info files since they are not part of the resources.json --- lib/tasks/generateResourcesJson.js | 13 ++++++++- .../resources/sap-ui-version.json | 7 +++++ test/lib/builder/builder.js | 27 +++++++++++++++++-- 3 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 test/expected/build/application.j/dest-resources-json/resources/sap-ui-version.json diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index 4d79fda5e..28bdbf94e 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -2,6 +2,17 @@ const resourceListCreator = require("../processors/resourceListCreator"); +const DEFAULT_EXCLUDES = [ + /* + * exclude mac metadata files + */ + "!**/.DS_Store", + /* + * sap-ui-version.json is not part of the resources + */ + "!/resources/sap-ui-version.json" +]; + function getCreatorOptions(projectName) { const creatorOptions = {}; if ( projectName === "sap.ui.core" ) { @@ -86,7 +97,7 @@ function getCreatorOptions(projectName) { * @returns {Promise} Promise resolving with undefined once data has been written */ module.exports = async function({workspace, options: {projectName}}) { - const resources = await workspace.byGlob(["/resources/**/*.*"]); + const resources = await workspace.byGlob(["/resources/**/*.*"].concat(DEFAULT_EXCLUDES)); const resourceLists = await resourceListCreator({ resources diff --git a/test/expected/build/application.j/dest-resources-json/resources/sap-ui-version.json b/test/expected/build/application.j/dest-resources-json/resources/sap-ui-version.json new file mode 100644 index 000000000..551fc7d92 --- /dev/null +++ b/test/expected/build/application.j/dest-resources-json/resources/sap-ui-version.json @@ -0,0 +1,7 @@ +{ + "name": "application.j", + "version": "1.0.0", + "buildTimestamp": "202008120917", + "scmRevision": "", + "libraries": [] +} \ No newline at end of file diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index d9ad99998..601a1202d 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -8,6 +8,7 @@ const readFile = promisify(fs.readFile); const assert = chai.assert; const sinon = require("sinon"); const mock = require("mock-require"); +const resourceFactory = require("@ui5/fs").resourceFactory; const ui5Builder = require("../../../"); const builder = ui5Builder.builder; @@ -478,17 +479,39 @@ test("Build application.j", (t) => { }); }); -test("Build application.j with resources.json", (t) => { +test("Build application.j with resources.json and version info", (t) => { const destPath = "./test/tmp/build/application.j/dest-resources-json"; const expectedPath = path.join("test", "expected", "build", "application.j", "dest-resources-json"); + + const dummyVersionInfoGenerator = () => { + const versionJson = { + "name": "application.j", + "version": "1.0.0", + "buildTimestamp": "202008120917", + "scmRevision": "", + "libraries": [] + }; + + return [resourceFactory.createResource({ + path: "/resources/sap-ui-version.json", + string: JSON.stringify(versionJson, null, "\t") + })]; + }; + + mock("../../../lib/processors/versionInfoGenerator", dummyVersionInfoGenerator); + mock.reRequire("../../../lib/tasks/generateVersionInfo"); + + const builder = mock.reRequire("../../../lib/builder/builder"); + + return builder.build({ includedTasks: [ "generateResourcesJson" ], tree: applicationJTree, destPath, - excludedTasks: ["createDebugFiles", "generateStandaloneAppBundle", "generateVersionInfo"] + excludedTasks: ["createDebugFiles", "generateStandaloneAppBundle"] }).then(() => { return findFiles(expectedPath); }).then((expectedFiles) => { From b4167159def2fcc93d74420eaf97cdc4b6ffa9a6 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 12 Aug 2020 09:46:47 +0200 Subject: [PATCH 72/88] Rename resourceJson creation method --- lib/processors/resourceListCreator.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/processors/resourceListCreator.js b/lib/processors/resourceListCreator.js index a4dfe03d1..20b5034a5 100644 --- a/lib/processors/resourceListCreator.js +++ b/lib/processors/resourceListCreator.js @@ -77,13 +77,15 @@ const DEBUG_BUNDLES = [ ]; /** - * Adds resources.json itself to the list + * Creates and adds resources.json entry (itself) to the list. + * + * Retrieves the string content of the overall result and returns it. * * @param {ResourceInfoList} list resources list * @param {string} prefix * @returns {string} new content with resources.json entry */ -function addResourcesJsonToList(list, prefix) { +function makeResourcesJSON(list, prefix) { // having the file size entry part of the file is a bit like the chicken egg scenario // you can't change the value of the file size without changing the file size // so this part here tries to cope with that. @@ -171,7 +173,7 @@ module.exports = async function({resources}, options) { for (const [prefix, list] of collector.components.entries()) { log.verbose(` writing '${prefix}resources.json'`); - const contentString = addResourcesJsonToList(list, prefix); + const contentString = makeResourcesJSON(list, prefix); resourceLists.push(new EvoResource({ path: `/resources/${prefix}resources.json`, @@ -181,7 +183,7 @@ module.exports = async function({resources}, options) { for (const [prefix, list] of collector.themePackages.entries()) { log.verbose(` writing '${prefix}resources.json'`); - const contentString = addResourcesJsonToList(list, prefix); + const contentString = makeResourcesJSON(list, prefix); resourceLists.push(new EvoResource({ path: `/resources/${prefix}resources.json`, From 241dbfe126243edfb52619daa49eafda73f57f14 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 12 Aug 2020 12:25:33 +0200 Subject: [PATCH 73/88] Create test for LibraryBuilder --- test/lib/types/library/LibraryBuilder.js | 58 ++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 test/lib/types/library/LibraryBuilder.js diff --git a/test/lib/types/library/LibraryBuilder.js b/test/lib/types/library/LibraryBuilder.js new file mode 100644 index 000000000..cd217cc0c --- /dev/null +++ b/test/lib/types/library/LibraryBuilder.js @@ -0,0 +1,58 @@ +const test = require("ava"); +const chai = require("chai"); +const path = require("path"); +chai.use(require("chai-fs")); + +const parentLogger = require("@ui5/logger").getGroupLogger("mygroup"); + +const LibraryBuilder = require("../../../../lib/types/library/LibraryBuilder"); + +function clone(o) { + return JSON.parse(JSON.stringify(o)); +} + +test("Instantiation", (t) => { + const project = clone(libraryETree); + const appBuilder = new LibraryBuilder({parentLogger, project}); + t.truthy(appBuilder); + t.deepEqual(appBuilder.taskExecutionOrder, [ + "escapeNonAsciiCharacters", + "replaceCopyright", + "replaceVersion", + "generateJsdoc", + "executeJsdocSdkTransformation", + "generateLibraryManifest", + "generateManifestBundle", + "generateLibraryPreload", + "buildThemes", + "createDebugFiles", + "uglify", + "generateResourcesJson" + ], "LibraryBuilder is instantiated with standard tasks"); +}); + +const libraryEPath = path.join(__dirname, "..", "..", "..", "fixtures", "library.e"); +const libraryETree = { + id: "library.e.id", + version: "1.0.0", + path: libraryEPath, + dependencies: [], + _level: 0, + _isRoot: true, + specVersion: "2.0", + type: "library", + metadata: { + name: "library.e", + copyright: "UI development toolkit for HTML5 (OpenUI5)\n * (c) Copyright 2009-xxx SAP SE or an SAP affiliate " + + "company.\n * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.", + namespace: "library.e" + }, + resources: { + configuration: { + paths: { + src: "src", + test: "test" + } + } + } +}; From af96c0851ce307dff71f779b81086e4b679d3527 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Wed, 12 Aug 2020 16:53:51 +0200 Subject: [PATCH 74/88] Reduce code size for fixtures --- test/fixtures/lbt/modules/functionDefine.js | 55 ++------------ test/fixtures/lbt/modules/nestedRequire.js | 82 ++++----------------- test/lib/types/library/LibraryBuilder.js | 2 - 3 files changed, 19 insertions(+), 120 deletions(-) diff --git a/test/fixtures/lbt/modules/functionDefine.js b/test/fixtures/lbt/modules/functionDefine.js index d8e4f61e3..9e8ae6cfc 100644 --- a/test/fixtures/lbt/modules/functionDefine.js +++ b/test/fixtures/lbt/modules/functionDefine.js @@ -1,67 +1,24 @@ /*! * ${copyright} */ - -/** - * FEATURE TO INCREASE DEVELOPMENT EXPERIENCE! NO PRODUCTIVE USAGE ALLOWED! - */ +/*global my */ (function() { "use strict"; - /** - * wraps the definition of the MyFile in order to be able to delay - * the definition until the body is loaded and sap.ui.define is available - */ function defineMyFile() { - - // Provides class sap.ui.core.plugin.MyFile - sap.ui.define('sap/ui/core/plugin/MyFile', [ - 'sap/ui/thirdparty/jquery'], - function(jQuery) { - - /** - * Creates an instance of the class sap.ui.core.plugin.MyFile - * - * @version ${version} - * @private - * @alias sap.ui.core.plugin.MyFile - */ - var MyFile = function() { - }; - - - /** - * Create the sap.ui.core.plugin.MyFile plugin and - * register it within the sap.ui.core.Core. - */ - var oThis = new MyFile(); - sap.ui.getCore().registerPlugin(oThis); - - /** - * Triggers a less refresh and updates the theming parameters. - * - * @private - */ - MyFile.refresh = function() { - }; - - return MyFile; - + sap.ui.define('def/MyFile', ['dep/myDep'], + function(myDep) { + return 47; }); - } - // check for "sap.ui.define" being already available - // - when available immediately define the MyFile - // - if not we delay the definition till the body is loaded + // conditional if (!(window.sap && window.sap.ui && window.sap.ui.define)) { var fnHandler = function() { - document.removeEventListener("DOMContentLoaded", fnHandler, false); defineMyFile(); }; - document.addEventListener("DOMContentLoaded", fnHandler, false); + my.addEventListener("myevent", fnHandler); } else { defineMyFile(); } - }()); \ No newline at end of file diff --git a/test/fixtures/lbt/modules/nestedRequire.js b/test/fixtures/lbt/modules/nestedRequire.js index ca6d3001e..fbb17056e 100644 --- a/test/fixtures/lbt/modules/nestedRequire.js +++ b/test/fixtures/lbt/modules/nestedRequire.js @@ -2,89 +2,33 @@ * ${copyright} */ -/* - * IMPORTANT: This is a private module, its API must not be used and is subject to change. - * Code other than the Core tests must not yet introduce dependencies to this module. - */ - -/*global document, sap */ +/*global my,sap */ (function(deps, callback) { "use strict"; - //extract base URL from script tag - var oScriptTag, mMatch, sBaseUrl; - - oScriptTag = document.querySelector("[src$='myfile.js']"); - if (oScriptTag) { - mMatch = /^(.*\/)?myfile.js/.exec(oScriptTag.getAttribute("src")); - if (mMatch) { - sBaseUrl = mMatch[1] + "../../../../"; - } + function doIt(array, callback) { + callback(); } - if (sBaseUrl == null) { - throw new Error("myfile.js: could not identify script tag!"); - } - - function loadScripts(urls, callback) { - var pending = urls.length, - errors = 0; - - if (pending === 0) { - callback(); - return; - } - - function listener(e) { - pending--; - if ( e.type === 'error' ) { - errors++; - } - e.target.removeEventListener("load", listener); - e.target.removeEventListener("error", listener); - if ( pending === 0 && errors === 0 && callback ) { - callback(); - } - } + var aArray = []; - for ( var i = 0; i < urls.length; i++ ) { - var script = document.createElement("script"); - script.addEventListener("load", listener); - script.addEventListener("error", listener); - script.src = sBaseUrl + urls[i]; - document.head.appendChild(script); - } - } - - // define the necessary polyfills to be loaded - var aPolyfills = []; - - // cascade 1: polyfills, can all be loaded in parallel - loadScripts(aPolyfills, function() { - // cascade 2: the loader - loadScripts([ - "ui5loader.js" + doIt(aArray, function() { + doIt([ + "foo" ], function() { - // cascade 3: the loader configuration script - sap.ui.loader.config({ - async:true - }); - loadScripts([ - "ui5loader-autoconfig.js" + doIt([ + "bar" ], function() { + // nested sap.ui.require sap.ui.require(deps, callback); }); }); }); }([ - "sap/ui/test/starter/_utils" -], function(utils) { + "my/dependency" +], function(myDep) { "use strict"; - - var oSuiteReadyEvent = document.createEvent("CustomEvent"); - oSuiteReadyEvent.initCustomEvent("sap-ui-testsuite-ready", true, true, {}); - window.dispatchEvent(oSuiteReadyEvent); - + console.log("done") })); \ No newline at end of file diff --git a/test/lib/types/library/LibraryBuilder.js b/test/lib/types/library/LibraryBuilder.js index cd217cc0c..41a05226a 100644 --- a/test/lib/types/library/LibraryBuilder.js +++ b/test/lib/types/library/LibraryBuilder.js @@ -1,7 +1,5 @@ const test = require("ava"); -const chai = require("chai"); const path = require("path"); -chai.use(require("chai-fs")); const parentLogger = require("@ui5/logger").getGroupLogger("mygroup"); From 2aad5fe70697a990a326270604b3ce891b9c83e7 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 13 Aug 2020 11:58:10 +0200 Subject: [PATCH 75/88] Refactored comments --- lib/lbt/resources/ResourceCollector.js | 72 ++++++------------------- lib/lbt/resources/ResourceFilterList.js | 26 +++++++++ 2 files changed, 43 insertions(+), 55 deletions(-) diff --git a/lib/lbt/resources/ResourceCollector.js b/lib/lbt/resources/ResourceCollector.js index 375074b80..f9cf97f5b 100644 --- a/lib/lbt/resources/ResourceCollector.js +++ b/lib/lbt/resources/ResourceCollector.js @@ -8,60 +8,6 @@ const THEME = /^((?:[^/]+\/)*)themes\/([^/]+)\//; const log = require("@ui5/logger").getLogger("lbt:resources:ResourceCollector"); -/* NODE-TODO - /** - * Global filters that should be taken into account when collecting resources. - * - * Each filter entry can be a comma separated list of simple filters. Each simple filter - * can be a pattern in resource name pattern syntax: A double asterisk '&0x2a;&0x2a;/' denotes an arbitrary - * number of resource name segments (folders) incl. a trailing slash, whereas a simple asterisk '*' - * denotes an arbitrary number of resource name characters, but not the segment separator '/'. - * A dot is interpreted as a dot, all other special regular expression characters keep their - * special meaning. This is a mixture of ANT-style path patterns and regular expressions. - * - * Excludes can be denoted by a leading '-' or '!', includes optionally by a leading '+'. - * Order of filters is significant, a later exclusion overrides an earlier inclusion - * and vice versa. - * - * Example: - *
    -	 *	 !sap/ui/core/
    -	 *	 +sap/ui/core/utils/
    -	 * 
    - * excludes everything from sap/ui/core, but includes everything from the subpackage sap/ui/core/utils/. - * - * Note that the filter operates on the full name of each resource. If a resource name - * prefix is configured for a resource set, the filter will be applied - * to the combination of prefix and local file path and not only to the local file path. - * / - @Parameter - private String[] filters; - - /** - * Whether the default filters should be ignored when filters are given. - * / - @Parameter(defaultValue="true") - private boolean ignoreDefaultFilters = true; - - /** - * Comma separated list of components to which orphaned resources should be added. - * - * If a component contains a colon, everything behind the colon is interpreted as a semicolon - * separated list of resource patterns of orphans that should be added to the preceeding component. - * If no such list is given, any orphaned resource will be added to the component. - * The evaluation logic for the filter list is the same as for the filters - * parameters: excludes can be denoted with a leading '-' or '!' and order is significant. - * Later filters can override the result of earlier ones. - * - * If no component is given, orphans will only be reported but not added to any component (default). - * - * @since 1.29.1 - * / - @Parameter - private String externalResources; -*/ - - /** * Collects all resources in a set of resource folders or from an archive * and writes a 'resources.json' file for each component or library @@ -78,6 +24,12 @@ class ResourceCollector { */ constructor(pool, filter) { this._pool = pool; + /** + * Global filters that should be taken into account when collecting resources. + * + * @type {ResourceFilterList} + * @private + */ this._filter = filter != null ? filter : new ResourceFilterList(); /** * name to resource info @@ -104,8 +56,18 @@ class ResourceCollector { } /** + * Comma separated list of components to which orphaned resources should be added. + * + * A component and a separated list of resource patterns of orphans that should be added + * to the preceding component. + * If no such list is given, any orphaned resource will be added to the component. + * The evaluation logic for the filter list is the same as for the filters + * parameters: excludes can be denoted with a leading '-' or '!' and order is significant. + * Later filters can override the result of earlier ones. + * + * If no component is given, orphans will only be reported but not added to any component (default). * - * @param {object} list + * @param {object} list component to list of components */ setExternalResources(list) { this._externalResources = list; diff --git a/lib/lbt/resources/ResourceFilterList.js b/lib/lbt/resources/ResourceFilterList.js index 67e23f53e..e29301177 100644 --- a/lib/lbt/resources/ResourceFilterList.js +++ b/lib/lbt/resources/ResourceFilterList.js @@ -127,6 +127,32 @@ class ResourceFilterList { } } +/** + * Each filter entry can be a comma separated list of simple filters. Each simple filter + * can be a pattern in resource name pattern syntax: A double asterisk '&0x2a;&0x2a;/' denotes an arbitrary + * number of resource name segments (folders) incl. a trailing slash, whereas a simple asterisk '*' + * denotes an arbitrary number of resource name characters, but not the segment separator '/'. + * A dot is interpreted as a dot, all other special regular expression characters keep their + * special meaning. This is a mixture of ANT-style path patterns and regular expressions. + * + * Excludes can be denoted by a leading '-' or '!', includes optionally by a leading '+'. + * Order of filters is significant, a later exclusion overrides an earlier inclusion + * and vice versa. + * + * Example: + *
    + *	 !sap/ui/core/
    + *	 +sap/ui/core/utils/
    + * 
    + * excludes everything from sap/ui/core, but includes everything from the subpackage sap/ui/core/utils/. + * + * Note that the filter operates on the full name of each resource. If a resource name + * prefix is configured for a resource set, the filter will be applied + * to the combination of prefix and local file path and not only to the local file path. + * + * @param {string} filterStr comma separated list of simple filters + * @returns {ResourceFilterList} + */ ResourceFilterList.fromString = function(filterStr) { const result = new ResourceFilterList(); if ( filterStr != null ) { From 711192c4ea69efde7c2bc272cf43654d127df1a3 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 13 Aug 2020 14:14:21 +0200 Subject: [PATCH 76/88] Reduced test files to the essential --- .../resources/library/n/.library | 2 +- .../resources/library/n/Button-dbg.js | 19 +++--- .../resources/library/n/Button.js | 2 +- .../n/changeHandler/SplitButton-dbg.js | 20 ++---- .../library/n/changeHandler/SplitButton.js | 2 +- .../n/designtime/Button-dbg.designtime.js | 40 ++++++------ .../library/n/designtime/Button.designtime.js | 2 +- .../library/n/designtime/Button.icon.svg | 25 +------- .../n/flexibility/Button.flexibility-dbg.js | 16 ++--- .../n/flexibility/Button.flexibility.js | 2 +- .../resources/library/n/library-dbg.js | 34 +++------- .../library/n/library-dbg.support.js | 2 +- .../resources/library/n/library.js | 2 +- .../resources/library/n/library.support.js | 2 +- .../resources/library/n/resources.json | 62 +++++++++---------- .../dest/resources/library/n/.library | 2 +- .../dest/resources/library/n/Button-dbg.js | 19 +++--- .../dest/resources/library/n/Button.js | 2 +- .../n/changeHandler/SplitButton-dbg.js | 20 ++---- .../library/n/changeHandler/SplitButton.js | 2 +- .../n/designtime/Button-dbg.designtime.js | 40 ++++++------ .../library/n/designtime/Button.designtime.js | 2 +- .../library/n/designtime/Button.icon.svg | 25 +------- .../n/flexibility/Button.flexibility-dbg.js | 16 ++--- .../n/flexibility/Button.flexibility.js | 2 +- .../dest/resources/library/n/library-dbg.js | 34 +++------- .../library/n/library-dbg.support.js | 2 +- .../dest/resources/library/n/library.js | 2 +- .../resources/library/n/library.support.js | 2 +- .../fixtures/library.n/src/library/n/.library | 2 +- .../library.n/src/library/n/Button.js | 19 +++--- .../library/n/changeHandler/SplitButton.js | 20 ++---- .../library/n/designtime/Button.designtime.js | 40 ++++++------ .../src/library/n/designtime/Button.icon.svg | 25 +------- .../n/flexibility/Button.flexibility.js | 16 ++--- .../library.n/src/library/n/library.js | 34 +++------- .../src/library/n/library.support.js | 2 +- 37 files changed, 208 insertions(+), 352 deletions(-) diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/.library b/test/expected/build/library.n/dest-resources-json/resources/library/n/.library index bb3db51ef..5969e9317 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/.library +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/.library @@ -2,7 +2,7 @@ library.n - SAP SE + The vendor UI development toolkit for HTML5 (OpenUI5) * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js index d75eb4240..158c05ca7 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js @@ -6,25 +6,24 @@ // Provides control library.N.Button. sap.ui.define([ - 'sap/ui/core/Control' + 'mylib/MyFirstClass' ], function( - Control + MyFirstClass ) { "use strict"; - return Control.extend("library.n.Button", { - renderer: { - render: function(oRm, oButton) { + return MyFirstClass.doIt("library.n.Button", { + prop: { + value: function() { // requireSync Dependency sap.ui.requireSync("library/n/changeHandler/SplitButton"); } }, - helper: function(sCalendarType) { - var sCalendar = "sap/ui/core/date/" + sCalendarType; + helper: function(sParam) { + var sDynamicDependency = "mylib/dyn/" + sParam; // dynamicDependency - sap.ui.require(["sap/ui/core/format/DateFormat", sCalendar], function(DateFormat, Calendar) { - DateFormat.getInstance(); - new Calendar(); + sap.ui.require(["mylib/MyClass", sDynamicDependency], function(MyClass, dynDep) { + new MyClass(dynDep); }); } }); diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js index 4dff24f7b..8b3031231 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["sap/ui/core/Control"],function(e){"use strict";return e.extend("library.n.Button",{renderer:{render:function(e,r){sap.ui.requireSync("library/n/changeHandler/SplitButton")}},helper:function(e){var r="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",r],function(e,r){e.getInstance();new r})}})}); \ No newline at end of file +sap.ui.define(["mylib/MyFirstClass"],function(n){"use strict";return n.doIt("library.n.Button",{prop:{value:function(){sap.ui.requireSync("library/n/changeHandler/SplitButton")}},helper:function(n){var i="mylib/dyn/"+n;sap.ui.require(["mylib/MyClass",i],function(n,i){new n(i)})}})}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js index 08302deee..a4f32df23 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js @@ -5,25 +5,17 @@ */ sap.ui.define([ - "sap/ui/core/util/reflection/JsControlTreeModifier" + "mylib/util/myUtil" ], function ( - JsControlTreeModifier + myUtil ) { "use strict"; - var ButtonCH = {}; + var SplitButton = {}; - SplitButton.applyChange = function(oChange, oControl, mPropertyBag) { - if (mPropertyBag.modifier.targets !== "jsControlTree") { - throw new Error("SplitButton change can't be applied on XML tree"); - } - return true; + SplitButton.doIt = function(param1) { + return myUtil(param1); }; - SplitButton.revertChange = function(oChange, oControl, mPropertyBag) { - oChange.resetRevertData(); - return true; - }; - - return ButtonCH; + return SplitButton; }); diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js index 4ba21a98a..be8bbba6c 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["sap/ui/core/util/reflection/JsControlTreeModifier"],function(e){"use strict";var t={};SplitButton.applyChange=function(e,t,r){if(r.modifier.targets!=="jsControlTree"){throw new Error("SplitButton change can't be applied on XML tree")}return true};SplitButton.revertChange=function(e,t,r){e.resetRevertData();return true};return t}); \ No newline at end of file +sap.ui.define(["mylib/util/myUtil"],function(t){"use strict";var i={};i.doIt=function(i){return t(i)};return i}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js index b4f1f4dc0..4542ef535 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js @@ -4,42 +4,42 @@ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -// Provides the Design Time Metadata for the library.n.Button control +// comment sap.ui.define([], function () { "use strict"; return { - palette: { - group: "ACTION", + prop1: { + val1: "string1", icons: { svg: "library/n/designtime/Button.icon.svg" } }, - actions: { - combine: { - changeType: "combineButtons", - changeOnRelevantContainer : true, - isEnabled : true + prop2: { + val1: { + myaction: "string", + myboolean : true, + myboolean2 : true }, - remove: { - changeType: "hideControl" + val2: { + myaction: "string" }, - split: { - changeType: "split" + val3: { + myaction: "foo" }, - rename: { - changeType: "rename", - domRef: function (oControl) { - return oControl.$().find(".libNBtnContent")[0]; + val4: { + myaction: "bar", + doIt: function (foo) { + return foo[0]; } }, - reveal: { - changeType: "unhideControl" + val5: { + myaction: "foo" } }, - templates: { - create: "library/n/designtime/Button.create.fragment.xml" + prop3: { + first: "mystring" } }; }); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js index 604978178..fee5587c5 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define([],function(){"use strict";return{palette:{group:"ACTION",icons:{svg:"library/n/designtime/Button.icon.svg"}},actions:{combine:{changeType:"combineButtons",changeOnRelevantContainer:true,isEnabled:true},remove:{changeType:"hideControl"},split:{changeType:"split"},rename:{changeType:"rename",domRef:function(e){return e.$().find(".libNBtnContent")[0]}},reveal:{changeType:"unhideControl"}},templates:{create:"library/n/designtime/Button.create.fragment.xml"}}}); \ No newline at end of file +sap.ui.define([],function(){"use strict";return{prop1:{val1:"string1",icons:{svg:"library/n/designtime/Button.icon.svg"}},prop2:{val1:{myaction:"string",myboolean:true,myboolean2:true},val2:{myaction:"string"},val3:{myaction:"foo"},val4:{myaction:"bar",doIt:function(n){return n[0]}},val5:{myaction:"foo"}},prop3:{first:"mystring"}}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.icon.svg b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.icon.svg index db8fc2011..876555edb 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.icon.svg +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.icon.svg @@ -1,26 +1,3 @@ - - - - - - - - - - - - - - - - - - + diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js index a22f5d6eb..2baf60c6b 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js @@ -5,18 +5,18 @@ */ sap.ui.define([ - "sap/ui/fl/changeHandler/BaseRename", + "mylib/MyRename", "../changeHandler/SplitButton" -], function (BaseRename, SplitButton) { +], function (MyRename, SplitButton) { "use strict"; return { - "hideControl": "default", - "split": SplitButton, - "rename": BaseRename.createRenameChangeHandler({ - propertyName: "text", - translationTextType: "XBUT" + "prop1": "default", + "prop2": SplitButton, + "prop3": MyRename.doIt({ + prop1: "val1", + prop2: "val2" }), - "unhideControl": "default" + "prop4": "val3" }; }); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js index 91714752b..87cc98951 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["sap/ui/fl/changeHandler/BaseRename","../changeHandler/SplitButton"],function(e,n){"use strict";return{hideControl:"default",split:n,rename:e.createRenameChangeHandler({propertyName:"text",translationTextType:"XBUT"}),unhideControl:"default"}}); \ No newline at end of file +sap.ui.define(["mylib/MyRename","../changeHandler/SplitButton"],function(p,r){"use strict";return{prop1:"default",prop2:r,prop3:p.doIt({prop1:"val1",prop2:"val2"}),prop4:"val3"}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js index be08e1816..26b3ca9d5 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js @@ -5,36 +5,20 @@ */ sap.ui.define([ - 'sap/ui/core/Core', - 'sap/ui/core/library', - 'sap/m/library' + 'mylib/Core', + 'mylib/library', + 'mob/library' ], function( Core, - coreLibrary, - mobileLibrary + Library, + mobLibrary ) { "use strict"; - // delegate further initialization of this library to the Core - sap.ui.getCore().initLibrary({ - name : "library.n", - version: "1.0.0", - dependencies : ["sap.ui.core", "sap.m"], - designtime: "library/n/designtime/library.designtime", - types: [], - interfaces: [], - controls: [], - elements: [], - extensions: { - flChangeHandlers: { - "library.n.Button": "library/n/flexibility/Button" - }, - "sap.ui.support": { - publicRules:true, - internalRules:false - } - } + // comment + Core.doIt({ + prop1 : "val1" }); - return sap.m; + return Core(Library(mobLibrary)); }); diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js index b5d45a041..402369162 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js @@ -4,7 +4,7 @@ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ sap.ui.define([ - "sap/ui/support/library", + "mylib/support/library", "./rules/Button.support" ], function( SupportLib, diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js index 9bb8f0e2f..8f8af6b88 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["sap/ui/core/Core","sap/ui/core/library","sap/m/library"],function(e,i,r){"use strict";sap.ui.getCore().initLibrary({name:"library.n",version:"1.0.0",dependencies:["sap.ui.core","sap.m"],designtime:"library/n/designtime/library.designtime",types:[],interfaces:[],controls:[],elements:[],extensions:{flChangeHandlers:{"library.n.Button":"library/n/flexibility/Button"},"sap.ui.support":{publicRules:true,internalRules:false}}});return sap.m}); \ No newline at end of file +sap.ui.define(["mylib/Core","mylib/library","mob/library"],function(r,i,b){"use strict";r.doIt({prop1:"val1"});return r(i(b))}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js index aa01ff9b5..6124e41fb 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["sap/ui/support/library","./rules/Button.support"],function(r,e){"use strict";return{name:"library.n",niceName:"Library N",ruleset:[e]}}); \ No newline at end of file +sap.ui.define(["mylib/support/library","./rules/Button.support"],function(r,e){"use strict";return{name:"library.n",niceName:"Library N",ruleset:[e]}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json b/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json index 912986bbc..89a4adfc7 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json @@ -3,56 +3,56 @@ "resources": [ { "name": ".library", - "size": 560 + "size": 564 }, { "name": "Button-dbg.js", "module": "library/n/Button.js", - "size": 786, + "size": 727, "isDebug": true, "required": [ - "sap/ui/core/Control.js" + "mylib/MyFirstClass.js" ], "condRequired": [ "library/n/changeHandler/SplitButton.js", - "sap/ui/core/format/DateFormat.js" + "mylib/MyClass.js" ], "dynRequired": true }, { "name": "Button.js", "module": "library/n/Button.js", - "size": 516, + "size": 469, "required": [ - "sap/ui/core/Control.js" + "mylib/MyFirstClass.js" ], "condRequired": [ "library/n/changeHandler/SplitButton.js", - "sap/ui/core/format/DateFormat.js" + "mylib/MyClass.js" ], "dynRequired": true }, { "name": "changeHandler/SplitButton-dbg.js", "module": "library/n/changeHandler/SplitButton.js", - "size": 701, + "size": 383, "isDebug": true, "required": [ - "sap/ui/core/util/reflection/JsControlTreeModifier.js" + "mylib/util/myUtil.js" ] }, { "name": "changeHandler/SplitButton.js", "module": "library/n/changeHandler/SplitButton.js", - "size": 533, + "size": 298, "required": [ - "sap/ui/core/util/reflection/JsControlTreeModifier.js" + "mylib/util/myUtil.js" ] }, { "name": "designtime/Button-dbg.designtime.js", "module": "library/n/designtime/Button.designtime.js", - "size": 950, + "size": 740, "isDebug": true, "designtime": true }, @@ -68,12 +68,12 @@ { "name": "designtime/Button.designtime.js", "module": "library/n/designtime/Button.designtime.js", - "size": 661, + "size": 520, "designtime": true }, { "name": "designtime/Button.icon.svg", - "size": 1386, + "size": 52, "designtime": true }, { @@ -92,62 +92,62 @@ { "name": "flexibility/Button.flexibility-dbg.js", "module": "library/n/flexibility/Button.flexibility.js", - "size": 540, + "size": 456, "isDebug": true, "required": [ "library/n/changeHandler/SplitButton.js", - "sap/ui/fl/changeHandler/BaseRename.js" + "mylib/MyRename.js" ] }, { "name": "flexibility/Button.flexibility.js", "module": "library/n/flexibility/Button.flexibility.js", - "size": 445, + "size": 365, "required": [ "library/n/changeHandler/SplitButton.js", - "sap/ui/fl/changeHandler/BaseRename.js" + "mylib/MyRename.js" ] }, { "name": "library-dbg.js", "module": "library/n/library.js", - "size": 837, + "size": 399, "isDebug": true, "required": [ - "sap/m/library.js", - "sap/ui/core/Core.js", - "sap/ui/core/library.js" + "mob/library.js", + "mylib/Core.js", + "mylib/library.js" ] }, { "name": "library-dbg.support.js", "module": "library/n/library.support.js", - "size": 417, + "size": 416, "isDebug": true, "support": true, "required": [ "library/n/rules/Button.support.js", - "sap/ui/support/library.js" + "mylib/support/library.js" ] }, { "name": "library.js", "module": "library/n/library.js", - "size": 642, + "size": 313, "required": [ - "sap/m/library.js", - "sap/ui/core/Core.js", - "sap/ui/core/library.js" + "mob/library.js", + "mylib/Core.js", + "mylib/library.js" ] }, { "name": "library.support.js", "module": "library/n/library.support.js", - "size": 338, + "size": 337, "support": true, "required": [ "library/n/rules/Button.support.js", - "sap/ui/support/library.js" + "mylib/support/library.js" ] }, { @@ -171,7 +171,7 @@ }, { "name": "resources.json", - "size": 4241 + "size": 4071 }, { "name": "rules/Button-dbg.support.js", diff --git a/test/expected/build/library.n/dest/resources/library/n/.library b/test/expected/build/library.n/dest/resources/library/n/.library index bb3db51ef..5969e9317 100644 --- a/test/expected/build/library.n/dest/resources/library/n/.library +++ b/test/expected/build/library.n/dest/resources/library/n/.library @@ -2,7 +2,7 @@ library.n - SAP SE + The vendor UI development toolkit for HTML5 (OpenUI5) * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. diff --git a/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js b/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js index d75eb4240..158c05ca7 100644 --- a/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js @@ -6,25 +6,24 @@ // Provides control library.N.Button. sap.ui.define([ - 'sap/ui/core/Control' + 'mylib/MyFirstClass' ], function( - Control + MyFirstClass ) { "use strict"; - return Control.extend("library.n.Button", { - renderer: { - render: function(oRm, oButton) { + return MyFirstClass.doIt("library.n.Button", { + prop: { + value: function() { // requireSync Dependency sap.ui.requireSync("library/n/changeHandler/SplitButton"); } }, - helper: function(sCalendarType) { - var sCalendar = "sap/ui/core/date/" + sCalendarType; + helper: function(sParam) { + var sDynamicDependency = "mylib/dyn/" + sParam; // dynamicDependency - sap.ui.require(["sap/ui/core/format/DateFormat", sCalendar], function(DateFormat, Calendar) { - DateFormat.getInstance(); - new Calendar(); + sap.ui.require(["mylib/MyClass", sDynamicDependency], function(MyClass, dynDep) { + new MyClass(dynDep); }); } }); diff --git a/test/expected/build/library.n/dest/resources/library/n/Button.js b/test/expected/build/library.n/dest/resources/library/n/Button.js index 4dff24f7b..8b3031231 100644 --- a/test/expected/build/library.n/dest/resources/library/n/Button.js +++ b/test/expected/build/library.n/dest/resources/library/n/Button.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["sap/ui/core/Control"],function(e){"use strict";return e.extend("library.n.Button",{renderer:{render:function(e,r){sap.ui.requireSync("library/n/changeHandler/SplitButton")}},helper:function(e){var r="sap/ui/core/date/"+e;sap.ui.require(["sap/ui/core/format/DateFormat",r],function(e,r){e.getInstance();new r})}})}); \ No newline at end of file +sap.ui.define(["mylib/MyFirstClass"],function(n){"use strict";return n.doIt("library.n.Button",{prop:{value:function(){sap.ui.requireSync("library/n/changeHandler/SplitButton")}},helper:function(n){var i="mylib/dyn/"+n;sap.ui.require(["mylib/MyClass",i],function(n,i){new n(i)})}})}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js index 08302deee..a4f32df23 100644 --- a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js @@ -5,25 +5,17 @@ */ sap.ui.define([ - "sap/ui/core/util/reflection/JsControlTreeModifier" + "mylib/util/myUtil" ], function ( - JsControlTreeModifier + myUtil ) { "use strict"; - var ButtonCH = {}; + var SplitButton = {}; - SplitButton.applyChange = function(oChange, oControl, mPropertyBag) { - if (mPropertyBag.modifier.targets !== "jsControlTree") { - throw new Error("SplitButton change can't be applied on XML tree"); - } - return true; + SplitButton.doIt = function(param1) { + return myUtil(param1); }; - SplitButton.revertChange = function(oChange, oControl, mPropertyBag) { - oChange.resetRevertData(); - return true; - }; - - return ButtonCH; + return SplitButton; }); diff --git a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js index 4ba21a98a..be8bbba6c 100644 --- a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js +++ b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["sap/ui/core/util/reflection/JsControlTreeModifier"],function(e){"use strict";var t={};SplitButton.applyChange=function(e,t,r){if(r.modifier.targets!=="jsControlTree"){throw new Error("SplitButton change can't be applied on XML tree")}return true};SplitButton.revertChange=function(e,t,r){e.resetRevertData();return true};return t}); \ No newline at end of file +sap.ui.define(["mylib/util/myUtil"],function(t){"use strict";var i={};i.doIt=function(i){return t(i)};return i}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js index b4f1f4dc0..4542ef535 100644 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js @@ -4,42 +4,42 @@ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -// Provides the Design Time Metadata for the library.n.Button control +// comment sap.ui.define([], function () { "use strict"; return { - palette: { - group: "ACTION", + prop1: { + val1: "string1", icons: { svg: "library/n/designtime/Button.icon.svg" } }, - actions: { - combine: { - changeType: "combineButtons", - changeOnRelevantContainer : true, - isEnabled : true + prop2: { + val1: { + myaction: "string", + myboolean : true, + myboolean2 : true }, - remove: { - changeType: "hideControl" + val2: { + myaction: "string" }, - split: { - changeType: "split" + val3: { + myaction: "foo" }, - rename: { - changeType: "rename", - domRef: function (oControl) { - return oControl.$().find(".libNBtnContent")[0]; + val4: { + myaction: "bar", + doIt: function (foo) { + return foo[0]; } }, - reveal: { - changeType: "unhideControl" + val5: { + myaction: "foo" } }, - templates: { - create: "library/n/designtime/Button.create.fragment.xml" + prop3: { + first: "mystring" } }; }); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js index 604978178..fee5587c5 100644 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define([],function(){"use strict";return{palette:{group:"ACTION",icons:{svg:"library/n/designtime/Button.icon.svg"}},actions:{combine:{changeType:"combineButtons",changeOnRelevantContainer:true,isEnabled:true},remove:{changeType:"hideControl"},split:{changeType:"split"},rename:{changeType:"rename",domRef:function(e){return e.$().find(".libNBtnContent")[0]}},reveal:{changeType:"unhideControl"}},templates:{create:"library/n/designtime/Button.create.fragment.xml"}}}); \ No newline at end of file +sap.ui.define([],function(){"use strict";return{prop1:{val1:"string1",icons:{svg:"library/n/designtime/Button.icon.svg"}},prop2:{val1:{myaction:"string",myboolean:true,myboolean2:true},val2:{myaction:"string"},val3:{myaction:"foo"},val4:{myaction:"bar",doIt:function(n){return n[0]}},val5:{myaction:"foo"}},prop3:{first:"mystring"}}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.icon.svg b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.icon.svg index db8fc2011..876555edb 100644 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.icon.svg +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.icon.svg @@ -1,26 +1,3 @@ - - - - - - - - - - - - - - - - - - + diff --git a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js index a22f5d6eb..2baf60c6b 100644 --- a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js @@ -5,18 +5,18 @@ */ sap.ui.define([ - "sap/ui/fl/changeHandler/BaseRename", + "mylib/MyRename", "../changeHandler/SplitButton" -], function (BaseRename, SplitButton) { +], function (MyRename, SplitButton) { "use strict"; return { - "hideControl": "default", - "split": SplitButton, - "rename": BaseRename.createRenameChangeHandler({ - propertyName: "text", - translationTextType: "XBUT" + "prop1": "default", + "prop2": SplitButton, + "prop3": MyRename.doIt({ + prop1: "val1", + prop2: "val2" }), - "unhideControl": "default" + "prop4": "val3" }; }); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js index 91714752b..87cc98951 100644 --- a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js +++ b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["sap/ui/fl/changeHandler/BaseRename","../changeHandler/SplitButton"],function(e,n){"use strict";return{hideControl:"default",split:n,rename:e.createRenameChangeHandler({propertyName:"text",translationTextType:"XBUT"}),unhideControl:"default"}}); \ No newline at end of file +sap.ui.define(["mylib/MyRename","../changeHandler/SplitButton"],function(p,r){"use strict";return{prop1:"default",prop2:r,prop3:p.doIt({prop1:"val1",prop2:"val2"}),prop4:"val3"}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/library-dbg.js b/test/expected/build/library.n/dest/resources/library/n/library-dbg.js index be08e1816..26b3ca9d5 100644 --- a/test/expected/build/library.n/dest/resources/library/n/library-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/library-dbg.js @@ -5,36 +5,20 @@ */ sap.ui.define([ - 'sap/ui/core/Core', - 'sap/ui/core/library', - 'sap/m/library' + 'mylib/Core', + 'mylib/library', + 'mob/library' ], function( Core, - coreLibrary, - mobileLibrary + Library, + mobLibrary ) { "use strict"; - // delegate further initialization of this library to the Core - sap.ui.getCore().initLibrary({ - name : "library.n", - version: "1.0.0", - dependencies : ["sap.ui.core", "sap.m"], - designtime: "library/n/designtime/library.designtime", - types: [], - interfaces: [], - controls: [], - elements: [], - extensions: { - flChangeHandlers: { - "library.n.Button": "library/n/flexibility/Button" - }, - "sap.ui.support": { - publicRules:true, - internalRules:false - } - } + // comment + Core.doIt({ + prop1 : "val1" }); - return sap.m; + return Core(Library(mobLibrary)); }); diff --git a/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js b/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js index b5d45a041..402369162 100644 --- a/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js +++ b/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js @@ -4,7 +4,7 @@ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ sap.ui.define([ - "sap/ui/support/library", + "mylib/support/library", "./rules/Button.support" ], function( SupportLib, diff --git a/test/expected/build/library.n/dest/resources/library/n/library.js b/test/expected/build/library.n/dest/resources/library/n/library.js index 9bb8f0e2f..8f8af6b88 100644 --- a/test/expected/build/library.n/dest/resources/library/n/library.js +++ b/test/expected/build/library.n/dest/resources/library/n/library.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["sap/ui/core/Core","sap/ui/core/library","sap/m/library"],function(e,i,r){"use strict";sap.ui.getCore().initLibrary({name:"library.n",version:"1.0.0",dependencies:["sap.ui.core","sap.m"],designtime:"library/n/designtime/library.designtime",types:[],interfaces:[],controls:[],elements:[],extensions:{flChangeHandlers:{"library.n.Button":"library/n/flexibility/Button"},"sap.ui.support":{publicRules:true,internalRules:false}}});return sap.m}); \ No newline at end of file +sap.ui.define(["mylib/Core","mylib/library","mob/library"],function(r,i,b){"use strict";r.doIt({prop1:"val1"});return r(i(b))}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/library.support.js b/test/expected/build/library.n/dest/resources/library/n/library.support.js index aa01ff9b5..6124e41fb 100644 --- a/test/expected/build/library.n/dest/resources/library/n/library.support.js +++ b/test/expected/build/library.n/dest/resources/library/n/library.support.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["sap/ui/support/library","./rules/Button.support"],function(r,e){"use strict";return{name:"library.n",niceName:"Library N",ruleset:[e]}}); \ No newline at end of file +sap.ui.define(["mylib/support/library","./rules/Button.support"],function(r,e){"use strict";return{name:"library.n",niceName:"Library N",ruleset:[e]}}); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/.library b/test/fixtures/library.n/src/library/n/.library index 02ec88b73..27c1610a7 100644 --- a/test/fixtures/library.n/src/library/n/.library +++ b/test/fixtures/library.n/src/library/n/.library @@ -2,7 +2,7 @@ library.n - SAP SE + The vendor ${copyright} ${version} diff --git a/test/fixtures/library.n/src/library/n/Button.js b/test/fixtures/library.n/src/library/n/Button.js index 29599a350..7de7455c6 100644 --- a/test/fixtures/library.n/src/library/n/Button.js +++ b/test/fixtures/library.n/src/library/n/Button.js @@ -4,25 +4,24 @@ // Provides control library.N.Button. sap.ui.define([ - 'sap/ui/core/Control' + 'mylib/MyFirstClass' ], function( - Control + MyFirstClass ) { "use strict"; - return Control.extend("library.n.Button", { - renderer: { - render: function(oRm, oButton) { + return MyFirstClass.doIt("library.n.Button", { + prop: { + value: function() { // requireSync Dependency sap.ui.requireSync("library/n/changeHandler/SplitButton"); } }, - helper: function(sCalendarType) { - var sCalendar = "sap/ui/core/date/" + sCalendarType; + helper: function(sParam) { + var sDynamicDependency = "mylib/dyn/" + sParam; // dynamicDependency - sap.ui.require(["sap/ui/core/format/DateFormat", sCalendar], function(DateFormat, Calendar) { - DateFormat.getInstance(); - new Calendar(); + sap.ui.require(["mylib/MyClass", sDynamicDependency], function(MyClass, dynDep) { + new MyClass(dynDep); }); } }); diff --git a/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js b/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js index f42a60c9e..27693aaad 100644 --- a/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js +++ b/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js @@ -3,25 +3,17 @@ */ sap.ui.define([ - "sap/ui/core/util/reflection/JsControlTreeModifier" + "mylib/util/myUtil" ], function ( - JsControlTreeModifier + myUtil ) { "use strict"; - var ButtonCH = {}; + var SplitButton = {}; - SplitButton.applyChange = function(oChange, oControl, mPropertyBag) { - if (mPropertyBag.modifier.targets !== "jsControlTree") { - throw new Error("SplitButton change can't be applied on XML tree"); - } - return true; + SplitButton.doIt = function(param1) { + return myUtil(param1); }; - SplitButton.revertChange = function(oChange, oControl, mPropertyBag) { - oChange.resetRevertData(); - return true; - }; - - return ButtonCH; + return SplitButton; }); diff --git a/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js b/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js index d6d669833..ef631d9c1 100644 --- a/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js +++ b/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js @@ -2,42 +2,42 @@ * ${copyright} */ -// Provides the Design Time Metadata for the library.n.Button control +// comment sap.ui.define([], function () { "use strict"; return { - palette: { - group: "ACTION", + prop1: { + val1: "string1", icons: { svg: "library/n/designtime/Button.icon.svg" } }, - actions: { - combine: { - changeType: "combineButtons", - changeOnRelevantContainer : true, - isEnabled : true + prop2: { + val1: { + myaction: "string", + myboolean : true, + myboolean2 : true }, - remove: { - changeType: "hideControl" + val2: { + myaction: "string" }, - split: { - changeType: "split" + val3: { + myaction: "foo" }, - rename: { - changeType: "rename", - domRef: function (oControl) { - return oControl.$().find(".libNBtnContent")[0]; + val4: { + myaction: "bar", + doIt: function (foo) { + return foo[0]; } }, - reveal: { - changeType: "unhideControl" + val5: { + myaction: "foo" } }, - templates: { - create: "library/n/designtime/Button.create.fragment.xml" + prop3: { + first: "mystring" } }; }); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/designtime/Button.icon.svg b/test/fixtures/library.n/src/library/n/designtime/Button.icon.svg index db8fc2011..876555edb 100644 --- a/test/fixtures/library.n/src/library/n/designtime/Button.icon.svg +++ b/test/fixtures/library.n/src/library/n/designtime/Button.icon.svg @@ -1,26 +1,3 @@ - - - - - - - - - - - - - - - - - - + diff --git a/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js b/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js index bbce17aea..39a4ef05a 100644 --- a/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js +++ b/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js @@ -3,18 +3,18 @@ */ sap.ui.define([ - "sap/ui/fl/changeHandler/BaseRename", + "mylib/MyRename", "../changeHandler/SplitButton" -], function (BaseRename, SplitButton) { +], function (MyRename, SplitButton) { "use strict"; return { - "hideControl": "default", - "split": SplitButton, - "rename": BaseRename.createRenameChangeHandler({ - propertyName: "text", - translationTextType: "XBUT" + "prop1": "default", + "prop2": SplitButton, + "prop3": MyRename.doIt({ + prop1: "val1", + prop2: "val2" }), - "unhideControl": "default" + "prop4": "val3" }; }); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/library.js b/test/fixtures/library.n/src/library/n/library.js index 292583ba1..2dd578d44 100644 --- a/test/fixtures/library.n/src/library/n/library.js +++ b/test/fixtures/library.n/src/library/n/library.js @@ -3,36 +3,20 @@ */ sap.ui.define([ - 'sap/ui/core/Core', - 'sap/ui/core/library', - 'sap/m/library' + 'mylib/Core', + 'mylib/library', + 'mob/library' ], function( Core, - coreLibrary, - mobileLibrary + Library, + mobLibrary ) { "use strict"; - // delegate further initialization of this library to the Core - sap.ui.getCore().initLibrary({ - name : "library.n", - version: "${version}", - dependencies : ["sap.ui.core", "sap.m"], - designtime: "library/n/designtime/library.designtime", - types: [], - interfaces: [], - controls: [], - elements: [], - extensions: { - flChangeHandlers: { - "library.n.Button": "library/n/flexibility/Button" - }, - "sap.ui.support": { - publicRules:true, - internalRules:false - } - } + // comment + Core.doIt({ + prop1 : "val1" }); - return sap.m; + return Core(Library(mobLibrary)); }); diff --git a/test/fixtures/library.n/src/library/n/library.support.js b/test/fixtures/library.n/src/library/n/library.support.js index 634d4fa8f..a6e72323e 100644 --- a/test/fixtures/library.n/src/library/n/library.support.js +++ b/test/fixtures/library.n/src/library/n/library.support.js @@ -2,7 +2,7 @@ * ${copyright} */ sap.ui.define([ - "sap/ui/support/library", + "mylib/support/library", "./rules/Button.support" ], function( SupportLib, From b731011c19417b6164263e9aaea8a706f8f3363c Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 13 Aug 2020 14:37:15 +0200 Subject: [PATCH 77/88] Reduced test files to the essential --- .../n/changeHandler/SplitButton-dbg.js | 9 +--- .../library/n/changeHandler/SplitButton.js | 2 +- .../n/designtime/Button-dbg.designtime.js | 42 ++----------------- .../library/n/designtime/Button.designtime.js | 2 +- .../n/flexibility/Button.flexibility-dbg.js | 7 +--- .../n/flexibility/Button.flexibility.js | 2 +- .../resources/library/n/library-dbg.js | 12 ++---- .../library/n/library-dbg.support.js | 17 ++------ .../resources/library/n/library.js | 2 +- .../resources/library/n/library.support.js | 2 +- .../resources/library/n/resources.json | 26 ++++++------ .../n/changeHandler/SplitButton-dbg.js | 9 +--- .../library/n/changeHandler/SplitButton.js | 2 +- .../n/designtime/Button-dbg.designtime.js | 42 ++----------------- .../library/n/designtime/Button.designtime.js | 2 +- .../n/flexibility/Button.flexibility-dbg.js | 7 +--- .../n/flexibility/Button.flexibility.js | 2 +- .../dest/resources/library/n/library-dbg.js | 12 ++---- .../library/n/library-dbg.support.js | 17 ++------ .../dest/resources/library/n/library.js | 2 +- .../resources/library/n/library.support.js | 2 +- .../library/n/changeHandler/SplitButton.js | 9 +--- .../library/n/designtime/Button.designtime.js | 42 ++----------------- .../n/flexibility/Button.flexibility.js | 7 +--- .../library.n/src/library/n/library.js | 12 ++---- .../src/library/n/library.support.js | 17 ++------ 26 files changed, 59 insertions(+), 248 deletions(-) diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js index a4f32df23..fe015e4a2 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js @@ -10,12 +10,5 @@ sap.ui.define([ myUtil ) { "use strict"; - - var SplitButton = {}; - - SplitButton.doIt = function(param1) { - return myUtil(param1); - }; - - return SplitButton; + return myUtil(47); }); diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js index be8bbba6c..64f3b03fc 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["mylib/util/myUtil"],function(t){"use strict";var i={};i.doIt=function(i){return t(i)};return i}); \ No newline at end of file +sap.ui.define(["mylib/util/myUtil"],function(i){"use strict";return i(47)}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js index 4542ef535..e3390389b 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js @@ -4,42 +4,8 @@ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -// comment -sap.ui.define([], - function () { - "use strict"; +sap.ui.define([], function () { + "use strict"; - return { - prop1: { - val1: "string1", - icons: { - svg: "library/n/designtime/Button.icon.svg" - } - }, - prop2: { - val1: { - myaction: "string", - myboolean : true, - myboolean2 : true - }, - val2: { - myaction: "string" - }, - val3: { - myaction: "foo" - }, - val4: { - myaction: "bar", - doIt: function (foo) { - return foo[0]; - } - }, - val5: { - myaction: "foo" - } - }, - prop3: { - first: "mystring" - } - }; - }); \ No newline at end of file + return {}; +}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js index fee5587c5..2e8bb38c4 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define([],function(){"use strict";return{prop1:{val1:"string1",icons:{svg:"library/n/designtime/Button.icon.svg"}},prop2:{val1:{myaction:"string",myboolean:true,myboolean2:true},val2:{myaction:"string"},val3:{myaction:"foo"},val4:{myaction:"bar",doIt:function(n){return n[0]}},val5:{myaction:"foo"}},prop3:{first:"mystring"}}}); \ No newline at end of file +sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js index 2baf60c6b..efae309d8 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js @@ -11,12 +11,7 @@ sap.ui.define([ "use strict"; return { - "prop1": "default", "prop2": SplitButton, - "prop3": MyRename.doIt({ - prop1: "val1", - prop2: "val2" - }), - "prop4": "val3" + "prop3": MyRename.doIt(), }; }); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js index 87cc98951..db2101b01 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["mylib/MyRename","../changeHandler/SplitButton"],function(p,r){"use strict";return{prop1:"default",prop2:r,prop3:p.doIt({prop1:"val1",prop2:"val2"}),prop4:"val3"}}); \ No newline at end of file +sap.ui.define(["mylib/MyRename","../changeHandler/SplitButton"],function(e,n){"use strict";return{prop2:n,prop3:e.doIt()}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js index 26b3ca9d5..c1f1b4939 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js @@ -5,20 +5,14 @@ */ sap.ui.define([ - 'mylib/Core', + 'mylib/MyClass', 'mylib/library', 'mob/library' ], function( - Core, + MyClass, Library, mobLibrary ) { "use strict"; - - // comment - Core.doIt({ - prop1 : "val1" - }); - - return Core(Library(mobLibrary)); + return MyClass(Library(mobLibrary)); }); diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js index 402369162..cd380747e 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js @@ -6,18 +6,7 @@ sap.ui.define([ "mylib/support/library", "./rules/Button.support" -], function( - SupportLib, - ButtonSupport, - ) { +], function(SupportLib, ButtonSupport) { "use strict"; - - return { - name: "library.n", - niceName: "Library N", - ruleset: [ - ButtonSupport - ] - }; - -}); \ No newline at end of file + return SupportLib(ButtonSupport); +}); diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js index 8f8af6b88..3bf993b68 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["mylib/Core","mylib/library","mob/library"],function(r,i,b){"use strict";r.doIt({prop1:"val1"});return r(i(b))}); \ No newline at end of file +sap.ui.define(["mylib/MyClass","mylib/library","mob/library"],function(i,r,b){"use strict";return i(r(b))}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js index 6124e41fb..4e4805d34 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["mylib/support/library","./rules/Button.support"],function(r,e){"use strict";return{name:"library.n",niceName:"Library N",ruleset:[e]}}); \ No newline at end of file +sap.ui.define(["mylib/support/library","./rules/Button.support"],function(r,t){"use strict";return r(t)}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json b/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json index 89a4adfc7..876cd834c 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json @@ -35,7 +35,7 @@ { "name": "changeHandler/SplitButton-dbg.js", "module": "library/n/changeHandler/SplitButton.js", - "size": 383, + "size": 288, "isDebug": true, "required": [ "mylib/util/myUtil.js" @@ -44,7 +44,7 @@ { "name": "changeHandler/SplitButton.js", "module": "library/n/changeHandler/SplitButton.js", - "size": 298, + "size": 261, "required": [ "mylib/util/myUtil.js" ] @@ -52,7 +52,7 @@ { "name": "designtime/Button-dbg.designtime.js", "module": "library/n/designtime/Button.designtime.js", - "size": 740, + "size": 249, "isDebug": true, "designtime": true }, @@ -68,7 +68,7 @@ { "name": "designtime/Button.designtime.js", "module": "library/n/designtime/Button.designtime.js", - "size": 520, + "size": 237, "designtime": true }, { @@ -92,7 +92,7 @@ { "name": "flexibility/Button.flexibility-dbg.js", "module": "library/n/flexibility/Button.flexibility.js", - "size": 456, + "size": 376, "isDebug": true, "required": [ "library/n/changeHandler/SplitButton.js", @@ -102,7 +102,7 @@ { "name": "flexibility/Button.flexibility.js", "module": "library/n/flexibility/Button.flexibility.js", - "size": 365, + "size": 309, "required": [ "library/n/changeHandler/SplitButton.js", "mylib/MyRename.js" @@ -111,18 +111,18 @@ { "name": "library-dbg.js", "module": "library/n/library.js", - "size": 399, + "size": 359, "isDebug": true, "required": [ "mob/library.js", - "mylib/Core.js", + "mylib/MyClass.js", "mylib/library.js" ] }, { "name": "library-dbg.support.js", "module": "library/n/library.support.js", - "size": 416, + "size": 348, "isDebug": true, "support": true, "required": [ @@ -133,17 +133,17 @@ { "name": "library.js", "module": "library/n/library.js", - "size": 313, + "size": 293, "required": [ "mob/library.js", - "mylib/Core.js", + "mylib/MyClass.js", "mylib/library.js" ] }, { "name": "library.support.js", "module": "library/n/library.support.js", - "size": 337, + "size": 291, "support": true, "required": [ "library/n/rules/Button.support.js", @@ -171,7 +171,7 @@ }, { "name": "resources.json", - "size": 4071 + "size": 4077 }, { "name": "rules/Button-dbg.support.js", diff --git a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js index a4f32df23..fe015e4a2 100644 --- a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js @@ -10,12 +10,5 @@ sap.ui.define([ myUtil ) { "use strict"; - - var SplitButton = {}; - - SplitButton.doIt = function(param1) { - return myUtil(param1); - }; - - return SplitButton; + return myUtil(47); }); diff --git a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js index be8bbba6c..64f3b03fc 100644 --- a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js +++ b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["mylib/util/myUtil"],function(t){"use strict";var i={};i.doIt=function(i){return t(i)};return i}); \ No newline at end of file +sap.ui.define(["mylib/util/myUtil"],function(i){"use strict";return i(47)}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js index 4542ef535..e3390389b 100644 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js @@ -4,42 +4,8 @@ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -// comment -sap.ui.define([], - function () { - "use strict"; +sap.ui.define([], function () { + "use strict"; - return { - prop1: { - val1: "string1", - icons: { - svg: "library/n/designtime/Button.icon.svg" - } - }, - prop2: { - val1: { - myaction: "string", - myboolean : true, - myboolean2 : true - }, - val2: { - myaction: "string" - }, - val3: { - myaction: "foo" - }, - val4: { - myaction: "bar", - doIt: function (foo) { - return foo[0]; - } - }, - val5: { - myaction: "foo" - } - }, - prop3: { - first: "mystring" - } - }; - }); \ No newline at end of file + return {}; +}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js index fee5587c5..2e8bb38c4 100644 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define([],function(){"use strict";return{prop1:{val1:"string1",icons:{svg:"library/n/designtime/Button.icon.svg"}},prop2:{val1:{myaction:"string",myboolean:true,myboolean2:true},val2:{myaction:"string"},val3:{myaction:"foo"},val4:{myaction:"bar",doIt:function(n){return n[0]}},val5:{myaction:"foo"}},prop3:{first:"mystring"}}}); \ No newline at end of file +sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js index 2baf60c6b..efae309d8 100644 --- a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js @@ -11,12 +11,7 @@ sap.ui.define([ "use strict"; return { - "prop1": "default", "prop2": SplitButton, - "prop3": MyRename.doIt({ - prop1: "val1", - prop2: "val2" - }), - "prop4": "val3" + "prop3": MyRename.doIt(), }; }); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js index 87cc98951..db2101b01 100644 --- a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js +++ b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["mylib/MyRename","../changeHandler/SplitButton"],function(p,r){"use strict";return{prop1:"default",prop2:r,prop3:p.doIt({prop1:"val1",prop2:"val2"}),prop4:"val3"}}); \ No newline at end of file +sap.ui.define(["mylib/MyRename","../changeHandler/SplitButton"],function(e,n){"use strict";return{prop2:n,prop3:e.doIt()}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/library-dbg.js b/test/expected/build/library.n/dest/resources/library/n/library-dbg.js index 26b3ca9d5..c1f1b4939 100644 --- a/test/expected/build/library.n/dest/resources/library/n/library-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/library-dbg.js @@ -5,20 +5,14 @@ */ sap.ui.define([ - 'mylib/Core', + 'mylib/MyClass', 'mylib/library', 'mob/library' ], function( - Core, + MyClass, Library, mobLibrary ) { "use strict"; - - // comment - Core.doIt({ - prop1 : "val1" - }); - - return Core(Library(mobLibrary)); + return MyClass(Library(mobLibrary)); }); diff --git a/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js b/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js index 402369162..cd380747e 100644 --- a/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js +++ b/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js @@ -6,18 +6,7 @@ sap.ui.define([ "mylib/support/library", "./rules/Button.support" -], function( - SupportLib, - ButtonSupport, - ) { +], function(SupportLib, ButtonSupport) { "use strict"; - - return { - name: "library.n", - niceName: "Library N", - ruleset: [ - ButtonSupport - ] - }; - -}); \ No newline at end of file + return SupportLib(ButtonSupport); +}); diff --git a/test/expected/build/library.n/dest/resources/library/n/library.js b/test/expected/build/library.n/dest/resources/library/n/library.js index 8f8af6b88..3bf993b68 100644 --- a/test/expected/build/library.n/dest/resources/library/n/library.js +++ b/test/expected/build/library.n/dest/resources/library/n/library.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["mylib/Core","mylib/library","mob/library"],function(r,i,b){"use strict";r.doIt({prop1:"val1"});return r(i(b))}); \ No newline at end of file +sap.ui.define(["mylib/MyClass","mylib/library","mob/library"],function(i,r,b){"use strict";return i(r(b))}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/library.support.js b/test/expected/build/library.n/dest/resources/library/n/library.support.js index 6124e41fb..4e4805d34 100644 --- a/test/expected/build/library.n/dest/resources/library/n/library.support.js +++ b/test/expected/build/library.n/dest/resources/library/n/library.support.js @@ -3,4 +3,4 @@ * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. */ -sap.ui.define(["mylib/support/library","./rules/Button.support"],function(r,e){"use strict";return{name:"library.n",niceName:"Library N",ruleset:[e]}}); \ No newline at end of file +sap.ui.define(["mylib/support/library","./rules/Button.support"],function(r,t){"use strict";return r(t)}); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js b/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js index 27693aaad..87d08f403 100644 --- a/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js +++ b/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js @@ -8,12 +8,5 @@ sap.ui.define([ myUtil ) { "use strict"; - - var SplitButton = {}; - - SplitButton.doIt = function(param1) { - return myUtil(param1); - }; - - return SplitButton; + return myUtil(47); }); diff --git a/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js b/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js index ef631d9c1..ff8f6d738 100644 --- a/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js +++ b/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js @@ -2,42 +2,8 @@ * ${copyright} */ -// comment -sap.ui.define([], - function () { - "use strict"; +sap.ui.define([], function () { + "use strict"; - return { - prop1: { - val1: "string1", - icons: { - svg: "library/n/designtime/Button.icon.svg" - } - }, - prop2: { - val1: { - myaction: "string", - myboolean : true, - myboolean2 : true - }, - val2: { - myaction: "string" - }, - val3: { - myaction: "foo" - }, - val4: { - myaction: "bar", - doIt: function (foo) { - return foo[0]; - } - }, - val5: { - myaction: "foo" - } - }, - prop3: { - first: "mystring" - } - }; - }); \ No newline at end of file + return {}; +}); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js b/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js index 39a4ef05a..717045832 100644 --- a/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js +++ b/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js @@ -9,12 +9,7 @@ sap.ui.define([ "use strict"; return { - "prop1": "default", "prop2": SplitButton, - "prop3": MyRename.doIt({ - prop1: "val1", - prop2: "val2" - }), - "prop4": "val3" + "prop3": MyRename.doIt(), }; }); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/library.js b/test/fixtures/library.n/src/library/n/library.js index 2dd578d44..b6253c59d 100644 --- a/test/fixtures/library.n/src/library/n/library.js +++ b/test/fixtures/library.n/src/library/n/library.js @@ -3,20 +3,14 @@ */ sap.ui.define([ - 'mylib/Core', + 'mylib/MyClass', 'mylib/library', 'mob/library' ], function( - Core, + MyClass, Library, mobLibrary ) { "use strict"; - - // comment - Core.doIt({ - prop1 : "val1" - }); - - return Core(Library(mobLibrary)); + return MyClass(Library(mobLibrary)); }); diff --git a/test/fixtures/library.n/src/library/n/library.support.js b/test/fixtures/library.n/src/library/n/library.support.js index a6e72323e..a425f747d 100644 --- a/test/fixtures/library.n/src/library/n/library.support.js +++ b/test/fixtures/library.n/src/library/n/library.support.js @@ -4,18 +4,7 @@ sap.ui.define([ "mylib/support/library", "./rules/Button.support" -], function( - SupportLib, - ButtonSupport, - ) { +], function(SupportLib, ButtonSupport) { "use strict"; - - return { - name: "library.n", - niceName: "Library N", - ruleset: [ - ButtonSupport - ] - }; - -}); \ No newline at end of file + return SupportLib(ButtonSupport); +}); From 86bd41eed2129bcad679eab1b62a6dccb9953125 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 13 Aug 2020 16:56:22 +0200 Subject: [PATCH 78/88] Used simple copyright statement for test files --- .../resources/library/n/.library | 4 +-- .../resources/library/n/Button-dbg.js | 4 +-- .../resources/library/n/Button.js | 4 +-- .../n/changeHandler/SplitButton-dbg.js | 4 +-- .../library/n/changeHandler/SplitButton.js | 4 +-- .../n/designtime/Button-dbg.designtime.js | 4 +-- .../library/n/designtime/Button.designtime.js | 4 +-- .../n/designtime/library-dbg.designtime.js | 4 +-- .../n/designtime/library.designtime.js | 4 +-- .../n/flexibility/Button.flexibility-dbg.js | 4 +-- .../n/flexibility/Button.flexibility.js | 4 +-- .../resources/library/n/library-dbg.js | 4 +-- .../library/n/library-dbg.support.js | 4 +-- .../resources/library/n/library.js | 4 +-- .../resources/library/n/library.support.js | 4 +-- .../resources/library/n/resources.json | 36 +++++++++---------- .../library/n/rules/Button-dbg.support.js | 4 +-- .../library/n/rules/Button.support.js | 4 +-- .../dest/resources/library/n/.library | 4 +-- .../dest/resources/library/n/Button-dbg.js | 4 +-- .../dest/resources/library/n/Button.js | 4 +-- .../n/changeHandler/SplitButton-dbg.js | 4 +-- .../library/n/changeHandler/SplitButton.js | 4 +-- .../n/designtime/Button-dbg.designtime.js | 4 +-- .../library/n/designtime/Button.designtime.js | 4 +-- .../n/designtime/library-dbg.designtime.js | 4 +-- .../n/designtime/library.designtime.js | 4 +-- .../n/flexibility/Button.flexibility-dbg.js | 4 +-- .../n/flexibility/Button.flexibility.js | 4 +-- .../dest/resources/library/n/library-dbg.js | 4 +-- .../library/n/library-dbg.support.js | 4 +-- .../dest/resources/library/n/library.js | 4 +-- .../resources/library/n/library.support.js | 4 +-- .../library/n/rules/Button-dbg.support.js | 4 +-- .../library/n/rules/Button.support.js | 4 +-- test/lib/builder/builder.js | 2 +- 36 files changed, 53 insertions(+), 121 deletions(-) diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/.library b/test/expected/build/library.n/dest-resources-json/resources/library/n/.library index 5969e9317..e9a6cb76d 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/.library +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/.library @@ -3,9 +3,7 @@ library.n The vendor - UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + some fancy copyright 1.0.0 Library N diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js index 158c05ca7..4160f7c70 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ // Provides control library.N.Button. diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js index 8b3031231..e50dcc825 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define(["mylib/MyFirstClass"],function(n){"use strict";return n.doIt("library.n.Button",{prop:{value:function(){sap.ui.requireSync("library/n/changeHandler/SplitButton")}},helper:function(n){var i="mylib/dyn/"+n;sap.ui.require(["mylib/MyClass",i],function(n,i){new n(i)})}})}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js index fe015e4a2..7f8efd2ce 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([ diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js index 64f3b03fc..138859296 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define(["mylib/util/myUtil"],function(i){"use strict";return i(47)}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js index e3390389b..45cbb921d 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([], function () { diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js index 2e8bb38c4..502fdec4c 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library-dbg.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library-dbg.designtime.js index 723a087bd..c08b12955 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library-dbg.designtime.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library-dbg.designtime.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([], function() { diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library.designtime.js index 2e8bb38c4..502fdec4c 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library.designtime.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library.designtime.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js index efae309d8..f0d8fbdaf 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([ diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js index db2101b01..ae9ace973 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define(["mylib/MyRename","../changeHandler/SplitButton"],function(e,n){"use strict";return{prop2:n,prop3:e.doIt()}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js index c1f1b4939..890312530 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([ diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js index cd380747e..8c5242469 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([ "mylib/support/library", diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js index 3bf993b68..5f4deed84 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define(["mylib/MyClass","mylib/library","mob/library"],function(i,r,b){"use strict";return i(r(b))}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js index 4e4805d34..520a48601 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define(["mylib/support/library","./rules/Button.support"],function(r,t){"use strict";return r(t)}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json b/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json index 876cd834c..ec9a045fd 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json @@ -3,12 +3,12 @@ "resources": [ { "name": ".library", - "size": 564 + "size": 411 }, { "name": "Button-dbg.js", "module": "library/n/Button.js", - "size": 727, + "size": 574, "isDebug": true, "required": [ "mylib/MyFirstClass.js" @@ -22,7 +22,7 @@ { "name": "Button.js", "module": "library/n/Button.js", - "size": 469, + "size": 316, "required": [ "mylib/MyFirstClass.js" ], @@ -35,7 +35,7 @@ { "name": "changeHandler/SplitButton-dbg.js", "module": "library/n/changeHandler/SplitButton.js", - "size": 288, + "size": 135, "isDebug": true, "required": [ "mylib/util/myUtil.js" @@ -44,7 +44,7 @@ { "name": "changeHandler/SplitButton.js", "module": "library/n/changeHandler/SplitButton.js", - "size": 261, + "size": 108, "required": [ "mylib/util/myUtil.js" ] @@ -52,7 +52,7 @@ { "name": "designtime/Button-dbg.designtime.js", "module": "library/n/designtime/Button.designtime.js", - "size": 249, + "size": 96, "isDebug": true, "designtime": true }, @@ -68,7 +68,7 @@ { "name": "designtime/Button.designtime.js", "module": "library/n/designtime/Button.designtime.js", - "size": 237, + "size": 84, "designtime": true }, { @@ -79,20 +79,20 @@ { "name": "designtime/library-dbg.designtime.js", "module": "library/n/designtime/library.designtime.js", - "size": 247, + "size": 94, "isDebug": true, "designtime": true }, { "name": "designtime/library.designtime.js", "module": "library/n/designtime/library.designtime.js", - "size": 237, + "size": 84, "designtime": true }, { "name": "flexibility/Button.flexibility-dbg.js", "module": "library/n/flexibility/Button.flexibility.js", - "size": 376, + "size": 223, "isDebug": true, "required": [ "library/n/changeHandler/SplitButton.js", @@ -102,7 +102,7 @@ { "name": "flexibility/Button.flexibility.js", "module": "library/n/flexibility/Button.flexibility.js", - "size": 309, + "size": 156, "required": [ "library/n/changeHandler/SplitButton.js", "mylib/MyRename.js" @@ -111,7 +111,7 @@ { "name": "library-dbg.js", "module": "library/n/library.js", - "size": 359, + "size": 206, "isDebug": true, "required": [ "mob/library.js", @@ -122,7 +122,7 @@ { "name": "library-dbg.support.js", "module": "library/n/library.support.js", - "size": 348, + "size": 195, "isDebug": true, "support": true, "required": [ @@ -133,7 +133,7 @@ { "name": "library.js", "module": "library/n/library.js", - "size": 293, + "size": 140, "required": [ "mob/library.js", "mylib/MyClass.js", @@ -143,7 +143,7 @@ { "name": "library.support.js", "module": "library/n/library.support.js", - "size": 291, + "size": 138, "support": true, "required": [ "library/n/rules/Button.support.js", @@ -171,12 +171,12 @@ }, { "name": "resources.json", - "size": 4077 + "size": 4071 }, { "name": "rules/Button-dbg.support.js", "module": "library/n/rules/Button.support.js", - "size": 211, + "size": 58, "format": "raw", "isDebug": true, "support": true @@ -184,7 +184,7 @@ { "name": "rules/Button.support.js", "module": "library/n/rules/Button.support.js", - "size": 211, + "size": 58, "format": "raw", "support": true } diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button-dbg.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button-dbg.support.js index dc9e1fc91..566c6fa91 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button-dbg.support.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button-dbg.support.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ console.log('HelloWorld'); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button.support.js index 39e3277ce..50fac1a94 100644 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button.support.js +++ b/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button.support.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ console.log("HelloWorld"); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/.library b/test/expected/build/library.n/dest/resources/library/n/.library index 5969e9317..e9a6cb76d 100644 --- a/test/expected/build/library.n/dest/resources/library/n/.library +++ b/test/expected/build/library.n/dest/resources/library/n/.library @@ -3,9 +3,7 @@ library.n The vendor - UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + some fancy copyright 1.0.0 Library N diff --git a/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js b/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js index 158c05ca7..4160f7c70 100644 --- a/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ // Provides control library.N.Button. diff --git a/test/expected/build/library.n/dest/resources/library/n/Button.js b/test/expected/build/library.n/dest/resources/library/n/Button.js index 8b3031231..e50dcc825 100644 --- a/test/expected/build/library.n/dest/resources/library/n/Button.js +++ b/test/expected/build/library.n/dest/resources/library/n/Button.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define(["mylib/MyFirstClass"],function(n){"use strict";return n.doIt("library.n.Button",{prop:{value:function(){sap.ui.requireSync("library/n/changeHandler/SplitButton")}},helper:function(n){var i="mylib/dyn/"+n;sap.ui.require(["mylib/MyClass",i],function(n,i){new n(i)})}})}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js index fe015e4a2..7f8efd2ce 100644 --- a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([ diff --git a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js index 64f3b03fc..138859296 100644 --- a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js +++ b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define(["mylib/util/myUtil"],function(i){"use strict";return i(47)}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js index e3390389b..45cbb921d 100644 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([], function () { diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js index 2e8bb38c4..502fdec4c 100644 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/library-dbg.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/library-dbg.designtime.js index 723a087bd..c08b12955 100644 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/library-dbg.designtime.js +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/library-dbg.designtime.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([], function() { diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/library.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/library.designtime.js index 2e8bb38c4..502fdec4c 100644 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/library.designtime.js +++ b/test/expected/build/library.n/dest/resources/library/n/designtime/library.designtime.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js index efae309d8..f0d8fbdaf 100644 --- a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([ diff --git a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js index db2101b01..ae9ace973 100644 --- a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js +++ b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define(["mylib/MyRename","../changeHandler/SplitButton"],function(e,n){"use strict";return{prop2:n,prop3:e.doIt()}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/library-dbg.js b/test/expected/build/library.n/dest/resources/library/n/library-dbg.js index c1f1b4939..890312530 100644 --- a/test/expected/build/library.n/dest/resources/library/n/library-dbg.js +++ b/test/expected/build/library.n/dest/resources/library/n/library-dbg.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([ diff --git a/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js b/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js index cd380747e..8c5242469 100644 --- a/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js +++ b/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js @@ -1,7 +1,5 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define([ "mylib/support/library", diff --git a/test/expected/build/library.n/dest/resources/library/n/library.js b/test/expected/build/library.n/dest/resources/library/n/library.js index 3bf993b68..5f4deed84 100644 --- a/test/expected/build/library.n/dest/resources/library/n/library.js +++ b/test/expected/build/library.n/dest/resources/library/n/library.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define(["mylib/MyClass","mylib/library","mob/library"],function(i,r,b){"use strict";return i(r(b))}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/library.support.js b/test/expected/build/library.n/dest/resources/library/n/library.support.js index 4e4805d34..520a48601 100644 --- a/test/expected/build/library.n/dest/resources/library/n/library.support.js +++ b/test/expected/build/library.n/dest/resources/library/n/library.support.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ sap.ui.define(["mylib/support/library","./rules/Button.support"],function(r,t){"use strict";return r(t)}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/rules/Button-dbg.support.js b/test/expected/build/library.n/dest/resources/library/n/rules/Button-dbg.support.js index dc9e1fc91..566c6fa91 100644 --- a/test/expected/build/library.n/dest/resources/library/n/rules/Button-dbg.support.js +++ b/test/expected/build/library.n/dest/resources/library/n/rules/Button-dbg.support.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ console.log('HelloWorld'); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/rules/Button.support.js b/test/expected/build/library.n/dest/resources/library/n/rules/Button.support.js index 39e3277ce..50fac1a94 100644 --- a/test/expected/build/library.n/dest/resources/library/n/rules/Button.support.js +++ b/test/expected/build/library.n/dest/resources/library/n/rules/Button.support.js @@ -1,6 +1,4 @@ /*! - * UI development toolkit for HTML5 (OpenUI5) - * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company. - * Licensed under the Apache License, Version 2.0 - see LICENSE.txt. + * some fancy copyright */ console.log("HelloWorld"); \ No newline at end of file diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index 601a1202d..c1a1bff3a 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -1488,7 +1488,7 @@ const libraryNTree = { "metadata": { "name": "library.n", "namespace": "library/n", - "copyright": "UI development toolkit for HTML5 (OpenUI5)\n * (c) Copyright 2009-xxx SAP SE or an SAP affiliate company.\n * Licensed under the Apache License, Version 2.0 - see LICENSE.txt." + "copyright": "some fancy copyright" }, "resources": { "configuration": { From 176d76f1cd090d087edc6a6bfe51fd723210e9aa Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 13 Aug 2020 17:02:12 +0200 Subject: [PATCH 79/88] Used simple copyright statement for test files --- test/lib/types/library/LibraryBuilder.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/lib/types/library/LibraryBuilder.js b/test/lib/types/library/LibraryBuilder.js index 41a05226a..e039a18d4 100644 --- a/test/lib/types/library/LibraryBuilder.js +++ b/test/lib/types/library/LibraryBuilder.js @@ -41,8 +41,7 @@ const libraryETree = { type: "library", metadata: { name: "library.e", - copyright: "UI development toolkit for HTML5 (OpenUI5)\n * (c) Copyright 2009-xxx SAP SE or an SAP affiliate " + - "company.\n * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.", + copyright: "some fancy copyright.", namespace: "library.e" }, resources: { From c8f3a800eaba22781751cce825ea9aa0796e8e3a Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 17 Aug 2020 14:46:12 +0200 Subject: [PATCH 80/88] Added reason why generateResourcesJson is inactive by default --- lib/builder/builder.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 221e9a27d..d79e39c19 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -59,6 +59,10 @@ function composeTaskList({dev, selfContained, jsdoc, includedTasks, excludedTask selectedTasks.executeJsdocSdkTransformation = false; selectedTasks.generateCachebusterInfo = false; selectedTasks.generateApiIndex = false; + + // Disable generateResourcesJson due to performance. + // When executed it analyzes each module's AST and therefore + // takes up much time (~10% more) selectedTasks.generateResourcesJson = false; if (selfContained) { From 7d41128807601051c2ef175e54433915aa665ef0 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 20 Aug 2020 14:34:00 +0200 Subject: [PATCH 81/88] remove unrelated htmlsanitizer fix --- lib/tasks/bundlers/generateLibraryPreload.js | 2 +- test/lib/tasks/bundlers/generateLibraryPreload.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tasks/bundlers/generateLibraryPreload.js b/lib/tasks/bundlers/generateLibraryPreload.js index b4158825e..23334cf95 100644 --- a/lib/tasks/bundlers/generateLibraryPreload.js +++ b/lib/tasks/bundlers/generateLibraryPreload.js @@ -48,7 +48,7 @@ function getBundleDefinition(namespace) { // include only thirdparty that is very likely to be used "sap/ui/thirdparty/crossroads.js", - "sap/ui/thirdparty/caja-html-sanitizer.js", + "sap/ui/thirdparty/caja-htmlsanitizer.js", "sap/ui/thirdparty/hasher.js", "sap/ui/thirdparty/signals.js", "sap/ui/thirdparty/jquery-mobile-custom.js", diff --git a/test/lib/tasks/bundlers/generateLibraryPreload.js b/test/lib/tasks/bundlers/generateLibraryPreload.js index 64ff0f3e2..da3867e7a 100644 --- a/test/lib/tasks/bundlers/generateLibraryPreload.js +++ b/test/lib/tasks/bundlers/generateLibraryPreload.js @@ -329,7 +329,7 @@ test("generateLibraryPreload for sap.ui.core (w/o ui5loader.js)", async (t) => { "sap/ui/util/", "sap/ui/Global.js", "sap/ui/thirdparty/crossroads.js", - "sap/ui/thirdparty/caja-html-sanitizer.js", + "sap/ui/thirdparty/caja-htmlsanitizer.js", "sap/ui/thirdparty/hasher.js", "sap/ui/thirdparty/signals.js", "sap/ui/thirdparty/jquery-mobile-custom.js", @@ -596,7 +596,7 @@ test("generateLibraryPreload for sap.ui.core (/w ui5loader.js)", async (t) => { "sap/ui/util/", "sap/ui/Global.js", "sap/ui/thirdparty/crossroads.js", - "sap/ui/thirdparty/caja-html-sanitizer.js", + "sap/ui/thirdparty/caja-htmlsanitizer.js", "sap/ui/thirdparty/hasher.js", "sap/ui/thirdparty/signals.js", "sap/ui/thirdparty/jquery-mobile-custom.js", From c9acba68844d11fd93ed2d7a090ff9949286a6ad Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 20 Aug 2020 14:45:58 +0200 Subject: [PATCH 82/88] removed library.n test to reduce js files --- .../resources/library/n/.library | 17 -- .../resources/library/n/Button-dbg.js | 28 --- .../resources/library/n/Button.js | 4 - .../n/changeHandler/SplitButton-dbg.js | 12 -- .../library/n/changeHandler/SplitButton.js | 4 - .../n/designtime/Button-dbg.designtime.js | 9 - .../n/designtime/Button.create.fragment.xml | 10 - .../library/n/designtime/Button.designtime.js | 4 - .../library/n/designtime/Button.icon.svg | 3 - .../n/designtime/library-dbg.designtime.js | 8 - .../n/designtime/library.designtime.js | 4 - .../n/flexibility/Button.flexibility-dbg.js | 15 -- .../n/flexibility/Button.flexibility.js | 4 - .../resources/library/n/library-dbg.js | 16 -- .../library/n/library-dbg.support.js | 10 - .../resources/library/n/library.js | 4 - .../resources/library/n/library.support.js | 4 - .../resources/library/n/manifest.json | 38 ---- .../library/n/messagebundle.properties | 1 - .../library/n/messagebundle_de.properties | 1 - .../resources/library/n/resources.json | 192 ------------------ .../library/n/rules/Button-dbg.support.js | 4 - .../library/n/rules/Button.support.js | 4 - .../dest/resources/library/n/.library | 17 -- .../dest/resources/library/n/Button-dbg.js | 28 --- .../dest/resources/library/n/Button.js | 4 - .../n/changeHandler/SplitButton-dbg.js | 12 -- .../library/n/changeHandler/SplitButton.js | 4 - .../n/designtime/Button-dbg.designtime.js | 9 - .../n/designtime/Button.create.fragment.xml | 10 - .../library/n/designtime/Button.designtime.js | 4 - .../library/n/designtime/Button.icon.svg | 3 - .../n/designtime/library-dbg.designtime.js | 8 - .../n/designtime/library.designtime.js | 4 - .../n/flexibility/Button.flexibility-dbg.js | 15 -- .../n/flexibility/Button.flexibility.js | 4 - .../dest/resources/library/n/library-dbg.js | 16 -- .../library/n/library-dbg.support.js | 10 - .../dest/resources/library/n/library.js | 4 - .../resources/library/n/library.support.js | 4 - .../dest/resources/library/n/manifest.json | 38 ---- .../library/n/messagebundle.properties | 1 - .../library/n/messagebundle_de.properties | 1 - .../library/n/rules/Button-dbg.support.js | 4 - .../library/n/rules/Button.support.js | 4 - test/fixtures/library.n/package.json | 8 - .../fixtures/library.n/src/library/n/.library | 17 -- .../library.n/src/library/n/Button.js | 28 --- .../library/n/changeHandler/SplitButton.js | 12 -- .../n/designtime/Button.create.fragment.xml | 10 - .../library/n/designtime/Button.designtime.js | 9 - .../src/library/n/designtime/Button.icon.svg | 3 - .../n/designtime/library.designtime.js | 8 - .../n/flexibility/Button.flexibility.js | 15 -- .../library.n/src/library/n/library.js | 16 -- .../src/library/n/library.support.js | 10 - .../src/library/n/messagebundle.properties | 1 - .../src/library/n/messagebundle_de.properties | 1 - .../src/library/n/rules/Button.support.js | 4 - test/fixtures/library.n/ui5.yaml | 5 - test/lib/builder/builder.js | 99 --------- 61 files changed, 846 deletions(-) delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/.library delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.create.fragment.xml delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.icon.svg delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library-dbg.designtime.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library.designtime.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/library.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/manifest.json delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle.properties delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle_de.properties delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button-dbg.support.js delete mode 100644 test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button.support.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/.library delete mode 100644 test/expected/build/library.n/dest/resources/library/n/Button-dbg.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/Button.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/designtime/Button.create.fragment.xml delete mode 100644 test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/designtime/Button.icon.svg delete mode 100644 test/expected/build/library.n/dest/resources/library/n/designtime/library-dbg.designtime.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/designtime/library.designtime.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/library-dbg.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/library.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/library.support.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/manifest.json delete mode 100644 test/expected/build/library.n/dest/resources/library/n/messagebundle.properties delete mode 100644 test/expected/build/library.n/dest/resources/library/n/messagebundle_de.properties delete mode 100644 test/expected/build/library.n/dest/resources/library/n/rules/Button-dbg.support.js delete mode 100644 test/expected/build/library.n/dest/resources/library/n/rules/Button.support.js delete mode 100644 test/fixtures/library.n/package.json delete mode 100644 test/fixtures/library.n/src/library/n/.library delete mode 100644 test/fixtures/library.n/src/library/n/Button.js delete mode 100644 test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js delete mode 100644 test/fixtures/library.n/src/library/n/designtime/Button.create.fragment.xml delete mode 100644 test/fixtures/library.n/src/library/n/designtime/Button.designtime.js delete mode 100644 test/fixtures/library.n/src/library/n/designtime/Button.icon.svg delete mode 100644 test/fixtures/library.n/src/library/n/designtime/library.designtime.js delete mode 100644 test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js delete mode 100644 test/fixtures/library.n/src/library/n/library.js delete mode 100644 test/fixtures/library.n/src/library/n/library.support.js delete mode 100644 test/fixtures/library.n/src/library/n/messagebundle.properties delete mode 100644 test/fixtures/library.n/src/library/n/messagebundle_de.properties delete mode 100644 test/fixtures/library.n/src/library/n/rules/Button.support.js delete mode 100644 test/fixtures/library.n/ui5.yaml diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/.library b/test/expected/build/library.n/dest-resources-json/resources/library/n/.library deleted file mode 100644 index e9a6cb76d..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/.library +++ /dev/null @@ -1,17 +0,0 @@ - - - - library.n - The vendor - some fancy copyright - 1.0.0 - - Library N - - - - sap.ui.core - - - - diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js deleted file mode 100644 index 4160f7c70..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button-dbg.js +++ /dev/null @@ -1,28 +0,0 @@ -/*! - * some fancy copyright - */ - -// Provides control library.N.Button. -sap.ui.define([ - 'mylib/MyFirstClass' -], function( - MyFirstClass -) { - "use strict"; - - return MyFirstClass.doIt("library.n.Button", { - prop: { - value: function() { - // requireSync Dependency - sap.ui.requireSync("library/n/changeHandler/SplitButton"); - } - }, - helper: function(sParam) { - var sDynamicDependency = "mylib/dyn/" + sParam; - // dynamicDependency - sap.ui.require(["mylib/MyClass", sDynamicDependency], function(MyClass, dynDep) { - new MyClass(dynDep); - }); - } - }); -}); diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js deleted file mode 100644 index e50dcc825..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/Button.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define(["mylib/MyFirstClass"],function(n){"use strict";return n.doIt("library.n.Button",{prop:{value:function(){sap.ui.requireSync("library/n/changeHandler/SplitButton")}},helper:function(n){var i="mylib/dyn/"+n;sap.ui.require(["mylib/MyClass",i],function(n,i){new n(i)})}})}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js deleted file mode 100644 index 7f8efd2ce..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton-dbg.js +++ /dev/null @@ -1,12 +0,0 @@ -/*! - * some fancy copyright - */ - -sap.ui.define([ - "mylib/util/myUtil" -], function ( - myUtil -) { - "use strict"; - return myUtil(47); -}); diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js deleted file mode 100644 index 138859296..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/changeHandler/SplitButton.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define(["mylib/util/myUtil"],function(i){"use strict";return i(47)}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js deleted file mode 100644 index 45cbb921d..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button-dbg.designtime.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! - * some fancy copyright - */ - -sap.ui.define([], function () { - "use strict"; - - return {}; -}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.create.fragment.xml b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.create.fragment.xml deleted file mode 100644 index 50988ae74..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.create.fragment.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js deleted file mode 100644 index 502fdec4c..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.designtime.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.icon.svg b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.icon.svg deleted file mode 100644 index 876555edb..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/Button.icon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library-dbg.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library-dbg.designtime.js deleted file mode 100644 index c08b12955..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library-dbg.designtime.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! - * some fancy copyright - */ - -sap.ui.define([], function() { - "use strict"; - return {}; -}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library.designtime.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library.designtime.js deleted file mode 100644 index 502fdec4c..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/designtime/library.designtime.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js deleted file mode 100644 index f0d8fbdaf..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility-dbg.js +++ /dev/null @@ -1,15 +0,0 @@ -/*! - * some fancy copyright - */ - -sap.ui.define([ - "mylib/MyRename", - "../changeHandler/SplitButton" -], function (MyRename, SplitButton) { - "use strict"; - - return { - "prop2": SplitButton, - "prop3": MyRename.doIt(), - }; -}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js deleted file mode 100644 index ae9ace973..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/flexibility/Button.flexibility.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define(["mylib/MyRename","../changeHandler/SplitButton"],function(e,n){"use strict";return{prop2:n,prop3:e.doIt()}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js deleted file mode 100644 index 890312530..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.js +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * some fancy copyright - */ - -sap.ui.define([ - 'mylib/MyClass', - 'mylib/library', - 'mob/library' -], function( - MyClass, - Library, - mobLibrary -) { - "use strict"; - return MyClass(Library(mobLibrary)); -}); diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js deleted file mode 100644 index 8c5242469..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library-dbg.support.js +++ /dev/null @@ -1,10 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define([ - "mylib/support/library", - "./rules/Button.support" -], function(SupportLib, ButtonSupport) { - "use strict"; - return SupportLib(ButtonSupport); -}); diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js deleted file mode 100644 index 5f4deed84..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define(["mylib/MyClass","mylib/library","mob/library"],function(i,r,b){"use strict";return i(r(b))}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js deleted file mode 100644 index 520a48601..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/library.support.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define(["mylib/support/library","./rules/Button.support"],function(r,t){"use strict";return r(t)}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/manifest.json b/test/expected/build/library.n/dest-resources-json/resources/library/n/manifest.json deleted file mode 100644 index 6cfe875b0..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "_version": "1.9.0", - "sap.app": { - "id": "library.n", - "type": "library", - "embeds": [], - "applicationVersion": { - "version": "1.0.0" - }, - "title": "Library N", - "description": "Library N", - "resources": "resources.json", - "offline": true - }, - "sap.ui": { - "technology": "UI5", - "supportedThemes": [] - }, - "sap.ui5": { - "dependencies": { - "minUI5Version": "1.0", - "libs": { - "sap.ui.core": { - "minVersion": "1.0.0" - } - } - }, - "library": { - "i18n": "messagebundle.properties", - "content": { - "controls": [], - "elements": [], - "types": [], - "interfaces": [] - } - } - } -} \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle.properties b/test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle.properties deleted file mode 100644 index 2fb1d609b..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle.properties +++ /dev/null @@ -1 +0,0 @@ -PRESS=Click! diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle_de.properties b/test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle_de.properties deleted file mode 100644 index 985400feb..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/messagebundle_de.properties +++ /dev/null @@ -1 +0,0 @@ -PRESS=Hier clicken! diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json b/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json deleted file mode 100644 index ec9a045fd..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/resources.json +++ /dev/null @@ -1,192 +0,0 @@ -{ - "_version": "1.1.0", - "resources": [ - { - "name": ".library", - "size": 411 - }, - { - "name": "Button-dbg.js", - "module": "library/n/Button.js", - "size": 574, - "isDebug": true, - "required": [ - "mylib/MyFirstClass.js" - ], - "condRequired": [ - "library/n/changeHandler/SplitButton.js", - "mylib/MyClass.js" - ], - "dynRequired": true - }, - { - "name": "Button.js", - "module": "library/n/Button.js", - "size": 316, - "required": [ - "mylib/MyFirstClass.js" - ], - "condRequired": [ - "library/n/changeHandler/SplitButton.js", - "mylib/MyClass.js" - ], - "dynRequired": true - }, - { - "name": "changeHandler/SplitButton-dbg.js", - "module": "library/n/changeHandler/SplitButton.js", - "size": 135, - "isDebug": true, - "required": [ - "mylib/util/myUtil.js" - ] - }, - { - "name": "changeHandler/SplitButton.js", - "module": "library/n/changeHandler/SplitButton.js", - "size": 108, - "required": [ - "mylib/util/myUtil.js" - ] - }, - { - "name": "designtime/Button-dbg.designtime.js", - "module": "library/n/designtime/Button.designtime.js", - "size": 96, - "isDebug": true, - "designtime": true - }, - { - "name": "designtime/Button.create.fragment.xml", - "module": "library/n/designtime/Button.create.fragment.xml", - "size": 172, - "designtime": true, - "required": [ - "library/n/Button.js" - ] - }, - { - "name": "designtime/Button.designtime.js", - "module": "library/n/designtime/Button.designtime.js", - "size": 84, - "designtime": true - }, - { - "name": "designtime/Button.icon.svg", - "size": 52, - "designtime": true - }, - { - "name": "designtime/library-dbg.designtime.js", - "module": "library/n/designtime/library.designtime.js", - "size": 94, - "isDebug": true, - "designtime": true - }, - { - "name": "designtime/library.designtime.js", - "module": "library/n/designtime/library.designtime.js", - "size": 84, - "designtime": true - }, - { - "name": "flexibility/Button.flexibility-dbg.js", - "module": "library/n/flexibility/Button.flexibility.js", - "size": 223, - "isDebug": true, - "required": [ - "library/n/changeHandler/SplitButton.js", - "mylib/MyRename.js" - ] - }, - { - "name": "flexibility/Button.flexibility.js", - "module": "library/n/flexibility/Button.flexibility.js", - "size": 156, - "required": [ - "library/n/changeHandler/SplitButton.js", - "mylib/MyRename.js" - ] - }, - { - "name": "library-dbg.js", - "module": "library/n/library.js", - "size": 206, - "isDebug": true, - "required": [ - "mob/library.js", - "mylib/MyClass.js", - "mylib/library.js" - ] - }, - { - "name": "library-dbg.support.js", - "module": "library/n/library.support.js", - "size": 195, - "isDebug": true, - "support": true, - "required": [ - "library/n/rules/Button.support.js", - "mylib/support/library.js" - ] - }, - { - "name": "library.js", - "module": "library/n/library.js", - "size": 140, - "required": [ - "mob/library.js", - "mylib/MyClass.js", - "mylib/library.js" - ] - }, - { - "name": "library.support.js", - "module": "library/n/library.support.js", - "size": 138, - "support": true, - "required": [ - "library/n/rules/Button.support.js", - "mylib/support/library.js" - ] - }, - { - "name": "manifest.json", - "module": "library/n/manifest.json", - "size": 708 - }, - { - "name": "messagebundle.properties", - "module": "library/n/messagebundle.properties", - "size": 13, - "locale": "", - "raw": "messagebundle.properties" - }, - { - "name": "messagebundle_de.properties", - "module": "library/n/messagebundle_de.properties", - "size": 20, - "locale": "de", - "raw": "messagebundle.properties" - }, - { - "name": "resources.json", - "size": 4071 - }, - { - "name": "rules/Button-dbg.support.js", - "module": "library/n/rules/Button.support.js", - "size": 58, - "format": "raw", - "isDebug": true, - "support": true - }, - { - "name": "rules/Button.support.js", - "module": "library/n/rules/Button.support.js", - "size": 58, - "format": "raw", - "support": true - } - ] -} \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button-dbg.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button-dbg.support.js deleted file mode 100644 index 566c6fa91..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button-dbg.support.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -console.log('HelloWorld'); \ No newline at end of file diff --git a/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button.support.js b/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button.support.js deleted file mode 100644 index 50fac1a94..000000000 --- a/test/expected/build/library.n/dest-resources-json/resources/library/n/rules/Button.support.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -console.log("HelloWorld"); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/.library b/test/expected/build/library.n/dest/resources/library/n/.library deleted file mode 100644 index e9a6cb76d..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/.library +++ /dev/null @@ -1,17 +0,0 @@ - - - - library.n - The vendor - some fancy copyright - 1.0.0 - - Library N - - - - sap.ui.core - - - - diff --git a/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js b/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js deleted file mode 100644 index 4160f7c70..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/Button-dbg.js +++ /dev/null @@ -1,28 +0,0 @@ -/*! - * some fancy copyright - */ - -// Provides control library.N.Button. -sap.ui.define([ - 'mylib/MyFirstClass' -], function( - MyFirstClass -) { - "use strict"; - - return MyFirstClass.doIt("library.n.Button", { - prop: { - value: function() { - // requireSync Dependency - sap.ui.requireSync("library/n/changeHandler/SplitButton"); - } - }, - helper: function(sParam) { - var sDynamicDependency = "mylib/dyn/" + sParam; - // dynamicDependency - sap.ui.require(["mylib/MyClass", sDynamicDependency], function(MyClass, dynDep) { - new MyClass(dynDep); - }); - } - }); -}); diff --git a/test/expected/build/library.n/dest/resources/library/n/Button.js b/test/expected/build/library.n/dest/resources/library/n/Button.js deleted file mode 100644 index e50dcc825..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/Button.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define(["mylib/MyFirstClass"],function(n){"use strict";return n.doIt("library.n.Button",{prop:{value:function(){sap.ui.requireSync("library/n/changeHandler/SplitButton")}},helper:function(n){var i="mylib/dyn/"+n;sap.ui.require(["mylib/MyClass",i],function(n,i){new n(i)})}})}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js deleted file mode 100644 index 7f8efd2ce..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton-dbg.js +++ /dev/null @@ -1,12 +0,0 @@ -/*! - * some fancy copyright - */ - -sap.ui.define([ - "mylib/util/myUtil" -], function ( - myUtil -) { - "use strict"; - return myUtil(47); -}); diff --git a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js b/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js deleted file mode 100644 index 138859296..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/changeHandler/SplitButton.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define(["mylib/util/myUtil"],function(i){"use strict";return i(47)}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js deleted file mode 100644 index 45cbb921d..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/Button-dbg.designtime.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! - * some fancy copyright - */ - -sap.ui.define([], function () { - "use strict"; - - return {}; -}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.create.fragment.xml b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.create.fragment.xml deleted file mode 100644 index 50988ae74..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.create.fragment.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js deleted file mode 100644 index 502fdec4c..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.designtime.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.icon.svg b/test/expected/build/library.n/dest/resources/library/n/designtime/Button.icon.svg deleted file mode 100644 index 876555edb..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/Button.icon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/library-dbg.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/library-dbg.designtime.js deleted file mode 100644 index c08b12955..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/library-dbg.designtime.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! - * some fancy copyright - */ - -sap.ui.define([], function() { - "use strict"; - return {}; -}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/designtime/library.designtime.js b/test/expected/build/library.n/dest/resources/library/n/designtime/library.designtime.js deleted file mode 100644 index 502fdec4c..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/designtime/library.designtime.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js deleted file mode 100644 index f0d8fbdaf..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility-dbg.js +++ /dev/null @@ -1,15 +0,0 @@ -/*! - * some fancy copyright - */ - -sap.ui.define([ - "mylib/MyRename", - "../changeHandler/SplitButton" -], function (MyRename, SplitButton) { - "use strict"; - - return { - "prop2": SplitButton, - "prop3": MyRename.doIt(), - }; -}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js b/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js deleted file mode 100644 index ae9ace973..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/flexibility/Button.flexibility.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define(["mylib/MyRename","../changeHandler/SplitButton"],function(e,n){"use strict";return{prop2:n,prop3:e.doIt()}}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/library-dbg.js b/test/expected/build/library.n/dest/resources/library/n/library-dbg.js deleted file mode 100644 index 890312530..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/library-dbg.js +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * some fancy copyright - */ - -sap.ui.define([ - 'mylib/MyClass', - 'mylib/library', - 'mob/library' -], function( - MyClass, - Library, - mobLibrary -) { - "use strict"; - return MyClass(Library(mobLibrary)); -}); diff --git a/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js b/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js deleted file mode 100644 index 8c5242469..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/library-dbg.support.js +++ /dev/null @@ -1,10 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define([ - "mylib/support/library", - "./rules/Button.support" -], function(SupportLib, ButtonSupport) { - "use strict"; - return SupportLib(ButtonSupport); -}); diff --git a/test/expected/build/library.n/dest/resources/library/n/library.js b/test/expected/build/library.n/dest/resources/library/n/library.js deleted file mode 100644 index 5f4deed84..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/library.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define(["mylib/MyClass","mylib/library","mob/library"],function(i,r,b){"use strict";return i(r(b))}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/library.support.js b/test/expected/build/library.n/dest/resources/library/n/library.support.js deleted file mode 100644 index 520a48601..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/library.support.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -sap.ui.define(["mylib/support/library","./rules/Button.support"],function(r,t){"use strict";return r(t)}); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/manifest.json b/test/expected/build/library.n/dest/resources/library/n/manifest.json deleted file mode 100644 index 6cfe875b0..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/manifest.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "_version": "1.9.0", - "sap.app": { - "id": "library.n", - "type": "library", - "embeds": [], - "applicationVersion": { - "version": "1.0.0" - }, - "title": "Library N", - "description": "Library N", - "resources": "resources.json", - "offline": true - }, - "sap.ui": { - "technology": "UI5", - "supportedThemes": [] - }, - "sap.ui5": { - "dependencies": { - "minUI5Version": "1.0", - "libs": { - "sap.ui.core": { - "minVersion": "1.0.0" - } - } - }, - "library": { - "i18n": "messagebundle.properties", - "content": { - "controls": [], - "elements": [], - "types": [], - "interfaces": [] - } - } - } -} \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/messagebundle.properties b/test/expected/build/library.n/dest/resources/library/n/messagebundle.properties deleted file mode 100644 index 2fb1d609b..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/messagebundle.properties +++ /dev/null @@ -1 +0,0 @@ -PRESS=Click! diff --git a/test/expected/build/library.n/dest/resources/library/n/messagebundle_de.properties b/test/expected/build/library.n/dest/resources/library/n/messagebundle_de.properties deleted file mode 100644 index 985400feb..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/messagebundle_de.properties +++ /dev/null @@ -1 +0,0 @@ -PRESS=Hier clicken! diff --git a/test/expected/build/library.n/dest/resources/library/n/rules/Button-dbg.support.js b/test/expected/build/library.n/dest/resources/library/n/rules/Button-dbg.support.js deleted file mode 100644 index 566c6fa91..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/rules/Button-dbg.support.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -console.log('HelloWorld'); \ No newline at end of file diff --git a/test/expected/build/library.n/dest/resources/library/n/rules/Button.support.js b/test/expected/build/library.n/dest/resources/library/n/rules/Button.support.js deleted file mode 100644 index 50fac1a94..000000000 --- a/test/expected/build/library.n/dest/resources/library/n/rules/Button.support.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * some fancy copyright - */ -console.log("HelloWorld"); \ No newline at end of file diff --git a/test/fixtures/library.n/package.json b/test/fixtures/library.n/package.json deleted file mode 100644 index bd37ccd0b..000000000 --- a/test/fixtures/library.n/package.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "library.n", - "version": "1.0.0", - "description": "Simple SAPUI5 based library - test for resourceListCreator", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - } -} diff --git a/test/fixtures/library.n/src/library/n/.library b/test/fixtures/library.n/src/library/n/.library deleted file mode 100644 index 27c1610a7..000000000 --- a/test/fixtures/library.n/src/library/n/.library +++ /dev/null @@ -1,17 +0,0 @@ - - - - library.n - The vendor - ${copyright} - ${version} - - Library N - - - - sap.ui.core - - - - diff --git a/test/fixtures/library.n/src/library/n/Button.js b/test/fixtures/library.n/src/library/n/Button.js deleted file mode 100644 index 7de7455c6..000000000 --- a/test/fixtures/library.n/src/library/n/Button.js +++ /dev/null @@ -1,28 +0,0 @@ -/*! - * ${copyright} - */ - -// Provides control library.N.Button. -sap.ui.define([ - 'mylib/MyFirstClass' -], function( - MyFirstClass -) { - "use strict"; - - return MyFirstClass.doIt("library.n.Button", { - prop: { - value: function() { - // requireSync Dependency - sap.ui.requireSync("library/n/changeHandler/SplitButton"); - } - }, - helper: function(sParam) { - var sDynamicDependency = "mylib/dyn/" + sParam; - // dynamicDependency - sap.ui.require(["mylib/MyClass", sDynamicDependency], function(MyClass, dynDep) { - new MyClass(dynDep); - }); - } - }); -}); diff --git a/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js b/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js deleted file mode 100644 index 87d08f403..000000000 --- a/test/fixtures/library.n/src/library/n/changeHandler/SplitButton.js +++ /dev/null @@ -1,12 +0,0 @@ -/*! - * ${copyright} - */ - -sap.ui.define([ - "mylib/util/myUtil" -], function ( - myUtil -) { - "use strict"; - return myUtil(47); -}); diff --git a/test/fixtures/library.n/src/library/n/designtime/Button.create.fragment.xml b/test/fixtures/library.n/src/library/n/designtime/Button.create.fragment.xml deleted file mode 100644 index 50988ae74..000000000 --- a/test/fixtures/library.n/src/library/n/designtime/Button.create.fragment.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js b/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js deleted file mode 100644 index ff8f6d738..000000000 --- a/test/fixtures/library.n/src/library/n/designtime/Button.designtime.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! - * ${copyright} - */ - -sap.ui.define([], function () { - "use strict"; - - return {}; -}); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/designtime/Button.icon.svg b/test/fixtures/library.n/src/library/n/designtime/Button.icon.svg deleted file mode 100644 index 876555edb..000000000 --- a/test/fixtures/library.n/src/library/n/designtime/Button.icon.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/test/fixtures/library.n/src/library/n/designtime/library.designtime.js b/test/fixtures/library.n/src/library/n/designtime/library.designtime.js deleted file mode 100644 index 6c8c315f3..000000000 --- a/test/fixtures/library.n/src/library/n/designtime/library.designtime.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! - * ${copyright} - */ - -sap.ui.define([], function() { - "use strict"; - return {}; -}); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js b/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js deleted file mode 100644 index 717045832..000000000 --- a/test/fixtures/library.n/src/library/n/flexibility/Button.flexibility.js +++ /dev/null @@ -1,15 +0,0 @@ -/*! - * ${copyright} - */ - -sap.ui.define([ - "mylib/MyRename", - "../changeHandler/SplitButton" -], function (MyRename, SplitButton) { - "use strict"; - - return { - "prop2": SplitButton, - "prop3": MyRename.doIt(), - }; -}); \ No newline at end of file diff --git a/test/fixtures/library.n/src/library/n/library.js b/test/fixtures/library.n/src/library/n/library.js deleted file mode 100644 index b6253c59d..000000000 --- a/test/fixtures/library.n/src/library/n/library.js +++ /dev/null @@ -1,16 +0,0 @@ -/*! - * ${copyright} - */ - -sap.ui.define([ - 'mylib/MyClass', - 'mylib/library', - 'mob/library' -], function( - MyClass, - Library, - mobLibrary -) { - "use strict"; - return MyClass(Library(mobLibrary)); -}); diff --git a/test/fixtures/library.n/src/library/n/library.support.js b/test/fixtures/library.n/src/library/n/library.support.js deleted file mode 100644 index a425f747d..000000000 --- a/test/fixtures/library.n/src/library/n/library.support.js +++ /dev/null @@ -1,10 +0,0 @@ -/*! - * ${copyright} - */ -sap.ui.define([ - "mylib/support/library", - "./rules/Button.support" -], function(SupportLib, ButtonSupport) { - "use strict"; - return SupportLib(ButtonSupport); -}); diff --git a/test/fixtures/library.n/src/library/n/messagebundle.properties b/test/fixtures/library.n/src/library/n/messagebundle.properties deleted file mode 100644 index 2fb1d609b..000000000 --- a/test/fixtures/library.n/src/library/n/messagebundle.properties +++ /dev/null @@ -1 +0,0 @@ -PRESS=Click! diff --git a/test/fixtures/library.n/src/library/n/messagebundle_de.properties b/test/fixtures/library.n/src/library/n/messagebundle_de.properties deleted file mode 100644 index 985400feb..000000000 --- a/test/fixtures/library.n/src/library/n/messagebundle_de.properties +++ /dev/null @@ -1 +0,0 @@ -PRESS=Hier clicken! diff --git a/test/fixtures/library.n/src/library/n/rules/Button.support.js b/test/fixtures/library.n/src/library/n/rules/Button.support.js deleted file mode 100644 index 81e734360..000000000 --- a/test/fixtures/library.n/src/library/n/rules/Button.support.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * ${copyright} - */ -console.log('HelloWorld'); \ No newline at end of file diff --git a/test/fixtures/library.n/ui5.yaml b/test/fixtures/library.n/ui5.yaml deleted file mode 100644 index 48c70435e..000000000 --- a/test/fixtures/library.n/ui5.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -specVersion: "0.1" -type: library -metadata: - name: library.n diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index c1a1bff3a..fb640e6fb 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -23,7 +23,6 @@ const libraryEPath = path.join(__dirname, "..", "..", "fixtures", "library.e"); const libraryHPath = path.join(__dirname, "..", "..", "fixtures", "library.h"); const libraryIPath = path.join(__dirname, "..", "..", "fixtures", "library.i"); const libraryJPath = path.join(__dirname, "..", "..", "fixtures", "library.j"); -const libraryNPath = path.join(__dirname, "..", "..", "fixtures", "library.n"); const libraryCore = path.join(__dirname, "..", "..", "fixtures", "sap.ui.core-evo"); const themeJPath = path.join(__dirname, "..", "..", "fixtures", "theme.j"); @@ -693,51 +692,6 @@ test("Build theme.j even without an library with resources.json", (t) => { }); }); -test("Build library.n", (t) => { - const destPath = path.join("test", "tmp", "build", "library.n", "dest"); - const expectedPath = path.join("test", "expected", "build", "library.n", "dest"); - - return builder.build({ - tree: libraryNTree, - destPath, - excludedTasks: ["generateLibraryPreload"] - }).then(() => { - return findFiles(expectedPath); - }).then((expectedFiles) => { - // Check for all directories and files - assert.directoryDeepEqual(destPath, expectedPath); - - // Check for all file contents - return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); - }).then(() => { - t.pass(); - }); -}); - -test("Build library.n with resources.json", (t) => { - const destPath = path.join("test", "tmp", "build", "library.n", "dest-resources-json"); - const expectedPath = path.join("test", "expected", "build", "library.n", "dest-resources-json"); - - return builder.build({ - includedTasks: [ - "generateResourcesJson" - ], - tree: libraryNTree, - destPath, - excludedTasks: ["generateLibraryPreload"] - }).then(() => { - return findFiles(expectedPath); - }).then((expectedFiles) => { - // Check for all directories and files - assert.directoryDeepEqual(destPath, expectedPath); - - // Check for all file contents - return checkFileContentsIgnoreLineFeeds(t, expectedFiles, expectedPath, destPath); - }).then(() => { - t.pass(); - }); -}); - test.serial("Cleanup", async (t) => { const BuildContext = require("../../../lib/builder/BuildContext"); const createProjectContextStub = sinon.spy(BuildContext.prototype, "createProjectContext"); @@ -1451,56 +1405,3 @@ const themeJTree = { } } }; - -const libraryNTree = { - "id": "library.n", - "version": "1.0.0", - "path": libraryNPath, - "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.n", - "namespace": "library/n", - "copyright": "some fancy copyright" - }, - "resources": { - "configuration": { - "paths": { - "src": "src", - "test": "test" - }, - "propertiesFileSourceEncoding": "ISO-8859-1" - }, - "pathMappings": { - "/resources/": "src", - "/test-resources/": "test" - } - } -}; From 5bbe036f0c3ad423b4121abc1c6acae4e238ec73 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Thu, 20 Aug 2020 15:08:41 +0200 Subject: [PATCH 83/88] removed unnecessary tests --- .../resources/library/h/.library | 2 +- .../resources/library/h/manifest.json | 4 +- .../dest/resources/library/h/.library | 2 +- .../dest/resources/library/h/manifest.json | 4 +- .../library.h/main/src/library/h/.library | 2 +- test/lib/lbt/resources/ModuleInfo.js | 63 ------------------- test/lib/types/library/LibraryBuilder.js | 55 ---------------- .../types/themeLibrary/ThemeLibraryBuilder.js | 46 -------------- 8 files changed, 7 insertions(+), 171 deletions(-) delete mode 100644 test/lib/lbt/resources/ModuleInfo.js delete mode 100644 test/lib/types/library/LibraryBuilder.js delete mode 100644 test/lib/types/themeLibrary/ThemeLibraryBuilder.js diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/.library b/test/expected/build/library.h/dest-resources-json/resources/library/h/.library index 9084728e8..5bdab13ab 100644 --- a/test/expected/build/library.h/dest-resources-json/resources/library/h/.library +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/.library @@ -6,7 +6,7 @@ Some fancy copyright 1.0.0 - Library H + Library D diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/manifest.json b/test/expected/build/library.h/dest-resources-json/resources/library/h/manifest.json index 2b6c457ad..2e67ab58d 100644 --- a/test/expected/build/library.h/dest-resources-json/resources/library/h/manifest.json +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/manifest.json @@ -12,8 +12,8 @@ "applicationVersion": { "version": "1.0.0" }, - "title": "Library H", - "description": "Library H", + "title": "Library D", + "description": "Library D", "resources": "resources.json", "offline": true }, diff --git a/test/expected/build/library.h/dest/resources/library/h/.library b/test/expected/build/library.h/dest/resources/library/h/.library index 9084728e8..5bdab13ab 100644 --- a/test/expected/build/library.h/dest/resources/library/h/.library +++ b/test/expected/build/library.h/dest/resources/library/h/.library @@ -6,7 +6,7 @@ Some fancy copyright 1.0.0 - Library H + Library D diff --git a/test/expected/build/library.h/dest/resources/library/h/manifest.json b/test/expected/build/library.h/dest/resources/library/h/manifest.json index 2b6c457ad..2e67ab58d 100644 --- a/test/expected/build/library.h/dest/resources/library/h/manifest.json +++ b/test/expected/build/library.h/dest/resources/library/h/manifest.json @@ -12,8 +12,8 @@ "applicationVersion": { "version": "1.0.0" }, - "title": "Library H", - "description": "Library H", + "title": "Library D", + "description": "Library D", "resources": "resources.json", "offline": true }, diff --git a/test/fixtures/library.h/main/src/library/h/.library b/test/fixtures/library.h/main/src/library/h/.library index 38501ff40..797c61cc8 100644 --- a/test/fixtures/library.h/main/src/library/h/.library +++ b/test/fixtures/library.h/main/src/library/h/.library @@ -6,7 +6,7 @@ Some fancy copyright ${version} - Library H + Library D diff --git a/test/lib/lbt/resources/ModuleInfo.js b/test/lib/lbt/resources/ModuleInfo.js deleted file mode 100644 index 9ecc16569..000000000 --- a/test/lib/lbt/resources/ModuleInfo.js +++ /dev/null @@ -1,63 +0,0 @@ -const test = require("ava"); - -const ModuleInfo = require("../../../../lib/lbt/resources/ModuleInfo"); - -test("ModuleInfo: constructor", async (t) => { - const moduleInfo = new ModuleInfo("myName"); - t.falsy(moduleInfo.exposedGlobals, "exposedGlobals is not set"); - t.falsy(moduleInfo.format, "format is not set"); - t.falsy(moduleInfo.description, "description is not set"); - t.false(moduleInfo.requiresTopLevelScope, "requiresTopLevelScope is false"); - t.false(moduleInfo.rawModule, "rawModule is false"); - t.false(moduleInfo.dynamicDependencies, "dynamicDependencies is false"); - t.deepEqual(moduleInfo.subModules, [], "submodules are empty"); -}); - -test("ModuleInfo: addSubModule", async (t) => { - // setup - const moduleInfo = new ModuleInfo("myName"); - moduleInfo.addDependency("otherModule", false); - const otherModuleInfo = new ModuleInfo("otherModule"); - otherModuleInfo.addDependency("unknownModule", false); - otherModuleInfo.dynamicDependencies = true; - - // action - moduleInfo.addSubModule(otherModuleInfo); - - // expectation - t.true(moduleInfo.dynamicDependencies, "dynamicDependencies is set"); - t.deepEqual(moduleInfo.subModules, ["otherModule"], "submodule is set"); - t.deepEqual(moduleInfo.dependencies, ["unknownModule"], "unknownModule dependency is copied over"); -}); - -test("ModuleInfo: name", async (t) => { - // setup - const moduleInfo = new ModuleInfo("myName"); - - // action - moduleInfo.addDependency("newName", false); - moduleInfo.name = "newName"; - - moduleInfo.addSubModule("newName2"); - moduleInfo.name = "newName2"; - - // expectation - t.deepEqual(moduleInfo.subModules, [], "submodule is empty"); - t.deepEqual(moduleInfo.dependencies, [], "dependencies is empty"); - t.is(moduleInfo.name, "newName2", "name was set"); -}); - -test("ModuleInfo: toString", async (t) => { - // setup - const moduleInfo = new ModuleInfo("myName"); - - // action - moduleInfo.addDependency("dep1", false); - moduleInfo.addDependency("dep2", false); - moduleInfo.addSubModule("sub1"); - moduleInfo.addSubModule("sub2"); - const stringContent = moduleInfo.toString(); - - // expectation - t.is(stringContent, "ModuleInfo(myName, dependencies=dep1,dep2, includes=sub1,sub2)", "string value is correct"); -}); diff --git a/test/lib/types/library/LibraryBuilder.js b/test/lib/types/library/LibraryBuilder.js deleted file mode 100644 index e039a18d4..000000000 --- a/test/lib/types/library/LibraryBuilder.js +++ /dev/null @@ -1,55 +0,0 @@ -const test = require("ava"); -const path = require("path"); - -const parentLogger = require("@ui5/logger").getGroupLogger("mygroup"); - -const LibraryBuilder = require("../../../../lib/types/library/LibraryBuilder"); - -function clone(o) { - return JSON.parse(JSON.stringify(o)); -} - -test("Instantiation", (t) => { - const project = clone(libraryETree); - const appBuilder = new LibraryBuilder({parentLogger, project}); - t.truthy(appBuilder); - t.deepEqual(appBuilder.taskExecutionOrder, [ - "escapeNonAsciiCharacters", - "replaceCopyright", - "replaceVersion", - "generateJsdoc", - "executeJsdocSdkTransformation", - "generateLibraryManifest", - "generateManifestBundle", - "generateLibraryPreload", - "buildThemes", - "createDebugFiles", - "uglify", - "generateResourcesJson" - ], "LibraryBuilder is instantiated with standard tasks"); -}); - -const libraryEPath = path.join(__dirname, "..", "..", "..", "fixtures", "library.e"); -const libraryETree = { - id: "library.e.id", - version: "1.0.0", - path: libraryEPath, - dependencies: [], - _level: 0, - _isRoot: true, - specVersion: "2.0", - type: "library", - metadata: { - name: "library.e", - copyright: "some fancy copyright.", - namespace: "library.e" - }, - resources: { - configuration: { - paths: { - src: "src", - test: "test" - } - } - } -}; diff --git a/test/lib/types/themeLibrary/ThemeLibraryBuilder.js b/test/lib/types/themeLibrary/ThemeLibraryBuilder.js deleted file mode 100644 index 261623d7d..000000000 --- a/test/lib/types/themeLibrary/ThemeLibraryBuilder.js +++ /dev/null @@ -1,46 +0,0 @@ -const test = require("ava"); - -const ThemeLibraryBuilder = require("../../../../lib/types/themeLibrary/ThemeLibraryBuilder"); - -test("tasks", async (t) => { - const themeLibraryBuilder = new ThemeLibraryBuilder({ - resourceCollections: { - workspace: { - byGlob: async () => { - return []; - } - } - }, - buildContext: { - isRootProject: () => { - return true; - } - }, - project: { - metadata: { - name: "name", - copyright: "copyright" - }, - type: "type" - }, - parentLogger: { - createSubLogger: () => { - return { - createTaskLogger: () => { - - } - }; - } - }, - taskUtil: { - isRootProject: () => { - return true; - } - } - }); - const asyncTasks = Object.keys(themeLibraryBuilder.tasks).map((taskKey) => { - return themeLibraryBuilder.tasks[taskKey](); - }); - - t.is(asyncTasks.length, 4, "all 4 tasks should be added"); -}); From c7db153012bea3fda597b969ca443355c9fb94e5 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Fri, 21 Aug 2020 07:44:22 +0200 Subject: [PATCH 84/88] [INTERNAL] Move test files into tests as strings Reduce test fixtures by using the file content string in the tests directly. --- .../lbt/modules/bundle-evo_invalid_comment.js | 7 -- .../fixtures/lbt/modules/declare_times_two.js | 7 -- test/fixtures/lbt/modules/declare_unnamed.js | 6 - test/fixtures/lbt/modules/functionDefine.js | 24 ---- test/fixtures/lbt/modules/nestedRequire.js | 34 ------ test/lib/lbt/analyzer/JSModuleAnalyzer.js | 111 +++++++++++++----- 6 files changed, 82 insertions(+), 107 deletions(-) delete mode 100644 test/fixtures/lbt/modules/bundle-evo_invalid_comment.js delete mode 100644 test/fixtures/lbt/modules/declare_times_two.js delete mode 100644 test/fixtures/lbt/modules/declare_unnamed.js delete mode 100644 test/fixtures/lbt/modules/functionDefine.js delete mode 100644 test/fixtures/lbt/modules/nestedRequire.js diff --git a/test/fixtures/lbt/modules/bundle-evo_invalid_comment.js b/test/fixtures/lbt/modules/bundle-evo_invalid_comment.js deleted file mode 100644 index 8eff0e436..000000000 --- a/test/fixtures/lbt/modules/bundle-evo_invalid_comment.js +++ /dev/null @@ -1,7 +0,0 @@ -//@ui5-bundles sap/ui/thirdparty/baseuri.js -if(!('baseURI'in Node.prototype)){} -//@ui5-bundle-raw-includes sap/ui/thirdparty/es6-promise.js -(function(g,f){ - g.ES6Promise=f();}(this,(function(){}))); - -sap.ui.define("my/module", ["sap/ui/core/UIComponent"],function(n){"use strict";return 47+n}); \ No newline at end of file diff --git a/test/fixtures/lbt/modules/declare_times_two.js b/test/fixtures/lbt/modules/declare_times_two.js deleted file mode 100644 index c15d36f86..000000000 --- a/test/fixtures/lbt/modules/declare_times_two.js +++ /dev/null @@ -1,7 +0,0 @@ -jQuery.sap.declare("sap.ui.testmodule"); - -sap.ui.testmodule.load = function(modName) { - jQuery.sap.require(modName); -}; - -jQuery.sap.declare("sap.ui.testmodule"); \ No newline at end of file diff --git a/test/fixtures/lbt/modules/declare_unnamed.js b/test/fixtures/lbt/modules/declare_unnamed.js deleted file mode 100644 index 37f14907b..000000000 --- a/test/fixtures/lbt/modules/declare_unnamed.js +++ /dev/null @@ -1,6 +0,0 @@ -var sCommonName = "sap.ui" -jQuery.sap.declare(sCommonName + ".testmodule"); - -sap.ui.testmodule.load = function(modName) { - jQuery.sap.require(modName); -}; diff --git a/test/fixtures/lbt/modules/functionDefine.js b/test/fixtures/lbt/modules/functionDefine.js deleted file mode 100644 index 9e8ae6cfc..000000000 --- a/test/fixtures/lbt/modules/functionDefine.js +++ /dev/null @@ -1,24 +0,0 @@ -/*! - * ${copyright} - */ -/*global my */ -(function() { - "use strict"; - - function defineMyFile() { - sap.ui.define('def/MyFile', ['dep/myDep'], - function(myDep) { - return 47; - }); - } - - // conditional - if (!(window.sap && window.sap.ui && window.sap.ui.define)) { - var fnHandler = function() { - defineMyFile(); - }; - my.addEventListener("myevent", fnHandler); - } else { - defineMyFile(); - } -}()); \ No newline at end of file diff --git a/test/fixtures/lbt/modules/nestedRequire.js b/test/fixtures/lbt/modules/nestedRequire.js deleted file mode 100644 index fbb17056e..000000000 --- a/test/fixtures/lbt/modules/nestedRequire.js +++ /dev/null @@ -1,34 +0,0 @@ -/*! - * ${copyright} - */ - -/*global my,sap */ -(function(deps, callback) { - - "use strict"; - - function doIt(array, callback) { - callback(); - } - - var aArray = []; - - doIt(aArray, function() { - doIt([ - "foo" - ], function() { - doIt([ - "bar" - ], function() { - // nested sap.ui.require - sap.ui.require(deps, callback); - }); - }); - }); - -}([ - "my/dependency" -], function(myDep) { - "use strict"; - console.log("done") -})); \ No newline at end of file diff --git a/test/lib/lbt/analyzer/JSModuleAnalyzer.js b/test/lib/lbt/analyzer/JSModuleAnalyzer.js index 61111d1be..e08b57a6a 100644 --- a/test/lib/lbt/analyzer/JSModuleAnalyzer.js +++ b/test/lib/lbt/analyzer/JSModuleAnalyzer.js @@ -39,9 +39,7 @@ function analyze(file, name) { reject(err); } try { - const ast = esprima.parseScript(buffer.toString(), {comment: true}); - const info = new ModuleInfo(name); - new JSModuleAnalyzer().analyze(ast, name, info); + const info = analyzeString(buffer.toString(), name); resolve(info); } catch (execErr) { reject(execErr); @@ -50,6 +48,13 @@ function analyze(file, name) { }); } +function analyzeString(content, name) { + const ast = esprima.parseScript(content, {comment: true}); + const info = new ModuleInfo(name); + new JSModuleAnalyzer().analyze(ast, name, info); + return info; +} + function assertModuleNamesEqual(t, actual, expected, msg) { actual.sort(); expected.sort(); @@ -528,42 +533,90 @@ test("Dynamic import (define/requireSync)", (t) => { }); test("Nested require", (t) => { - return analyze("modules/nestedRequire.js").then((info) => { - t.true(info.rawModule, - "raw module"); + const content = ` +(function(deps, callback) { + function doIt(array, callback) { + callback(); + } + + var aArray = []; + doIt(aArray, function() { + doIt(["foo"], function() { + doIt(["bar"], function() { + // nested sap.ui.require + sap.ui.require(deps, callback); + }); + }); }); +}([ + "my/dependency" +], function(myDep) { + console.log("done") +}));`; + const info = analyzeString(content, "modules/nestedRequire.js"); + t.true(info.rawModule, "raw module"); }); test("Toplevel define", (t) => { - return analyze("modules/functionDefine.js").then((info) => { - t.true(info.rawModule, - "raw module"); - }); + const content = ` +(function() { + function defineMyFile() { + sap.ui.define('def/MyFile', ['dep/myDep'], + function(myDep) { + return 47; + }); + } + + // conditional + if (!(window.sap && window.sap.ui && window.sap.ui.define)) { + var fnHandler = function() { + defineMyFile(); + }; + my.addEventListener("myevent", fnHandler); + } else { + defineMyFile(); + } +}()); `; + const info = analyzeString(content, "modules/functionDefine.js"); + t.true(info.rawModule, "raw module"); }); test("Invalid ui5 bundle comment", (t) => { - return analyze("modules/bundle-evo_invalid_comment.js").then((info) => { - t.is(info.name, "my/module.js", - "module name matches"); - t.deepEqual(info.subModules, [], - "no submodules"); - }); + const content = `/@ui5-bundles sap/ui/thirdparty/xxx.js +if(!('xxx'in Node.prototype)){} +//@ui5-bundle-raw-includes sap/ui/thirdparty/aaa.js +(function(g,f){g.AAA=f();}(this,(function(){}))); +sap.ui.define("my/module", ["sap/ui/core/UIComponent"],function(n){"use strict";return 47+n});`; + const info = analyzeString(content, "modules/bundle-evo_invalid_comment.js"); + t.is(info.name, "my/module.js", + "module name matches"); + t.deepEqual(info.subModules, [], + "no submodules"); }); test("Declare two times", (t) => { - return analyze("modules/declare_times_two.js").then((info) => { - t.is(info.name, "sap/ui/testmodule.js", - "module name matches"); - t.deepEqual(info.subModules, [], - "no submodules"); - }); + const content = `jQuery.sap.declare("sap.ui.testmodule"); +sap.ui.testmodule.load = function(modName) { + jQuery.sap.require(modName); +}; +jQuery.sap.declare("sap.ui.testmodule");`; + const info = analyzeString(content, "modules/declare_times_two.js"); + t.is(info.name, "sap/ui/testmodule.js", + "module name matches"); + t.deepEqual(info.subModules, [], + "no submodules"); }); -test("Declare unnamed", (t) => { - return analyze("modules/declare_unnamed.js").then((info) => { - t.is(info.name, "modules/declare_unnamed.js", - "module name matches"); - t.deepEqual(info.subModules, [], - "no submodules"); - }); +test("Declare dynamic name", (t) => { + const content = `var sCommonName = "sap.ui" +jQuery.sap.declare(sCommonName + ".testmodule"); + +sap.ui.testmodule.load = function(modName) { + jQuery.sap.require(modName); +};`; + const info = analyzeString(content, "modules/dynamic_name.js"); + t.is(info.name, "modules/dynamic_name.js", + "module name matches"); + t.deepEqual(info.subModules, [], + "no submodules"); }); From 423858d468017c7ec75115998940bf95db3b5d30 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Fri, 21 Aug 2020 07:58:59 +0200 Subject: [PATCH 85/88] [INTERNAL] Reduce test files * move i18n files to separate folder * revert some.js * put global export logic into newly introduced library.designtime.js file --- .../resources/library/h/customBundle.js | 6 ++- .../h/designtime/library.designtime.js | 2 +- .../messagebundle.properties | 0 .../messagebundle_en.properties | 0 .../resources/library/h/resources.json | 43 +++++++++---------- .../resources/library/h/some.js | 2 +- .../dest/resources/library/h/customBundle.js | 6 ++- .../h/designtime/library.designtime.js | 2 +- .../messagebundle.properties | 0 .../messagebundle_en.properties | 0 .../dest/resources/library/h/some.js | 2 +- .../h/designtime/library.designtime.js | 11 +++-- .../messagebundle.properties | 0 .../messagebundle_en.properties | 0 .../library.h/main/src/library/h/some.js | 10 +---- 15 files changed, 44 insertions(+), 40 deletions(-) rename test/expected/build/library.h/dest-resources-json/resources/library/h/{designtime => i18n}/messagebundle.properties (100%) rename test/expected/build/library.h/dest-resources-json/resources/library/h/{designtime => i18n}/messagebundle_en.properties (100%) rename test/expected/build/library.h/dest/resources/library/h/{designtime => i18n}/messagebundle.properties (100%) rename test/expected/build/library.h/dest/resources/library/h/{designtime => i18n}/messagebundle_en.properties (100%) rename test/fixtures/library.h/main/src/library/h/{designtime => i18n}/messagebundle.properties (100%) rename test/fixtures/library.h/main/src/library/h/{designtime => i18n}/messagebundle_en.properties (100%) diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/customBundle.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/customBundle.js index 5859d335b..21db087bb 100644 --- a/test/expected/build/library.h/dest-resources-json/resources/library/h/customBundle.js +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/customBundle.js @@ -10,5 +10,9 @@ console.log(" File "); */ console.log(" Library "); }, - "library/h/some.js":'/*!\n * Some fancy copyright\n */\nvar myexport=function(){"use strict";String("asd")}();' + "library/h/some.js":function(){/*! + * Some fancy copyright + */ +console.log(" Some "); +} }); diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/library.designtime.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/library.designtime.js index 9b3a27111..9b135171d 100644 --- a/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/library.designtime.js +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/library.designtime.js @@ -1,4 +1,4 @@ /*! * Some fancy copyright */ -sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file +var myexport=function(){"use strict";String("asd")}(); \ No newline at end of file diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/messagebundle.properties b/test/expected/build/library.h/dest-resources-json/resources/library/h/i18n/messagebundle.properties similarity index 100% rename from test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/messagebundle.properties rename to test/expected/build/library.h/dest-resources-json/resources/library/h/i18n/messagebundle.properties diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/messagebundle_en.properties b/test/expected/build/library.h/dest-resources-json/resources/library/h/i18n/messagebundle_en.properties similarity index 100% rename from test/expected/build/library.h/dest-resources-json/resources/library/h/designtime/messagebundle_en.properties rename to test/expected/build/library.h/dest-resources-json/resources/library/h/i18n/messagebundle_en.properties diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/resources.json b/test/expected/build/library.h/dest-resources-json/resources/library/h/resources.json index c4c5fb06a..8505cc2a4 100644 --- a/test/expected/build/library.h/dest-resources-json/resources/library/h/resources.json +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/resources.json @@ -83,7 +83,7 @@ { "name": "customBundle.js", "module": "library/h/customBundle.js", - "size": 368, + "size": 344, "merged": true, "included": [ "library/h/file.js", @@ -94,30 +94,33 @@ { "name": "designtime/library.designtime.js", "module": "library/h/designtime/library.designtime.js", - "size": 84, + "size": 86, + "requiresTopLevelScope": true, + "exposedGlobalNames": [ + "myexport" + ], + "format": "raw", "designtime": true }, { - "name": "designtime/messagebundle.properties", - "module": "library/h/designtime/messagebundle.properties", + "name": "file.js", + "module": "library/h/file.js", + "size": 54, + "format": "raw" + }, + { + "name": "i18n/messagebundle.properties", + "module": "library/h/i18n/messagebundle.properties", "size": 3, - "designtime": true, "locale": "", - "raw": "designtime/messagebundle.properties" + "raw": "i18n/messagebundle.properties" }, { - "name": "designtime/messagebundle_en.properties", - "module": "library/h/designtime/messagebundle_en.properties", + "name": "i18n/messagebundle_en.properties", + "module": "library/h/i18n/messagebundle_en.properties", "size": 3, - "designtime": true, "locale": "en", - "raw": "designtime/messagebundle.properties" - }, - { - "name": "file.js", - "module": "library/h/file.js", - "size": 54, - "format": "raw" + "raw": "i18n/messagebundle.properties" }, { "name": "library.js", @@ -138,16 +141,12 @@ }, { "name": "resources.json", - "size": 3445 + "size": 3383 }, { "name": "some.js", "module": "library/h/some.js", - "size": 86, - "requiresTopLevelScope": true, - "exposedGlobalNames": [ - "myexport" - ], + "size": 54, "format": "raw" } ] diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/some.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/some.js index 9b135171d..98e1e6665 100644 --- a/test/expected/build/library.h/dest-resources-json/resources/library/h/some.js +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/some.js @@ -1,4 +1,4 @@ /*! * Some fancy copyright */ -var myexport=function(){"use strict";String("asd")}(); \ No newline at end of file +console.log(" Some "); \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/customBundle.js b/test/expected/build/library.h/dest/resources/library/h/customBundle.js index 5859d335b..21db087bb 100644 --- a/test/expected/build/library.h/dest/resources/library/h/customBundle.js +++ b/test/expected/build/library.h/dest/resources/library/h/customBundle.js @@ -10,5 +10,9 @@ console.log(" File "); */ console.log(" Library "); }, - "library/h/some.js":'/*!\n * Some fancy copyright\n */\nvar myexport=function(){"use strict";String("asd")}();' + "library/h/some.js":function(){/*! + * Some fancy copyright + */ +console.log(" Some "); +} }); diff --git a/test/expected/build/library.h/dest/resources/library/h/designtime/library.designtime.js b/test/expected/build/library.h/dest/resources/library/h/designtime/library.designtime.js index 9b3a27111..9b135171d 100644 --- a/test/expected/build/library.h/dest/resources/library/h/designtime/library.designtime.js +++ b/test/expected/build/library.h/dest/resources/library/h/designtime/library.designtime.js @@ -1,4 +1,4 @@ /*! * Some fancy copyright */ -sap.ui.define([],function(){"use strict";return{}}); \ No newline at end of file +var myexport=function(){"use strict";String("asd")}(); \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/designtime/messagebundle.properties b/test/expected/build/library.h/dest/resources/library/h/i18n/messagebundle.properties similarity index 100% rename from test/expected/build/library.h/dest/resources/library/h/designtime/messagebundle.properties rename to test/expected/build/library.h/dest/resources/library/h/i18n/messagebundle.properties diff --git a/test/expected/build/library.h/dest/resources/library/h/designtime/messagebundle_en.properties b/test/expected/build/library.h/dest/resources/library/h/i18n/messagebundle_en.properties similarity index 100% rename from test/expected/build/library.h/dest/resources/library/h/designtime/messagebundle_en.properties rename to test/expected/build/library.h/dest/resources/library/h/i18n/messagebundle_en.properties diff --git a/test/expected/build/library.h/dest/resources/library/h/some.js b/test/expected/build/library.h/dest/resources/library/h/some.js index 9b135171d..98e1e6665 100644 --- a/test/expected/build/library.h/dest/resources/library/h/some.js +++ b/test/expected/build/library.h/dest/resources/library/h/some.js @@ -1,4 +1,4 @@ /*! * Some fancy copyright */ -var myexport=function(){"use strict";String("asd")}(); \ No newline at end of file +console.log(" Some "); \ No newline at end of file diff --git a/test/fixtures/library.h/main/src/library/h/designtime/library.designtime.js b/test/fixtures/library.h/main/src/library/h/designtime/library.designtime.js index e3434b297..e961048c1 100644 --- a/test/fixtures/library.h/main/src/library/h/designtime/library.designtime.js +++ b/test/fixtures/library.h/main/src/library/h/designtime/library.designtime.js @@ -3,9 +3,12 @@ */ /** - * Initialization of designtime Code and shared classes for the library sap.ui.core. + * designtime and global export */ -sap.ui.define([], function() { +var myexport = (function() { + "use strict"; - return {}; -}); \ No newline at end of file + + String("asd"); + +}()); diff --git a/test/fixtures/library.h/main/src/library/h/designtime/messagebundle.properties b/test/fixtures/library.h/main/src/library/h/i18n/messagebundle.properties similarity index 100% rename from test/fixtures/library.h/main/src/library/h/designtime/messagebundle.properties rename to test/fixtures/library.h/main/src/library/h/i18n/messagebundle.properties diff --git a/test/fixtures/library.h/main/src/library/h/designtime/messagebundle_en.properties b/test/fixtures/library.h/main/src/library/h/i18n/messagebundle_en.properties similarity index 100% rename from test/fixtures/library.h/main/src/library/h/designtime/messagebundle_en.properties rename to test/fixtures/library.h/main/src/library/h/i18n/messagebundle_en.properties diff --git a/test/fixtures/library.h/main/src/library/h/some.js b/test/fixtures/library.h/main/src/library/h/some.js index dffe6bd28..f14efacd4 100644 --- a/test/fixtures/library.h/main/src/library/h/some.js +++ b/test/fixtures/library.h/main/src/library/h/some.js @@ -1,10 +1,4 @@ /*! - * Some fancy copyright + * ${copyright} */ -var myexport = (function() { - - "use strict"; - - String("asd"); - -}()); +console.log(' Some '); From a3963b983f3555d5a6bf28c25f857160e5113167 Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Fri, 21 Aug 2020 15:01:20 +0200 Subject: [PATCH 86/88] Add integration test for uglifier ensure @ui5-bundle-raw-include comment is also preserved in Builder.js --- lib/lbt/bundle/Builder.js | 2 +- .../resources/library/h/customBundle.js | 6 ++++++ .../resources/library/h/resources.json | 16 +++++++++++----- .../resources/library/h/some.js | 1 + .../dest/resources/library/h/customBundle.js | 6 ++++++ .../library.h/dest/resources/library/h/some.js | 1 + .../library.h/main/src/library/h/some.js | 1 + test/lib/builder/builder.js | 10 +++++++++- 8 files changed, 36 insertions(+), 7 deletions(-) diff --git a/lib/lbt/bundle/Builder.js b/lib/lbt/bundle/Builder.js index 7b6686d55..6892d3eb2 100644 --- a/lib/lbt/bundle/Builder.js +++ b/lib/lbt/bundle/Builder.js @@ -20,7 +20,7 @@ const {SectionType} = require("./BundleDefinition"); const BundleWriter = require("./BundleWriter"); const log = require("@ui5/logger").getLogger("lbt:bundle:Builder"); -const copyrightCommentsPattern = /copyright|\(c\)(?:[0-9]+|\s+[0-9A-za-z])|released under|license|\u00a9/i; +const copyrightCommentsPattern = /copyright|\(c\)(?:[0-9]+|\s+[0-9A-za-z])|released under|license|\u00a9|^@ui5-bundle-raw-include |^@ui5-bundle /i; const xmlHtmlPrePattern = /<(?:\w+:)?pre>/; const strReplacements = { diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/customBundle.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/customBundle.js index 21db087bb..e9e0e00ed 100644 --- a/test/expected/build/library.h/dest-resources-json/resources/library/h/customBundle.js +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/customBundle.js @@ -13,6 +13,12 @@ console.log(" Library "); "library/h/some.js":function(){/*! * Some fancy copyright */ +//@ui5-bundle-raw-include library/h/other.js console.log(" Some "); } }); +//@ui5-bundle-raw-include library/h/not.js +/*! + * Some fancy copyright + */ +console.log(" Not including "); \ No newline at end of file diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/resources.json b/test/expected/build/library.h/dest-resources-json/resources/library/h/resources.json index 8505cc2a4..d0820dcf4 100644 --- a/test/expected/build/library.h/dest-resources-json/resources/library/h/resources.json +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/resources.json @@ -83,12 +83,14 @@ { "name": "customBundle.js", "module": "library/h/customBundle.js", - "size": 344, + "size": 495, "merged": true, "included": [ "library/h/file.js", "library/h/library.js", - "library/h/some.js" + "library/h/some.js", + "library/h/other.js", + "library/h/not.js" ] }, { @@ -141,13 +143,17 @@ }, { "name": "resources.json", - "size": 3383 + "size": 3500 }, { "name": "some.js", "module": "library/h/some.js", - "size": 54, - "format": "raw" + "size": 99, + "format": "raw", + "merged": true, + "included": [ + "library/h/other.js" + ] } ] } \ No newline at end of file diff --git a/test/expected/build/library.h/dest-resources-json/resources/library/h/some.js b/test/expected/build/library.h/dest-resources-json/resources/library/h/some.js index 98e1e6665..1e86f9afc 100644 --- a/test/expected/build/library.h/dest-resources-json/resources/library/h/some.js +++ b/test/expected/build/library.h/dest-resources-json/resources/library/h/some.js @@ -1,4 +1,5 @@ /*! * Some fancy copyright */ +//@ui5-bundle-raw-include library/h/other.js console.log(" Some "); \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/customBundle.js b/test/expected/build/library.h/dest/resources/library/h/customBundle.js index 21db087bb..e9e0e00ed 100644 --- a/test/expected/build/library.h/dest/resources/library/h/customBundle.js +++ b/test/expected/build/library.h/dest/resources/library/h/customBundle.js @@ -13,6 +13,12 @@ console.log(" Library "); "library/h/some.js":function(){/*! * Some fancy copyright */ +//@ui5-bundle-raw-include library/h/other.js console.log(" Some "); } }); +//@ui5-bundle-raw-include library/h/not.js +/*! + * Some fancy copyright + */ +console.log(" Not including "); \ No newline at end of file diff --git a/test/expected/build/library.h/dest/resources/library/h/some.js b/test/expected/build/library.h/dest/resources/library/h/some.js index 98e1e6665..1e86f9afc 100644 --- a/test/expected/build/library.h/dest/resources/library/h/some.js +++ b/test/expected/build/library.h/dest/resources/library/h/some.js @@ -1,4 +1,5 @@ /*! * Some fancy copyright */ +//@ui5-bundle-raw-include library/h/other.js console.log(" Some "); \ No newline at end of file diff --git a/test/fixtures/library.h/main/src/library/h/some.js b/test/fixtures/library.h/main/src/library/h/some.js index f14efacd4..c1a44398b 100644 --- a/test/fixtures/library.h/main/src/library/h/some.js +++ b/test/fixtures/library.h/main/src/library/h/some.js @@ -1,4 +1,5 @@ /*! * ${copyright} */ +//@ui5-bundle-raw-include library/h/other.js console.log(' Some '); diff --git a/test/lib/builder/builder.js b/test/lib/builder/builder.js index fb640e6fb..06c27325a 100644 --- a/test/lib/builder/builder.js +++ b/test/lib/builder/builder.js @@ -1275,11 +1275,19 @@ const libraryHTree = { "library/h/some.js", "library/h/library.js", "library/h/file.js", - "!library/h/not.js", "!library/h/components/" ], "resolve": false, "renderer": false + }, { + "mode": "raw", + "filters": [ + "library/h/not.js" + ], + "resolve": true, + "declareModules": false, + "sort": true, + "renderer": false }] }, "bundleOptions": { From 01a5634a8c5d75248e67d69db58f8aa54511685c Mon Sep 17 00:00:00 2001 From: Tobias Sorn Date: Mon, 24 Aug 2020 10:38:22 +0200 Subject: [PATCH 87/88] Add support information Not supported with generateStandaloneAppBundle task. --- lib/tasks/generateResourcesJson.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index 28bdbf94e..1db425e73 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -47,6 +47,9 @@ function getCreatorOptions(projectName) { * The detailed structure can be found in the documentation: * https://openui5.hana.ondemand.com/#topic/adcbcf8b50924556ab3f321fcd9353ea * + * Not supported in combination with task: generateStandaloneAppBundle + * Therefore it is also not supported in combination with self-contained build. + * * @example sample resources.json * { * "_version": "1.1.0", From a58c11e0e8a37480d5e614431d843beb088f2575 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Mon, 24 Aug 2020 13:19:48 +0200 Subject: [PATCH 88/88] JSDoc round off --- lib/tasks/generateResourcesJson.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/tasks/generateResourcesJson.js b/lib/tasks/generateResourcesJson.js index 1db425e73..399aa524d 100644 --- a/lib/tasks/generateResourcesJson.js +++ b/lib/tasks/generateResourcesJson.js @@ -44,15 +44,19 @@ function getCreatorOptions(projectName) { /** * Task for creating a resources.json file, describing all productive build resources. * + *

    * The detailed structure can be found in the documentation: - * https://openui5.hana.ondemand.com/#topic/adcbcf8b50924556ab3f321fcd9353ea + * {@link https://openui5.hana.ondemand.com/#topic/adcbcf8b50924556ab3f321fcd9353ea} + *

    * - * Not supported in combination with task: generateStandaloneAppBundle + *

    + * Not supported in combination with task {@link module:@ui5/builder.tasks.generateStandaloneAppBundle}. * Therefore it is also not supported in combination with self-contained build. + *

    * * @example sample resources.json - * { - * "_version": "1.1.0", + * { + * "_version": "1.1.0", * "resources": [ * { * "name": "Component-preload.js", @@ -88,8 +92,8 @@ function getCreatorOptions(projectName) { * "dynRequired": true, * "support": true * } - * ] - * } + * ] + * } * * @public * @alias module:@ui5/builder.tasks.generateResourcesJson