What's this do?
- ... validates them against (your own) rules
- ... reports violated rules
- in text (for your builds)
- in graphics (for your eyeballs)
As a side effect it can generate cool dependency graphs you can stick on the wall to impress your grandma.
How do I use it?
npm install --save-dev dependency-cruiserto use it as a validator in your project (recommended) or...
npm install --global dependency-cruiserif you just want to to inspect multiple projects.
Show stuff to your grandma
To create a graph of the dependencies in your src folder, you'd run dependency
cruiser with output type
dot and run GraphViz dot on the result. In
a one liner:
depcruise --include-only "^src" --output-type dot src | dot -T svg > dependencygraph.svg
- You can read more about what you can do with
--include-onlyand other command line options in the command line interface documentation.
- Real world samples contains dependency cruises of some of the most used projects on npm.
Declare some rules
The easy way to get you started:
This will create a
.dependency-cruiser.json with some rules that make sense
in most projects (detecting circular dependencies, dependencies
missing in package.json, orphans, production code relying on
dev- or optionalDependencies, ...).
Start adding your rules by tweaking that file.
- To read more about writing rules check the writing rules tutorial or the rules reference
- You can find the
depcruise --validate .dependency-cruiser.json src
This will validate against your rules and shows any violations in an eslint-like format:
There's more ways to report validations; in a graph (like the one on top of this readme) or in a table.
- Read more about the err, dot, csv and html reporters in the command line interface documentation.
- dependency-cruiser uses itself to check on itself in its own build process;
decpruisescript in the package.json
I want to know more!
You've come to the right place :-) :
- Hacking on dependency-cruiser
- Other things
- Katerina Limpitsouni of unDraw for the ollie in dependency-cruiser's social media image.
- All members of the open source community who have been kind enough to raise issues, ask questions and make pull requests to get dependency-cruiser to be a better tool.
Made with 🤘 in Holland.