Migrate figwheel conf from project.clj to figwheel ns
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
cc8ef6580e
commit
fad47500bb
|
@ -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})
|
|
@ -2,50 +2,19 @@
|
||||||
(: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]
|
[status-im.utils.core :as utils]
|
||||||
[status-im.utils.core :as utils]))
|
[figwheel :as config]))
|
||||||
|
|
||||||
(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)))))
|
|
||||||
|
|
||||||
(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]
|
||||||
(ra/start-figwheel!
|
(ra/start-figwheel! (config/system-options build-ids)))
|
||||||
{:figwheel-options {:nrepl-port 7888}
|
|
||||||
:build-ids build-ids
|
|
||||||
:all-builds cljs-builds}))
|
|
||||||
|
|
||||||
(defn stop-figwheel
|
(defn stop-figwheel
|
||||||
"Stops figwheel"
|
"Stops figwheel"
|
||||||
[]
|
[]
|
||||||
(ra/stop-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
|
(defn start
|
||||||
([]
|
([]
|
||||||
(start (if *command-line-args*
|
(start (if *command-line-args*
|
||||||
|
@ -59,19 +28,8 @@
|
||||||
(spit path (str js-resourced " ;;"))
|
(spit path (str js-resourced " ;;"))
|
||||||
(spit path js-resourced))
|
(spit path js-resourced))
|
||||||
ctx)}])
|
ctx)}])
|
||||||
;; read project.clj to get build configs
|
(start-figwheel build-ids)
|
||||||
(let [profiles (->> "project.clj"
|
(rfs/-main)))
|
||||||
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))))
|
|
||||||
|
|
||||||
(def stop ra/stop-figwheel!)
|
(def stop ra/stop-figwheel!)
|
||||||
|
|
||||||
|
|
13
project.clj
13
project.clj
|
@ -50,18 +50,7 @@
|
||||||
[re-frisk-remote "0.5.3"]
|
[re-frisk-remote "0.5.3"]
|
||||||
[re-frisk-sidecar "0.5.4"]
|
[re-frisk-sidecar "0.5.4"]
|
||||||
[hawk "0.2.11"]]
|
[hawk "0.2.11"]]
|
||||||
:source-paths ["src" "env/dev"]
|
: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}}}}]
|
|
||||||
:test {:dependencies [[day8.re-frame/test "0.1.5"]]
|
:test {:dependencies [[day8.re-frame/test "0.1.5"]]
|
||||||
:plugins [[lein-doo "0.1.7"]]
|
:plugins [[lein-doo "0.1.7"]]
|
||||||
:cljsbuild {:builds
|
:cljsbuild {:builds
|
||||||
|
|
Loading…
Reference in New Issue