Fork me on GitHub
#tools-deps
<
2022-04-06
>
grzm11:04:51

I’ve been doing some monorepo spelunking and am calling clojure.tools.cli.api/tree programmatically to get the dependency hierarchy. To get the result as data:

(-> (deps/tree {:project deps-map, 
                :format :edn})
    (with-out-str)
    (edn/read-string))
Works a treat. That said, the round-tripping from pprint within cli/tree and re-parsing makes me suspect I’m doing it wrong.

grzm11:04:38

I could call clojure.tools.deps.alpha.tree/trace->tree but there’s some nice setup within cli/tree that I’d rather not duplicate https://github.com/clojure/tools.deps.alpha/blob/master/src/main/clojure/clojure/tools/cli/api.clj#L151-L156

grzm11:04:18

I suspect this information is in the basis as well. My likely-too-brief and naïve inspection of the basis thinks shows that it’s already flattened and inverted from what’s returned by cli/tree (listing parents rather than children).

Alex Miller (Clojure team)11:04:41

There is not sufficient information in the rest of the basis to construct the “tree” (it's not really a tree)

tree-shake 1
Alex Miller (Clojure team)12:04:49

Something could probably be factored better for programmatic use, feel free to add a request to https://ask.clojure.org

grzm12:04:05

Will do! Thanks, @U064X3EF3 🙂

grzm12:04:23

Is that preferred over opening a TDEPS issue and sending a patch?

Alex Miller (Clojure team)12:04:08

Ask is preferred first, then I make a jira from that

🎸 1
Alex Miller (Clojure team)12:04:36

If you want to provide a patch on that, that would be fine