leiningen

2021-11-22T20:25:41.032Z

Is there a way to retrieve data from somewhere in project.clj and put in :aliases? For example, I'd like to configure :figwheel-main in some profiles and then be able to pass those configs to the figwheel launch command in :aliases.

vemv 2021-11-22T20:53:35.032100Z

I don't get what you want exactly, can you rephrase it? (perhaps without mentioning figwheel)

2021-11-22T20:57:24.032300Z

Sure:

{:profiles {:A {:compiler :config-map}}

 :aliases ["with-profiles" "A" "run" "m" "something.main" "-co"
           #=(pr-str ***COMPILER***)]}
I'd like to fill ***COMPILER*** with the data from :compiler as defined in the profile.

vemv 2021-11-22T21:02:02.032500Z

(def data {:compiler :config-map})

(defproject foo :profiles {:A ~data})

vemv 2021-11-22T21:02:22.032700Z

before defproject you can def/defns, without any special syntax required

vemv 2021-11-22T21:02:49.032900Z

inside defproject you can use ~ to eval arbitrary expressions, within which you can refer to any prior def/defns

2021-11-22T21:02:49.033100Z

Right, but then I can't extract the merged profiles, can I?

👀 1
vemv 2021-11-22T21:06:40.033400Z

if you don't want pure data but the result of a Lein computation, that sounds like something that plugins/middleware can do

2021-11-22T21:06:58.033600Z

I was afraid of that 🙃

vemv 2021-11-22T21:07:19.033800Z

here is an example of a piece of 'inline middleware', no messing with .jars required https://github.com/nedap/formatting-stack/blob/31a17527260899b5a052e7e8fc8c4aaf37609d32/project.clj#L84-L101

vemv 2021-11-22T21:07:44.034100Z

the fn receives a project map as an argument from Lein, probably with all profiles merged?

2021-11-22T21:08:03.034300Z

Oh an inline middleware, that's very interesting

2021-11-22T21:08:19.034500Z

I'll explore this path, thank you very much!

🍻 1