Socket
Socket
Sign inDemoInstall

elm-to-dot

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    elm-to-dot

Crawl an Elm project and produce a dependency graph in [DOT](<https://en.wikipedia.org/wiki/DOT_(graph_description_language)>).


Version published
Maintainers
1
Created

Readme

Source

elm-to-dot

Crawl an Elm project and produce a dependency graph in DOT.

$ npm install --global elm-to-dot
$ elm-to-dot --help
elm-to-dot [--include-external] <entry file>

usage

$ elm-to-dot src/Main.elm
digraph {
    rankdir=LR
    Main -> "Graph"
    Main -> "Native.File"
    Main -> "Native.Log"
}
$ elm-to-dot --include-external src/Main.elm
digraph {
    rankdir=LR
    "Graph" -> Dict
    "Graph" -> DotLang
    Main -> "Cli.Option"
    Main -> "Cli.OptionsParser"
    Main -> "Cli.Program"
    Main -> "Elm.Parser"
    Main -> "Elm.RawFile"
    Main -> "Elm.Syntax.Node"
    Main -> "Graph"
    Main -> "Json.Decode"
    Main -> "Native.File"
    Main -> "Native.Log"
    Main -> Parser
}

DOT can be fed into Graphviz to generate an SVG.

dependencies

I like this browser-based version of Graphviz, but I generated the dependency graph above like so.

$ elm-to-dot --include-external src/Main.elm \
    | dot -Tsvg \
    | svgo --input - \
    > dependency-graph.svg
  • dot is Graphviz. With the -Tsvg flag, it outputs an SVG.
  • svgo optimizes SVG files.

why?

I looked at elm-analyse and was surprised to find this CLI is largely written in Elm. However portions of the logic, like the file-gatherer, are written in TypeScript.

I wondered what it would be like to thinly wrap Node.js APIs in ports, allowing full filesystem access in Elm.

dev

$ npm install
$ npm run build
$ ./bin.js src/Main.elm
digraph {
    rankdir=LR
    Main -> "Graph"
    Main -> "Native.File"
    Main -> "Native.Log"
}

FAQs

Last updated on 07 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc