Fork me on GitHub
#tools-deps
<
2022-06-02
>
pyr15:06:05

Is there a clj -X:deps prep like function that I can call to prep a lib when working against it directly (instead of going out to dependencies as clj -X:deps prep does)

seancorfield15:06:38

Since "prep" is "run this function with this alias" you can use clojure -X:some-alias some-fn directly (or clojure -T:... - I can't remember whether prep runs it as a tool or as an exec function).

Alex Miller (Clojure team)16:06:08

so if you are in that project, clj -T:alias fn should be the equivalent of what prep is doing

Alex Miller (Clojure team)16:06:41

maybe it would be useful to have some shortcut for "self prep"

seancorfield16:06:10

Thanks, @U064X3EF3 saves me having to go digging in the code! ūüôā

Alex Miller (Clojure team)16:06:46

it's a little hard to tell even if you do look at the code, but that is the intent :)

pyr06:06:09

I agree that you can use the targeted alias, as you suggest @U04V70XH6. But I was more interested in a generic way to call something akin to self-prep as @U064X3EF3 suggests. Point taken that it's not something that exists at the moment. Would there be interest in a patch that adds support for self-prep? The context for us is that we have a (soon to be released) tool which adds conventions around building stuff. Our codebase is large and spread across several repositories which are either standalone or multi-module. Since the engineering team is large as well, we are always careful about ensuring there are conventions and as few snowflakes as possible (hence why we built a tool instead of distributing build.clj files around). The specific need for self-prep is when building jars with the tool, it would be interesting to try launching self-prep. For now, I'll make the tool discover the :deps/prep-lib and mimick prep's behavior in that case. Oh and by the way if the above didn't make it obvious, we're transitioning wholesale away from leiningen and on to deps over the course of the next two months ūüôā

seancorfield07:06:40

And just to be clear clojure -X:deps prep doesn't work for the current project? (I'm a bit surprised about that)

pyr07:06:07

it only runs the :deps/prep-lib task in dependencies, not in the current project (by design)

pyr07:06:45

OK, scratch the suggestion to make a patch for it, I guess it's a bit too specific to the tool we built and it's easy enough to bake the behavior in it

Diego23:06:57

What the best way to run something like this in my codebase?

clojure -Sdeps '{:deps {cljfmt {:mvn/version "0.8.0"}}}' \
  -m cljfmt.main fix
Thinking like I could make alias or something.

seancorfield23:06:45

:aliases
{:format {:extra-deps {cljfmt {:mvn/version "0.8.0"}}
          :main-opts ["-m" "cljfmt.main" "fix"]}
 ..}
Then clojure -M:format -- like that?

practicalli-john08:06:15

I have these cljfmt aliases in practicalli/clojure-deps-edn

  ;; cljfmt-check - check/report formatting issues 
   :format/cljfmt-check 
   {:extra-deps {cljfmt/cljfmt {:mvn/version "0.8.0"}} 
    :main-opts ["-m" "cljfmt.main" "check"]} 
  
   ;; cljfmt-check - check/report formatting issues 
   :format/cljfmt-fix 
   {:extra-deps {cljfmt/cljfmt {:mvn/version "0.8.0"}} 
    :main-opts ["-m" "cljfmt.main" "fix"]}
https://github.com/practicalli/clojure-deps-edn