Fork me on GitHub
#boot
<
2017-02-03
>
seancorfield00:02:27

@mobileink How would you suggest they could be improved?

qqq00:02:25

write it as emacs-org mode files, where you can interactively evaluate each step 🙂

mobileink04:02:07

@seancorfield: currently there is no documentation on templates. i spent about 20 minutes trying to create a new template using -t template and then gave up.

seancorfield04:02:23

Happy to help when I'm at my computer (since I wrote boot-new and its "totally useless" documentation) @mobileink :)

seancorfield04:02:17

Hit me up tomorrow during Pacific office hours if you're around. We can DM and get you up and running. Then I can use that to improve the documentation.

seancorfield04:02:11

You're 2 hours ahead of me, I believe? Central time?

mobileink04:02:44

yes. not sure about schedule tomorrow, though. all i need though is some explanation of what a boot template is supposed to look like and what the development workflow should be. the result of boot -d boot/new new -t template -n my-template does not seem to work:

mobileink04:02:59

$ boot -d boot/new new -t template -n mytemplate

mobileink04:02:10

$ cd mytemplate

mobileink04:02:14

$ boot build

mobileink04:02:54

$ boot -d boot/new new -t mytemplate -n myapp

mobileink04:02:32

crash: Could not load template, failed with: Failed to collect dependencies for ...

moxaj14:02:18

@micha hey there 🙂

moxaj15:02:28

are beginner questions welcome here?

donaldball15:02:58

If they’re about boot, sure; at least, I’ve asked my share of beginner questions without sanction 🙂. If they’re about clojure or the wider ecosystem, #beginners is a better forum.

moxaj15:02:11

probably extremely trivial, but I haven't messed with boot filesets yet; all I'm trying to do is write to an asset file (foo/bar.txt). Started from https://github.com/boot-clj/boot/wiki/Filesets#examples, but the file won't appear

micha15:02:17

@moxaj you want to update the contents of the file?

micha15:02:31

here is an example you can try:

moxaj15:02:39

@micha or create a new one

micha15:02:30

(deftask doit []
  (let [tmp (tmp-dir!)]
    (with-pre-wrap fs
      (empty-dir! tmp)
      (let [tmpf (->> fs input-files (by-path ["foo/bar.txt"]) first)
            [infile inpath] ((juxt tmp-file tmp-path) tmpf)
            outfile (doto (io/file tmp inpath) io/make-parents)]
        (spit outfile (str (slurp infile) "one more line.\n"))
        (-> fs (add-resource tmp) commit!)))))

micha15:02:44

that adds a line to the foo/bar.txt file

micha15:02:14

the idea is that you have your own anonymous temp dir that only your task knows

micha15:02:20

your task creates files in there

micha15:02:42

when your task adds that directory to the fileset it can overwrite files already in the fileset

moxaj15:02:36

so, I can only write to existing files?

micha15:02:09

you can create new files

micha15:02:21

if you have your temp dir, in the example above that's bound to tmp

micha15:02:27

you can cerate files in there as you like

micha15:02:42

when you do add-resource that adds those files to the fileset

moxaj15:02:50

(deftask my-task []
  (let [tmp (tmp-dir!)]
    (with-pre-wrap fileset
      (empty-dir! tmp)
      (doto (io/file tmp "out.txt")
        (io/make-parents)
        (spit "Why, hello there :)"))
      (-> fileset
          (add-resource tmp)
          (commit!)))))

donaldball15:02:15

You may need to follow this task with the target task, right?

moxaj15:02:18

but out.txt is nowhere to be found

moxaj15:02:56

@donaldball bingo! but what if I want to write to a directory other than target?

donaldball15:02:02

Doesn’t it allow a :dir option?

moxaj15:02:02

@donaldball it does. alright, back to docs, thanks for the directions

micha16:02:40

@moxaj can you try boot my-task show -f

micha16:02:47

that will show you what's in the fileset

micha16:02:31

you can use show -f between tasks to see what's going on with the fileset

borkdude16:02:56

Is there a way to force boot to download the latest snapshots every time you start it?

micha16:02:25

you can use [my/dep "(0,)"]

micha16:02:46

it's not guaranteed though

micha16:02:56

snapshots are not an exact science

micha16:02:58

there is an option you can try in boot.aether to try to disable caching of snapshots

micha16:02:07

but i've found that it's not reliable

qqq17:02:48

in boot, is there a nice way to "compress" three windows into one? I'm building a webapp where server = clj, client = cljs right now, I need one for: boot watching clj files to recompile server side boot watching cljs files to recompile client side boot cljs repl now I really want to compress all three into a single terminal -- it's okay if the output is interleaved -- that doesn't bother me

qqq17:02:58

[I'm just trying to recover screen real estate]

micha17:02:48

tmux perhaps?

micha17:02:53

or gnu screen

pesterhazy17:02:01

@qqq, I've wanted this before too

pesterhazy17:02:40

it'd be nice to be able start a "session", with multiple boot processes, as a package

pesterhazy17:02:23

especially because you can't easily combine watch with repl -c

pesterhazy17:02:36

you pretty much need two terminal windows

micha17:02:04

@pesterhazy you can run the boot task from inside the repl, like boot.user=> (boot (watch) ...

micha17:02:20

you can use a future there

pesterhazy17:02:50

@micha, can I submit an initial command to the repl?

micha17:02:52

there is a neat little gfredricks library for in-repl job control that i like to use sometimes

pesterhazy17:02:15

I guess I could make a deftask that runs (future (boot (watch)))

micha17:02:25

just a function, but yes

micha17:02:30

probably not a task

pesterhazy17:02:57

why is a task not a good idea?

micha17:02:42

because nesting calls to boot wouldn't help 🙂

micha17:02:06

oh i see what you mean

micha17:02:17

you put that task before the repl task

micha17:02:21

that might work!

pesterhazy17:02:50

yeah exactly

micha17:02:57

(deftask doit []
  (def p (future (boot ....)))
  identity)

micha17:02:14

but there is also the -e repl option

micha17:02:30

boot repl -e '(do-the-future-thing)'

micha17:02:52

$ boot repl -e '(println "hello")'
nREPL server started on port 51846 on host 127.0.0.1 - 
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_91-b14
        Exit: Control+D or (exit) or (quit)
    Commands: (user/help)
        Docs: (doc function-name-here)
              (find-doc "part-of-name-here")
Find by Name: (find-name "part-of-name-here")
      Source: (source function-name-here)
     Javadoc: (javadoc java-object-or-class-here)
    Examples from : [clojuredocs or cdoc]
              (user/clojuredocs name-here)
              (user/clojuredocs "ns-here" "name-here")
hello
boot.user=>

moxaj17:02:19

(deftask x []
  (set-env! :source-paths #(conj % "src2")))
  (require '[foo.bar :as bar])
  ...
  (bar/qux) ;; <= throws no such namespace: bar (-_-。)

pesterhazy17:02:25

that's probably the answer then, thanks

pesterhazy17:02:33

@moxaj you have to use resolve

pesterhazy17:02:52

((resolve 'foo.bar/qux))

moxaj17:02:13

ew that's ugly

moxaj17:02:24

but I can live with it

micha17:02:38

it's because clojure compiles top level expressions as a unit

pesterhazy17:02:41

you only need it in build.boot - it's not as bad as it looks

micha17:02:59

it doesn't compile each subexpression separately

micha17:02:21

there is a special case in there sometimes, but in general not

moxaj17:02:28

I guess you can't even work around this with a convenince macro, since it would still expand to (do ...)

micha17:02:55

do is actually the special case that clojure tries to accomodate

micha17:02:24

i remember boot version 1 used to have some workarounds there

micha17:02:32

but i think it was still tricky

micha17:02:49

so it was decided that it's better to not add any new quirks

qqq18:02:31

@micha @pesterhazy : tmux/sreen doesn't work, as I want the three output "interleaved"

qqq18:02:44

however, it sounds like you guys worked out some solution -- how does it actually work?

micha18:02:23

@qqq you can do this, too

micha18:02:48

$ boot foo bar &
$ boot baz baf &
$ boot quux

micha18:02:56

then output will be interleaved

micha18:02:15

the first two will run in the background while the last runs in the foreground as usual

qqq18:02:38

actually, are you serious?

micha18:02:46

um, soft yes?

micha18:02:52

i mean i was

micha18:02:58

but maybe it's dumb?

qqq18:02:10

it technically solves the problem I defined

pesterhazy18:02:24

I'm stealing "soft yes"

qqq18:02:02

let's daydream for a moment

qqq18:02:13

what I'd relaly love would be if boot, on startup, fired up a web browser

qqq18:02:19

err, opened up a webserver

qqq18:02:33

this websever would support websockets ... and in the js side, provide a basic terminal emulator

qqq18:02:46

then, I can run multiple boot 'watch' commands, and have the browser do all the output rendering

micha18:02:12

maybe you don't need multiple watch commands?

micha18:02:24

there is also boot-in-boot

qqq18:02:29

I need one for recomiping .js into .class files, and one for recompiling .cljs to .js files

micha18:02:51

why not use one pipeline that does both?

qqq18:02:11

in this linked appraoch, if I update a server clj file, does my cljs -> js recompile as well?

micha18:02:36

i think it would, why wouldn't it?

qqq18:02:39

oh, I also need separate processes for this reason: I don't want client side dependencies (huge) to go into server side WAR (want as small classes as possible)

micha18:02:58

i mean the cljs only recompiles cljs namespaces that have changed

micha18:02:19

well packaging and developing are different things

micha18:02:01

ok so here is another thing to try

micha18:02:10

the "boot-in-boot" approach

richiardiandrea18:02:34

for classpath issues, my approach to that was very hacky in lambone, but I was able to have the cljs classpath include only frontend deps

micha18:02:38

boot.user=> (boot.App/runBoot (boot.App/newCore nil) (future boot.pod/worker-pod) (into-array String ["help"]))

qqq18:02:28

Right now, to startup my dev environment, I have to do fire up the following 4 terminals: 1) dev_appserver.sh war 2) boot watch-server // clj -> class files 3) boot watch-client // cljs -> js files 4) boot brepl // browser cljs repl This seems kind of crazy.

richiardiandrea18:02:32

if you want to reach real classpath isolation and launch one process only, lambone does it for you

richiardiandrea18:02:41

in the hacky way above

richiardiandrea18:02:16

(aka, run in pods wherever you can)

richiardiandrea18:02:56

there was also some discussion around having a way to "hook into" or "configure" the pod running in standard tasks

richiardiandrea18:02:08

like boot-cljs-repl

richiardiandrea18:02:23

or why not, pass a pod as option

qqq18:02:44

@richiardiandrea : initially, I thought you were asking a different question -- however, based on your last two posts, it seems like you may be answering my question -- is lambone a solution to the "4 windows is too much" problem ?

qqq18:02:11

Three ready to use boot build, boot dev and boot test tasks boot dev with no option launches two Repl instances within the same JVM

qqq18:02:13

This sounds interesting.

richiardiandrea18:02:59

also, feel free to steal anything you need 😄

moxaj18:02:36

whoops, apparently (target :dir "./") is not a good idea

richiardiandrea18:02:41

the deps are maybe a bit outdated

pesterhazy18:02:41

@moxaj that might delete your cwd 😞

moxaj18:02:55

it deleted pretty much everything, pulling a fresh repo

moxaj18:02:05

I don't think I lost anything though

pesterhazy18:02:54

might be a good idea to sanity-check target for ^.(/.*)?'

qqq18:02:07

this reminds me of the one time I did: rm -rf *.png ; and put a space before the .png

qqq18:02:20

lots all my .tex and .fig files too

micha20:02:02

@qqq a few months ago i was typing too fast and i did rm -rf ~/.foop, but with tab completion and general bad typing skills i ended up with a space between the ~/ and everything else

micha20:02:18

i saw the error in a split second but it had already deleted everything i cared about

micha20:02:24

in like 0.000023 sec

micha20:02:35

ssd drives so fast to delete things from

qqq20:02:31

@micha whoa, you win the shitty typo award; I think the only thing of comparable level would be a "mkfs.ext3 /dev/sd<WRONG-PARTITION>"

moxaj21:02:17

@micha re writing into a file: I may have misunderstood something .. is there no way to spit into the actual file it read from?

mobileink22:02:28

@micha: if it makes you feel any better, i once did "$ sudo rm -rf ./" except i forgot the .

micha22:02:23

@moxaj you don't want to write to files that are in the fileset

micha22:02:45

beacuse the files are organized by their contents

micha22:02:02

so if you change the contents of a file that is being managed by the fileset it will cause unexpected results

micha22:02:45

this is how the fileset is able to provide some level of immutable characteristics

micha22:02:56

on top of the mutable filesystem

micha22:02:19

so if you want to modify a file that is in the fileset you would replace the file with your modified copy

micha22:02:34

you'd do that by creating the file in your temp dir and add the dir to the fileset

micha22:02:51

that will replace the existing fileset file with your new version in the temp dir

moxaj23:02:00

@micha I mean the actual actual file 🙂 the one on the filesystem, not in the temp directories

moxaj23:02:34

it seems in the end I can only write into the target directory

micha23:02:12

@moxaj oh, that's true

micha23:02:30

that's because boot does not know about the files in your project

micha23:02:48

that's an important prerequisite for the fileset to work in a sane way

micha23:02:15

because the files in your project belong to you, not to boot

micha23:02:29

so boot will copy your source files into its own temp dirs

micha23:02:48

that way you can delete files or modify them, even if they are source files

micha23:02:58

without messing up the user's project files

micha23:02:51

this is also key for the immutable fileset abstraction, too

samueldev23:02:52

does anyone have a sample usage of the sift task? I'm using boot-cljs and outputting my compiled cljs, but id like to move the destination folder to /release/site.min.js rather than the default /target/js/app.js

alandipert23:02:47

@samueldev the target task uses /target by default, but you can change it to output to /release with (target :dir #{"release"})