Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] LibraryFormatter: Do not throw for missing .library in legacy OpenUI5 theme libraries #593

Merged
merged 1 commit into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/types/application/ApplicationFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class ApplicationFormatter extends AbstractUi5Formatter {
}
const namespace = appId.replace(/\./g, "/");
log.verbose(
`Namespace of project ${this._project.metadata.name} is ${namespace} (from manifest.appdescr_variant)`);
`Namespace of project ${this._project.metadata.name} is ${namespace} (from manifest.json)`);
return namespace;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/types/library/LibraryFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class LibraryFormatter extends AbstractUi5Formatter {
log.verbose(err.message);
}

if (isFrameworkProject(project)) {
if (isFrameworkProject(project) && !SAP_THEMES_NS_EXEMPTIONS.includes(this._project.metadata.name)) {
if (project.builder && project.builder.libraryPreload && project.builder.libraryPreload.excludes) {
log.verbose(
`Using preload excludes for framework library ${project.metadata.name} from project configuration`);
Expand Down
34 changes: 34 additions & 0 deletions test/lib/types/library/LibraryFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,31 @@ const libraryETree = {
}
};

const legacyThemeLibPath = path.join(__dirname, "..", "..", "..", "fixtures", "theme.library.e");
const legacyThemeLibTree = {
id: "@openui5/themelib_sap_bluecrystal",
version: "1.0.0",
path: legacyThemeLibPath,
dependencies: [],
_level: 0,
_isRoot: true,
specVersion: "2.0",
type: "library",
metadata: {
name: "themelib_sap_bluecrystal",
copyright: "UI development toolkit for HTML5 (OpenUI5)\n * (c) Copyright 2009-xxx SAP SE or an SAP affiliate " +
"company.\n * Licensed under the Apache License, Version 2.0 - see LICENSE.txt."
},
resources: {
configuration: {
paths: {
src: "src",
test: "test"
}
}
}
};

function clone(o) {
return JSON.parse(JSON.stringify(o));
}
Expand Down Expand Up @@ -396,6 +421,15 @@ test.serial("format: namespace resolution fails", async (t) => {
mock.stop("@ui5/logger");
});

test("format: legacy OpenUI5 theme library", async (t) => {
const myProject = clone(legacyThemeLibTree);
const libraryFormatter = new LibraryFormatter({project: myProject});
sinon.stub(libraryFormatter, "validate").resolves();

await t.notThrowsAsync(libraryFormatter.format(), "Does not throw for missing .library");
t.deepEqual(myProject.metadata.copyright, legacyThemeLibTree.metadata.copyright, "Copyright was not altered");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably a leftover from another test, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well yes but I still found it to be valid

});

test("format: configuration test path", async (t) => {
const myProject = clone(libraryETree);
const libraryFormatter = new LibraryFormatter({project: myProject});
Expand Down