This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-27
Channels
- # announcements (13)
- # asami (12)
- # babashka (65)
- # beginners (62)
- # calva (14)
- # cider (8)
- # clara (11)
- # clj-kondo (16)
- # clojure (86)
- # clojure-europe (12)
- # clojure-gamedev (4)
- # clojure-nl (2)
- # clojure-sg (4)
- # clojure-uk (5)
- # clojurescript (206)
- # clojureverse-ops (11)
- # community-development (7)
- # conjure (12)
- # core-async (2)
- # core-logic (13)
- # cursive (49)
- # datalevin (1)
- # datomic (30)
- # deps-new (3)
- # duct (8)
- # events (5)
- # fulcro (10)
- # helix (5)
- # jobs (1)
- # klipse (5)
- # lsp (178)
- # luminus (1)
- # malli (8)
- # meander (3)
- # membrane (13)
- # missionary (1)
- # nrepl (5)
- # other-languages (4)
- # pedestal (4)
- # reitit (3)
- # releases (1)
- # reveal (27)
- # shadow-cljs (89)
- # tools-build (6)
- # tools-deps (11)
- # vim (2)
- # xtdb (64)
This one right? (I lost the timing): https://news.ycombinator.com/item?id=28982952
one issue I have with bb tasks and I hope it gets improved is that bb.edn files are spread across the monorepo and people don't know about the tasks available to them.
Drawing inspiration from gradle (that also has tasks) - it has the concept of sub-projects and it can include other builds thus making all tasks accessible from the root via a path - :my-subproject:my-task ( uses semicolon for path separator).
Can babasha tasks support something like this ?
Should I open an issue ?
I woule like to be in monorepo root, do bb tasks
and get tasks that are in other subprojects.
Also I should be able to call those tasks from the root and they should be executed properly (as from their own dir).
Making the tasks available could be done via am include/require mechanism or a dir scan with filters (path is ~ namespace).
( I would pick include and maybe scan could be implemented in lib that produces a list of require bb files)
wdyt?
@U9ES37CSZ has a similar request recently:
This is what I replied:
> Hey there! Can you please let me know if it's possible to have two projects sitting next to each other, with a `bb.edn` file in each of them, and one project's tasks to depend on tasks from the other project?
> This is currently not yet supported (similar to how you cannot do this with Makefiles). But you can have one root `bb.edn` and use `:dir` to execute shell and clojure commands in subdirectories, if that helps
It might be worth exploring but it comes with additional complexities so there is a trade-off between additional complexity and convenience.
• The classpaths from both bb.edns should be made absolute (src becomes an absolute directory) and appended
• :init
fragments should be concatenated?
Also there are very likely to be naming clashes between tasks. E.g. in the repo you are speaking of there are a couple of dev
tasks. If you merge those, which dev
task will you pick? You will pick one and lose the others.
ok, but even then. in the DRE monorepo, if you execute bb dev
, there are three tasks in those sub dirs
of course, it's tempting to have the approach you described, and it's more pwerfull in some scenarios - but it comes with stuff attached
as a convenience if you have only one dev
task in all your subprojects you could call that by short name
@U011NGC5FFY Let's post this idea in Github Discussions so we can think about it and more people can chime in. This may sound easy but I'm sure it comes with edge cases, I'm mostly worried about those, before settling on anything. This specific feature is probably something you can build using a root bb.edn
that has one task per repo and gives an overview of the specific repo + the option to invoke a task in that repo.
{:tasks {:requires ([clojure.string :as str])
app {:doc "Without arguments, prints tasks in app - with arguments, invokes task in app dir"
:task (if (empty? *command-line-args*)
(shell {:dir "app"} "bb tasks")
(shell {:dir "app"} (str "bb run " (str/join " " *command-line-args*))))}}}
@U011NGC5FFY I added one now in the DRE repo. Type bb app
in the root and e.g. bb app dev
I really like Eugen's idea about
build
publish-image
app:build
app:publish-image
We do something like this already with a Python task runner and it works really well. Happy to take part in the GitHub discussion too 👍@U9ES37CSZ With the above snippet you get:
bb app ;; prints app tasks
bb app build
bb app publish-image
This is literally 5 lines in user spaceBabashka on the technology radar of ThoughtWorks : https://www.thoughtworks.com/radar/platforms/babashka :-)
bb
is already really a game changer for me. Being able to code with the comfort of clojure in this "scripty" niche is immensely liberating. And it works well + the creator is available on slack for questions 😛
Hi, not sure if it is really related to babashka but i am playing around with it and have an issue. I have this code:
(defn -main
[& args]
(let [{:keys [options arguments errors summary]} (parse-opts args cli-options)
package-name (:name options)]
(selmer/set-resource-path! templates-path)
(map (fn [[in out]]
(spit out (selmer/render-file in {:package-name package-name})))
[["deps.edn.template" "deps.edn"] ["build.xml.template" "build.xml"]])
(println "done " package-name)))
When I run the executable I get:
~/w/babashka-scripts ./script.clj --name TestTest
done TestTest
but my files, deps.edn and build.xml, are not created. What am i missing?@UBTMXD33J map
is lazy, for causing side effects you could use run!
or realize the lazy sequence with doall
but if you do not use the result then run!
or doseq
is better
since ssh does not exit on its own anything i try with process ends up blocking and not printing
Try this:
bb -e '(-> (babashka.process/process ["ssh" "user@host"] {:in "ls" :out :string}) deref :out)'
just tried. perfect. thanks so much @U04V15CAJ
cool. Note that you can use :out :inherit
if you just want to print the output from ssh as you execute it
each call to process
will create a new OS process so it will result in a new ssh session
Like this:
(require '[babashka.process :refer [process]]
'[ :as io])
(let [ssh-process (process ["ssh" "user@host"] {:out :inherit})
in (:in ssh-process)]
(with-open [in (io/writer in)]
(binding [*out* in]
(println "ls")
(println "whoami")))
(deref ssh-process))
nil
I went down a rabbit hole exploring babashka pods.. bb
<> pod process
communication architecture using bencode
., bencode
protocol and it usage outside of Torrent protocol.. nREPL
... Because of my limited experience with bencode
I am strangling to understand why bb
uses bencode
even though payload is edn
/`json` ?