Skip to content

Ryu0118/swift-dependencies-graph

Repository files navigation

swift-dependencies-graph

CLI tool to output mermaid diagrams of module dependencies for multi-modularized projects in Swift Package Manager.

Installation

Mint

Ryu0118/swift-dependencies-graph@0.1.0

Homebrew

$ brew install Ryu0118/dgraph/dgraph
update
$ brew update
$ brew upgrade Ryu0118/dgraph/dgraph

Usage

USAGE: dgraph <project-path> [--add-to-readme] [--include-product] [--strip-transitive]

ARGUMENTS:
  <project-path>          Project root directory

OPTIONS:
  --add-to-readme         Add Mermaid diagram to README
  --include-product       Include .product(name:package:)
  --strip-transitive      Strip transitive dependencies to avoid redundant arrows
  -h, --help              Show help information.

Converting Mermaid Diagrams to Images

To convert the generated Mermaid diagrams to image files (SVG, PNG, PDF), you need to install and use mermaid-cli.

Prerequisites

Install Mermaid CLI globally

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

Step-by-Step Process

. Generate Mermaid diagram using this tool:

$ dgraph /path/to/your/swift/project > dependencies.mmd
  1. Convert to image format:
    # Convert to SVG
    $ mmdc -i dependencies.mmd -o dependencies.svg
    
    # Convert to PNG
    $ mmdc -i dependencies.mmd -o dependencies.png
    
    # Convert to PNG with dark theme
    $ mmdc -i dependencies.mmd -o dependencies.png -t dark
    
    # Convert to PNG with transparent background
    $ mmdc -i dependencies.mmd -o dependencies.png -b transparent

Example

graph TD;
    App-->HogeFeature;
    App-->FugaFeature;
    App-->LoginFeature;
    LoginFeature-->CoreModule;
    HogeFeature-->CoreModule;
    FugaFeature-->CoreModule;
Loading

Package Dependencies

graph TD;
    DependenciesGraph-->DependenciesGraphCore;
    DependenciesGraphCoreTests-->DependenciesGraphCore;
Loading

About

CLI tool to output Mermaid of module dependencies for multi-modularized projects in Swift Package Manager

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •