Fork me on GitHub
#babashka
<
2022-02-17
>
escherize05:02:16

Pleased to announce an installation script for https://github.com/escherize/quick-question. Run the installation script (or install it on your own). Then you can use those beautiful interactive prompts (my favorites are autocomplete and multi-select) in your scripts. Here’s the installation script: https://asciinema.org/a/w0qaYpsSofJa2FQp21FlgYith?i=1

🎉 1
escherize05:02:27

Thanks to a few of you in here who helped me get this together. @U04V15CAJ of course, and also @U11BV7MTK 😎

dpsutton05:02:51

all i did was watch in amazement 🙂

james10:02:53

Very nice. btw I think the install script need to be changed to

(fs/exists? ".qq") # was (fs/exists? "quick-question")

👍 1
escherize15:02:58

Thanks I’ve fixed it.

Steffen Glückselig08:02:46

Concerning Tasks - I don't understand the difference between :init and :enter - both seem to be executed before each individual task? How would one do a init-before-all?

borkdude08:02:08

:init is executed before all

Steffen Glückselig08:02:33

Is there a difference then between tasks that are executed via :depends and run?

borkdude08:02:37

Except that with parallel the order of dep runs is undefined

Steffen Glückselig08:02:13

Ok - but :init should still be called just once? Calling this

Steffen Glückselig08:02:25

{:paths [src]
 :tasks {:init (println "INIT")
         :enter (let [task-name (:name (current-task))]
                  (println "Entering:" task-name))
         integrate {:depends [jenkins:lovoonl-backend]}
         jenkins:lobeda-backend {:task (println "")}
         jenkins:lobeda-ui {:task (println "")}
         -jenkins:lobeda-ui-and-backend {:depends [jenkins:lobeda-backend jenkins:lobeda-ui]}
         -source:lovoonl-frontend {:task (do)}
         source:lovoonl-frontend {:task (do
                                          (run '-jenkins:lobeda-ui-and-backend {:parallel true})
                                          (run '-source:lovoonl-frontend))}
         jenkins:lovoonl-frontend {:task (do
                                           (run 'source:lovoonl-frontend))}
         jenkins:lovoonl-backend {:depends [jenkins:lovoonl-frontend]}}}

Steffen Glückselig08:02:41

via bb --config lovoonl-orch_test.edn integrate I get

INIT
Entering: jenkins:lovoonl-frontend
INIT
Entering: source:lovoonl-frontend
INIT
Entering: jenkins:lobeda-ui

Entering: jenkins:lobeda-backend

Entering: -jenkins:lobeda-ui-and-backend
INIT
Entering: -source:lovoonl-frontend
Entering: jenkins:lovoonl-backend
Entering: integrate

borkdude08:02:35

init should be called once yes... this seems like a bug, let me try locally

borkdude08:02:52

thanks, I can reproduce locally

borkdude09:02:18

this has probably been in here for a while but since init usually only contains functions and constants, nobody noticed

borkdude09:02:50

ah, it is due to run, I get why this happens now

borkdude09:02:00

but it's still a bug :)

borkdude09:02:59

A workaround for now is to put your init code in a file on the classpath

borkdude09:02:13

and then use :requires, where you require / load that file

👍 1
borkdude09:02:23

and since that is idempotent, the code will only run once

Jakub Holý (HolyJak)12:02:14

Can I use grasp from bb as a library? I guess I would need to use st. instead of clojure.spec.alpha ?

borkdude12:02:52

grasp doesn't work in babashka.

👍 1
😭 1
borkdude12:02:31

what is st?

Jakub Holý (HolyJak)13:02:10

sorry for being so lazy, st. = something

Jakub Holý (HolyJak)13:02:28

I will use the binary distribution then

borkdude14:02:42

@holyjak You can use it as a JVM library too.

👍 1
borkdude14:02:51

I will retrigger the mac build for a binary

🙏 1
borkdude16:02:26

hmm, weird!

borkdude16:02:50

ok, now it's running

🙏 1
Stas Makarov15:02:37

i’m having issues with cider-jack-in-clj and bb.edn with dependencies defined in a task:

{:paths ["script"]
 :tasks
 {pre-push
  {:extra-deps
   {org.clojure/tools.namespace
    {:git/url ""
     :git/sha "a13b037215e21a2e71aa34b27e1dd52c801a2a7b"}}}}}
when i run cider-jack-in-clj and choose babashka it works, but when i’m evaluating a ns with deps from tasks it fails with Could not find namespace. moving dependencies from :tasks to the top level :deps works, but i wonder if there’s any other solution?

borkdude15:02:59

Hi! I'm not sure if I get your question. What are you exactly evaluating in CIDER?

Stas Makarov16:02:01

hey! thanks for the quick reply! i’ve just updated original snippet of bb.edn. It has everything to reproduce the issue. I’m evaluating (with cider-eval-buffer) script/pre-push.cljc with the following content:

(ns pre-push
  (:require
    [ :as io]
    [clojure.tools.namespace.find :as ns-find]
    [clojure.tools.namespace.parse :as ns-parse]))

(defn parse-ns-decl [ns-decl]
  {:ns   (ns-parse/name-from-ns-decl ns-decl)
   :deps (ns-parse/deps-from-ns-decl ns-decl)})

(comment
  (->> "./src/backend"
       io/file
       ns-find/find-ns-decls-in-dir
       (map parse-ns-decl))
  )

borkdude16:02:43

This makes sense. Yeah, you need to either add the deps on the top level, or evaluate (babashka.deps/add-deps '{:deps { ... }}) once in the REPL with the deps

Stas Makarov16:02:49

thank you! ps: babashka rocks, it awesome to have running repl in milliseconds! 🙂

❤️ 1