fix(misc): display nested apps properly in dep graph (#5022)
ISSUES CLOSED: #4906
This commit is contained in:
parent
71d9f86762
commit
80f3039176
@ -1 +1,3 @@
|
|||||||
{}
|
{
|
||||||
|
"presets": ["@nrwl/web/babel"]
|
||||||
|
}
|
||||||
|
|||||||
@ -1,10 +1,15 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'dep-graph-client',
|
name: 'dep-graph-client',
|
||||||
|
preset: '../../jest.preset.js',
|
||||||
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
||||||
globals: {
|
globals: {
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
tsConfig: '<rootDir>/tsconfig.spec.json',
|
tsConfig: '<rootDir>/tsconfig.spec.json',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
transform: {
|
||||||
|
'^.+\\.[tj]s$': 'ts-jest',
|
||||||
|
},
|
||||||
|
moduleFileExtensions: ['ts', 'js', 'html'],
|
||||||
coverageDirectory: '../../coverage/apps/dep-graph-client',
|
coverageDirectory: '../../coverage/apps/dep-graph-client',
|
||||||
};
|
};
|
||||||
|
|||||||
@ -0,0 +1,115 @@
|
|||||||
|
import { ProjectNode } from './project-node';
|
||||||
|
|
||||||
|
describe('ProjectNode', () => {
|
||||||
|
describe('app nodes', () => {
|
||||||
|
it('should not set parentId if groupByFolder is false', () => {
|
||||||
|
const projectNode = new ProjectNode({
|
||||||
|
name: 'sub-app',
|
||||||
|
type: 'app',
|
||||||
|
data: {
|
||||||
|
projectType: 'application',
|
||||||
|
root: 'apps/sub/app',
|
||||||
|
sourceRoot: 'apps/sub/app/src',
|
||||||
|
prefix: 'sub-app',
|
||||||
|
tags: [],
|
||||||
|
files: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = projectNode.getCytoscapeNodeDef(false);
|
||||||
|
|
||||||
|
expect(result.data.parent).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not set parentId if app is not nested', () => {
|
||||||
|
const projectNode = new ProjectNode({
|
||||||
|
name: 'app',
|
||||||
|
type: 'app',
|
||||||
|
data: {
|
||||||
|
projectType: 'application',
|
||||||
|
root: 'apps/app',
|
||||||
|
sourceRoot: 'apps/app/src',
|
||||||
|
prefix: 'app',
|
||||||
|
tags: [],
|
||||||
|
files: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = projectNode.getCytoscapeNodeDef(false);
|
||||||
|
|
||||||
|
expect(result.data.parent).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set parentId if the app is nested and groupByFolder is true', () => {
|
||||||
|
const projectNode = new ProjectNode({
|
||||||
|
name: 'sub-app',
|
||||||
|
type: 'app',
|
||||||
|
data: {
|
||||||
|
projectType: 'application',
|
||||||
|
root: 'apps/sub/app',
|
||||||
|
sourceRoot: 'apps/sub/app/src',
|
||||||
|
prefix: 'sub-app',
|
||||||
|
tags: [],
|
||||||
|
files: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = projectNode.getCytoscapeNodeDef(true);
|
||||||
|
|
||||||
|
expect(result.data.parent).toEqual('dir-sub');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('lib nodes', () => {
|
||||||
|
it('should not set parentId if groupByFolder is false', () => {
|
||||||
|
const projectNode = new ProjectNode({
|
||||||
|
name: 'sub-lib',
|
||||||
|
type: 'lib',
|
||||||
|
data: {
|
||||||
|
root: 'libs/sub/lib',
|
||||||
|
sourceRoot: 'libs/sub/lib/src',
|
||||||
|
projectType: 'library',
|
||||||
|
files: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = projectNode.getCytoscapeNodeDef(false);
|
||||||
|
|
||||||
|
expect(result.data.parent).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not set parentId if lib is not nested', () => {
|
||||||
|
const projectNode = new ProjectNode({
|
||||||
|
name: 'lib',
|
||||||
|
type: 'lib',
|
||||||
|
data: {
|
||||||
|
root: 'libs/lib',
|
||||||
|
sourceRoot: 'libs/lib/src',
|
||||||
|
projectType: 'library',
|
||||||
|
files: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = projectNode.getCytoscapeNodeDef(false);
|
||||||
|
|
||||||
|
expect(result.data.parent).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should set parentId if the lib is nested and groupByFolder is true', () => {
|
||||||
|
const projectNode = new ProjectNode({
|
||||||
|
name: 'sub-lib',
|
||||||
|
type: 'lib',
|
||||||
|
data: {
|
||||||
|
root: 'libs/sub/lib',
|
||||||
|
sourceRoot: 'libs/sub/lib/src',
|
||||||
|
projectType: 'library',
|
||||||
|
files: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = projectNode.getCytoscapeNodeDef(true);
|
||||||
|
|
||||||
|
expect(result.data.parent).toEqual('dir-sub');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -30,9 +30,7 @@ export class ProjectNode {
|
|||||||
type: this.project.type,
|
type: this.project.type,
|
||||||
tags: this.project.data.tags,
|
tags: this.project.data.tags,
|
||||||
parent:
|
parent:
|
||||||
groupByFolder &&
|
groupByFolder && this.project.data.hasOwnProperty('sourceRoot')
|
||||||
this.project.type == 'lib' &&
|
|
||||||
this.project.data.hasOwnProperty('sourceRoot')
|
|
||||||
? this.getParentId(this.project.data.sourceRoot)
|
? this.getParentId(this.project.data.sourceRoot)
|
||||||
: null,
|
: null,
|
||||||
};
|
};
|
||||||
|
|||||||
1082
apps/dep-graph-client/src/graphs/sub-apps.ts
Normal file
1082
apps/dep-graph-client/src/graphs/sub-apps.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -19,5 +19,6 @@ module.exports = {
|
|||||||
'<rootDir>/packages/cli',
|
'<rootDir>/packages/cli',
|
||||||
'<rootDir>/packages/angular',
|
'<rootDir>/packages/angular',
|
||||||
'<rootDir>/packages/gatsby',
|
'<rootDir>/packages/gatsby',
|
||||||
|
'<rootDir>/apps/dep-graph-client',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1994,13 +1994,11 @@
|
|||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
"executor": "@nrwl/jest:jest",
|
"executor": "@nrwl/jest:jest",
|
||||||
|
"outputs": ["coverage/apps/dep-graph-client"],
|
||||||
"options": {
|
"options": {
|
||||||
"jestConfig": "apps/dep-graph-client/jest.config.js",
|
"jestConfig": "apps/dep-graph-client/jest.config.js",
|
||||||
"tsConfig": "apps/dep-graph-client/tsconfig.spec.json",
|
"passWithNoTests": true
|
||||||
"passWithNoTests": true,
|
}
|
||||||
"setupFile": "apps/dep-graph-client/src/test-setup.ts"
|
|
||||||
},
|
|
||||||
"outputs": ["coverage/apps/dep-graph-client"]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user