mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-27 00:49:39 +00:00
Use clj-rn for development
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
011a7e2218
commit
bb729c6c81
31
Makefile
31
Makefile
@ -38,6 +38,9 @@ prepare-ios: prepare ##@prepare Install iOS specific dependencies
|
|||||||
mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack
|
mvn -f modules/react-native-status/ios/RCTStatus dependency:unpack
|
||||||
cd ios && pod install && cd ..
|
cd ios && pod install && cd ..
|
||||||
|
|
||||||
|
prepare-android: prepare ##@prepare Install Android specific dependencies
|
||||||
|
cd android; ./gradlew react-native-android:installArchives
|
||||||
|
|
||||||
#----------------
|
#----------------
|
||||||
# Release builds
|
# Release builds
|
||||||
#----------------
|
#----------------
|
||||||
@ -71,26 +74,25 @@ full-prod-build: ##@build build prod for both Android and iOS
|
|||||||
# REPL
|
# REPL
|
||||||
# -------------
|
# -------------
|
||||||
|
|
||||||
repl-ios-real: ##@repl Start REPL for iOS real device
|
watch-ios-real: ##@watch Start development for iOS real device
|
||||||
clj -R:repl build.clj figwheel --platform ios --ios-device real
|
clj -R:dev build.clj watch --platform ios --ios-device real
|
||||||
|
|
||||||
repl-ios-simulator: ##@repl Start REPL for iOS simulator
|
watch-ios-simulator: ##@watch Start development for iOS simulator
|
||||||
clj -R:repl build.clj figwheel --platform ios --ios-device simulator
|
clj -R:dev build.clj watch --platform ios --ios-device simulator
|
||||||
|
|
||||||
repl-android-real: ##@repl Start REPL for Android real device
|
watch-android-real: ##@watch Start development for Android real device
|
||||||
clj -R:repl build.clj figwheel --platform android --android-device real
|
clj -R:dev build.clj watch --platform android --android-device real
|
||||||
|
|
||||||
repl-android-avd: ##@repl Start REPL for Android AVD
|
watch-android-avd: ##@watch Start development for Android AVD
|
||||||
clj -R:repl build.clj figwheel --platform android --android-device avd
|
clj -R:dev build.clj watch --platform android --android-device avd
|
||||||
|
|
||||||
repl-android-genymotion: ##@repl Start REPL for Android Genymotion
|
watch-android-genymotion: ##@watch Start development for Android Genymotion
|
||||||
clj -R:repl build.clj figwheel --platform android --android-device genymotion
|
clj -R:dev build.clj watch --platform android --android-device genymotion
|
||||||
|
|
||||||
#--------------
|
#--------------
|
||||||
# Run
|
# Run
|
||||||
# -------------
|
# -------------
|
||||||
run-android: ##@run Run Android build
|
run-android: ##@run Run Android build
|
||||||
cd android; ./gradlew react-native-android:installArchives
|
|
||||||
react-native run-android --appIdSuffix debug
|
react-native run-android --appIdSuffix debug
|
||||||
|
|
||||||
SIMULATOR=
|
SIMULATOR=
|
||||||
@ -140,8 +142,5 @@ android-ports-real: ##@other Add reverse proxy to Android Device/Simulator
|
|||||||
startdev-%:
|
startdev-%:
|
||||||
$(eval SYSTEM := $(word 2, $(subst -, , $@)))
|
$(eval SYSTEM := $(word 2, $(subst -, , $@)))
|
||||||
$(eval DEVICE := $(word 3, $(subst -, , $@)))
|
$(eval DEVICE := $(word 3, $(subst -, , $@)))
|
||||||
case "$(SYSTEM)" in \
|
${MAKE} prepare-${SYSTEM}
|
||||||
"android") ${MAKE} prepare;; \
|
${MAKE} watch-$(SYSTEM)-$(DEVICE)
|
||||||
"ios") ${MAKE} prepare-ios;; \
|
|
||||||
esac
|
|
||||||
${MAKE} repl-$(SYSTEM)-$(DEVICE)
|
|
||||||
|
99
build.clj
99
build.clj
@ -81,10 +81,10 @@
|
|||||||
"[env] (required): Pre-defined build environment. Allowed values: \"dev\", \"prod\", \"test\""
|
"[env] (required): Pre-defined build environment. Allowed values: \"dev\", \"prod\", \"test\""
|
||||||
"[build-id] (optional): Build ID. When omitted, this task will compile all builds from the specified [env]."
|
"[build-id] (optional): Build ID. When omitted, this task will compile all builds from the specified [env]."
|
||||||
"[type] (optional): Build type - value could be \"once\" or \"watch\". Default: \"once\"."]}
|
"[type] (optional): Build type - value could be \"once\" or \"watch\". Default: \"once\"."]}
|
||||||
:figwheel {:desc "Start figwheel + CLJS REPL / nREPL"
|
:watch {:desc "Start development"
|
||||||
:usage ["Usage: clj -R:repl build.clj figwheel [options]"
|
:usage ["Usage: clj -R:dev build.clj watch [options]"
|
||||||
""
|
""
|
||||||
"[-h|--help] to see all available options"]}
|
"[-h|--help] to see all available options"]}
|
||||||
:test {:desc "Run tests"
|
:test {:desc "Run tests"
|
||||||
:usage ["Usage: clj -R:test build.clj test [build-id]"
|
:usage ["Usage: clj -R:test build.clj test [build-id]"
|
||||||
""
|
""
|
||||||
@ -202,86 +202,27 @@
|
|||||||
(compile-cljs :test build-id)
|
(compile-cljs :test build-id)
|
||||||
(doo/run-script :node (->> build-id (get-cljsbuild-config :test) :compiler))))
|
(doo/run-script :node (->> build-id (get-cljsbuild-config :test) :compiler))))
|
||||||
|
|
||||||
;;; Figwheeling task
|
;;; :watch task
|
||||||
|
|
||||||
(def figwheel-cli-opts
|
(defn hawk-handler
|
||||||
[["-p" "--platform BUILD-IDS" "CLJS Build IDs for platforms <android|ios>"
|
[ctx e]
|
||||||
:id :build-ids
|
(let [path "src/status_im/utils/js_resources.cljs"
|
||||||
:default [:android]
|
js-resourced (slurp path)]
|
||||||
:parse-fn #(->> (.split % ",")
|
(spit path (str js-resourced " ;;"))
|
||||||
(map (comp keyword str/lower-case str/trim))
|
(spit path js-resourced))
|
||||||
vec)
|
ctx)
|
||||||
:validate [(fn [build-ids] (every? #(some? (#{:android :ios} %)) build-ids)) "Allowed \"android\", and/or \"ios\""]]
|
|
||||||
["-n" "--nrepl-port PORT" "nREPL Port"
|
|
||||||
:id :port
|
|
||||||
:parse-fn #(if (string? %) (Integer/parseInt %) %)
|
|
||||||
:validate [#(or (true? %) (< 0 % 0x10000)) "Must be a number between 0 and 65536"]]
|
|
||||||
["-a" "--android-device TYPE" "Android Device Type <avd|genymotion|real>"
|
|
||||||
:id :android-device
|
|
||||||
:parse-fn #(keyword (str/lower-case %))
|
|
||||||
:validate [#(some? (#{:avd :genymotion :real} %)) "Must be \"avd\", \"genymotion\", or \"real\""]]
|
|
||||||
["-i" "--ios-device TYPE" "iOS Device Type <simulator|real>"
|
|
||||||
:id :ios-device
|
|
||||||
:parse-fn #(keyword (str/lower-case %))
|
|
||||||
:validate [#(some? (#{:simulator :real} %)) "Must be \"simulator\", or \"real\""]]
|
|
||||||
["-h" "--help"]])
|
|
||||||
|
|
||||||
(defn print-and-exit [msg]
|
(defmethod task "watch" [[_ & args]]
|
||||||
(println msg)
|
(with-namespaces [[hawk.core :as hawk]
|
||||||
(System/exit 1))
|
|
||||||
|
|
||||||
(defn parse-figwheel-cli-opts [args]
|
|
||||||
(with-namespaces [[clojure.tools.cli :as cli]]
|
|
||||||
(let [{:keys [options errors summary]} (cli/parse-opts args figwheel-cli-opts)]
|
|
||||||
(cond
|
|
||||||
(:help options) (print-and-exit summary)
|
|
||||||
(not (nil? errors)) (print-and-exit errors)
|
|
||||||
:else options))))
|
|
||||||
|
|
||||||
(defmethod task "figwheel" [[_ & args]]
|
|
||||||
(with-namespaces [[figwheel-sidecar.repl-api :as ra]
|
|
||||||
[hawk.core :as hawk]
|
|
||||||
[re-frisk-sidecar.core :as rfs]
|
[re-frisk-sidecar.core :as rfs]
|
||||||
|
[figwheel-sidecar.repl-api :as ra]
|
||||||
[clj-rn.core :as clj-rn]
|
[clj-rn.core :as clj-rn]
|
||||||
[clj-rn.main :refer [get-main-config] :rename {get-main-config get-cljrn-config}]]
|
[clj-rn.main :as main]]
|
||||||
(let [{:keys [build-ids
|
(let [options (main/parse-cli-options args main/watch-task-options)]
|
||||||
port
|
(clj-rn/watch (assoc options :start-cljs-repl false))
|
||||||
android-device
|
|
||||||
ios-device]} (parse-figwheel-cli-opts args)
|
|
||||||
hosts-map {:android (clj-rn/resolve-dev-host :android android-device)
|
|
||||||
:ios (clj-rn/resolve-dev-host :ios ios-device)}]
|
|
||||||
(clj-rn/enable-source-maps)
|
|
||||||
(clj-rn/write-env-dev hosts-map)
|
|
||||||
(doseq [build-id build-ids
|
|
||||||
:let [host-ip (get hosts-map build-id)
|
|
||||||
platform-name (if (= build-id :ios) "iOS" "Android")
|
|
||||||
{:keys [js-modules
|
|
||||||
name
|
|
||||||
resource-dirs]} (get-cljrn-config)]]
|
|
||||||
(clj-rn/rebuild-index-js build-id {:app-name name
|
|
||||||
:host-ip host-ip
|
|
||||||
:js-modules js-modules
|
|
||||||
:resource-dirs resource-dirs})
|
|
||||||
(when (= build-id :ios)
|
|
||||||
(clj-rn/update-ios-rct-web-socket-executor host-ip)
|
|
||||||
(println-colorized "Host in RCTWebSocketExecutor.m was updated" green-color))
|
|
||||||
(println-colorized (format "Dev server host for %s: %s" platform-name host-ip) green-color))
|
|
||||||
(ra/start-figwheel!
|
|
||||||
{:figwheel-options (cond-> {:builds-to-start build-ids}
|
|
||||||
port (merge {:nrepl-port port
|
|
||||||
:nrepl-middleware ["cider.nrepl/cider-middleware"
|
|
||||||
"refactor-nrepl.middleware/wrap-refactor"
|
|
||||||
"cemerick.piggieback/wrap-cljs-repl"]}))
|
|
||||||
:all-builds (into [] (for [[build-id {:keys [source-paths compiler warning-handlers]}]
|
|
||||||
(get-cljsbuild-config :dev)]
|
|
||||||
{:id build-id
|
|
||||||
:source-paths (conj source-paths "env/dev")
|
|
||||||
:compiler compiler
|
|
||||||
:figwheel true}))})
|
|
||||||
(rfs/-main)
|
(rfs/-main)
|
||||||
(if-not port
|
(hawk/watch! [{:paths ["resources"] :handler hawk-handler}])
|
||||||
(ra/cljs-repl)
|
(when (:start-cljs-repl options) (ra/cljs-repl)))))
|
||||||
(spit ".nrepl-port" port)))))
|
|
||||||
|
|
||||||
;;; Help
|
;;; Help
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
{:name "StatusIm"
|
{:name "StatusIm"
|
||||||
|
|
||||||
|
:run-options {:android {"appIdSuffix" "debug"}}
|
||||||
|
|
||||||
|
:figwheel-bridge "figwheel-bridge.js"
|
||||||
;; JS modules
|
;; JS modules
|
||||||
:js-modules ["realm"
|
:js-modules ["realm"
|
||||||
"react-native-i18n"
|
"react-native-i18n"
|
||||||
@ -37,4 +40,35 @@
|
|||||||
"react-native-testfairy"]
|
"react-native-testfairy"]
|
||||||
|
|
||||||
;; Resoures
|
;; Resoures
|
||||||
:resource-dirs ["resources/images"]}
|
:resource-dirs ["resources/images"]
|
||||||
|
|
||||||
|
:figwheel-options {:nrepl-port 7888
|
||||||
|
:nrepl-middleware ["cider.nrepl/cider-middleware"
|
||||||
|
"refactor-nrepl.middleware/wrap-refactor"
|
||||||
|
"cemerick.piggieback/wrap-cljs-repl"]}
|
||||||
|
|
||||||
|
:builds [{:id :desktop
|
||||||
|
:source-paths ["react-native/src" "src" "env/dev"]
|
||||||
|
:compiler {:output-to "target/ios/desktop.js"
|
||||||
|
:main "env.desktop.main"
|
||||||
|
:output-dir "target/desktop"
|
||||||
|
:npm-deps false
|
||||||
|
:optimizations :none}
|
||||||
|
:figwheel true}
|
||||||
|
{: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"
|
||||||
|
:npm-deps false
|
||||||
|
: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"
|
||||||
|
:npm-deps false
|
||||||
|
:optimizations :none}
|
||||||
|
:warning-handlers [status-im.utils.build/warning-handler]
|
||||||
|
:figwheel true}]}
|
||||||
|
33
deps.edn
33
deps.edn
@ -13,22 +13,23 @@
|
|||||||
com.cognitect/transit-cljs {:mvn/version "0.8.248"}}
|
com.cognitect/transit-cljs {:mvn/version "0.8.248"}}
|
||||||
|
|
||||||
:aliases
|
:aliases
|
||||||
{:repl {:extra-deps
|
{:dev {:extra-deps
|
||||||
{;; Figwheel ClojureScript REPL
|
{clj-rn {:git/url "https://github.com/status-im/clj-rn"
|
||||||
com.cemerick/piggieback {:mvn/version "0.2.2"
|
:sha "d9b835701232cb1744a670e6dd21325712a43789"}
|
||||||
:exclusions [com.google.javascript/closure-compiler]}
|
|
||||||
figwheel-sidecar {:mvn/version "0.5.16-SNAPSHOT"
|
|
||||||
:exclusions [com.google.javascript/closure-compiler]}
|
|
||||||
re-frisk-remote {:mvn/version "0.5.5"}
|
|
||||||
re-frisk-sidecar {:mvn/version "0.5.7"}
|
|
||||||
hawk {:mvn/version "0.2.11"}
|
|
||||||
day8.re-frame/tracing {:mvn/version "0.5.0"}
|
|
||||||
|
|
||||||
;; CIDER compatible nREPL
|
;; Figwheel ClojureScript REPL
|
||||||
cider/cider-nrepl {:mvn/version "0.16.0"}
|
com.cemerick/piggieback {:mvn/version "0.2.2"
|
||||||
org.clojure/tools.nrepl {:mvn/version "0.2.13"}
|
:exclusions [com.google.javascript/closure-compiler]}
|
||||||
refactor-nrepl {:mvn/version "2.3.1"}
|
figwheel-sidecar {:mvn/version "0.5.16"
|
||||||
org.clojure/tools.cli {:mvn/version "0.3.7"}
|
:exclusions [com.google.javascript/closure-compiler]}
|
||||||
clj-rn {:git/url "https://github.com/status-im/clj-rn" :sha "e3fe471c601b2fa890f8692757aab74adf96fa28"}}}
|
re-frisk-remote {:mvn/version "0.5.5"}
|
||||||
|
re-frisk-sidecar {:mvn/version "0.5.7"}
|
||||||
|
hawk {:mvn/version "0.2.11"}
|
||||||
|
day8.re-frame/tracing {:mvn/version "0.5.0"}
|
||||||
|
|
||||||
|
;; CIDER compatible nREPL
|
||||||
|
cider/cider-nrepl {:mvn/version "0.16.0"}
|
||||||
|
org.clojure/tools.nrepl {:mvn/version "0.2.13"}
|
||||||
|
refactor-nrepl {:mvn/version "2.3.1"}}}
|
||||||
:test {:extra-deps {day8.re-frame/test {:mvn/version "0.1.5"}
|
:test {:extra-deps {day8.re-frame/test {:mvn/version "0.1.5"}
|
||||||
doo {:mvn/version "0.1.9"}}}}}
|
doo {:mvn/version "0.1.9"}}}}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user