Stopped loading Figwheel API by default #2669

Signed-off-by: andytudhope <tuddy0525@gmail.com>
This commit is contained in:
Audrius Molis 2017-12-17 19:16:42 +02:00 committed by andytudhope
parent 2f4c750d8a
commit 3e940b5bd4
No known key found for this signature in database
GPG Key ID: 02A3DFA93BF26AD2
4 changed files with 33 additions and 36 deletions

View File

@ -79,13 +79,13 @@ prod-build:
# ------------- # -------------
repl: ##@repl Start REPL for iOS and Android repl: ##@repl Start REPL for iOS and Android
BUILD_IDS="ios,android" lein repl lein figwheel-repl ios android
repl-ios: ##@repl Start REPL for iOS repl-ios: ##@repl Start REPL for iOS
BUILD_IDS="ios" lein repl lein figwheel-repl ios
repl-android: ##@repl Start REPL for Android repl-android: ##@repl Start REPL for Android
BUILD_IDS="android" lein repl lein figwheel-repl android
#-------------- #--------------
# Run # Run

View File

@ -1,17 +1,8 @@
(ns user (ns figwheel-api
(:use [figwheel-sidecar.repl-api :as ra]) (:use [figwheel-sidecar.repl-api :as ra])
(:require [hawk.core :as hawk] (:require [hawk.core :as hawk]
[re-frisk-sidecar.core :as rfs] [re-frisk-sidecar.core :as rfs]
[clojure.string :as s])) [clojure.string :as s]))
;; This namespace is loaded automatically by nREPL
;; read project.clj to get build configs
(def profiles (->> "project.clj"
slurp
read-string
(drop-while #(not= % :profiles))
(apply hash-map)
:profiles))
(defn get-test-build [build] (defn get-test-build [build]
(update build :source-paths (update build :source-paths
@ -21,9 +12,6 @@
(conj "env/test" "test/cljs") (conj "env/test" "test/cljs")
vec))))) vec)))))
(def cljs-builds
(get-in profiles [:dev :cljsbuild :builds]))
(defn start-figwheel (defn start-figwheel
"Start figwheel for one or more builds" "Start figwheel for one or more builds"
[build-ids cljs-builds] [build-ids cljs-builds]
@ -32,21 +20,11 @@
:build-ids build-ids :build-ids build-ids
:all-builds cljs-builds})) :all-builds cljs-builds}))
(def start-cljs-repl ra/cljs-repl)
(defn stop-figwheel (defn stop-figwheel
"Stops figwheel" "Stops figwheel"
[] []
(ra/stop-figwheel!)) (ra/stop-figwheel!))
(hawk/watch! [{:paths ["resources"]
:handler (fn [ctx e]
(let [path "src/status_im/utils/js_resources.cljs"
js-resourced (slurp path)]
(spit path (str js-resourced " ;;"))
(spit path js-resourced))
ctx)}])
(defn test-id? [id] (defn test-id? [id]
(s/includes? (name id) "-test")) (s/includes? (name id) "-test"))
@ -67,10 +45,28 @@
:id id)) :id id))
ids)) ids))
(let [env-build-ids (System/getenv "BUILD_IDS") (defn start-cljs-repl []
build-ids (if env-build-ids (hawk/watch! [{:paths ["resources"]
(map keyword (s/split env-build-ids #",")) :handler (fn [ctx e]
(let [path "src/status_im/utils/js_resources.cljs"
js-resourced (slurp path)]
(spit path (str js-resourced " ;;"))
(spit path js-resourced))
ctx)}])
(let [build-ids (if *command-line-args*
(map keyword *command-line-args*)
[:android]) [:android])
;; read project.clj to get build configs
profiles (->> "project.clj"
slurp
read-string
(drop-while #(not= % :profiles))
(apply hash-map)
:profiles)
cljs-builds (get-in profiles [:dev :cljsbuild :builds])
builds (get-builds build-ids cljs-builds)] builds (get-builds build-ids cljs-builds)]
(start-figwheel build-ids builds) (start-figwheel build-ids builds)
(rfs/-main)) (rfs/-main))
(ra/cljs-repl))
(start-cljs-repl)

View File

@ -19,6 +19,7 @@
["do" "clean" ["do" "clean"
["with-profile" "prod" "cljsbuild" "once" "ios"] ["with-profile" "prod" "cljsbuild" "once" "ios"]
["with-profile" "prod" "cljsbuild" "once" "android"]] ["with-profile" "prod" "cljsbuild" "once" "android"]]
"figwheel-repl" ["run" "-m" "clojure.main" "env/dev/figwheel_api.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"]}
:figwheel {:nrepl-port 7888} :figwheel {:nrepl-port 7888}
@ -30,14 +31,14 @@
:source-paths ["src" "env/dev"] :source-paths ["src" "env/dev"]
:cljsbuild {:builds :cljsbuild {:builds
{:ios {:ios
{:source-paths ["react-native/src" "src" "env/dev"] {:source-paths ["react-native/src"]
:figwheel true :figwheel true
:compiler {:output-to "target/ios/app.js" :compiler {:output-to "target/ios/app.js"
:main "env.ios.main" :main "env.ios.main"
:output-dir "target/ios" :output-dir "target/ios"
:optimizations :none}} :optimizations :none}}
:android :android
{:source-paths ["react-native/src" "src" "env/dev"] {:source-paths ["react-native/src"]
:figwheel true :figwheel true
:compiler {:output-to "target/android/app.js" :compiler {:output-to "target/android/app.js"
:main "env.android.main" :main "env.android.main"

View File

@ -64,7 +64,7 @@ fi
lein deps && ./re-natal deps && ./re-natal use-android-device "${device_type}" && ./re-natal use-figwheel lein deps && ./re-natal deps && ./re-natal use-android-device "${device_type}" && ./re-natal use-figwheel
# open figwheel in new tab # open figwheel in new tab
tab "BUILD_IDS=${cljs_build} lein repl" tab "lein figwheel-repl ${cljs_build}"
# open react-native package in new tab # open react-native package in new tab
tab "react-native start" tab "react-native start"