@ui5/builder 3.0.0-alpha.3 → 3.0.0-alpha.6
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 +32 -1
- package/lib/builder/BuildContext.js +6 -2
- package/lib/builder/ProjectBuildContext.js +4 -0
- package/lib/builder/builder.js +8 -2
- package/lib/lbt/analyzer/JSModuleAnalyzer.js +13 -2
- 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/tasks/TaskUtil.js +12 -0
- package/lib/tasks/generateLibraryManifest.js +2 -8
- package/lib/tasks/generateThemeDesignerResources.js +110 -0
- package/lib/types/application/ApplicationBuilder.js +21 -21
- package/lib/types/library/LibraryBuilder.js +19 -19
- package/lib/types/themeLibrary/ThemeLibraryBuilder.js +2 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,35 @@
|
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
4
4
|
|
|
5
|
-
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.
|
|
5
|
+
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.6...HEAD).
|
|
6
|
+
|
|
7
|
+
<a name="v3.0.0-alpha.6"></a>
|
|
8
|
+
## [v3.0.0-alpha.6] - 2022-04-26
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
- **JSModuleAnalyzer:** Fix detection of bundle name ([#705](https://github.com/SAP/ui5-builder/issues/705)) [`aaeafd4`](https://github.com/SAP/ui5-builder/commit/aaeafd4a1fd194dd08e5ae47c29d90f0b4c7d197)
|
|
11
|
+
- **generateResourcesJson:** Add raw-module info for debug bundles ([#736](https://github.com/SAP/ui5-builder/issues/736)) [`3b918e8`](https://github.com/SAP/ui5-builder/commit/3b918e83bfd38342778ecd4c58e648e99ad7cffc)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
<a name="v3.0.0-alpha.5"></a>
|
|
15
|
+
## [v3.0.0-alpha.5] - 2022-04-14
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
- **LibraryBuilder:** Align task order of "generateComponentPreload" [`aea061d`](https://github.com/SAP/ui5-builder/commit/aea061d9d6c2ac0c11484dcc08bdcda23ab62986)
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
- **generateThemeDesignerResources task:** Create css_variables.less ([#730](https://github.com/SAP/ui5-builder/issues/730)) [`34e69be`](https://github.com/SAP/ui5-builder/commit/34e69be95fc8ec1961b24b7e2580c2c993d814d3)
|
|
21
|
+
|
|
22
|
+
### BREAKING CHANGE
|
|
23
|
+
|
|
24
|
+
For library projects, the task "generateComponentPreload" is now
|
|
25
|
+
executed after tasks "generateLibraryManifest" and
|
|
26
|
+
"generateManifestBundle" instead of before them.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
<a name="v3.0.0-alpha.4"></a>
|
|
30
|
+
## [v3.0.0-alpha.4] - 2022-04-05
|
|
31
|
+
### Features
|
|
32
|
+
- **builder:** Add cssVariables option ([#728](https://github.com/SAP/ui5-builder/issues/728)) [`30d58e1`](https://github.com/SAP/ui5-builder/commit/30d58e1081c1bdc665f13952ecbe5c400b5f4ed7)
|
|
33
|
+
|
|
6
34
|
|
|
7
35
|
<a name="v3.0.0-alpha.3"></a>
|
|
8
36
|
## [v3.0.0-alpha.3] - 2022-03-10
|
|
@@ -693,6 +721,9 @@ to load the custom bundle file instead.
|
|
|
693
721
|
- Add ability to configure component preloads and custom bundles [`2241e5f`](https://github.com/SAP/ui5-builder/commit/2241e5ff98fd95f1f80cc74959655ae7a9c660e7)
|
|
694
722
|
|
|
695
723
|
|
|
724
|
+
[v3.0.0-alpha.6]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.5...v3.0.0-alpha.6
|
|
725
|
+
[v3.0.0-alpha.5]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.4...v3.0.0-alpha.5
|
|
726
|
+
[v3.0.0-alpha.4]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.3...v3.0.0-alpha.4
|
|
696
727
|
[v3.0.0-alpha.3]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.2...v3.0.0-alpha.3
|
|
697
728
|
[v3.0.0-alpha.2]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.1...v3.0.0-alpha.2
|
|
698
729
|
[v3.0.0-alpha.1]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.0...v3.0.0-alpha.1
|
|
@@ -15,22 +15,26 @@ const GLOBAL_TAGS = Object.freeze({
|
|
|
15
15
|
* @memberof module:@ui5/builder.builder
|
|
16
16
|
*/
|
|
17
17
|
class BuildContext {
|
|
18
|
-
constructor({rootProject}) {
|
|
18
|
+
constructor({rootProject, options = {}}) {
|
|
19
19
|
if (!rootProject) {
|
|
20
20
|
throw new Error(`Missing parameter 'rootProject'`);
|
|
21
21
|
}
|
|
22
22
|
this.rootProject = rootProject;
|
|
23
23
|
this.projectBuildContexts = [];
|
|
24
|
-
|
|
25
24
|
this._resourceTagCollection = new ResourceTagCollection({
|
|
26
25
|
allowedTags: Object.values(GLOBAL_TAGS)
|
|
27
26
|
});
|
|
27
|
+
this.options = options;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
getRootProject() {
|
|
31
31
|
return this.rootProject;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
getOption(key) {
|
|
35
|
+
return this.options[key];
|
|
36
|
+
}
|
|
37
|
+
|
|
34
38
|
createProjectContext({project, resources}) {
|
|
35
39
|
const projectBuildContext = new ProjectBuildContext({
|
|
36
40
|
buildContext: this,
|
package/lib/builder/builder.js
CHANGED
|
@@ -224,6 +224,7 @@ module.exports = {
|
|
|
224
224
|
* @param {boolean} [parameters.dev=false]
|
|
225
225
|
* Decides whether a development build should be activated (skips non-essential and time-intensive tasks)
|
|
226
226
|
* @param {boolean} [parameters.selfContained=false] Flag to activate self contained build
|
|
227
|
+
* @param {boolean} [parameters.cssVariables=false] Flag to activate CSS variables generation
|
|
227
228
|
* @param {boolean} [parameters.jsdoc=false] Flag to activate JSDoc build
|
|
228
229
|
* @param {Array.<string>} [parameters.includedTasks=[]] List of tasks to be included
|
|
229
230
|
* @param {Array.<string>} [parameters.excludedTasks=[]] List of tasks to be excluded.
|
|
@@ -234,7 +235,7 @@ module.exports = {
|
|
|
234
235
|
async build({
|
|
235
236
|
tree, destPath, cleanDest = false,
|
|
236
237
|
buildDependencies = false, includedDependencies = [], excludedDependencies = [],
|
|
237
|
-
dev = false, selfContained = false, jsdoc = false,
|
|
238
|
+
dev = false, selfContained = false, cssVariables = false, jsdoc = false,
|
|
238
239
|
includedTasks = [], excludedTasks = [], devExcludeProject = []
|
|
239
240
|
}) {
|
|
240
241
|
const startTime = process.hrtime();
|
|
@@ -249,7 +250,12 @@ module.exports = {
|
|
|
249
250
|
virBasePath: "/"
|
|
250
251
|
});
|
|
251
252
|
|
|
252
|
-
const buildContext = new BuildContext({
|
|
253
|
+
const buildContext = new BuildContext({
|
|
254
|
+
rootProject: tree,
|
|
255
|
+
options: {
|
|
256
|
+
cssVariables: cssVariables
|
|
257
|
+
}
|
|
258
|
+
});
|
|
253
259
|
const cleanupSigHooks = registerCleanupSigHooks(buildContext);
|
|
254
260
|
|
|
255
261
|
const projects = {}; // Unique project index to prevent building the same project multiple times
|
|
@@ -301,6 +301,9 @@ class JSModuleAnalyzer {
|
|
|
301
301
|
*/
|
|
302
302
|
let bIsUi5Module = false;
|
|
303
303
|
|
|
304
|
+
// Module name via @ui5-bundle comment in first line. Overrides all other main module candidates.
|
|
305
|
+
let firstLineBundleName;
|
|
306
|
+
|
|
304
307
|
// first analyze the whole AST...
|
|
305
308
|
visit(ast, false);
|
|
306
309
|
|
|
@@ -314,7 +317,12 @@ class JSModuleAnalyzer {
|
|
|
314
317
|
log.verbose(`bundle include directive ${subModule}`);
|
|
315
318
|
} else if ( comment.value.startsWith("@ui5-bundle ") ) {
|
|
316
319
|
const bundleName = comment.value.slice("@ui5-bundle ".length);
|
|
317
|
-
|
|
320
|
+
if (comment.start === 0) {
|
|
321
|
+
// Remember the name from the first line to use it as final name
|
|
322
|
+
firstLineBundleName = bundleName;
|
|
323
|
+
} else {
|
|
324
|
+
setMainModuleInfo(bundleName, null);
|
|
325
|
+
}
|
|
318
326
|
log.verbose(`bundle name directive ${bundleName}`);
|
|
319
327
|
} else {
|
|
320
328
|
log.warn(`unrecognized bundle directive ${comment.value}`);
|
|
@@ -324,7 +332,10 @@ class JSModuleAnalyzer {
|
|
|
324
332
|
}
|
|
325
333
|
|
|
326
334
|
// ...and finally take conclusions about the file's content
|
|
327
|
-
if (
|
|
335
|
+
if ( firstLineBundleName ) {
|
|
336
|
+
// If the first line has a bundle name, use it and override all other found names
|
|
337
|
+
info.name = firstLineBundleName;
|
|
338
|
+
} else if ( !mainModuleFound ) {
|
|
328
339
|
// if there's exactly one module definition in this file but it didn't
|
|
329
340
|
// immediately qualify as main module, make it now the main module
|
|
330
341
|
if ( candidateName != null && nModuleDeclarations == 1 ) {
|
|
@@ -110,10 +110,11 @@ class ResourceCollector {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
async enrichWithDependencyInfo(resourceInfo) {
|
|
113
|
-
return this._pool.getModuleInfo(resourceInfo.name).then(async (moduleInfo) => {
|
|
114
|
-
if ( moduleInfo.name ) {
|
|
113
|
+
return this._pool.getModuleInfo(resourceInfo.name, resourceInfo.module).then(async (moduleInfo) => {
|
|
114
|
+
if ( !resourceInfo.module && moduleInfo.name ) {
|
|
115
115
|
resourceInfo.module = moduleInfo.name;
|
|
116
116
|
}
|
|
117
|
+
|
|
117
118
|
if ( moduleInfo.dynamicDependencies ) {
|
|
118
119
|
resourceInfo.dynRequired = true;
|
|
119
120
|
}
|
|
@@ -279,37 +280,43 @@ class ResourceCollector {
|
|
|
279
280
|
|
|
280
281
|
await Promise.all(promises);
|
|
281
282
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const dbgInfo = debugResourcesInfo[i];
|
|
286
|
-
const nonDebugName = ResourceInfoList.getNonDebugName(dbgInfo.name);
|
|
283
|
+
await Promise.all(debugResourcesInfo.map(async (dbgInfo) => {
|
|
284
|
+
const debugName = dbgInfo.name;
|
|
285
|
+
const nonDebugName = ResourceInfoList.getNonDebugName(debugName);
|
|
287
286
|
const nonDbgInfo = this._resources.get(nonDebugName);
|
|
288
287
|
|
|
289
288
|
// FIXME: "merged" property is only calculated in ResourceInfo#copyFrom
|
|
290
289
|
// Therefore using the same logic here to compute it.
|
|
290
|
+
|
|
291
|
+
// TODO: Idea: Use IsDebugVariant tag to decide whether to analyze the resource
|
|
292
|
+
// If the tag is set, we don't expect different analysis results so we can copy the info (else-path)
|
|
293
|
+
// Only when the tag is not set, we analyze the resource with its name (incl. -dbg)
|
|
294
|
+
|
|
291
295
|
if (!nonDbgInfo || (nonDbgInfo.included != null && nonDbgInfo.included.size > 0)) {
|
|
292
296
|
// We need to analyze the dbg resource if there is no non-dbg variant or
|
|
293
297
|
// it is a bundle because we will (usually) have different content.
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
298
|
+
|
|
299
|
+
if (nonDbgInfo) {
|
|
300
|
+
// Always use the non-debug module name, if available
|
|
301
|
+
dbgInfo.module = nonDbgInfo.module;
|
|
302
|
+
}
|
|
303
|
+
await this.enrichWithDependencyInfo(dbgInfo);
|
|
297
304
|
} else {
|
|
298
305
|
// If the non-dbg resource is not a bundle, we can just copy over the info and skip
|
|
299
306
|
// analyzing the dbg variant as both should have the same info.
|
|
300
307
|
|
|
301
|
-
const newDbgInfo = new ResourceInfo(
|
|
308
|
+
const newDbgInfo = new ResourceInfo(debugName);
|
|
302
309
|
|
|
303
310
|
// First copy info of analysis from non-dbg file (included, required, condRequired, ...)
|
|
304
311
|
newDbgInfo.copyFrom(null, nonDbgInfo);
|
|
305
312
|
// Then copy over info from dbg file to properly set name, isDebug, etc.
|
|
306
313
|
newDbgInfo.copyFrom(null, dbgInfo);
|
|
314
|
+
// Finally, set the module name to the non-dbg name
|
|
315
|
+
newDbgInfo.module = nonDbgInfo.module;
|
|
307
316
|
|
|
308
|
-
this._resources.set(
|
|
317
|
+
this._resources.set(debugName, newDbgInfo);
|
|
309
318
|
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
await Promise.all(debugBundlePromises);
|
|
319
|
+
}));
|
|
313
320
|
}
|
|
314
321
|
|
|
315
322
|
createOrphanFilters() {
|
|
@@ -48,7 +48,6 @@ class ResourceInfoList {
|
|
|
48
48
|
if ( myInfo == null ) {
|
|
49
49
|
myInfo = new ResourceInfo(relativeName);
|
|
50
50
|
myInfo.size = info.size;
|
|
51
|
-
myInfo.module = ResourceInfoList.getNonDebugName(info.name);
|
|
52
51
|
this.resources.push(myInfo);
|
|
53
52
|
this.resourcesByName.set(relativeName, myInfo);
|
|
54
53
|
}
|
|
@@ -176,17 +176,18 @@ class ResourcePool {
|
|
|
176
176
|
/**
|
|
177
177
|
* Retrieves the module info
|
|
178
178
|
*
|
|
179
|
-
* @param {string}
|
|
179
|
+
* @param {string} resourceName resource/module name
|
|
180
|
+
* @param {string} [moduleName] module name, in case it differs from the resource name (e.g. for -dbg resources)
|
|
180
181
|
* @returns {Promise<ModuleInfo>}
|
|
181
182
|
*/
|
|
182
|
-
async getModuleInfo(
|
|
183
|
-
let info = this._dependencyInfos.get(
|
|
183
|
+
async getModuleInfo(resourceName, moduleName) {
|
|
184
|
+
let info = this._dependencyInfos.get(resourceName);
|
|
184
185
|
if ( info == null ) {
|
|
185
186
|
info = Promise.resolve().then(async () => {
|
|
186
|
-
const resource = await this.findResource(
|
|
187
|
-
return determineDependencyInfo( resource, this._rawModuleInfos.get(
|
|
187
|
+
const resource = await this.findResource(resourceName);
|
|
188
|
+
return determineDependencyInfo( resource, this._rawModuleInfos.get(moduleName || resourceName), this );
|
|
188
189
|
});
|
|
189
|
-
this._dependencyInfos.set(
|
|
190
|
+
this._dependencyInfos.set(resourceName, info);
|
|
190
191
|
}
|
|
191
192
|
return info;
|
|
192
193
|
}
|
package/lib/tasks/TaskUtil.js
CHANGED
|
@@ -108,6 +108,18 @@ class TaskUtil {
|
|
|
108
108
|
return this._projectBuildContext.isRootProject();
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Retrieves a build option defined by its <code>key</code.
|
|
113
|
+
* If no option with the given <code>key</code> is stored, <code>undefined</code> is returned.
|
|
114
|
+
*
|
|
115
|
+
* @param {string} key The option key
|
|
116
|
+
* @returns {any|undefined} The build option (or undefined)
|
|
117
|
+
* @private
|
|
118
|
+
*/
|
|
119
|
+
getBuildOption(key) {
|
|
120
|
+
return this._projectBuildContext.getOption(key);
|
|
121
|
+
}
|
|
122
|
+
|
|
111
123
|
/**
|
|
112
124
|
* Register a function that must be executed once the build is finished. This can be used to, for example,
|
|
113
125
|
* clean up files temporarily created on the file system. If the callback returns a Promise, it will be waited for.
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const log = require("@ui5/logger").getLogger("builder:tasks:generateLibraryManifest");
|
|
4
4
|
const manifestCreator = require("../processors/manifestCreator");
|
|
5
|
-
const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -12,23 +11,18 @@ const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritiz
|
|
|
12
11
|
* @alias module:@ui5/builder.tasks.generateLibraryManifest
|
|
13
12
|
* @param {object} parameters Parameters
|
|
14
13
|
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
|
|
15
|
-
* @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
|
|
16
14
|
* @param {object} parameters.options Options
|
|
17
15
|
* @param {string} parameters.options.projectName Project name
|
|
18
16
|
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
|
|
19
17
|
*/
|
|
20
|
-
module.exports = function({workspace,
|
|
21
|
-
const combo = new ReaderCollectionPrioritized({
|
|
22
|
-
name: `libraryManifestGenerator - prioritize workspace over dependencies: ${projectName}`,
|
|
23
|
-
readers: [workspace, dependencies]
|
|
24
|
-
});
|
|
18
|
+
module.exports = function({workspace, options: {projectName}}) {
|
|
25
19
|
// Note:
|
|
26
20
|
// *.library files are needed to identify libraries
|
|
27
21
|
// *.json files are needed to avoid overwriting them
|
|
28
22
|
// *.js files are needed to identify nested components
|
|
29
23
|
// *.less, *.css, *.theming and *.theme files are needed to identify supported themes
|
|
30
24
|
// *.properties to identify existence of i18n bundles (e.g. messagebundle.properties)
|
|
31
|
-
return
|
|
25
|
+
return workspace.byGlob("/resources/**/*.{js,json,library,less,css,theming,theme,properties}").then((resources) => {
|
|
32
26
|
// Find all libraries and create a manifest.json file
|
|
33
27
|
return workspace.byGlob("/resources/**/.library").then((libraryIndicatorResources) => {
|
|
34
28
|
if (libraryIndicatorResources.length < 1) {
|
|
@@ -3,6 +3,37 @@ const log = require("@ui5/logger").getLogger("builder:tasks:generateThemeDesigne
|
|
|
3
3
|
const libraryLessGenerator = require("../processors/libraryLessGenerator");
|
|
4
4
|
const {ReaderCollectionPrioritized, Resource, fsInterface} = require("@ui5/fs");
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Returns a relative path from the given themeFolder to the root namespace.
|
|
8
|
+
*
|
|
9
|
+
* When combining the given themeFolder with the returned relative path it
|
|
10
|
+
* resolves to "/resources/". However the "/resources/" part is not important
|
|
11
|
+
* here as it doesn't exist within the theming engine environment where the
|
|
12
|
+
* UI5 resources are part of a "UI5" folder (e.g. "UI5/sap/ui/core/") that
|
|
13
|
+
* is next to a "Base" folder.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* getPathToRoot("/resources/sap/ui/foo/themes/base")
|
|
17
|
+
* > "../../../../../"
|
|
18
|
+
*
|
|
19
|
+
* @param {string} themeFolder Virtual path including /resources/
|
|
20
|
+
* @returns {string} Relative path to root namespace
|
|
21
|
+
*/
|
|
22
|
+
function getPathToRoot(themeFolder) {
|
|
23
|
+
// -2 for initial "/"" and "resources/"
|
|
24
|
+
return "../".repeat(themeFolder.split("/").length - 2);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Generates an less import statement for the given <code>filePath</code>
|
|
29
|
+
*
|
|
30
|
+
* @param {string} filePath The path to the desired file
|
|
31
|
+
* @returns {string} The less import statement
|
|
32
|
+
*/
|
|
33
|
+
function lessImport(filePath) {
|
|
34
|
+
return `@import "${filePath}";\n`;
|
|
35
|
+
}
|
|
36
|
+
|
|
6
37
|
function generateLibraryDotTheming({namespace, version, hasThemes}) {
|
|
7
38
|
const dotTheming = {
|
|
8
39
|
sEntity: "Library",
|
|
@@ -80,6 +111,82 @@ async function generateThemeDotTheming({workspace, combo, themeFolder}) {
|
|
|
80
111
|
return newDotThemingResource;
|
|
81
112
|
}
|
|
82
113
|
|
|
114
|
+
async function createCssVariablesLessResource({workspace, combo, themeFolder}) {
|
|
115
|
+
const pathToRoot = getPathToRoot(themeFolder);
|
|
116
|
+
const cssVariablesSourceLessFile = "css_variables.source.less";
|
|
117
|
+
const cssVariablesLessFile = "css_variables.less";
|
|
118
|
+
|
|
119
|
+
// posix as it is a virtual path (separated with /)
|
|
120
|
+
const themeName = posixPath.basename(themeFolder);
|
|
121
|
+
// The "base" theme of the baseLib is called "baseTheme"
|
|
122
|
+
const baseLibThemeName = themeName === "base" ? "baseTheme" : themeName;
|
|
123
|
+
|
|
124
|
+
// Some themes do not have a base.less file (e.g. sap_hcb)
|
|
125
|
+
const hasBaseLess = !!(await combo.byPath(`/resources/sap/ui/core/themes/${themeName}/base.less`));
|
|
126
|
+
|
|
127
|
+
let cssVariablesLess =
|
|
128
|
+
`/* NOTE: This file was generated as an optimized version of "${cssVariablesSourceLessFile}" \
|
|
129
|
+
for the Theme Designer. */\n\n`;
|
|
130
|
+
|
|
131
|
+
if (themeName !== "base") {
|
|
132
|
+
const cssVariablesSourceLessResource = await workspace.byPath(
|
|
133
|
+
posixPath.join(themeFolder, cssVariablesSourceLessFile)
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
if (!cssVariablesSourceLessResource) {
|
|
137
|
+
throw new Error(`Could not find file "${cssVariablesSourceLessFile}" in theme "${themeFolder}"`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const cssVariablesSourceLess = await cssVariablesSourceLessResource.getString();
|
|
141
|
+
|
|
142
|
+
cssVariablesLess += lessImport(`../base/${cssVariablesLessFile}`);
|
|
143
|
+
cssVariablesLess += `
|
|
144
|
+
/* START "${cssVariablesSourceLessFile}" */
|
|
145
|
+
${cssVariablesSourceLess}
|
|
146
|
+
/* END "${cssVariablesSourceLessFile}" */
|
|
147
|
+
|
|
148
|
+
`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (hasBaseLess) {
|
|
152
|
+
cssVariablesLess += lessImport(`${pathToRoot}../Base/baseLib/${baseLibThemeName}/base.less`);
|
|
153
|
+
}
|
|
154
|
+
cssVariablesLess += lessImport(`${pathToRoot}sap/ui/core/themes/${themeName}/global.less`);
|
|
155
|
+
|
|
156
|
+
return new Resource({
|
|
157
|
+
path: posixPath.join(themeFolder, cssVariablesLessFile),
|
|
158
|
+
string: cssVariablesLess
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async function generateCssVariablesLess({workspace, combo, namespace}) {
|
|
163
|
+
let cssVariablesSourceLessResourcePattern;
|
|
164
|
+
if (namespace) {
|
|
165
|
+
// In case of a library only check for themes directly below the namespace
|
|
166
|
+
cssVariablesSourceLessResourcePattern = `/resources/${namespace}/themes/*/css_variables.source.less`;
|
|
167
|
+
} else {
|
|
168
|
+
// In case of a theme-library check for all "themes"
|
|
169
|
+
cssVariablesSourceLessResourcePattern = `/resources/**/themes/*/css_variables.source.less`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const cssVariablesSourceLessResource = await workspace.byGlob(cssVariablesSourceLessResourcePattern);
|
|
173
|
+
|
|
174
|
+
const hasCssVariables = cssVariablesSourceLessResource.length > 0;
|
|
175
|
+
|
|
176
|
+
if (hasCssVariables) {
|
|
177
|
+
await Promise.all(
|
|
178
|
+
cssVariablesSourceLessResource.map(async (cssVariableSourceLess) => {
|
|
179
|
+
const themeFolder = posixPath.dirname(cssVariableSourceLess.getPath());
|
|
180
|
+
log.verbose(`Generating css_variables.less for theme ${themeFolder}`);
|
|
181
|
+
const r = await createCssVariablesLessResource({
|
|
182
|
+
workspace, combo, themeFolder
|
|
183
|
+
});
|
|
184
|
+
return await workspace.write(r);
|
|
185
|
+
})
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
83
190
|
/**
|
|
84
191
|
* Generates resources required for integration with the SAP Theme Designer.
|
|
85
192
|
*
|
|
@@ -163,4 +270,7 @@ module.exports = async function({workspace, dependencies, options: {projectName,
|
|
|
163
270
|
await Promise.all(
|
|
164
271
|
libraryLessResources.map((resource) => workspace.write(resource))
|
|
165
272
|
);
|
|
273
|
+
|
|
274
|
+
// css_variables.less
|
|
275
|
+
await generateCssVariablesLess({workspace, combo, namespace});
|
|
166
276
|
};
|
|
@@ -43,6 +43,27 @@ class ApplicationBuilder extends AbstractBuilder {
|
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
+
// Support rules should not be minified to have readable code in the Support Assistant
|
|
47
|
+
const minificationPattern = ["/**/*.js", "!**/*.support.js"];
|
|
48
|
+
if (["2.6"].includes(project.specVersion)) {
|
|
49
|
+
const minificationExcludes = project.builder && project.builder.minification &&
|
|
50
|
+
project.builder.minification.excludes;
|
|
51
|
+
if (minificationExcludes) {
|
|
52
|
+
// TODO 3.0: namespaces should become mandatory, see existing check above
|
|
53
|
+
const patternPrefix = project.metadata.namespace ? "/resources/" : "/";
|
|
54
|
+
this.enhancePatternWithExcludes(minificationPattern, minificationExcludes, patternPrefix);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
this.addTask("minify", async () => {
|
|
58
|
+
return getTask("minify").task({
|
|
59
|
+
workspace: resourceCollections.workspace,
|
|
60
|
+
taskUtil,
|
|
61
|
+
options: {
|
|
62
|
+
pattern: minificationPattern
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
46
67
|
this.addTask("generateFlexChangesBundle", async () => {
|
|
47
68
|
const generateFlexChangesBundle = getTask("generateFlexChangesBundle").task;
|
|
48
69
|
return generateFlexChangesBundle({
|
|
@@ -67,27 +88,6 @@ class ApplicationBuilder extends AbstractBuilder {
|
|
|
67
88
|
});
|
|
68
89
|
}
|
|
69
90
|
|
|
70
|
-
// Support rules should not be minified to have readable code in the Support Assistant
|
|
71
|
-
const minificationPattern = ["/**/*.js", "!**/*.support.js"];
|
|
72
|
-
if (["2.6"].includes(project.specVersion)) {
|
|
73
|
-
const minificationExcludes = project.builder && project.builder.minification &&
|
|
74
|
-
project.builder.minification.excludes;
|
|
75
|
-
if (minificationExcludes) {
|
|
76
|
-
// TODO 3.0: namespaces should become mandatory, see existing check above
|
|
77
|
-
const patternPrefix = project.metadata.namespace ? "/resources/" : "/";
|
|
78
|
-
this.enhancePatternWithExcludes(minificationPattern, minificationExcludes, patternPrefix);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
this.addTask("minify", async () => {
|
|
82
|
-
return getTask("minify").task({
|
|
83
|
-
workspace: resourceCollections.workspace,
|
|
84
|
-
taskUtil,
|
|
85
|
-
options: {
|
|
86
|
-
pattern: minificationPattern
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
91
|
const componentPreload = project.builder && project.builder.componentPreload;
|
|
92
92
|
if (componentPreload && (componentPreload.namespaces || componentPreload.paths)) {
|
|
93
93
|
this.addTask("generateComponentPreload", async () => {
|
|
@@ -109,27 +109,9 @@ class LibraryBuilder extends AbstractBuilder {
|
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
-
const componentPreload = project.builder && project.builder.componentPreload;
|
|
113
|
-
if (componentPreload) {
|
|
114
|
-
this.addTask("generateComponentPreload", async () => {
|
|
115
|
-
return getTask("generateComponentPreload").task({
|
|
116
|
-
workspace: resourceCollections.workspace,
|
|
117
|
-
dependencies: resourceCollections.dependencies,
|
|
118
|
-
taskUtil,
|
|
119
|
-
options: {
|
|
120
|
-
projectName: project.metadata.name,
|
|
121
|
-
paths: componentPreload.paths,
|
|
122
|
-
namespaces: componentPreload.namespaces,
|
|
123
|
-
excludes: componentPreload.excludes
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
112
|
this.addTask("generateLibraryManifest", async () => {
|
|
130
113
|
return getTask("generateLibraryManifest").task({
|
|
131
114
|
workspace: resourceCollections.workspace,
|
|
132
|
-
dependencies: resourceCollections.dependencies,
|
|
133
115
|
taskUtil,
|
|
134
116
|
options: {
|
|
135
117
|
projectName: project.metadata.name
|
|
@@ -150,6 +132,23 @@ class LibraryBuilder extends AbstractBuilder {
|
|
|
150
132
|
});
|
|
151
133
|
}
|
|
152
134
|
|
|
135
|
+
const componentPreload = project.builder && project.builder.componentPreload;
|
|
136
|
+
if (componentPreload) {
|
|
137
|
+
this.addTask("generateComponentPreload", async () => {
|
|
138
|
+
return getTask("generateComponentPreload").task({
|
|
139
|
+
workspace: resourceCollections.workspace,
|
|
140
|
+
dependencies: resourceCollections.dependencies,
|
|
141
|
+
taskUtil,
|
|
142
|
+
options: {
|
|
143
|
+
projectName: project.metadata.name,
|
|
144
|
+
paths: componentPreload.paths,
|
|
145
|
+
namespaces: componentPreload.namespaces,
|
|
146
|
+
excludes: componentPreload.excludes
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
153
152
|
this.addTask("generateLibraryPreload", async () => {
|
|
154
153
|
return getTask("generateLibraryPreload").task({
|
|
155
154
|
workspace: resourceCollections.workspace,
|
|
@@ -198,7 +197,8 @@ class LibraryBuilder extends AbstractBuilder {
|
|
|
198
197
|
projectName: project.metadata.name,
|
|
199
198
|
librariesPattern: !taskUtil.isRootProject() ? "/resources/**/(*.library|library.js)" : undefined,
|
|
200
199
|
themesPattern: !taskUtil.isRootProject() ? "/resources/sap/ui/core/themes/*" : undefined,
|
|
201
|
-
inputPattern
|
|
200
|
+
inputPattern,
|
|
201
|
+
cssVariables: taskUtil.getBuildOption("cssVariables")
|
|
202
202
|
}
|
|
203
203
|
});
|
|
204
204
|
});
|
|
@@ -31,7 +31,8 @@ class ThemeLibraryBuilder extends AbstractBuilder {
|
|
|
31
31
|
projectName: project.metadata.name,
|
|
32
32
|
librariesPattern: !taskUtil.isRootProject() ? "/resources/**/(*.library|library.js)" : undefined,
|
|
33
33
|
themesPattern: !taskUtil.isRootProject() ? "/resources/sap/ui/core/themes/*" : undefined,
|
|
34
|
-
inputPattern: "/resources/**/themes/*/library.source.less"
|
|
34
|
+
inputPattern: "/resources/**/themes/*/library.source.less",
|
|
35
|
+
cssVariables: taskUtil.getBuildOption("cssVariables")
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
38
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/builder",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.6",
|
|
4
4
|
"description": "UI5 Tooling - Builder",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "SAP SE",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"url": "git@github.com:SAP/ui5-builder.git"
|
|
106
106
|
},
|
|
107
107
|
"dependencies": {
|
|
108
|
-
"@ui5/fs": "^3.0.0-alpha.
|
|
108
|
+
"@ui5/fs": "^3.0.0-alpha.3",
|
|
109
109
|
"@ui5/logger": "^3.0.1-alpha.1",
|
|
110
110
|
"cheerio": "1.0.0-rc.9",
|
|
111
111
|
"escape-unicode": "^0.2.0",
|