Skip to content

Commit

Permalink
version info exclude
Browse files Browse the repository at this point in the history
Excluded version info files since they are not
part of the resources.json
  • Loading branch information
tobiasso85 committed Aug 12, 2020
1 parent c588b7f commit edbf669
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
13 changes: 12 additions & 1 deletion lib/tasks/generateResourcesJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

const resourceListCreator = require("../processors/resourceListCreator");

const DEFAULT_EXCLUDES = [
/*
* exclude mac metadata files
*/
"!**/.DS_Store",
/*
* sap-ui-version.json is not part of the resources
*/
"!/resources/sap-ui-version.json"
];

function getCreatorOptions(projectName) {
const creatorOptions = {};
if ( projectName === "sap.ui.core" ) {
Expand Down Expand Up @@ -86,7 +97,7 @@ function getCreatorOptions(projectName) {
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
*/
module.exports = async function({workspace, options: {projectName}}) {
const resources = await workspace.byGlob(["/resources/**/*.*"]);
const resources = await workspace.byGlob(["/resources/**/*.*"].concat(DEFAULT_EXCLUDES));

const resourceLists = await resourceListCreator({
resources
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "application.j",
"version": "1.0.0",
"buildTimestamp": "202008120917",
"scmRevision": "",
"libraries": []
}
27 changes: 25 additions & 2 deletions test/lib/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const readFile = promisify(fs.readFile);
const assert = chai.assert;
const sinon = require("sinon");
const mock = require("mock-require");
const resourceFactory = require("@ui5/fs").resourceFactory;

const ui5Builder = require("../../../");
const builder = ui5Builder.builder;
Expand Down Expand Up @@ -478,17 +479,39 @@ test("Build application.j", (t) => {
});
});

test("Build application.j with resources.json", (t) => {
test("Build application.j with resources.json and version info", (t) => {
const destPath = "./test/tmp/build/application.j/dest-resources-json";
const expectedPath = path.join("test", "expected", "build", "application.j", "dest-resources-json");


const dummyVersionInfoGenerator = () => {
const versionJson = {
"name": "application.j",
"version": "1.0.0",
"buildTimestamp": "202008120917",
"scmRevision": "",
"libraries": []
};

return [resourceFactory.createResource({
path: "/resources/sap-ui-version.json",
string: JSON.stringify(versionJson, null, "\t")
})];
};

mock("../../../lib/processors/versionInfoGenerator", dummyVersionInfoGenerator);
mock.reRequire("../../../lib/tasks/generateVersionInfo");

const builder = mock.reRequire("../../../lib/builder/builder");


return builder.build({
includedTasks: [
"generateResourcesJson"
],
tree: applicationJTree,
destPath,
excludedTasks: ["createDebugFiles", "generateStandaloneAppBundle", "generateVersionInfo"]
excludedTasks: ["createDebugFiles", "generateStandaloneAppBundle"]
}).then(() => {
return findFiles(expectedPath);
}).then((expectedFiles) => {
Expand Down

0 comments on commit edbf669

Please sign in to comment.