@ui5/builder 3.0.0-alpha.3 → 3.0.0-alpha.4

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,13 @@
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.3...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.4...HEAD).
6
+
7
+ <a name="v3.0.0-alpha.4"></a>
8
+ ## [v3.0.0-alpha.4] - 2022-04-05
9
+ ### Features
10
+ - **builder:** Add cssVariables option ([#728](https://github.com/SAP/ui5-builder/issues/728)) [`30d58e1`](https://github.com/SAP/ui5-builder/commit/30d58e1081c1bdc665f13952ecbe5c400b5f4ed7)
11
+
6
12
 
7
13
  <a name="v3.0.0-alpha.3"></a>
8
14
  ## [v3.0.0-alpha.3] - 2022-03-10
@@ -693,6 +699,7 @@ to load the custom bundle file instead.
693
699
  - Add ability to configure component preloads and custom bundles [`2241e5f`](https://github.com/SAP/ui5-builder/commit/2241e5ff98fd95f1f80cc74959655ae7a9c660e7)
694
700
 
695
701
 
702
+ [v3.0.0-alpha.4]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.3...v3.0.0-alpha.4
696
703
  [v3.0.0-alpha.3]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.2...v3.0.0-alpha.3
697
704
  [v3.0.0-alpha.2]: https://github.com/SAP/ui5-builder/compare/v3.0.0-alpha.1...v3.0.0-alpha.2
698
705
  [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,
@@ -39,6 +39,10 @@ class ProjectBuildContext {
39
39
  return this._project === this._buildContext.getRootProject();
40
40
  }
41
41
 
42
+ getOption(key) {
43
+ return this._buildContext.getOption(key);
44
+ }
45
+
42
46
  registerCleanupTask(callback) {
43
47
  this.queues.cleanup.push(callback);
44
48
  }
@@ -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({rootProject: tree});
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
@@ -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.
@@ -198,7 +198,8 @@ class LibraryBuilder extends AbstractBuilder {
198
198
  projectName: project.metadata.name,
199
199
  librariesPattern: !taskUtil.isRootProject() ? "/resources/**/(*.library|library.js)" : undefined,
200
200
  themesPattern: !taskUtil.isRootProject() ? "/resources/sap/ui/core/themes/*" : undefined,
201
- inputPattern
201
+ inputPattern,
202
+ cssVariables: taskUtil.getBuildOption("cssVariables")
202
203
  }
203
204
  });
204
205
  });
@@ -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",
3
+ "version": "3.0.0-alpha.4",
4
4
  "description": "UI5 Tooling - Builder",
5
5
  "author": {
6
6
  "name": "SAP SE",