@ui5/builder 3.0.0-alpha.6 → 3.0.0-alpha.7

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/index.js +0 -39
  3. package/lib/lbt/bundle/Builder.js +18 -48
  4. package/lib/lbt/resources/LocatorResource.js +1 -1
  5. package/lib/lbt/utils/escapePropertiesFile.js +3 -6
  6. package/lib/processors/bundlers/moduleBundler.js +2 -3
  7. package/lib/processors/jsdoc/lib/transformApiJson.js +13 -4
  8. package/lib/processors/manifestCreator.js +8 -45
  9. package/lib/tasks/TaskUtil.js +82 -17
  10. package/lib/tasks/bundlers/generateComponentPreload.js +14 -14
  11. package/lib/tasks/bundlers/generateFlexChangesBundle.js +6 -2
  12. package/lib/tasks/bundlers/generateLibraryPreload.js +84 -91
  13. package/lib/tasks/bundlers/generateManifestBundle.js +8 -10
  14. package/lib/tasks/bundlers/generateStandaloneAppBundle.js +7 -2
  15. package/lib/tasks/bundlers/utils/createModuleNameMapping.js +3 -2
  16. package/lib/tasks/generateCachebusterInfo.js +7 -3
  17. package/lib/tasks/generateLibraryManifest.js +5 -1
  18. package/lib/tasks/generateResourcesJson.js +1 -1
  19. package/lib/tasks/generateThemeDesignerResources.js +8 -2
  20. package/lib/tasks/generateVersionInfo.js +5 -5
  21. package/lib/tasks/taskRepository.js +1 -13
  22. package/lib/tasks/transformBootstrapHtml.js +6 -1
  23. package/package.json +4 -5
  24. package/lib/builder/BuildContext.js +0 -60
  25. package/lib/builder/ProjectBuildContext.js +0 -61
  26. package/lib/builder/builder.js +0 -425
  27. package/lib/types/AbstractBuilder.js +0 -270
  28. package/lib/types/AbstractFormatter.js +0 -66
  29. package/lib/types/AbstractUi5Formatter.js +0 -95
  30. package/lib/types/application/ApplicationBuilder.js +0 -211
  31. package/lib/types/application/ApplicationFormatter.js +0 -227
  32. package/lib/types/application/applicationType.js +0 -15
  33. package/lib/types/library/LibraryBuilder.js +0 -231
  34. package/lib/types/library/LibraryFormatter.js +0 -519
  35. package/lib/types/library/libraryType.js +0 -15
  36. package/lib/types/module/ModuleBuilder.js +0 -7
  37. package/lib/types/module/ModuleFormatter.js +0 -54
  38. package/lib/types/module/moduleType.js +0 -15
  39. package/lib/types/themeLibrary/ThemeLibraryBuilder.js +0 -64
  40. package/lib/types/themeLibrary/ThemeLibraryFormatter.js +0 -90
  41. package/lib/types/themeLibrary/themeLibraryType.js +0 -15
  42. package/lib/types/typeRepository.js +0 -46
@@ -2,6 +2,7 @@ const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateFle
2
2
  const flexChangesBundler = require("../../processors/bundlers/flexChangesBundler");
3
3
  const semver = require("semver");
4
4
 
5
+ /* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
5
6
  /**
6
7
  * Task to create changesBundle.json file containing all changes stored in the /changes folder for easier consumption
7
8
  * at runtime.
@@ -16,10 +17,13 @@ const semver = require("semver");
16
17
  * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
17
18
  * @param {module:@ui5/builder.tasks.TaskUtil|object} [parameters.taskUtil] TaskUtil
18
19
  * @param {object} [parameters.options] Options
19
- * @param {string} [parameters.options.namespace] Application Namespace
20
+ * @param {string} [parameters.options.projectNamespace] Project Namespace
20
21
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
21
22
  */
22
- module.exports = async function({workspace, taskUtil, options: {namespace}}) {
23
+ module.exports = async function({workspace, taskUtil, options = {}}) {
24
+ // Backward compatibility: "namespace" option got renamed to "projectNamespace"
25
+ const namespace = options.projectNamespace || options.namespace;
26
+
23
27
  // Use the given namespace if available, otherwise use no namespace
24
28
  // (e.g. in case no manifest.json is present)
25
29
  let pathPrefix = "";
@@ -1,6 +1,5 @@
1
1
  const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateLibraryPreload");
2
2
  const moduleBundler = require("../../processors/bundlers/moduleBundler");
3
- const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
4
3
  const {negateFilters} = require("../../lbt/resources/ResourceFilterList");
5
4
  const createModuleNameMapping = require("./utils/createModuleNameMapping");
6
5
 
@@ -8,7 +7,7 @@ function getDefaultLibraryPreloadFilters(namespace, excludes) {
8
7
  const filters = [
9
8
  `${namespace}/`,
10
9
  `${namespace}/**/manifest.json`,
11
- `!${namespace}/*-preload.js`, // exclude all bundles
10
+ `!${namespace}/**/*-preload.js`, // exclude all bundles
12
11
  `!${namespace}/designtime/`,
13
12
  `!${namespace}/**/*.designtime.js`,
14
13
  `!${namespace}/**/*.support.js`
@@ -143,48 +142,6 @@ function getSupportFilesBundleDefinition(namespace) {
143
142
  };
144
143
  }
145
144
 
146
- function createLibraryBundles(libraryNamespace, resources, excludes) {
147
- return Promise.all([
148
- moduleBundler({
149
- options: {
150
- bundleDefinition: getBundleDefinition(libraryNamespace, excludes),
151
- bundleOptions: {
152
- optimize: true,
153
- usePredefineCalls: true,
154
- ignoreMissingModules: true
155
- }
156
- },
157
- resources
158
- }),
159
- moduleBundler({
160
- options: {
161
- bundleDefinition: getDesigntimeBundleDefinition(libraryNamespace),
162
- bundleOptions: {
163
- optimize: true,
164
- usePredefineCalls: true,
165
- ignoreMissingModules: true,
166
- skipIfEmpty: true
167
- }
168
- },
169
- resources
170
- }),
171
- moduleBundler({
172
- options: {
173
- bundleDefinition: getSupportFilesBundleDefinition(libraryNamespace),
174
- bundleOptions: {
175
- optimize: false,
176
- usePredefineCalls: true,
177
- ignoreMissingModules: true,
178
- skipIfEmpty: true
179
- }
180
- // Note: Although the bundle uses optimize=false, there is
181
- // no moduleNameMapping needed, as support files are excluded from minification.
182
- },
183
- resources
184
- })
185
- ]);
186
- }
187
-
188
145
  function getModuleBundlerOptions(config) {
189
146
  const moduleBundlerOptions = {};
190
147
 
@@ -266,32 +223,36 @@ function getSapUiCoreBunDef(name, filters, preload) {
266
223
  * @alias module:@ui5/builder.tasks.generateLibraryPreload
267
224
  * @param {object} parameters Parameters
268
225
  * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
269
- * @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
270
- * @param {module:@ui5/builder.tasks.TaskUtil|object} [parameters.taskUtil] TaskUtil
226
+ * @param {module:@ui5/builder.tasks.TaskUtil} [parameters.taskUtil] TaskUtil
227
+ * @param {object} parameters.options Options
228
+ * @param {string} parameters.options.projectName Project name
229
+ * @param {string[]} [parameters.options.skipBundles] Names of bundles that should not be created
271
230
  * @param {string[]} [parameters.options.excludes=[]] List of modules declared as glob patterns (resource name patterns)
272
231
  * that should be excluded from the library-preload.js bundle.
273
232
  * A pattern ending with a slash '/' will, similarly to the use of a single '*' or double '**' asterisk,
274
233
  * denote an arbitrary number of characters or folder names.
275
234
  * Re-includes should be marked with a leading exclamation mark '!'. The order of filters is relevant; a later
276
235
  * inclusion overrides an earlier exclusion, and vice versa.
277
- * @param {object} parameters.options Options
278
- * @param {string} parameters.options.projectName Project name
279
236
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
280
237
  */
281
- module.exports = function({workspace, dependencies, taskUtil, options: {projectName, excludes = []}}) {
282
- let combo = new ReaderCollectionPrioritized({
283
- name: `libraryBundler - prioritize workspace over dependencies: ${projectName}`,
284
- readers: [workspace, dependencies]
285
- });
286
-
238
+ module.exports = function({workspace, taskUtil, options: {skipBundles = [], excludes = [], projectName}}) {
239
+ let nonDbgWorkspace = workspace;
287
240
  if (taskUtil) {
288
- combo = combo.filter(function(resource) {
241
+ nonDbgWorkspace = workspace.filter(function(resource) {
289
242
  // Remove any debug variants
290
243
  return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant);
291
244
  });
292
245
  }
293
246
 
294
- return combo.byGlob("/**/*.{js,json,xml,html,properties,library,js.map}").then(async (resources) => {
247
+ const execModuleBundlerIfNeeded = ({options, resources}) => {
248
+ if (skipBundles.includes(options.bundleDefinition.name)) {
249
+ log.verbose(`Skipping generation of bundle ${options.bundleDefinition.name}`);
250
+ return null;
251
+ }
252
+ return moduleBundler({options, resources});
253
+ };
254
+
255
+ return nonDbgWorkspace.byGlob("/**/*.{js,json,xml,html,properties,library,js.map}").then(async (resources) => {
295
256
  // Find all libraries and create a library-preload.js bundle
296
257
 
297
258
  let p = Promise.resolve();
@@ -299,14 +260,12 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
299
260
  // Create core bundles for older versions (<1.97.0) which don't define bundle configuration in the ui5.yaml
300
261
  // See: https://github.com/SAP/openui5/commit/ff127fd2d009162ea43ad312dec99d759ebc23a0
301
262
  if (projectName === "sap.ui.core") {
302
- const coreProject = resources[0]._project;
303
- const coreSpecVersion = coreProject && coreProject.specVersion;
304
263
  // Instead of checking the sap.ui.core library version, the specVersion is checked against all versions
305
264
  // that have been defined for sap.ui.core before the bundle configuration has been introduced.
306
265
  // This is mainly to have an easier check without version parsing or using semver.
307
266
  // If no project/specVersion is available, the bundles should also be created to not break potential
308
267
  // existing use cases without a properly formed/formatted project tree.
309
- if (!coreSpecVersion || ["0.1", "1.1", "2.0"].includes(coreSpecVersion)) {
268
+ if (!taskUtil || ["0.1", "1.1", "2.0"].includes(taskUtil.getProject().getSpecVersion())) {
310
269
  const isEvo = resources.find((resource) => {
311
270
  return resource.getPath() === "/resources/ui5loader.js";
312
271
  });
@@ -314,10 +273,7 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
314
273
  let unoptimizedModuleNameMapping;
315
274
  let unoptimizedResources = resources;
316
275
  if (taskUtil) {
317
- unoptimizedResources = await new ReaderCollectionPrioritized({
318
- name: `libraryBundler - prioritize workspace over dependencies: ${projectName}`,
319
- readers: [workspace, dependencies]
320
- }).filter(function(resource) {
276
+ unoptimizedResources = await workspace.filter(function(resource) {
321
277
  // Remove any non-debug variants
322
278
  return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.HasDebugVariant);
323
279
  }).byGlob("/**/*.{js,json,xml,html,properties,library,js.map}");
@@ -335,24 +291,24 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
335
291
  filters = ["jquery.sap.global.js"];
336
292
  }
337
293
  p = Promise.all([
338
- moduleBundler({
294
+ execModuleBundlerIfNeeded({
339
295
  options: getModuleBundlerOptions({name: "sap-ui-core.js", filters, preload: true}),
340
296
  resources
341
297
  }),
342
- moduleBundler({
298
+ execModuleBundlerIfNeeded({
343
299
  options: getModuleBundlerOptions({
344
300
  name: "sap-ui-core-dbg.js", filters, preload: false,
345
301
  moduleNameMapping: unoptimizedModuleNameMapping
346
302
  }),
347
303
  resources: unoptimizedResources
348
304
  }),
349
- moduleBundler({
305
+ execModuleBundlerIfNeeded({
350
306
  options: getModuleBundlerOptions({
351
307
  name: "sap-ui-core-nojQuery.js", filters, preload: true, provided: true
352
308
  }),
353
309
  resources
354
310
  }),
355
- moduleBundler({
311
+ execModuleBundlerIfNeeded({
356
312
  options: getModuleBundlerOptions({
357
313
  name: "sap-ui-core-nojQuery-dbg.js", filters, preload: false, provided: true,
358
314
  moduleNameMapping: unoptimizedModuleNameMapping
@@ -360,7 +316,7 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
360
316
  resources: unoptimizedResources
361
317
  }),
362
318
  ]).then((results) => {
363
- const bundles = Array.prototype.concat.apply([], results);
319
+ const bundles = Array.prototype.concat.apply([], results).filter(Boolean);
364
320
  return Promise.all(bundles.map(({bundle, sourceMap}) => {
365
321
  if (taskUtil) {
366
322
  taskUtil.setTag(bundle, taskUtil.STANDARD_TAGS.IsBundle);
@@ -387,7 +343,8 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
387
343
  } else {
388
344
  // Fallback to "library.js" as library indicator
389
345
  log.verbose(
390
- `Could not find a ".library" file for project ${projectName}, falling back to "library.js".`);
346
+ `Could not find a ".library" file for project ${projectName}, ` +
347
+ `falling back to "library.js".`);
391
348
  return workspace.byGlob("/resources/**/library.js");
392
349
  }
393
350
  }).then((libraryIndicatorResources) => {
@@ -399,7 +356,7 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
399
356
  return;
400
357
  }
401
358
 
402
- return Promise.all(libraryIndicatorResources.map((libraryIndicatorResource) => {
359
+ return Promise.all(libraryIndicatorResources.map(async (libraryIndicatorResource) => {
403
360
  // Determine library namespace from library indicator file path
404
361
  // ending with either ".library" or "library.js" (see fallback logic above)
405
362
  // e.g. /resources/sap/foo/.library => sap/foo
@@ -409,28 +366,64 @@ module.exports = function({workspace, dependencies, taskUtil, options: {projectN
409
366
  const libraryNamespaceMatch = libraryIndicatorPath.match(libraryNamespacePattern);
410
367
  if (libraryNamespaceMatch && libraryNamespaceMatch[1]) {
411
368
  const libraryNamespace = libraryNamespaceMatch[1];
412
- return createLibraryBundles(libraryNamespace, resources, excludes)
413
- .then((results) => {
414
- const bundles = Array.prototype.concat.apply([], results);
415
- return Promise.all(bundles.map(({bundle, sourceMap} = {}) => {
416
- if (bundle) {
417
- if (taskUtil) {
418
- taskUtil.setTag(bundle, taskUtil.STANDARD_TAGS.IsBundle);
419
- if (sourceMap) {
420
- // Clear tag that might have been set by the minify task, in cases where
421
- // the bundle name is identical to a source file
422
- taskUtil.clearTag(sourceMap,
423
- taskUtil.STANDARD_TAGS.OmitFromBuildResult);
424
- }
425
- }
426
- const writes = [workspace.write(bundle)];
427
- if (sourceMap) {
428
- writes.push(workspace.write(sourceMap));
429
- }
430
- return Promise.all(writes);
369
+ const results = await Promise.all([
370
+ execModuleBundlerIfNeeded({
371
+ options: {
372
+ bundleDefinition: getBundleDefinition(libraryNamespace, excludes),
373
+ bundleOptions: {
374
+ optimize: true,
375
+ usePredefineCalls: true,
376
+ ignoreMissingModules: true
431
377
  }
432
- }));
433
- });
378
+ },
379
+ resources
380
+ }),
381
+ execModuleBundlerIfNeeded({
382
+ options: {
383
+ bundleDefinition: getDesigntimeBundleDefinition(libraryNamespace),
384
+ bundleOptions: {
385
+ optimize: true,
386
+ usePredefineCalls: true,
387
+ ignoreMissingModules: true,
388
+ skipIfEmpty: true
389
+ }
390
+ },
391
+ resources
392
+ }),
393
+ execModuleBundlerIfNeeded({
394
+ options: {
395
+ bundleDefinition: getSupportFilesBundleDefinition(libraryNamespace),
396
+ bundleOptions: {
397
+ optimize: false,
398
+ usePredefineCalls: true,
399
+ ignoreMissingModules: true,
400
+ skipIfEmpty: true
401
+ }
402
+ // Note: Although the bundle uses optimize=false, there is
403
+ // no moduleNameMapping needed, as support files are excluded from minification.
404
+ },
405
+ resources
406
+ })
407
+ ]);
408
+ const bundles = Array.prototype.concat.apply([], results).filter(Boolean);
409
+ return Promise.all(bundles.map(({bundle, sourceMap} = {}) => {
410
+ if (bundle) {
411
+ if (taskUtil) {
412
+ taskUtil.setTag(bundle, taskUtil.STANDARD_TAGS.IsBundle);
413
+ if (sourceMap) {
414
+ // Clear tag that might have been set by the minify task, in cases where
415
+ // the bundle name is identical to a source file
416
+ taskUtil.clearTag(sourceMap,
417
+ taskUtil.STANDARD_TAGS.OmitFromBuildResult);
418
+ }
419
+ }
420
+ const writes = [workspace.write(bundle)];
421
+ if (sourceMap) {
422
+ writes.push(workspace.write(sourceMap));
423
+ }
424
+ return Promise.all(writes);
425
+ }
426
+ }));
434
427
  } else {
435
428
  log.verbose(
436
429
  `Could not determine library namespace from file "${libraryIndicatorPath}" ` +
@@ -4,14 +4,7 @@ const DESCRIPTOR = "manifest.json";
4
4
  const PROPERTIES_EXT = ".properties";
5
5
  const BUNDLE_NAME = "manifest-bundle.zip";
6
6
 
7
- /**
8
- *
9
- * @public
10
- * @typedef {object} ManifestBundlerOptions
11
- * @property {string} projectName Project Name
12
- * @property {string} namespace Namespace
13
- */
14
-
7
+ /* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
15
8
  /**
16
9
  * Task for manifestBundler.
17
10
  *
@@ -19,11 +12,16 @@ const BUNDLE_NAME = "manifest-bundle.zip";
19
12
  * @alias module:@ui5/builder.tasks.generateManifestBundle
20
13
  * @param {object} parameters Parameters
21
14
  * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
22
- * @param {ManifestBundlerOptions} parameters.options Options
15
+ * @param {object} parameters.options Options
16
+ * @param {string} parameters.options.projectName Project name
17
+ * @param {string} parameters.options.projectNamespace Project namespace
23
18
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
24
19
  */
25
20
  module.exports = async function({workspace, options = {}}) {
26
- const {projectName, namespace} = options;
21
+ const {projectName} = options;
22
+ // Backward compatibility: "namespace" option got renamed to "projectNamespace"
23
+ const namespace = options.projectNamespace || options.namespace;
24
+
27
25
  if (!projectName || !namespace) {
28
26
  throw new Error("[generateManifestBundle]: One or more mandatory options not provided");
29
27
  }
@@ -58,6 +58,7 @@ function getBundleDefinition(config) {
58
58
  return bundleDefinition;
59
59
  }
60
60
 
61
+ /* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
61
62
  /**
62
63
  * Task for bundling standalone applications.
63
64
  *
@@ -69,10 +70,14 @@ function getBundleDefinition(config) {
69
70
  * @param {module:@ui5/builder.tasks.TaskUtil|object} [parameters.taskUtil] TaskUtil
70
71
  * @param {object} parameters.options Options
71
72
  * @param {string} parameters.options.projectName Project name
72
- * @param {string} [parameters.options.namespace] Project namespace
73
+ * @param {string} [parameters.options.projectNamespace] Project namespace
73
74
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
74
75
  */
75
- module.exports = async function({workspace, dependencies, taskUtil, options: {projectName, namespace}}) {
76
+ module.exports = async function({workspace, dependencies, taskUtil, options}) {
77
+ const {projectName} = options;
78
+ // Backward compatibility: "namespace" option got renamed to "projectNamespace"
79
+ const namespace = options.projectNamespace || options.namespace;
80
+
76
81
  if (!namespace) {
77
82
  log.warn(`Namespace of project ${projectName} is not known. Self contained bundling is currently ` +
78
83
  `unable to generate complete bundles for such projects.`);
@@ -17,8 +17,9 @@ const ModuleName = require("../../../lbt/utils/ModuleName");
17
17
  module.exports = function({resources, taskUtil}) {
18
18
  const moduleNameMapping = {};
19
19
  for (let i = resources.length - 1; i >= 0; i--) {
20
- const resourcePath = resources[i].getPath();
21
- if (taskUtil.getTag(resourcePath, taskUtil.STANDARD_TAGS.IsDebugVariant)) {
20
+ const resource = resources[i];
21
+ if (taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant)) {
22
+ const resourcePath = resource.getPath();
22
23
  const nonDbgPath = ModuleName.getNonDebugName(resourcePath);
23
24
  if (!nonDbgPath) {
24
25
  throw new Error(`Failed to resolve non-debug name for ${resourcePath}`);
@@ -28,6 +28,7 @@ function getSigner(type) {
28
28
  }
29
29
  }
30
30
 
31
+ /* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
31
32
  /**
32
33
  * Task to generate the application cachebuster info file.
33
34
  *
@@ -35,13 +36,16 @@ function getSigner(type) {
35
36
  * @alias module:@ui5/builder.tasks.generateCachebusterInfo
36
37
  * @param {object} parameters Parameters
37
38
  * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
38
- * @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
39
39
  * @param {object} parameters.options Options
40
- * @param {string} parameters.options.namespace Namespace of the application
40
+ * @param {string} parameters.options.projectNamespace Namespace of the application
41
41
  * @param {string} [parameters.options.signatureType='time'] Type of signature to be used ('time' or 'hash')
42
42
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
43
43
  */
44
- module.exports = function({workspace, dependencies, options: {namespace, signatureType}}) {
44
+ module.exports = function({workspace, options}) {
45
+ const {signatureType} = options;
46
+ // Backward compatibility: "namespace" option got renamed to "projectNamespace"
47
+ const namespace = options.projectNamespace || options.namespace;
48
+
45
49
  const basePath = `/resources/${namespace}/`;
46
50
  return workspace.byGlob(`/resources/${namespace}/**/*`)
47
51
  .then(async (resources) => {
@@ -11,11 +11,12 @@ const manifestCreator = require("../processors/manifestCreator");
11
11
  * @alias module:@ui5/builder.tasks.generateLibraryManifest
12
12
  * @param {object} parameters Parameters
13
13
  * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
14
+ * @param {module:@ui5/builder.tasks.TaskUtil|object} [parameters.taskUtil] TaskUtil
14
15
  * @param {object} parameters.options Options
15
16
  * @param {string} parameters.options.projectName Project name
16
17
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
17
18
  */
18
- module.exports = function({workspace, options: {projectName}}) {
19
+ module.exports = function({workspace, taskUtil, options: {projectName}}) {
19
20
  // Note:
20
21
  // *.library files are needed to identify libraries
21
22
  // *.json files are needed to avoid overwriting them
@@ -45,6 +46,9 @@ module.exports = function({workspace, options: {projectName}}) {
45
46
  libraryResource: libraryIndicatorResource,
46
47
  namespace: libraryNamespace,
47
48
  resources,
49
+ getProjectVersion: (projectName) => {
50
+ return taskUtil?.getProject(projectName)?.getVersion();
51
+ },
48
52
  options: {
49
53
  }
50
54
  }).then((manifest) => {
@@ -43,7 +43,7 @@ function getCreatorOptions(projectName) {
43
43
  *
44
44
  * <p>
45
45
  * The detailed structure can be found in the documentation:
46
- * {@link https://openui5.hana.ondemand.com/#topic/adcbcf8b50924556ab3f321fcd9353ea}
46
+ * {@link https://sdk.openui5.org/topic/adcbcf8b50924556ab3f321fcd9353ea}
47
47
  * </p>
48
48
  *
49
49
  * <p>
@@ -187,6 +187,7 @@ async function generateCssVariablesLess({workspace, combo, namespace}) {
187
187
  }
188
188
  }
189
189
 
190
+ /* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
190
191
  /**
191
192
  * Generates resources required for integration with the SAP Theme Designer.
192
193
  *
@@ -198,11 +199,16 @@ async function generateCssVariablesLess({workspace, combo, namespace}) {
198
199
  * @param {object} parameters.options Options
199
200
  * @param {string} parameters.options.projectName Project name
200
201
  * @param {string} parameters.options.version Project version
201
- * @param {string} [parameters.options.namespace] If the project is of type <code>library</code>, provide its namespace.
202
+ * @param {string} [parameters.options.projectNamespace] If the project is of type <code>library</code>,
203
+ * provide its namespace.
202
204
  * Omit for type <code>theme-library</code>
203
205
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
204
206
  */
205
- module.exports = async function({workspace, dependencies, options: {projectName, version, namespace}}) {
207
+ module.exports = async function({workspace, dependencies, options}) {
208
+ const {projectName, version} = options;
209
+ // Backward compatibility: "namespace" option got renamed to "projectNamespace"
210
+ const namespace = options.projectNamespace || options.namespace;
211
+
206
212
  // Skip sap.ui.documentation since it is not intended to be available in SAP Theme Designer to create custom themes
207
213
  if (namespace === "sap/ui/documentation") {
208
214
  return;
@@ -19,7 +19,7 @@ module.exports = async ({workspace, dependencies, options: {rootProject, pattern
19
19
  const resources = await dependencies.byGlob(pattern);
20
20
 
21
21
  const libraryInfosPromises = resources.map((dotLibResource) => {
22
- const namespace = dotLibResource._project.metadata.namespace;
22
+ const namespace = dotLibResource.getProject().getNamespace();
23
23
  // pass all required resources to the processor
24
24
  // the processor will then filter
25
25
  return dependencies.byGlob(`/resources/${namespace}/**/${MANIFEST_JSON}`).then((manifestResources) => {
@@ -31,8 +31,8 @@ module.exports = async ({workspace, dependencies, options: {rootProject, pattern
31
31
  return {
32
32
  libraryManifest,
33
33
  embeddedManifests,
34
- name: dotLibResource._project.metadata.name,
35
- version: dotLibResource._project.version
34
+ name: dotLibResource.getProject().getName(),
35
+ version: dotLibResource.getProject().getVersion()
36
36
  };
37
37
  });
38
38
  });
@@ -40,8 +40,8 @@ module.exports = async ({workspace, dependencies, options: {rootProject, pattern
40
40
 
41
41
  const [versionInfoResource] = await versionInfoGenerator({
42
42
  options: {
43
- rootProjectName: rootProject.metadata.name,
44
- rootProjectVersion: rootProject.version,
43
+ rootProjectName: rootProject.getName(),
44
+ rootProjectVersion: rootProject.getVersion(),
45
45
  libraryInfos
46
46
  }
47
47
  });
@@ -36,30 +36,18 @@ function getTask(taskName) {
36
36
  try {
37
37
  const task = require(taskInfo.path);
38
38
  return {
39
- task,
40
- specVersion: taskInfo.specVersion
39
+ task
41
40
  };
42
41
  } catch (err) {
43
42
  throw new Error(`taskRepository: Failed to require task module for ${taskName}: ${err.message}`);
44
43
  }
45
44
  }
46
45
 
47
- function addTask({name, specVersion, taskPath}) {
48
- if (taskInfos[name]) {
49
- throw new Error(`taskRepository: A task with the name ${name} has already been registered`);
50
- }
51
- taskInfos[name] = {
52
- path: taskPath,
53
- specVersion
54
- };
55
- }
56
-
57
46
  function getAllTaskNames() {
58
47
  return Object.keys(taskInfos);
59
48
  }
60
49
 
61
50
  module.exports = {
62
51
  getTask,
63
- addTask,
64
52
  getAllTaskNames
65
53
  };
@@ -1,6 +1,7 @@
1
1
  const log = require("@ui5/logger").getLogger("builder:tasks:transformBootstrapHtml");
2
2
  const bootstrapHtmlTransformer = require("../processors/bootstrapHtmlTransformer");
3
3
 
4
+ /* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
4
5
  /**
5
6
  * Task for transforming the application bootstrap HTML file.
6
7
  *
@@ -12,7 +13,11 @@ const bootstrapHtmlTransformer = require("../processors/bootstrapHtmlTransformer
12
13
  * @param {string} [parameters.options.namespace] Project namespace
13
14
  * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
14
15
  */
15
- module.exports = async function({workspace, options: {projectName, namespace}}) {
16
+ module.exports = async function({workspace, options}) {
17
+ const {projectName} = options;
18
+ // Backward compatibility: "namespace" option got renamed to "projectNamespace"
19
+ const namespace = options.projectNamespace || options.namespace;
20
+
16
21
  let indexPath;
17
22
  if (namespace) {
18
23
  indexPath = `/resources/${namespace}/index.html`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/builder",
3
- "version": "3.0.0-alpha.6",
3
+ "version": "3.0.0-alpha.7",
4
4
  "description": "UI5 Tooling - Builder",
5
5
  "author": {
6
6
  "name": "SAP SE",
@@ -105,28 +105,27 @@
105
105
  "url": "git@github.com:SAP/ui5-builder.git"
106
106
  },
107
107
  "dependencies": {
108
- "@ui5/fs": "^3.0.0-alpha.3",
108
+ "@ui5/fs": "^3.0.0-alpha.4",
109
109
  "@ui5/logger": "^3.0.1-alpha.1",
110
110
  "cheerio": "1.0.0-rc.9",
111
111
  "escape-unicode": "^0.2.0",
112
112
  "escope": "^3.6.0",
113
113
  "espree": "^9.3.1",
114
- "globby": "^11.1.0",
115
114
  "graceful-fs": "^4.2.9",
116
115
  "jsdoc": "^3.6.7",
117
116
  "less-openui5": "^0.11.2",
118
117
  "make-dir": "^3.1.0",
119
118
  "pretty-data": "^0.40.0",
120
- "pretty-hrtime": "^1.0.3",
121
119
  "replacestream": "^4.0.3",
122
120
  "rimraf": "^3.0.2",
123
121
  "semver": "^7.3.5",
124
122
  "sourcemap-codec": "^1.4.8",
125
- "terser": "^5.10.0",
123
+ "terser": "^5.14.1",
126
124
  "xml2js": "^0.4.23",
127
125
  "yazl": "^2.5.1"
128
126
  },
129
127
  "devDependencies": {
128
+ "@ui5/project": "SAP/ui5-project#ui5-project-3.0",
130
129
  "ava": "^3.15.0",
131
130
  "chai": "^4.3.4",
132
131
  "chai-fs": "^2.0.0",
@@ -1,60 +0,0 @@
1
- const ResourceTagCollection = require("@ui5/fs").ResourceTagCollection;
2
- const ProjectBuildContext = require("./ProjectBuildContext");
3
-
4
- // Note: When adding standard tags, always update the public documentation in TaskUtil
5
- // (Type "module:@ui5/builder.tasks.TaskUtil~StandardBuildTags")
6
- const GLOBAL_TAGS = Object.freeze({
7
- IsDebugVariant: "ui5:IsDebugVariant",
8
- HasDebugVariant: "ui5:HasDebugVariant",
9
- });
10
-
11
- /**
12
- * Context of a build process
13
- *
14
- * @private
15
- * @memberof module:@ui5/builder.builder
16
- */
17
- class BuildContext {
18
- constructor({rootProject, options = {}}) {
19
- if (!rootProject) {
20
- throw new Error(`Missing parameter 'rootProject'`);
21
- }
22
- this.rootProject = rootProject;
23
- this.projectBuildContexts = [];
24
- this._resourceTagCollection = new ResourceTagCollection({
25
- allowedTags: Object.values(GLOBAL_TAGS)
26
- });
27
- this.options = options;
28
- }
29
-
30
- getRootProject() {
31
- return this.rootProject;
32
- }
33
-
34
- getOption(key) {
35
- return this.options[key];
36
- }
37
-
38
- createProjectContext({project, resources}) {
39
- const projectBuildContext = new ProjectBuildContext({
40
- buildContext: this,
41
- globalTags: GLOBAL_TAGS,
42
- project,
43
- resources
44
- });
45
- this.projectBuildContexts.push(projectBuildContext);
46
- return projectBuildContext;
47
- }
48
-
49
- async executeCleanupTasks() {
50
- await Promise.all(this.projectBuildContexts.map((ctx) => {
51
- return ctx.executeCleanupTasks();
52
- }));
53
- }
54
-
55
- getResourceTagCollection() {
56
- return this._resourceTagCollection;
57
- }
58
- }
59
-
60
- module.exports = BuildContext;