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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix(mermaid): makes nodes without a name render as well #705

Merged
merged 1 commit into from Dec 23, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -87,7 +87,7 @@
"depcruise:graph:doc:samples": "sh tools/generate-samples.sh",
"depcruise:graph:dot": "node ./bin/dependency-cruise.js bin src --config --output-type dot | dot -T svg > tmp_deps.svg",
"depcruise:graph:fdp": "node ./bin/dependency-cruise.js bin src --config --output-type dot | fdp -GK=0.1 -Gsplines=true -T svg > tmp_deps.svg",
"depcruise:graph:mermaid": "node ./bin/dependency-cruise.js bin src --include-only ^src/ --config --output-type mermaid",
"depcruise:graph:mermaid": "node ./bin/dependency-cruise.js bin src --include-only ^src/ --config --collapse 2 --output-type mermaid",
"depcruise:graph:mermaid:diff": "node ./bin/dependency-cruise.js bin src test --config configs/.dependency-cruiser-unlimited.json --output-type mermaid --reaches \"$(watskeburt $SHA)\"",
"depcruise:graph:osage": "node ./bin/dependency-cruise.js bin src --config --output-type dot | osage -Gpack=32 -GpackMode=array2 -T svg > tmp_deps.svg",
"depcruise:graph:view": "node ./bin/dependency-cruise.js bin src --prefix vscode://file/$(pwd)/ --config configs/.dependency-cruiser-show-metrics-config.json --output-type dot --progress cli-feedback --highlight \"$(watskeburt develop)\" | dot -T svg | node ./bin/wrap-stream-in-html.js | browser",
Expand Down
3 changes: 2 additions & 1 deletion src/report/mermaid.js
Expand Up @@ -4,7 +4,8 @@ const REPORT_DEFAULTS = {
minify: true,
};

const renderNode = (pNode, pText) => `${pNode}["${pText}"]`;
const renderNode = (pNode, pText) =>
`${pNode}["${pText.length > 0 ? pText : " "}"]`;

const renderEdge = (pFrom, pTo) => `${pFrom.node}-->${pTo.node}`;

Expand Down
65 changes: 65 additions & 0 deletions test/report/mermaid/__mocks__/collapsed.json
@@ -0,0 +1,65 @@
{
"modules": [
{
"dependencies": [],
"rules": [],
"valid": false,
"source": "src/",
"dependents": [],
"orphan": true,
"consolidated": true
}
],
"summary": {
"violations": [],
"error": 0,
"warn": 0,
"info": 0,
"ignore": 0,
"totalCruised": 1,
"totalDependenciesCruised": 0,
"optionsUsed": {
"baseDir": "/Users/jdoe/dependency-cruiser",
"cache": "node_modules/.cache/dependency-cruiser",
"collapse": "node_modules/[^/]+|^[^/]+/",
"combinedDependencies": false,
"doNotFollow": {
"path": "node_modules",
"dependencyTypes": [
"npm",
"npm-dev",
"npm-optional",
"npm-peer",
"npm-bundled",
"npm-no-pkg"
]
},
"enhancedResolveOptions": {
"exportsFields": ["exports"],
"conditionNames": ["require"],
"extensions": [".js", ".d.ts"]
},
"exclude": {
"path": "mocks|fixtures|test/integration|src/cli/tools/svg-in-html-snippets/script.snippet.js"
},
"exoticRequireStrings": ["tryRequire", "requireJSON"],
"externalModuleResolutionStrategy": "node_modules",
"includeOnly": "^src/",
"metrics": false,
"moduleSystems": ["cjs", "es6"],
"outputTo": "-",
"outputType": "json",
"prefix": "https://github.com/sverweij/dependency-cruiser/blob/develop/",
"preserveSymlinks": false,
"reporterOptions": {},
"rulesFile": ".dependency-cruiser.json",
"tsPreCompilationDeps": true,
"args": "bin src"
},
"ruleSetUsed": {}
},
"revisionData": {
"SHA1": "3fc6295ac0edfdb8f23957720298be9b8d6d395f",
"changes": []
}
}
6 changes: 6 additions & 0 deletions test/report/mermaid/__mocks__/collapsed.min.mmd
@@ -0,0 +1,6 @@
flowchart LR

subgraph 0["src"]
1[" "]
end

3 changes: 3 additions & 0 deletions test/report/mermaid/mermaid.spec.mjs
Expand Up @@ -52,6 +52,9 @@ describe("[I] report/mermaid", () => {
it("renders a mermaid - renders focused elements with highlights - minified", () => {
same("with-focus", { minify: true });
});
it("renders collapsed nodes correctly", () => {
same("collapsed", { minify: true });
});
});

describe("[I] configs/plugins/mermaid-reporter-plugin", () => {
Expand Down