This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-06
Channels
- # announcements (33)
- # babashka (13)
- # babashka-sci-dev (23)
- # beginners (94)
- # calva (105)
- # cider (37)
- # circleci (1)
- # clj-kondo (45)
- # cljs-dev (59)
- # cljsrn (2)
- # clojure (145)
- # clojure-czech (1)
- # clojure-europe (19)
- # clojure-nl (18)
- # clojure-norway (13)
- # clojure-portugal (1)
- # clojure-uk (5)
- # clojurescript (19)
- # community-development (2)
- # conjure (3)
- # copenhagen-clojurians (1)
- # core-async (34)
- # data-science (6)
- # datomic (25)
- # emacs (43)
- # fulcro (19)
- # graalvm (7)
- # graalvm-mobile (12)
- # graphql (10)
- # honeysql (3)
- # hyperfiddle (3)
- # improve-getting-started (2)
- # interop (20)
- # kaocha (3)
- # lsp (16)
- # meander (7)
- # off-topic (22)
- # other-languages (14)
- # portal (15)
- # releases (1)
- # rewrite-clj (2)
- # ring (1)
- # shadow-cljs (119)
- # spacemacs (19)
- # sql (65)
- # testing (4)
- # tools-deps (11)
- # xtdb (29)
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.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
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).
There is not sufficient information in the rest of the basis to construct the “tree” (it's not really a tree)
Something could probably be factored better for programmatic use, feel free to add a request to https://ask.clojure.org
Will do! Thanks, @U064X3EF3 🙂
If you want to provide a patch on that, that would be fine