@ui5/builder 3.0.0-alpha.11 → 3.0.0-alpha.12
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 +18 -2
- package/jsdoc.json +2 -2
- package/lib/lbt/UI5ClientConstants.js +7 -8
- package/lib/lbt/analyzer/ComponentAnalyzer.js +10 -10
- package/lib/lbt/analyzer/FioriElementsAnalyzer.js +9 -9
- package/lib/lbt/analyzer/JSModuleAnalyzer.js +32 -25
- package/lib/lbt/analyzer/SmartTemplateAnalyzer.js +9 -9
- package/lib/lbt/analyzer/XMLCompositeAnalyzer.js +8 -8
- package/lib/lbt/analyzer/XMLTemplateAnalyzer.js +19 -17
- package/lib/lbt/analyzer/analyzeLibraryJS.js +8 -7
- package/lib/lbt/bundle/AutoSplitter.js +10 -11
- package/lib/lbt/bundle/Builder.js +29 -32
- package/lib/lbt/bundle/BundleDefinition.js +1 -5
- package/lib/lbt/bundle/BundleWriter.js +1 -2
- package/lib/lbt/bundle/ResolvedBundleDefinition.js +6 -7
- package/lib/lbt/bundle/Resolver.js +9 -10
- package/lib/lbt/calls/SapUiDefine.js +5 -6
- package/lib/lbt/graph/dependencyGraph.js +3 -4
- package/lib/lbt/graph/dominatorTree.js +3 -3
- package/lib/lbt/graph/topologicalSort.js +3 -3
- package/lib/lbt/resources/LibraryFileAnalyzer.js +5 -8
- package/lib/lbt/resources/LocatorResource.js +2 -2
- package/lib/lbt/resources/LocatorResourcePool.js +3 -3
- package/lib/lbt/resources/ModuleInfo.js +1 -2
- package/lib/lbt/resources/Resource.js +3 -4
- package/lib/lbt/resources/ResourceCollector.js +7 -8
- package/lib/lbt/resources/ResourceFilterList.js +38 -40
- package/lib/lbt/resources/ResourceInfo.js +1 -1
- package/lib/lbt/resources/ResourceInfoList.js +2 -2
- package/lib/lbt/resources/ResourcePool.js +15 -21
- package/lib/lbt/utils/ASTUtils.js +17 -30
- package/lib/lbt/utils/JSTokenizer.js +4 -4
- package/lib/lbt/utils/ModuleName.js +10 -20
- package/lib/lbt/utils/escapePropertiesFile.js +3 -3
- package/lib/lbt/utils/parseUtils.js +4 -10
- package/lib/processors/bootstrapHtmlTransformer.js +15 -7
- package/lib/processors/bundlers/flexChangesBundler.js +16 -8
- package/lib/processors/bundlers/manifestBundler.js +19 -10
- package/lib/processors/bundlers/moduleBundler.js +26 -15
- package/lib/processors/jsdoc/apiIndexGenerator.js +16 -9
- package/lib/processors/jsdoc/jsdocGenerator.js +31 -17
- package/lib/processors/jsdoc/lib/{createIndexFiles.js → createIndexFiles.cjs} +0 -0
- package/lib/processors/jsdoc/lib/{transformApiJson.js → transformApiJson.cjs} +0 -0
- package/lib/processors/jsdoc/lib/ui5/{plugin.js → plugin.cjs} +0 -0
- package/lib/processors/jsdoc/lib/ui5/template/{publish.js → publish.cjs} +1 -1
- package/lib/processors/jsdoc/lib/ui5/template/utils/{versionUtil.js → versionUtil.cjs} +0 -0
- package/lib/processors/jsdoc/sdkTransformer.js +18 -11
- package/lib/processors/libraryLessGenerator.js +28 -16
- package/lib/processors/manifestCreator.js +14 -13
- package/lib/processors/minifier.js +21 -15
- package/lib/processors/nonAsciiEscaper.js +16 -6
- package/lib/processors/resourceListCreator.js +13 -13
- package/lib/processors/stringReplacer.js +13 -6
- package/lib/processors/themeBuilder.js +30 -22
- package/lib/processors/versionInfoGenerator.js +33 -23
- package/lib/tasks/buildThemes.js +17 -10
- package/lib/tasks/bundlers/generateBundle.js +23 -12
- package/lib/tasks/bundlers/generateComponentPreload.js +18 -10
- package/lib/tasks/bundlers/generateFlexChangesBundle.js +16 -8
- package/lib/tasks/bundlers/generateLibraryPreload.js +22 -12
- package/lib/tasks/bundlers/generateManifestBundle.js +15 -6
- package/lib/tasks/bundlers/generateStandaloneAppBundle.js +21 -13
- package/lib/tasks/bundlers/utils/createModuleNameMapping.js +6 -6
- package/lib/tasks/escapeNonAsciiCharacters.js +12 -5
- package/lib/tasks/generateCachebusterInfo.js +16 -8
- package/lib/tasks/generateLibraryManifest.js +14 -8
- package/lib/tasks/generateResourcesJson.js +15 -9
- package/lib/tasks/generateThemeDesignerResources.js +19 -9
- package/lib/tasks/generateVersionInfo.js +12 -5
- package/lib/tasks/jsdoc/executeJsdocSdkTransformation.js +17 -9
- package/lib/tasks/jsdoc/generateApiIndex.js +16 -10
- package/lib/tasks/jsdoc/generateJsdoc.js +131 -119
- package/lib/tasks/minify.js +13 -6
- package/lib/tasks/replaceBuildtime.js +12 -5
- package/lib/tasks/replaceCopyright.js +12 -5
- package/lib/tasks/replaceVersion.js +12 -5
- package/lib/tasks/taskRepository.js +24 -29
- package/lib/tasks/transformBootstrapHtml.js +6 -5
- package/package.json +29 -15
- package/index.js +0 -173
|
@@ -1,15 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {spawn} from "node:child_process";
|
|
2
|
+
import fs from "graceful-fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import {promisify} from "node:util";
|
|
5
5
|
const writeFile = promisify(fs.writeFile);
|
|
6
|
-
|
|
6
|
+
import {createAdapter} from "@ui5/fs/resourceFactory";
|
|
7
|
+
import {createRequire} from "node:module";
|
|
8
|
+
import {fileURLToPath} from "node:url";
|
|
9
|
+
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
* @module @ui5/builder/processors/jsdocGenerator
|
|
16
|
+
*/
|
|
7
17
|
|
|
8
18
|
/**
|
|
9
19
|
* JSDoc generator
|
|
10
20
|
*
|
|
11
21
|
* @public
|
|
12
|
-
* @
|
|
22
|
+
* @function default
|
|
23
|
+
* @static
|
|
24
|
+
*
|
|
13
25
|
* @param {object} parameters Parameters
|
|
14
26
|
* @param {string} parameters.sourcePath Path of the source files to be processed
|
|
15
27
|
* @param {string} parameters.targetPath Path to write any output files
|
|
@@ -19,9 +31,9 @@ const {resourceFactory} = require("@ui5/fs");
|
|
|
19
31
|
* @param {string} parameters.options.namespace Namespace to build (e.g. <code>some/project/name</code>)
|
|
20
32
|
* @param {string} parameters.options.version Project version
|
|
21
33
|
* @param {Array} [parameters.options.variants=["apijson"]] JSDoc variants to be built
|
|
22
|
-
* @returns {Promise
|
|
34
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with newly created resources
|
|
23
35
|
*/
|
|
24
|
-
|
|
36
|
+
export default async function jsdocGenerator(
|
|
25
37
|
{sourcePath, targetPath, tmpPath, options: {projectName, namespace, version, variants}} = {}
|
|
26
38
|
) {
|
|
27
39
|
if (!sourcePath || !targetPath || !tmpPath || !projectName || !namespace || !version) {
|
|
@@ -48,7 +60,7 @@ const jsdocGenerator = async function(
|
|
|
48
60
|
configPath
|
|
49
61
|
});
|
|
50
62
|
|
|
51
|
-
const fsTarget =
|
|
63
|
+
const fsTarget = createAdapter({
|
|
52
64
|
fsBasePath: targetPath,
|
|
53
65
|
virBasePath: "/"
|
|
54
66
|
});
|
|
@@ -58,7 +70,7 @@ const jsdocGenerator = async function(
|
|
|
58
70
|
fsTarget.byPath(`/test-resources/${namespace}/designtime/api.json`)
|
|
59
71
|
// fsTarget.byPath(`/libraries/${options.projectName}.js`)
|
|
60
72
|
]).then((res) => res.filter(($)=>$));
|
|
61
|
-
}
|
|
73
|
+
}
|
|
62
74
|
|
|
63
75
|
|
|
64
76
|
/**
|
|
@@ -82,8 +94,11 @@ async function generateJsdocConfig({targetPath, tmpPath, namespace, projectName,
|
|
|
82
94
|
|
|
83
95
|
// Resolve path to this script to get the path to the JSDoc extensions folder
|
|
84
96
|
const jsdocPath = path.normalize(__dirname);
|
|
85
|
-
const pluginPath = path.join(jsdocPath, "lib", "ui5", "plugin.
|
|
86
|
-
|
|
97
|
+
const pluginPath = path.join(jsdocPath, "lib", "ui5", "plugin.cjs").replace(backslashRegex, "\\\\");
|
|
98
|
+
// Using export via package.json to allow loading the CJS template.
|
|
99
|
+
// jsdoc appends /publish to the provided path but doesn't allow to
|
|
100
|
+
// add the .cjs extension, so loading won't work otherwise.
|
|
101
|
+
const templatePath = "@ui5/builder/internal/jsdoc/template";
|
|
87
102
|
const destinationPath = path.normalize(tmpPath).replace(backslashRegex, "\\\\");
|
|
88
103
|
const jsapiFilePath = path.join(targetPath, "libraries", projectName + ".js").replace(backslashRegex, "\\\\");
|
|
89
104
|
const apiJsonFolderPath = path.join(tmpPath, "dependency-apis").replace(backslashRegex, "\\\\");
|
|
@@ -157,7 +172,7 @@ async function buildJsdoc({sourcePath, configPath}) {
|
|
|
157
172
|
];
|
|
158
173
|
return new Promise((resolve, reject) => {
|
|
159
174
|
const child = spawn("node", args, {
|
|
160
|
-
stdio: ["ignore", "ignore",
|
|
175
|
+
stdio: ["ignore", "ignore", "inherit"]
|
|
161
176
|
});
|
|
162
177
|
child.on("close", function(code) {
|
|
163
178
|
if (code === 0 || code === 1) {
|
|
@@ -169,7 +184,6 @@ async function buildJsdoc({sourcePath, configPath}) {
|
|
|
169
184
|
});
|
|
170
185
|
}
|
|
171
186
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
module.exports._buildJsdoc = buildJsdoc;
|
|
187
|
+
jsdocGenerator._generateJsdocConfig = generateJsdocConfig;
|
|
188
|
+
jsdocGenerator._writeJsdocConfig = writeJsdocConfig;
|
|
189
|
+
jsdocGenerator._buildJsdoc = buildJsdoc;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -27,7 +27,7 @@ const info = logger.info.bind(logger);
|
|
|
27
27
|
const warning = logger.warn.bind(logger);
|
|
28
28
|
const error = logger.error.bind(logger);
|
|
29
29
|
|
|
30
|
-
const {extractVersion, extractSince} = require("./utils/versionUtil");
|
|
30
|
+
const {extractVersion, extractSince} = require("./utils/versionUtil.cjs");
|
|
31
31
|
|
|
32
32
|
/* errors that might fail the build in future */
|
|
33
33
|
function future(msg) {
|
|
File without changes
|
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {createResource} from "@ui5/fs/resourceFactory";
|
|
2
|
+
import transformer from "./lib/transformApiJson.cjs";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* @public
|
|
6
|
+
* @module @ui5/builder/processors/sdkTransformer
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Transform api.json as created by [jsdocGenerator]{@link @ui5/builder/processors/jsdocGenerator}
|
|
6
11
|
* for usage in a UI5 SDK
|
|
7
12
|
*
|
|
8
13
|
* @public
|
|
9
|
-
* @
|
|
14
|
+
* @function default
|
|
15
|
+
* @static
|
|
16
|
+
*
|
|
10
17
|
* @param {object} parameters Parameters
|
|
11
18
|
* @param {string} parameters.apiJsonPath Path to the projects api.json file as created by
|
|
12
|
-
* [jsdocGenerator]{@link
|
|
19
|
+
* [jsdocGenerator]{@link @ui5/builder/processors/jsdoc/jsdocGenerator}
|
|
13
20
|
* @param {string} parameters.dotLibraryPath Path to the projects .library file
|
|
14
21
|
* @param {string[]} parameters.dependencyApiJsonPaths List of paths to the api.json files of all dependencies of
|
|
15
|
-
* the project as created by [jsdocGenerator]{@link
|
|
22
|
+
* the project as created by [jsdocGenerator]{@link @ui5/builder/processors/jsdoc/jsdocGenerator}
|
|
16
23
|
* @param {string} parameters.targetApiJsonPath Path to create the new, transformed api.json resource for
|
|
17
|
-
* @param {fs|module:@ui5/fs
|
|
18
|
-
* custom [fs interface]{@link module
|
|
24
|
+
* @param {fs|module:@ui5/fs/fsInterface} parameters.fs Node fs or
|
|
25
|
+
* custom [fs interface]{@link module:@ui5/fs/fsInterface} to use
|
|
19
26
|
*
|
|
20
|
-
* @returns {Promise
|
|
27
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with created resources
|
|
21
28
|
*/
|
|
22
29
|
const sdkTransformer = async function({
|
|
23
30
|
apiJsonPath, dotLibraryPath, dependencyApiJsonPaths, targetApiJsonPath, fs} = {}
|
|
@@ -30,10 +37,10 @@ const sdkTransformer = async function({
|
|
|
30
37
|
fs,
|
|
31
38
|
returnOutputFiles: true
|
|
32
39
|
});
|
|
33
|
-
return [
|
|
40
|
+
return [createResource({
|
|
34
41
|
path: targetApiJsonPath,
|
|
35
42
|
string: apiJsonContent
|
|
36
43
|
})];
|
|
37
44
|
};
|
|
38
45
|
|
|
39
|
-
|
|
46
|
+
export default sdkTransformer;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import logger from "@ui5/logger";
|
|
2
|
+
const log = logger.getLogger("builder:processors:libraryLessGenerator");
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import {promisify} from "node:util";
|
|
5
|
+
import posixPath from "node:path/posix";
|
|
6
|
+
import Resource from "@ui5/fs/Resource";
|
|
6
7
|
|
|
7
8
|
const IMPORT_PATTERN = /@import .*"(.*)";/g;
|
|
8
9
|
const BASE_LESS_PATTERN = /^\/resources\/sap\/ui\/core\/themes\/([^/]+)\/base\.less$/;
|
|
@@ -24,10 +25,10 @@ class LibraryLessGenerator {
|
|
|
24
25
|
async generate({filePath, fileContent}) {
|
|
25
26
|
return `/* NOTE: This file was generated as an optimized version of ` +
|
|
26
27
|
`"library.source.less" for the Theme Designer. */\n\n` +
|
|
27
|
-
await this.resolveLessImports({
|
|
28
|
+
(await this.resolveLessImports({
|
|
28
29
|
filePath,
|
|
29
30
|
fileContent
|
|
30
|
-
});
|
|
31
|
+
}));
|
|
31
32
|
}
|
|
32
33
|
static getPathToRoot(baseDir) {
|
|
33
34
|
return posixPath.relative(baseDir, "/") + "/";
|
|
@@ -132,10 +133,10 @@ class LibraryLessGenerator {
|
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
return `/* START "${originalFilePath}" */\n` +
|
|
135
|
-
await this.resolveLessImports({
|
|
136
|
+
(await this.resolveLessImports({
|
|
136
137
|
filePath: resolvedFilePath,
|
|
137
138
|
fileContent: importedFileContent
|
|
138
|
-
}) +
|
|
139
|
+
})) +
|
|
139
140
|
`\n/* END "${originalFilePath}" */\n`;
|
|
140
141
|
}
|
|
141
142
|
findLessImports(fileContent) {
|
|
@@ -153,6 +154,11 @@ class LibraryLessGenerator {
|
|
|
153
154
|
}
|
|
154
155
|
}
|
|
155
156
|
|
|
157
|
+
/**
|
|
158
|
+
* @public
|
|
159
|
+
* @module @ui5/builder/processors/libraryLessGenerator
|
|
160
|
+
*/
|
|
161
|
+
|
|
156
162
|
/**
|
|
157
163
|
* Creates a "library.less" file for the SAP Theme Designer based on a "library.source.less" file.
|
|
158
164
|
*
|
|
@@ -165,15 +171,17 @@ class LibraryLessGenerator {
|
|
|
165
171
|
* </ul>
|
|
166
172
|
*
|
|
167
173
|
* @public
|
|
168
|
-
* @
|
|
174
|
+
* @function default
|
|
175
|
+
* @static
|
|
176
|
+
*
|
|
169
177
|
* @param {object} parameters Parameters
|
|
170
|
-
* @param {
|
|
178
|
+
* @param {@ui5/fs/Resource[]} parameters.resources List of <code>library.source.less</code>
|
|
171
179
|
* resources
|
|
172
|
-
* @param {fs|module:@ui5/fs
|
|
173
|
-
* [fs interface]{@link module:resources/module:@ui5/fs
|
|
174
|
-
* @returns {Promise
|
|
180
|
+
* @param {fs|module:@ui5/fs/fsInterface} parameters.fs Node fs or custom
|
|
181
|
+
* [fs interface]{@link module:resources/module:@ui5/fs/fsInterface}
|
|
182
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with library.less resources
|
|
175
183
|
*/
|
|
176
|
-
|
|
184
|
+
async function createLibraryLess({resources, fs}) {
|
|
177
185
|
const generator = new LibraryLessGenerator({fs});
|
|
178
186
|
return Promise.all(resources.map(async (librarySourceLessResource) => {
|
|
179
187
|
const filePath = librarySourceLessResource.getPath();
|
|
@@ -189,10 +197,14 @@ module.exports = async function({resources, fs}) {
|
|
|
189
197
|
string: libraryLessFileContent
|
|
190
198
|
});
|
|
191
199
|
}));
|
|
192
|
-
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export default createLibraryLess;
|
|
193
203
|
|
|
204
|
+
let myLibraryLessGenerator;
|
|
194
205
|
// Export class for testing only
|
|
195
206
|
/* istanbul ignore else */
|
|
196
207
|
if (process.env.NODE_ENV === "test") {
|
|
197
|
-
|
|
208
|
+
myLibraryLessGenerator = LibraryLessGenerator;
|
|
198
209
|
}
|
|
210
|
+
export const _LibraryLessGenerator = myLibraryLessGenerator;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
2
|
+
import posixPath from "node:path/posix";
|
|
3
|
+
import semver from "semver";
|
|
4
|
+
const {SemVer: Version} = semver;
|
|
5
|
+
import logger from "@ui5/logger";
|
|
6
|
+
const log = logger.getLogger("builder:processors:manifestCreator");
|
|
7
|
+
import Resource from "@ui5/fs/Resource";
|
|
8
|
+
import xml2js from "xml2js";
|
|
9
|
+
import analyzeLibraryJS from "../lbt/analyzer/analyzeLibraryJS.js";
|
|
9
10
|
|
|
10
11
|
/*
|
|
11
12
|
* A single parse instance to be used by all invocations (TODO check reentrance capa of xml2js)
|
|
@@ -128,7 +129,7 @@ class LibraryBundle {
|
|
|
128
129
|
/**
|
|
129
130
|
*
|
|
130
131
|
* @param {string} prefix
|
|
131
|
-
* @param {
|
|
132
|
+
* @param {@ui5/fs/Resource[]} resources
|
|
132
133
|
*/
|
|
133
134
|
constructor(prefix, resources) {
|
|
134
135
|
this.prefix = prefix;
|
|
@@ -138,7 +139,7 @@ class LibraryBundle {
|
|
|
138
139
|
/**
|
|
139
140
|
*
|
|
140
141
|
* @param {string} name
|
|
141
|
-
* @returns {
|
|
142
|
+
* @returns {@ui5/fs/Resource}
|
|
142
143
|
*/
|
|
143
144
|
findResource(name) {
|
|
144
145
|
return this.resources.find((res) => res.getPath() === this.prefix + name);
|
|
@@ -147,7 +148,7 @@ class LibraryBundle {
|
|
|
147
148
|
/**
|
|
148
149
|
*
|
|
149
150
|
* @param {RegExp} pattern
|
|
150
|
-
* @returns {
|
|
151
|
+
* @returns {@ui5/fs/Resource[]}
|
|
151
152
|
*/
|
|
152
153
|
getResources(pattern) {
|
|
153
154
|
return this.resources.filter((res) => pattern == null || pattern.test(res.getPath()));
|
|
@@ -620,7 +621,7 @@ async function createManifest(
|
|
|
620
621
|
};
|
|
621
622
|
}
|
|
622
623
|
|
|
623
|
-
|
|
624
|
+
export default function({libraryResource, resources, getProjectVersion, options}) {
|
|
624
625
|
// merge options with defaults
|
|
625
626
|
options = Object.assign({
|
|
626
627
|
descriptorVersion: APP_DESCRIPTOR_V22, // TODO 3.0: change this to type string instead of a semver object
|
|
@@ -642,9 +643,9 @@ module.exports = function({libraryResource, resources, getProjectVersion, option
|
|
|
642
643
|
return createManifest(libraryResource, libBundle, options.descriptorVersion, options.include3rdParty,
|
|
643
644
|
options.omitMinVersions, getProjectVersion)
|
|
644
645
|
.then((manifest) => {
|
|
645
|
-
return new
|
|
646
|
+
return new Resource({
|
|
646
647
|
path: resourcePathPrefix + "manifest.json",
|
|
647
648
|
string: JSON.stringify(manifest, null, options.prettyPrint ? " " : undefined)
|
|
648
649
|
});
|
|
649
650
|
});
|
|
650
|
-
}
|
|
651
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import posixPath from "node:path/posix";
|
|
2
|
+
import {minify} from "terser";
|
|
3
|
+
import Resource from "@ui5/fs/Resource";
|
|
4
|
+
|
|
4
5
|
/**
|
|
5
6
|
* Preserve comments which contain:
|
|
6
7
|
* <ul>
|
|
@@ -15,38 +16,43 @@ const Resource = require("@ui5/fs").Resource;
|
|
|
15
16
|
const copyrightCommentsAndBundleCommentPattern = /copyright|\(c\)(?:[0-9]+|\s+[0-9A-za-z])|released under|license|\u00a9|^@ui5-bundle-raw-include |^@ui5-bundle /i;
|
|
16
17
|
const debugFileRegex = /((?:\.view|\.fragment|\.controller|\.designtime|\.support)?\.js)$/;
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* @public
|
|
21
|
+
* @module @ui5/builder/processors/minifier
|
|
22
|
+
*/
|
|
18
23
|
|
|
19
24
|
/**
|
|
20
25
|
* Result set
|
|
21
26
|
*
|
|
22
27
|
* @public
|
|
23
28
|
* @typedef {object} MinifierResult
|
|
24
|
-
* @property {
|
|
25
|
-
* @property {
|
|
26
|
-
* @property {
|
|
27
|
-
* @memberof module:@ui5/builder.processors
|
|
29
|
+
* @property {@ui5/fs/Resource} resource Minified resource
|
|
30
|
+
* @property {@ui5/fs/Resource} dbgResource Debug (non-minified) variant
|
|
31
|
+
* @property {@ui5/fs/Resource} sourceMap Source Map
|
|
28
32
|
*/
|
|
29
33
|
|
|
30
34
|
/**
|
|
31
35
|
* Minifies the supplied resources.
|
|
32
36
|
*
|
|
33
37
|
* @public
|
|
34
|
-
* @
|
|
38
|
+
* @function default
|
|
39
|
+
* @static
|
|
40
|
+
*
|
|
35
41
|
* @param {object} parameters Parameters
|
|
36
|
-
* @param {
|
|
42
|
+
* @param {@ui5/fs/Resource[]} parameters.resources List of resources to be processed
|
|
37
43
|
* @param {object} [parameters.options] Options
|
|
38
44
|
* @param {boolean} [parameters.options.addSourceMappingUrl=true]
|
|
39
45
|
* Whether to add a sourceMappingURL reference to the end of the minified resource
|
|
40
|
-
* @returns {Promise<module:@ui5/builder
|
|
46
|
+
* @returns {Promise<module:@ui5/builder/processors/minifier~MinifierResult[]>}
|
|
41
47
|
* Promise resolving with object of resource, dbgResource and sourceMap
|
|
42
48
|
*/
|
|
43
|
-
|
|
49
|
+
export default async function({resources, options: {addSourceMappingUrl = true} = {}}) {
|
|
44
50
|
return Promise.all(resources.map(async (resource) => {
|
|
45
51
|
const dbgPath = resource.getPath().replace(debugFileRegex, "-dbg$1");
|
|
46
52
|
const dbgResource = await resource.clone();
|
|
47
53
|
dbgResource.setPath(dbgPath);
|
|
48
54
|
|
|
49
|
-
const filename =
|
|
55
|
+
const filename = posixPath.basename(resource.getPath());
|
|
50
56
|
const code = await resource.getString();
|
|
51
57
|
try {
|
|
52
58
|
const sourceMapOptions = {
|
|
@@ -55,8 +61,8 @@ module.exports = async function({resources, options: {addSourceMappingUrl = true
|
|
|
55
61
|
if (addSourceMappingUrl) {
|
|
56
62
|
sourceMapOptions.url = filename + ".map";
|
|
57
63
|
}
|
|
58
|
-
const dbgFilename =
|
|
59
|
-
const result = await
|
|
64
|
+
const dbgFilename = posixPath.basename(dbgPath);
|
|
65
|
+
const result = await minify({
|
|
60
66
|
// Use debug-name since this will be referenced in the source map "sources"
|
|
61
67
|
[dbgFilename]: code
|
|
62
68
|
}, {
|
|
@@ -87,4 +93,4 @@ module.exports = async function({resources, options: {addSourceMappingUrl = true
|
|
|
87
93
|
`(line ${err.line}, col ${err.col}, pos ${err.pos})`);
|
|
88
94
|
}
|
|
89
95
|
}));
|
|
90
|
-
}
|
|
96
|
+
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import escapeUnicode from "escape-unicode";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @module @ui5/builder/processors/nonAsciiEscaper
|
|
6
|
+
*/
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* @see https://en.wikipedia.org/wiki/ASCII
|
|
@@ -58,14 +63,16 @@ const escapeNonAscii = function(string) {
|
|
|
58
63
|
*
|
|
59
64
|
*
|
|
60
65
|
* @public
|
|
61
|
-
* @
|
|
66
|
+
* @function default
|
|
67
|
+
* @static
|
|
68
|
+
*
|
|
62
69
|
* @param {object} parameters Parameters
|
|
63
|
-
* @param {
|
|
70
|
+
* @param {@ui5/fs/Resource[]} parameters.resources List of resources to be processed
|
|
64
71
|
* @param {object} [parameters.options] Options
|
|
65
72
|
* @param {string} [parameters.options.encoding="utf8"] resource file encoding
|
|
66
73
|
* ({@link https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings Node.js character encodings}).
|
|
67
74
|
* Use #getEncodingFromAlias to get the encoding string
|
|
68
|
-
* @returns {Promise
|
|
75
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with the processed resources
|
|
69
76
|
*/
|
|
70
77
|
async function nonAsciiEscaper({resources, options: {encoding}}) {
|
|
71
78
|
encoding = encoding || "utf8";
|
|
@@ -94,7 +101,10 @@ const encodingMap = {
|
|
|
94
101
|
* such that it can be used standalone without the respective task (e.g. in Splitter, Bundler and related projects).
|
|
95
102
|
*
|
|
96
103
|
* @public
|
|
97
|
-
* @
|
|
104
|
+
* @function getEncodingFromAlias
|
|
105
|
+
* @alias @ui5/builder/processors/nonAsciiEscaper․getEncodingFromAlias
|
|
106
|
+
* @static
|
|
107
|
+
*
|
|
98
108
|
* @param {string} encoding encoding labels: "UTF-8" and "ISO-8859-1"
|
|
99
109
|
* @returns {string} node.js character encoding string, e.g. utf8 and latin1
|
|
100
110
|
*/
|
|
@@ -106,4 +116,4 @@ nonAsciiEscaper.getEncodingFromAlias = function(encoding) {
|
|
|
106
116
|
return encodingMap[encoding];
|
|
107
117
|
};
|
|
108
118
|
|
|
109
|
-
|
|
119
|
+
export default nonAsciiEscaper;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import logger from "@ui5/logger";
|
|
3
|
+
const log = logger.getLogger("builder:processors:resourceListCreator");
|
|
4
|
+
import ResourceCollector from "../lbt/resources/ResourceCollector.js";
|
|
5
|
+
import LocatorResourcePool from "../lbt/resources/LocatorResourcePool.js";
|
|
6
|
+
import ResourceInfo from "../lbt/resources/ResourceInfo.js";
|
|
7
|
+
import Resource from "@ui5/fs/Resource";
|
|
7
8
|
|
|
8
|
-
const EvoResource = require("@ui5/fs").Resource;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* List of resource patterns that describe all debug resources.
|
|
@@ -115,12 +115,12 @@ function makeResourcesJSON(list, prefix) {
|
|
|
115
115
|
*
|
|
116
116
|
* @private
|
|
117
117
|
* @param {object} parameters Parameters
|
|
118
|
-
* @param {
|
|
119
|
-
* @param {
|
|
118
|
+
* @param {@ui5/fs/Resource[]} parameters.resources List of resources
|
|
119
|
+
* @param {@ui5/fs/Resource[]} [parameters.dependencyResources=[]] List of dependency resources
|
|
120
120
|
* @param {object} [parameters.options] Options
|
|
121
|
-
* @returns {Promise
|
|
121
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with the resources.json resources
|
|
122
122
|
*/
|
|
123
|
-
|
|
123
|
+
export default async function({resources, dependencyResources = [], options}) {
|
|
124
124
|
options = Object.assign({
|
|
125
125
|
failOnOrphans: false,
|
|
126
126
|
externalResources: undefined,
|
|
@@ -163,7 +163,7 @@ module.exports = async function({resources, dependencyResources = [], options})
|
|
|
163
163
|
|
|
164
164
|
const contentString = makeResourcesJSON(list, prefix);
|
|
165
165
|
|
|
166
|
-
resourceLists.push(new
|
|
166
|
+
resourceLists.push(new Resource({
|
|
167
167
|
path: `/resources/${prefix}resources.json`,
|
|
168
168
|
string: contentString
|
|
169
169
|
}));
|
|
@@ -173,7 +173,7 @@ module.exports = async function({resources, dependencyResources = [], options})
|
|
|
173
173
|
|
|
174
174
|
const contentString = makeResourcesJSON(list, prefix);
|
|
175
175
|
|
|
176
|
-
resourceLists.push(new
|
|
176
|
+
resourceLists.push(new Resource({
|
|
177
177
|
path: `/resources/${prefix}resources.json`,
|
|
178
178
|
string: contentString
|
|
179
179
|
}));
|
|
@@ -187,4 +187,4 @@ module.exports = async function({resources, dependencyResources = [], options})
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
return resourceLists;
|
|
190
|
-
}
|
|
190
|
+
}
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import replaceStream from "replacestream";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @module @ui5/builder/processors/stringReplacer
|
|
6
|
+
*/
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* Replaces placeholders with corresponding values.
|
|
5
10
|
*
|
|
6
11
|
* @public
|
|
7
|
-
* @
|
|
12
|
+
* @function default
|
|
13
|
+
* @static
|
|
14
|
+
*
|
|
8
15
|
* @param {object} parameters Parameters
|
|
9
|
-
* @param {
|
|
16
|
+
* @param {@ui5/fs/Resource[]} parameters.resources List of resources to be processed
|
|
10
17
|
* @param {object} parameters.options Options
|
|
11
18
|
* @param {string} parameters.options.pattern Pattern of placeholders
|
|
12
19
|
* @param {string} parameters.options.replacement Replacement for placeholders
|
|
13
|
-
* @returns {Promise
|
|
20
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with modified resources
|
|
14
21
|
*/
|
|
15
|
-
|
|
22
|
+
export default function({resources, options: {pattern, replacement}}) {
|
|
16
23
|
return Promise.all(resources.map((resource) => {
|
|
17
24
|
let stream = resource.getStream();
|
|
18
25
|
stream.setEncoding("utf8");
|
|
@@ -21,4 +28,4 @@ module.exports = function({resources, options: {pattern, replacement}}) {
|
|
|
21
28
|
resource.setStream(stream);
|
|
22
29
|
return resource;
|
|
23
30
|
}));
|
|
24
|
-
}
|
|
31
|
+
}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import logger from "@ui5/logger";
|
|
2
|
+
const log = logger.getLogger("builder:processors:themeBuilder");
|
|
3
|
+
import posixPath from "node:path/posix";
|
|
4
|
+
import less from "less-openui5";
|
|
5
|
+
import Resource from "@ui5/fs/Resource";
|
|
5
6
|
|
|
6
7
|
const libraryMatchPattern = /^\/resources\/(.*)\/themes\/[^/]*\/library\.source\.less$/i;
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @public
|
|
11
|
+
* @module @ui5/builder/processors/ThemeBuilder
|
|
12
|
+
*/
|
|
13
|
+
|
|
8
14
|
/**
|
|
9
15
|
* Builds a library theme
|
|
10
16
|
*
|
|
11
17
|
* @public
|
|
12
|
-
* @
|
|
18
|
+
* @class
|
|
13
19
|
*/
|
|
14
|
-
class ThemeBuilder {
|
|
20
|
+
export class ThemeBuilder {
|
|
15
21
|
/**
|
|
16
22
|
* Constructor
|
|
17
23
|
*
|
|
18
24
|
* @public
|
|
19
|
-
* @param {fs|module:@ui5/fs
|
|
20
|
-
* [fs interface]{@link module
|
|
25
|
+
* @param {fs|module:@ui5/fs/fsInterface} fs Node fs or custom
|
|
26
|
+
* [fs interface]{@link module:@ui5/fs/fsInterface}
|
|
21
27
|
*/
|
|
22
28
|
constructor({fs}) {
|
|
23
29
|
this.builder = new less.Builder({fs});
|
|
@@ -27,13 +33,13 @@ class ThemeBuilder {
|
|
|
27
33
|
* Starts the theme build
|
|
28
34
|
*
|
|
29
35
|
* @public
|
|
30
|
-
* @param {
|
|
36
|
+
* @param {@ui5/fs/Resource[]} resources Library files
|
|
31
37
|
* @param {object} [options] Build options
|
|
32
38
|
* @param {boolean} [options.compress=false] Compress build output (CSS / JSON)
|
|
33
39
|
* @param {boolean} [options.cssVariables=false] Generates the CSS variables
|
|
34
40
|
* (css-variables.css, css-variables.source.less) and the skeleton for a theme
|
|
35
41
|
* (library-skeleton.css, [library-skeleton-RTL.css])
|
|
36
|
-
* @returns {Promise
|
|
42
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Resolving with array of created files
|
|
37
43
|
*/
|
|
38
44
|
build(resources, {compress = false, cssVariables = false} = {}) {
|
|
39
45
|
const files = [];
|
|
@@ -57,7 +63,7 @@ class ThemeBuilder {
|
|
|
57
63
|
},
|
|
58
64
|
cssVariables
|
|
59
65
|
}).then((result) => {
|
|
60
|
-
const themeDir =
|
|
66
|
+
const themeDir = posixPath.dirname(resource.getPath());
|
|
61
67
|
|
|
62
68
|
const libCss = new Resource({
|
|
63
69
|
path: themeDir + "/library.css",
|
|
@@ -132,21 +138,25 @@ class ThemeBuilder {
|
|
|
132
138
|
* Builds a library theme.
|
|
133
139
|
*
|
|
134
140
|
* @public
|
|
135
|
-
* @
|
|
141
|
+
* @function default
|
|
142
|
+
* @static
|
|
143
|
+
*
|
|
144
|
+
* @alias @ui5/builder/processors/themeBuilder
|
|
136
145
|
* @param {object} parameters Parameters
|
|
137
|
-
* @param {
|
|
146
|
+
* @param {@ui5/fs/Resource[]} parameters.resources List of <code>library.source.less</code>
|
|
138
147
|
* resources to be processed
|
|
139
|
-
* @param {fs|module:@ui5/fs
|
|
140
|
-
* [fs interface]{@link module
|
|
141
|
-
* @param {ThemeBuilderOptions} [parameters.options] Options
|
|
142
|
-
* @returns {Promise
|
|
148
|
+
* @param {fs|module:@ui5/fs/fsInterface} parameters.fs Node fs or custom
|
|
149
|
+
* [fs interface]{@link module:@ui5/fs/fsInterface}
|
|
150
|
+
* @param {module:@ui5/builder/processors/ThemeBuilder~ThemeBuilderOptions} [parameters.options] Options
|
|
151
|
+
* @returns {Promise<@ui5/fs/Resource[]>} Promise resolving with theme resources
|
|
143
152
|
*/
|
|
144
|
-
|
|
153
|
+
export default async function({
|
|
145
154
|
resources,
|
|
146
155
|
fs,
|
|
147
156
|
options = {}
|
|
148
157
|
}) {
|
|
149
|
-
const {compress, cssVariables} =
|
|
158
|
+
const {compress, cssVariables} =
|
|
159
|
+
/** @type {module:@ui5/builder/processors/ThemeBuilder~ThemeBuilderOptions} */ (options);
|
|
150
160
|
const themeBuilder = new ThemeBuilder({fs});
|
|
151
161
|
return themeBuilder.build(resources, {
|
|
152
162
|
compress,
|
|
@@ -155,6 +165,4 @@ module.exports = async function({
|
|
|
155
165
|
themeBuilder.clearCache();
|
|
156
166
|
return files;
|
|
157
167
|
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
module.exports.ThemeBuilder = ThemeBuilder;
|
|
168
|
+
}
|