[feature #2793]
- update re-natal to 0.8.0 - git ignore config.cljs - derive re-frisk url from config.cljs - add tests for env/dev/env/utils - remove lein re-frisk use-re-natal from Makefile Signed-off-by: Oskar Thoren <ot@oskarthoren.com>
This commit is contained in:
parent
b5735230ff
commit
591e568e37
|
@ -50,6 +50,8 @@ android/keystores/debug.keystore
|
||||||
index.android.js
|
index.android.js
|
||||||
index.ios.js
|
index.ios.js
|
||||||
target/
|
target/
|
||||||
|
env/dev/env/config.cljs
|
||||||
|
.re-natal.local
|
||||||
|
|
||||||
# Generated by lein voom
|
# Generated by lein voom
|
||||||
#
|
#
|
||||||
|
|
1
Makefile
1
Makefile
|
@ -31,7 +31,6 @@ prepare: ##@prepare Install dependencies and prepare workspace
|
||||||
npm install
|
npm install
|
||||||
./re-natal deps
|
./re-natal deps
|
||||||
./re-natal use-figwheel
|
./re-natal use-figwheel
|
||||||
lein re-frisk use-re-natal
|
|
||||||
./re-natal enable-source-maps
|
./re-natal enable-source-maps
|
||||||
|
|
||||||
prepare-ios: prepare ##@prepare Install iOS specific dependencies
|
prepare-ios: prepare ##@prepare Install iOS specific dependencies
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
(ns ^:figwheel-no-load env.android.main
|
(ns ^:figwheel-no-load env.android.main
|
||||||
(:require [reagent.core :as r]
|
(:require [reagent.core :as r]
|
||||||
[re-frame.core :as re-frame]
|
|
||||||
[status-im.android.core :as core]
|
[status-im.android.core :as core]
|
||||||
[figwheel.client :as figwheel :include-macros true]
|
[figwheel.client :as figwheel :include-macros true]
|
||||||
[re-frisk-remote.core :as rr]
|
[re-frisk-remote.core :as rr]
|
||||||
[env.config :as conf]
|
[env.config :as conf]
|
||||||
|
[env.utils]
|
||||||
[status-im.utils.handlers :as utils.handlers]))
|
[status-im.utils.handlers :as utils.handlers]))
|
||||||
|
|
||||||
(enable-console-print!)
|
(enable-console-print!)
|
||||||
|
@ -16,11 +16,11 @@
|
||||||
(defn reloader [] @cnt [core/app-root])
|
(defn reloader [] @cnt [core/app-root])
|
||||||
(def root-el (r/as-element [reloader]))
|
(def root-el (r/as-element [reloader]))
|
||||||
|
|
||||||
(figwheel/watch-and-reload
|
(figwheel/start {:websocket-url (:android conf/figwheel-urls)
|
||||||
:websocket-url "ws://localhost:3449/figwheel-ws"
|
:heads-up-display false
|
||||||
:heads-up-display false
|
:jsload-callback #(swap! cnt inc)})
|
||||||
:jsload-callback #(swap! cnt inc))
|
|
||||||
|
|
||||||
(utils.handlers/add-pre-event-callback rr/pre-event-callback)
|
(utils.handlers/add-pre-event-callback rr/pre-event-callback)
|
||||||
|
|
||||||
(rr/enable-re-frisk-remote! {:host "10.0.3.2:4567" :on-init core/init})
|
(rr/enable-re-frisk-remote! {:host (env.utils/re-frisk-url (:android conf/figwheel-urls))
|
||||||
|
:on-init core/init})
|
||||||
|
|
|
@ -4,19 +4,24 @@
|
||||||
[status-im.ios.core :as core]
|
[status-im.ios.core :as core]
|
||||||
[status-im.utils.handlers :as utils.handlers]
|
[status-im.utils.handlers :as utils.handlers]
|
||||||
[figwheel.client :as figwheel :include-macros true]
|
[figwheel.client :as figwheel :include-macros true]
|
||||||
|
[env.config :as conf]
|
||||||
|
[env.utils]
|
||||||
[cljs.pprint]))
|
[cljs.pprint]))
|
||||||
|
|
||||||
(enable-console-print!)
|
(enable-console-print!)
|
||||||
|
|
||||||
|
(assert (exists? core/init) "Fatal Error - Your core.cljs file doesn't define an 'init' function!!! - Perhaps there was a compilation failure?")
|
||||||
|
(assert (exists? core/app-root) "Fatal Error - Your core.cljs file doesn't define an 'app-root' function!!! - Perhaps there was a compilation failure?")
|
||||||
|
|
||||||
(def cnt (r/atom 0))
|
(def cnt (r/atom 0))
|
||||||
(defn reloader [] @cnt [core/app-root])
|
(defn reloader [] @cnt [core/app-root])
|
||||||
(def root-el (r/as-element [reloader]))
|
(def root-el (r/as-element [reloader]))
|
||||||
|
|
||||||
(figwheel/watch-and-reload
|
(figwheel/start {:websocket-url (:ios conf/figwheel-urls)
|
||||||
:websocket-url "ws://localhost:3449/figwheel-ws"
|
:heads-up-display false
|
||||||
:heads-up-display false
|
:jsload-callback #(swap! cnt inc)})
|
||||||
:jsload-callback #(swap! cnt inc))
|
|
||||||
|
|
||||||
(utils.handlers/add-pre-event-callback rr/pre-event-callback)
|
(utils.handlers/add-pre-event-callback rr/pre-event-callback)
|
||||||
|
|
||||||
(rr/enable-re-frisk-remote! {:host "localhost:4567" :on-init core/init})
|
(rr/enable-re-frisk-remote! {:host (env.utils/re-frisk-url (:ios conf/figwheel-urls))
|
||||||
|
:on-init core/init})
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
(ns env.utils
|
||||||
|
(:require [clojure.string :as string]))
|
||||||
|
|
||||||
|
(defn get-host
|
||||||
|
"Expects the input url to be in the form protocol://host:port
|
||||||
|
Returns host or an empty string upon failure"
|
||||||
|
[url]
|
||||||
|
(->
|
||||||
|
url
|
||||||
|
(string/split #"/")
|
||||||
|
(get 2 "")
|
||||||
|
(string/split #":")
|
||||||
|
(get 0 "")))
|
||||||
|
|
||||||
|
(defn re-frisk-url
|
||||||
|
"Expects the input url to be in the form ws://host:port/figwheel-ws
|
||||||
|
which is generated by re-natal"
|
||||||
|
[url]
|
||||||
|
(let [host (get-host url)]
|
||||||
|
(if (string/blank? host)
|
||||||
|
(throw (js/Error. "Failed to parse figwheel url. re-frisk url cannot be blank"))
|
||||||
|
(str host ":" 4567))))
|
|
@ -43,7 +43,7 @@
|
||||||
"prop-types": "15.6.0",
|
"prop-types": "15.6.0",
|
||||||
"punycode": "^1.4.1",
|
"punycode": "^1.4.1",
|
||||||
"querystring-es3": "0.2.1",
|
"querystring-es3": "0.2.1",
|
||||||
"re-natal": "0.7.2",
|
"re-natal": "0.8.0",
|
||||||
"react": "^16.0.0",
|
"react": "^16.0.0",
|
||||||
"react-dom": "16.0.0",
|
"react-dom": "16.0.0",
|
||||||
"react-native": "^0.50.3",
|
"react-native": "^0.50.3",
|
||||||
|
|
10
project.clj
10
project.clj
|
@ -21,7 +21,8 @@
|
||||||
["with-profile" "prod" "cljsbuild" "once" "android"]]
|
["with-profile" "prod" "cljsbuild" "once" "android"]]
|
||||||
"figwheel-repl" ["run" "-m" "clojure.main" "env/dev/run.clj"]
|
"figwheel-repl" ["run" "-m" "clojure.main" "env/dev/run.clj"]
|
||||||
"test-cljs" ["with-profile" "test" "doo" "node" "test" "once"]
|
"test-cljs" ["with-profile" "test" "doo" "node" "test" "once"]
|
||||||
"test-protocol" ["with-profile" "test" "doo" "node" "protocol" "once"]}
|
"test-protocol" ["with-profile" "test" "doo" "node" "protocol" "once"]
|
||||||
|
"test-env-dev-utils" ["with-profile" "test" "doo" "node" "env-dev-utils" "once"]}
|
||||||
:figwheel {:nrepl-port 7888}
|
:figwheel {:nrepl-port 7888}
|
||||||
:profiles {:dev {:dependencies [[figwheel-sidecar "0.5.14"]
|
:profiles {:dev {:dependencies [[figwheel-sidecar "0.5.14"]
|
||||||
[re-frisk-remote "0.5.3"]
|
[re-frisk-remote "0.5.3"]
|
||||||
|
@ -61,6 +62,13 @@
|
||||||
{:id "protocol"
|
{:id "protocol"
|
||||||
:source-paths ["src" "test/cljs"]
|
:source-paths ["src" "test/cljs"]
|
||||||
:compiler {:main status-im.test.protocol.runner
|
:compiler {:main status-im.test.protocol.runner
|
||||||
|
:output-to "target/test/test.js"
|
||||||
|
:output-dir "target/test"
|
||||||
|
:optimizations :none
|
||||||
|
:target :nodejs}}
|
||||||
|
{:id "env-dev-utils"
|
||||||
|
:source-paths ["env/dev/env/utils.cljs" "test/env/dev"]
|
||||||
|
:compiler {:main env.test.runner
|
||||||
:output-to "target/test/test.js"
|
:output-to "target/test/test.js"
|
||||||
:output-dir "target/test"
|
:output-dir "target/test"
|
||||||
:optimizations :none
|
:optimizations :none
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
(ns env.test.runner
|
||||||
|
(:require [doo.runner :refer-macros [doo-tests]]
|
||||||
|
[env.test.utils]))
|
||||||
|
|
||||||
|
(enable-console-print!)
|
||||||
|
|
||||||
|
;; Or doo will exit with an error, see:
|
||||||
|
;; https://github.com/bensu/doo/issues/83#issuecomment-165498172
|
||||||
|
(set! (.-error js/console) (fn [x] (.log js/console x)))
|
||||||
|
|
||||||
|
(set! goog.DEBUG false)
|
||||||
|
|
||||||
|
(doo-tests 'env.test.utils)
|
|
@ -0,0 +1,13 @@
|
||||||
|
(ns env.test.utils
|
||||||
|
(:require [cljs.test :refer-macros [deftest is]]
|
||||||
|
[env.utils :as utils]))
|
||||||
|
|
||||||
|
(deftest get-host-test
|
||||||
|
(is (= (utils/get-host "http://localhost:8000") "localhost"))
|
||||||
|
(is (= (utils/get-host "http://0.0.0.0:8000") "0.0.0.0"))
|
||||||
|
(is (= (utils/get-host "invalid") "")))
|
||||||
|
|
||||||
|
(deftest re-frisk-url-test
|
||||||
|
(is (= (utils/re-frisk-url "ws://localhost:3449/figwheel-ws") "localhost:4567"))
|
||||||
|
(is (= (utils/re-frisk-url "ws://10.0.2.2:3449/figwheel-ws") "10.0.2.2:4567"))
|
||||||
|
(is (thrown? js/Error (utils/re-frisk-url "invalid"))))
|
Loading…
Reference in New Issue