I haven't thought this through all the way, but I'm curious if anyone has done a robust-ish "direnv task-runner type thing" with bb tasks. The idea I had would be that if I'm in a terminal at path /a/b/c, and I run [blub] test, then blub would find the nearest parent bb.edn (or something) with a test task and bb run it, maybe with a flag or an option on the task or something that'd run it in the context of the directory where the bb.edn lives.
I've been looking at/experimenting with this idea at the shell level, but I figured if I could do it with bb, then the shell wouldn't be as much of a dependency, and it might be another way to get some people on my team to install bb, and of course I could write things in clojure.
I was thinking about stealing concepts from editorconfig, like a setting for a 'root' task file that would stop any further upward traversal looking for tasks.
We've been using Mise as a "direnv task-runner type thing", which works as a package manager too, so that Mise is the thing that pulls in babashka. So I do
mise bb deploy
to deploy the current project. Or mise //apps/some-app bb deploy to deploy some other app in the monorepo. I'm pretty happy with that :^)I was looking at mise - from reading the docs, my initial impression was that it wants to sort of be 5 different things, which is not oberly appealing to me. But, I'll look at it a bit more closely.
Maybe relevant discussion: https://github.com/babashka/babashka/discussions/1044
this setup may also work: https://github.com/just-sultanov/bb-modules
perhaps that's what @post972 is using too
I'm using Mise instead of direnv, but ig it works similarly 😄
that seems pretty close... I might give it a shot... I wasn't thinking as much about monorepos as just the fact that I might be 3 directories down in a project and wanting to run something like an annoying maven command line from the root, which might be doable with just direnv and a wrapper that calls bb with the root's config file.
ah right. yeah, the thing is that scripts can rely on the current working directory and bb can't change it (JVM restriction). so automatically invoking tasks from the nearest parent directory comes with that kind of confusion. leiningen does allow invoking itself from a sub directory (and when you have stuff that relies on cwd, it will probably fail?). clojure CLI doesn't allow it
oh look. leiningen does change the cwd.
borkdude@MBP25-2 ~/dev/clj-kondo/src (hiccup) $ lein test
==== Testing JVM version 1.10.3
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.
"/Users/borkdude/dev/clj-kondo" perhaps the lein bash script does this
this feels a little bit hacky, but I was honestly just kind of thinking about basically shelling out to bb run with a :dir
that sounds reasonable
I might just mess around with a little prototype thing to see what comes up, and maybe mess around with some ideas for subdirectories as well - I figure that'll almost definitely need add'l config to avoid endlessly scanning trees, but maybe it could also serve as a bit of a testbed for experimenting if there's an appetite to include stuff from that GH discussion into bb proper in the future
It seems there are two opposite things here. The GH discussion is more about mono-repos where you invoke tasks from a subdirectory. The thing you're looking for is invoking tasks from a parent directory, right? How could bb support both at the same time? I'm going to take some 💤 , will look back tomorow
Good night! 💤