Fork me on GitHub
#boot
<
2016-06-28
>
Petrus Theron11:06:18

I want to combine my boot cljs compile/reload hosting and compojure server in one boot task. Is this a good idea, and how do I go about it?

martinklepsch11:06:47

@petrus: you can use the serve task with your compojure handler if you have one globally defined (i.e. you're not using component or similar)

martinklepsch11:06:07

in general it is a good idea of course 🙂

Petrus Theron11:06:43

@martinklepsch, do I then pass in my compojure app handler to serve’s :not-found handler? And is there a template of someone doing this already?

Petrus Theron12:06:55

I ended up copypastaing from this repo: https://github.com/Deraen/saapas/

Petrus Theron12:06:08

but now I get this warning: ClojureScript could not load :main, did you forget to specify :asset-path?

Petrus Theron13:06:31

got it working. didn’t understand the magic behind main.cljs.edn

martinklepsch13:06:04

@petrus: any particular questions? The main idea behind .cljs.edn is that you can have multiple builds with independent tasks modifying those builds (e.g. injecting dev tooling like repl/reload/cljs-devtools)

lwhorton16:06:12

is there a way to just get boot to install the listed :dependencies but do nothing else? right now i have a deftask that just logs “hey”, which triggers deps… but that feels icky

micha16:06:01

@lwhorton: just typing boot on the command line will do that, if your dependencies are in set-env!

micha16:06:52

@lwhorton: the only time you need a deps task is when you load dependencies dynamically in your tasks

micha16:06:59

like for example in pods

micha16:06:21

and in that case there is no way for boot to know what you're going to do dynamically in pods

lwhorton17:06:31

i see .. very helpful, thanks

lwhorton22:06:40

does anyone have an example of how you might run npm install from boot assuming the host has npm available on the path? i’ve tried the very basic:

(deftask install-deps
  "Install node dependencies before attempting to use them."
  []
  (c/with-pre-wrap fileset
    (conch/with-programs [npm]
      (apply npm ["install" "postcss" "postcss-modules"]))
    fileset))
with no success… also tried with (util/dosh) but I think this is more complicated than I hoped.

lwhorton22:06:44

sounds like a place where I would want to use a pod, i think… and not litter the userland with installs — but i dont know if that supports non-jvm environments likenode

micha22:06:45

what do you see happening?

micha22:06:08

pods provide JVM classloader isolation

micha22:06:19

they won't help with running other separate processes

micha22:06:27

they are already isolated

lwhorton22:06:42

assuming I want to run some node script “myscript”, installing said script locally via something like npm install -g myscript, I can do just fine with conch

lwhorton22:06:52

i read the stdout of the process, it can read the stdin of my task, everything’s dandy

micha22:06:57

(dosh "npm" "install" "postscc")

micha22:06:38

is that not what you're trying to do?

lwhorton22:06:46

but trying to move this to where it’s a 1-button solution for someone else to pull in… without having to have postcss-modules installed globally, would be great.

lwhorton22:06:18

it is- but when I do that it just kinda .. doesnt’ work? it doesn’t give any error message, but running the script right after that does a require(‘postcss’) dies right during the require

micha22:06:31

i'd make a Makefile or init.sh script that installs npm modules or whatever

micha22:06:53

they can just run ./init.sh once

lwhorton22:06:25

as part of the task, or external to the task?

micha22:06:36

are you making sure you're waiting for the external process to finish?

micha22:06:43

you might need to block on it

lwhorton22:06:47

i thought dosh already blocked?

micha22:06:13

yes it does

micha22:06:30

i'm not familiar with the with-programs macro

micha22:06:48

but yeah, personally i'd just have a separate script that does all the npm prep

micha22:06:09

or a Makefile if i was going to do something that was aware of updates

lwhorton22:06:23

i see. how would you deliver that package to the end user?

micha22:06:43

oh i guess it depends who the end user is

micha22:06:02

i was imagining you'd have a git repo and the end user would be a developer

micha22:06:11

in which case the makefile or whatever is in the repo

lwhorton22:06:29

let’s assume it’s someone who wants to use a pre-defined boot task and I dont have control over them.. ideally I would want them to only require the boot task… but it seems like that’s not really an option

micha22:06:48

does npm have a javascript api?

micha22:06:54

like is embedded npm a thing?

micha22:06:59

probably not lol

lwhorton22:06:09

hah good question, i doubt it

micha22:06:13

but if it is then you can run npm in a nashorn in a pod

lwhorton22:06:14

I tried nashorn originally

lwhorton22:06:31

wasn’t getting very far, too new to the whole scene

micha22:06:55

you just need npm modules right?

micha22:06:08

you don't necessarily need npm to manage dependencies?

micha22:06:14

are there native modules involved?

micha22:06:23

like compiling with gcc etc?

lwhorton22:06:25

there are, yea, since node will be a dependency

lwhorton22:06:36

but anything non-native I would like to avoid that install step

micha22:06:45

there may be a decent maven repo with the dependencies you need

micha22:06:19

like when i did stuff with jython i found all the libraries i needed via maven

micha22:06:47

so it was super clean, i just added the python packages to the :dependencies of the jython pod

micha22:06:01

no need to mess with pip etc

lwhorton22:06:18

oh that sounds nice

micha22:06:40

oh but you need node specifically

micha22:06:48

maybe node only works with npm i dunno there

lwhorton22:06:23

you may be on to something with an internal api

lwhorton22:06:39

looks like there is some, just not well documentedd - might be able to npm install inside myself?

lwhorton22:06:45

ill let you know- thanks again

micha22:06:53

good luck 🙂

jyriand23:06:58

hi. I need to put clojurescript output to resources/public folder so that my ring handler could serve these files as static content. This should work in dev environment with (watch) and (reload) etc. Can’t really figure out a way to do this. Any ideas?

micha23:06:00

@jyriand: i recommend serving them from the classpath with wrap-resource etc. in dev

micha23:06:24

otherwise you can use the sift task to move files around in the fileset as you like

currentoor23:06:09

I'm trying to use sente in a boot application but it fails with an error complaining about a library that uses cljx.

currentoor23:06:47

Do I need to do anything special to use a library written in cljx? The cljx code is not in my code.

micha23:06:25

@currentoor: https://github.com/Deraen/boot-cljx looks like the thing you need

currentoor23:06:54

@micha i tried that, but i think it only works for files in your project

micha23:06:28

you're saying there is .cljx files in a jar that need to be compiled?

micha23:06:03

i thought that the practice there was to package transpiled artifacts in jars, so the consumer doesn't need cljx

micha23:06:12

you should look in the jar to make sure

currentoor23:06:14

hmm could be, i'm not sure

currentoor23:06:23

how do i do that?

micha23:06:27

jar tf /the/jar/file.jar

micha23:06:31

that will show you all the files in there

micha23:06:38

so you should see .cljs files for instance

micha23:06:47

or you can just open the jar file in vim or emacs

micha23:06:50

and look around

currentoor23:06:42

@micha yeah there are cljx files in here

currentoor23:06:49

~/.m/r/c/t/t/1.1.1 $ jar tf truss-1.1.1.jar 
META-INF/MANIFEST.MF
META-INF/maven/com.taoensso/truss/pom.xml
META-INF/leiningen/com.taoensso/truss/project.clj
project.clj
META-INF/leiningen/com.taoensso/truss/README.md
META-INF/leiningen/com.taoensso/truss/LICENSE
META-INF/
META-INF/maven/
META-INF/maven/com.taoensso/
META-INF/maven/com.taoensso/truss/
META-INF/maven/com.taoensso/truss/pom.properties
taoensso/
taoensso/truss/
taoensso/truss/impl.clj
taoensso/truss/impl.cljs
taoensso/truss.clj
taoensso/truss.cljs
taoensso/truss/examples.cljc
taoensso/truss/impl.cljx
taoensso/truss.cljx

micha23:06:53

are there .cljs files in there though?

micha23:06:05

yeah the .cljs files are the ones you care about

micha23:06:25

and .clj of course too