Skip to content

Commit

Permalink
Add integration test tailored for resourceListCreator
Browse files Browse the repository at this point in the history
  • Loading branch information
codeworrior committed Dec 29, 2019
1 parent b7cb970 commit dcb2252
Show file tree
Hide file tree
Showing 50 changed files with 1,051 additions and 26 deletions.
59 changes: 33 additions & 26 deletions lib/processors/resourceListCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
});
}
});
}

Expand Down
7 changes: 7 additions & 0 deletions lib/tasks/generateResourcesJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
{
"name": ".library"
},
{
"name": "library-dbg.js",
"module": "library/e/library.js",
"isDebug": true
},
{
"name": "library.js",
"module": "library/e/library.js"
},
{
"name": "manifest.json"
},
{
"name": "some-dbg.js",
"module": "library/e/some.js",
"isDebug": true
},
{
"name": "some.js",
"module": "library/e/some.js"
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -12,20 +21,44 @@
"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",
"required": [
"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",
"required": [
"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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -15,27 +24,61 @@
"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",
"required": [
"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",
"required": [
"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",
"required": [
"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"
Expand All @@ -44,6 +87,9 @@
"name": "library.js",
"module": "library/h/library.js"
},
{
"name": "manifest.json"
},
{
"name": "not.js",
"module": "library/h/not.js"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"required": [
"sap/ui/core/Core.js"
]
},
{
"name": "manifest.json"
}
]
}
19 changes: 19 additions & 0 deletions test/expected/build/library.n/dest/resources/library/n/.library
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<library xmlns="http://www.sap.com/sap.ui.library.xsd" >

<name>library.n</name>
<vendor>SAP SE</vendor>
<copyright>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.</copyright>
<version>1.0.0</version>

<documentation>Library N</documentation>

<dependencies>
<dependency>
<libraryName>sap.ui.core</libraryName>
</dependency>
</dependencies>

</library>
Loading

0 comments on commit dcb2252

Please sign in to comment.