[Fix #3076] Separate figwheel from dev lein profile

Signed-off-by: Dmitry Novotochinov <trybeee@gmail.com>
This commit is contained in:
Foo Pang 2018-01-18 18:15:37 +08:00 committed by Dmitry Novotochinov
parent 03e62548a6
commit ae04dde8ba
No known key found for this signature in database
GPG Key ID: 267674DCC86628D9
16 changed files with 174 additions and 164 deletions

View File

@ -2,7 +2,8 @@
(:use [figwheel-sidecar.repl-api :as ra])
(:require [hawk.core :as hawk]
[re-frisk-sidecar.core :as rfs]
[clojure.string :as s]))
[clojure.string :as s]
[status-im.utils.core :as utils]))
(defn get-test-build [build]
(update build :source-paths
@ -59,14 +60,16 @@
(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)
cljs-builds (get-in profiles [:dev :cljsbuild :builds])
builds (get-builds build-ids cljs-builds)]
(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))))

View File

@ -14,86 +14,91 @@
:plugins [[lein-cljsbuild "1.1.7"]
[lein-re-frisk "0.5.5"]]
:clean-targets ["target/" "index.ios.js" "index.android.js"]
:aliases {"prod-build" ^{:doc "Recompile code with prod profile."}
:aliases {"prod-build" ^{:doc "Recompile code with prod profile."}
["do" "clean"
["with-profile" "prod" "cljsbuild" "once" "ios"]
["with-profile" "prod" "cljsbuild" "once" "android"]]
"figwheel-repl" ["run" "-m" "clojure.main" "env/dev/run.clj"]
"test-cljs" ["with-profile" "test" "doo" "node" "test" "once"]
"test-protocol" ["with-profile" "test" "doo" "node" "protocol" "once"]
"figwheel-repl" ["with-profile" "+figwheel" "run" "-m" "clojure.main" "env/dev/run.clj"]
"test-cljs" ["with-profile" "test" "doo" "node" "test" "once"]
"test-protocol" ["with-profile" "test" "doo" "node" "protocol" "once"]
"test-env-dev-utils" ["with-profile" "test" "doo" "node" "env-dev-utils" "once"]}
:figwheel {:nrepl-port 7888}
:profiles {:dev {:dependencies [[figwheel-sidecar "0.5.14"]
[re-frisk-remote "0.5.3"]
[re-frisk-sidecar "0.5.4"]
[com.cemerick/piggieback "0.2.2"]
[hawk "0.2.11"]]
:source-paths ["src" "env/dev"]
:cljsbuild {:builds
{:ios
{:source-paths ["react-native/src" "src" "env/dev"]
: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"]
:figwheel true
: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]}}}
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]
:timeout 240000}}
:test {:dependencies [[day8.re-frame/test "0.1.5"]]
:plugins [[lein-doo "0.1.7"]]
:cljsbuild {:builds
[{:id "test"
:source-paths ["src" "test/cljs"]
:compiler {:main status-im.test.runner
:output-to "target/test/test.js"
:output-dir "target/test"
:optimizations :none
:preamble ["js/hook-require.js"]
:target :nodejs}}
{:id "protocol"
:source-paths ["src" "test/cljs"]
:compiler {:main status-im.test.protocol.runner
:output-to "target/test/test.js"
:output-dir "target/test"
:optimizations :none
:target :nodejs}}
{:id "env-dev-utils"
:source-paths ["env/dev/env/utils.cljs" "test/env/dev"]
:compiler {:main env.test.runner
:output-to "target/test/test.js"
:output-dir "target/test"
:optimizations :none
:target :nodejs}}]}}
:prod {:cljsbuild {:builds
{:ios
{:source-paths ["react-native/src" "src" "env/prod"]
:compiler {:output-to "index.ios.js"
:main "env.ios.main"
:output-dir "target/ios-prod"
:static-fns true
:optimize-constants true
:optimizations :simple
:closure-defines {"goog.DEBUG" false}
:parallel-build false
:language-in :ecmascript5}
:warning-handlers [status-im.utils.build/warning-handler]}
:android
{:source-paths ["react-native/src" "src" "env/prod"]
:compiler {:output-to "index.android.js"
:main "env.android.main"
:output-dir "target/android-prod"
:static-fns true
:optimize-constants true
:optimizations :simple
:closure-defines {"goog.DEBUG" false}
:parallel-build false
:language-in :ecmascript5}
:warning-handlers [status-im.utils.build/warning-handler]}}}}})
:profiles {:dev {:dependencies [[com.cemerick/piggieback "0.2.2"]]
:cljsbuild {:builds
{:ios
{:source-paths ["react-native/src" "src"]
:compiler {:output-to "target/ios/app.js"
:main "env.ios.main"
:output-dir "target/ios"
:optimizations :none}}
:android
{:source-paths ["react-native/src" "src"]
: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]}}}
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]
:timeout 240000}}
:figwheel [:dev
{:dependencies [[figwheel-sidecar "0.5.14"]
[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"]
:figwheel true}
:android
{:source-paths ["react-native/src" "src" "env/dev"]
:figwheel true}}}}]
:test {:dependencies [[day8.re-frame/test "0.1.5"]]
:plugins [[lein-doo "0.1.7"]]
:cljsbuild {:builds
[{:id "test"
:source-paths ["src" "test/cljs"]
:compiler {:main status-im.test.runner
:output-to "target/test/test.js"
:output-dir "target/test"
:optimizations :none
:preamble ["js/hook-require.js"]
:target :nodejs}}
{:id "protocol"
:source-paths ["src" "test/cljs"]
:compiler {:main status-im.test.protocol.runner
:output-to "target/test/test.js"
:output-dir "target/test"
:optimizations :none
:target :nodejs}}
{:id "env-dev-utils"
:source-paths ["env/dev/env/utils.cljs" "test/env/dev"]
:compiler {:main env.test.runner
:output-to "target/test/test.js"
:output-dir "target/test"
:optimizations :none
:target :nodejs}}]}}
:prod {:cljsbuild {:builds
{:ios
{:source-paths ["react-native/src" "src" "env/prod"]
:compiler {:output-to "index.ios.js"
:main "env.ios.main"
:output-dir "target/ios-prod"
:static-fns true
:optimize-constants true
:optimizations :simple
:closure-defines {"goog.DEBUG" false}
:parallel-build false
:language-in :ecmascript5}
:warning-handlers [status-im.utils.build/warning-handler]}
:android
{:source-paths ["react-native/src" "src" "env/prod"]
:compiler {:output-to "index.android.js"
:main "env.android.main"
:output-dir "target/android-prod"
:static-fns true
:optimize-constants true
:optimizations :simple
:closure-defines {"goog.DEBUG" false}
:parallel-build false
:language-in :ecmascript5}
:warning-handlers [status-im.utils.build/warning-handler]}}}}})

View File

@ -1,6 +1,6 @@
(ns status-im.bots.events
(:require [re-frame.core :as re-frame]
[status-im.utils.utils :as utils]
[status-im.utils.core :as utils]
[status-im.utils.handlers :as handlers]
[status-im.chat.models.input :as input-model]
[taoensso.timbre :as log]))

View File

@ -8,7 +8,7 @@
[status-im.i18n :as i18n]
[status-im.ui.components.animation :as anim]
[status-im.ui.components.list.views :as list]
[status-im.utils.utils :as utils]
[status-im.utils.core :as utils]
[status-im.utils.identicon :as identicon]))
(defn- container-animation-logic [{:keys [to-value val]}]
@ -77,4 +77,4 @@
[list/flat-list {:contentContainerStyle styles/bottom-info-list-container
:data statuses
:render-fn (render-status @contacts)
:enableEmptySections true}]]]))})))
:enableEmptySections true}]]]))})))

View File

@ -4,7 +4,7 @@
[status-im.constants :as constants]
[status-im.data-store.realm.messages :as data-store]
[status-im.utils.random :as random]
[status-im.utils.utils :as utils]))
[status-im.utils.core :as utils]))
(defn- command-type?
[type]
@ -75,7 +75,7 @@
prepare-statuses
(utils/update-if-present :content prepare-content)))
(defn save
(defn save
[{:keys [message-id content from] :as message}]
(when-not (data-store/exists? message-id)
(data-store/save (prepare-message (merge default-values

View File

@ -1,6 +1,6 @@
(ns status-im.ios.platform
(:require [status-im.i18n :refer [label]]
[status-im.utils.utils :as utils]
[status-im.utils.core :as utils]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(def fonts

View File

@ -1,6 +1,6 @@
(ns status-im.ui.components.action-sheet
(:require [status-im.i18n :as i18n]
[status-im.utils.utils :as utils]
[status-im.utils.core :as utils]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn- callback [options]
@ -21,4 +21,4 @@
(merge (options options)
(when title {:title title})
(when message {:message message}))
callback))
callback))

View File

@ -1,7 +1,7 @@
(ns status-im.ui.components.chat-preview
(:require [status-im.ui.components.react :as components]
[status-im.ui.screens.home.styles :as home.styles]
[status-im.utils.utils :as utils]))
[status-im.utils.core :as utils]))
(def default-attributes
{:style home.styles/last-message-text

View File

@ -5,7 +5,7 @@
[status-im.ui.components.react :refer [view text]]
[status-im.utils.platform :refer [platform-specific]]
[status-im.ui.components.styles :refer [color-blue color-black color-blue4-faded]]
[status-im.utils.utils :refer [hash-tag?]]))
[status-im.utils.core :refer [hash-tag?]]))
(defn tag-view [tag]
[text {:style {:color color-blue4-faded}

View File

@ -2,7 +2,7 @@
(:require-macros [status-im.utils.styles :refer [defstyle defnstyle]])
(:require [status-im.ui.components.styles :as common]
[status-im.utils.platform :refer [platform-specific]]
[status-im.utils.utils :as u]
[status-im.utils.core :as u]
[status-im.ui.components.react :as react]))
(def sticky-button-style
@ -27,4 +27,4 @@
[react/view sticky-button-style
[react/text {:style sticky-button-label-style
:uppercase? (get-in platform-specific [:uppercase?])}
label]]]))
label]]]))

View File

@ -8,7 +8,7 @@
[status-im.ui.components.context-menu :as context-menu]
[status-im.ui.screens.home.styles :as styles]
[status-im.ui.components.styles :as component.styles]
[status-im.utils.utils :as utils]
[status-im.utils.core :as utils]
[status-im.commands.utils :as commands-utils]
[status-im.i18n :as i18n]
[status-im.utils.datetime :as time]

View File

@ -13,7 +13,7 @@
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.handlers :as handlers]
[status-im.utils.image-processing :refer [img->base64]]
[status-im.utils.utils :as utils]
[status-im.utils.core :as utils]
[taoensso.timbre :as log]))
(re-frame/reg-fx

View File

@ -19,6 +19,7 @@
[status-im.ui.screens.profile.styles :as styles]
[status-im.ui.components.colors :as colors]
[status-im.utils.utils :as utils]
[status-im.utils.core :refer [hash-tag?]]
[status-im.utils.datetime :as time]
[status-im.utils.config :as config]
[status-im.utils.platform :as platform]
@ -194,7 +195,7 @@
(defn colorize-status-hashtags [status]
(for [[i status] (map-indexed vector (string/split status #" "))]
(if (utils/hash-tag? status)
(if (hash-tag? status)
^{:key (str "item-" i)}
[tag-view status]
^{:key (str "item-" i)}

View File

@ -0,0 +1,61 @@
(ns status-im.utils.core
(:require [clojure.string :as str]))
(defn truncate-str
"Given string and max threshold, trims the string to threshold length with `...`
appended to end if length of the string exceeds max threshold, returns the same
string if threshold is not exceeded"
[s threshold]
(if (and s (< threshold (count s)))
(str (subs s 0 (- threshold 3)) "...")
s))
(defn clean-text [s]
(-> s
(str/replace #"\n" "")
(str/replace #"\r" "")
(str/trim)))
(defn first-index
"Returns first index in coll where predicate on coll element is truthy"
[pred coll]
(->> coll
(keep-indexed (fn [idx e]
(when (pred e)
idx)))
first))
(defn hash-tag? [s]
(= \# (first s)))
(defn wrap-call-once!
"Returns a version of provided function that will be called only the first time wrapping function is called. Returns nil."
[f]
(let [called? (volatile! false)]
(fn [& args]
(when-not @called?
(vreset! called? true)
(apply f args)
nil))))
(defn update-if-present
"Like regular `clojure.core/update` but returns original map if update key is not present"
[m k f & args]
(if (contains? m k)
(apply update m k f args)
m))
(defn map-values
"Efficiently apply function to all map values"
[m f]
(into {}
(map (fn [[k v]]
[k (f v)]))
m))
(defn deep-merge
"Recursively merge maps"
[& maps]
(if (every? map? maps)
(apply merge-with deep-merge maps)
(last maps)))

View File

@ -1,7 +1,6 @@
(ns status-im.utils.utils
(:require [status-im.constants :as const]
[status-im.i18n :as i18n]
[clojure.string :as str]
[status-im.react-native.js-dependencies :as rn-dependencies]))
(defn show-popup [title content]
@ -81,62 +80,3 @@
(.catch (or on-error
(fn [error]
(show-popup "Error" (str error))))))))
(defn truncate-str
"Given string and max threshold, trims the string to threshold length with `...`
appended to end if length of the string exceeds max threshold, returns the same
string if threshold is not exceeded"
[s threshold]
(if (and s (< threshold (count s)))
(str (subs s 0 (- threshold 3)) "...")
s))
(defn clean-text [s]
(-> s
(str/replace #"\n" "")
(str/replace #"\r" "")
(str/trim)))
(defn first-index
"Returns first index in coll where predicate on coll element is truthy"
[pred coll]
(->> coll
(keep-indexed (fn [idx e]
(when (pred e)
idx)))
first))
(defn hash-tag? [s]
(= \# (first s)))
(defn wrap-call-once!
"Returns a version of provided function that will be called only the first time wrapping function is called. Returns nil."
[f]
(let [called? (volatile! false)]
(fn [& args]
(when-not @called?
(vreset! called? true)
(apply f args)
nil))))
(defn update-if-present
"Like regular `clojure.core/update` but returns original map if update key is not present"
[m k f & args]
(if (contains? m k)
(apply update m k f args)
m))
(defn map-values
"Efficiently apply function to all map values"
[m f]
(into {}
(map (fn [[k v]]
[k (f v)]))
m))
(defn deep-merge
"Recursively merge maps"
[& maps]
(if (every? map? maps)
(apply merge-with deep-merge maps)
(last maps)))

View File

@ -1,6 +1,6 @@
(ns status-im.test.utils.utils
(:require [cljs.test :refer-macros [deftest is]]
[status-im.utils.utils :as u]))
[status-im.utils.core :as u]))
(deftest wrap-as-call-once-test
(let [count (atom 0)]