This repository has been archived by the owner on Jan 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dev.clj
71 lines (59 loc) · 2.04 KB
/
dev.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
(ns hiposfer.kamal.dev
"Tools for interactive development with the REPL.
WARNING:
This file should NOT be included in a production build of the application
WARNNING:
using (refresh!) will fail if you just ran `lein uberjar`
without cleaning afterwards.
https://stackoverflow.com/questions/44246924/clojure-tools-namespace-refresh-fails-with-no-namespace-foo"
(:require [com.stuartsierra.component :as component]
[hiposfer.kamal.core :as core]
[expound.alpha :as expound]
[clojure.spec.alpha :as s]
[clojure.spec.test.alpha]
[clojure.tools.namespace.repl :as repl]))
(def env
"a fake environment variables setting for development"
{:USE_FAKE_NETWORK false
:JOIN_THREAD false
:PORT 3000
:FRANKFURT_AM_MAIN_AREA_EDN "resources/test/frankfurt-am-main.edn.gz"})
(defonce system nil)
(defn init!
"Constructs the current development system."
[]
(alter-var-root #'system
(constantly (core/system (core/prepare-env env)))))
(defn start!
"Starts the current development system."
[]
(println "Starting System")
(alter-var-root #'system component/start))
(defn stop!
"Shuts down and destroys the current development system."
[]
(println "Stopping System\n")
(alter-var-root #'system (fn [s] (when s (component/stop s)))))
(defn custom-printer
[explain-data]
(let [printer (expound/custom-printer {:show-valid-values? true
:print-specs? false})]
(printer explain-data)))
(defn go!
"Initializes the current development system and starts it running."
[]
(stop!)
(init!)
(clojure.spec.test.alpha/instrument)
(alter-var-root #'s/*explain-out* (constantly custom-printer))
(set! *warn-on-reflection* true)
(set! *print-length* 50)
(start!))
(defn refresh!
"reset the system to a fresh state. Prefer using this over go!"
[]
(stop!)
(repl/refresh :after 'hiposfer.kamal.dev/go!))
;(refresh!)
;(type @(first @(:networks (:router system))))
;(take 10 @(first @(:networks (:router system))))