Anyone have an example of boot + dirac agent? (as opposed to lein)
I believe @jaen is a boot user
Yeah. @smw, what do you have problems with?
@jaen: I’m just looking for a bit of example code that runs the agent integrated with something like boot-cljs-repl?
I have something like
(deftask dev-cljs-repl
"Run a restartable system in the Repl"
[]
(comp
(environ :env {:http-port "3300" :dev true})
(watch :verbose true)
(system :sys #'dev-system :auto true :files ["handler.clj"])
(reload :port 55554)
(cljs-repl :port 55555)
(cljs)
(speak)))
Dirac documentation suggests that you can’t use piggieback, as Dirac provides the same functionality.
boot-cljs-repl has
piggie-repl (partial repl :server true
:middleware ['cemerick.piggieback/wrap-cljs-repl])]
I guess I need something like boot-dirac-repl that does something similar, as I don’t see a way to override the middleware there.
I don’t mind trying to write such a thing, but I was hoping someone might have already done it.
your understanding is correct, you just need to replace piggieback with dirac middleware
unfortunately I don’t have personal experience with boot stack
Ok. I’ll try to spin out a boot-dirac-repl… or see if the boot people are ok with a PR adding dirac support. Thanks :simple_smile:
So I don't really have anything more than:
(repl :server true
:middleware '[dirac.nrepl.middleware/dirac-repl]
:port 8230)
and
(defn start-dirac! []
(require 'dirac.agent)
(let [dirac-boot! (resolve 'dirac.agent/boot!)]
(dirac-boot!)))
in build boot.And then I just call start-dirac!
when I connect to boot REPL.
And that's it.
@smw: ^
Oh. Wow, that’s simple.
Remember to remove boot-cljs-repl
tho
Otherwise it might clash.
If I read the cljs-repl code, it appears it’s doing some slightly complex stuff with weasel… I’m not sure I understand the impact. Do you know if I’m losing functionality by using your incredibly simple version? :simple_smile:
I guess not, because that’s part of webtools?
err, sorry,
I mean ‘part of dirac?'
You loose some, you gain some. But dirac gives you equivalent functionality to boot-cljs-repl
.
Roger that. Thanks so much for the help.
Just inside the devtools.
And if you don't remove boot-cljs-repl
(both the task and related piggibeack/weasel/austin dependencies) you probably won't get dirac to work
At least the deps clashed for me if I didn't remove them all.
Otherwise this should Just Work™
If it won't, let me know.
Of course remember to have something equivalent to:
(defn install-devtools! []
(devtools/set-pref! :install-sanity-hints true)
(devtools/enable-feature! :dirac)
(devtools/install!))
called in your client app.Oh. I have that part, mostly? I don’t think I have enable-feature!
...
no, I do...
missing the set-pref
I think you should be able to run them side-by-side if you make sure that ports don’t clash
(devtools/enable-feature! :sanity-hints :dirac)
(devtools/install!)
Is that equivalent?
that’s equivalent
Thanks.
I’m so psyched about this. Thanks for this work! This really does seem like the holy grail.
(not sure what a holly grail is, but it’s probably too Christmasy)
thanks, still needs more polish
want to jump on it next week again
I need good integration with IntelliJ
:simple_smile: Me too!
Cursive
Cursive is so amazing.
so you would connect via Cursive REPL and can let dirac “echo” commands you send into REPL from code editor
you know what I mean?
Really wish it were open source, would love to try to add boot support. I’ve spent 3 days playing with boot, and it’s so much simpler than the equivalent lein config.
@darwin: I couldn't get boot-cljs-repl
and dirac
working together in one project last I tried (quite recently) so not too sure it's possible.
It’ll output a project.clj with correct dependencies, etc.
So cursive’s lein support will ‘work'
boot is amazing, just don’t have energy to convert my lein setups to boot yet
but it’s not quite the same level of elegant integration
Well, just emitting a rudimentary project.clj
works well for me.
Except debugging (and it's hard for me to live without debugging), but not sure what's at fault here exactly.
Yeah, it’s working for me too. I need to put a watch trigger in intellij that generates the project.clj when build.boot changes.
even project.clj support is not perfect for me, I use lein profiles heavily and clojure does not understand them
I mean Cursive
so maybe generating project.clj is a pretty flexible solution, because now I have to jump through hoops to satisfy both lein and Cursive
I tell you though, I’ve been building web ‘applications’ since the perl/cgi days, and between this and devcards, I’m finally starting to think it might actually be something fun.
@smw: in IntelliJ? You can put that in a task like so - https://gist.github.com/jaen/17d555c45f067f080091 - and then just do:
(build-utilities/update-dependencies)
(build-utilities/lein-generate)
in the build pipeline.As a bonus
This automatically updates dependencies without having to restart the REPL
(modulo dependency clashes)
ahhhhhh
that’s brilliant!
Yeah, it's pretty nice.
At some point I would want to have everything run in a pod so I can' avoid even those dependency clashes
But that's rare enough I didn't care to do that yet.
But it's nice
You don't set dependencies in build.boot
but in resources/dependencies.edn
and it Just Works™.
Which is nice.
Yes, yes. That is really nice.
May I assume a liberal license on this? Or have you published it somewhere?
Yeah, I have it in my thesis repo, which is open — https://gitlab.com/jaen/thesis-code-new/blob/master/dev/build_utils.clj
Though I didn't think of giving any license on that to be honest.
Feel free to use it, it's nothing groundbreaking, just a bit more nicely wrapped snippet from boot wiki.
Thank you :simple_smile:
@smw so did you get dirac working with boot?
https://clojurians.slack.com/archives/dirac/p1457648308000375
This seems to work.
Though honestly I haven’t had much time to play with it, somehow I keep ending up on calls 😞
and disable boot-cljs-repl... i'll give it a try. which boot task calls start-dirac!
?
https://gitlab.com/jaen/thesis-code-new/blob/master/build.boot
None here, so I was doing it from the repl separately
my thought was to make a dirac-repl task
that does the same stuff my cljs-repl task does with dirac replaced
oh ok, make sense, i'll give it a try, thx!
If I get a chance to get that part working, I’ll paste a gist here