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

[INTERNAL] Groundwork for extension projects #4

Closed
wants to merge 4 commits into from
Closed
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
427 changes: 337 additions & 90 deletions lib/projectPreprocessor.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions test/fixtures/legacy.library.a/node_modules/library.f/package.json

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

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

10 changes: 10 additions & 0 deletions test/fixtures/legacy.library.a/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "legacy.library.a",
"version": "1.0.0",
"description": "Simple SAPUI5 based library - legacy library missing ui5.yaml",
"devDependencies": {
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}
11 changes: 11 additions & 0 deletions test/fixtures/legacy.library.a/src/legacy/library/a/.library
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<library xmlns="http://www.sap.com/sap.ui.library.xsd" >

<name>legacy.library.a</name>
<vendor>SAP SE</vendor>
<copyright>${copyright}</copyright>
<version>${version}</version>

<documentation>Legacy Library A</documentation>

</library>
4 changes: 4 additions & 0 deletions test/fixtures/legacy.library.a/src/legacy/library/a/some.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*!
* ${copyright}
*/
console.log('HelloWorld');
Empty file.
144 changes: 144 additions & 0 deletions test/lib/extensions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
const {test} = require("ava");
const path = require("path");
const projectPreprocessor = require("../..").projectPreprocessor;
const applicationAPath = path.join(__dirname, "..", "fixtures", "application.a");
const legacyLibraryAPath = path.join(__dirname, "..", "fixtures", "legacy.library.a");

test("Projects with extension dependency inline configuration", (t) => {
const tree = {
id: "application.a",
path: applicationAPath,
dependencies: [{
id: "extension.a",
path: applicationAPath,
dependencies: [],
version: "1.0.0",
specVersion: "0.1",
kind: "extension",
type: "project-shim",
metadata: {
name: "shims.a"
},
configurations: {
"legacy.library.a": {
specVersion: "0.1",
type: "library",
metadata: {
name: "legacy.library.a",
}
}
}
}, {
id: "legacy.library.a",
version: "1.0.0",
path: legacyLibraryAPath,
dependencies: []
}],
version: "1.0.0",
specVersion: "0.1",
type: "application",
metadata: {
name: "xy"
}
};
return projectPreprocessor.processTree(tree).then((parsedTree) => {
t.deepEqual(parsedTree, {
_level: 0,
type: "application",
metadata: {
name: "xy",
},
resources: {
configuration: {
paths: {
webapp: "webapp"
}
},
pathMappings: {
"/": "webapp",
}
},
dependencies: [{
id: "legacy.library.a",
kind: "project",
version: "1.0.0",
specVersion: "0.1",
path: legacyLibraryAPath,
_level: 1,
type: "library",
metadata: {
name: "legacy.library.a",
copyright: "${copyright}",
},
resources: {
configuration: {
paths: {
src: "src",
test: "test"
}
},
pathMappings: {
"/resources/": "src",
"/test-resources/": "test"
}
},
dependencies: []
}],
id: "application.a",
kind: "project",
version: "1.0.0",
specVersion: "0.1",
path: applicationAPath
}, "Parsed correctly");
});
});

test("Projects with extension dependency inline configuration", (t) => {
const tree = {
id: "application.a",
path: applicationAPath,
dependencies: [{
id: "extension.a",
path: applicationAPath,
dependencies: [],
version: "1.0.0",
specVersion: "0.1",
kind: "extension",
type: "project-type",
metadata: {
name: "z"
}
}],
version: "1.0.0",
specVersion: "0.1",
type: "z",
metadata: {
name: "xy"
}
};
return t.throws(projectPreprocessor.processTree(tree).then((parsedTree) => {
t.deepEqual(parsedTree, {
_level: 0,
type: "z",
metadata: {
name: "xy",
},
resources: {
configuration: {
paths: {
root: ""
}
},
pathMappings: {
"/": "",
}
},
dependencies: [],
id: "application.a",
kind: "project",
version: "1.0.0",
specVersion: "0.1",
path: applicationAPath
}, "Parsed correctly");
}), "Unknown extension type 'project-type' for extension.a", "Rejected with error");
});
Loading