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

[FEATURE] Builder: Add excludes option #254

Merged
merged 9 commits into from
Jun 3, 2019
13 changes: 11 additions & 2 deletions lib/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,17 @@ module.exports = {

const projectType = typeRepository.getType(project.type);
const resourceCollections = resourceFactory.createCollectionsForTree(project, {
useNamespaces: true,
virtualReaders: projectWriters
virtualReaders: projectWriters,
getVirtualBasePathPrefix: function({project, virBasePath}) {
if (project.type === "application" && project.metadata.namespace) {
return "/resources/" + project.metadata.namespace;
}
},
getProjectExcludes: function(project) {
if (project.builder && project.builder.resources) {
return project.builder.resources.excludes;
}
}
});

const writer = new MemAdapter({
Expand Down
170 changes: 153 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"escope": "^3.6.0",
"esprima": "^4.0.1",
"estraverse": "^4.2.0",
"globby": "^7.1.1",
"globby": "^9.2.0",
"graceful-fs": "^4.1.15",
"jsdoc": "3.5.5",
"less-openui5": "^0.6.0",
Expand Down
14 changes: 14 additions & 0 deletions test/expected/build/application.g/excludes/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"_version": "1.1.0",
"sap.app": {
"_version": "1.1.0",
"id": "application.g",
"type": "application",
"applicationVersion": {
"version": "${version}"
},
"embeds": ["embedded"],
"title": "{{title}}"
},
"customCopyrightString": "${copyright}"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"_version": "1.1.0",
"sap.app": {
"_version": "1.1.0",
"id": "application.g.subcomponentA",
"type": "application",
"applicationVersion": {
"version": "1.2.2"
},
"embeds": ["embedded"],
"title": "{{title}}"
}
}
65 changes: 60 additions & 5 deletions test/lib/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,36 @@ test("Build application.g with component preload paths", (t) => {
});
});

test("Build application.g with excludes", (t) => {
const destPath = "./test/tmp/build/application.g/excludes";
const expectedPath = path.join("test", "expected", "build", "application.g", "excludes");

return builder.build({
tree: applicationGTreeWithExcludes,
destPath,
includeTasks: ["createDebugFiles"],
excludedTasks: ["*"]
}).then(() => {
return findFiles(expectedPath);
}).then((expectedFiles) => {
// Check for all directories and files
assert.directoryDeepEqual(destPath, expectedPath);
// Check for all file contents
return checkFileContentsIgnoreLineFeeds(expectedFiles, expectedPath, destPath);
}).then(() => {
t.pass();
});
});

test("Build application.h", (t) => {
const destPath = "./test/tmp/build/application.h/dest";
const expectedPath = path.join("test", "expected", "build", "application.h", "dest");

return builder.build({
tree: applicationHTree,
destPath,
excludedTasks: ["createDebugFiles", "generateComponentPreload", "generateStandaloneAppBundle", "generateVersionInfo"]
excludedTasks: ["createDebugFiles", "generateComponentPreload",
"generateStandaloneAppBundle", "generateVersionInfo"]
}).then(() => {
return findFiles(expectedPath);
}).then((expectedFiles) => {
Expand Down Expand Up @@ -572,6 +594,41 @@ const applicationGTree = {
}
};

const applicationGTreeWithExcludes = {
"id": "application.g",
"version": "1.0.0",
"path": applicationGPath,
"_level": 0,
"specVersion": "0.1",
"type": "application",
"metadata": {
"name": "application.g",
"namespace": "application/g",
"copyright": "Some fancy copyright"
},
"dependencies": [],
"resources": {
"configuration": {
"paths": {
"webapp": "webapp"
}
},
"pathMappings": {
"/": "webapp"
}
},
"builder": {
"resources": {
"excludes": [
"/subcomponentA/**",
"!**/manifest.json",
RandomByte marked this conversation as resolved.
Show resolved Hide resolved
"/subcomponentB/**",
"/Component.js",
]
}
}
};

const applicationGTreeComponentPreloadPaths = {
"id": "application.g",
"version": "1.0.0",
Expand Down Expand Up @@ -918,8 +975,7 @@ const libraryITree = {
}
},
"pathMappings": {
"/resources/": "main/src",
"/test-resources/": "main/test"
"/resources/": "main/src"
}
}
};
Expand Down Expand Up @@ -968,8 +1024,7 @@ const themeJTree = {
}
},
"pathMappings": {
"/resources/": "main/src",
"/test-resources/": "main/test"
"/resources/": "main/src"
}
}
};
Loading