sverweij / dependency-cruiser

Validate and visualize dependencies. Your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.
https://npmjs.com/dependency-cruiser
MIT License
5.15k stars 249 forks source link

Make it work without installation #949

Closed gentlee closed 1 month ago

gentlee commented 1 month ago

Would be nice to just call:

npx dependency-cruiser src

to show the graph, without the need of installing anything.

Context

I don't want to install and then remove this package if I want it to be used once.

Expected Behavior

Just run npx dependency-cruiser src and get graph

Current Behavior

Need to do installation steps then remove it.

sverweij commented 1 month ago

Hi @gentlee thanks for the suggestion.

dependency-cruiser's primary use case is to run it as part of a permanent setup. Besides, running it as a one-off with e.g. npx comes with some complications:

That said even with these complication it's possible to run dependency-cruiser with npx

Mileage may vary, though.

Some examples:

# list all dependencies in src in text format
npx --package typescript --package dependency-cruiser -- \
    depcruise src --no-config --include-only ^src --ts-config tsconfig.json --output-type text
# npx will ask if it's OK to install typescript and dependency-cruiser; 
# hit enter to confirm

# list all dependencies in src and use the experimental 
# x-dot-webpage reporter to generate a webpage with a graph 
# of the dependencies with the native graphviz' dot
# command  + show  it  in the  browser with the `browser` command/ script
npx --package typescript --package dependency-cruiser -- \
    depcruise src --no-config --include-only ^src --ts-config tsconfig.json --output-type x-dot-webpage > dependencies.html
github-actions[bot] commented 1 month ago

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