Skip to content

Commit

Permalink
[INTERNAL] Adapt to new Specification#getSpecVersion implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Nov 28, 2022
1 parent 798fc1d commit 99ae94e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/lbt/utils/escapePropertiesFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async function(resource) {
let propertiesFileSourceEncoding = project && project.getPropertiesFileSourceEncoding();

if (!propertiesFileSourceEncoding) {
if (project && ["0.1", "1.0", "1.1"].includes(project.getSpecVersion())) {
if (project && project.getSpecVersion().lte("1.1")) {
// default encoding to "ISO-8859-1" for old specVersions
propertiesFileSourceEncoding = "ISO-8859-1";
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/bundlers/generateLibraryPreload.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export default async function({workspace, taskUtil, options: {skipBundles = [],
// This is mainly to have an easier check without version parsing or using semver.
// If no project/specVersion is available, the bundles should also be created to not break potential
// existing use cases without a properly formed/formatted project tree.
if (!taskUtil || ["0.1", "1.1", "2.0"].includes(taskUtil.getProject().getSpecVersion())) {
if (!taskUtil || taskUtil.getProject().getSpecVersion().lte("2.0")) {
const isEvo = resources.find((resource) => {
return resource.getPath() === "/resources/ui5loader.js";
});
Expand Down
28 changes: 24 additions & 4 deletions test/lib/lbt/utils/escapePropertiesFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ test.serial("propertiesFileSourceEncoding not set - specVersion 0.1", async (t)
const lbtResource = {
getProject: () => {
return {
getSpecVersion: () => "0.1",
getSpecVersion: () => {
return {
toString: () => "0.1",
lte: () => true,
};
},
getPropertiesFileSourceEncoding: () => ""
};
},
Expand All @@ -126,7 +131,12 @@ test.serial("propertiesFileSourceEncoding not set - specVersion 1.0", async (t)
const lbtResource = {
getProject: () => {
return {
getSpecVersion: () => "1.0",
getSpecVersion: () => {
return {
toString: () => "1.0",
lte: () => true,
};
},
getPropertiesFileSourceEncoding: () => ""
};
},
Expand All @@ -153,7 +163,12 @@ test.serial("propertiesFileSourceEncoding not set - specVersion 1.1", async (t)
const lbtResource = {
getProject: () => {
return {
getSpecVersion: () => "1.1",
getSpecVersion: () => {
return {
toString: () => "1.1",
lte: () => true,
};
},
getPropertiesFileSourceEncoding: () => ""
};
},
Expand All @@ -180,7 +195,12 @@ test.serial("propertiesFileSourceEncoding not set - specVersion 2.0", async (t)
const lbtResource = {
getProject: () => {
return {
getSpecVersion: () => "2.0",
getSpecVersion: () => {
return {
toString: () => "2.0",
lte: () => false,
};
},
getPropertiesFileSourceEncoding: () => ""
};
},
Expand Down
35 changes: 30 additions & 5 deletions test/lib/tasks/bundlers/generateLibraryPreload.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,12 @@ test.serial("generateLibraryPreload for sap.ui.core (/w ui5loader.js)", async (t
]);

const coreProject = {
getSpecVersion: () => "0.1"
getSpecVersion: () => {
return {
toString: () => "0.1",
lte: () => true,
};
}
};
const taskUtil = {
getTag: sinon.stub().returns(false),
Expand Down Expand Up @@ -756,7 +761,12 @@ test.serial("generateLibraryPreload for sap.ui.core with old specVersion defined
]);

const coreProject = {
getSpecVersion: () => "0.1"
getSpecVersion: () => {
return {
toString: () => "0.1",
lte: () => true,
};
}
};

const taskUtil = {
Expand Down Expand Up @@ -1089,7 +1099,12 @@ test.serial("generateLibraryPreload for sap.ui.core with own bundle configuratio

const coreProject = {
// A newer specVersion is the indicator that the hardcoded bundle config should be skipped
getSpecVersion: () => "2.4"
getSpecVersion: () => {
return {
toString: () => "2.4",
lte: () => false,
};
}
};
const taskUtil = {
getTag: sinon.stub().returns(false),
Expand Down Expand Up @@ -1253,7 +1268,12 @@ test.serial("generateLibraryPreload for sap.ui.core with own bundle configuratio

const coreProject = {
// A newer specVersion is the indicator that the hardcoded bundle config should be skipped
getSpecVersion: () => "2.6"
getSpecVersion: () => {
return {
toString: () => "2.6",
lte: () => false,
};
}
};
const taskUtil = {
getTag: sinon.stub().returns(false),
Expand Down Expand Up @@ -1417,7 +1437,12 @@ test.serial("Error: Failed to resolve non-debug name", async (t) => {
]);

const coreProject = {
getSpecVersion: () => "0.1"
getSpecVersion: () => {
return {
toString: () => "0.1",
lte: () => true,
};
}
};
const taskUtil = {
getTag: sinon.stub().returns(false),
Expand Down

0 comments on commit 99ae94e

Please sign in to comment.