dirac

Dirac v1.7.2 is out: https://github.com/binaryage/dirac/releases/tag/v1.7.2
2016-03-10T05:52:07.000363Z

Anyone have an example of boot + dirac agent? (as opposed to lein)

2016-03-10T10:53:56.000364Z

I believe @jaen is a boot user

jaen 2016-03-10T10:56:31.000365Z

Yeah. @smw, what do you have problems with?

2016-03-10T22:13:33.000366Z

@jaen: I’m just looking for a bit of example code that runs the agent integrated with something like boot-cljs-repl?

2016-03-10T22:13:41.000367Z

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)))

2016-03-10T22:14:07.000368Z

Dirac documentation suggests that you can’t use piggieback, as Dirac provides the same functionality.

2016-03-10T22:14:35.000369Z

boot-cljs-repl has

piggie-repl (partial repl :server true
                             :middleware ['cemerick.piggieback/wrap-cljs-repl])]

2016-03-10T22:15:02.000370Z

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.

2016-03-10T22:15:12.000371Z

I don’t mind trying to write such a thing, but I was hoping someone might have already done it.

2016-03-10T22:16:14.000372Z

your understanding is correct, you just need to replace piggieback with dirac middleware

2016-03-10T22:16:26.000373Z

unfortunately I don’t have personal experience with boot stack

2016-03-10T22:17:03.000374Z

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:

jaen 2016-03-10T22:18:28.000375Z

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.

jaen 2016-03-10T22:18:41.000376Z

And then I just call start-dirac! when I connect to boot REPL.

jaen 2016-03-10T22:18:43.000377Z

And that's it.

jaen 2016-03-10T22:19:14.000379Z

@smw: ^

2016-03-10T22:19:32.000380Z

Oh. Wow, that’s simple.

jaen 2016-03-10T22:19:36.000381Z

Remember to remove boot-cljs-repl tho

jaen 2016-03-10T22:19:41.000382Z

Otherwise it might clash.

2016-03-10T22:20:52.000383Z

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:

2016-03-10T22:21:29.000384Z

I guess not, because that’s part of webtools?

2016-03-10T22:21:34.000385Z

err, sorry,

2016-03-10T22:21:41.000386Z

I mean ‘part of dirac?'

jaen 2016-03-10T22:21:53.000387Z

You loose some, you gain some. But dirac gives you equivalent functionality to boot-cljs-repl.

2016-03-10T22:22:02.000388Z

Roger that. Thanks so much for the help.

jaen 2016-03-10T22:22:02.000389Z

Just inside the devtools.

jaen 2016-03-10T22:22:53.000390Z

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

jaen 2016-03-10T22:23:05.000391Z

At least the deps clashed for me if I didn't remove them all.

jaen 2016-03-10T22:23:25.000392Z

Otherwise this should Just Work™

jaen 2016-03-10T22:23:30.000393Z

If it won't, let me know.

jaen 2016-03-10T22:24:21.000394Z

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.

2016-03-10T22:27:19.000395Z

Oh. I have that part, mostly? I don’t think I have enable-feature!...

2016-03-10T22:27:36.000396Z

no, I do...

2016-03-10T22:27:46.000397Z

missing the set-pref

2016-03-10T22:27:51.000398Z

I think you should be able to run them side-by-side if you make sure that ports don’t clash

2016-03-10T22:27:53.000399Z

(devtools/enable-feature! :sanity-hints :dirac)
  (devtools/install!)

2016-03-10T22:28:01.000400Z

Is that equivalent?

2016-03-10T22:28:07.000401Z

that’s equivalent

2016-03-10T22:28:09.000402Z

Thanks.

2016-03-10T22:28:51.000403Z

I’m so psyched about this. Thanks for this work! This really does seem like the holy grail.

2016-03-10T22:29:15.000405Z

(not sure what a holly grail is, but it’s probably too Christmasy)

2016-03-10T22:29:48.000407Z

thanks, still needs more polish

2016-03-10T22:30:00.000408Z

want to jump on it next week again

2016-03-10T22:30:53.000409Z

I need good integration with IntelliJ

2016-03-10T22:31:00.000410Z

:simple_smile: Me too!

2016-03-10T22:31:04.000411Z

Cursive

2016-03-10T22:31:10.000412Z

Cursive is so amazing.

2016-03-10T22:31:37.000413Z

so you would connect via Cursive REPL and can let dirac “echo” commands you send into REPL from code editor

2016-03-10T22:31:44.000414Z

you know what I mean?

2016-03-10T22:32:05.000415Z

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.

jaen 2016-03-10T22:32:17.000416Z

@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.

2016-03-10T22:32:21.000417Z

It’ll output a project.clj with correct dependencies, etc.

2016-03-10T22:32:36.000418Z

So cursive’s lein support will ‘work'

2016-03-10T22:32:44.000419Z

boot is amazing, just don’t have energy to convert my lein setups to boot yet

2016-03-10T22:32:53.000420Z

but it’s not quite the same level of elegant integration

jaen 2016-03-10T22:33:19.000421Z

Well, just emitting a rudimentary project.clj works well for me.

jaen 2016-03-10T22:33:54.000422Z

Except debugging (and it's hard for me to live without debugging), but not sure what's at fault here exactly.

2016-03-10T22:33:57.000423Z

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.

2016-03-10T22:33:58.000424Z

even project.clj support is not perfect for me, I use lein profiles heavily and clojure does not understand them

2016-03-10T22:34:04.000425Z

I mean Cursive

2016-03-10T22:34:45.000427Z

so maybe generating project.clj is a pretty flexible solution, because now I have to jump through hoops to satisfy both lein and Cursive

2016-03-10T22:36:47.000428Z

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.

😁 1
jaen 2016-03-10T22:38:01.000429Z

@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.

jaen 2016-03-10T22:38:06.000430Z

As a bonus

jaen 2016-03-10T22:38:17.000431Z

This automatically updates dependencies without having to restart the REPL

jaen 2016-03-10T22:38:24.000432Z

(modulo dependency clashes)

2016-03-10T22:38:24.000433Z

ahhhhhh

2016-03-10T22:38:29.000434Z

that’s brilliant!

jaen 2016-03-10T22:39:08.000435Z

Yeah, it's pretty nice.

jaen 2016-03-10T22:39:31.000436Z

At some point I would want to have everything run in a pod so I can' avoid even those dependency clashes

jaen 2016-03-10T22:39:45.000437Z

But that's rare enough I didn't care to do that yet.

jaen 2016-03-10T22:40:18.000438Z

But it's nice

jaen 2016-03-10T22:40:39.000439Z

You don't set dependencies in build.boot but in resources/dependencies.edn and it Just Works™.

jaen 2016-03-10T22:40:42.000440Z

Which is nice.

2016-03-10T22:41:00.000441Z

Yes, yes. That is really nice.

2016-03-10T22:41:20.000442Z

May I assume a liberal license on this? Or have you published it somewhere?

jaen 2016-03-10T22:42:41.000443Z

Yeah, I have it in my thesis repo, which is open — https://gitlab.com/jaen/thesis-code-new/blob/master/dev/build_utils.clj

jaen 2016-03-10T22:43:01.000446Z

Though I didn't think of giving any license on that to be honest.

jaen 2016-03-10T22:43:23.000447Z

Feel free to use it, it's nothing groundbreaking, just a bit more nicely wrapped snippet from boot wiki.

2016-03-10T22:45:31.000448Z

Thank you :simple_smile:

2016-03-10T23:29:19.000450Z

@smw so did you get dirac working with boot?

2016-03-10T23:29:49.000453Z

This seems to work.

2016-03-10T23:30:16.000454Z

Though honestly I haven’t had much time to play with it, somehow I keep ending up on calls 😞

2016-03-10T23:34:12.000455Z

and disable boot-cljs-repl... i'll give it a try. which boot task calls start-dirac! ?

2016-03-10T23:35:00.000458Z

None here, so I was doing it from the repl separately

2016-03-10T23:35:23.000459Z

my thought was to make a dirac-repl task

2016-03-10T23:35:44.000460Z

that does the same stuff my cljs-repl task does with dirac replaced

2016-03-10T23:36:47.000461Z

oh ok, make sense, i'll give it a try, thx!

2016-03-10T23:37:08.000463Z

If I get a chance to get that part working, I’ll paste a gist here

👍 1