Fork me on GitHub
#calva
<
2023-04-16
>
pez16:04:32

Dear Calva-friends, an extra exciting release today: https://github.com/BetterThanTomorrow/calva/releases/tag/v2.0.352https://github.com/BetterThanTomorrow/calva/issues/2152https://github.com/BetterThanTomorrow/calva/issues/2157 Where the exciting part is the custom Jack-in command lines. From https://calva.io/connect-sequences/#custom-command-line: > Custom command lines are there to bridge the gap to those situations where standard Jack-in command lines don’t reach. Like: > 1. You want to provide command line options to a supported tool, which Jack-in does not provide > 2. Your project has some script through which it is started > 3. The REPL is provided by some tool that Calva does not know of > 4. Any other reason... > A custom command line is executed from same directory as the REPL project root (See projectRootPath, above), and can be as simple as my-repl-jack-in-command. You can use a relative or absolute path to your command line.

🙌 4
seancorfield17:04:21

@pez I'm experimenting with "autoSelectForJackIn": true and noticed that if you provide an alias that include :main-opts Calva does not omit -m nrepl.cmdline ... which it does if you select the exact same aliases for a manual jack-in.

seancorfield17:04:22

(it happens to work in my situation but it's still "wrong") Here are the two jack-in command-lines, the first with auto true, the second with auto false and the same selections

pushd /var/www/worldsingles ; clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"}}}' -M:build:dev:+default:test:vscode-calva-jack-in -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" ; popd
pushd /var/www/worldsingles ; clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"}}}' -M:+default:build:dev:test:vscode-calva-jack-in ; popd

seancorfield17:04:40

:vscode-calva-jack-in
  {:extra-deps {com.datomic/dev.datafy {:git/sha "4a9dffb"
                                        :git/tag "v0.1"
                                        :git/url ""}
                djblue/portal {:mvn/version "RELEASE"}
                io.github.seancorfield/dot-clojure
                {:git/tag "v1.0.1"
                 :git/sha "e932f96"}
                io.github.stuarthalloway/reflector
                {:git/sha "93a0c19b4526c1180959e940202928d35e5c3cef"}
                jedi-time/jedi-time {:mvn/version "RELEASE"}
                party.donut/dbxray {:mvn/version "RELEASE"}}
   :main-opts ["-e" "((requiring-resolve 'org.corfield.dev.repl/start-repl))"]}

seancorfield17:04:01

"calva.replConnectSequences": [
    {
      "name": "World Singles Backend (Jack-In)",
      "projectType": "deps.edn",
      "autoSelectForJackIn": false,
      "projectRootPath": ["/var/www/worldsingles"],
      "menuSelections": {
        "cljAliases": ["build", "dev", "+default", "test", "vscode-calva-jack-in"]
      }
    }
  ],

seancorfield17:04:20

(toggle that to true to see the difference in the command)

seancorfield17:04:21

Or it is something in the "copy" logic as opposed to the execute logic that causes this and the actual command-line executed is right?

seancorfield17:04:56

No, it still uses the "wrong" jack-in command:

; Starting Jack-in Terminal: pushd /var/www/worldsingles ; clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"}}}' -M:build:dev:+default:test:vscode-calva-jack-in -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" ; popd

pez17:04:09

Good find! We need to fix it.

seancorfield17:04:46

The projectRootPath is "An array of path segments" -- but it can be just a single absolute path (see above). When might it need to actually be multiple sequences?

pez17:04:19

When you need it to work both on Windows and Unix.

seancorfield18:04:27

Calva has afterCLJReplJackInCode to execute Clojure code in the newly-connected REPL, but it doesn't have anything to auto-trigger one or more Calva commands after a successful jack-in. I know I could probably rig up some Joyride code to jack-in and then run other stuff but this seems like a good opportunity for more automation within Calva...? On a related note, I see there's autoConnectRepl to automatically reconnect to an external running REPL on start/reload -- what would be the pros of autoJackInRepl: true to automatically jack-in on start/reload if there wasn't already a REPL to connect to?

pez19:04:59

It should be reasonable simple to add some command triggers after successful connect.

pez19:04:37

autoJackInRepl sounds good to me.

seancorfield19:04:32

In particular, after a successful jack-in or reconnect, I want to run the custom repl snippets that set up my Portal windows.

seancorfield19:04:14

I've been updating all my projects with auto-jack-in and auto-connect REPL sequences this morning -- including my work setup. Makes life much simpler!

pez19:04:25

:the_horns:

seancorfield21:04:33

Thanks for "auto" jack-in/connect REPL connect sequence selection stuff!

🙏 2
calva 4
joyride 2
friedqi22:04:22

Hi calva!! I've just joined...new to the world of Clojure/Script. I have some newbie questions. Hope you don't mind. First off, thanks for Calva! I've been through the Clojure getting started tutorial. Works great! Now I'm off to ClojureScript using the "Fire up the ClojureScript quickstart REPL" tutorial. All works fine until I reload the browser page... from the tutorial:

;; Evalute these steps with Ctrl+Alt+Enter after each line.
  (-> js/document
      (.getElementById "app")
      (.-innerHTML)
      (set! "Hello ClojureScript REPL from Calva!")
      ;; reload browser page to restore the original content 😎
      )
After a browser reload, anything I execute using Atl-Enter gives me:
cljs꞉hello-world.core꞉> 
; Execution error (TypeError) at (<cljs repl>:1).
; undefined is not an object (evaluating 'cljs.pprint.pprint')
; 
I'm using MacOS and Safari and Chrome ... if that matters. The terminal output from calva looks like this:
⚡️ Starting the REPL ⚡️ using the below command line:
pushd /var/folders/6b/622j_t9n3sx1znjntr0tr19r0000gn/T/betterthantomorrow.calva/clwnsm ; clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"},cider/piggieback {:mvn/version,"0.5.3"}}}' -M -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware cider.piggieback/wrap-cljs-repl]" ; popd
nREPL server started on port 63425 on host localhost - 
thanks

pez04:04:34

Hello and welcome! It could be that you need to load/evaluate the namespace/file, or at least the (ns …) form after having restarted the app.

friedqi04:04:11

Thanks much! I'm not aware that I restarted the app. I just did a refresh of the web page.

friedqi04:04:26

I have tried a few things...reloaded the file core.cljs

friedqi04:04:01

I haven't changed anything. I'm just using the file and connection as setup that results from cmd-shift-P and choosing "Fire up the ClojureScript quick start browser REPL".

pez05:04:49

I’m sorry, should have been less cryptic. With “the app” I meant the app running in the browser. The one you are hacking on with that example script. When you reload the browser, the app running there gets restarted.

pez05:04:48

I just tried the thing myself and run into the same problem as you. I don’t understand what is going on. Something goes wrong when the results are being sent back to Calva… For continuing exploring ClojureScript, maybe you can try this example project? https://github.com/PEZ/shadow-bare-bones

friedqi06:04:43

thanks. I'll play with that next.

friedqi06:04:37

Noticed the dependency loaded with "Fire up the ClojureScript quick start browser REPL" uses an older version of ClojureScript 1.10.x. Should this be updated?

friedqi06:04:06

brilliant...thanks @pez! the shadow-bare-bones project is working as advertised 🙂.

pez06:04:18

Awesome.

pez06:04:17

I just tried to update that dependency. Then some other things stop working… Pretty crazy, it is the most minimal setup ever….

😅 2
friedqi06:04:12

Does the shadow-bare-bones template come equiped with methods for a deploy build? I'm trying out all the things I need for dev lifecycle.

pez06:04:09

I probably should config and instructions for a release build. It’s pretty straight-forward. You could try npx shadow-cljs release :app and see what happens. The shadow-cljs user guide is here: https://shadow-cljs.github.io/docs/UsersGuide.html And shadow comes with stellar support in the #C6N245JGG channel.

👍 2
pez06:04:49

If you want to try building a mobile app with ClojureScript, you can check this example project out: https://github.com/PEZ/rn-rf-shadow

friedqi08:04:52

thanks. will give it a try.