Skip to content

Commit ad51be1

Browse files
authored
dev: repl stuff (#337)
* dev: nrepl: allow interrupts https://docs.cider.mx/cider/basics/up_and_running.html#enabling-nrepl-jvmti-agent * dev: optionally enable flowstorm support for repl Flowstorm is a wonderful develpment diagnostic tool. Don't think this will work for when bringing up a cljs repl via `bb dev-cljs`, but am happy with only clj repl (via `bb dev-clj`) support for now.
1 parent 9adcc9f commit ad51be1

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

deps.edn

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,24 @@
3232
cider/cider-nrepl {:mvn/version "0.52.0"}}
3333
:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]}
3434

35+
:flowstorm
36+
{;; for disabling the official compiler
37+
:classpath-overrides {org.clojure/clojure nil}
38+
:extra-deps {com.github.flow-storm/clojure {:mvn/version "1.12.0-3"}
39+
com.github.flow-storm/flow-storm-dbg {:mvn/version "4.1.1"}}
40+
:jvm-opts ["-Dclojure.storm.instrumentEnable=true"]}
41+
3542
:nrepl/jvm
3643
{:extra-deps {refactor-nrepl/refactor-nrepl {:mvn/version "3.10.0"}}
44+
:jvm-opts ["-Djdk.attach.allowAttachSelf"]
3745
:main-opts ["-m" "nrepl.cmdline"
3846
"--middleware" "[refactor-nrepl.middleware/wrap-refactor cider.nrepl/cider-middleware]"
3947
"-i"]}
4048

4149
:nrepl/cljs ;; note shadow-cljs does its own thing, this is for a REPL with
4250
;; support for plain old ClojureScript
4351
{:extra-deps {cider/piggieback {:mvn/version "0.6.0"}}
52+
:jvm-opts ["-Djdk.attach.allowAttachSelf"]
4453
:main-opts ["-m" "nrepl.cmdline"
4554
"--middleware" "[cider.nrepl/cider-middleware cider.piggieback/wrap-cljs-repl]"
4655
"-i"]}

script/dev_repl.clj

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
(ns dev-repl
22
(:require [babashka.cli :as cli]
33
[babashka.process :as process]
4+
[clojure.string :as str]
45
[lread.status-line :as status]))
56

67
(def cli-spec {:help {:desc "This usage help"}
78

9+
:flowstorm {:alias :f
10+
:coerce :boolean
11+
:desc "Enable flowstorm"}
12+
813
;; cider nrepl pass through opts
914
:host {:ref "<ADDR>"
1015
:alias :h
@@ -22,7 +27,7 @@
2227

2328
(defn- usage-help[]
2429
(status/line :head "Usage help")
25-
(status/line :detail (cli/format-opts {:spec cli-spec :order [:host :bind :port :help]})))
30+
(status/line :detail (cli/format-opts {:spec cli-spec :order [:flowstorm :host :bind :port :help]})))
2631

2732
(defn- usage-fail [msg]
2833
(status/line :error msg)
@@ -40,16 +45,20 @@
4045

4146

4247
(defn launch-repl [flavor args]
43-
(let [opts (parse-opts args)]
44-
(if (:help opts)
48+
(let [{:keys [flowstorm host bind port help]} (parse-opts args)]
49+
(if help
4550
(usage-help)
46-
(do (status/line :head "Launching Clojure %s nREPL" (name flavor))
47-
(process/exec "clj" (str "-M:1.12:test-common:nrepl:nrepl/" (case flavor
48-
:cljs "cljs:cljs"
49-
:jvm "jvm"))
50-
"-h" (:host opts)
51-
"-b" (:bind opts)
52-
"-p" (:port opts))))))
51+
(let [aliases (cond-> [(case flavor
52+
:cljs "nrepl/cljs:cljs"
53+
:jvm "nrepl/jvm")]
54+
flowstorm (conj "flowstorm"))]
55+
(status/line :head "Launching Clojure %s nREPL" (name flavor))
56+
(when flowstorm
57+
(status/line :detail "Flowstorm support is enabled"))
58+
(process/exec "clj" (str "-M:1.12:test-common:nrepl:" (str/join ":" aliases))
59+
"-h" host
60+
"-b" bind
61+
"-p" port)))))
5362

5463
;; Entry points
5564
(defn dev-jvm [& args]

0 commit comments

Comments
 (0)