Skip to content

Gives insights about cargo workspace, like how packages depend on each other

License

Notifications You must be signed in to change notification settings

jaads/cargo-workspace-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cargo Workspace Analyzer

A CLI tool which provides insights about a Cargo workspace. Currently, the following is supported.

Workspace Visualization

It visualizes the workspace with a Mermaid diagram. That way the user can see how packages depend on each other may identify layers of the application. As an example, here is the resulting diagram a randomly selected workspace, Tauri.

example diagram of packages within a workspace

To have such diagram gives you the following advantages:

  • a high level overview of the software you create
  • gives you an idea about the degree of coupling between your packages

Circular Dependency Detection

This analyzer finds circular dependencies. It highlights those packages, which form a circle. By running the analyzer regularly, one can detect circular dependencies before they get hard if not impossible to resolve later on. See this example.

Package Count

It will also display the amount of packages in your workspace.

Installation

Install it globally:

cargo install cargo-workspace-analyzer

To render the Mermaid diagram and store it so disk (which is the default behaviour), you would need to have the Mermaid CLI installed as well, which run on Node.js.

npm install -g @mermaid-js/mermaid-cli

Usage

For all details, use cargo-workspace-analyzer --help. However here is how you can use it generally: Navigate to a Cargo workspace and run the tool:

cd path/to/your/workspace
cargo-workspace-analyzer

Or use an argument to specify the location of the workspace and run it from where ever you want.

cargo-workspace-analyzer --working-dir /path/to/your/workspace

If you use the --no-file argument, the resulting Mermaid diagram will be printed to the console. You can copy it for somewhere else for further processing.

Here's an example of circular dependency detection.
graph TD
    service-1 --> db-connector
    API --> service-2
    API --> service-1
    service-2 --> db-connector

About

Gives insights about cargo workspace, like how packages depend on each other

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages