From 3e940b5bd437eb348b77570147eb44a1bf09b817 Mon Sep 17 00:00:00 2001 From: Audrius Molis Date: Sun, 17 Dec 2017 19:16:42 +0200 Subject: [PATCH] Stopped loading Figwheel API by default #2669 Signed-off-by: andytudhope --- Makefile | 6 +-- env/dev/{user.clj => figwheel_api.clj} | 56 ++++++++++++-------------- project.clj | 5 ++- scripts/run-osx | 2 +- 4 files changed, 33 insertions(+), 36 deletions(-) rename env/dev/{user.clj => figwheel_api.clj} (50%) diff --git a/Makefile b/Makefile index 1f5751aac6..a216742096 100644 --- a/Makefile +++ b/Makefile @@ -79,13 +79,13 @@ prod-build: # ------------- 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 - BUILD_IDS="ios" lein repl + lein figwheel-repl ios repl-android: ##@repl Start REPL for Android - BUILD_IDS="android" lein repl + lein figwheel-repl android #-------------- # Run diff --git a/env/dev/user.clj b/env/dev/figwheel_api.clj similarity index 50% rename from env/dev/user.clj rename to env/dev/figwheel_api.clj index 90b8394638..bc9daff592 100644 --- a/env/dev/user.clj +++ b/env/dev/figwheel_api.clj @@ -1,17 +1,8 @@ -(ns user +(ns figwheel-api (:use [figwheel-sidecar.repl-api :as ra]) (:require [hawk.core :as hawk] [re-frisk-sidecar.core :as rfs] [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] (update build :source-paths @@ -21,9 +12,6 @@ (conj "env/test" "test/cljs") vec))))) -(def cljs-builds - (get-in profiles [:dev :cljsbuild :builds])) - (defn start-figwheel "Start figwheel for one or more builds" [build-ids cljs-builds] @@ -32,21 +20,11 @@ :build-ids build-ids :all-builds cljs-builds})) -(def start-cljs-repl ra/cljs-repl) - (defn stop-figwheel "Stops 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] (s/includes? (name id) "-test")) @@ -67,10 +45,28 @@ :id id)) ids)) -(let [env-build-ids (System/getenv "BUILD_IDS") - build-ids (if env-build-ids - (map keyword (s/split env-build-ids #",")) - [:android]) - builds (get-builds build-ids cljs-builds)] - (start-figwheel build-ids builds) - (rfs/-main)) +(defn start-cljs-repl [] + (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)}]) + (let [build-ids (if *command-line-args* + (map keyword *command-line-args*) + [: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)] + (start-figwheel build-ids builds) + (rfs/-main)) + (ra/cljs-repl)) + +(start-cljs-repl) diff --git a/project.clj b/project.clj index 66a3a99c2f..bd7716d22b 100644 --- a/project.clj +++ b/project.clj @@ -19,6 +19,7 @@ ["do" "clean" ["with-profile" "prod" "cljsbuild" "once" "ios"] ["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-protocol" ["with-profile" "test" "doo" "node" "protocol" "once"]} :figwheel {:nrepl-port 7888} @@ -30,14 +31,14 @@ :source-paths ["src" "env/dev"] :cljsbuild {:builds {:ios - {:source-paths ["react-native/src" "src" "env/dev"] + {:source-paths ["react-native/src"] :figwheel true :compiler {:output-to "target/ios/app.js" :main "env.ios.main" :output-dir "target/ios" :optimizations :none}} :android - {:source-paths ["react-native/src" "src" "env/dev"] + {:source-paths ["react-native/src"] :figwheel true :compiler {:output-to "target/android/app.js" :main "env.android.main" diff --git a/scripts/run-osx b/scripts/run-osx index d37771ef57..109e5be39a 100755 --- a/scripts/run-osx +++ b/scripts/run-osx @@ -64,7 +64,7 @@ fi lein deps && ./re-natal deps && ./re-natal use-android-device "${device_type}" && ./re-natal use-figwheel # 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 tab "react-native start"