babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
borkdude 2021-05-05T07:59:29.461700Z

Cool new library for CLI arg parsing. It works with babashka if you include spartan.spec: https://github.com/clj-clapps/clj-clapps/issues/1

borkdude 2021-05-05T08:49:54.462400Z

Should babashka have global tasks in <home>/.config/.babashka/bb.edn?

๐Ÿ‘ 3
Karol Wรณjcik 2021-05-05T08:55:57.462600Z

Definitely!

borkdude 2021-05-05T09:05:42.463500Z

I feel that the global tasks should be disjunct from the project specific tasks. I.e. you can't have a dependency in a project specific task on a global task or vice versa.

borkdude 2021-05-05T09:06:27.463900Z

So when you invoke bb foo and foo is in the local bb.edn, the global tasks will be ignored

borkdude 2021-05-05T09:06:45.464400Z

And vice versa, when you invoke bb global-foo, the local bb.edn will be ignored

borkdude 2021-05-05T09:07:04.464600Z

^ @orestis

2021-05-05T10:29:45.467Z

I agree with local vs global. What do you think about looking up bb.edn files in parent dirs? E.g. when I have parent/bb.edn and Iโ€™m in the dir parent/child and I invoke bb it would use the bb.edn of the parent dir (when the child dir doesnโ€™t have a bb.edn )

2021-05-05T10:30:43.467100Z

I think this would be helpful in bigger projects, but Iโ€™m curious if iโ€™m alone in this

borkdude 2021-05-05T10:31:40.467400Z

I think this can be conflicting with relative :paths so I would say let's avoid it for now

๐Ÿ‘ 1
borkdude 2021-05-05T10:32:13.467700Z

Maybe having a parent bb.edn and a local bb.edn can be useful in a mono-repo

borkdude 2021-05-05T10:32:44.467900Z

There is also the :init thing to think about :thinking_face:

2021-05-05T10:33:30.468100Z

yeah I can imagine things start to get complicated

borkdude 2021-05-05T10:35:06.468300Z

I think local :init would just override the global :init but if you would invoke a global task, that would depend on the global :init then... arg

๐Ÿ˜… 1
2021-05-05T10:35:28.468500Z

Iโ€™m experimenting with tools.deps in a monorepo indeed. Iโ€™m having 10+ local libraries now. I think the potential is great, but it is a bit off-putting if you have to copy the same files to get standard tasks. So for this it would be helpful. Iโ€™m not sure yet where this will go. Maybe Iโ€™ll find other ways to deal with this

borkdude 2021-05-05T10:41:17.470Z

It's already possible to include libraries in babashka so maybe that's the way to do it.

2021-05-05T10:42:12.471Z

yeah exactly Iโ€™m still figuring out what I really need

pithyless 2021-05-05T10:46:47.474800Z

I consider bb.edn a great entrypoint into a project, so I imagine there would be one for a monorepo (and using arguments / subcommands when needing to scope to certain submodules). Similarly, I'm not yet convinced about having global tasks, since (a) it would now be some external thing that is obviously not specific to a project entry-point, (b) any common logic between projects can (and probably should) be moved to clj code that can be imported by any bb.edn, (c) it complicates things like understanding some hidden dependency between project tasks and global tasks (e.g. even if the default behavior is "run local task if found" I would be very surprised if I expected to run my global task when typing bb some-funky-name-that-hopefully-no-project-uses

pithyless 2021-05-05T10:48:47.477Z

deps.tools has exactly the same problems with the confusion related to -Srepro and I think my concerns could be alleviated if babashka had a similar mode (but probably reversed the default). So perhaps bb foo will always run local foo (or fail) and something explicit like bb global foo will always run the global task (or fail)

borkdude 2021-05-05T10:49:24.477300Z

hmm bb run --global foo could work

borkdude 2021-05-05T10:49:45.477700Z

but I agree, the need for a global thing is maybe far fetched

borkdude 2021-05-05T10:50:03.478100Z

unless you have certain tools in your global deps.edn that you would like to have easy access to

borkdude 2021-05-05T10:50:13.478400Z

but then bb run --global foo is already too much to type

pithyless 2021-05-05T10:51:43.479500Z

if it's just a question of typing less, bb will never compete with the ubiquity and flexibility of a shell's alias ;]

borkdude 2021-05-05T10:52:34.480600Z

yeah, I agree, but it would be cool to have a cross platform way of aliasing, regardless of your shell

borkdude 2021-05-05T10:52:41.481100Z

so you could share your config on any computer

borkdude 2021-05-05T10:53:24.482200Z

e.g you have the clj-new alias in your deps.edn. Instead of typing clojure -M:new ... you could type bb new ..., I guess that doesn't add very much, I agree with this.

borkdude 2021-05-05T10:53:41.482500Z

and people who tend to be on *nix don't care about cross platform with Windows anyway

borkdude 2021-05-05T10:55:12.483900Z

I've also considered a global "script" dir for bb, I think that might be a better fit. e.g. ~/.config/babashka/scripts where it will look for files as a fallback and you could also install useful scripts from other places.

bb install com.github/foobar/webserver webserver
bb webserver

pithyless 2021-05-05T11:00:45.489200Z

yeah, one of the things that bugs me the most is the potential for name conflicts by using the implicit bb run foo vs bb foo - this problem would probably be exacerbated if you allow essentially supporting some arbitrary BB_SCRIPTS_PATH . It's a neat idea, but I'd feel better if it was explicit ala bb run --global webserver or eg. bb cmd webserver . Maybe even steal git's idea and just take advantage of the default PATH? Any executable named bb-webserver would immediately be a babashka package ala bb cmd webserver

pithyless 2021-05-05T11:01:30.490400Z

But this is all starting to sound pie-in-the-sky... I'm just happy we now have bb tasks for projects ๐Ÿ˜‰

borkdude 2021-05-05T11:01:50.490800Z

We can still revert to explicit bb run foo and remove bb foo

borkdude 2021-05-05T11:02:24.491500Z

The reason I went with bb foo is that it's more similar to make foo

pithyless 2021-05-05T11:02:25.491600Z

You'd have my sword, but it may be a very small fellowship. ๐Ÿ˜„

borkdude 2021-05-05T11:02:44.491800Z

bb run foo also works btw

pithyless 2021-05-05T11:03:27.492600Z

yeah, I'm aware; just if you allow bb foo and it becomes popular, you will never be able to take it back. :]

pithyless 2021-05-05T11:03:53.492900Z

I kind of assumed that ship had sailed already

borkdude 2021-05-05T11:04:33.493700Z

well, I'm close to an announcement of a "stable" bb tasks. so far I have tried to emphasize that this is still work in progress https://github.com/babashka/babashka/issues/778

borkdude 2021-05-05T11:05:01.494400Z

also the bb foo is inspired by lein foo where foo is a lein alias

borkdude 2021-05-05T11:05:23.494900Z

I think it's ok to allow it, while also offering escape hatches in case of conflicts

borkdude 2021-05-05T11:06:06.495900Z

The escape hatches:

Task: bb run foo
File: bb ./foo or bb -f foo
Subcommand: bb --foo

๐Ÿ‘ 1
borkdude 2021-05-05T11:06:37.496900Z

(file always has precedence, it's FILE > TASK> SUBCOMMAND)

pithyless 2021-05-05T11:10:09.499900Z

This brings me back to my original point - I'm not a fan, but it's borderline aesthetics and very small cognitive dissonance; and not a hill I plan to fight on; but if we start talking about global tasks that are outside of the existing project entrypoint that may also auto-resolve themselves, the chance for surprises and name collisions increases.

borkdude 2021-05-05T11:12:07.001600Z

As for resolving names, I don't think it will be a big issue, like with clojure: local wins over global. Global tasks bring other complexities I'm more worried about. Thanks for reinforcing that worry, I will probably not implement it. Like you said, a shell alias (or global script) is probably the better answer to global tasks.

๐Ÿ‘ 1
orestis 2021-05-05T11:41:58.003100Z

Having suggested something like global tasks, I agree that having them is not that important, since you can point bb to any bb.edn file regardless of your current directory.

orestis 2021-05-05T11:42:41.003500Z

Thanks for the idea of having global clj code that then your task can reference.

orestis 2021-05-05T11:43:17.004Z

BTW I may not be using babashka proper but I'm loving the utility libraries like babashka.fs ๐Ÿ™‚

orestis 2021-05-05T11:45:00.004500Z

Wait, how was I not sponsoring you before? Sponsoring now via our open source support project which I made up this year ๐Ÿ˜„

๐ŸŽ‰ 1
borkdude 2021-05-05T11:59:52.004700Z

Ooh, thank you!

Jakub Holรฝ 2021-05-05T15:11:52.005200Z

The httpkit server only supports http so if I need https then I have to use some proxy or something, right?

borkdude 2021-05-05T15:13:50.005600Z

you'd have to check the httpkit docs for this, don't know. #http-kit might know

๐Ÿ‘ 1
borkdude 2021-05-05T15:14:07.005900Z

I think I've read something like using nginx as a reverse proxy to do this

2021-05-05T15:14:37.006300Z

In case you run on AWS, the load balancer can do this for you

Jakub Holรฝ 2021-05-05T15:37:53.006500Z

Now, I'm trying to make CLI tool for OIDC end-user login :)

๐Ÿ‘ 1
emilaasa 2021-05-06T14:19:18.014200Z

It's a dirty job but someone has to do it ๐Ÿ™‚

kokada 2021-05-05T23:12:06.006600Z

Just to avoid confusion, does bb tasks always list the bb run <something> version?

kokada 2021-05-05T23:13:55.006900Z

BTW, I don't like this kinda of "trying to do the right thing depending of the context", I was bitten more than one time by people automatizing scripts and people not realizing that a simple PR adding a new parameters ended up shadowing the old usage of the program

kokada 2021-05-05T23:14:05.007100Z

And everything breaking horrible afterwards

kokada 2021-05-05T23:14:21.007300Z

But this is my 2c