From fad47500bb5da3247169dc05a548b7015b0488e7 Mon Sep 17 00:00:00 2001 From: "Itoh, Masaru" Date: Sun, 18 Feb 2018 21:13:53 +0900 Subject: [PATCH] Migrate figwheel conf from project.clj to figwheel ns Signed-off-by: Julien Eluard --- env/dev/figwheel.clj | 21 ++++++++++++++++ env/dev/figwheel_api.clj | 54 +++++----------------------------------- project.clj | 13 +--------- 3 files changed, 28 insertions(+), 60 deletions(-) create mode 100644 env/dev/figwheel.clj diff --git a/env/dev/figwheel.clj b/env/dev/figwheel.clj new file mode 100644 index 0000000000..a8e928d279 --- /dev/null +++ b/env/dev/figwheel.clj @@ -0,0 +1,21 @@ +(ns figwheel + (:require [clojure.string :as s])) + +(defn system-options [builds-to-start] + {:nrepl-port 7888 + :builds [{:id :ios + :source-paths ["react-native/src" "src" "env/dev"] + :compiler {:output-to "target/ios/app.js" + :main "env.ios.main" + :output-dir "target/ios" + :optimizations :none} + :figwheel true} + {:id :android + :source-paths ["react-native/src" "src" "env/dev"] + :compiler {:output-to "target/android/app.js" + :main "env.android.main" + :output-dir "target/android" + :optimizations :none} + :warning-handlers '[status-im.utils.build/warning-handler] + :figwheel true}] + :builds-to-start builds-to-start}) diff --git a/env/dev/figwheel_api.clj b/env/dev/figwheel_api.clj index 95e71584e5..5045ed7959 100644 --- a/env/dev/figwheel_api.clj +++ b/env/dev/figwheel_api.clj @@ -2,50 +2,19 @@ (:use [figwheel-sidecar.repl-api :as ra]) (:require [hawk.core :as hawk] [re-frisk-sidecar.core :as rfs] - [clojure.string :as s] - [status-im.utils.core :as utils])) - -(defn get-test-build [build] - (update build :source-paths - (fn [paths] (let [paths-set (set paths)] - (-> paths-set - (disj "env/dev") - (conj "test/cljs") - vec))))) + [status-im.utils.core :as utils] + [figwheel :as config])) (defn start-figwheel "Start figwheel for one or more builds" - [build-ids cljs-builds] - (ra/start-figwheel! - {:figwheel-options {:nrepl-port 7888} - :build-ids build-ids - :all-builds cljs-builds})) + [build-ids] + (ra/start-figwheel! (config/system-options build-ids))) (defn stop-figwheel "Stops figwheel" [] (ra/stop-figwheel!)) -(defn test-id? [id] - (s/includes? (name id) "-test")) - -(defn get-id [id] - (-> id - name - (s/replace #"-test" "") - keyword)) - -(defn get-builds [ids all-builds] - (keep - (fn [id] - (assoc - (let [build (get all-builds (get-id id))] - (if (test-id? id) - (get-test-build build) - build)) - :id id)) - ids)) - (defn start ([] (start (if *command-line-args* @@ -59,19 +28,8 @@ (spit path (str js-resourced " ;;")) (spit path js-resourced)) ctx)}]) - ;; read project.clj to get build configs - (let [profiles (->> "project.clj" - slurp - read-string - (drop-while #(not= % :profiles)) - (apply hash-map) - :profiles) - dev-cljs-builds (get-in profiles [:dev :cljsbuild :builds]) - fig-cljs-builds (get-in profiles [:figwheel 1 :cljsbuild :builds]) - cljs-builds (utils/deep-merge dev-cljs-builds fig-cljs-builds) - builds (get-builds build-ids cljs-builds)] - (start-figwheel build-ids builds) - (rfs/-main)))) + (start-figwheel build-ids) + (rfs/-main))) (def stop ra/stop-figwheel!) diff --git a/project.clj b/project.clj index 5b87055f4a..63e01c2add 100644 --- a/project.clj +++ b/project.clj @@ -50,18 +50,7 @@ [re-frisk-remote "0.5.3"] [re-frisk-sidecar "0.5.4"] [hawk "0.2.11"]] - :source-paths ["src" "env/dev"] - :cljsbuild {:builds - {:ios - {:source-paths ["react-native/src" "src" "env/dev"] - :compiler {:output-to "target/ios/app.js" - :output-dir "target/ios"} - :figwheel true} - :android - {:source-paths ["react-native/src" "src" "env/dev"] - :compiler {:output-to "target/android/app.js" - :output-dir "target/android"} - :figwheel true}}}}] + :source-paths ["src" "env/dev"]}] :test {:dependencies [[day8.re-frame/test "0.1.5"]] :plugins [[lein-doo "0.1.7"]] :cljsbuild {:builds