Compare commits
20 commits
master
...
benjamin-a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
663052bda3 | ||
|
|
631f54e4e2 | ||
|
|
89e1351456 | ||
|
|
f58c0fcff4 | ||
|
|
e933a5aef3 | ||
|
|
9a6f48b986 | ||
|
|
73805703a2 | ||
|
|
5f0a822a55 | ||
|
|
a05004b9a2 | ||
|
|
5f3da77669 | ||
|
|
74b6b736d5 | ||
|
|
6bb48134f4 | ||
|
|
07a0c03593 | ||
|
|
8f96f23e35 | ||
|
|
4db8f7cc92 | ||
|
|
15df72344d | ||
|
|
0dd55dc556 | ||
|
|
4cfe188861 | ||
|
|
60af6a3a94 | ||
|
|
dbb28b86e1 |
21 changed files with 277 additions and 118 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit ad763a78f1bc327a493ff0b650aa5408ecbf4819
|
||||
Subproject commit 52a5a2daa4cc048c8d5d93a36e0ac05d52dfa21d
|
||||
2
deps.clj
2
deps.clj
|
|
@ -1 +1 @@
|
|||
Subproject commit 9bae77d5b346089f4fd2108933971c5a342ed39e
|
||||
Subproject commit 2f93fe8ba712c855feb6ecf26d2ed70646b34356
|
||||
6
deps.edn
6
deps.edn
|
|
@ -31,7 +31,7 @@
|
|||
org.clojure/data.csv {:mvn/version "1.0.0"},
|
||||
cheshire/cheshire {:mvn/version "5.11.0"}
|
||||
org.clojure/data.xml {:mvn/version "0.2.0-alpha8"}
|
||||
clj-commons/clj-yaml {:mvn/version "0.7.169"}
|
||||
clj-commons/clj-yaml {:mvn/version "1.0.26"}
|
||||
com.cognitect/transit-clj {:mvn/version "1.0.333"}
|
||||
org.clojure/test.check {:mvn/version "1.1.1"}
|
||||
nrepl/bencode {:mvn/version "1.1.0"}
|
||||
|
|
@ -50,8 +50,8 @@
|
|||
org.clojure/data.priority-map {:mvn/version "1.1.0"}
|
||||
insn/insn {:mvn/version "0.5.2"}
|
||||
org.clojure/core.rrb-vector {:mvn/version "0.1.2"}
|
||||
org.babashka/cli {:mvn/version "0.6.50"}
|
||||
org.babashka/http-client {:mvn/version "0.1.8"}
|
||||
org.babashka/cli {:mvn/version "0.7.51"}
|
||||
org.babashka/http-client {:mvn/version "0.2.9"}
|
||||
;; native image bloat with ordered 1.5.10
|
||||
org.flatland/ordered {:mvn/version "1.5.9"}}
|
||||
:aliases {:babashka/dev
|
||||
|
|
|
|||
49
doc/news.md
49
doc/news.md
|
|
@ -5,6 +5,55 @@ you have anything to add. Also see
|
|||
[#babashka](https://twitter.com/hashtag/babashka?src=hashtag_click&f=live) on
|
||||
Twitter.
|
||||
|
||||
## 2023-03 ([Twitter](https://twitter.com/search?q=(%23babashka%20OR%20babashka)%20since%3A2023-03-01%20until%3A2023-04-01&src=typed_query&f=top), [Mastodon](https://mastodon.social/tags/babashka))
|
||||
|
||||
### Releases
|
||||
|
||||
1.3.176, 1.3.175, 1.2.174:
|
||||
|
||||
Biggest highlight: Switch to GraalVM 19 and enable virtual threads!
|
||||
|
||||
### Videos
|
||||
|
||||
- [Blambda! The sound of babashka and AWS colliding](https://pitch.com/public/03fa9c7e-2b0e-45fb-8a22-d4a4d4d79d24), by Josh Glover from Pitch!
|
||||
|
||||
### Projects
|
||||
|
||||
- [babashka.json](https://github.com/babashka/json): JSON abstraction library
|
||||
- [martian](https://github.com/oliyh/martian) is now babashka compatible!
|
||||
- [panas.reload](https://github.com/keychera/panas.reload): a hot reload for babashka serving html+css (or htmx)
|
||||
- [cljs-exif-reader](https://git.sr.ht/~rwv/cljs-exif-reader): Extract information from TIFF and JPEG images (works in babashka, despite the name)
|
||||
|
||||
### Jobs
|
||||
|
||||
- Write babashka at [Cognician](https://twitter.com/RobStuttaford/status/1641694501793038336)!
|
||||
|
||||
## 2023-02 ([Twitter](https://twitter.com/search?q=(%23babashka%20OR%20babashka)%20since%3A2023-02-01%20until%3A2023-03-01&src=typed_query&f=live), [Mastodon](https://mastodon.social/tags/babashka))
|
||||
|
||||
## Releases
|
||||
|
||||
1.1.173: mostly bugfixes
|
||||
|
||||
### Articles
|
||||
|
||||
- [A technique for live coding simple web pages](https://github.com/whacked/cow/blob/main/a%20technique%20for%20live%20coding%20simple%20web%20pages.md) with babashka
|
||||
|
||||
### Videos
|
||||
|
||||
- [Stockholm Clojure Meetup Feb 23: Blambda! The sound of Babashka and Lambda colliding](https://www.youtube.com/watch?v=NfgYon96dsE)
|
||||
|
||||
### Projects
|
||||
|
||||
- [debux](https://github.com/philoskim/debux) is now babaskha-compatible
|
||||
- [lines-of-code-bb](https://github.com/matthewdowney/linesofcode-bb): Babashka script to count lines of Clojure code, docs, comments, and more
|
||||
- [deps-try](https://github.com/eval/deps-try): a babashka-script to try out Clojure libraries in rebel-readline
|
||||
- [bb-dialog](https://github.com/pixelated-noise/bb-dialog) adds support for `--treeview`
|
||||
- [A duckduck go CLI with babashka and (bbl)gum](https://mastodon.me.uk/@choffee/109845697304457129)
|
||||
- [babashka http-client](https://github.com/babashka/http-client) now supports multipart uploads
|
||||
- [sublime-pretty-edn](https://github.com/oakmac/sublime-pretty-edn): Format, Validate, Minify EDN files in Sublime Text
|
||||
- [Play console tetris in babashka!](https://twitter.com/borkdude/status/1628473136969576449)
|
||||
- [kaocha test runner](https://github.com/lambdaisland/kaocha) became babashka compatible!
|
||||
|
||||
## 2023-01 ([Twitter](https://twitter.com/search?q=%28%23babashka%20OR%20babashka%29%20until%3A2023-02-01%20since%3A2023-01-01&src=typed_query&f=live), [Mastodon](https://mastodon.social/tags/babashka))
|
||||
|
||||
### Releases
|
||||
|
|
|
|||
33
examples/user_middleware/Readme.md
Normal file
33
examples/user_middleware/Readme.md
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# User Middleware
|
||||
|
||||
- Your middleware is defined in bb user sources.
|
||||
- Middleware is a function in wrap-middleware style.
|
||||
|
||||
# Example
|
||||
|
||||
Middleware should be a function in the form of:
|
||||
|
||||
```clojure
|
||||
(defn my-middleware [handler]
|
||||
(fn [request]
|
||||
;; ...
|
||||
(handler request)
|
||||
;; ...
|
||||
))
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
```shell
|
||||
bb nrepl-server --middleware [my.middleware/println-middleware]
|
||||
```
|
||||
|
||||
--middleware is a vector of fully qualified function symbols.
|
||||
They are required to be located on the babashka classpath.
|
||||
|
||||
This will start babashka with a nrepl server with the middlware defined in `user_middleware/my_middleware/src/my/middleware.clj`.
|
||||
|
||||
You can now connect to the nrepl like usual.
|
||||
|
||||
It is possible to redefine the middleware function from within the running nrepl, because we keep a reference
|
||||
to the sci-var of the middlware.
|
||||
1
examples/user_middleware/my_middleware/deps.edn
Normal file
1
examples/user_middleware/my_middleware/deps.edn
Normal file
|
|
@ -0,0 +1 @@
|
|||
{:paths ["src"]}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
(ns my.middleware)
|
||||
|
||||
(defn println-middleware [handler]
|
||||
(fn [request]
|
||||
(println (:op (:msg request)))
|
||||
(handler request)))
|
||||
2
examples/user_middleware/my_project/bb.edn
Normal file
2
examples/user_middleware/my_project/bb.edn
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
{:deps
|
||||
{my/middleware {:local/root "../my_middleware/"}}}
|
||||
1
examples/user_middleware/my_project/hello_middleware.clj
Normal file
1
examples/user_middleware/my_project/hello_middleware.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(ns hello-middleware)
|
||||
2
process
2
process
|
|
@ -1 +1 @@
|
|||
Subproject commit 63bef86c76098366531ab973a79d04c51ae0856b
|
||||
Subproject commit dadcff417675c84dcd32448e22e6270d1555af5d
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
:flaky :flaky}
|
||||
:jvm-opts ["--enable-preview"]
|
||||
:dependencies [[org.clojure/clojure "1.11.1"]
|
||||
[borkdude/edamame "1.3.20"]
|
||||
[borkdude/edamame "1.3.22"]
|
||||
[borkdude/graal.locking "0.0.2"]
|
||||
[org.clojure/tools.cli "1.0.214"]
|
||||
[cheshire "5.11.0"]
|
||||
|
|
@ -35,14 +35,14 @@
|
|||
[com.github.clj-easy/graal-build-time "0.1.0"]
|
||||
[rewrite-clj/rewrite-clj "1.1.46"]
|
||||
[insn/insn "0.5.2"]
|
||||
[org.babashka/cli "0.6.50"]
|
||||
[org.babashka/http-client "0.1.8"]]
|
||||
[org.babashka/cli "0.7.51"]
|
||||
[org.babashka/http-client "0.2.9"]]
|
||||
:plugins [[org.kipz/lein-meta-bom "0.1.1"]]
|
||||
:metabom {:jar-name "metabom.jar"}
|
||||
:profiles {:feature/xml {:source-paths ["feature-xml"]
|
||||
:dependencies [[org.clojure/data.xml "0.2.0-alpha8"]]}
|
||||
:feature/yaml {:source-paths ["feature-yaml"]
|
||||
:dependencies [[clj-commons/clj-yaml "0.7.169"
|
||||
:dependencies [[clj-commons/clj-yaml "1.0.26"
|
||||
:exclusions [org.flatland/ordered]#_#_clj-commons/clj-yaml "0.7.110"]
|
||||
;; 1.15.10 cause native image bloat problem
|
||||
[org.flatland/ordered "1.5.9"]]}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@
|
|||
org.clojure/data.csv {:mvn/version "1.0.0"},
|
||||
cheshire/cheshire {:mvn/version "5.11.0"}
|
||||
org.clojure/data.xml {:mvn/version "0.2.0-alpha8"}
|
||||
clj-commons/clj-yaml {:mvn/version "0.7.169"}
|
||||
com.cognitect/transit-clj {:mvn/version "1.0.329"}
|
||||
clj-commons/clj-yaml {:mvn/version "1.0.26"}
|
||||
com.cognitect/transit-clj {:mvn/version "1.0.333"}
|
||||
org.clojure/test.check {:mvn/version "1.1.1"}
|
||||
nrepl/bencode {:mvn/version "1.1.0"}
|
||||
seancorfield/next.jdbc {:mvn/version "1.1.610"}
|
||||
|
|
|
|||
2
sci
2
sci
|
|
@ -1 +1 @@
|
|||
Subproject commit ae1679ceee89acb00d05744355f501ffaa3cbddb
|
||||
Subproject commit 987910fb38fdd166865458c3fd4b468a22fb9992
|
||||
|
|
@ -43,6 +43,7 @@ args=("-jar" "$BABASHKA_JAR"
|
|||
"--verbose"
|
||||
"--no-fallback"
|
||||
"--native-image-info"
|
||||
"--install-exit-handlers"
|
||||
# --trace-class-initialization=jdk.internal.net.http.common.DebugLogger,jdk.internal.net.http.websocket.WebSocketImpl,jdk.internal.net.http.common.Utils
|
||||
"$BABASHKA_XMX"
|
||||
"--enable-preview")
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ call %GRAALVM_HOME%\bin\native-image.cmd ^
|
|||
"--verbose" ^
|
||||
"--no-fallback" ^
|
||||
"--enable-preview" ^
|
||||
"--install-exit-handlers" ^
|
||||
"%BABASHKA_XMX%"
|
||||
|
||||
if %errorlevel% neq 0 exit /b %errorlevel%
|
||||
|
|
|
|||
|
|
@ -210,6 +210,7 @@
|
|||
java.net.http.WebSocket$Builder
|
||||
java.net.http.WebSocket$Listener
|
||||
java.security.cert.X509Certificate
|
||||
java.security.cert.CertificateFactory
|
||||
javax.crypto.Cipher
|
||||
javax.crypto.Mac
|
||||
javax.crypto.SecretKey
|
||||
|
|
@ -317,7 +318,7 @@
|
|||
java.lang.System
|
||||
java.lang.Throwable
|
||||
java.lang.Thread$UncaughtExceptionHandler
|
||||
;; java.lang.UnsupportedOperationException
|
||||
java.lang.UnsupportedOperationException
|
||||
java.lang.ref.WeakReference
|
||||
java.lang.ref.ReferenceQueue
|
||||
java.lang.ref.Cleaner
|
||||
|
|
@ -696,6 +697,8 @@
|
|||
javax.crypto.SecretKey
|
||||
(instance? java.lang.Thread v)
|
||||
java.lang.Thread
|
||||
(instance? java.security.cert.X509Certificate v)
|
||||
java.security.cert.X509Certificate
|
||||
;; keep commas for merge friendliness
|
||||
,,,)))
|
||||
m (assoc m (list 'quote 'clojure.lang.Var) 'sci.lang.Var)
|
||||
|
|
@ -764,7 +767,7 @@
|
|||
Throwable java.lang.Throwable
|
||||
VirtualMachineError java.lang.VirtualMachineError
|
||||
ThreadDeath java.lang.ThreadDeath
|
||||
;; UnsupportedOperationException java.lang.UnsupportedOperationException
|
||||
UnsupportedOperationException java.lang.UnsupportedOperationException
|
||||
})
|
||||
|
||||
(defn reflection-file-entries []
|
||||
|
|
|
|||
|
|
@ -313,8 +313,11 @@ Use bb run --help to show this help output.
|
|||
(defn start-socket-repl! [address ctx]
|
||||
(socket-repl/start-repl! address ctx))
|
||||
|
||||
(defn start-nrepl! [address]
|
||||
(let [opts (nrepl-server/parse-opt address)]
|
||||
(defn start-nrepl! [user-middleware address]
|
||||
(let [user-middleware (when-not (str/blank? user-middleware)
|
||||
(read-string user-middleware))
|
||||
opts (nrepl-server/parse-opt address)
|
||||
opts (assoc opts :middleware user-middleware)]
|
||||
(babashka.impl.nrepl-server/start-server! opts))
|
||||
(binding [*out* *err*]
|
||||
(println "For more info visit: https://book.babashka.org/#_nrepl"))
|
||||
|
|
@ -645,6 +648,11 @@ Use bb run --help to show this help output.
|
|||
(recur options
|
||||
(assoc opts-map
|
||||
:nrepl (or opt "1667"))))
|
||||
("--middleware")
|
||||
(let [options (next options)]
|
||||
(recur (next options)
|
||||
(assoc opts-map
|
||||
:middleware (first options))))
|
||||
("--eval", "-e")
|
||||
(let [options (next options)
|
||||
opts-map (assoc opts-map :prn true)]
|
||||
|
|
@ -839,7 +847,7 @@ Use bb run --help to show this help output.
|
|||
:main :uberscript :describe?
|
||||
:jar :uberjar :clojure
|
||||
:doc :run :list-tasks
|
||||
:print-deps :prepare]
|
||||
:print-deps :prepare :middleware]
|
||||
exec-fn :exec}
|
||||
cli-opts
|
||||
print-result? (:prn cli-opts)
|
||||
|
|
@ -1018,7 +1026,7 @@ Use bb run --help to show this help output.
|
|||
describe?
|
||||
[(print-describe) 0]
|
||||
repl [(repl/start-repl! sci-ctx) 0]
|
||||
nrepl [(start-nrepl! nrepl) 0]
|
||||
nrepl [(start-nrepl! middleware nrepl) 0]
|
||||
uberjar [nil 0]
|
||||
list-tasks [(tasks/list-tasks sci-ctx) 0]
|
||||
print-deps [(print-deps/print-deps (:print-deps-format cli-opts)) 0]
|
||||
|
|
|
|||
34
test-resources/certificate.crt
Normal file
34
test-resources/certificate.crt
Normal file
|
|
@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H
|
||||
wj/WczPsGo6D8RG0nU4MiGCerMiY1oF9navINFTZptWiy/gVhR85XwQrKu+Pt+AM
|
||||
47JAFeruig==
|
||||
-----END CERTIFICATE-----
|
||||
|
|
@ -15,8 +15,9 @@
|
|||
|
||||
(set! *warn-on-reflection* true)
|
||||
|
||||
(defn socket-command [expr expected & [log?]]
|
||||
(with-open [socket (java.net.Socket. "127.0.0.1" 1666)
|
||||
(defn socket-command-on-port [^long port]
|
||||
(fn [expr expected & [log?]]
|
||||
(with-open [socket (java.net.Socket. "127.0.0.1" port)
|
||||
reader (io/reader socket)
|
||||
sw (java.io.StringWriter.)
|
||||
writer (io/writer socket)]
|
||||
|
|
@ -38,7 +39,7 @@
|
|||
(recur)))))
|
||||
(binding [*out* writer]
|
||||
(println ":repl/quit\n"))
|
||||
:success))
|
||||
:success)))
|
||||
|
||||
(def server-process (volatile! nil))
|
||||
|
||||
|
|
@ -46,6 +47,7 @@
|
|||
|
||||
(deftest ^:flaky socket-repl-test
|
||||
(when exec?
|
||||
(let [socket-command (socket-command-on-port 1666)]
|
||||
(try
|
||||
(if tu/jvm?
|
||||
(let [ctx (init {:namespaces main/namespaces
|
||||
|
|
@ -74,10 +76,11 @@
|
|||
(do (stop-repl!)
|
||||
(ctx-store/reset-ctx! nil)
|
||||
(Thread/sleep 100))
|
||||
(p/destroy-tree @server-process))))))
|
||||
(p/destroy-tree @server-process)))))))
|
||||
|
||||
(deftest ^:flaky socket-repl-opts-test
|
||||
(when exec?
|
||||
(let [socket-command (socket-command-on-port 1667)]
|
||||
(try
|
||||
(if tu/jvm?
|
||||
(let [ctx (init {:bindings {'*command-line-args*
|
||||
|
|
@ -86,11 +89,11 @@
|
|||
:namespaces {'clojure.core.server clojure-core-server-namespace}
|
||||
:features #{:bb}})]
|
||||
(ctx-store/reset-ctx! ctx)
|
||||
(start-repl! "{:address \"localhost\" :accept clojure.core.server/repl :port 1666}"
|
||||
(start-repl! "{:address \"localhost\" :accept clojure.core.server/repl :port 1667}"
|
||||
ctx))
|
||||
(do (vreset! server-process
|
||||
(p/process ["./bb" "--socket-repl" "{:address \"localhost\" :accept clojure.core.server/repl :port 1666}"]))
|
||||
(w/wait-for-port "localhost" 1666)))
|
||||
(p/process ["./bb" "--socket-repl" "{:address \"localhost\" :accept clojure.core.server/repl :port 1667}"]))
|
||||
(w/wait-for-port "localhost" 1667)))
|
||||
(Thread/sleep 50)
|
||||
(is (socket-command "(+ 1 2 3)" "user=> 6"))
|
||||
(finally
|
||||
|
|
@ -98,10 +101,11 @@
|
|||
(do (stop-repl!)
|
||||
(ctx-store/reset-ctx! nil)
|
||||
(Thread/sleep 100))
|
||||
(p/destroy-tree @server-process))))))
|
||||
(p/destroy-tree @server-process)))))))
|
||||
|
||||
(deftest ^:flaky socket-prepl-test
|
||||
(when exec?
|
||||
(let [socket-command (socket-command-on-port 1668)]
|
||||
(try
|
||||
(if tu/jvm?
|
||||
(let [ctx (init {:bindings {'*command-line-args*
|
||||
|
|
@ -110,11 +114,11 @@
|
|||
:namespaces {'clojure.core.server clojure-core-server-namespace}
|
||||
:features #{:bb}})]
|
||||
(ctx-store/reset-ctx! ctx)
|
||||
(start-repl! "{:address \"localhost\" :accept clojure.core.server/io-prepl :port 1666}"
|
||||
(start-repl! "{:address \"localhost\" :accept clojure.core.server/io-prepl :port 1668}"
|
||||
ctx))
|
||||
(do (vreset! server-process
|
||||
(p/process ["./bb" "--socket-repl" "{:address \"localhost\" :accept clojure.core.server/io-prepl :port 1666}"]))
|
||||
(w/wait-for-port "localhost" 1666)))
|
||||
(p/process ["./bb" "--socket-repl" "{:address \"localhost\" :accept clojure.core.server/io-prepl :port 1668}"]))
|
||||
(w/wait-for-port "localhost" 1668)))
|
||||
(Thread/sleep 50)
|
||||
(is (socket-command "(+ 1 2 3)" (fn [s]
|
||||
(let [m (edn/read-string s)]
|
||||
|
|
@ -126,7 +130,7 @@
|
|||
(do (stop-repl!)
|
||||
(ctx-store/reset-ctx! nil)
|
||||
(Thread/sleep 100))
|
||||
(p/destroy-tree @server-process))))))
|
||||
(p/destroy-tree @server-process)))))))
|
||||
|
||||
;;;; Scratch
|
||||
|
||||
|
|
@ -141,5 +145,5 @@
|
|||
'*command-line-args*
|
||||
["a" "b" "c"]}
|
||||
:env (atom {})})
|
||||
(socket-command "(+ 1 2 3)" "6")
|
||||
((socket-command-on-port 1666) "(+ 1 2 3)" "6")
|
||||
)
|
||||
|
|
|
|||
|
|
@ -27,3 +27,17 @@
|
|||
(is (true? (bb nil "(= (first {1 2})
|
||||
(clojure.lang.MapEntry. 1 2)
|
||||
(clojure.lang.MapEntry/create 1 2))"))))
|
||||
|
||||
(deftest X509Certificate-test
|
||||
(is (true? (bb nil "(import java.security.cert.X509Certificate)
|
||||
(import java.security.cert.CertificateFactory)
|
||||
(require '[clojure.java.io :as io])
|
||||
(defn x509-certificate
|
||||
^X509Certificate
|
||||
[f]
|
||||
(let [input (io/input-stream f)
|
||||
factory (CertificateFactory/getInstance \"X.509\")]
|
||||
(.generateCertificate factory input)))
|
||||
(def cert (x509-certificate (io/file \"test-resources/certificate.crt\")))
|
||||
(some? (.getSubjectX500Principal cert))
|
||||
"))))
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
(deftest parse-opts-test
|
||||
(is (= "1667"
|
||||
(:nrepl (parse-opts ["--nrepl-server"]))))
|
||||
(is (= "[foo]"
|
||||
(:middleware (parse-opts ["--middleware" "[foo]"]))))
|
||||
(is (= "1666"
|
||||
(:socket-repl (parse-opts ["--socket-repl"]))))
|
||||
(is (= {:nrepl "1667", :classpath "src"}
|
||||
|
|
|
|||
Loading…
Reference in a new issue