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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not a bug or a feature: Possible to consolidate all dependencies of a source within the dependencies list? #503

Open
nickhodaly opened this issue Sep 25, 2021 · 5 comments
Labels

Comments

@nickhodaly
Copy link

I am using the dependency-cruiser API to cruise a list of files and working with the JSON output. Is it currently possible to consolidate all of a source files dependencies into the dependency list recursively?

Summary

From what I can tell, the list of dependencies contains only the top level dependencies of the source and if you want to see the dependencies of those top level dependencies you need to find the JSON object whose source matches the top level dependency, and look at it's dependencies, so on and so forth.

Context

I can build some logic to trace these dependencies down recursively and consolidate them, just wondering if it's something available out of the box.

@sverweij
Copy link
Owner

hi @nickhodaly - this is indeed not available 'out of the box'.

Can you tell me what you're going to use it for? (I'm just curious)

@nickhodaly
Copy link
Author

@sverweij Of course! Thanks for responding so quickly! I have a use case that I would imagine is pretty uncommon. I am working on something that will relate browser based UI tests to the code under test and the code under tests' dependencies. This is a solved problem when it comes to unit testing as the code under test in unit tests is typically already a dependency of the unit test itself. For example the jest test runner supports this via changedSince and onlyChanged which allow you to only run a subset of tests rather than the entire suite based on the files that have changed https://jestjs.io/docs/cli#--changedsince. In my case specifically, I just want a single list (recursive) of all the dependencies for a given file. That way I can check if a given test file needs to be executed based on whether or not a file that has been changed is included in the list of dependencies.

Some examples:
Scenario 1: the file def/components/xyz.ts has been modified, thus onlydef/ui_test.ts shall be executed.
Scenario 2: the file utils/cool_util.ts has been modified so the tests abc/ui_test.ts and ghi/ui_test.ts will be executed.

{
    source: 'abc/ui_test.ts'
    dependencies: ['abc/index.ts', 'abc/types.ts', 'abc/components/xyz.ts', 'utils/cool_util.ts', ...]
},
{
    source: 'def/ui_test.ts'
    dependencies: ['def/index.ts', 'def/types.ts', 'def/components/xyz.ts', ...]
},
{
    source: 'ghi/ui_test.ts'
    dependencies: ['ghi/index.ts', 'ghi/types.ts', 'ghi/components/xyz.ts', 'utils/cool_util.ts', ...]
},
...

@github-actions
Copy link

github-actions bot commented Oct 4, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale label Oct 4, 2021
@github-actions github-actions bot closed this as completed Oct 7, 2021
@sverweij
Copy link
Owner

(reopened as the stale issue bot inadvertently closed it during my holidays)

@sverweij sverweij reopened this Nov 15, 2021
@sverweij sverweij removed the stale label Nov 15, 2021
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale label Nov 23, 2021
@sverweij sverweij added question and removed stale labels Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants