dependency-cruiser
dependency-cruiser copied to clipboard
Not a bug or a feature: Possible to consolidate all dependencies of a source within the dependencies list?
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.
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)
@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', ...]
},
...
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
(reopened as the stale issue bot inadvertently closed it during my holidays)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.