Skip to content

Commit

Permalink
dev: repl stuff (#337)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
lread authored Feb 6, 2025
1 parent 9adcc9f commit ad51be1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
9 changes: 9 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,24 @@
cider/cider-nrepl {:mvn/version "0.52.0"}}
:jvm-opts ["-XX:-OmitStackTraceInFastThrow"]}

:flowstorm
{;; for disabling the official compiler
:classpath-overrides {org.clojure/clojure nil}
:extra-deps {com.github.flow-storm/clojure {:mvn/version "1.12.0-3"}
com.github.flow-storm/flow-storm-dbg {:mvn/version "4.1.1"}}
:jvm-opts ["-Dclojure.storm.instrumentEnable=true"]}

:nrepl/jvm
{:extra-deps {refactor-nrepl/refactor-nrepl {:mvn/version "3.10.0"}}
:jvm-opts ["-Djdk.attach.allowAttachSelf"]
:main-opts ["-m" "nrepl.cmdline"
"--middleware" "[refactor-nrepl.middleware/wrap-refactor cider.nrepl/cider-middleware]"
"-i"]}

:nrepl/cljs ;; note shadow-cljs does its own thing, this is for a REPL with
;; support for plain old ClojureScript
{:extra-deps {cider/piggieback {:mvn/version "0.6.0"}}
:jvm-opts ["-Djdk.attach.allowAttachSelf"]
:main-opts ["-m" "nrepl.cmdline"
"--middleware" "[cider.nrepl/cider-middleware cider.piggieback/wrap-cljs-repl]"
"-i"]}
Expand Down
29 changes: 19 additions & 10 deletions script/dev_repl.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
(ns dev-repl
(:require [babashka.cli :as cli]
[babashka.process :as process]
[clojure.string :as str]
[lread.status-line :as status]))

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

:flowstorm {:alias :f
:coerce :boolean
:desc "Enable flowstorm"}

;; cider nrepl pass through opts
:host {:ref "<ADDR>"
:alias :h
Expand All @@ -22,7 +27,7 @@

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

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


(defn launch-repl [flavor args]
(let [opts (parse-opts args)]
(if (:help opts)
(let [{:keys [flowstorm host bind port help]} (parse-opts args)]
(if help
(usage-help)
(do (status/line :head "Launching Clojure %s nREPL" (name flavor))
(process/exec "clj" (str "-M:1.12:test-common:nrepl:nrepl/" (case flavor
:cljs "cljs:cljs"
:jvm "jvm"))
"-h" (:host opts)
"-b" (:bind opts)
"-p" (:port opts))))))
(let [aliases (cond-> [(case flavor
:cljs "nrepl/cljs:cljs"
:jvm "nrepl/jvm")]
flowstorm (conj "flowstorm"))]
(status/line :head "Launching Clojure %s nREPL" (name flavor))
(when flowstorm
(status/line :detail "Flowstorm support is enabled"))
(process/exec "clj" (str "-M:1.12:test-common:nrepl:" (str/join ":" aliases))
"-h" host
"-b" bind
"-p" port)))))

;; Entry points
(defn dev-jvm [& args]
Expand Down

0 comments on commit ad51be1

Please sign in to comment.