-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathgenerateResourcesJson.js
More file actions
136 lines (129 loc) · 3.83 KB
/
generateResourcesJson.js
File metadata and controls
136 lines (129 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import resourceListCreator from "../processors/resourceListCreator.js";
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 = {};
// TODO: Move configuration into ui5.yaml
if ( projectName === "sap.ui.core" ) {
Object.assign(creatorOptions, {
externalResources: {
"sap/ui/core": [
"*",
"sap/base/",
"sap/ui/"
]
}
});
} else if ( projectName === "sap.ui.integration" ) {
Object.assign(creatorOptions, {
externalResources: {
"sap/ui/integration": [
"sap-ui-integration*.js",
]
}
});
}
return creatorOptions;
}
/**
* @public
* @module @ui5/builder/tasks/generateResourcesJson
*/
/**
* Task for creating a resources.json file, describing all productive build resources.
*
* <p>
* The detailed structure can be found in the documentation:
* {@link https://sdk.openui5.org/topic/adcbcf8b50924556ab3f321fcd9353ea}
* </p>
*
* <p>
* Not supported in combination with task {@link @ui5/builder/tasks/bundlers/generateStandaloneAppBundle}.
* Therefore it is also not supported in combination with self-contained build.
* </p>
*
* <caption>sample resources.json</caption>
* ```
* const resourcesJson = {
* "_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
* @function default
* @static
*
* @param {object} parameters Parameters
* @param {@ui5/fs/DuplexCollection} parameters.workspace DuplexCollection to read and write files
* @param {@ui5/fs/AbstractReader} parameters.dependencies Reader or Collection to read dependency files
* @param {@ui5/project/build/helpers/TaskUtil|object} [parameters.taskUtil] TaskUtil
* @param {object} parameters.options Options
* @param {string} parameters.options.projectName Project name
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
*/
export default async function({workspace, dependencies, taskUtil, options: {projectName}}) {
let resources = await workspace.byGlob(["/resources/**/*"].concat(DEFAULT_EXCLUDES));
let dependencyResources =
await dependencies.byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}");
if (taskUtil) {
// Filter out resources that will be omitted from the build results
resources = resources.filter((resource) => {
return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.OmitFromBuildResult);
});
dependencyResources = dependencyResources.filter((resource) => {
return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.OmitFromBuildResult);
});
}
const resourceLists = await resourceListCreator({
resources,
dependencyResources,
options: getCreatorOptions(projectName),
});
await Promise.all(
resourceLists.map((resourceList) => workspace.write(resourceList))
);
}