Skip to content

Instantly share code, notes, and snippets.

@amtoine
Created May 25, 2023 17:53
Show Gist options
  • Save amtoine/535f21c16a8c1ebeb180db2c49c494b4 to your computer and use it in GitHub Desktop.
Save amtoine/535f21c16a8c1ebeb180db2c49c494b4 to your computer and use it in GitHub Desktop.
Nushell dependency graph

Nushell dependency graph

below is the dependency graph of the Nushell project

💡 Note
command to generate this, with the graphviz package

dot -T png -o nushell.png nushell.dot

nushell

generating nushell.dot

i've used the script below and then tweaked the style and rank of the nodes manually 😋

let nushell = (http get https://raw.githubusercontent.com/nushell/nushell/main/Cargo.toml)
let graph = (
    $nushell.dependencies | transpose name data | each {|dependency|
        print -n $"(ansi erase_line)($dependency.name)\r"

        let url = if ($dependency.name in ["reedline" "nu-ansi-term"]) {
            $"https://raw.githubusercontent.com/nushell/($dependency.name)/main/Cargo.toml"
        } else if ($dependency.name | str starts-with "nu-") {
            $"https://raw.githubusercontent.com/nushell/nushell/main/crates/($dependency.name)/Cargo.toml"
        }

        if $url != null {
            let dependencies = (
                http get $url
                | get dependencies
                | transpose name data
                | where {|it| $it.name | str starts-with "nu-"}
                | get name
            )

            if not ($dependencies | is-empty) {
                [
                    $'    "($dependency.name)" -> {'
                    ($dependencies | each { $'        "($in)"' } | str join "\n")
                    $"    }"
                ] | str join "\n"
            }
        }
    }
)

$"digraph nushell {
($graph | str join "\n\n")
}" | save --force nushell.dot
digraph nushell {
"nu-ansi-term" [color = green]
"reedline" [shape = box, color = green]
{rank = same;
"nu-ansi-term" [shape = box]
"nu-explore" [shape = box]
"nu-glob" [shape = box]
"nu-json" [shape = box]
"nu-path" [shape = box]
"nu-protocol" [shape = box]
"nu-system" [shape = box]
"nu-utils" [shape = box]
}
"nu" -> {
"nu-cli"
"nu-color-config"
"nu-cmd-lang"
"nu-cmd-dataframe"
"nu-command"
"nu-engine"
"nu-parser"
"nu-plugin"
"nu-pretty-hex"
"nu-table"
"nu-term-grid"
"nu-std"
"reedline"
} [style = dashed, color = red];
"nu" -> {
"nu-ansi-term"
"nu-json"
"nu-path"
"nu-protocol"
"nu-system"
"nu-utils"
} [style = "", color = grey];
"nu-cli" -> {
"nu-color-config"
"nu-command"
"nu-engine"
"nu-parser"
}
"nu-cli" -> {
"nu-ansi-term"
"nu-path"
"nu-protocol"
"nu-utils"
} [style = "", color = grey];
"nu-cmd-dataframe" -> {
"nu-cmd-lang"
"nu-engine"
"nu-parser"
}
"nu-cmd-dataframe" -> {
"nu-protocol"
} [style = "", color = grey];
"nu-cmd-lang" -> {
"nu-color-config"
"nu-engine"
"nu-parser"
}
"nu-cmd-lang" -> {
"nu-ansi-term"
"nu-protocol"
"nu-utils"
} [style = "", color = grey];
"nu-color-config" -> {
"nu-engine"
}
"nu-color-config" -> {
"nu-ansi-term"
"nu-json"
"nu-protocol"
"nu-utils"
} [style = "", color = grey];
"nu-command" -> {
"nu-cmd-dataframe"
"nu-cmd-lang"
"nu-color-config"
"nu-engine"
"nu-parser"
"nu-pretty-hex"
"nu-table"
"nu-term-grid"
} [style = "", color = blue];
"nu-command" -> {
"nu-ansi-term"
"nu-explore"
"nu-glob"
"nu-json"
"nu-path"
"nu-protocol"
"nu-system"
"nu-utils"
} [style = "dashed", color = blue];
"nu-engine" -> {
"nu-glob"
"nu-path"
"nu-protocol"
"nu-utils"
} [style = "", color = grey]
"nu-parser" -> {
"nu-engine"
"nu-plugin"
}
"nu-parser" -> {
"nu-path"
"nu-protocol"
} [style = "", color = grey]
"nu-plugin" -> {
"nu-engine"
}
"nu-plugin" -> {
"nu-protocol"
} [style = "", color = grey]
"nu-pretty-hex" -> {
"nu-ansi-term"
} [style = "", color = grey]
"nu-protocol" -> {
"nu-utils"
} [style = "", color = grey]
"nu-std" -> {
"nu-parser"
}
"nu-std" -> {
"nu-protocol"
} [style = "", color = grey]
"nu-table" -> {
"nu-color-config"
"nu-engine"
}
"nu-table" -> {
"nu-ansi-term"
"nu-protocol"
"nu-utils"
} [style = "", color = grey]
"nu-term-grid" -> {
"nu-utils"
} [style = "", color = grey]
"reedline" -> {
"nu-ansi-term"
} [style = "", color = grey]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment