@ui5/builder 3.0.0-alpha.1 → 3.0.0-alpha.10
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 +850 -0
- package/index.js +0 -43
- package/lib/lbt/analyzer/JSModuleAnalyzer.js +27 -8
- package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +2 -1
- package/lib/lbt/bundle/Builder.js +364 -137
- package/lib/lbt/bundle/BundleWriter.js +17 -0
- package/lib/lbt/bundle/Resolver.js +2 -2
- 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/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 +20 -20
- package/lib/processors/jsdoc/lib/ui5/plugin.js +111 -6
- 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 +11 -10
- 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,6 +1,7 @@
|
|
|
1
1
|
const log = require("@ui5/logger").getLogger("builder:tasks:bundlers:generateStandaloneAppBundle");
|
|
2
2
|
const ReaderCollectionPrioritized = require("@ui5/fs").ReaderCollectionPrioritized;
|
|
3
3
|
const moduleBundler = require("../../processors/bundlers/moduleBundler");
|
|
4
|
+
const createModuleNameMapping = require("./utils/createModuleNameMapping");
|
|
4
5
|
|
|
5
6
|
function getBundleDefinition(config) {
|
|
6
7
|
const bundleDefinition = {
|
|
@@ -57,6 +58,7 @@ function getBundleDefinition(config) {
|
|
|
57
58
|
return bundleDefinition;
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
/* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
|
|
60
62
|
/**
|
|
61
63
|
* Task for bundling standalone applications.
|
|
62
64
|
*
|
|
@@ -65,13 +67,17 @@ function getBundleDefinition(config) {
|
|
|
65
67
|
* @param {object} parameters Parameters
|
|
66
68
|
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
|
|
67
69
|
* @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
|
|
68
|
-
* @param {module:@ui5/
|
|
70
|
+
* @param {module:@ui5/project.build.helpers.TaskUtil|object} [parameters.taskUtil] TaskUtil
|
|
69
71
|
* @param {object} parameters.options Options
|
|
70
72
|
* @param {string} parameters.options.projectName Project name
|
|
71
|
-
* @param {string} [parameters.options.
|
|
73
|
+
* @param {string} [parameters.options.projectNamespace] Project namespace
|
|
72
74
|
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
|
|
73
75
|
*/
|
|
74
|
-
module.exports = async function({workspace, dependencies, taskUtil, options
|
|
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
|
+
|
|
75
81
|
if (!namespace) {
|
|
76
82
|
log.warn(`Namespace of project ${projectName} is not known. Self contained bundling is currently ` +
|
|
77
83
|
`unable to generate complete bundles for such projects.`);
|
|
@@ -88,8 +94,7 @@ module.exports = async function({workspace, dependencies, taskUtil, options: {pr
|
|
|
88
94
|
return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant);
|
|
89
95
|
});
|
|
90
96
|
}
|
|
91
|
-
const
|
|
92
|
-
const resources = Array.prototype.concat.apply([], results);
|
|
97
|
+
const resources = await combo.byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}");
|
|
93
98
|
|
|
94
99
|
const isEvo = resources.find((resource) => {
|
|
95
100
|
return resource.getPath() === "/resources/ui5loader.js";
|
|
@@ -101,6 +106,23 @@ module.exports = async function({workspace, dependencies, taskUtil, options: {pr
|
|
|
101
106
|
filters = ["jquery.sap.global.js"];
|
|
102
107
|
}
|
|
103
108
|
|
|
109
|
+
let unoptimizedModuleNameMapping;
|
|
110
|
+
let unoptimizedResources = resources;
|
|
111
|
+
if (taskUtil) {
|
|
112
|
+
unoptimizedResources = await new ReaderCollectionPrioritized({
|
|
113
|
+
name: `generateStandaloneAppBundle - prioritize workspace over dependencies: ${projectName}`,
|
|
114
|
+
readers: [workspace, dependencies]
|
|
115
|
+
}).filter(function(resource) {
|
|
116
|
+
// Remove any non-debug variants
|
|
117
|
+
return !taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.HasDebugVariant);
|
|
118
|
+
}).byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}");
|
|
119
|
+
|
|
120
|
+
unoptimizedModuleNameMapping = createModuleNameMapping({
|
|
121
|
+
resources: unoptimizedResources,
|
|
122
|
+
taskUtil
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
104
126
|
await Promise.all([
|
|
105
127
|
moduleBundler({
|
|
106
128
|
resources,
|
|
@@ -114,7 +136,7 @@ module.exports = async function({workspace, dependencies, taskUtil, options: {pr
|
|
|
114
136
|
}
|
|
115
137
|
}),
|
|
116
138
|
moduleBundler({
|
|
117
|
-
resources,
|
|
139
|
+
resources: unoptimizedResources,
|
|
118
140
|
options: {
|
|
119
141
|
bundleDefinition: getBundleDefinition({
|
|
120
142
|
name: "sap-ui-custom-dbg.js",
|
|
@@ -123,16 +145,26 @@ module.exports = async function({workspace, dependencies, taskUtil, options: {pr
|
|
|
123
145
|
}),
|
|
124
146
|
bundleOptions: {
|
|
125
147
|
optimize: false
|
|
126
|
-
}
|
|
148
|
+
},
|
|
149
|
+
moduleNameMapping: unoptimizedModuleNameMapping
|
|
127
150
|
}
|
|
128
151
|
})
|
|
129
152
|
]).then((results) => {
|
|
130
153
|
const bundles = Array.prototype.concat.apply([], results);
|
|
131
|
-
return Promise.all(bundles.map((
|
|
154
|
+
return Promise.all(bundles.map(({bundle, sourceMap}) => {
|
|
132
155
|
if (taskUtil) {
|
|
133
|
-
taskUtil.setTag(
|
|
156
|
+
taskUtil.setTag(bundle, taskUtil.STANDARD_TAGS.IsBundle);
|
|
157
|
+
if (sourceMap) {
|
|
158
|
+
// Clear tag that might have been set by the minify task, in cases where
|
|
159
|
+
// the bundle name is identical to a source file
|
|
160
|
+
taskUtil.clearTag(sourceMap, taskUtil.STANDARD_TAGS.OmitFromBuildResult);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
const writes = [workspace.write(bundle)];
|
|
164
|
+
if (sourceMap) {
|
|
165
|
+
writes.push(workspace.write(sourceMap));
|
|
134
166
|
}
|
|
135
|
-
return
|
|
167
|
+
return Promise.all(writes);
|
|
136
168
|
}));
|
|
137
169
|
});
|
|
138
170
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const ModuleName = require("../../../lbt/utils/ModuleName");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* For "unoptimized" bundles, the non-debug files have already been filtered out above.
|
|
5
|
+
* Now we need to create a mapping from the debug-variant resource path to the respective module
|
|
6
|
+
* name, which is basically the non-debug resource path, minus the "/resources/"" prefix.
|
|
7
|
+
* This mapping overwrites internal logic of the LocatorResourcePool which would otherwise determine
|
|
8
|
+
* the module name from the resource path, which would contain "-dbg" in this case. That would be
|
|
9
|
+
* incorrect since debug-variants should still keep the original module name.
|
|
10
|
+
*
|
|
11
|
+
* @private
|
|
12
|
+
* @param {object} parameters Parameters
|
|
13
|
+
* @param {module:@ui5/fs.Resource[]} parameters.resources List of resources
|
|
14
|
+
* @param {module:@ui5/project.build.helpers.TaskUtil|object} parameters.taskUtil TaskUtil
|
|
15
|
+
* @returns {object} Module name mapping
|
|
16
|
+
*/
|
|
17
|
+
module.exports = function({resources, taskUtil}) {
|
|
18
|
+
const moduleNameMapping = {};
|
|
19
|
+
for (let i = resources.length - 1; i >= 0; i--) {
|
|
20
|
+
const resource = resources[i];
|
|
21
|
+
if (taskUtil.getTag(resource, taskUtil.STANDARD_TAGS.IsDebugVariant)) {
|
|
22
|
+
const resourcePath = resource.getPath();
|
|
23
|
+
const nonDbgPath = ModuleName.getNonDebugName(resourcePath);
|
|
24
|
+
if (!nonDbgPath) {
|
|
25
|
+
throw new Error(`Failed to resolve non-debug name for ${resourcePath}`);
|
|
26
|
+
}
|
|
27
|
+
moduleNameMapping[resourcePath] = nonDbgPath.slice("/resources/".length);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return moduleNameMapping;
|
|
31
|
+
};
|
|
@@ -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.
|
|
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,
|
|
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) => {
|
|
@@ -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,19 @@ 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/
|
|
14
|
+
* @param {module:@ui5/project.build.helpers.TaskUtil|object} [parameters.taskUtil] TaskUtil
|
|
16
15
|
* @param {object} parameters.options Options
|
|
17
16
|
* @param {string} parameters.options.projectName Project name
|
|
18
17
|
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
|
|
19
18
|
*/
|
|
20
|
-
module.exports = function({workspace,
|
|
21
|
-
const combo = new ReaderCollectionPrioritized({
|
|
22
|
-
name: `libraryManifestGenerator - prioritize workspace over dependencies: ${projectName}`,
|
|
23
|
-
readers: [workspace, dependencies]
|
|
24
|
-
});
|
|
19
|
+
module.exports = function({workspace, taskUtil, options: {projectName}}) {
|
|
25
20
|
// Note:
|
|
26
21
|
// *.library files are needed to identify libraries
|
|
27
22
|
// *.json files are needed to avoid overwriting them
|
|
28
23
|
// *.js files are needed to identify nested components
|
|
29
24
|
// *.less, *.css, *.theming and *.theme files are needed to identify supported themes
|
|
30
25
|
// *.properties to identify existence of i18n bundles (e.g. messagebundle.properties)
|
|
31
|
-
return
|
|
26
|
+
return workspace.byGlob("/resources/**/*.{js,json,library,less,css,theming,theme,properties}").then((resources) => {
|
|
32
27
|
// Find all libraries and create a manifest.json file
|
|
33
28
|
return workspace.byGlob("/resources/**/.library").then((libraryIndicatorResources) => {
|
|
34
29
|
if (libraryIndicatorResources.length < 1) {
|
|
@@ -51,6 +46,9 @@ module.exports = function({workspace, dependencies, options: {projectName}}) {
|
|
|
51
46
|
libraryResource: libraryIndicatorResource,
|
|
52
47
|
namespace: libraryNamespace,
|
|
53
48
|
resources,
|
|
49
|
+
getProjectVersion: (projectName) => {
|
|
50
|
+
return taskUtil?.getProject(projectName)?.getVersion();
|
|
51
|
+
},
|
|
54
52
|
options: {
|
|
55
53
|
}
|
|
56
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.
|
|
46
|
+
* {@link https://sdk.openui5.org/topic/adcbcf8b50924556ab3f321fcd9353ea}
|
|
47
47
|
* </p>
|
|
48
48
|
*
|
|
49
49
|
* <p>
|
|
@@ -97,7 +97,7 @@ function getCreatorOptions(projectName) {
|
|
|
97
97
|
* @param {object} parameters Parameters
|
|
98
98
|
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
|
|
99
99
|
* @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
|
|
100
|
-
* @param {module:@ui5/
|
|
100
|
+
* @param {module:@ui5/project.build.helpers.TaskUtil|object} [parameters.taskUtil] TaskUtil
|
|
101
101
|
* @param {object} parameters.options Options
|
|
102
102
|
* @param {string} parameters.options.projectName Project name
|
|
103
103
|
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
|
|
@@ -105,7 +105,7 @@ function getCreatorOptions(projectName) {
|
|
|
105
105
|
module.exports = async function({workspace, dependencies, taskUtil, options: {projectName}}) {
|
|
106
106
|
let resources = await workspace.byGlob(["/resources/**/*"].concat(DEFAULT_EXCLUDES));
|
|
107
107
|
let dependencyResources =
|
|
108
|
-
await dependencies.byGlob("/resources/**/*.{js,json,xml,html,properties,library}");
|
|
108
|
+
await dependencies.byGlob("/resources/**/*.{js,json,xml,html,properties,library,js.map}");
|
|
109
109
|
|
|
110
110
|
if (taskUtil) {
|
|
111
111
|
// Filter out resources that will be omitted from the build results
|
|
@@ -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,83 @@ 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
|
+
|
|
190
|
+
/* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
|
|
83
191
|
/**
|
|
84
192
|
* Generates resources required for integration with the SAP Theme Designer.
|
|
85
193
|
*
|
|
@@ -91,11 +199,16 @@ async function generateThemeDotTheming({workspace, combo, themeFolder}) {
|
|
|
91
199
|
* @param {object} parameters.options Options
|
|
92
200
|
* @param {string} parameters.options.projectName Project name
|
|
93
201
|
* @param {string} parameters.options.version Project version
|
|
94
|
-
* @param {string} [parameters.options.
|
|
202
|
+
* @param {string} [parameters.options.projectNamespace] If the project is of type <code>library</code>,
|
|
203
|
+
* provide its namespace.
|
|
95
204
|
* Omit for type <code>theme-library</code>
|
|
96
205
|
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
|
|
97
206
|
*/
|
|
98
|
-
module.exports = async function({workspace, dependencies, options
|
|
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
|
+
|
|
99
212
|
// Skip sap.ui.documentation since it is not intended to be available in SAP Theme Designer to create custom themes
|
|
100
213
|
if (namespace === "sap/ui/documentation") {
|
|
101
214
|
return;
|
|
@@ -163,4 +276,7 @@ module.exports = async function({workspace, dependencies, options: {projectName,
|
|
|
163
276
|
await Promise.all(
|
|
164
277
|
libraryLessResources.map((resource) => workspace.write(resource))
|
|
165
278
|
);
|
|
279
|
+
|
|
280
|
+
// css_variables.less
|
|
281
|
+
await generateCssVariablesLess({workspace, combo, namespace});
|
|
166
282
|
};
|
|
@@ -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.
|
|
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.
|
|
35
|
-
version: dotLibResource.
|
|
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.
|
|
44
|
-
rootProjectVersion: rootProject.
|
|
43
|
+
rootProjectName: rootProject.getName(),
|
|
44
|
+
rootProjectVersion: rootProject.getVersion(),
|
|
45
45
|
libraryInfos
|
|
46
46
|
}
|
|
47
47
|
});
|
|
@@ -28,7 +28,7 @@ const {resourceFactory} = require("@ui5/fs");
|
|
|
28
28
|
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
|
|
29
29
|
* @param {module:@ui5/fs.AbstractReader} parameters.dependencies Reader or Collection to read dependency files
|
|
30
30
|
* @param {GenerateJsdocOptions} parameters.options Options
|
|
31
|
-
* @param {module:@ui5/
|
|
31
|
+
* @param {module:@ui5/project.build.helpers.TaskUtil|object} [parameters.taskUtil] TaskUtil
|
|
32
32
|
* @param {object} [parameters.buildContext] Internal, deprecated parameter
|
|
33
33
|
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
|
|
34
34
|
*/
|
package/lib/tasks/minify.js
CHANGED
|
@@ -7,20 +7,30 @@ const minifier = require("../processors/minifier");
|
|
|
7
7
|
* @alias module:@ui5/builder.tasks.minify
|
|
8
8
|
* @param {object} parameters Parameters
|
|
9
9
|
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
|
|
10
|
-
* @param {module:@ui5/
|
|
10
|
+
* @param {module:@ui5/project.build.helpers.TaskUtil|object} [parameters.taskUtil] TaskUtil
|
|
11
11
|
* @param {object} parameters.options Options
|
|
12
12
|
* @param {string} parameters.options.pattern Pattern to locate the files to be processed
|
|
13
|
+
* @param {boolean} [parameters.options.omitSourceMapResources=false] Whether source map resources shall
|
|
14
|
+
* be tagged as "OmitFromBuildResult" and no sourceMappingURL shall be added to the minified resource
|
|
13
15
|
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
|
|
14
16
|
*/
|
|
15
|
-
module.exports = async function({workspace, taskUtil, options: {pattern}}) {
|
|
17
|
+
module.exports = async function({workspace, taskUtil, options: {pattern, omitSourceMapResources = false}}) {
|
|
16
18
|
const resources = await workspace.byGlob(pattern);
|
|
17
|
-
const processedResources = await minifier({
|
|
19
|
+
const processedResources = await minifier({
|
|
20
|
+
resources,
|
|
21
|
+
options: {
|
|
22
|
+
addSourceMappingUrl: !omitSourceMapResources
|
|
23
|
+
}
|
|
24
|
+
});
|
|
18
25
|
|
|
19
26
|
return Promise.all(processedResources.map(async ({resource, dbgResource, sourceMapResource}) => {
|
|
20
27
|
if (taskUtil) {
|
|
21
28
|
taskUtil.setTag(resource, taskUtil.STANDARD_TAGS.HasDebugVariant);
|
|
22
29
|
taskUtil.setTag(dbgResource, taskUtil.STANDARD_TAGS.IsDebugVariant);
|
|
23
|
-
taskUtil.setTag(sourceMapResource, taskUtil.STANDARD_TAGS.
|
|
30
|
+
taskUtil.setTag(sourceMapResource, taskUtil.STANDARD_TAGS.HasDebugVariant);
|
|
31
|
+
if (omitSourceMapResources) {
|
|
32
|
+
taskUtil.setTag(sourceMapResource, taskUtil.STANDARD_TAGS.OmitFromBuildResult);
|
|
33
|
+
}
|
|
24
34
|
}
|
|
25
35
|
return Promise.all([
|
|
26
36
|
workspace.write(resource),
|
|
@@ -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
|
|
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.
|
|
3
|
+
"version": "3.0.0-alpha.10",
|
|
4
4
|
"description": "UI5 Tooling - Builder",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "SAP SE",
|
|
@@ -37,13 +37,14 @@
|
|
|
37
37
|
"jsdoc-generate": "jsdoc -c ./jsdoc.json -t $(node -p 'path.dirname(require.resolve(\"docdash\"))') ./lib/ || (echo 'Error during JSDoc generation! Check log.' && exit 1)",
|
|
38
38
|
"jsdoc-watch": "npm run jsdoc && chokidar \"./lib/**/*.js\" -c \"npm run jsdoc-generate\"",
|
|
39
39
|
"preversion": "npm test",
|
|
40
|
-
"version": "git-chglog --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
|
|
40
|
+
"version": "git-chglog --sort semver --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
|
|
41
41
|
"postversion": "git push --follow-tags",
|
|
42
|
-
"release-note": "git-chglog -c .chglog/release-config.yml v$npm_package_version",
|
|
43
|
-
"depcheck": "depcheck --ignores docdash"
|
|
42
|
+
"release-note": "git-chglog --sort semver -c .chglog/release-config.yml v$npm_package_version",
|
|
43
|
+
"depcheck": "depcheck --ignores docdash --ignore-patterns lib/processors/jsdoc/lib/ui5"
|
|
44
44
|
},
|
|
45
45
|
"files": [
|
|
46
46
|
"index.js",
|
|
47
|
+
"CHANGELOG.md",
|
|
47
48
|
"CONTRIBUTING.md",
|
|
48
49
|
"jsdoc.json",
|
|
49
50
|
"lib/**",
|
|
@@ -104,27 +105,27 @@
|
|
|
104
105
|
"url": "git@github.com:SAP/ui5-builder.git"
|
|
105
106
|
},
|
|
106
107
|
"dependencies": {
|
|
107
|
-
"@
|
|
108
|
-
"@ui5/
|
|
108
|
+
"@jridgewell/sourcemap-codec": "^1.4.14",
|
|
109
|
+
"@ui5/fs": "^3.0.0-alpha.6",
|
|
110
|
+
"@ui5/logger": "^3.0.1-alpha.2",
|
|
109
111
|
"cheerio": "1.0.0-rc.9",
|
|
110
112
|
"escape-unicode": "^0.2.0",
|
|
111
113
|
"escope": "^3.6.0",
|
|
112
|
-
"espree": "^9.3.
|
|
113
|
-
"globby": "^11.1.0",
|
|
114
|
+
"espree": "^9.3.1",
|
|
114
115
|
"graceful-fs": "^4.2.9",
|
|
115
116
|
"jsdoc": "^3.6.7",
|
|
116
117
|
"less-openui5": "^0.11.2",
|
|
117
118
|
"make-dir": "^3.1.0",
|
|
118
119
|
"pretty-data": "^0.40.0",
|
|
119
|
-
"pretty-hrtime": "^1.0.3",
|
|
120
120
|
"replacestream": "^4.0.3",
|
|
121
121
|
"rimraf": "^3.0.2",
|
|
122
122
|
"semver": "^7.3.5",
|
|
123
|
-
"terser": "^5.
|
|
123
|
+
"terser": "^5.14.2",
|
|
124
124
|
"xml2js": "^0.4.23",
|
|
125
125
|
"yazl": "^2.5.1"
|
|
126
126
|
},
|
|
127
127
|
"devDependencies": {
|
|
128
|
+
"@ui5/project": "^3.0.0-alpha.7",
|
|
128
129
|
"ava": "^3.15.0",
|
|
129
130
|
"chai": "^4.3.4",
|
|
130
131
|
"chai-fs": "^2.0.0",
|
|
@@ -1,56 +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}) {
|
|
19
|
-
if (!rootProject) {
|
|
20
|
-
throw new Error(`Missing parameter 'rootProject'`);
|
|
21
|
-
}
|
|
22
|
-
this.rootProject = rootProject;
|
|
23
|
-
this.projectBuildContexts = [];
|
|
24
|
-
|
|
25
|
-
this._resourceTagCollection = new ResourceTagCollection({
|
|
26
|
-
allowedTags: Object.values(GLOBAL_TAGS)
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getRootProject() {
|
|
31
|
-
return this.rootProject;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
createProjectContext({project, resources}) {
|
|
35
|
-
const projectBuildContext = new ProjectBuildContext({
|
|
36
|
-
buildContext: this,
|
|
37
|
-
globalTags: GLOBAL_TAGS,
|
|
38
|
-
project,
|
|
39
|
-
resources
|
|
40
|
-
});
|
|
41
|
-
this.projectBuildContexts.push(projectBuildContext);
|
|
42
|
-
return projectBuildContext;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async executeCleanupTasks() {
|
|
46
|
-
await Promise.all(this.projectBuildContexts.map((ctx) => {
|
|
47
|
-
return ctx.executeCleanupTasks();
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
getResourceTagCollection() {
|
|
52
|
-
return this._resourceTagCollection;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
module.exports = BuildContext;
|