Fork me on GitHub
#boot
<
2017-11-19
>
au-phiware01:11:10

Hello, I'm new to boot and am attempting to try some ideas that haven't worked well with lein... I'm attempting to build an app with multiple targets, i.e. an isomorphic app with a cljs :server target (that targets nodejs) and a cljs :client target (that targets the browser). The interesting part that the two target may have namespaces that are shared and namespaces that are conflicting. I thought that pods would be the ideal way to isolate that two builds from each other, however I can't figure out how to run tasks within a pod... is it a good idea or should I use something like degree9/boot-exec?

au-phiware01:11:16

Any help or advice would be greatly appreciated, I have a sample project here: https://github.com/au-phiware/boot-isomorphic

flyboarder01:11:25

@au-phiware that’s not really what I designed boot-exec for, it’s for shelling out to other executables

flyboarder01:11:16

http://GitHub.com/Degree9/meta has an example of a client/server setup both using cljs

au-phiware01:11:45

thanks for the pointer, I'll check it out

flyboarder01:11:53

That’s just a proof of concept task, doesn’t have any real purpose

flyboarder01:11:17

You are looking for boot-multibuild

flyboarder01:11:10

However usually I refactor before attempting that approach, it’s not really needed for dual cljs projects

au-phiware01:11:40

reading meta's readme... wish I'd found that months ago, sounds like a great stack!

flyboarder01:11:57

It works well enough, but has limited documentation

flyboarder01:11:43

The goal was a simple app in under 1 minute, which usually takes a few attempts to get running

au-phiware02:11:06

I think I'd prefer to just pilfer some of its ideas anyway 🙂

flyboarder02:11:41

Yeah thats probably best until it hits a stable version

Ruben W19:11:11

I want to make some resources of a webjar (fonts/images) available on the class path. Can anyone give me a hint of how to do that using boot?

richiardiandrea20:11:44

@freakinruben as long as the webjar is on the classpath, you should see your assets on the files, you can append the target task at the end of the chain for seeing where they are located (or (show :fileset true))

Ruben W20:11:44

the assets are inside the webjar, in my dependencies I have [org.webjars.bower/semantic "2.2.13"] (show :fileset true) only shows the files that are actually in my project

Ruben W20:11:11

(show :classpath true) shows that the jar is on the classpath /Users/myhomefolder/.m2/repository/org/webjars/bower/semantic/2.2.13/semantic-2.2.13.jar

richiardiandrea20:11:21

@freakinruben I am working on semantic UI and boot as well

richiardiandrea20:11:57

I am really find it hard to use less4clj because it seems like the Java implementation is very limited compared to the JS one

Ruben W20:11:02

Ah I see, I’m still exploring the boot-niverse and besides compiling semantic, I haven’t run into lots of complications with less4clj

richiardiandrea20:11:42

I think semantic-ui is the toughest thing I could find in my quite long experience with boot...not boot's fault...

richiardiandrea20:11:03

the task is actually very easy:

(deftask include-semantic
  "Compile and prepare the css files"
  []
  (comp
   ;; (sift :add-jar #{['cljsjs/semantic-ui #"cljsjs/semantic-ui/common/.*\.css"]})
   (sift :move {#_#"cljsjs/semantic-ui/common/(.*\.css)" #_"css/$1"
                #"semantic-ui-less/definitions" "css/definitions"
                #"semantic-ui-less/themes" "css/themes" ;; need this here for less
                #"semantic-ui-less/_site" "css/_site"
                #"semantic-ui-less/semantic.less" "css/semantic.less"
                #"semantic-ui-less/theme.less" "css/theme.less"})
   (less)
   (sift :move {#"css/themes/" (str serve-dir "themes/")})
   (sift :move {#"css/" (str serve-dir "css/")})))

richiardiandrea20:11:35

but a lot of warnings are coming out of that

Ruben W20:11:44

less4j warnings?

martinklepsch20:11:50

@freakinruben (io/resource “path/to/file/in/jar”) should work IIRC

Ruben W20:11:23

yeah saw those quite a few of those already

richiardiandrea20:11:23

I am even thinking of dropping less compilation completely and just use css

Ruben W20:11:28

much appreciated

Ruben W20:11:35

hm, that seems wrong 😕

martinklepsch20:11:33

I find that when using Tachyons I often don’t have the need for a preprocessor, not always an option though

richiardiandrea20:11:37

what I will try today is to use https://github.com/degree9/boot-npm in order to use lessc for compilation

flyboarder20:11:04

@richiardiandrea if you have any issues let me know!

richiardiandrea20:11:33

@flyboarder oh ok, I see already an issue in what I wanted to do

richiardiandrea20:11:48

my task will be in a watch

richiardiandrea20:11:59

and I wouldn't want to install the package every time

flyboarder20:11:49

it wont reinstall

flyboarder20:11:23

since it’s already in the managed folder, however it will check every time

flyboarder20:11:13

I have plans for a restartable task, basically something more generic than what is in boot-nodejs

richiardiandrea20:11:21

it is good then for now, trying 😄

Ruben W20:11:49

@richiardiandrea thanks a lot, this seems to do the trick for what I want:

(deftask include-semantic-assets
  "Copy assets like fonts and images from semantic-ui to classpath"
  []
  (comp
    (sift :add-jar #{['org.webjars.bower/semantic #"dist/themes"]})
    (sift :move {#"META-INF/(.+)/dist/themes" "public/themes"})))

richiardiandrea20:11:45

@freakinruben yeah that works, however let me know what you get from compiling, I did not get themes when switching, say, from default to material here

Ruben W20:11:33

same here… default works fine (one warning), but with material it grows to about 18 warnings and a not really functioning css

Ruben W20:11:04

less then optimal would be to use a non-java less compiler.. haven’t tried anything like that with boot

richiardiandrea20:11:00

yeah I am trying exactly that

Ruben W20:11:48

ah, I’m really curious about the outcome!

flyboarder20:11:24

@freakinruben not for preprocessing however I use boot with external apps all the time

flyboarder20:11:43

works well, they get their own managed folder which gets added to the fileset

richiardiandrea21:11:23

@flyboarder one question I have is what is the pattern you use if you have a file from the fileset that needs to be passed as parameter to npm/exec...maybe I should actually use boot-exec here

flyboarder21:11:03

@richiardiandrea as it currently stands boot-exec expects files to be in the root of a project, or passed in via task arguments

flyboarder21:11:18

Via a wrapper task

richiardiandrea21:11:51

ok so you actually need to execute the exec task yourself inside the wrapper

flyboarder21:11:34

Boot-npm is an example of this

flyboarder21:11:58

@richiardiandrea so if your files exist only on the fileset (resources Etc.) you will want a task that copies them into a tmp dir then passes that tmp dir to the exec task

flyboarder21:11:17

You can wrap that as a single task

flyboarder21:11:48

Boot-exec can support cache and temp directories which are boot managed or absolute paths

richiardiandrea21:11:15

@flyboarder should I see the std output of the command?

richiardiandrea21:11:41

ok cool so then I am doing it wrong 😄

flyboarder21:11:50

@richiardiandrea are you proving a :directory or :cache option?

richiardiandrea21:11:20

no for now it is just a call to exec/exec :process "lessc"

flyboarder21:11:35

@richiardiandrea ok so that will run lessc in a tmp dir

flyboarder21:11:49

which is probably empty

richiardiandrea21:11:58

uhm I am passing (exec/exec :process "lessc" :arguments [( .getAbsolutePath less-tmp-file) (.getAbsolutePath compiled-file)])

flyboarder21:11:47

oh that should work, since the arguments are absolute

richiardiandrea21:11:08

yeah I was thinking that would work, I am probably not invoking it correctly

richiardiandrea21:11:16

given its middleware nature

richiardiandrea21:11:33

(let [handler (exec/exec :process "lessc" :arguments [( .getAbsolutePath less-tmp-file) (.getAbsolutePath compiled-file)])]
          (handler new-fs))

flyboarder21:11:08

I would enable debug mode on boot to see exactly which arguments are being passed in

richiardiandrea21:11:12

yeah it is not even called

richiardiandrea21:11:41

right, I need on more call

richiardiandrea21:11:32

Magic!

(let [mw (exec/exec :process "lessc" :arguments [( .getAbsolutePath less-tmp-file) (.getAbsolutePath compiled-file)])
              handler (mw identity)]
          (handler new-fs))
ardi/git/ar-website/dk2/alhi8w/css/blog.css
Executing Process: lessc
Executing Process with arguments: ["/home/arichiardi/.boot/cache/tmp/home/arichiardi/git/ar-website/dk2/fwjp2k/css/blog.main.less" "/home/arichiardi/.boot/cache/tmp/home/arichiardi/git/ar-website/dk2/alhi8w/css/blog.css"]
Process failed with...: 
 null 
Process completed successfully...

flyboarder21:11:46

lol ok so failed with null means it couldn’t find the binary you are trying to execute

flyboarder21:11:06

I have an issue created for that, it should fail the build entirely

richiardiandrea21:11:06

oh nice at least we know what is failing

flyboarder21:11:22

but right now it passes on non-zero error codes

richiardiandrea21:11:07

when I use npm/exec it is better

richiardiandrea21:11:18

Process failed with...: 
 npm ERR! code E404
npm ERR! 404 Not Found: lessc@*

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/arichiardi/.npm/_logs/2017-11-19T21_54_55_866Z-debug.log
 
Process completed successfully...
Executing Process: lessc
Process failed with...: 
 null 

richiardiandrea21:11:40

oh right, it is less and....works!

richiardiandrea21:11:03

uhm...actually not quite...but getting there

flyboarder21:11:18

I should really put together a boot-css task with a bunch of preprocessors out-of-the-box

flyboarder22:11:35

@richiardiandrea so there is also a :process option for npm/exec when the exec is different than the npm name

richiardiandrea22:11:02

yep that works, I think I got it going, thanks for the support @flyboarder I am now playing with the relative paths

richiardiandrea22:11:10

Executing Process: /home/arichiardi/git/ar-website/node_modules/less/bin/lessc
Process failed with...: 
 FileError: 'css/semantic.less' wasn't found. Tried - /home/arichiardi/.boot/cache/tmp/home/arichiardi/git/ar-website/fb4/fwjp2k/css/css/semantic.less,/home/arichiardi/.boot/cache/tmp/home/arichiardi/git/ar-website/fb4/fwjp2k/css/css/semantic.less,css/semantic.less in /home/arichiardi/.boot/cache/tmp/home/arichiardi/git/ar-website/fb4/fwjp2k/css/blog.main.less on line 1, column 1:
1 @import "css/semantic.less";
2 

 
Process completed successfully...

richiardiandrea22:11:25

it will work at the end of today 💪