Skip to content
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
3 changes: 2 additions & 1 deletion lib/projectPreprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class ProjectPreprocessor {
if (this.isConfigValid(project)) {
await this.applyType(project);
queue.push({
projects: project.dependencies,
// copy array, so that the queue is stable while ignored project dependencies are removed
projects: [...project.dependencies],
parent: project,
level: level + 1
});
Expand Down
145 changes: 145 additions & 0 deletions test/lib/projectPreprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const libraryBPath = path.join(__dirname, "..", "fixtures", "collection", "libra
// const libraryCPath = path.join(__dirname, "..", "fixtures", "collection", "library.c");
const libraryDPath = path.join(__dirname, "..", "fixtures", "library.d");
const cycleDepsBasePath = path.join(__dirname, "..", "fixtures", "cyclic-deps", "node_modules");
const pathToInvalidModule = path.join(__dirname, "..", "fixtures", "invalidModule");

test("Project with inline configuration", (t) => {
const tree = {
Expand Down Expand Up @@ -533,9 +534,153 @@ test("Project tree B with inline configs", (t) => {
});
});

test("Project with nested invalid dependencies", (t) => {
return projectPreprocessor.processTree(treeWithInvalidModules).then((parsedTree) => {
t.deepEqual(expectedTreeWithInvalidModules, parsedTree);
});
});

/* ========================= */
/* ======= Test data ======= */

/* === Invalid Modules */
const treeWithInvalidModules = {
id: "application.a",
path: applicationAPath,
dependencies: [
// A
{
id: "library.a",
path: libraryAPath,
dependencies: [
{
// C - invalid - should be missing in preprocessed tree
id: "module.c",
dependencies: [],
path: pathToInvalidModule,
version: "1.0.0"
},
{
// D - invalid - should be missing in preprocessed tree
id: "module.d",
dependencies: [],
path: pathToInvalidModule,
version: "1.0.0"
}
],
version: "1.0.0",
specVersion: "1.0",
type: "library",
metadata: {name: "library.a"}
},
// B
{
id: "library.b",
path: libraryBPath,
dependencies: [
{
// C - invalid - should be missing in preprocessed tree
id: "module.c",
dependencies: [],
path: pathToInvalidModule,
version: "1.0.0"
},
{
// D - invalid - should be missing in preprocessed tree
id: "module.d",
dependencies: [],
path: pathToInvalidModule,
version: "1.0.0"
}
],
version: "1.0.0",
specVersion: "1.0",
type: "library",
metadata: {name: "library.b"}
}
],
version: "1.0.0",
specVersion: "1.0",
type: "application",
metadata: {
name: "application.a"
}
};

const expectedTreeWithInvalidModules = {
"id": "application.a",
"path": applicationAPath,
"dependencies": [{
"id": "library.a",
"path": libraryAPath,
"dependencies": [],
"version": "1.0.0",
"specVersion": "1.0",
"type": "library",
"metadata": {
"name": "library.a",
"copyright": "Some fancy copyright ${currentYear}"
},
"kind": "project",
"_level": 1,
"resources": {
"configuration": {
"paths": {
"src": "src",
"test": "test"
}
},
"pathMappings": {
"/resources/": "src",
"/test-resources/": "test"
}
}
}, {
"id": "library.b",
"path": libraryBPath,
"dependencies": [],
"version": "1.0.0",
"specVersion": "1.0",
"type": "library",
"metadata": {
"name": "library.b",
"copyright": "Some fancy copyright ${currentYear}"
},
"kind": "project",
"_level": 1,
"resources": {
"configuration": {
"paths": {
"src": "src",
"test": "test"
}
},
"pathMappings": {
"/resources/": "src",
"/test-resources/": "test"
}
}
}],
"version": "1.0.0",
"specVersion": "1.0",
"type": "application",
"metadata": {
"name": "application.a"
},
"_level": 0,
"kind": "project",
"resources": {
"configuration": {
"paths": {
"webapp": "webapp"
}
},
"pathMappings": {
"/": "webapp"
}
}
};

/* === Tree A === */
const treeAWithInlineConfigs = {
id: "application.a",
Expand Down