Skip to content

Commit 043cf4c

Browse files
committed
removed some dependencies.
1 parent e35603f commit 043cf4c

File tree

15 files changed

+599
-149
lines changed

15 files changed

+599
-149
lines changed

deps.edn

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
{:paths ["src/main"],
22

3-
:deps {com.taoensso/timbre {:mvn/version "4.10.0"}
4-
org.clojure/clojure {:mvn/version "1.10.1"}
5-
expound {:mvn/version "0.8.4"}}
3+
:deps {expound/expound {:mvn/version "0.8.5"}}
64

7-
:aliases {:test {:extra-paths ["src/test"]
8-
:extra-deps {fulcrologic/fulcro-spec {:mvn/version "3.1.4"}}}
5+
:aliases {:test {:extra-paths ["src/test"]}
96

107
:clj-tests {:extra-paths ["src/test"]
118
:main-opts ["-m" "kaocha.runner"]
12-
:extra-deps {lambdaisland/kaocha {:mvn/version "0.0-590"}}}
9+
:extra-deps {lambdaisland/kaocha {:mvn/version "1.0.700"}}}
1310

14-
:dev {:extra-paths ["src/dev"]
15-
:extra-deps {thheller/shadow-cljs {:mvn/version "2.8.83"}
11+
:dev {:extra-paths ["src/dev" "src/test"]
12+
:extra-deps {thheller/shadow-cljs {:mvn/version "2.11.7"}
13+
fulcrologic/fulcro-spec {:mvn/version "3.1.8"}
14+
org.clojure/clojure {:mvn/version "1.10.0"}
1615
org.clojure/tools.nrepl {:mvn/version "0.2.13"}
1716
binaryage/devtools {:mvn/version "1.0.0"}
18-
org.clojure/tools.namespace {:mvn/version "0.3.1"}}}}}
17+
org.clojure/tools.namespace {:mvn/version "1.0.0"}}}}}
1918

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"karma-chrome-launcher": "2.2.0",
1010
"karma-cljs-test": "0.1.0",
1111
"karma-firefox-launcher": "1.1.0",
12-
"shadow-cljs": "2.8.67"
12+
"shadow-cljs": "2.11.7"
1313
},
1414
"author": "Tony Kay",
1515
"license": "MIT",

pom.xml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
<id>clojars</id>
6161
<url>https://repo.clojars.org/</url>
6262
</repository>
63+
<repository>
64+
<id>fulcrologic</id>
65+
<url>https://mvn.fulcrologic.com</url>
66+
</repository>
6367
</repositories>
6468
<dependencies>
6569
<dependency>
@@ -70,12 +74,7 @@
7074
<dependency>
7175
<groupId>expound</groupId>
7276
<artifactId>expound</artifactId>
73-
<version>0.8.4</version>
74-
</dependency>
75-
<dependency>
76-
<groupId>com.taoensso</groupId>
77-
<artifactId>timbre</artifactId>
78-
<version>4.10.0</version>
77+
<version>0.8.5</version>
7978
</dependency>
8079
</dependencies>
8180
</project>

src/dev/user.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
;; When guardrails is disabled this will just be a normal `defn`, and no fspec overhead will
1212
;; appear in cljs builds. When enabled it will check the inputs/outputs and *always* log
1313
;; an error using `expound`, and then *optionally* throw an exception,
14-
(>defn f [i]
15-
[int? | #(< -10 i 5) => int? | #(> i %)]
16-
(inc i))
14+
;; TODO: return predicate cannot resolve from arglist
15+
;(>defn f [i]
16+
; [int? | #(< -10 i 5) => int? | #(> i %)]
17+
; (inc i))
1718

1819
(comment
1920
(f -2))

src/main/com/fulcrologic/guardrails/config.cljc

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
(ns ^:no-doc com.fulcrologic.guardrails.config
1010
#?(:cljs (:require-macros com.fulcrologic.guardrails.config))
1111
(:require
12-
[com.fulcrologic.guardrails.utils :as util]
13-
[taoensso.timbre :as log]
12+
[com.fulcrologic.guardrails.utils :as utils]
1413
#?@(:clj [[clojure.edn :as edn]]
1514
:cljs [[cljs.env :as cljs-env]])))
1615

@@ -44,9 +43,10 @@
4443
read-config-file
4544
(fn []
4645
#?(:clj (try
47-
(edn/read-string (slurp (or
48-
(System/getProperty "guardrails.config")
49-
"guardrails.edn")))
46+
(edn/read-string
47+
(slurp
48+
(or (System/getProperty "guardrails.config")
49+
"guardrails.edn")))
5050
(catch Exception _ nil))
5151
:cljs nil))
5252

@@ -56,50 +56,50 @@
5656
(let [config (let [cljs-compiler-config
5757
(when cljs-env/*compiler*
5858
(get-in @cljs-env/*compiler* [:options :external-config :guardrails]))]
59-
(when #?(:clj (or
60-
cljs-compiler-config
61-
(System/getProperty "guardrails.enabled")) :cljs false)
59+
(when #?(:clj (or
60+
cljs-compiler-config
61+
(System/getProperty "guardrails.enabled"))
62+
:cljs false)
6263
(when-not @warned?
6364
(reset! warned? true)
64-
(log/warn "GUARDRAILS IS ENABLED. RUNTIME PERFORMANCE WILL BE AFFECTED.")
65-
(log/info "Guardrails was enabled because"
66-
(if cljs-compiler-config
67-
"the CLJS Compiler config enabled it"
68-
"the guardrails.enabled property is set to a (any) value.")))
69-
(merge {}
70-
(read-config-file)
71-
cljs-compiler-config)))]
72-
#?(:clj
73-
(when (:pro? config)
74-
(try
75-
(require 'com.fulcrologic.guardrails-pro.core)
76-
(log/info "Guardrails Pro Enabled.")
77-
(catch Exception e
78-
(log/error e)
79-
(throw (ex-info "Guardrails Pro mode requested, but Guardrails Pro is not on the classpath!" {}))))))
65+
(utils/report-problem "GUARDRAILS IS ENABLED. RUNTIME PERFORMANCE WILL BE AFFECTED.")
66+
(utils/report-problem (str "Guardrails was enabled because "
67+
(if cljs-compiler-config
68+
"the CLJS Compiler config enabled it"
69+
"the guardrails.enabled property is set to a (any) value."))))
70+
(merge {} (read-config-file))))]
8071
;#?(:clj (.println System/err config)) ; DEBUG
8172
config))]
8273

8374
(defn get-env-config
8475
([]
8576
(get-env-config true))
8677
([cache?]
87-
(let [result (if (or (not cache?)
88-
#?(:clj (= (System/getProperty "guardrails.cache") "false")))
89-
(reload-config)
90-
(let [now (identity #?(:clj (System/currentTimeMillis) :cljs (js/Date.now)))]
91-
(if (< (- now (::timestamp @*config-cache))
92-
2000)
93-
(::value @*config-cache)
94-
(::value (reset! *config-cache {::timestamp now
95-
::value (reload-config)})))))]
78+
(let [result (if (or (not cache?)
79+
#?(:clj (= "false" (System/getProperty "guardrails.cache"))))
80+
(reload-config)
81+
(let [now (identity #?(:clj (System/currentTimeMillis) :cljs (js/Date.now)))
82+
since-last (- now (::timestamp @*config-cache))]
83+
(if (< since-last 2000)
84+
(::value @*config-cache)
85+
(::value (reset! *config-cache {::timestamp now
86+
::value (reload-config)})))))
87+
cljs-compiler-config (when cljs-env/*compiler*
88+
(get-in @cljs-env/*compiler* [:options :external-config :guardrails]))
89+
mode-config #?(:cljs nil
90+
:clj (when-let [mode (System/getProperty "guardrails.mode")]
91+
(let [?mode (read-string mode)]
92+
(if (#{:runtime :pro :all} ?mode)
93+
{:mode ?mode}
94+
(.println System/err (format "Unknown guardrails mode %s, defaulting to :runtime" mode))))))]
9695
#?(:clj (when (and result cljs-env/*compiler*)
97-
(let [production? (contains? #{:advanced :whitespace :simple} (get-in @cljs-env/*compiler* [:options :optimizations]))]
96+
(let [production? (contains? #{:advanced :whitespace :simple}
97+
(get-in @cljs-env/*compiler* [:options :optimizations]))]
9898
(when (and production? (not= "production" (System/getProperty "guardrails.enabled")))
9999
(throw (ex-info (str "REFUSING TO COMPILE PRODUCTION BUILD WITH GUARDRAILS ENABLED!. If you really want to take "
100100
"that performance hit then set the JVM properter guardrails.enabled to \"production\" on the CLJS compiler's JVM")
101101
{}))))))
102-
result))))
102+
(merge result cljs-compiler-config mode-config)))))
103103

104104
(defn get-base-config-fn
105105
"Base config is defaults + env config."
@@ -122,7 +122,10 @@
122122
(merge a b)
123123
b))
124124
(get-base-config-fn)
125-
(util/get-ns-meta env)
125+
(utils/get-ns-meta env)
126126
meta-maps)
127127
(into {}))]
128128
config))
129+
130+
(defn mode [config]
131+
(get config :mode :runtime))

0 commit comments

Comments
 (0)