Fork me on GitHub
#boot
<
2015-12-30
>
magomimmo00:12:29

#C03S1KBA2 #C03S1L9DN #C053K90BR just published the 18th Tutorial of the modern-cljs series. It uses the TDD environment augmented with the REPLs. https://github.com/magomimmo/modern-cljs/blob/master/doc/second-edition/tutorial-18.md

magomimmo00:12:53

Happy new year to all of you. I’m going on vacation simple_smile

alandipert00:12:15

happy new year to you also! enjoy your vacation

fappy02:12:56

hello. I'm trying to get automatic testing going with boot-cljs-test ... I copied the example project, changed js-env to node insetad of phantom, and made the target nodejs. But when it runs tests, it thinks there are 0 tests instead of one. My small repo is at https://github.com/frankhenderson/boot-cljs-test-question Could someone tell me what I'm doing wrong?

escherize05:12:51

Is there a way to start a boot repl and interactively require libraries?

fappy05:12:53

The example I started with was boot-cljs-example https://github.com/adzerk-oss/boot-cljs-example

escherize05:12:50

Like, sometimes I just want to do some throw-away work like scraping - would be nice to be able to say... (dep-search enlive) and have it list lein coordinates like '[enlive "1.6"] and the library's namespaces like '[enlive.core enlive.html ,,,]

micha05:12:37

you can do boot -d enlive repl

micha05:12:42

if that's what you mean?

micha05:12:17

you can also use the RELEASE version

micha05:12:47

like (merge-env! :dependencies '[[enlive "RELEASE"]])

seancorfield06:12:29

@escherize: You can just run (set-env! :dependencies #(conj % '[some.new/dependency "1.0.5"])) in the repl and it will download it and make it available.

seancorfield06:12:04

(I was a bit surprised that worked, but I just tried it)

seancorfield06:12:40

I don't know of a shortcut to figure out the latest version tho'...

escherize06:12:00

Thanks a lot guys

micha06:12:45

[foo/bar "RELEASE"] will get you the latest release version

micha06:12:11

[foo/bar "(0,)"] will get you the latest latest, including SNAPSHOTs

micha06:12:54

like literally typing RELEASE

micha06:12:30

@seancorfield: the boot script doesn't do anything you can't do in the repl

micha06:12:50

you can even do (load-file "build.boot") in the repl to reload it

seancorfield06:12:37

Oh, I misunderstood what you meant there sorry... I get it now....

seancorfield06:12:37

ah, so merge-env! would be better than set-env! with a function and into or conj... are there equivalents for source paths, resource-paths and repositories?

micha06:12:29

yeah merge-env! is just a convenience function, it does set-env! with a function internally

micha06:12:47

with some dispatching on the type of the key in the env

micha06:12:58

uses into where appropriate to merge

micha06:12:13

or if the key isn't a collection it replaces it with the new value

micha06:12:58

merge-env! takes keys and values of the same shape as set-env!, which i like

micha06:12:16

but the two are equivalent

seancorfield06:12:36

But merge-env! is the only convenience? For :source-paths and :resource-paths we need set-env! and a function?

seancorfield06:12:48

Same with :repositories right?

micha06:12:58

you can use it as you would use set-env!

micha06:12:11

only instead of replacing the values it merges them into the current values

micha06:12:24

but all the keys you can use with set-env! also work with merge-env!

micha06:12:29

is that what you mean?

seancorfield06:12:01

oh, so (merge-env! :dependencies ... :source-paths ... :resource-paths ...) works?

micha06:12:22

it doesn't take functions as values, though

micha06:12:27

but maybe it should

seancorfield06:12:30

OK, I'll go clean up our build.boot file at work then!

seancorfield06:12:06

I didn't realize it existed... the docs sort of imply you need to use set-env! with functions... and that's what you'd suggested here too simple_smile

micha06:12:06

yeah i don't know how much better merge-env! is

seancorfield06:12:37

Oh, it's a big improvement over all the set-env! calls we had with anonymous functions! So much cleaner!

seancorfield06:12:01

We have 40+ tasks, most of which modify the environment. This is a big cleanup.

crisptrutski06:12:04

@fappy: took a look boot-cljs-test-question - the issue is the naming of your test namespace, 0.2.1-SNAPSHOT is trying out a cheeky heuristic for determining test namespaces

crisptrutski06:12:27

you can change the test namespace to core-test and it’ll run

crisptrutski07:12:17

@micha: want to second @seancorfield, love-at-first-sight with merge-env!

escherize07:12:14

cool! I guess what I want is just clojars search + what-boot-already-does! 😄

micha07:12:15

clojars search would be pretty awesome!

crisptrutski07:12:21

boot apropos? simple_smile

micha07:12:24

there are somewhat legit api docs now btw: https://github.com/boot-clj/boot/tree/master/doc

escherize07:12:28

I think i might make my first boot task around searching clojars using: https://github.com/clojars/clojars-web/wiki/Data#json-search-results

micha07:12:47

awesome, yes!

escherize08:12:06

Hope I can bug you guys for some help here

escherize08:12:28

so I have a function that takes a clojars search term (here hiccup) and returns a string like this..

hiccup
  A fast library for rendering HTML in Clojure
    [hiccup "1.0.5"]
    [hiccup "0.2.3"]
    [hiccup "1.0.3-SNAPSHOT"]
    [hiccup "1.0.2"]
    [hiccup "2.0.0-alpha1"]
    [hiccup "1.0.3a"]
    [hiccup "1.1.1"]
    [hiccup "1.0.2"]
    [hiccup "1.0.2"]
    [hiccup "1.0.0-beta1"]
    [hiccup "1.0.1-SNAPSHOT"]
    [hiccup "2.0.0-SNAPSHOT"]

hiccup-bridge
  Hiccup to html, html to hiccup.
    [hiccup-bridge "1.0.1"]
    [hiccup-bridge "1.0.0-SNAPSHOT"]

hicv
  Hiccup to html, html to hiccup.
    [hicv "1.0.0-SNAPSHOT"]
....

escherize08:12:22

how can i make it so that boot my-task-name hiccup will print this?

micha08:12:33

you can do like this:

micha08:12:21

(deftask showme
  [s search TERM [str] "The vector of search terms."]
  (with-pass-thru [_]
    (doseq [s search] (print (searchfn s)))))

micha08:12:40

boot showme -s hiccup

escherize08:12:13

Thanks micha. Just re-watched your clojure west talk

micha08:12:29

what do you think so far?

escherize08:12:53

... better than lein

escherize08:12:07

except that my whole infrastructure is built with lein

micha08:12:18

haha yeah

micha08:12:57

this function is probably something you'd want to use in the repl too

micha08:12:11

and in your editor if you have cider or vim fireplace

escherize08:12:29

i feel like i want it all the time, i do a lot of googleing and web browsing just to solve this issue

micha08:12:35

yeah totally

micha08:12:42

you can make a pod in your profile.boot

micha08:12:49

in which you add this dependency

micha08:12:09

and you can then make a stub function in your profile.boot, which will be in the boot.user namespace

micha08:12:23

that function would call through to the implementation in the pod

micha08:12:37

that way you don't need to add the library that does the searching as a project dependency or anything

micha08:12:46

and it won't interfere with any classpath you might have for a build

micha08:12:53

but it'll be available all the time

micha08:12:33

actually that's needlessly complicated

micha08:12:47

you can make a library with artifacts on clojars

escherize08:12:54

I'd like to get it added to the comminity tasks

micha08:12:11

and you can also hijack a thing in boot

micha08:12:23

to load a function into the boot.user namespace

micha08:12:56

sorry i'm a little out of it, fighting with computers all day

escherize08:12:09

No worries, still very helpful

micha08:12:41

did you see examples of how to make a pod to isolate your dependencies?

escherize09:12:52

hmm, there was one in the video

micha09:12:18

the environment configuration is contained in the "env"

micha09:12:26

like when you do set-env! to add dependencies

micha09:12:30

that's a map

escherize09:12:40

j/w: how can i see that map?

micha09:12:43

you can create a pod with the make-pod function

micha09:12:53

you can do (get-env) with no args

micha09:12:10

it's also accessible from boot.pod/env

micha09:12:13

which is just a var

micha09:12:34

the make-pod function takes an env map

micha09:12:48

and creates a new clojure runtime that is isolated from the others

micha09:12:58

with the given :dependencies etc

micha09:12:13

so in your case you probably want to do something like this to make a pod:

escherize09:12:38

the beginning of my build.boot is like this, btw:

(set-env!
 :source-paths #{"."}
 :resouce-paths #{"."}
 :dependencies '[[http-kit "2.1.18"]
                 [cheshire "5.5.0"]])

(require '[cheshire.core :as json]
         '[org.httpkit.client :as http]
         '[clojure.string :as str])

escherize09:12:57

I probably dont need source/resouce-paths

micha09:12:03

(boot.pod/make-pod (assoc boot.pod/env :dependencies '[[http-kit "..."][cheshire "..."]]))

micha09:12:20

that will return a reference to the pod instance

micha09:12:00

i used assoc and started with boot.pod/env becuase the user might have for example repository configuration in their env

micha09:12:15

which you want to pass to the pod, so it can resolve dependencies etc

micha09:12:32

but assoc replaces the project deps with the ones you need

micha09:12:24

once you have the pod you can evaluate clojure in there

escherize09:12:44

This is gonna be awesome!

micha09:12:16

(boot.pod/with-eval-in the-pod
  (require '[cheshire.core :as c])
  (c/json-parse "{\"foo\":100}"))

micha09:12:25

and that will return data

escherize09:12:43

that's run in another jvm instance, right

micha09:12:01

no, in the same jvm

micha09:12:10

different classloader hierarchy though

escherize09:12:15

i'm getting a problem with this:

(deftask search-clojars
  "Search in clojars for libraries and return leiningen coordinates for them."
  [s search TERM str "The vector of search terms."]
  (with-pass-thru [_]
    (print (search-clojars s))))
which is

micha09:12:35

you need the long option, not the short

micha09:12:42

search there

micha09:12:19

you can do (doc search-clojars) in the repl to see the arglist too

micha09:12:46

and if you're hacking on a build.boot file this is a handy thing:

micha09:12:55

(load-file "build.boot")

micha09:12:05

to reload the build.boot in the repl

escherize09:12:29

should the deftask be defined inside boot.pod/with-eval-in ?

micha09:12:58

no, the task needs to be in the pod that your build.boot is running in

micha09:12:20

so you can require it in your build.boot and stuff

micha09:12:48

the idea is to have a package with no dependencies

micha09:12:08

that people can put in their :dependencies with no chance of dependency conflicts

micha09:12:32

i.e. your package doesn't introduce transitive dependencies into the project that uses it

escherize09:12:44

right, but what am i actually with-evaling-in ?

micha09:12:46

instead you'd put the dependencies of your task in a pod

micha09:12:01

well you have cheshire and stuff

micha09:12:14

which might conflict with a version of cheshire in the user's project

micha09:12:28

(boot.core has cheshire in it btw)

micha09:12:41

boot.core/json-parse and boot.core/json-generate

micha09:12:54

in a pod, of course

micha09:12:18

because it's very common to need to parse json config files and whatnot

escherize09:12:48

for sure, so i can get rid of that one

escherize09:12:09

should I make the pod from inside the task?

micha09:12:02

one sec i find a good example

micha09:12:16

that's a good pattern

micha09:12:56

that happens when the task is constructed

micha09:12:31

which is evaluated for each time the pipeline runs

micha09:12:45

like in the case of the watch task and things like that

micha09:12:22

the pod is constructed in a future so you don't need to wait for clojure to load

tcrawley13:12:00

is there anything like lein deps :verify for boot?

tcrawley21:12:31

@micha: I can take a whack at it as a plugin, and you can then have it for core if you want it