Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions lib/graph/providers/NodePackageDependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class NodePackageDependencies {
}
return Promise.all(node._dependencies.map(async ({name, optional}) => {
const modulePath = await this._resolveModulePath(node.path, name, workspace);
return this._getNode(modulePath, optional);
return this._getNode(modulePath, optional, name);
}));
}

Expand Down Expand Up @@ -99,15 +99,15 @@ class NodePackageDependencies {
}
}

async _getNode(modulePath, optional) {
async _getNode(modulePath, optional, nameAlias) {
log.verbose(`Reading package.json in directory ${modulePath}...`);
const packageJson = await readPackage({
cwd: modulePath,
normalize: false
});

return {
id: packageJson.name,
id: nameAlias || packageJson.name,
version: packageJson.version,
path: modulePath,
optional,
Expand Down

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.

12 changes: 12 additions & 0 deletions test/fixtures/application.a.aliases/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "application.a.aliases",
"version": "1.0.0",
"description": "Simple SAPUI5 based application",
"main": "index.html",
"dependencies": {
"extension.a.esm.alias": "file:../extension.a.esm"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}
23 changes: 23 additions & 0 deletions test/fixtures/application.a.aliases/ui5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
specVersion: "3.0"
type: application
metadata:
name: application.a.aliases

--- # Everything below this line could also be put into the ui5.yaml of a standalone extension module
specVersion: "3.0"
kind: extension
type: project-shim
metadata:
name: my.application.thirdparty
shims:
configurations:
extension.a.esm.alias: # name as defined in package.json
specVersion: "3.0"
type: module # Use module type
metadata:
name: extension.a.esm.alias
resources:
configuration:
paths:
/resources/my/application/thirdparty/: "" # map root directory of lodash module
9 changes: 9 additions & 0 deletions test/fixtures/application.a.aliases/webapp/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>Application A</title>
</head>
<body>

</body>
</html>
13 changes: 13 additions & 0 deletions test/fixtures/application.a.aliases/webapp/manifest.json
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": "id1",
"type": "application",
"applicationVersion": {
"version": "1.2.2"
},
"embeds": ["embedded"],
"title": "{{title}}"
}
}
5 changes: 5 additions & 0 deletions test/fixtures/application.a.aliases/webapp/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function test(paramA) {
var variableA = paramA;
console.log(variableA);
}
test();
20 changes: 20 additions & 0 deletions test/lib/graph/providers/NodePackageDependencies.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import sinonGlobal from "sinon";
const __dirname = path.dirname(fileURLToPath(import.meta.url));

const applicationAPath = path.join(__dirname, "..", "..", "..", "fixtures", "application.a");
const applicationAAliasesPath = path.join(__dirname, "..", "..", "..", "fixtures", "application.a.aliases");
const applicationCPath = path.join(__dirname, "..", "..", "..", "fixtures", "application.c");
const applicationC2Path = path.join(__dirname, "..", "..", "..", "fixtures", "application.c2");
const applicationC3Path = path.join(__dirname, "..", "..", "..", "fixtures", "application.c3");
Expand Down Expand Up @@ -68,6 +69,25 @@ test("AppA: project with collection dependency", async (t) => {
]);
});

test("AppA: project with an alias dependency", async (t) => {
const workspace = {
getName: () => "workspace name",
getModuleByNodeId: t.context.sinon.stub().resolves(undefined).onFirstCall().resolves({
// This version of library.d has an additional dependency to library.f,
// which in turn has a dependency to library.g
Copy link
Member

Choose a reason for hiding this comment

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

I think this comment does not apply here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. Thanks!

getPath: () => path.join(applicationAAliasesPath, "node_modules", "extension.a.esm.alias"),
getVersion: () => "1.0.0",
})
};
const npmProvider = new NodePackageDependenciesProvider({
cwd: applicationAAliasesPath
});
await testGraphCreationDfs(t, npmProvider, [
"extension.a.esm.alias",
"application.a.aliases",
], workspace);
});

test("AppA: project with workspace overrides", async (t) => {
const workspace = {
getName: () => "workspace name",
Expand Down