Fork me on GitHub
#boot
<
2017-08-05
>
Ruben W11:08:19

Hi, I’m trying to write a task that downloads an external less-template and move it permanently to my prj folder. That part works, but I’m stuck with trying to rename the downloaded folder. Task below is mostly based on what cljsjs does:

(deftask download-semantic-ui []
  (comp
    (download
      :url (format "" +semantic-ui-version+)
      :checksum "98ba3248a2c74882204235cba06fad5e"
      :unzip true)
    (sift :include #{#"^Semantic-UI-.*/(.*)$"})
    (sift :include #{#"\.js", #"\.json"} :invert true)
    (target :dir #{"resources/less"})))

Ruben W11:08:21

this gives me the folder resources/less/Semantic-UI-LESS-{x.y.z} while I would like to reference in my own less file resources/less/semantic-ui How can I rename this?

juhoteperi11:08:12

@freakinruben (sift :move {#"Semantic-UI-LESS-[\d.]*/" ""})

juhoteperi11:08:32

@freakinruben Though I'd just recommend using Semantic UI from webjars and https://github.com/Deraen/less4clj

Ruben W11:08:47

yeah I did something like that but sift only moves files, not directories.. and it’s quite a nested folder structure inside

juhoteperi11:08:06

If you move all the files, the old directory will be empty

juhoteperi11:08:18

Boot only operates on files, not directories

Ruben W11:08:52

Ah didn’t know about webjars

Ruben W11:08:46

I will give that a try. Ok, so if I would like to make the above work I’ll have to use some java file methods

juhoteperi11:08:32

It should work

Ruben W14:08:28

@juhoteperi did you ever manage to use semantic-ui less files through webjars? Question doesn’t really belong in this channel, but in case you did, how did you solve semantic-ui trying to import ../../theme.config while that file is not present in the jar

juhoteperi14:08:04

@freakinruben I haven't used semantic-ui

juhoteperi14:08:51

Which package are you using? "org.webjars.npm" % "semantic-ui" % "2.2.10"?

juhoteperi14:08:39

You could try adding the file META-INF/resources/webjars/semantic-ui/2.2.10/src/theme.config under you classpath (i.e. resource-paths) (version number in the path doesn't matter, less4clj ignores that part)

Ruben W14:08:05

tried org.webjars.npm and org.webjars.bower, I’ll give it a try

juhoteperi14:08:21

Looks like only the npm version includes the less files

Ruben W14:08:51

npm jar ended up empty when I checked with jar tf ..

juhoteperi14:08:01

Semantic-ui should work with less4clj/less4j, : https://github.com/SomMeri/less4j/issues/295

Ruben W14:08:27

wow, that seems too work, adding the file under the path you said.. I tried it before with bower in the path as well 😄

juhoteperi14:08:48

Great! Looking at the import resolve code, having the file at classpath root might also work (`resources/theme.config`)

juhoteperi14:08:43

Or maybe not. That would work if semantic-ui/src/foo.less did import ../../theme.config, but the import is from semantic-ui/src/a/b/something.less hmm

Ruben W14:08:43

no, tried every path 😛 resources/theme.config, ./theme.config, resources/public/theme.config etc.

juhoteperi14:08:02

resources/semantic-ui/src/theme.config

Ruben W14:08:30

nope, only META-INF/resources/webjars/semantic-ui/2.2.10/src/theme.config seems to work

Ruben W14:08:53

that’s fine, I can just import there from my actual folder and forget about that file

Ruben W14:08:00

big thanks though, was about to give up

juhoteperi14:08:19

I'll add note about this to less4clj readme

anmonteiro21:08:33

@juhoteperi I’m getting an error with boot-cljs 2.1.1

anmonteiro21:08:40

and boot-cljs-test

anmonteiro21:08:55

> Cannot find module ‘/Users/anmonteiro/.boot/cache/tmp/Users/anmonteiro/Documents/github/lumo/1xed/3lgroc/lumo_test/lumo_test/test_suite.out/goog/bootstrap/nodejs.js’

anmonteiro21:08:01

has this been reported?

anmonteiro21:08:55

this is CLJS 1.9.854

anmonteiro21:08:01

boot-cljs-test 0.3.0

anmonteiro21:08:05

and boot-cljs 2.1.1

anmonteiro21:08:20

(using boot-cljs-test to run my tests in Node)

juhoteperi21:08:33

There is boot-cljs-test 0.3.1 available

juhoteperi21:08:45

and 0.3.2-SNAPSHOT

anmonteiro21:08:31

I get the same error with ^

anmonteiro21:08:18

looks like there’s one extra /lumo_test/ segment in the path

anmonteiro21:08:33

@juhoteperi this is a regression between 2.0.0 and 2.1.1

anmonteiro21:08:36

I just upgraded and started getting the error

juhoteperi21:08:09

2.1 changed the default :asset-path

juhoteperi21:08:19

Perhaps that doesn't work with Node

anmonteiro21:08:58

it might not work with Node

anmonteiro21:08:00

(I don’t have a .cljs.edn file btw)

anmonteiro21:08:05

not sure if that’s relevant

juhoteperi21:08:20

I think boot-cljs-test creates one

anmonteiro21:08:45

so perhaps this is a bug in boot-cljs-test?

juhoteperi21:08:41

might be related

juhoteperi21:08:16

Can you build something without boot-cljs-test and see if that works?

juhoteperi22:08:01

Also, you can provide :asset-path to test-cljs :cljs-opts to override value Boot-cljs-test sets

juhoteperi22:08:19

or :asset-path to cljs :compiler-options

anmonteiro22:08:32

trying to build something with Node right now (without boot-cljs-test)

anmonteiro22:08:33

what’s the goal behind this change in boot-cljs?

anmonteiro22:08:44

doesn’t seem like a very good default from the Node.js standpoint

juhoteperi22:08:59

I don't think the bug is in Boot-cljs, at least only

juhoteperi22:08:08

Boot-cljs had bug previously, it only used the name of .cljs.edn file to set asset-path default

juhoteperi22:08:10

now it uses path

juhoteperi22:08:45

Boot-cljs-test code now only uses the name of .cljs.edn, that is at least wrong, but I'm not sure if that is what causes this

anmonteiro22:08:48

to make this work in Node I had to use these compiler options:

(cljs :compiler-options {:optimizations :none
                             :main 'lumo.test-runner
                             :verbose true
                             :asset-path "/target/main.out"
                             :compiler-stats true
                             :target :nodejs})

anmonteiro22:08:14

I guess boot-cljs-test will need to use the asset path

juhoteperi22:08:18

It is also possible that the default should be different for Nodejs

juhoteperi22:08:34

Looks like something is prepending asset-path with output-dir or something

juhoteperi22:08:57

"require(path.join(path.resolve(\".\"),\"" asset-path "\",\"goog\",\"bootstrap\",\"nodejs.js\"));\n"

juhoteperi22:08:13

This file is written to :output-dir so path.resolve(\".\") will resolve to that?

juhoteperi22:08:30

:cljs-opts {:parallel-build true
                    :asset-path "test_suite.out"}
works with boot-cljs-test on Lumo

juhoteperi22:08:36

I also tried nil but either ClojureScript default doesn't work, or boot-cljs-repl overwrites nil value

juhoteperi22:08:56

I'll open issue about this

juhoteperi22:08:41

@anmonteiro Btw. it should be safe to include test in :source-paths always, and then you could remove the side-effecting testing task

anmonteiro22:08:21

hrm I can’t remember why I did that

anmonteiro22:08:33

I think it’s copy paste from another project where I didn’t want the test folder in the installed JAR?

anmonteiro22:08:50

I honestly can’t remember

juhoteperi22:08:51

:source-paths is not included in JARs, only resources are

juhoteperi22:08:10

I just tested the boot-cljs only with the conf you posted

juhoteperi22:08:29

It does work with default :asset-path IF you first cd into the target dir and then run node main.js

anmonteiro22:08:38

which makes sense

anmonteiro22:08:49

because target was not my output dir

juhoteperi22:08:50

I think the ClojureScript node output is only meant to work when when running from same dir?

anmonteiro22:08:57

yes, there are a few issues around that

anmonteiro22:08:15

perhaps it’s time we clean that up 🙂

juhoteperi22:08:15

And perhaps I should finally start testing boot-cljs with Node 😄

juhoteperi22:08:37

I do have some projects using boot-cljs-test but I don't touch those very often

juhoteperi22:08:46

Oh and I'm using PhantomJS on that project

juhoteperi22:08:07

Updating 293 -> 854 seems to break PhantomJS 😕

anmonteiro22:08:32

well that’s a pretty big update

juhoteperi22:08:06

Ah it was problem with old Schema

anmonteiro22:08:19

oh I’ve definitely seen that

juhoteperi22:08:25

Boot-cljs 2.0 -> 2.1 breaks both phantom and node tests

anmonteiro23:08:50

I think I found another bug in boot-cljs

anmonteiro23:08:00

this one is very minor

anmonteiro23:08:20

I think you’re overriding warnings and there’s a space missing in e.g. undeclared var warnings

anmonteiro23:08:30

between the var name and at line, etc....

anmonteiro23:08:52

just got a warning like undeclared Var my.ns/fooat line ...