@ui5/builder 3.0.0-alpha.4 → 3.0.0-alpha.5
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
CHANGED
|
@@ -2,7 +2,22 @@
|
|
|
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.5...HEAD).
|
|
6
|
+
|
|
7
|
+
<a name="v3.0.0-alpha.5"></a>
|
|
8
|
+
## [v3.0.0-alpha.5] - 2022-04-14
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
- **LibraryBuilder:** Align task order of "generateComponentPreload" [`aea061d`](https://github.com/SAP/ui5-builder/commit/aea061d9d6c2ac0c11484dcc08bdcda23ab62986)
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
- **generateThemeDesignerResources task:** Create css_variables.less ([#730](https://github.com/SAP/ui5-builder/issues/730)) [`34e69be`](https://github.com/SAP/ui5-builder/commit/34e69be95fc8ec1961b24b7e2580c2c993d814d3)
|
|
14
|
+
|
|
15
|
+
### BREAKING CHANGE
|
|
16
|
+
|
|
17
|
+
For library projects, the task "generateComponentPreload" is now
|
|
18
|
+
executed after tasks "generateLibraryManifest" and
|
|
19
|
+
"generateManifestBundle" instead of before them.
|
|
20
|
+
|
|
6
21
|
|
|
7
22
|
<a name="v3.0.0-alpha.4"></a>
|
|
8
23
|
## [v3.0.0-alpha.4] - 2022-04-05
|
|
@@ -699,6 +714,7 @@ to load the custom bundle file instead.
|
|
|
699
714
|
- Add ability to configure component preloads and custom bundles [`2241e5f`](https://github.com/SAP/ui5-builder/commit/2241e5ff98fd95f1f80cc74959655ae7a9c660e7)
|
|
700
715
|
|
|
701
716
|
|
|
717
|
+
[v3.0.0-alpha.5]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.4...v3.0.0-alpha.5
|
|
702
718
|
[v3.0.0-alpha.4]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.3...v3.0.0-alpha.4
|
|
703
719
|
[v3.0.0-alpha.3]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.2...v3.0.0-alpha.3
|
|
704
720
|
[v3.0.0-alpha.2]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.1...v3.0.0-alpha.2
|
|
@@ -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,23 +109,6 @@ 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,
|
|
@@ -150,6 +133,23 @@ class LibraryBuilder extends AbstractBuilder {
|
|
|
150
133
|
});
|
|
151
134
|
}
|
|
152
135
|
|
|
136
|
+
const componentPreload = project.builder && project.builder.componentPreload;
|
|
137
|
+
if (componentPreload) {
|
|
138
|
+
this.addTask("generateComponentPreload", async () => {
|
|
139
|
+
return getTask("generateComponentPreload").task({
|
|
140
|
+
workspace: resourceCollections.workspace,
|
|
141
|
+
dependencies: resourceCollections.dependencies,
|
|
142
|
+
taskUtil,
|
|
143
|
+
options: {
|
|
144
|
+
projectName: project.metadata.name,
|
|
145
|
+
paths: componentPreload.paths,
|
|
146
|
+
namespaces: componentPreload.namespaces,
|
|
147
|
+
excludes: componentPreload.excludes
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
153
|
this.addTask("generateLibraryPreload", async () => {
|
|
154
154
|
return getTask("generateLibraryPreload").task({
|
|
155
155
|
workspace: resourceCollections.workspace,
|