dependency-cruiser-report-action icon indicating copy to clipboard operation
dependency-cruiser-report-action copied to clipboard

Support for `--reaches` option

Open katz opened this issue 11 months ago • 3 comments

Hi,

Thank you for the great GitHub Action!

I tried to leverage this action in our project and found that there is another way to visualize dependencies. Currently, this action uses the --focus option, which displays the dependencies/dependents of the files passed to the option. Although it's useful, the main purpose of the visualization is to identify which files are dependents of the files changed in a Pull Request. If the action uses the --reaches option, it can visualize which modules will be directly or indirectly affected by a change in a Pull Request.

For example, in Pull Request #306, the action runs the following command:

pnpm exec depcruise  \
  --output-type mermaid  \
  --config .dependency-cruiser.js  \
  --focus "^dist/index.js|^src/options.ts|^src/options/filterSupportedFiles.test.ts|^src/options/formatFocusOption.test.ts|^src/options/validateOptions.test.ts|^src/options/validateOptions.ts|^src/report/body/reportBody.test.ts|^src/report/body/uniqueTag.test.ts|^src/report/fetchPreviousReport.ts|^test/runDepcruise/index.test.ts|^test/runDepcruise/sample/__mocks__/test/fixtures/cjs/root_one.js|^test/runDepcruise/sample/__mocks__/test/fixtures/cjs/root_two.js"  \
  dist/index.js src/options.ts src/options/filterSupportedFiles.test.ts src/options/formatFocusOption.test.ts src/options/validateOptions.test.ts src/options/validateOptions.ts src/report/body/reportBody.test.ts src/report/body/uniqueTag.test.ts src/report/fetchPreviousReport.ts test/runDepcruise/index.test.ts test/runDepcruise/sample/__mocks__/test/fixtures/cjs/root_one.js test/runDepcruise/sample/__mocks__/test/fixtures/cjs/root_two.js

The output only visualizes the dependencies of the changed files.

flowchart LR

subgraph 0["src"]
1["options.ts"]
subgraph 2["options"]
3["filterSupportedFiles.ts"]
4["formatFocusOption.ts"]
5["getConfigFilePath.ts"]
6["validateOptions.ts"]
8["filterSupportedFiles.test.ts"]
9["formatFocusOption.test.ts"]
A["validateOptions.test.ts"]
end
7["ActionError.ts"]
subgraph B["report"]
subgraph C["body"]
D["reportBody.test.ts"]
E["reportBody.ts"]
F["uniqueTag.ts"]
G["uniqueTag.test.ts"]
end
H["fetchPreviousReport.ts"]
end
I["type.ts"]
end
1-->3
1-->4
1-->5
1-->6
1-->6
6-->7
8-->3
9-->4
A-->7
A-->6
A-->6
D-->E
E-->F
G-->F
H-->1
H-->I
H-->F

style 1 fill:lime,color:black
style 6 fill:lime,color:black
style 8 fill:lime,color:black
style 9 fill:lime,color:black
style A fill:lime,color:black
style D fill:lime,color:black
style G fill:lime,color:black
style H fill:lime,color:black

On the other hand, if I run the command with the --reaches option, it can visualize which modules will be directly or indirectly affected by a change:

pnpm exec depcruise  \
  --output-type mermaid  \
  --config .dependency-cruiser.js  \
  --max-depth 2 \
  --reaches "^dist/index.js|^src/options.ts|^src/options/filterSupportedFiles.test.ts|^src/options/formatFocusOption.test.ts|^src/options/validateOptions.test.ts|^src/options/validateOptions.ts|^src/report/body/reportBody.test.ts|^src/report/body/uniqueTag.test.ts|^src/report/fetchPreviousReport.ts|^test/runDepcruise/index.test.ts|^test/runDepcruise/sample/__mocks__/test/fixtures/cjs/root_one.js|^test/runDepcruise/sample/__mocks__/test/fixtures/cjs/root_two.js" \
  src
flowchart LR

subgraph 0["src"]
1["installDependencies.ts"]
2["options.ts"]
subgraph 3["options"]
4["validateOptions.ts"]
9["filterSupportedFiles.test.ts"]
A["formatFocusOption.test.ts"]
B["validateOptions.test.ts"]
end
5["main.ts"]
subgraph 6["report"]
7["generateReport.ts"]
8["fetchPreviousReport.ts"]
subgraph C["body"]
D["reportBody.test.ts"]
E["uniqueTag.test.ts"]
end
end
end
1-->2
2-->4
2-->4
5-->1
5-->2
5-->7
7-->2
7-->8
B-->4
B-->4

style 2 fill:lime,color:black
style 4 fill:lime,color:black
style 8 fill:lime,color:black
style 9 fill:lime,color:black
style A fill:lime,color:black
style B fill:lime,color:black
style D fill:lime,color:black
style E fill:lime,color:black

katz avatar Mar 25 '24 00:03 katz