Fork me on GitHub
#boot
<
2016-04-23
>
shaunlebron19:04:25

started trying out boot for building a nodejs script

shaunlebron19:04:58

haven’t found examples for doing this yet

shaunlebron19:04:47

thinking that executing the script from the target directory could cause problems with finding node_modules

martinklepsch20:04:46

@shaunlebron: hey simple_smile are you compiling with whitespace/simple? if so maybe quickest solution would be to just move the file into .?

dominicm20:04:54

@shaunlebron: I'm not entirely sure it would yanno.

shaunlebron20:04:08

i’m not sure how to copy that over

dominicm20:04:36

That is, struggle to find node_modules.

shaunlebron20:04:17

out of curiosity, i was wondering if I could run boot script to compile and run a script on node without ever seeing the compiled js file at root, but it doesn’t really matter

shaunlebron20:04:58

@dominicm what do you mean by yanno

dominicm20:04:30

"You know" Just terrible slang I've picked up.

shaunlebron20:04:11

oh, yeah, that clears it up, thanks for the link

dominicm20:04:22

No problem simple_smile

shaunlebron20:04:42

sorry, i’m a bit confused about filesets in deftasks

shaunlebron20:04:18

i’d like to run node on the target output and not the fileset, as the last step of my deftask

shaunlebron20:04:45

(deftask site-gen []
  (comp
    (cljs :compiler-options sitegen-opts)
    (target :dirs #{"target"})))

shaunlebron20:04:27

not sure how to add a last step to execute node target/main.js

micha20:04:23

you can shell out to it, no?

martinklepsch20:04:10

@shaunlebron: you want to shell out but you're not sure how to correctly handle the fact that tasks need to return a fileset?

shaunlebron20:04:18

I can use sh, but I believe boot’s version of it runs relative to the fileset temp directory?

martinklepsch20:04:54

(with-pass-thru
  (boot.util/sh ["node" "..."]))

martinklepsch20:04:16

boot's sh isn't doing anything special

micha20:04:49

the only thing it provides ove what cl;ojure.shell does is that it will stream output from the shell command as it's produced

micha20:04:04

instead of buffering it until the shell command completes

micha20:04:50

so if the shell command you're running prints output you'll see it as it runs instead of getting the output all at once after the shell command is finished

micha20:04:32

the fileset isn't in a single directory

micha20:04:46

it's split up among a number of different temp dirs

micha20:04:09

so it doesn't have a single directory tree like node_modules does

micha20:04:26

the fileset is the product of overlaying these different directories over each other

martinklepsch20:04:31

@shaunlebron: working version of the above:

(deftask x []
  (with-pass-thru fs
    (boot.util/sh "ls" "-lah")))

shaunlebron20:04:48

thanks for the details @micha

shaunlebron20:04:02

(def sitegen-opts
  {:target :nodejs
   :optimizations :simple})

(deftask run-site-gen []
  (with-pass-thru fs
    (sh "node" "target/main.js")))

(deftask site-gen []
  (comp
    (cljs :compiler-options sitegen-opts)
    (target :dir #{"target"})
    (run-site-gen)))

shaunlebron20:04:49

i’m not getting any output from sh on whether it ran or not

micha20:04:11

try boot.util/dosh

micha20:04:03

that will block

micha20:04:28

boot.util/sh won't block on completion

shaunlebron20:04:31

awesome thanks

shaunlebron20:04:39

i’m getting output from the running node process but with errors

shaunlebron20:04:11

Error: cljs.core/*main-cli-fn* not set

shaunlebron20:04:49

sorry, I set this value inside my sitegen.core, but I can’t seem to set :main compiler option to point to sitegen.core since it is replaced by boot-cljs to something else

micha20:04:09

you ahve a .cljs.edn file?

shaunlebron20:04:35

I’m confused by the concept of a cljs.edn file per build

martinklepsch20:04:47

$name.cljs.edn files can be used to specify/configure builds in a composable way (perhaps multiple), details are here: https://github.com/adzerk-oss/boot-cljs/wiki/Usage#multiple-builds

shaunlebron20:04:49

I thought the config is fed into the cljs task in my boot file

martinklepsch20:04:23

@shaunlebron: right and for some options thats true but for others it's not: https://github.com/adzerk-oss/boot-cljs/wiki/Usage#options

martinklepsch20:04:17

The issue with passing all options to the cljs task is that you would not be able to create multiple builds with varying configurations

micha20:04:55

also you couldn't have tasks that add cljs options

micha20:04:10

or help you to configure cljs properly

martinklepsch20:04:50

e.g. cljs-repl and reload tasks inject things into your build without you needing to touch your code

shaunlebron21:04:25

sorry there’s a lot I don’t understand here

shaunlebron21:04:38

and thanks for your help so far

shaunlebron21:04:59

I created a main.cljs.edn file and put it in my root project directory

shaunlebron21:04:21

I don’t think it’s being picked up by boot-cljs

shaunlebron21:04:19

would either of you like to google hangout / screenshare for a bit

shaunlebron21:04:24

i’d like to meet yall anyway

martinklepsch21:04:52

@shaunlebron: the cljs.edn file needs to be on the classpath. so any of the dirs in :source-paths or :resource-paths

shaunlebron21:04:51

it’s saying “writing main.cljs.edn"

shaunlebron21:04:56

I have it in src

martinklepsch21:04:28

and src/is in :source-paths I guess?

martinklepsch21:04:08

the "writing main.cljs.edn" is printed if there is none. boot-cljs creates one for you in that case.

shaunlebron21:04:49

all the boot parts seem to working now

martinklepsch21:04:09

I can't do hangout right now btw, but would love to some other time

martinklepsch21:04:07

@shaunlebron: cool! are you doing static site generation using rum's new server side rendering stuff?

shaunlebron21:04:35

that requires clojure, I’m specifically trying to stay in cljs

shaunlebron21:04:12

just rendering normal hiccups with the runtime hiccups renderer function

shaunlebron21:04:41

there will be some dynamic parts like the api docs sidebar which will use a hiccup function that can be fed to either hiccups.runtime for the static part or to rum during user interaction

shaunlebron21:04:52

haven’t figured it out yet really

shaunlebron21:04:42

not sure if that made sense

martinklepsch21:04:20

not sure I got it either 😄

martinklepsch21:04:07

but it's late here...

shaunlebron21:04:12

i’m not sure I can use the static rum stuff in cljs I mean

shaunlebron21:04:06

yeah, it’s just for clojure

shaunlebron21:04:31

alright boot experts, thanks again for the help

richiardiandrea23:04:45

hello folks, I was wondering if boot new has already generators for, say, create the boilerplate env dir that is used for instance in the Luminous framework

richiardiandrea23:04:46

oh sorry I did not read until the end, basically it is already possible to generate, say, foo.bar.config in env/prod and env/dev thanks to the ns generator, cool stuff!