Skip to content

Commit c4820dd

Browse files
committed
Fix tests I
1 parent 98d3d47 commit c4820dd

16 files changed

+350
-312
lines changed

lib/lbt/utils/escapePropertiesFile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ const nonAsciiEscaper = require("../../processors/nonAsciiEscaper");
44
* Can be used to escape *.properties files.
55
*
66
* Input encoding is read from project configuration.
7-
* In case the resource belongs to no project (e.g. bundler is used standalone) the default is "ISO-8859-1".
7+
* In case the resource belongs to no project (e.g. bundler is used standalone) the default is "UTF-8".
88
*
99
* @private
1010
* @param {Resource} resource the resource for which the content will be escaped
1111
* @returns {Promise<string>} resolves with the escaped string content of the given Resource
1212
*/
1313
module.exports = async function(resource) {
1414
const project = resource.getProject();
15-
let propertiesFileSourceEncoding = project.getPropertiesFileSourceEncoding();
15+
let propertiesFileSourceEncoding = project && project.getPropertiesFileSourceEncoding();
1616

1717
if (!propertiesFileSourceEncoding) {
1818
if (project && ["0.1", "1.0", "1.1"].includes(project.getSpecVersion())) {

lib/tasks/bundlers/generateLibraryPreload.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ function getSapUiCoreBunDef(name, filters, preload) {
223223
* @alias module:@ui5/builder.tasks.generateLibraryPreload
224224
* @param {object} parameters Parameters
225225
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
226-
* @param {module:@ui5/builder.tasks.TaskUtil|object} [parameters.taskUtil] TaskUtil
226+
* @param {module:@ui5/builder.tasks.TaskUtil} [parameters.taskUtil] TaskUtil
227227
* @param {object} parameters.options Options
228+
* @param {string} parameters.options.projectName Project name
228229
* @param {string[]} [parameters.options.skipBundles] Names of bundles that should not be created
229230
* @param {string[]} [parameters.options.excludes=[]] List of modules declared as glob patterns (resource name patterns)
230231
* that should be excluded from the library-preload.js bundle.
@@ -234,7 +235,7 @@ function getSapUiCoreBunDef(name, filters, preload) {
234235
* inclusion overrides an earlier exclusion, and vice versa.
235236
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
236237
*/
237-
module.exports = function({workspace, taskUtil, options: {skipBundles = [], excludes = []}}) {
238+
module.exports = function({workspace, taskUtil, options: {skipBundles = [], excludes = [], projectName}}) {
238239
let nonDbgWorkspace = workspace;
239240
if (taskUtil) {
240241
nonDbgWorkspace = workspace.filter(function(resource) {
@@ -255,17 +256,16 @@ module.exports = function({workspace, taskUtil, options: {skipBundles = [], excl
255256
// Find all libraries and create a library-preload.js bundle
256257

257258
let p = Promise.resolve();
258-
const project = taskUtil.getProject();
259259

260260
// Create core bundles for older versions (<1.97.0) which don't define bundle configuration in the ui5.yaml
261261
// See: https://github.com/SAP/openui5/commit/ff127fd2d009162ea43ad312dec99d759ebc23a0
262-
if (project.getName() === "sap.ui.core") {
262+
if (projectName === "sap.ui.core") {
263263
// Instead of checking the sap.ui.core library version, the specVersion is checked against all versions
264264
// that have been defined for sap.ui.core before the bundle configuration has been introduced.
265265
// This is mainly to have an easier check without version parsing or using semver.
266266
// If no project/specVersion is available, the bundles should also be created to not break potential
267267
// existing use cases without a properly formed/formatted project tree.
268-
if (["0.1", "1.1", "2.0"].includes(project.getSpecVersion())) {
268+
if (!taskUtil || ["0.1", "1.1", "2.0"].includes(taskUtil.getProject().getSpecVersion())) {
269269
const isEvo = resources.find((resource) => {
270270
return resource.getPath() === "/resources/ui5loader.js";
271271
});
@@ -343,15 +343,15 @@ module.exports = function({workspace, taskUtil, options: {skipBundles = [], excl
343343
} else {
344344
// Fallback to "library.js" as library indicator
345345
log.verbose(
346-
`Could not find a ".library" file for project ${project.getName()}, ` +
346+
`Could not find a ".library" file for project ${projectName}, ` +
347347
`falling back to "library.js".`);
348348
return workspace.byGlob("/resources/**/library.js");
349349
}
350350
}).then((libraryIndicatorResources) => {
351351
if (libraryIndicatorResources.length < 1) {
352352
// No library found - nothing to do
353353
log.verbose(
354-
`Could not find a ".library" or "library.js" file for project ${project.getName()}. ` +
354+
`Could not find a ".library" or "library.js" file for project ${projectName}. ` +
355355
`Skipping library preload bundling.`);
356356
return;
357357
}
@@ -427,7 +427,7 @@ module.exports = function({workspace, taskUtil, options: {skipBundles = [], excl
427427
} else {
428428
log.verbose(
429429
`Could not determine library namespace from file "${libraryIndicatorPath}" ` +
430-
`for project ${project.getName()}. Skipping library preload bundling.`);
430+
`for project ${projectName}. Skipping library preload bundling.`);
431431
return Promise.resolve();
432432
}
433433
}));

lib/tasks/bundlers/generateManifestBundle.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,24 @@ const DESCRIPTOR = "manifest.json";
44
const PROPERTIES_EXT = ".properties";
55
const BUNDLE_NAME = "manifest-bundle.zip";
66

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}] */
158
/**
169
* Task for manifestBundler.
1710
*
1811
* @public
1912
* @alias module:@ui5/builder.tasks.generateManifestBundle
2013
* @param {object} parameters Parameters
2114
* @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
2318
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
2419
*/
2520
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+
2725
if (!projectName || !namespace) {
2826
throw new Error("[generateManifestBundle]: One or more mandatory options not provided");
2927
}

lib/tasks/bundlers/generateStandaloneAppBundle.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function getBundleDefinition(config) {
5858
return bundleDefinition;
5959
}
6060

61+
/* eslint "jsdoc/check-param-names": ["error", {"disableExtraPropertyReporting":true}] */
6162
/**
6263
* Task for bundling standalone applications.
6364
*
@@ -69,10 +70,14 @@ function getBundleDefinition(config) {
6970
* @param {module:@ui5/builder.tasks.TaskUtil|object} [parameters.taskUtil] TaskUtil
7071
* @param {object} parameters.options Options
7172
* @param {string} parameters.options.projectName Project name
72-
* @param {string} [parameters.options.namespace] Project namespace
73+
* @param {string} [parameters.options.projectNamespace] Project namespace
7374
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
7475
*/
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+
7681
if (!namespace) {
7782
log.warn(`Namespace of project ${projectName} is not known. Self contained bundling is currently ` +
7883
`unable to generate complete bundles for such projects.`);

test/expected/build/application.b/standalone/resources/sap-ui-custom-dbg.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/expected/build/application.b/standalone/resources/sap-ui-custom.js

Lines changed: 2 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/expected/build/application.b/standalone/resources/sap-ui-custom.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/lib/builder/builder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ test.serial("Build library.ø", async (t) => {
871871
t.pass();
872872
});
873873

874-
test.serial("Build library.coreBuildtime (legacy-library): replaceBuildtime", async (t) => {
874+
test.serial("Build library.coreBuildtime: replaceBuildtime", async (t) => {
875875
const destPath = path.join("test", "tmp", "build", "sap.ui.core-buildtime", "dest");
876876
const expectedPath = path.join("test", "expected", "build", "sap.ui.core-buildtime", "dest");
877877

@@ -1833,7 +1833,7 @@ const libraryCoreBuildtimeTree = {
18331833
"dependencies": [],
18341834
"configuration": {
18351835
"specVersion": "2.6",
1836-
"type": "legacy-library",
1836+
"type": "library",
18371837
"metadata": {
18381838
"name": "library.coreBuildtime",
18391839
"copyright": "Some fancy copyright"

test/lib/lbt/bundle/AutoSplitter.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ function createMockPool(dependencies) {
2020
buffer: async () => Buffer.from(name.padStart(2048, "*")),
2121
getProject: () => {
2222
return {
23-
"resources": {
24-
"configuration": {
25-
"propertiesFileSourceEncoding": "ISO-8859-1"
26-
}
27-
}
23+
getPropertiesFileSourceEncoding: () => "ISO-8859-1"
2824
};
2925
},
3026
resource: {
@@ -211,11 +207,7 @@ test("_calcMinSize: properties resource", async (t) => {
211207
},
212208
getProject: () => {
213209
return {
214-
"resources": {
215-
"configuration": {
216-
"propertiesFileSourceEncoding": "ISO-8859-1"
217-
}
218-
}
210+
getPropertiesFileSourceEncoding: () => "ISO-8859-1"
219211
};
220212
}
221213
};

test/lib/lbt/utils/escapePropertiesFile.js

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ test.serial("propertiesFileSourceEncoding UTF-8", async (t) => {
2121
const lbtResource = {
2222
getProject: () => {
2323
return {
24-
resources: {
25-
configuration: {
26-
propertiesFileSourceEncoding: "UTF-8"
27-
}
28-
}
24+
getPropertiesFileSourceEncoding: () => "UTF-8"
2925
};
3026
},
3127
resource: "actual resource",
@@ -52,11 +48,7 @@ test.serial("propertiesFileSourceEncoding ISO-8859-1", async (t) => {
5248
const lbtResource = {
5349
getProject: () => {
5450
return {
55-
resources: {
56-
configuration: {
57-
propertiesFileSourceEncoding: "ISO-8859-1"
58-
}
59-
}
51+
getPropertiesFileSourceEncoding: () => "ISO-8859-1"
6052
};
6153
},
6254
resource: "actual resource",
@@ -81,12 +73,7 @@ test.serial("propertiesFileSourceEncoding ISO-8859-1", async (t) => {
8173
test.serial("propertiesFileSourceEncoding not set", async (t) => {
8274
const lbtResource = {
8375
getProject: () => {
84-
return {
85-
resources: {
86-
configuration: {
87-
}
88-
}
89-
};
76+
return undefined;
9077
},
9178
resource: "actual resource",
9279
buffer: async () => {
@@ -111,7 +98,8 @@ test.serial("propertiesFileSourceEncoding not set - specVersion 0.1", async (t)
11198
const lbtResource = {
11299
getProject: () => {
113100
return {
114-
specVersion: "0.1"
101+
getSpecVersion: () => "0.1",
102+
getPropertiesFileSourceEncoding: () => ""
115103
};
116104
},
117105
resource: "actual resource",
@@ -137,7 +125,8 @@ test.serial("propertiesFileSourceEncoding not set - specVersion 1.0", async (t)
137125
const lbtResource = {
138126
getProject: () => {
139127
return {
140-
specVersion: "1.0"
128+
getSpecVersion: () => "1.0",
129+
getPropertiesFileSourceEncoding: () => ""
141130
};
142131
},
143132
resource: "actual resource",
@@ -163,7 +152,8 @@ test.serial("propertiesFileSourceEncoding not set - specVersion 1.1", async (t)
163152
const lbtResource = {
164153
getProject: () => {
165154
return {
166-
specVersion: "1.1"
155+
getSpecVersion: () => "1.1",
156+
getPropertiesFileSourceEncoding: () => ""
167157
};
168158
},
169159
resource: "actual resource",
@@ -189,7 +179,8 @@ test.serial("propertiesFileSourceEncoding not set - specVersion 2.0", async (t)
189179
const lbtResource = {
190180
getProject: () => {
191181
return {
192-
specVersion: "2.0"
182+
getSpecVersion: () => "2.0",
183+
getPropertiesFileSourceEncoding: () => ""
193184
};
194185
},
195186
resource: "actual resource",

0 commit comments

Comments
 (0)