Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev: repl stuff #337

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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