Skip to content

Commit

Permalink
adding more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
zcaudate committed Feb 3, 2024
1 parent 6c884d3 commit 49b2f1f
Show file tree
Hide file tree
Showing 15 changed files with 225 additions and 70 deletions.
6 changes: 5 additions & 1 deletion config/packages.edn
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,11 @@
:include [[net.resp :complete]]
:bundle
[{:path "target/classes" :include ["hara/net/resp"]}]}


foundation/python
{:description "python libs and helpers"
:include [[python :complete]]}

foundation/rt.basic
{:description "wrapper for nginx"
:include [[rt.basic :complete]]
Expand Down
34 changes: 34 additions & 0 deletions proguard-postgres.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Our uberjar
-injars target/uberjar/rt-postgres-4.0.1.jar
# Our output directory
-outjars obfuscated

# ProGuard options. Detailed explanation here http://proguard.sourceforge.net/index.html#manual/usage.html
-dontskipnonpubliclibraryclassmembers
-dontnote
-dontwarn
-printseeds

# -libraryjars /Library/Java/JavaVirtualMachines/openjdk-11.jdk/Contents/Home/jmods
-libraryjars $JAVA_HOME/jmods
-libraryjars ~/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar
-libraryjars ~/.m2/repository/foundation/std.lib/4.0.1/std.lib-4.0.1.jar
-libraryjars ~/.m2/repository/foundation/std.lang/4.0.1/std.lang-4.0.1.jar
-libraryjars ~/.m2/repository/foundation/std.json/4.0.1/std.json-4.0.1.jar
-libraryjars ~/.m2/repository/foundation/std.html/4.0.1/std.html-4.0.1.jar
-libraryjars ~/.m2/repository/org/jsoup/jsoup/1.16.1/jsoup-1.16.1.jar
-libraryjars ~/.m2/repository/com/impossibl/pgjdbc-ng/pgjdbc-ng/0.8.9/pgjdbc-ng-0.8.9.jar
-libraryjars ~/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.15.2/jackson-core-2.15.2.jar
-libraryjars ~/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.15.2/jackson-databind-2.15.2.jar
-libraryjars ~/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.15.2/jackson-datatype-jsr310-2.15.2.jar

# What we will be doing is obfuscating, shrinking and optimizing the jar.
# If you experience any problems start out with obfuscation and add the
# -dontoptimize and the -dontshrink flags and see if it works.

# Tell proguard to leave the clojure runtime alone
# You would need to add any other classes that you wish to preserve here.
-keep class clojure.** { *; }
-keep class java.** { *; }
-keep class javax.** { *; }
# -keep class rt.postgres.** { *; }
2 changes: 1 addition & 1 deletion src-build/component/build_native_index.clj
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"@types/react" "16.9.35",
"@types/react-native" "0.63.2",
"expo" "45.0.3",
"expo-cli" "6.0.8",
"expo-cli" "6.3.7",
"typescript" "4.3.5"},
"metro" {"watchFolders" ["assets"]}}}]}
:default [{:type :module.graph
Expand Down
27 changes: 25 additions & 2 deletions src-build/component/web_native_index.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
[net.http :as http]))

(l/script :js
{:require [[js.core :as j]
{:runtime :websocket
:config {:bench true
:id :dev/web-main
:emit {:native {:suppress true}
:lang/jsx false}}
:require [[js.core :as j]
[js.react.ext-box :as ext-box]
[js.react :as r]
[js.react-native :as n :include [:fn]]
Expand Down Expand Up @@ -55,7 +60,10 @@

(defrun.js ^{:rt/init true}
__main__
(base-box/set-data -/Global ["Main"] -/AppMain))
(base-box/set-data -/Global ["Main"] -/AppMain)
(client/client-ws "localhost"
29001
{}))

(defn.js clearScratch
[]
Expand All @@ -68,4 +76,19 @@
(def.js MODULE
(x/registerRootComponent -/App))

(comment
(l/rt:restart)

(std.make/build-triggered)
(!.js
(+ 1 2 3))

(!.js
(alert "hello"))

(!.js
(console.log "blah"))

(!.js
(+ 1 2 3)))

24 changes: 14 additions & 10 deletions src/rt/basic/type_basic.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
[rt.basic.type-bench :as bench]
[rt.basic.type-container :as container]))

(comment
(h/os-arch)
"aarch64")

(defn start-basic
"starts the basic rt"
{:added "4.0"}
Expand All @@ -30,21 +34,21 @@
:make
:exec]))))
[attach key] (cond container
[(container/start-container
lang
(merge {:suffix id}
(merge-rt container))
(:port server)
rt)
:container]
[(container/start-container
lang
(merge {:suffix id}
(merge-rt container))
(:port server)
rt)
:container]

(not (false? bench))
[(bench/start-bench
(not (false? bench))
[(bench/start-bench
lang
(merge-rt bench)
(:port server)
rt)
:bench])
:bench])
rt (cond-> rt
key (assoc key attach)
key (doto (server/wait-ready)))]
Expand Down
7 changes: 4 additions & 3 deletions src/rt/basic/type_container.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
port
{:keys [host] :as rt}]
(let [script (bootstrap port {:host (or host "host.docker.internal")})
container {:id id
container {:id (or id (h/sid))
:suffix suffix
:group (or group "testing")
:image image
Expand Down Expand Up @@ -55,6 +55,7 @@


(comment
(lib.docker.common/start-container (assoc *container* :cmd ["luajit" "-e" "print(1+1)"])
)
(lib.docker.common/start-container
(assoc *container* :cmd ["luajit" "-e" "print(1+1)"])
)
)
117 changes: 78 additions & 39 deletions src/rt/nginx.clj
Original file line number Diff line number Diff line change
Expand Up @@ -102,35 +102,81 @@
tmp-log (str (fs/create-directory (str tmp-dir "/logs")))]
[tmp-dir tmp-file conf]))

(defn start-test-server-shell
[{:keys [port]
:as rt}]
(let [[tmp-dir tmp-file] (make-temp rt)
sh-args ["nginx" "-p" tmp-dir "-c" tmp-file]
sh-err (h/with-thrown
(h/sh {:args sh-args})
nil)
wait-err (h/with-thrown
(h/wait-for-port "localhost" port {:timeout 2000})
nil)]
(cond wait-err
(do (h/p (str/join " " sh-args))
#_(throw (or sh-err
wait-err))
[:errored tmp-dir])

:else
[:started tmp-dir tmp-file])))

(defn start-test-server-container
"starts the test server for a given port"
{:added "4.0"}
([{:keys [port container]
:as rt}]
(let [{:keys [exec image]} container
[tmp-dir tmp-file] (make-temp rt)

sh-args ["docker" "run" "--rm" #_#_"--network" "host"
"-d"
"-p" (str port ":" port)
"-v" (str tmp-dir ":" tmp-dir)
"-v" (str tmp-file ":" tmp-file)
(or image (h/error "No image found" {:image image}))
(or exec (h/error "No exec found" {:exec exec}))
"-g" "daemon off;"
"-p" tmp-dir "-c" tmp-file]
sh-err (h/with-thrown
(h/sh {:args sh-args})
nil)
wait-err (h/with-thrown
(h/wait-for-port "localhost" port {:timeout 2000})
(Thread/sleep 1000)
nil)]
(cond wait-err
(do (h/p (str/join " " sh-args))
#_(throw (or sh-err
wait-err))
[:errored tmp-dir])

:else
[:started tmp-dir tmp-file]))))

(defn start-test-server
"starts the test server for a given port"
{:added "4.0"}
([{:keys [port]
([{:keys [port container]
:as rt}]
(let [ports (all-nginx-ports)]
(cond (get ports port)
(let [port (h/port:check-available port)
ports (all-nginx-ports)
arch (keyword (h/os-arch))]
(h/prn {:container container
:port port})
(cond (not port)
(h/error "Port not available" {:port port})

(get ports port)
[:running]

(h/port:check-available port)
(let [[tmp-dir tmp-file] (make-temp rt)
sh-args ["nginx" "-p" tmp-dir "-c" tmp-file]
sh-err (h/with-thrown
(h/sh {:args sh-args})
nil)
wait-err (h/with-thrown
(h/wait-for-port "localhost" port {:timeout 2000})
nil)]
(cond wait-err
(do (h/p (str/join " " sh-args))
#_(throw (or sh-err
wait-err))
[:errored tmp-dir])

:else
[:started tmp-dir tmp-file]))


(and container
(contains? (:only container) arch))
(start-test-server-container (assoc rt :port port))

:else
(h/error "Port not available" {:port port})))))
(start-test-server-shell (assoc rt :port port))))))

(defn kill-single-nginx
"kills nginx processes for a single port"
Expand All @@ -151,8 +197,14 @@
{:added "4.0"}
[]
(let [ports (all-nginx-ports)
exec (h/sh "bash" "-c" "ps aux | grep '[n]ginx: .* process' | awk '{print $2}' | xargs kill"
{:wait false})]
exec (h/sh {:args ["bash" "-c"
(str/join
" | "
["ps aux"
"grep '[n]ginx: .* process'"
"awk '{print $2}'"
"xargs kill"])]
:wait false})]
[ports exec]))

(defn stop-test-server
Expand All @@ -176,20 +228,7 @@

(defn- start-nginx
([{:keys [id state host port container no-server] :as rt}]
(cond container
(let [[tmp-dir tmp-file] (make-temp rt)
rt (docker/start-runtime
rt
(-> (merge {:suffix id} container)
(update :volumes merge {tmp-dir "/tmp/nginx"
tmp-file "/tmp/nginx/nginx.conf"})
(assoc :cmd ["nginx"
"-p" "/tmp/nginx"
"-c" "/tmp/nginx/nginx.conf"
"-g" "daemon off;"])))]
(h/wait-for-port (:host rt) port {:timeout 2000})
(reset! state [:started tmp-dir tmp-file])
rt)
(cond

(or no-server
(not= host "localhost"))
Expand Down
37 changes: 37 additions & 0 deletions src/scratch.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
(ns hello
(:require [std.lang :as l]
[std.lib :as h]))


(l/script :js)

(!.js
(fn []
(var a 1)
(var b 2)
(return
(+ 1 2 3))))


(defn.js add-10
[x]
(return (+ x 10)))



(l/script :python
{:runtime :basic
:require [[xt.lang.base-lib :as k]]})

(defn.py add-20
[y]
(return (+ y 20)))




(comment
(add-10 10)
(add-20 10)

)
3 changes: 2 additions & 1 deletion src/std/lib/collection.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"Returns `true` if `x` implements `clojure.lang.APersistentMap`.
(hash-map? {}) => true
(hash-map? []) => false"
(hash-map? []) => false
1 => 2"
{:added "3.0"}
([x] (instance? clojure.lang.APersistentMap x)))

Expand Down
3 changes: 2 additions & 1 deletion test/js/react_native/react_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

(l/script :js
{:runtime :websocket
:config {:id :play/web-main
:config {:id :dev/web-main
#_#_:id :play/web-main
:bench false
:emit {:native {:suppress true}
:lang/jsx false}
Expand Down
10 changes: 5 additions & 5 deletions test/js/react_native_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@
[]
(return
(n/EnclosedCode
{:label "js.react-native/Enclosed"}
[:% n/Row
{:label "js.react-native/Enclosed"}
[:% n/Row
[:% n/Text "HELLO"]]))))

^{:refer js.react-native/EnclosedCodeContainer :added "4.0"}
Expand Down Expand Up @@ -158,12 +158,12 @@
[]
(return
(n/EnclosedCode
{:label "js.react-native/Row"}
[:% n/Row
{:label "js.react-native/Row"}
[:% n/Row
{:style {:backgroundColor "orange"}}
[:% n/Text "HELLO"]
[:% n/Text "WORLD"]]
[:% n/Row
[:% n/Row
{:style {:backgroundColor "blue"}}
[:% n/Text "HELLO"]
[:% n/Text "WORLD"]]))))
Expand Down
Loading

0 comments on commit 49b2f1f

Please sign in to comment.