Fork me on GitHub
#cljsrn
<
2020-05-07
>
Oliver George01:05:57

Yeah, I'm not demonstrably a muppet this time. Needs to be "-c -r" to generate it though. I'll log a bug.

dnolen15:05:46

untested but I believe everything is in place

dotemacs15:05:28

Thanks for that @dnolen I’ll give it a spin right away

dnolen15:05:30

feel free report any tweaks this needs

dnolen15:05:54

I won't be able to help out wrt. to actually trying this, busy with other stuff - but I don't think there's anything missing to make it work

đź‘Ť 4
dnolen15:05:44

krell.api/build is generally useful for scripts

dnolen15:05:09

(krell.api/build :some-build {:verbose true} "more_opts.edn") works

dnolen15:05:18

all options merged left to right

dotemacs16:05:15

The first thing that is missing is '[ :as io] in the :require clause, as io is used.

dnolen16:05:12

fixed thanks

dotemacs16:05:46

This is what happens. I eval this in Emacs:

(setq cider-custom-cljs-repl-init-form
      "(require '[cider.piggieback]
         '[ :as io]
         '[krell.api :as krell]
         '[krell.repl])

(def config (slurp (io/file \"build.edn\")))
(krell/build config)
(apply cider.piggieback/cljs-repl (krell.repl/repl-env) (mapcat identity config))")
From the root of the project, where deps.edn is, I run M-x cider-jack-in-cljs, which runs:
/usr/local/bin/clojure -Sdeps '{:deps {nrepl {:mvn/version "0.6.0"} cider/piggieback {:mvn/version "0.4.2"} refactor-nrepl {:mvn/version "2.4.0"} cider/cider-nrepl {:mvn/version "0.24.0"}}}' -m nrepl.cmdline --middleware '["refactor-nrepl.middleware/wrap-refactor", "cider.nrepl/cider-middleware", "cider.piggieback/wrap-cljs-repl"]'
Then I’m prompted what REPL type I want, and I type custom. The REPL starts, and this is returned:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See  for further details.
nil#'user/configFileNotFoundException {:main awesome-project.core
:output-to "target/main.js"
:output-dir "target"}
(No such file or directory)  .FileInputStream.open0 (FileInputStream.java:-2)
IllegalArgumentException Don't know how to create ISeq from: java.lang.Character  clojure.lang.RT.seqFrom (RT.java:550)

dnolen16:05:16

need to see a full stracktrace - no much use otherwise

dotemacs16:05:51

RT.java:  550  clojure.lang.RT/seqFrom
                   RT.java:  530  clojure.lang.RT/seq
                  core.clj:  137  clojure.core/seq
                  core.clj:  717  clojure.core/concat/fn
              LazySeq.java:   40  clojure.lang.LazySeq/sval
              LazySeq.java:   49  clojure.lang.LazySeq/seq
                   RT.java:  528  clojure.lang.RT/seq
                  core.clj:  137  clojure.core/seq
                  core.clj:  726  clojure.core/concat/cat/fn
              LazySeq.java:   40  clojure.lang.LazySeq/sval
              LazySeq.java:   49  clojure.lang.LazySeq/seq
                 Cons.java:   39  clojure.lang.Cons/next
                   RT.java: 1785  clojure.lang.RT/boundedLength
               RestFn.java:  130  clojure.lang.RestFn/applyTo
                  core.clj:  659  clojure.core/apply
                  core.clj:  652  clojure.core/apply
                      REPL:    8  user/eval21162
                      REPL:    8  user/eval21162
             Compiler.java: 7062  clojure.lang.Compiler/eval
             Compiler.java: 7025  clojure.lang.Compiler/eval
                  core.clj: 3206  clojure.core/eval
                  core.clj: 3202  clojure.core/eval
                  main.clj:  243  clojure.main/repl/read-eval-print/fn
                  main.clj:  243  clojure.main/repl/read-eval-print
                  main.clj:  261  clojure.main/repl/fn
                  main.clj:  261  clojure.main/repl
                  main.clj:  177  clojure.main/repl
               RestFn.java: 1523  clojure.lang.RestFn/invoke
    interruptible_eval.clj:   79  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:   55  nrepl.middleware.interruptible-eval/evaluate
    interruptible_eval.clj:  142  nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
                  AFn.java:   22  clojure.lang.AFn/run
               session.clj:  171  nrepl.middleware.session/session-exec/main-loop/fn
               session.clj:  170  nrepl.middleware.session/session-exec/main-loop
                  AFn.java:   22  clojure.lang.AFn/run
               Thread.java:  834  java.lang.Thread/run

dnolen16:05:13

this is why I don't use nREPL

dnolen16:05:03

oh another bug in the code I wrote

dotemacs16:05:14

Aha 🙂

joshmiller16:05:56

@dnolen It’s working for me over here, thanks for the update

dotemacs16:05:54

I can confirm that it works for me too! Thanks @dnolen

dotemacs16:05:31

Working steps: Eval this in Emacs:

(setq cider-custom-cljs-repl-init-form
      "(require '[ :as io]
         '[clojure.edn :as edn]
         '[cider.piggieback]
         '[krell.api :as krell]
         '[krell.repl])

(def config (edn/read-string (slurp (io/file \"build.edn\"))))
(krell/build config)
(apply cider.piggieback/cljs-repl (krell.repl/repl-env) (mapcat identity config))")
M-x cider-jack-in-cljs When prompted for the REPL type provide custom. The REPL will start and you’ll see user> Start the simulator: react-native run-ios. Once the the connection is established, the REPL prompt will change to: cljs.user>.

joshmiller16:05:12

@dotemacs Any idea if we can set the REPL type automatically to skip that step?

dotemacs16:05:22

If by “automatically” you mean we write a custom .dir-locals.el which will set that variable for us, then yes 🙂 But on the serious note, we should submit a patch that runs that step for us when it detects Krell.

joshmiller16:05:06

Heh, I was already putting the cljs-repl-init form into .dir-locals.el

dotemacs16:05:08

The same way it does it for the other tools, like for shadow-cljs…

joshmiller16:05:06

Do you know which cider variable sets that repl type? I’m paging through the 8 million of them and not seeing anything off the top of my head.

dotemacs16:05:44

I’m trying to find the place where it’s configured for other tools… digging around on GitHub right now…

đź‘Ť 4
dnolen17:05:17

glad it's working!

đź‘Ź 8
dotemacs17:05:15

The way I see it, you can tell easily if a project is lein, boot, shadow-cljs… based, simply based on the config file: project.clj, boot…, deps.edn, shadow-cljs.edn. But for krell, I guess we have to see if it’s a dependency …

joshmiller17:05:06

Ah, I see. I was just looking to set the repl type to custom, this would skip that step entirely.

dotemacs17:05:13

I get you. But I was hoping that there could be a “smart” step within CIDER that would figure out if it’s a Krell based project and then just inject the dependency. If it can’t figure it out, then it would revert to prompting the user…

joshmiller17:05:53

I mean, you could rename build.edn in your project to krell-build.edn and look at that, but then you have to explain the difference to official docs.

dotemacs17:05:43

I guess that could be an option.

dotemacs17:05:19

But for now, I guess we could “suffer” this manual approach and see if that will be painful enough to warrant a PR…

joshmiller17:05:30

I’m going to commit the current setup to a blog post so it doesn’t get lost to the sands of Slack.

đź‘Ť 8
dotemacs17:05:53

Nice 🙂

dotemacs17:05:30

I created this issue to start a discussion: https://github.com/clojure-emacs/cider/issues/2841

dnolen17:05:48

thanks for writing that up

đź‘Ť 4
dotemacs17:05:58

But it was @dnolen who did all the work, so all kudos to him 🙂

đź‘Ť 4
dotemacs17:05:52

I’m just mentioning that in reference to your blog post @joshmiller because you gave me credit 🙂

dotemacs17:05:44

Maybe you can amend it and also add cider-cljs-repl-type set to custom?

joshmiller17:05:30

Tried that, no dice on skipping the repl type selection step.

đź‘Ť 4
dotemacs18:05:45

@joshmiller this works, after adding it to .dir-locals.el:

((nil . ((cider-default-cljs-repl . custom)
         (cider-custom-cljs-repl-init-form . "(require '[ :as io]
         '[clojure.edn :as edn]
         '[cider.piggieback]
         '[krell.api :as krell]
         '[krell.repl])
(def config (edn/read-string (slurp (io/file \"build.edn\"))))
(krell/build config)
(apply cider.piggieback/cljs-repl (krell.repl/repl-env) (mapcat identity config))"))))
you can just C-c M-J. You won’t get prompted for anything.

đź‘Ť 4
joshmiller18:05:12

Oh cool, let me try that

joshmiller18:05:08

That works, I’ll update.

đź‘Ť 4
adamtait21:05:20

I would love to hear if anyone has tips/scripts on making an iOS archive from a Krell app? It seems that re-natal has a complicated story based on leiningen for building publish-able archives. Unfortunately, the https://github.com/vouch-opensource/krell/wiki/Reagent-Tutorial#production-build tip hasn’t helped me; I haven’t seen a main.js being built and iOS archives result in an app waiting for the Krell repl socket.

adamtait21:05:46

ha I keep asking questions then fixing them myself shortly after. In case anyone has similar questions, this process seems to work:

clj -Srepro -m krell.main -v -co build.edn -O advanced -c
npx react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'
# finally, run standard build/archive process in XCode following 

đź‘Ť 4