Fork me on GitHub
#biff
<
2024-04-18
>
adammiller19:04:00

I'm attempting to use biff inside the polylith structure. The biff web app is a base in polylith with corresponding project. However, I'd like to be able to start/stop the biff web app from an existing repl session instead of having biff start the system from the cli (to be more in line with the polylith workflow). Is there a documented way or something someone can point me to in how this can be accomplished?

Jacob O'Bryant19:04:57

Instead of running clj -M:dev dev, you can call the -main function from the repl: https://github.com/jacobobryant/biff/blob/146f2b1c8e0563bd288795851beae8b985cacac7/starter/src/com/example.clj#L86 to stop, see the first part of the refresh function: https://github.com/jacobobryant/biff/blob/146f2b1c8e0563bd288795851beae8b985cacac7/starter/src/com/example.clj#L90. you could extract that (the doseq) into a stop function. The clj -M:dev dev command also handles project init (e.g. creating a config.env file if there isn't already one) and starting up the tailwind watcher. For init you can just run clj -M:dev dev at least once when creating/cloning a project, and for the latter you can run clj -M:dev css --watch in a separate terminal. (see https://github.com/jacobobryant/biff/blob/146f2b1c8e0563bd288795851beae8b985cacac7/libs/tasks/src/com/biffweb/tasks.clj#L262)

Jacob O'Bryant19:04:07

actually you'll want to call start, not -main -- only difference is that -main starts up an nrepl server which you'll already have. also if it's helpful, you can run clj -M:dev nrepl to get an nrepl server without also doing the other stuff that clj -M:dev dev does.

adammiller20:04:35

Yeah I've generated the initial files by running clj -M:dev dev , then I'm simply starting a repl in calva from the polylith root and I try to run start but it just immediately kills my nrepl. No worries though, I can work around it for now. By the way, the Biff framework is awesome! I really appreciate the work you've put into it!

Jacob O'Bryant20:04:52

huh that's weird; not sure why it'd be killing nrepl. FWIW I just tried starting up the example project with clj -M:dev nrepl and then calling (start) and it worked as expected. glad to hear Biff's been helpful!

adammiller20:04:28

Ah yes, that method does work for me as well. That's a good compromise. Thanks so much!

🙌 1