Fork me on GitHub
#boot
<
2017-01-31
>
geoffs00:01:03

can you do the same thing from the repl?

geoffs00:01:16

or rather, another task definition?

geoffs00:01:57

👍 awesome

micha00:01:58

@geoffs it's a little bit tricky in some ways, because it will still parse options

micha00:01:23

i mean it's the same as usual for cli parsing, but there is a lot going on in there

micha00:01:45

so you might need to do like boot [ task --flag -- --this-is-not-an-option ]

geoffs00:01:51

right, i've seen some of the discussion around that. luckily I don't need to pass anything except a port number 🙂

micha00:01:03

the -- in there would indicate an end to options

micha00:01:18

if you want a positional parameter to start with -

micha00:01:45

otherwise it will give a unrecognized option: --this-is-not-an-option

geoffs00:01:04

It seems like all this would be useful info to have in the task author's wiki page. I might edit that in later if that's alright

micha00:01:40

that would be amazing

geoffs00:01:55

maybe with a big fat "here be (smallish) dragons" at the top of the section

micha00:01:17

haha right

micha00:01:38

it's not crazy, it's just easy to overlook things with all the nested arguments going on

micha00:01:19

you should be able to just pass positional arguments in the normal clj apply fashion

micha00:01:41

like (boot (mytask :flag true "--this-is-not-an-option"))

micha00:01:54

note that the positional parameters need to be strings

micha00:01:06

well actually not really

micha00:01:09

they're untyped

micha00:01:15

but from the command line they will be strings

geoffs00:01:36

and so if you pass positional arguments through from a wrapper deftask to the inner deftask they'll still be strings...

micha00:01:01

i think in clojureland they'll be whatever you pass

micha00:01:17

it's just from the command line it will just pass strings

geoffs00:01:52

yeah. We're on the same page. I'm just doing this:

(deftask smoke-test []
  (comp
   (build)
   (testing)
   (apply run :namespace 'project.dev-main *args*)
   (wait)))

geoffs00:01:13

where run is a task I defined to run an arbitrary clojure namespace

geoffs00:01:55

I'm a little surprised that I need the wait in there, because I thought my main function in project.dev-main would block...

geoffs00:01:03

thanks again! I'll try to find some time soon to pull all this info into the wiki 🙂

micha00:01:16

i think there is a small bug in there

micha00:01:22

i mean in the cli parsing stuff

micha00:01:29

boot.user=> (deftask foop []
       #_=>   (with-pass-thru _
       #_=>     (prn {:opts *opts* :args *args*})))
#'boot.user/foop
boot.user=> (boot (foop [1 2 3]))
boot.user=> java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.CharSequence
boot.user=> (boot (foop "--" [1 2 3]))
{:opts {}, :args ([1 2 3])}
nil

micha00:01:00

it shouldn't throw an exception there

micha00:01:15

because it can know if there is a keyword or not

micha00:01:43

so that's kind of a bummer

micha00:01:59

but the workaround is to add a "--" in the arguments to the task

geoffs00:01:11

oooh. interesting

lxsameer09:01:23

hey folks, what is the best solution for parallel task invocation in boot ?

dm311:01:49

@lxsameer there's boot.pipeline or something to that effect

dm311:01:16

how does one override the built-in tasks in Boot?

dm311:01:31

is there some sort of exclude thing?

dm311:01:12

or do I alter-var-root

juhoteperi11:01:09

This should be quite general way to pass exceptions task pods to main pod: https://github.com/boot-clj/boot-cljs/commit/af670d3acff6990b7ba256d7ae0d12b82b744948 @micha @richiardiandrea

juhoteperi11:01:52

Though I best test what happens if I send Less4JError or something from pod to main pod, when the class is not available in main classloader

juhoteperi12:01:04

java.io.NotSerializableException: com.github.sommeri.less4j.core.problems.GeneralProblem
clojure.lang.Compiler$CompilerException: java.io.NotSerializableException: com.github.sommeri.less4j.core.problems.GeneralProblem, compiling:(adzerk/boot_cljs/util.clj:71:5)
Oh no 😞

richiardiandrea16:01:40

Can they be passed among pods?

juhoteperi16:01:53

Exceptions yes, all Throwables are Serializable, but custom exceptions can refer other objects that are not necessarily serializable

juhoteperi16:01:13

Clojure datastructures should also be Serializable, at least all I tested

juhoteperi16:01:23

also File etc. basic Java classes

richiardiandrea16:01:51

So @juhoteperi is it a good for porting it to boot-figwheeu? Is it only in Snapshot

juhoteperi16:01:08

Yeah, should work fine for Cljs use-case

juhoteperi16:01:39

Hmm, but Figreload doesn't really need to serialize&deserialize the exceptions?

juhoteperi16:01:48

Only to create Figwheel compatible map from the exception

juhoteperi16:01:48

@richiardiandrea I think the Figreload serialize-exception is probably fine as is, the use-case there is different to boot-cljs

richiardiandrea16:01:55

@juhoteperi i thought you changed also the way to save them in the meta

richiardiandrea16:01:14

I see now that you did not 😄

juhoteperi16:01:17

Ah no, the latest change shouldn't change them from the yesterdays version, and even that shouldn't have changed it much

richiardiandrea16:01:24

@juhoteperi would you be OK in recursively change the :file key in the exception

richiardiandrea16:01:54

Either that or I need to ask Bruce 😄

juhoteperi16:01:14

You can do that quite easily in Figreload side also

richiardiandrea16:01:21

For some reason the :file is absolute

juhoteperi16:01:00

Take the :file from first ex-data and overwrite :file inside recursive calls with that

richiardiandrea16:01:31

But isn't a bit inconsistent that one file is relative and all the others absolute ?

juhoteperi16:01:34

It would have been easy to do in Boot-cljs with the previous implementation, but currently I don't walk the cause stack through at all but only pass all the exceptions as is

juhoteperi16:01:49

Hmm not really

juhoteperi16:01:59

The absolute paths are from the original Cljs exceptions

juhoteperi16:01:09

Only the top-most exception from Boot-cljs has the relativized path

richiardiandrea16:01:44

Mmm also probably it will be solved on the compiler side, I saw the discussion on #cljs-dev

richiardiandrea16:01:39

Ah OK so if that is the reason, I could throw the first away

richiardiandrea16:01:09

If you create one on top of the compiler ones I mean

juhoteperi16:01:24

Sure, you can do that

juhoteperi16:01:32

But the I guess you'll see the absolute path

richiardiandrea16:01:39

But that would not solve anything lol

juhoteperi16:01:00

(defn serialize-exception'
  [e file]
  {:class (-> e type .getName)
   :message (.getMessage e)
   :data (cond-> (safe-data (ex-data e))
           file (assoc :file file))
   :cause (when-let [cause (.getCause e)]
            (serialize-exception cause (or file (:file (ex-data e)))))})

(defn serialize-exception
  [e]
  (serialize-exception' e nil))

richiardiandrea16:01:08

K cool I will go for a custom walk (which I already doing anyways)

juhoteperi16:01:32

^ I think something like that would work. Probably can be done even simpler.

juhoteperi16:01:53

perhaps check to only assoc :file if ex-data is not nil

richiardiandrea16:01:13

Yeah just maybe I would override only if relative is included on the absolute

richiardiandrea16:01:34

Yeah and the nil check as well

richiardiandrea16:01:14

@juhoteperi last question for you 😀 figwheel detects when deps.js is changing I think and send a big eval command when it does, would it be something useful to add on our side? I find it quite useful if we will be watching node_modules at some point

juhoteperi16:01:24

Probably. I haven't yet tried to do real work with new features so I don't know how the workflow is and what happens without that.

juhoteperi16:01:48

If foreign-lib JS in fileset changes, boot-reload would reload that, I think.

juhoteperi16:01:00

Because boot-reload watches for changed JS files.

richiardiandrea16:01:19

Oh OK, I don't remember having seen that, I will double check again, maybe it is easier than I thought then

kenbier18:01:46

im wondering if its possible to connect to a datomic database created in one boot task from another. currently i am having trouble doing this, and keep getting an error: actual: clojure.lang.ExceptionInfo: :db.error/db-not-found Could not find db-fixture in catalog

kenbier18:01:14

our boot task looks like this:

kenbier18:01:43

(deftask build-test-system
  []
  (comp
   (environ :env test-env)
   (sass :output-style :compressed)
   (sift :move {#"app.css" "public/app.css"})
   (cljs :optimizations :advanced
         :compiler-options {:devcards        true
                            :externs         ["src/client/externs/app.ext.js"]
                            :closure-defines {"goog.DEBUG" false}}
         :ids #{"public/combined"})
   (run :main-namespace "arc.core" :arguments [#'prod-system])))

(deftask test-all []
  (comp
   (build-test-system) ;; Where we compile
   (test) ;; Where the failure is, we try to connect to the db in an integration test
   (test-cljs :keep-errors? true)
   (compare-screenshots :solano true)
   (report-errors!)))

kenbier18:01:08

basically we compile and call run in the build-test-system task, and that starts an in memory database. then in the test we run some integration tests, that want to connect to the database using d/connect

kenbier18:01:51

the uri i pass in looks correct, its just not finding the database even though it still exists

geoffs20:01:41

@kenbier if test is from boot-test I believe that runs your tests inside a pod, so it’s running in a totally different invocation of clojure. Not sure how datomic memory databases work, but I bet that’s why it’s not working.

kenbier20:01:23

test is from boot-test, yes

geoffs20:01:25

To me that seems like you’re really mixing concerns though. If you need to start your prod-system for the tests, then do that in the tests.

kenbier20:01:41

thats fair

kenbier20:01:47

im not as familiar with pods as i should be, admittedly

kenbier20:01:40

if i were to do that, i would have make a task that starts my prod-system and then run the tests on the same fileset?

kenbier20:01:55

or i suppose i could try starting the prod-system in one of the test files themselves, that might be even simpler than trying to make a new task out of boot-test/test that also starts my system. ill try that for now, thanks @geoffs.

geoffs20:01:55

yeah, that was actually what I was thinking of 👍

geoffs20:01:03

to start your system in a separate task you’d probably have to reimplement the internals of boot-test to some degree, I don’t think there’s a way to just run some code inside the pod that it is going to run your tests in.

kenbier23:01:17

geoffs: so your suggestion helped, just starting my system in the first test worked 🙂

kenbier23:01:35

i couldn’t get it to work though. i have a simple function with no args that i want to pass in as a startup, but it complains it cant find it when it comes time to evaluate it

kenbier23:01:06

fails there. i wonder why that is

geoffs02:02:04

ah, what are you passing in there?

geoffs02:02:28

You probably want to do it something like:

:startup '[(do (require ‘arc.core) (arc.core/prod-system)])

geoffs02:02:48

actually, you want

(test :requires '#{arc.core}
      :startup '#{arc.core/prod-system})

geoffs02:02:18

assuming that arc.core/prod-system is a function that takes no arguments and starts the system.

geoffs02:02:15

If you’re using component and that’s actually a component map I would write a little helper function that just does all the startup stuff.

kenbier18:02:19

@geoffs ah just saw this. thats a good idea, ill try that.

kenbier18:02:31

we are using component yes, and system around it too.

kenbier18:02:13

totally missed the requires options, thanks!

adamfrey21:01:07

I have a boot task where I’m transforming my index.html file from the fileset and committing it as a resource https://github.com/AdamFrey/boot-asset-fingerprint/blob/master/src/afrey/boot_asset_fingerprint.clj#L38-L54. My file is transformed correctly in the target directory when I run my task, but the untransformed file is served from boot-http. Does anyone have an thought of why that’s happening?

juhoteperi21:01:03

@adamfrey Is your serve task after asset-fingerprint

micha21:01:25

ah yeah good question

micha21:01:26

what happens if you make a task to debug print the contents of the file from the classpath?

micha21:01:33

(vs. from the fileset)

adamfrey21:01:59

I’ll check

adamfrey21:01:05

I found a fix. In this line: https://github.com/AdamFrey/boot-asset-fingerprint/blob/master/src/afrey/boot_asset_fingerprint.clj#L10 I was finding my source files with core/output-files but I needed to be using core/input-files.

adamfrey21:01:40

thanks for your help juho and micha

adamfrey21:01:37

hmm, maybe not. I thought I had a reproducible fix, but now it’s back to broken.

adamfrey21:01:28

@micha when I call this task right before my serve task it prints the transformed file, but I still get the old version from curling the server

(deftask check []
  (with-pass-thru [_]
    (prn (slurp (io/resource "index.html")))))

juhoteperi21:01:50

@adamfrey What serve options are you using?

juhoteperi21:01:26

Hmm, it should be trying to serve files from classpath root by default

adamfrey21:01:00

I switched to your boot-alt-http and now my options are (serve :port 3000 :prefixes #{””})

juhoteperi21:01:04

Looking at asset-fingerprint, you empty the tmp-dir each time, but only write the changed files to tmp dir

juhoteperi21:01:18

So when you change any files, tmp-dir is emptied but no html files get written

adamfrey21:01:17

oh I didn’t notice that empty-dir! call

adamfrey21:01:50

that looks like the problem

adamfrey21:01:30

I don’t need to empty the tmp-dir at all, right?

juhoteperi21:01:12

Probably not. If you remove some html files from your source/resource-paths, the results from those will be left to tmp-dir, but usually that is not a problem.

juhoteperi21:01:23

Boot-cljs/less/sass just don't care about deleted files

micha21:01:45

also there is boot.core/fileset-removed if you want to handle that case

adamfrey21:01:43

Thanks so much guys

qqq23:01:28

anyone know of a good tutorial for boot/om-next ? all the om tutorial I find are lein based

kenbier23:01:36

qqq: i remember when it first came out i went through https://github.com/awkay/om-tutorial

kenbier23:01:39

it was helpful

kenbier23:01:52

also if you are open to a lightweight framework, checkout untangled!

kenbier23:01:08

there is a channel that you can ask questions in, and everyone is very helpful

richiardiandrea23:01:10

^ @juhoteperi this is why I wanted to handle it at the source 😄 now it is done anyways 😄