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: add --host to dev:bb and dev:jvm tasks #580

Merged
merged 1 commit into from
May 15, 2024
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
17 changes: 14 additions & 3 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@
:tasks
{;; setup
:requires ([babashka.classpath :as cp]
[babashka.cli :as cli]
[babashka.fs :as fs]
[clojure.string :as string]
[helper.shell :as shell]
[lread.status-line :as status])
:init (do (defn parse-repl-args [args]
(let [cli-spec {:spec
{:host {:desc "Bind to host (use 0.0.0.0 to allow anyone to connect)"
:alias :h
:default "localhost"}}
:restrict true}]
(cli/parse-opts args cli-spec))))
:enter (let [{:keys [name]} (current-task)]
(when-not (string/starts-with? name "-")
(status/line :head "TASK %s %s" name (string/join " " *command-line-args*))))
Expand All @@ -21,16 +29,19 @@

;; commands
dev:jvm {:doc "start a Clojure nrepl server/prompt"
:task (shell/command "clj" "-M:test:repl/cider")}
:task (let [opts (parse-repl-args *command-line-args*)
host (:host opts)]
(shell/command "clj" "-M:test:repl/cider" "-h" host "-b" host))}
dev:bb {:doc "start a Babashka nrepl server"
;; repeat :test paths from deps.edn
:extra-paths ["test" "env/test/resources"]
:extra-deps {;; inherit base deps from deps.edn
etaoin/etaoin {:local/root "."}
;; repeat necessary :test deps from deps.edn
io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}}
:task (do (babashka.nrepl.server/start-server!)
(deref (promise)))}
:task (let [opts (parse-repl-args *command-line-args*)]
(babashka.nrepl.server/start-server! opts)
(deref (promise)))}
test:jvm {:doc "Runs tests under JVM Clojure [--help]"
:task test/test-jvm}
-test:bb {:doc "bb test runner, invoked within script/test.clj"
Expand Down
9 changes: 9 additions & 0 deletions doc/02-developer-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ For a babashka REPL
bb dev:bb
----

By default you can only connect to the REPL from localhost.
If you need to connect to a REPL running on a different host, launch your REPL with `--host`.
For example, to allow anyone to connect to your REPL:

[source,shell]
----
bb dev:jvm --host 0.0.0.0
----

=== Checking Tools Versions

Used by GitHub Actions, but also an interesting way to check your prerequisites:
Expand Down
Loading