@ui5/builder 3.0.0-alpha.1 → 3.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +867 -0
- package/index.js +0 -43
- package/lib/lbt/analyzer/FioriElementsAnalyzer.js +23 -12
- package/lib/lbt/analyzer/JSModuleAnalyzer.js +115 -61
- package/lib/lbt/analyzer/SmartTemplateAnalyzer.js +23 -12
- package/lib/lbt/analyzer/XMLCompositeAnalyzer.js +29 -19
- package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +2 -1
- package/lib/lbt/analyzer/analyzeLibraryJS.js +15 -0
- package/lib/lbt/bundle/Builder.js +365 -138
- package/lib/lbt/bundle/BundleWriter.js +17 -0
- package/lib/lbt/bundle/Resolver.js +2 -2
- package/lib/lbt/calls/SapUiDefine.js +13 -7
- package/lib/lbt/resources/LocatorResource.js +7 -7
- package/lib/lbt/resources/LocatorResourcePool.js +8 -4
- package/lib/lbt/resources/ResourceCollector.js +22 -15
- package/lib/lbt/resources/ResourceInfoList.js +0 -1
- package/lib/lbt/resources/ResourcePool.js +7 -6
- package/lib/lbt/utils/ASTUtils.js +45 -18
- package/lib/lbt/utils/escapePropertiesFile.js +3 -6
- package/lib/lbt/utils/parseUtils.js +1 -1
- package/lib/processors/bundlers/moduleBundler.js +31 -10
- package/lib/processors/jsdoc/lib/createIndexFiles.js +1 -1
- package/lib/processors/jsdoc/lib/transformApiJson.js +78 -22
- package/lib/processors/jsdoc/lib/ui5/plugin.js +414 -122
- package/lib/processors/jsdoc/lib/ui5/template/publish.js +112 -91
- package/lib/processors/jsdoc/lib/ui5/template/utils/versionUtil.js +1 -1
- package/lib/processors/manifestCreator.js +8 -45
- package/lib/processors/minifier.js +11 -5
- package/lib/tasks/buildThemes.js +1 -1
- package/lib/tasks/bundlers/generateBundle.js +70 -30
- package/lib/tasks/bundlers/generateComponentPreload.js +26 -19
- package/lib/tasks/bundlers/generateFlexChangesBundle.js +10 -5
- package/lib/tasks/bundlers/generateLibraryPreload.js +113 -94
- package/lib/tasks/bundlers/generateManifestBundle.js +8 -10
- package/lib/tasks/bundlers/generateStandaloneAppBundle.js +42 -10
- package/lib/tasks/bundlers/utils/createModuleNameMapping.js +31 -0
- package/lib/tasks/generateCachebusterInfo.js +7 -3
- package/lib/tasks/generateLibraryManifest.js +6 -8
- package/lib/tasks/generateResourcesJson.js +3 -3
- package/lib/tasks/generateThemeDesignerResources.js +118 -2
- package/lib/tasks/generateVersionInfo.js +5 -5
- package/lib/tasks/jsdoc/generateJsdoc.js +1 -1
- package/lib/tasks/minify.js +14 -4
- package/lib/tasks/taskRepository.js +1 -13
- package/lib/tasks/transformBootstrapHtml.js +6 -1
- package/package.json +13 -11
- package/lib/builder/BuildContext.js +0 -56
- package/lib/builder/ProjectBuildContext.js +0 -57
- package/lib/builder/builder.js +0 -419
- package/lib/tasks/TaskUtil.js +0 -160
- package/lib/types/AbstractBuilder.js +0 -270
- package/lib/types/AbstractFormatter.js +0 -66
- package/lib/types/AbstractUi5Formatter.js +0 -95
- package/lib/types/application/ApplicationBuilder.js +0 -211
- package/lib/types/application/ApplicationFormatter.js +0 -227
- package/lib/types/application/applicationType.js +0 -15
- package/lib/types/library/LibraryBuilder.js +0 -231
- package/lib/types/library/LibraryFormatter.js +0 -519
- package/lib/types/library/libraryType.js +0 -15
- package/lib/types/module/ModuleBuilder.js +0 -7
- package/lib/types/module/ModuleFormatter.js +0 -54
- package/lib/types/module/moduleType.js +0 -15
- package/lib/types/themeLibrary/ThemeLibraryBuilder.js +0 -63
- package/lib/types/themeLibrary/ThemeLibraryFormatter.js +0 -90
- package/lib/types/themeLibrary/themeLibraryType.js +0 -15
- package/lib/types/typeRepository.js +0 -46
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const ResourceTagCollection = require("@ui5/fs").ResourceTagCollection;
|
|
2
|
-
|
|
3
|
-
// Note: When adding standard tags, always update the public documentation in TaskUtil
|
|
4
|
-
// (Type "module:@ui5/builder.tasks.TaskUtil~StandardBuildTags")
|
|
5
|
-
const STANDARD_TAGS = {
|
|
6
|
-
OmitFromBuildResult: "ui5:OmitFromBuildResult",
|
|
7
|
-
IsBundle: "ui5:IsBundle",
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Build context of a single project. Always part of an overall
|
|
12
|
-
* [Build Context]{@link module:@ui5/builder.builder.BuildContext}
|
|
13
|
-
*
|
|
14
|
-
* @private
|
|
15
|
-
* @memberof module:@ui5/builder.builder
|
|
16
|
-
*/
|
|
17
|
-
class ProjectBuildContext {
|
|
18
|
-
constructor({buildContext, globalTags, project, resources}) {
|
|
19
|
-
if (!buildContext || !globalTags || !project || !resources) {
|
|
20
|
-
throw new Error(`One or more mandatory parameters are missing`);
|
|
21
|
-
}
|
|
22
|
-
this._buildContext = buildContext;
|
|
23
|
-
this._project = project;
|
|
24
|
-
// this.resources = resources;
|
|
25
|
-
this.queues = {
|
|
26
|
-
cleanup: []
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
this.STANDARD_TAGS = Object.assign({}, STANDARD_TAGS, globalTags);
|
|
30
|
-
Object.freeze(this.STANDARD_TAGS);
|
|
31
|
-
|
|
32
|
-
this._resourceTagCollection = new ResourceTagCollection({
|
|
33
|
-
allowedTags: Object.values(this.STANDARD_TAGS),
|
|
34
|
-
superCollection: this._buildContext.getResourceTagCollection()
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
isRootProject() {
|
|
39
|
-
return this._project === this._buildContext.getRootProject();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
registerCleanupTask(callback) {
|
|
43
|
-
this.queues.cleanup.push(callback);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async executeCleanupTasks() {
|
|
47
|
-
await Promise.all(this.queues.cleanup.map((callback) => {
|
|
48
|
-
return callback();
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
getResourceTagCollection() {
|
|
53
|
-
return this._resourceTagCollection;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
module.exports = ProjectBuildContext;
|
package/lib/builder/builder.js
DELETED
|
@@ -1,419 +0,0 @@
|
|
|
1
|
-
const {promisify} = require("util");
|
|
2
|
-
const rimraf = promisify(require("rimraf"));
|
|
3
|
-
const log = require("@ui5/logger").getGroupLogger("builder:builder");
|
|
4
|
-
const resourceFactory = require("@ui5/fs").resourceFactory;
|
|
5
|
-
const MemAdapter = require("@ui5/fs").adapters.Memory;
|
|
6
|
-
const typeRepository = require("../types/typeRepository");
|
|
7
|
-
const taskRepository = require("../tasks/taskRepository");
|
|
8
|
-
const BuildContext = require("./BuildContext");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// Set of tasks for development
|
|
12
|
-
const devTasks = [
|
|
13
|
-
"replaceCopyright",
|
|
14
|
-
"replaceVersion",
|
|
15
|
-
"replaceBuildtime",
|
|
16
|
-
"buildThemes"
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Calculates the elapsed build time and returns a prettified output
|
|
21
|
-
*
|
|
22
|
-
* @private
|
|
23
|
-
* @param {Array} startTime Array provided by <code>process.hrtime()</code>
|
|
24
|
-
* @returns {string} Difference between now and the provided time array as formatted string
|
|
25
|
-
*/
|
|
26
|
-
function getElapsedTime(startTime) {
|
|
27
|
-
const prettyHrtime = require("pretty-hrtime");
|
|
28
|
-
const timeDiff = process.hrtime(startTime);
|
|
29
|
-
return prettyHrtime(timeDiff);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Creates the list of tasks to be executed by the build process
|
|
34
|
-
*
|
|
35
|
-
* Sets specific tasks to be disabled by default, these tasks need to be included explicitly.
|
|
36
|
-
* Based on the selected build mode (dev|selfContained|preload), different tasks are enabled.
|
|
37
|
-
* Tasks can be enabled or disabled. The wildcard <code>*</code> is also supported and affects all tasks.
|
|
38
|
-
*
|
|
39
|
-
* @private
|
|
40
|
-
* @param {object} parameters
|
|
41
|
-
* @param {boolean} parameters.dev Sets development mode, which only runs essential tasks
|
|
42
|
-
* @param {boolean} parameters.selfContained
|
|
43
|
-
* True if a the build should be self-contained or false for prelead build bundles
|
|
44
|
-
* @param {boolean} parameters.jsdoc True if a JSDoc build should be executed
|
|
45
|
-
* @param {Array} parameters.includedTasks Task list to be included from build
|
|
46
|
-
* @param {Array} parameters.excludedTasks Task list to be excluded from build
|
|
47
|
-
* @returns {Array} Return a task list for the builder
|
|
48
|
-
*/
|
|
49
|
-
function composeTaskList({dev, selfContained, jsdoc, includedTasks, excludedTasks}) {
|
|
50
|
-
const definedTasks = taskRepository.getAllTaskNames();
|
|
51
|
-
let selectedTasks = definedTasks.reduce((list, key) => {
|
|
52
|
-
list[key] = true;
|
|
53
|
-
return list;
|
|
54
|
-
}, {});
|
|
55
|
-
|
|
56
|
-
// Exclude non default tasks
|
|
57
|
-
selectedTasks.generateManifestBundle = false;
|
|
58
|
-
selectedTasks.generateStandaloneAppBundle = false;
|
|
59
|
-
selectedTasks.transformBootstrapHtml = false;
|
|
60
|
-
selectedTasks.generateJsdoc = false;
|
|
61
|
-
selectedTasks.executeJsdocSdkTransformation = false;
|
|
62
|
-
selectedTasks.generateCachebusterInfo = false;
|
|
63
|
-
selectedTasks.generateApiIndex = false;
|
|
64
|
-
selectedTasks.generateThemeDesignerResources = false;
|
|
65
|
-
|
|
66
|
-
// Disable generateResourcesJson due to performance.
|
|
67
|
-
// When executed it analyzes each module's AST and therefore
|
|
68
|
-
// takes up much time (~10% more)
|
|
69
|
-
selectedTasks.generateResourcesJson = false;
|
|
70
|
-
|
|
71
|
-
if (selfContained) {
|
|
72
|
-
// No preloads, bundle only
|
|
73
|
-
selectedTasks.generateComponentPreload = false;
|
|
74
|
-
selectedTasks.generateStandaloneAppBundle = true;
|
|
75
|
-
selectedTasks.transformBootstrapHtml = true;
|
|
76
|
-
selectedTasks.generateLibraryPreload = false;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// TODO 3.0: exclude generateVersionInfo if not --all is used
|
|
80
|
-
|
|
81
|
-
if (jsdoc) {
|
|
82
|
-
// Include JSDoc tasks
|
|
83
|
-
selectedTasks.generateJsdoc = true;
|
|
84
|
-
selectedTasks.executeJsdocSdkTransformation = true;
|
|
85
|
-
selectedTasks.generateApiIndex = true;
|
|
86
|
-
|
|
87
|
-
// Include theme build as required for SDK
|
|
88
|
-
selectedTasks.buildThemes = true;
|
|
89
|
-
|
|
90
|
-
// Exclude all tasks not relevant to JSDoc generation
|
|
91
|
-
selectedTasks.replaceCopyright = false;
|
|
92
|
-
selectedTasks.replaceVersion = false;
|
|
93
|
-
selectedTasks.replaceBuildtime = false;
|
|
94
|
-
selectedTasks.generateComponentPreload = false;
|
|
95
|
-
selectedTasks.generateLibraryPreload = false;
|
|
96
|
-
selectedTasks.generateLibraryManifest = false;
|
|
97
|
-
selectedTasks.minify = false;
|
|
98
|
-
selectedTasks.generateFlexChangesBundle = false;
|
|
99
|
-
selectedTasks.generateManifestBundle = false;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Only run essential tasks in development mode, it is not desired to run time consuming tasks during development.
|
|
103
|
-
if (dev) {
|
|
104
|
-
// Overwrite all other tasks with noop promise
|
|
105
|
-
Object.keys(selectedTasks).forEach((key) => {
|
|
106
|
-
if (devTasks.indexOf(key) === -1) {
|
|
107
|
-
selectedTasks[key] = false;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Exclude tasks
|
|
113
|
-
for (let i = 0; i < excludedTasks.length; i++) {
|
|
114
|
-
const taskName = excludedTasks[i];
|
|
115
|
-
if (taskName === "*") {
|
|
116
|
-
Object.keys(selectedTasks).forEach((sKey) => {
|
|
117
|
-
selectedTasks[sKey] = false;
|
|
118
|
-
});
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
if (selectedTasks[taskName] === true) {
|
|
122
|
-
selectedTasks[taskName] = false;
|
|
123
|
-
} else if (typeof selectedTasks[taskName] === "undefined") {
|
|
124
|
-
log.warn(`Unable to exclude task '${taskName}': Task is unknown`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Include tasks
|
|
129
|
-
for (let i = 0; i < includedTasks.length; i++) {
|
|
130
|
-
const taskName = includedTasks[i];
|
|
131
|
-
if (taskName === "*") {
|
|
132
|
-
Object.keys(selectedTasks).forEach((sKey) => {
|
|
133
|
-
selectedTasks[sKey] = true;
|
|
134
|
-
});
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
if (selectedTasks[taskName] === false) {
|
|
138
|
-
selectedTasks[taskName] = true;
|
|
139
|
-
} else if (typeof selectedTasks[taskName] === "undefined") {
|
|
140
|
-
log.warn(`Unable to include task '${taskName}': Task is unknown`);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Filter only for tasks that will be executed
|
|
145
|
-
selectedTasks = Object.keys(selectedTasks).filter((task) => selectedTasks[task]);
|
|
146
|
-
|
|
147
|
-
return selectedTasks;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async function executeCleanupTasks(buildContext) {
|
|
151
|
-
log.info("Executing cleanup tasks...");
|
|
152
|
-
await buildContext.executeCleanupTasks();
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function registerCleanupSigHooks(buildContext) {
|
|
156
|
-
function createListener(exitCode) {
|
|
157
|
-
return function() {
|
|
158
|
-
// Asynchronously cleanup resources, then exit
|
|
159
|
-
executeCleanupTasks(buildContext).then(() => {
|
|
160
|
-
process.exit(exitCode);
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
const processSignals = {
|
|
166
|
-
"SIGHUP": createListener(128 + 1),
|
|
167
|
-
"SIGINT": createListener(128 + 2),
|
|
168
|
-
"SIGTERM": createListener(128 + 15),
|
|
169
|
-
"SIGBREAK": createListener(128 + 21)
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
for (const signal of Object.keys(processSignals)) {
|
|
173
|
-
process.on(signal, processSignals[signal]);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// == TO BE DISCUSSED: Also cleanup for unhandled rejections and exceptions?
|
|
177
|
-
// Add additional events like signals since they are registered on the process
|
|
178
|
-
// event emitter in a similar fashion
|
|
179
|
-
// processSignals["unhandledRejection"] = createListener(1);
|
|
180
|
-
// process.once("unhandledRejection", processSignals["unhandledRejection"]);
|
|
181
|
-
// processSignals["uncaughtException"] = function(err, origin) {
|
|
182
|
-
// const fs = require("fs");
|
|
183
|
-
// fs.writeSync(
|
|
184
|
-
// process.stderr.fd,
|
|
185
|
-
// `Caught exception: ${err}\n` +
|
|
186
|
-
// `Exception origin: ${origin}`
|
|
187
|
-
// );
|
|
188
|
-
// createListener(1)();
|
|
189
|
-
// };
|
|
190
|
-
// process.once("uncaughtException", processSignals["uncaughtException"]);
|
|
191
|
-
|
|
192
|
-
return processSignals;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function deregisterCleanupSigHooks(signals) {
|
|
196
|
-
for (const signal of Object.keys(signals)) {
|
|
197
|
-
process.removeListener(signal, signals[signal]);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Builder
|
|
203
|
-
*
|
|
204
|
-
* @public
|
|
205
|
-
* @namespace
|
|
206
|
-
* @alias module:@ui5/builder.builder
|
|
207
|
-
*/
|
|
208
|
-
module.exports = {
|
|
209
|
-
/**
|
|
210
|
-
* Configures the project build and starts it.
|
|
211
|
-
*
|
|
212
|
-
* @public
|
|
213
|
-
* @param {object} parameters Parameters
|
|
214
|
-
* @param {object} parameters.tree Project tree as generated by the
|
|
215
|
-
* [@ui5/project.normalizer]{@link module:@ui5/project.normalizer}
|
|
216
|
-
* @param {string} parameters.destPath Target path
|
|
217
|
-
* @param {boolean} [parameters.cleanDest=false] Decides whether project should clean the target path before build
|
|
218
|
-
* @param {boolean} [parameters.buildDependencies=false] Decides whether project dependencies are built as well
|
|
219
|
-
* @param {Array.<string|RegExp>} [parameters.includedDependencies=[]]
|
|
220
|
-
* List of build dependencies to be included if buildDependencies is true
|
|
221
|
-
* @param {Array.<string|RegExp>} [parameters.excludedDependencies=[]]
|
|
222
|
-
* List of build dependencies to be excluded if buildDependencies is true.
|
|
223
|
-
* If the wildcard '*' is provided, only the included dependencies will be built.
|
|
224
|
-
* @param {boolean} [parameters.dev=false]
|
|
225
|
-
* Decides whether a development build should be activated (skips non-essential and time-intensive tasks)
|
|
226
|
-
* @param {boolean} [parameters.selfContained=false] Flag to activate self contained build
|
|
227
|
-
* @param {boolean} [parameters.jsdoc=false] Flag to activate JSDoc build
|
|
228
|
-
* @param {Array.<string>} [parameters.includedTasks=[]] List of tasks to be included
|
|
229
|
-
* @param {Array.<string>} [parameters.excludedTasks=[]] List of tasks to be excluded.
|
|
230
|
-
* If the wildcard '*' is provided, only the included tasks will be executed.
|
|
231
|
-
* @param {Array.<string>} [parameters.devExcludeProject=[]] List of projects to be excluded from development build
|
|
232
|
-
* @returns {Promise} Promise resolving to <code>undefined</code> once build has finished
|
|
233
|
-
*/
|
|
234
|
-
async build({
|
|
235
|
-
tree, destPath, cleanDest = false,
|
|
236
|
-
buildDependencies = false, includedDependencies = [], excludedDependencies = [],
|
|
237
|
-
dev = false, selfContained = false, jsdoc = false,
|
|
238
|
-
includedTasks = [], excludedTasks = [], devExcludeProject = []
|
|
239
|
-
}) {
|
|
240
|
-
const startTime = process.hrtime();
|
|
241
|
-
log.info(`Building project ${tree.metadata.name}` + (buildDependencies ? "" : " not") +
|
|
242
|
-
" including dependencies..." + (dev ? " [dev mode]" : ""));
|
|
243
|
-
log.verbose(`Building to ${destPath}...`);
|
|
244
|
-
|
|
245
|
-
const selectedTasks = composeTaskList({dev, selfContained, jsdoc, includedTasks, excludedTasks});
|
|
246
|
-
|
|
247
|
-
const fsTarget = resourceFactory.createAdapter({
|
|
248
|
-
fsBasePath: destPath,
|
|
249
|
-
virBasePath: "/"
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
const buildContext = new BuildContext({rootProject: tree});
|
|
253
|
-
const cleanupSigHooks = registerCleanupSigHooks(buildContext);
|
|
254
|
-
|
|
255
|
-
const projects = {}; // Unique project index to prevent building the same project multiple times
|
|
256
|
-
const projectWriters = {}; // Collection of memory adapters of already built libraries
|
|
257
|
-
function projectFilter(project) {
|
|
258
|
-
function projectMatchesAny(deps) {
|
|
259
|
-
return deps.some((dep) => dep instanceof RegExp ?
|
|
260
|
-
dep.test(project.metadata.name) : dep === project.metadata.name);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// if everything is included, this overrules exclude lists
|
|
264
|
-
if (includedDependencies.includes("*")) return true;
|
|
265
|
-
let test = !excludedDependencies.includes("*"); // exclude everything?
|
|
266
|
-
|
|
267
|
-
if (test && projectMatchesAny(excludedDependencies)) {
|
|
268
|
-
test = false;
|
|
269
|
-
}
|
|
270
|
-
if (!test && projectMatchesAny(includedDependencies)) {
|
|
271
|
-
test = true;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return test;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
const projectCountMarker = {};
|
|
278
|
-
function projectCount(project, count = 0) {
|
|
279
|
-
if (buildDependencies) {
|
|
280
|
-
count = project.dependencies.filter(projectFilter).reduce((depCount, depProject) => {
|
|
281
|
-
return projectCount(depProject, depCount);
|
|
282
|
-
}, count);
|
|
283
|
-
}
|
|
284
|
-
if (!projectCountMarker[project.metadata.name]) {
|
|
285
|
-
count++;
|
|
286
|
-
projectCountMarker[project.metadata.name] = true;
|
|
287
|
-
}
|
|
288
|
-
return count;
|
|
289
|
-
}
|
|
290
|
-
const buildLogger = log.createTaskLogger("🛠 ", projectCount(tree));
|
|
291
|
-
|
|
292
|
-
function buildProject(project) {
|
|
293
|
-
const projectBasePath = `/resources/${project.metadata.namespace}`;
|
|
294
|
-
let depPromise;
|
|
295
|
-
let projectTasks = selectedTasks;
|
|
296
|
-
|
|
297
|
-
// Build dependencies in sequence as it is far easier to detect issues and reduces
|
|
298
|
-
// side effects or other issues such as too many open files
|
|
299
|
-
if (buildDependencies) {
|
|
300
|
-
depPromise = project.dependencies.filter(projectFilter).reduce(function(p, depProject) {
|
|
301
|
-
return p.then(() => buildProject(depProject));
|
|
302
|
-
}, Promise.resolve());
|
|
303
|
-
} else {
|
|
304
|
-
depPromise = Promise.resolve();
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// Build the project after all dependencies have been built
|
|
308
|
-
return depPromise.then(() => {
|
|
309
|
-
if (projects[project.metadata.name]) {
|
|
310
|
-
return Promise.resolve();
|
|
311
|
-
} else {
|
|
312
|
-
projects[project.metadata.name] = true;
|
|
313
|
-
}
|
|
314
|
-
buildLogger.startWork(`Building project ${project.metadata.name}`);
|
|
315
|
-
|
|
316
|
-
const projectType = typeRepository.getType(project.type);
|
|
317
|
-
const resourceCollections = resourceFactory.createCollectionsForTree(project, {
|
|
318
|
-
virtualReaders: projectWriters,
|
|
319
|
-
getVirtualBasePathPrefix: function({project, virBasePath}) {
|
|
320
|
-
if (project.type === "application" && project.metadata.namespace) {
|
|
321
|
-
return projectBasePath;
|
|
322
|
-
}
|
|
323
|
-
},
|
|
324
|
-
getProjectExcludes: function(project) {
|
|
325
|
-
if (project.builder && project.builder.resources) {
|
|
326
|
-
return project.builder.resources.excludes;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
const writer = new MemAdapter({
|
|
332
|
-
virBasePath: "/"
|
|
333
|
-
});
|
|
334
|
-
// Store project writer as virtual reader for parent projects
|
|
335
|
-
// so they can access the build results of this project
|
|
336
|
-
projectWriters[project.metadata.name] = writer;
|
|
337
|
-
|
|
338
|
-
// TODO: Add getter for writer of DuplexColection
|
|
339
|
-
const workspace = resourceFactory.createWorkspace({
|
|
340
|
-
virBasePath: "/",
|
|
341
|
-
writer,
|
|
342
|
-
reader: resourceCollections.source,
|
|
343
|
-
name: project.metadata.name
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
const projectContext = buildContext.createProjectContext({
|
|
347
|
-
project, // TODO 2.0: Add project facade object/instance here
|
|
348
|
-
resources: {
|
|
349
|
-
workspace,
|
|
350
|
-
dependencies: resourceCollections.dependencies
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
const TaskUtil = require("../tasks/TaskUtil");
|
|
355
|
-
const taskUtil = new TaskUtil({
|
|
356
|
-
projectBuildContext: projectContext
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
if (dev && devExcludeProject.indexOf(project.metadata.name) !== -1) {
|
|
360
|
-
projectTasks = composeTaskList({dev: false, selfContained, includedTasks, excludedTasks});
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
return projectType.build({
|
|
364
|
-
resourceCollections: {
|
|
365
|
-
workspace,
|
|
366
|
-
dependencies: resourceCollections.dependencies
|
|
367
|
-
},
|
|
368
|
-
tasks: projectTasks,
|
|
369
|
-
project,
|
|
370
|
-
parentLogger: log,
|
|
371
|
-
taskUtil
|
|
372
|
-
}).then(() => {
|
|
373
|
-
log.verbose("Finished building project %s. Writing out files...", project.metadata.name);
|
|
374
|
-
buildLogger.completeWork(1);
|
|
375
|
-
|
|
376
|
-
return workspace.byGlob("/**/*").then((resources) => {
|
|
377
|
-
const tagCollection = projectContext.getResourceTagCollection();
|
|
378
|
-
return Promise.all(resources.map((resource) => {
|
|
379
|
-
if (tagCollection.getTag(resource, projectContext.STANDARD_TAGS.OmitFromBuildResult)) {
|
|
380
|
-
log.verbose(`Skipping write of resource tagged as "OmitFromBuildResult": ` +
|
|
381
|
-
resource.getPath());
|
|
382
|
-
return; // Skip target write for this resource
|
|
383
|
-
}
|
|
384
|
-
if (projectContext.isRootProject() && project.type === "application" &&
|
|
385
|
-
project.metadata.namespace) {
|
|
386
|
-
// Root-application projects only: Remove namespace prefix if given
|
|
387
|
-
const resourcePath = resource.getPath();
|
|
388
|
-
if (resourcePath.startsWith(projectBasePath)) {
|
|
389
|
-
resource.setPath(resourcePath.replace(projectBasePath, ""));
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
return fsTarget.write(resource);
|
|
393
|
-
}));
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
try {
|
|
400
|
-
if (cleanDest) {
|
|
401
|
-
await rimraf(destPath);
|
|
402
|
-
}
|
|
403
|
-
await buildProject(tree);
|
|
404
|
-
log.info(`Build succeeded in ${getElapsedTime(startTime)}`);
|
|
405
|
-
} catch (err) {
|
|
406
|
-
log.error(`Build failed in ${getElapsedTime(startTime)}`);
|
|
407
|
-
throw err;
|
|
408
|
-
} finally {
|
|
409
|
-
deregisterCleanupSigHooks(cleanupSigHooks);
|
|
410
|
-
await executeCleanupTasks(buildContext);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
// Export local function for testing only
|
|
416
|
-
/* istanbul ignore else */
|
|
417
|
-
if (process.env.NODE_ENV === "test") {
|
|
418
|
-
module.exports._composeTaskList = composeTaskList;
|
|
419
|
-
}
|
package/lib/tasks/TaskUtil.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convenience functions for UI5 Builder tasks.
|
|
3
|
-
* An instance of this class is passed to every standard UI5 Builder task that requires it.
|
|
4
|
-
*
|
|
5
|
-
* Custom tasks that define a specification version >= 2.2 will receive an interface
|
|
6
|
-
* to an instance of this class when called.
|
|
7
|
-
* The set of available functions on that interface depends on the specification
|
|
8
|
-
* version defined for the extension.
|
|
9
|
-
*
|
|
10
|
-
* @public
|
|
11
|
-
* @memberof module:@ui5/builder.tasks
|
|
12
|
-
*/
|
|
13
|
-
class TaskUtil {
|
|
14
|
-
/**
|
|
15
|
-
* Standard Build Tags. See UI5 Tooling
|
|
16
|
-
* [RFC 0008]{@link https://github.com/SAP/ui5-tooling/blob/master/rfcs/0008-resource-tagging-during-build.md}
|
|
17
|
-
* for details.
|
|
18
|
-
*
|
|
19
|
-
* @public
|
|
20
|
-
* @typedef {object} module:@ui5/builder.tasks.TaskUtil~StandardBuildTags
|
|
21
|
-
* @property {string} OmitFromBuildResult
|
|
22
|
-
* Setting this tag to true for a resource will prevent it from being written to the build target
|
|
23
|
-
* @property {string} IsBundle
|
|
24
|
-
* This tag identifies resources that contain (i.e. bundle) multiple other resources
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Since <code>@ui5/builder.builder.ProjectBuildContext</code> is a private class, TaskUtil must not be
|
|
29
|
-
* instantiated by modules other than @ui5/builder itself.
|
|
30
|
-
*
|
|
31
|
-
* @param {object} parameters
|
|
32
|
-
* @param {module:@ui5/builder.builder.ProjectBuildContext} parameters.projectBuildContext ProjectBuildContext
|
|
33
|
-
* @public
|
|
34
|
-
*/
|
|
35
|
-
constructor({projectBuildContext}) {
|
|
36
|
-
this._projectBuildContext = projectBuildContext;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @member {module:@ui5/builder.tasks.TaskUtil~StandardBuildTags}
|
|
40
|
-
* @public
|
|
41
|
-
*/
|
|
42
|
-
this.STANDARD_TAGS = this._projectBuildContext.STANDARD_TAGS;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Stores a tag with value for a given resource's path. Note that the tag is independent of the supplied
|
|
47
|
-
* resource instance. For two resource instances with the same path, the same tag value is returned.
|
|
48
|
-
* If the path of a resource is changed, any tag information previously stored for that resource is lost.
|
|
49
|
-
*
|
|
50
|
-
* </br></br>
|
|
51
|
-
* This method is only available to custom task extensions defining
|
|
52
|
-
* <b>Specification Version 2.2 and above</b>.
|
|
53
|
-
*
|
|
54
|
-
* @param {string|module:@ui5/fs.Resource} resourcePath Path or resource-instance the tag should be stored for
|
|
55
|
-
* @param {string} tag Name of the tag.
|
|
56
|
-
* Currently only the [STANDARD_TAGS]{@link module:@ui5/builder.tasks.TaskUtil#STANDARD_TAGS} are allowed
|
|
57
|
-
* @param {string|boolean|integer} [value=true] Tag value. Must be primitive
|
|
58
|
-
* @public
|
|
59
|
-
*/
|
|
60
|
-
setTag(resourcePath, tag, value) {
|
|
61
|
-
return this._projectBuildContext.getResourceTagCollection().setTag(resourcePath, tag, value);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Retrieves the value for a stored tag. If no value is stored, <code>undefined</code> is returned.
|
|
66
|
-
*
|
|
67
|
-
* </br></br>
|
|
68
|
-
* This method is only available to custom task extensions defining
|
|
69
|
-
* <b>Specification Version 2.2 and above</b>.
|
|
70
|
-
*
|
|
71
|
-
* @param {string|module:@ui5/fs.Resource} resourcePath Path or resource-instance the tag should be retrieved for
|
|
72
|
-
* @param {string} tag Name of the tag
|
|
73
|
-
* @returns {string|boolean|integer|undefined} Tag value for the given resource.
|
|
74
|
-
* <code>undefined</code> if no value is available
|
|
75
|
-
* @public
|
|
76
|
-
*/
|
|
77
|
-
getTag(resourcePath, tag) {
|
|
78
|
-
return this._projectBuildContext.getResourceTagCollection().getTag(resourcePath, tag);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Clears the value of a tag stored for the given resource's path.
|
|
83
|
-
* It's like the tag was never set for that resource.
|
|
84
|
-
*
|
|
85
|
-
* </br></br>
|
|
86
|
-
* This method is only available to custom task extensions defining
|
|
87
|
-
* <b>Specification Version 2.2 and above</b>.
|
|
88
|
-
*
|
|
89
|
-
* @param {string|module:@ui5/fs.Resource} resourcePath Path or resource-instance the tag should be cleared for
|
|
90
|
-
* @param {string} tag Tag
|
|
91
|
-
* @public
|
|
92
|
-
*/
|
|
93
|
-
clearTag(resourcePath, tag) {
|
|
94
|
-
return this._projectBuildContext.getResourceTagCollection().clearTag(resourcePath, tag);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Check whether the project currently being built is the root project.
|
|
99
|
-
*
|
|
100
|
-
* </br></br>
|
|
101
|
-
* This method is only available to custom task extensions defining
|
|
102
|
-
* <b>Specification Version 2.2 and above</b>.
|
|
103
|
-
*
|
|
104
|
-
* @returns {boolean} <code>true</code> if the currently built project is the root project
|
|
105
|
-
* @public
|
|
106
|
-
*/
|
|
107
|
-
isRootProject() {
|
|
108
|
-
return this._projectBuildContext.isRootProject();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Register a function that must be executed once the build is finished. This can be used to, for example,
|
|
113
|
-
* clean up files temporarily created on the file system. If the callback returns a Promise, it will be waited for.
|
|
114
|
-
* It will also be executed in cases where the build has failed or has been aborted.
|
|
115
|
-
*
|
|
116
|
-
* </br></br>
|
|
117
|
-
* This method is only available to custom task extensions defining
|
|
118
|
-
* <b>Specification Version 2.2 and above</b>.
|
|
119
|
-
*
|
|
120
|
-
* @param {Function} callback Callback to register. If it returns a Promise, it will be waited for
|
|
121
|
-
* @public
|
|
122
|
-
*/
|
|
123
|
-
registerCleanupTask(callback) {
|
|
124
|
-
return this._projectBuildContext.registerCleanupTask(callback);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Get an interface to an instance of this class that only provides those functions
|
|
129
|
-
* that are supported by the given custom task extension specification version.
|
|
130
|
-
*
|
|
131
|
-
* @param {string} specVersion Specification version of custom task extension
|
|
132
|
-
* @returns {object} An object with bound instance methods supported by the given specification version
|
|
133
|
-
*/
|
|
134
|
-
getInterface(specVersion) {
|
|
135
|
-
if (["0.1", "1.0", "1.1", "2.0", "2.1"].includes(specVersion)) {
|
|
136
|
-
return undefined;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const baseInterface = {
|
|
140
|
-
STANDARD_TAGS: this.STANDARD_TAGS,
|
|
141
|
-
setTag: this.setTag.bind(this),
|
|
142
|
-
clearTag: this.clearTag.bind(this),
|
|
143
|
-
getTag: this.getTag.bind(this),
|
|
144
|
-
isRootProject: this.isRootProject.bind(this),
|
|
145
|
-
registerCleanupTask: this.registerCleanupTask.bind(this)
|
|
146
|
-
};
|
|
147
|
-
switch (specVersion) {
|
|
148
|
-
case "2.2":
|
|
149
|
-
case "2.3":
|
|
150
|
-
case "2.4":
|
|
151
|
-
case "2.5":
|
|
152
|
-
case "2.6":
|
|
153
|
-
return baseInterface;
|
|
154
|
-
default:
|
|
155
|
-
throw new Error(`TaskUtil: Unknown or unsupported Specification Version ${specVersion}`);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
module.exports = TaskUtil;
|