2016-02-22 22:04:42 +00:00
|
|
|
(ns user
|
2016-11-02 20:27:31 +00:00
|
|
|
(:use [figwheel-sidecar.repl-api :as ra])
|
|
|
|
(:require [hawk.core :as hawk]
|
2017-03-21 12:44:47 +00:00
|
|
|
[re-frisk-sidecar.core :as rfs]
|
2016-11-02 20:27:31 +00:00
|
|
|
[clojure.string :as s]))
|
2016-02-22 22:04:42 +00:00
|
|
|
;; 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))
|
|
|
|
|
2017-01-27 00:55:45 +00:00
|
|
|
(defn get-test-build [build]
|
|
|
|
(update build :source-paths
|
|
|
|
(fn [paths] (let [paths-set (set paths)]
|
|
|
|
(-> paths-set
|
|
|
|
(disj "env/dev")
|
|
|
|
(conj "env/test" "test/cljs")
|
|
|
|
vec)))))
|
|
|
|
|
2016-11-02 20:27:31 +00:00
|
|
|
(def cljs-builds
|
|
|
|
(get-in profiles [:dev :cljsbuild :builds]))
|
2016-02-22 22:04:42 +00:00
|
|
|
|
|
|
|
(defn start-figwheel
|
2016-11-02 20:27:31 +00:00
|
|
|
"Start figwheel for one or more builds"
|
2017-01-27 00:55:45 +00:00
|
|
|
[build-ids cljs-builds]
|
2016-11-02 20:27:31 +00:00
|
|
|
(ra/start-figwheel!
|
|
|
|
{:figwheel-options {:nrepl-port 7888}
|
|
|
|
:build-ids build-ids
|
|
|
|
:all-builds cljs-builds}))
|
|
|
|
|
|
|
|
(def start-cljs-repl ra/cljs-repl)
|
2016-02-22 22:04:42 +00:00
|
|
|
|
|
|
|
(defn stop-figwheel
|
2016-11-02 20:27:31 +00:00
|
|
|
"Stops figwheel"
|
|
|
|
[]
|
|
|
|
(ra/stop-figwheel!))
|
|
|
|
|
2017-08-11 09:38:21 +00:00
|
|
|
(hawk/watch! [{:paths ["resources"]
|
2016-11-02 20:27:31 +00:00
|
|
|
: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)}])
|
|
|
|
|
2017-01-27 00:55:45 +00:00
|
|
|
(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]
|
2017-07-16 15:30:53 +00:00
|
|
|
(assoc
|
|
|
|
(let [build (get all-builds (get-id id))]
|
|
|
|
(if (test-id? id)
|
|
|
|
(get-test-build build)
|
|
|
|
build))
|
|
|
|
:id id))
|
2017-01-27 00:55:45 +00:00
|
|
|
ids))
|
|
|
|
|
2016-11-02 20:27:31 +00:00
|
|
|
(let [env-build-ids (System/getenv "BUILD_IDS")
|
2017-01-27 00:55:45 +00:00
|
|
|
build-ids (if env-build-ids
|
|
|
|
(map keyword (s/split env-build-ids #","))
|
|
|
|
[:android])
|
2017-07-16 15:30:53 +00:00
|
|
|
builds (get-builds build-ids cljs-builds)]
|
2017-03-21 12:44:47 +00:00
|
|
|
(start-figwheel build-ids builds)
|
|
|
|
(rfs/-main))
|