Fork me on GitHub
#boot
<
2017-02-01
>
arohner00:02:51

Are there any boot libraries for doing web frontend asset pipelines?

arohner00:02:06

minification, fingerprinting, CDN urls, etc?

richiardiandrea00:02:27

I don't think it does minification though

richiardiandrea00:02:54

I haven't tried them

arohner00:02:22

thanks. I was asking to see what people were actually using

arohner00:02:43

Google found the first one, but it looked a little unmaintained

richiardiandrea00:02:34

I think there was a question above from its author about it, so probably it is ok 😄

arohner00:02:01

derp. Didn’t see that

adamfrey01:02:53

@arohner I just pushed a new version up today

adamfrey01:02:46

also my library is boot-asset-fingerprint, not boot-fingerprint, which is unmaintained

michael.heuberger02:02:57

hello guys - stuck here adding a new boot task dsl option. always throws "java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String"

michael.heuberger02:02:02

here the simplified code

michael.heuberger02:02:03

(deftask dev
  "Simple alias to run application in development mode"
  [o optimizations LEVEL      kw   "The optimization level. May be :none, :simple or
                                   :advanced. Note :none breaks source maps during
                                   debugging."
   p proxy-port               int  "Port number for proxy server which delegates API calls to backend."]
  (comp (boot.util/info (str "proxy port what?" proxy-port))
        (development :optimizations optimizations)
        (run :proxy-port proxy-port)))

michael.heuberger03:02:28

any ideas why it cannot print the proxy port when i run i.E. with boot dev -p 3452 but throws the above error?

richiardiandrea03:02:52

Basically you are composing tasks with a info call which does not return tasks @michael.heuberger

richiardiandrea03:02:25

So you should do that outside the comp if you want it to be one-off

arohner03:02:26

@adamfrey cool! No offense intended earlier btw

michael.heuberger03:02:23

@richiardiandrea tried that before too, prints same error

richiardiandrea03:02:32

Ah yes, so info accepts a format string and params similar to printf

richiardiandrea03:02:45

So you actually need to fix two errors above

adamfrey03:02:46

@arohner none taken 🙂

michael.heuberger03:02:59

(deftask dev
  [p proxy-port PROXY-PORT int "Port number for proxy server which delegates API calls to backend."]
  (boot.util/info (str "proxy port what?" proxy-port)))

michael.heuberger03:02:13

clojure.lang.ExceptionInfo: clojure.lang.PersistentVector cannot be cast to java.lang.String

richiardiandrea03:02:48

Yes @michael.heuberger see above for the format of params in info

michael.heuberger03:02:33

(deftask dev
  [p proxy-port PROXY-PORT int "Port number for proxy server which delegates API calls to backend."]
  (boot.util/info “blahblah”))

michael.heuberger03:02:41

throws same error ??

richiardiandrea03:02:17

Woah OK I finished my suggestions

michael.heuberger03:02:03

yep, very weird - what can this be?

michael.heuberger03:02:37

even weirder, with this code without OPTARGS

(deftask dev
  [p proxy-port int "Port number for proxy server which delegates API calls to backend."]
  (boot.util/info (str "proxy port what? " proxy-port "\n")))

michael.heuberger03:02:08

~/c ❯❯❯ boot dev -p 343423                                                                                                                    
proxy port what? 1
        clojure.lang.ExceptionInfo: No such task (343423)
    data: {:file
           "/var/folders/m7/r54_bcwj2ms2w5rpgdmvr6hh0000gn/T/boot.user244238939908557460.clj",
           :line 143}
java.lang.IllegalArgumentException: No such task (343423)
          boot.core/construct-tasks  core.clj:  905
                                ...
    clojure.core/apply/invokeStatic  core.clj:  646
                 clojure.core/apply  core.clj:  641
                  boot.core/boot/fn  core.clj:  949
clojure.core/binding-conveyor-fn/fn  core.clj: 1938
                                …

seancorfield03:02:49

Your task needs to return a function.

seancorfield03:02:09

(deftask dev
  [p proxy-port int "Port number for proxy server which delegates API calls to backend."]
  (boot.util/info (str "proxy port what? " proxy-port “\n”))
  identity)

seancorfield03:02:58

Otherwise, the result of calling boot.util/info will be treated as the task function to run...

michael.heuberger03:02:04

nope, still does not work

michael.heuberger03:02:08

(deftask dev
  [p proxy-port int "Port number for proxy server which delegates API calls to backend."]
  (boot.util/info (str "proxy port what? " proxy-port "\n"))
  identity)

michael.heuberger03:02:35

~/c/something ❯❯❯ boot dev -p 343423                                                                                                                   
proxy port what? 1
        clojure.lang.ExceptionInfo: No such task (343423)
    data: {:file
           "/var/folders/m7/r54_bcwj2ms2w5rpgdmvr6hh0000gn/T/boot.user893364953168518953.clj",
           :line 143}
java.lang.IllegalArgumentException: No such task (343423)
          boot.core/construct-tasks  core.clj:  905
                                ...
    clojure.core/apply/invokeStatic  core.clj:  646
                 clojure.core/apply  core.clj:  641
                  boot.core/boot/fn  core.clj:  949
clojure.core/binding-conveyor-fn/fn  core.clj: 1938
                                …

seancorfield03:02:14

You’re still missing the placeholder variable from the argument definition...

seancorfield03:02:00

(! 877)-> boot dev -p 343423
deftask boot.user/dev was overridden
proxy port what? 343423

Tue Jan 31 19:45:38
(sean)-(jobs:0)-(~/clojure/heuberger)
(! 878)-> tail -5 build.boot 

(deftask dev
  [p proxy-port PORT int "Port number for proxy server which delegates API calls to backend."]
  (boot.util/info (str "proxy port what? " proxy-port "\n"))
  identity)

seancorfield03:02:54

Without the placeholder, you’re defining a counter-style flag so -p sets it to 1, -ppp sets it to 3.

seancorfield03:02:30

(I’d missed that error first time around b/c the code you posted 30 mins ago did have PROXY-PORT in it and then the code you posted afterward had removed it…)

seancorfield03:02:43

^ @michael.heuberger

richiardiandrea03:02:51

Ah true ^ didn't notice that either

michael.heuberger04:02:34

oh man, thanks guys

michael.heuberger04:02:47

i think it behaves differently when there is a dash in the placeholder

michael.heuberger04:02:01

PROXY works but PROXY-PORT is funny

seancorfield05:02:44

Good to know... I don't think I've ever tried it with - in it...

juhoteperi08:02:47

boot.util logging functions probably shouldn't use format

juhoteperi08:02:02

Currently message with % and no arguments throws exception

juhoteperi08:02:43

This is very problematic in print-ex which tries to use fail to display exception message if stacktrace is to be omited

pesterhazy08:02:44

Well they work like logf in clojure.tools.logging

juhoteperi08:02:57

In this case the exception kills whole Boot processes

pesterhazy08:02:02

You can just log ℅s

juhoteperi08:02:08

Except logging functions don't catastrophically fail if there are no arguments

juhoteperi08:02:41

And I'm not logging, but throwing exceptions

pesterhazy08:02:47

Whatever is calling dbug, warn etc should be using %s

juhoteperi08:02:52

hmm, ah the problem isn't about missing parameters, but the message contains "error at: 20%)" or something

juhoteperi08:02:56

print-ex should probably escape any %

alandipert10:02:45

I disabled the bootclj org webhook on github

lxsameer12:02:07

how can i test a boot template locally ?

alandipert14:02:45

@lxsameer: in the template dir you can run 'boot watch install' to continuously install to local maven cache. then in different directory run boot new

alandipert14:02:12

from repl maybe like (boot (new ....)) so you don't have to start up boot every time

lxsameer16:02:01

I have A lib in the dependencies list of lib Z, when I use Z in my project I can't require A in my build.boot. is that normal ?

micha16:02:38

@lxsameer no, that's not right

micha16:02:44

try boot show -d

micha16:02:56

does it show the A dependency as a child of Z?

lxsameer16:02:04

It seems that I messed up the scopes

micha16:02:18

ah yeah that will be seen in boot show -d

micha16:02:26

you shouldn't see A in there

lxsameer16:02:28

@micha I really can't understand the scopes. I read the maven docs, can you help me with them please ?

micha16:02:58

so really all you need to know about is two scopes: compile and test

micha16:02:34

because when you're not using mvn to build your project there is really only one aspect of scopes that is relevant to you

micha16:02:57

scopes in maven are sort of coupled to maven as a build tool

micha16:02:08

so compile scope is the default

micha16:02:22

if you don't specify a scope that's what will be assumed as the default

micha16:02:49

if you have a project Z with a pom.xml

micha16:02:59

and you specify A as a dependency in that pom

micha16:02:33

when you add Z to your dependencies A is pulled in as a transitive dependency, right?

micha16:02:49

meaning A is a dependency of Z is a dependency of your project

micha16:02:59

tracking so far?

micha16:02:29

ok so if you had specified scope test for the A dependency in the pom.xml for Z, that would tell maven to ignore A when you don't explicitly add it to your dependencies

micha16:02:09

in other words, scope test "hides" a dependency from being pulled in transitively

lxsameer16:02:18

@micha aha i get it now

lxsameer16:02:47

@micha i have two other questions that I know that are silly but I never used JVM before

micha16:02:06

this is why it's common to see boot tasks added to :dependencies with scope test

lxsameer16:02:16

compile scoped dependencies will be included in the resulted jar, right ?

micha16:02:20

you only need like pandeiro/boot-http for dev

micha16:02:40

you don't want consumers of your library to pull that in transitively because they won't need it

micha16:02:12

so you do like :dependencies [['boot-http "1.2.3" :scope "test"]]

micha16:02:26

scopes have nothing to do with jars

micha16:02:40

scopes are metadata on dependencies declared in the pom.xml

micha16:02:50

the pom.xml itself is metadata about the jar

micha16:02:12

scopes and jars, completely separate

micha16:02:15

does that make sense?

lxsameer16:02:24

yeah. completely

micha16:02:40

the stuff in the jar is determined by what's in the fileset (in boot)

micha16:02:56

when you make the jar with the jar task

lxsameer16:02:27

@micha do you know any good article to learn more about compilation and stuff related to jars ?

micha16:02:07

hmm, that's a good question

micha16:02:18

i don't really know of anything offhand, if you find a good resource could you add it to the boot wiki?

lxsameer16:02:08

@micha also thanks for your time man

micha18:02:15

@lxsameer any time 🙂

richiardiandrea18:02:55

Hello 😄 I had this problem with boot-cljs, I was wondering if a patch for this is something you folks are open to: https://github.com/cljsjs/boot-cljsjs/issues/44

richiardiandrea18:02:17

(of course after polishing a bit)

juhoteperi18:02:37

@richiardiandrea If marking is not supported, I think it means that the archive contains single file

juhoteperi18:02:16

So instead of checking file extension, proper check would be to check .markSupported

juhoteperi18:02:01

and change decompress-file logic based on that

richiardiandrea18:02:19

I read this: > For the bzip2, gzip and xz formats a single compressed file may actually consist of several streams that will be concatenated by the command line utilities when decompressing them. Starting with Commons Compress 1.4 the *CompressorInputStreams for these formats support concatenating streams as well, but they won't do so by default. You must use the two-arg constructor and explicitly enable the support.

richiardiandrea18:02:31

and I thought the single file was support by default

juhoteperi18:02:37

But yeah, PR is welcome, but don't try to use file extension to select the logic

richiardiandrea18:02:56

you know the thing is that I am trying to make it more generic, but always failing

richiardiandrea18:02:11

of course the extension trick is ugly

juhoteperi18:02:12

unless you can find something on commons-compress for this, .markSupported should be good check

richiardiandrea18:02:16

it looks like CompressorStreamFactory always creates a stream where mark is not supported

richiardiandrea18:02:35

yep and what to do if no .markSupported ?

richiardiandrea18:02:00

the problem is the ArchiveStreamFactory wants mark

juhoteperi18:02:02

similar to what you did in snippet you pasted on github

juhoteperi18:02:19

ArchiveStream is about splitting the multiple files from archive

juhoteperi18:02:26

if there is only single file, it is unncessary

richiardiandrea18:02:12

Ok, but then if we will have another archive type that does not support marking, we are back at that again

richiardiandrea18:02:33

(not sure if there exists another one, just speculating)

richiardiandrea18:02:30

ok I will try one thing, I think I got what you mean

richiardiandrea18:02:09

@juhoteperi worked, thanks for the hint, I will PR shortly

juhoteperi18:02:49

@richiardiandrea For cleanest patch, I recommend adding .markSupported check to unpackage-stream and .decompress-file, then the with-open binding doesn't need to be touched at all

richiardiandrea18:02:30

yeah but I have to do it earlier in order to avoid the exception, like so:

(defn decompress-file [in out-dir & [{:keys [compression-format archive-format]}]]
  (with-open [is (-> (io/input-stream in)
                     (try-decompress-stream {:format compression-format}))]
    (if (.markSupported is)
      (with-open [is (unpackage-stream is {:format archive-format})]
        (let [count (loop [i 0
                           entry (.getNextEntry is)]
                      (if entry
                        (if-not (.isDirectory entry)
                          (let [target (io/file out-dir (.getName entry))]
                            (io/make-parents target)
                            ;; After .getNextEntry the stream points to the specific archive entry
                            (io/copy is target)
                            (recur (inc i) (.getNextEntry is)))
                          (recur i (.getNextEntry is)))
                        i))]
          (util/info (format "Extracted %d files\n" count))))
      (let [target (io/file out-dir (.getName (io/file in)))]
        (println target)
        (io/make-parents target)
        (io/copy is target)))))

juhoteperi18:02:56

(defn unpackage-stream [is & [{:keys [format]}]]
  (if (.markSupported is)
    (cond-> (ArchiveStreamFactory.)
      format       (.createArchiveInputStream format is)
      (not format) (.createArchiveInputStream is))
    is))

richiardiandrea18:02:04

@juhoteperi no, wrong 😄 because the new stream then does not support .getEntry calls

richiardiandrea18:02:41

so I need the io/copy if mark is not supported

juhoteperi18:02:59

Yes, so check markSupported again in decompress-file

richiardiandrea18:02:36

ah ok you prefer two checks, ok then

juhoteperi18:02:13

I think it keeps the decompress-file simplest when there is only single with-open

juhoteperi18:02:34

(string/replace (.getName (io/file in)) #"\.[^.]*$" "") can be used to remove last file extension from name

juhoteperi18:02:42

.md.gz -> .md

juhoteperi19:02:16

I think most compression formats follow this

juhoteperi19:02:24

.md.bz2, .md.lzma etc.

richiardiandrea19:02:10

I found FileNameUtil

richiardiandrea19:02:04

just checking everything is ok 😉

richiardiandrea19:02:12

so weird that I have to specify the extensions myself lol