Support for clj-http-lite
This commit is contained in:
parent
4ca9a81c1c
commit
3270d521d3
5 changed files with 68 additions and 62 deletions
|
|
@ -188,6 +188,11 @@
|
||||||
"allPublicMethods" : true,
|
"allPublicMethods" : true,
|
||||||
"allPublicFields" : true,
|
"allPublicFields" : true,
|
||||||
"allPublicConstructors" : true
|
"allPublicConstructors" : true
|
||||||
|
}, {
|
||||||
|
"name" : "java.nio.file.Paths",
|
||||||
|
"allPublicMethods" : true,
|
||||||
|
"allPublicFields" : true,
|
||||||
|
"allPublicConstructors" : true
|
||||||
}, {
|
}, {
|
||||||
"name" : "java.nio.file.StandardCopyOption",
|
"name" : "java.nio.file.StandardCopyOption",
|
||||||
"allPublicMethods" : true,
|
"allPublicMethods" : true,
|
||||||
|
|
@ -353,21 +358,16 @@
|
||||||
"allPublicMethods" : true,
|
"allPublicMethods" : true,
|
||||||
"allPublicFields" : true,
|
"allPublicFields" : true,
|
||||||
"allPublicConstructors" : true
|
"allPublicConstructors" : true
|
||||||
}, {
|
|
||||||
"name" : "javax.xml.bind.DatatypeConverter",
|
|
||||||
"allPublicMethods" : true,
|
|
||||||
"allPublicFields" : true,
|
|
||||||
"allPublicConstructors" : true
|
|
||||||
}, {
|
|
||||||
"name" : "sun.net.www.protocol.http.HttpURLConnection",
|
|
||||||
"allPublicMethods" : true,
|
|
||||||
"allPublicFields" : true,
|
|
||||||
"allPublicConstructors" : true
|
|
||||||
}, {
|
}, {
|
||||||
"name" : "sun.net.www.protocol.http.HttpURLConnection$HttpInputStream",
|
"name" : "sun.net.www.protocol.http.HttpURLConnection$HttpInputStream",
|
||||||
"allPublicMethods" : true,
|
"allPublicMethods" : true,
|
||||||
"allPublicFields" : true,
|
"allPublicFields" : true,
|
||||||
"allPublicConstructors" : true
|
"allPublicConstructors" : true
|
||||||
|
}, {
|
||||||
|
"name" : "sun.net.www.protocol.https.HttpsURLConnectionImpl",
|
||||||
|
"allPublicMethods" : true,
|
||||||
|
"allPublicFields" : true,
|
||||||
|
"allPublicConstructors" : true
|
||||||
}, {
|
}, {
|
||||||
"name" : "sun.nio.fs.UnixPath",
|
"name" : "sun.nio.fs.UnixPath",
|
||||||
"allPublicMethods" : true,
|
"allPublicMethods" : true,
|
||||||
|
|
|
||||||
2
sci
2
sci
|
|
@ -1 +1 @@
|
||||||
Subproject commit 577351c5514edb7492314048aef99d3c4319a667
|
Subproject commit 6b75e1071ee425c6f468c73b2cef3ceae9c24af5
|
||||||
|
|
@ -43,6 +43,7 @@
|
||||||
java.nio.file.Files
|
java.nio.file.Files
|
||||||
java.nio.file.NoSuchFileException
|
java.nio.file.NoSuchFileException
|
||||||
java.nio.file.Path
|
java.nio.file.Path
|
||||||
|
java.nio.file.Paths
|
||||||
java.nio.file.StandardCopyOption
|
java.nio.file.StandardCopyOption
|
||||||
java.nio.file.attribute.FileAttribute
|
java.nio.file.attribute.FileAttribute
|
||||||
java.nio.file.attribute.PosixFilePermission
|
java.nio.file.attribute.PosixFilePermission
|
||||||
|
|
@ -75,9 +76,8 @@
|
||||||
java.util.zip.DeflaterInputStream
|
java.util.zip.DeflaterInputStream
|
||||||
java.util.zip.GZIPInputStream
|
java.util.zip.GZIPInputStream
|
||||||
java.util.zip.GZIPOutputStream
|
java.util.zip.GZIPOutputStream
|
||||||
javax.xml.bind.DatatypeConverter
|
|
||||||
sun.nio.fs.UnixPath ;; included because of permission check
|
sun.nio.fs.UnixPath ;; included because of permission check
|
||||||
sun.net.www.protocol.http.HttpURLConnection ;; needed for clj-http.lite
|
sun.net.www.protocol.https.HttpsURLConnectionImpl ;; needed fo clj-http.lite
|
||||||
sun.net.www.protocol.http.HttpURLConnection$HttpInputStream ;; needed for clj-http.lite
|
sun.net.www.protocol.http.HttpURLConnection$HttpInputStream ;; needed for clj-http.lite
|
||||||
]
|
]
|
||||||
:custom-classes {'java.lang.Thread
|
:custom-classes {'java.lang.Thread
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,7 @@
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[sci.addons :as addons]
|
[sci.addons :as addons]
|
||||||
[sci.core :as sci]
|
[sci.core :as sci]
|
||||||
[sci.impl.vars :as vars]
|
[sci.impl.vars :as vars])
|
||||||
[sci.impl.namespaces :as sci-namespaces])
|
|
||||||
(:gen-class))
|
(:gen-class))
|
||||||
|
|
||||||
(set! *warn-on-reflection* true)
|
(set! *warn-on-reflection* true)
|
||||||
|
|
@ -169,6 +168,8 @@ Everything after that is bound to *command-line-args*."))
|
||||||
(edn/read {;;:readers *data-readers*
|
(edn/read {;;:readers *data-readers*
|
||||||
:eof ::EOF} *in*))
|
:eof ::EOF} *in*))
|
||||||
|
|
||||||
|
(def reflection-var (sci/new-dynamic-var '*warn-on-reflection* false))
|
||||||
|
|
||||||
(defn load-file* [ctx f]
|
(defn load-file* [ctx f]
|
||||||
(let [f (io/file f)
|
(let [f (io/file f)
|
||||||
s (slurp f)]
|
s (slurp f)]
|
||||||
|
|
@ -247,7 +248,8 @@ Everything after that is bound to *command-line-args*."))
|
||||||
:namespaces {'clojure.core (assoc core-extras
|
:namespaces {'clojure.core (assoc core-extras
|
||||||
'*command-line-args*
|
'*command-line-args*
|
||||||
(sci/new-dynamic-var '*command-line-args* command-line-args)
|
(sci/new-dynamic-var '*command-line-args* command-line-args)
|
||||||
'*file* vars/file-var)
|
'*file* vars/file-var
|
||||||
|
'*warn-on-reflection* reflection-var)
|
||||||
'clojure.tools.cli tools-cli-namespace
|
'clojure.tools.cli tools-cli-namespace
|
||||||
'clojure.edn {'read edn/read
|
'clojure.edn {'read edn/read
|
||||||
'read-string edn/read-string}
|
'read-string edn/read-string}
|
||||||
|
|
@ -288,52 +290,53 @@ Everything after that is bound to *command-line-args*."))
|
||||||
main)
|
main)
|
||||||
expression)
|
expression)
|
||||||
exit-code
|
exit-code
|
||||||
(or
|
(sci/with-bindings {reflection-var false}
|
||||||
#_(binding [*out* *err*]
|
(or
|
||||||
(prn ">>" _opts))
|
#_(binding [*out* *err*]
|
||||||
(second
|
(prn ">>" _opts))
|
||||||
(cond version
|
(second
|
||||||
[(print-version) 0]
|
(cond version
|
||||||
help?
|
[(print-version) 0]
|
||||||
[(print-help) 0]
|
help?
|
||||||
repl [(start-repl! ctx #(read-next *in*)) 0]
|
[(print-help) 0]
|
||||||
socket-repl [(start-socket-repl! socket-repl ctx #(read-next *in*)) 0]
|
repl [(start-repl! ctx #(read-next *in*)) 0]
|
||||||
:else
|
socket-repl [(start-socket-repl! socket-repl ctx #(read-next *in*)) 0]
|
||||||
(try
|
:else
|
||||||
(let [expr (if file (read-file file) expression)]
|
(try
|
||||||
(if expr
|
(let [expr (if file (read-file file) expression)]
|
||||||
(loop [in (read-next *in*)]
|
(if expr
|
||||||
(let [ctx (update-in ctx [:namespaces 'user] assoc (with-meta '*input*
|
(loop [in (read-next *in*)]
|
||||||
(when-not stream?
|
(let [ctx (update-in ctx [:namespaces 'user] assoc (with-meta '*input*
|
||||||
{:sci.impl/deref! true}))
|
(when-not stream?
|
||||||
(sci/new-dynamic-var '*input* in))]
|
{:sci.impl/deref! true}))
|
||||||
(if (identical? ::EOF in)
|
(sci/new-dynamic-var '*input* in))]
|
||||||
[nil 0] ;; done streaming
|
(if (identical? ::EOF in)
|
||||||
(let [res [(let [res (eval-string expr ctx)]
|
[nil 0] ;; done streaming
|
||||||
(when (some? res)
|
(let [res [(let [res (eval-string expr ctx)]
|
||||||
(if-let [pr-f (cond shell-out println
|
(when (some? res)
|
||||||
edn-out prn)]
|
(if-let [pr-f (cond shell-out println
|
||||||
(if (coll? res)
|
edn-out prn)]
|
||||||
(doseq [l res
|
(if (coll? res)
|
||||||
:while (not (pipe-signal-received?))]
|
(doseq [l res
|
||||||
(pr-f l))
|
:while (not (pipe-signal-received?))]
|
||||||
(pr-f res))
|
(pr-f l))
|
||||||
(prn res)))) 0]]
|
(pr-f res))
|
||||||
(if stream?
|
(prn res)))) 0]]
|
||||||
(recur (read-next *in*))
|
(if stream?
|
||||||
res)))))
|
(recur (read-next *in*))
|
||||||
[(start-repl! ctx #(read-next *in*)) 0]))
|
res)))))
|
||||||
(catch Throwable e
|
[(start-repl! ctx #(read-next *in*)) 0]))
|
||||||
(binding [*out* *err*]
|
(catch Throwable e
|
||||||
(let [d (ex-data e)
|
(binding [*out* *err*]
|
||||||
exit-code (:bb/exit-code d)]
|
(let [d (ex-data e)
|
||||||
(if exit-code [nil exit-code]
|
exit-code (:bb/exit-code d)]
|
||||||
(do (if verbose?
|
(if exit-code [nil exit-code]
|
||||||
(print-stack-trace e)
|
(do (if verbose?
|
||||||
(println (.getMessage e)))
|
(print-stack-trace e)
|
||||||
(flush)
|
(println (.getMessage e)))
|
||||||
[nil 1]))))))))
|
(flush)
|
||||||
1)
|
[nil 1]))))))))
|
||||||
|
1))
|
||||||
t1 (System/currentTimeMillis)]
|
t1 (System/currentTimeMillis)]
|
||||||
(when time? (binding [*out* *err*]
|
(when time? (binding [*out* *err*]
|
||||||
(println "bb took" (str (- t1 t0) "ms."))))
|
(println "bb took" (str (- t1 t0) "ms."))))
|
||||||
|
|
|
||||||
|
|
@ -319,6 +319,9 @@
|
||||||
(is (thrown-with-msg? Exception #"error.bb"
|
(is (thrown-with-msg? Exception #"error.bb"
|
||||||
(bb nil (.getPath (io/file "test" "babashka" "scripts" "error.bb"))))))
|
(bb nil (.getPath (io/file "test" "babashka" "scripts" "error.bb"))))))
|
||||||
|
|
||||||
|
(deftest compatibility-test
|
||||||
|
(is (true? (bb nil "(set! *warn-on-reflection* true)"))))
|
||||||
|
|
||||||
;;;; Scratch
|
;;;; Scratch
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue