You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Fixes issue where nodes were not added to existing cluster
* Adds missing dependency
* Adds support for the d2 syntax
* Adds d2 to README
* Update README.md
* Update README.md
Copy file name to clipboardExpand all lines: README.md
+49-30Lines changed: 49 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,19 +4,19 @@
4
4
5
5
dependency-graph is a command-line tool that can visualize the dependencies of packages. The tool takes the path to an Xcode project or a Package.swift file as input and outputs a graph that shows the dependencies of the packages in the project or package.
6
6
7
-
## 👀 Sample
7
+
## 👀 Examples
8
8
9
-
The graph below shows the relationship of the products and targets in this package as of December 11, 2022. Click on the image to see a larger version.
9
+
The following graphs are examples of the graphs that dependency-graph can output. The first graph built by providing dependency-graph the path to a Package.swift file and the second graph was made by providing dependency-graph the path to an .xcodeproj file as input.
10
10
11
-
<imgwidth="400"src="./sample-swift-package.png"alt="Example graph showing the dependencies of this package." />
11
+
|Swift Package|Xcode Project|
12
+
|-|-|
13
+
|<imgwidth="400"src="./example-swift-package.png"alt="Example graph showing the dependencies of this package." />|<imgwidth="400"src="./example-xcodeproj.png"alt="Example graph showing the dependencies of an Xcode project." />|
12
14
13
-
Nodes shaped as an ellipse represent products, e.g. the libraries in a Swift package, and the square nodes represent targets.
15
+
Nodes shaped as ellipsis represent products, e.g. the libraries in a Swift package, and the square nodes represent targets.
14
16
15
17
## 🚀 Getting Started
16
18
17
-
Start off by installing the tool.
18
-
19
-
#### Using [Homebrew](https://brew.sh)
19
+
Start off by installing the tool with [Homebrew](https://brew.sh).
20
20
21
21
```bash
22
22
brew tap simonbs/dependency-graph https://github.com/simonbs/dependency-graph.git
@@ -39,14 +39,6 @@ brew install dependency-graph
39
39
> arch -arm64 brew install dependency-graph
40
40
> ```
41
41
42
-
#### Using [Mint](https://github.com/yonaskolb/Mint)
43
-
44
-
```bash
45
-
mint install simonbs/dependency-graph
46
-
```
47
-
48
-
#### Confirm Installation
49
-
50
42
You may now run the following command to verify that the tool was installed correctly. The following command should print information on how the tool can be used.
51
43
52
44
```
@@ -97,7 +89,13 @@ digraph g {
97
89
}
98
90
```
99
91
100
-
The output can be rendered to an image by piping it to the [dot CLI](https://graphviz.org/doc/info/command.html), which is part of [Graphviz](https://graphviz.org).
92
+
The output can be rendered to an image by piping it to a renderer. See the following sections for details on the supported renderers.
93
+
94
+
#### DOT
95
+
96
+
<imgwidth="400"src="./example-dot.png"alt="Example graph rendered with dot." />
97
+
98
+
By default dependency-graph will use the DOT syntax which can be rendered by the [dot CLI](https://graphviz.org/doc/info/command.html), which is part of [Graphviz](https://graphviz.org).
101
99
102
100
Install Graphviz and run `dependency-graph` and pass the output to the newly installed `dot` CLI.
The previous example output would look different but similar when using [the Mermaid diagram syntax](https://mermaid-js.github.io/mermaid/#/flowchart) instead. The syntax is used by passing the `--syntax mermaid` option.
107
+
When rendering the graph to a PNG, you will likely want to specify the size of the output to ensure it is readable. To generate an image with dot that is exactly 6000 pixels wide or 8000 pixels tall but not necessarily both, do the following:
When rendering the graph to a PNG, you will likely want to specify the size of the output to ensure it is readable. You can do this with both the dot and mermaid CLIs.
119
+
For large projects the graph may become unreadable. Passing the output through Grahpviz' [unflatten](https://graphviz.org/docs/cli/unflatten/) command may improve the results.
119
120
120
-
To generate an image with dot that is exactly 6000 pixels wide or 8000 pixels tall but not necessarily both, do the following:
<imgwidth="400"src="./example-mermaid.png"alt="Example graph rendered with mermaid." />
128
+
129
+
Specify the `--syntax mermaid` option to have dependency-graph output a graph using [the Mermaid diagram syntax](https://mermaid-js.github.io/mermaid/#/flowchart).
130
+
131
+
The output be rendered to an image using the [the mermaid cli](https://github.com/mermaid-js/mermaid-cli).
Pass the `--packages-only` flag to include only the Xcode project and Swift packages in the graph. This omits the libraries and targets within the Xcode project and Swift packages.
150
+
#### D2
139
151
140
-
<imgwidth="400"src="./sample-packages-only.png"alt="Example graph showing only an Xcode project and Swift packages." />
152
+
<imgwidth="400"src="./example-d2.png"alt="Example graph rendered with d2." />
141
153
142
-
For large projects the graph may become unreadable. Passing the output through Grahpviz' [unflatten](https://graphviz.org/docs/cli/unflatten/) command may improve the resutls.
154
+
Specify the `--syntax d2` option to have dependency-graph output a graph using [the d2 scripting language](https://d2lang.com/tour/intro).
155
+
156
+
The output be rendered to an image using the [the d2 cli](https://github.com/terrastruct/d2#install).
Pass the `--packages-only` flag to include only the Xcode project and Swift packages in the graph. This omits the libraries and targets within the Xcode project and Swift packages.
166
+
167
+
<imgwidth="400"src="./example-packages-only.png"alt="Example graph showing only an Xcode project and Swift packages." />
168
+
148
169
## 🤷♂️ OK, why?
149
170
150
171
As I'm splitting my iOS and macOS applications into small Swift packages with several small targets, I started wishing for a way to visualise the relationship between the products and targets in my Swift packages. That's why I built this tool.
@@ -154,9 +175,7 @@ Several other tools can visualise a Swift package, however, I wanted a tool that
154
175
The example in the top of this README shows a visualization of a Swift package and the graph below shows a visualisation of an Xcode project.
155
176
Notice that the left-most subgraph represents an Xcode project named ScriptUIEditor.xcodeproj and it has three targets: ScriptUIEditor, ScriptBrowserFeature, and ScriptBrowserFeatureUITests. Two of these depends on the Swift packages represented by the remaining subgraphs.
156
177
157
-
These graphs provide a good way to get an overview of a package or the relationship between several packages. Sometimes it can be helpful to generate multiple graphs to get a good overview, for example, a graph of the entire project and graphs of selected packages. Fortunately, the `dependency-graph` cLI makes this easy as it can take either an Xcode project and a Package.swift file as input.
158
-
159
-
<imgwidth="400"src="./sample-xcodeproj.png"alt="Example graph showing the dependencies of an Xcode project." />
178
+
These graphs provide a good way to get an overview of a package or the relationship between several packages. Sometimes it can be helpful to generate multiple graphs to get a good overview, for example, a graph of the entire project and graphs of selected packages. Fortunately, the `dependency-graph` CLI makes this easy as it can take either an Xcode project and a Package.swift file as input.
0 commit comments