lumo

:lumo: Standalone ClojureScript environment. Currently at version 1.9.0
onetom 2018-10-17T14:14:31.000100Z

i was just giving a try to lumo -n 5555 -D kitchen-async:0.1.0-SNAPSHOT using a tubular socket repl client from cursive eap8. my main use-case would be exploring http apis interactively, which is why i pulled in kitchen-async, hoping to ease the experience, but it breaks badly at the boundaries and im not sure what to do about it.

onetom 2018-10-17T14:18:23.000100Z

when an expression evaluates to a Promise i wont see what it resolves to. if i tuck a (p/then the-promise-im-interested-in prn), then it will be printed on the terminal (but not always :/) where i started lumo, instead of the socket repl client, in the cursive repl window

onetom 2018-10-17T14:20:50.000100Z

im wondering how others would deal with this

onetom 2018-10-17T14:24:50.000100Z

ah, yeah, the multi-line expressions are also printing a bunch of secondary prompts but after it appears in the cursive console and all on one line, so the output is quite a mess. i was looking at the source hoping to replace the prompt strings, but it seems the repl.js:prompt() function is not exposed in the cljs context.

onetom 2018-10-17T14:25:15.000100Z

im envisioning something like an automatic wrapper around promise return values with automatic printing of the resolved value, a timeout and a default .catch...

2018-10-17T14:32:01.000100Z

@onetom what is p in p/then, it's usually (-> a-promise (.then (fn [res] ..do smth..))). Did you try enabling dumb-terminal for the console logs, does it make a difference?

flag:
-d, --dumb-terminal

onetom 2018-10-17T14:32:31.000100Z

haven't thought about that, but let's see

onetom 2018-10-17T14:38:23.000100Z

doesn't make a difference

2018-10-17T14:40:10.000100Z

I guess then it's better to start the client in cursive, instead of socket-repl client. But not unlikely that you can transfer the logs over the socket, don't remember how it was, but I think stdout is transfered and stderr messages not. But let's see if someone else knows a better way.

onetom 2018-10-17T14:41:02.000100Z

what do you mean by "start the client in cursive"?

2018-10-17T14:42:04.000100Z

I'm not a cursive user, but I mean, skipping the -n 5555 and just start lumo with shell command from within the cursive terminal (I suppose there's one there?)

2018-10-17T14:44:15.000100Z

I should use the word IntelliJ* as Cursive is just a plugin. But do note that there's quite small support for lumo in text editors, even in Emacs where all we have is inf-clojure mode.

onetom 2018-10-17T14:50:54.000100Z

yeah, you can start it in a terminal, but that doesn't have any integration with the file editor area, so i can't send forms over to it... 😕

onetom 2018-10-17T17:46:48.000100Z

i was trying the custom socket repl accept function in lumo 1.9.0-alpha, but it seems to be ignored:

cljs.user=> dusty:lumo onetom$ lumo -n '{"port":5559, "accept":"XXX"}'
Lumo 1.9.0-alpha
ClojureScript 1.10.238
Node.js v9.10.1
...
Lumo socket REPL listening at localhost:5559.
cljs.user=>
then when i connect to it i get the usual repl behaviour:
dusty:lumo onetom$ nc localhost 5559
Lumo 1.9.0-alpha
ClojureScript 1.10.238
Node.js v9.10.1
...
cljs.user=> 123
123
cljs.user=>

onetom 2018-10-17T17:50:12.000100Z

i was expecting to see an error, since XXX is obviously a bogus function reference. i was trying with lumo -n '{"port":5559, "accept":"ethlib.repl/accept"}' originally of course, where src/ethlib/repl.cljs is :

(ns ethlib.repl)
(defn accept [socket & args]
  (.end socket (str "\nHello friend.\nYou gave me the following args: " args "\n\n")))
which i copied from https://github.com/anmonteiro/lumo/blob/master/examples/socketAccept/hello/world.cljs

onetom 2018-10-17T17:51:11.000100Z

i thought i would debug it by building my custom lumo, but it depends on the 5.90 GB Xcode... <sigh>

anmonteiro 2018-10-17T17:51:51.000100Z

@onetom you can run lumo in development without compiling the C++ code

anmonteiro 2018-10-17T17:51:55.000100Z

as long as you have Node.js installed

anmonteiro 2018-10-17T17:52:30.000100Z

btw I’m sorry the workflow is so rough

anmonteiro 2018-10-17T17:52:40.000100Z

but I don’t really use IntelliJ so I can’t really help

anmonteiro 2018-10-17T17:53:06.000100Z

wrt to your latest question though, have you included the folder where the ethlib.repl namespace is in the classpath?

onetom 2018-10-17T17:55:34.000100Z

it's in the src/ dir, which i would guess is in the class path, but i tried it with lumo -c src/ -n ... and it makes no difference

onetom 2018-10-17T17:56:00.000100Z

how can i run a modified version of lumo without boot release?

onetom 2018-10-17T17:56:25.000100Z

how are you using the lumo repl usually?

anmonteiro 2018-10-17T17:56:59.000100Z

you can run the development version with boot dev

anmonteiro 2018-10-17T17:57:05.000100Z

as long as you have Node.js installed

onetom 2018-10-17T17:58:03.000100Z

i just tried an earlier lumo (installed with brew install lumo) and it doesn't complain about the bogus accept function either:

dusty:lumo onetom$ lumo -n '{"port":5559, "accept":"XXX"}'
Lumo 1.8.0
ClojureScript 1.9.946
Node.js v9.2.0
...
Lumo socket REPL listening at localhost:5559.
cljs.user=&gt;

anmonteiro 2018-10-17T17:58:18.000100Z

because the function hasn’t been run

anmonteiro 2018-10-17T17:58:28.000100Z

it’ll probably fail if you telnet localhost 5559

anmonteiro 2018-10-17T17:58:45.000100Z

that said, it looks like 1.9.0-alpha has a bug where it doesn’t run the accept function

anmonteiro 2018-10-17T17:58:49.000100Z

mind opening an issue?

onetom 2018-10-17T17:59:06.000100Z

indeed it did fail!

anmonteiro 2018-10-17T17:59:37.000200Z

the function is only run when you connect to it

onetom 2018-10-17T18:00:05.000100Z

sure, i thought so, that's why i was showing above a connection attempt too.

onetom 2018-10-17T18:21:30.000100Z

im getting these circular dependency messages when i run boot dev:

...
Copying jar:file:/Users/onetom/.m2/repository/com/cognitect/transit-js/0.8.846/transit-js-0.8.846.jar!/com/cognitect/transit.js to /Users/onetom/.boot/cache/tmp/Users/onetom/github.com/anmonteiro/lumo/akl/fluhj4/main.out/com/cognitect/transit.js
Applying optimizations :simple to 82 sources
Optimizing with Google Closure Compiler, elapsed time: 19665.113763 msecs
Optimizing 82 sources, elapsed time: 20218.912582 msecs
Sifting output files...
Sifting output files...
Sifting output files...
Sifting output files...
Sifting output files...
Writing target dir(s)...
yarn run v1.10.1
$ node scripts/bundle.js --dev
Building development bundle...
Circular dependency: src/js/cljs.js -&gt; src/js/repl.js -&gt; src/js/cljs.js
Circular dependency: src/js/cli.js -&gt; src/js/cljs.js -&gt; src/js/repl.js -&gt; src/js/socketRepl.js -&gt; src/js/cli.js
Circular dependency: src/js/repl.js -&gt; src/js/socketRepl.js -&gt; src/js/repl.js
Circular dependency: src/js/cljs.js -&gt; src/js/repl.js -&gt; src/js/socketRepl.js -&gt; src/js/cljs.js
Done in 4.50s.
Elapsed time: 54.387 sec

onetom 2018-10-17T18:21:32.000100Z

is that expected?

anmonteiro 2018-10-17T18:21:43.000200Z

yes

anmonteiro 2018-10-17T18:21:52.000100Z

JS can have circular deps

onetom 2018-10-17T18:22:03.000100Z

then the build/ folder is empty 😕

onetom 2018-10-17T18:23:02.000100Z

yeah, i read the docs on the nodejs circular dependency handling the other week... it a weird choice how they just ignore it... 😕

onetom 2018-10-17T18:23:53.000100Z

i really wanted to debug this, but i guess i will just try to use the older version first, since that works

onetom 2018-10-17T18:38:20.000100Z

https://github.com/anmonteiro/lumo/issues/431

onetom 2018-10-17T18:46:34.000100Z

I managed to run the development version with node target/bundle.js -c target/ after starting boot dev. i think it worth mentioning it in the README, because it's not very obvious

anmonteiro 2018-10-17T19:11:30.000100Z

@onetom there’s yarn dev

anmonteiro 2018-10-17T19:11:47.000100Z

which you can run to start lumo in dev

anmonteiro 2018-10-17T19:11:55.000100Z

or npm run dev

onetom 2018-10-17T19:16:28.000100Z

found https://github.com/anmonteiro/lumo/blob/master/CONTRIBUTING.md as i was making a pull request and yarn dev is mentioned there