Compare commits
41 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcdff7577a | ||
|
|
984979b347 | ||
|
|
2f4d1a3581 | ||
|
|
2bca9089b8 | ||
|
|
656af38802 | ||
|
|
bfd7adf98f | ||
|
|
08173bc6a1 | ||
|
|
3fc6c58cd6 | ||
|
|
ccaf99910c | ||
|
|
9c588f68c2 | ||
|
|
f16d7004ee | ||
|
|
3caea10121 | ||
|
|
fb09fef496 | ||
|
|
b89b930ec2 | ||
|
|
4065f5df36 | ||
|
|
632977ff41 | ||
|
|
5275023b38 | ||
|
|
ad6ca6fb5e | ||
|
|
eff4c04f21 | ||
|
|
5df6c941f7 | ||
|
|
098b56d14f | ||
|
|
58e2ded430 | ||
|
|
8a3fc385a2 | ||
|
|
2d050e9055 | ||
|
|
b77f504cfd | ||
|
|
5ac52b725b | ||
|
|
c85da6149c | ||
|
|
6cf5390a44 | ||
|
|
bc3924aedf | ||
|
|
5d992042e4 | ||
|
|
83542e56a7 | ||
|
|
232df7a8a3 | ||
|
|
10dbbaa40b | ||
|
|
5b26fb6092 | ||
|
|
e9f9dfca14 | ||
|
|
348297ee11 | ||
|
|
52831f6b3e | ||
|
|
9666d3f372 | ||
|
|
5564e367e7 | ||
|
|
f65ed6a266 | ||
|
|
6dafae195d |
22 changed files with 281 additions and 37 deletions
1
.clj-kondo/config.edn
Normal file
1
.clj-kondo/config.edn
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{:config-paths ["../resources/clj-kondo.exports/mount/mount/"]}
|
||||||
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -1,7 +1,10 @@
|
||||||
/target
|
/target
|
||||||
/classes
|
/classes
|
||||||
/checkouts
|
/checkouts
|
||||||
pom.xml
|
.cpcache/
|
||||||
|
.rebel_readline_history
|
||||||
|
cljs-test-runner-out
|
||||||
|
node_modules
|
||||||
pom.xml.asc
|
pom.xml.asc
|
||||||
.repl*
|
.repl*
|
||||||
dev/resources/public/js/*
|
dev/resources/public/js/*
|
||||||
|
|
@ -18,3 +21,4 @@ doo-index.html
|
||||||
/.nrepl-history
|
/.nrepl-history
|
||||||
.cljs_rhino_repl/
|
.cljs_rhino_repl/
|
||||||
out/
|
out/
|
||||||
|
.clj-kondo/.cache
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ install:
|
||||||
|
|
||||||
- curl -L https://github.com/boot-clj/boot-bin/releases/download/latest/boot.sh -o ~/bin/boot
|
- curl -L https://github.com/boot-clj/boot-bin/releases/download/latest/boot.sh -o ~/bin/boot
|
||||||
- chmod +x ~/bin/boot
|
- chmod +x ~/bin/boot
|
||||||
|
jdk: openjdk8
|
||||||
env:
|
env:
|
||||||
matrix:
|
matrix:
|
||||||
- BOOT_CLOJURE_VERSION=1.8.0
|
- BOOT_CLOJURE_VERSION=1.8.0
|
||||||
|
|
|
||||||
18
CHANGELOG.md
18
CHANGELOG.md
|
|
@ -1,3 +1,21 @@
|
||||||
|
## 0.1.19
|
||||||
|
###### Wed Aug 21 22:43:40 2024 -0400
|
||||||
|
|
||||||
|
* add `clojure-kondo`
|
||||||
|
|
||||||
|
## 0.1.17
|
||||||
|
###### Mon Dec 19 15:17:21 2022 -0500
|
||||||
|
|
||||||
|
* 2d050e9 fix: swap-states non string rollback (thanks to [egg-juxt](https://github.com/egg-juxt))
|
||||||
|
|
||||||
|
## 0.1.16
|
||||||
|
###### Mon Jan 28 10:34:26 2019 -0500
|
||||||
|
|
||||||
|
* fb52f79 prevent reloading of mount.core ns ([106](https://github.com/tolitius/mount/issues/106))
|
||||||
|
* c5f3e4c current-state should return Derefable on :cljc ([104](https://github.com/tolitius/mount/issues/104))
|
||||||
|
* c2687d1 silent `*logger*` warning in latest ClojureScript([101](https://github.com/tolitius/mount/issues/101))
|
||||||
|
* bb23747 switch form circle to travis
|
||||||
|
|
||||||
## 0.1.14
|
## 0.1.14
|
||||||
###### Thu Oct 25 18:34:22 2018 -0400
|
###### Thu Oct 25 18:34:22 2018 -0400
|
||||||
|
|
||||||
|
|
|
||||||
31
Makefile
Normal file
31
Makefile
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
.PHONY: clean test jar tag outdated install deploy tree repl
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf target
|
||||||
|
rm -rf classes
|
||||||
|
|
||||||
|
jar: clean test tag
|
||||||
|
clojure -A:jar
|
||||||
|
|
||||||
|
test: clean
|
||||||
|
clojure -X:test :patterns '[".*"]' # clojure tests
|
||||||
|
# clojure -Atest-cljs -r ".*test.self.host.*" # clojure script tests
|
||||||
|
# run "j8; boot test-cljs" until running cljs tests via deps.edn is fixed
|
||||||
|
|
||||||
|
outdated:
|
||||||
|
clojure -M:outdated
|
||||||
|
|
||||||
|
tag:
|
||||||
|
clojure -A:tag
|
||||||
|
|
||||||
|
install: jar
|
||||||
|
clojure -A:install
|
||||||
|
|
||||||
|
deploy: jar
|
||||||
|
clojure -A:deploy
|
||||||
|
|
||||||
|
tree:
|
||||||
|
mvn dependency:tree
|
||||||
|
|
||||||
|
repl:
|
||||||
|
clojure -A:dev -A:repl
|
||||||
14
README.md
14
README.md
|
|
@ -1,9 +1,8 @@
|
||||||
> I think that it's _extraordinarily important_ that we in computer science keep fun in computing
|
> I think that it's _extraordinarily important_ that we in computer science keep fun in computing
|
||||||
|
|
||||||
_**Alan J. Perlis** from [Structure and Interpretation of Computer Programs](https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-3.html)_
|
_**Alan J. Perlis** from [Structure and Interpretation of Computer Programs](https://web.mit.edu/6.001/6.037/sicp.pdf)_
|
||||||
|
|
||||||
# mount <img src="doc/img/mount-logo.png" width="70px">
|
# mount <img src="doc/img/mount-logo.png" width="70px">
|
||||||
[](https://travis-ci.org/tolitius/mount)
|
|
||||||
[](https://github.com/tolitius/mount/releases)
|
[](https://github.com/tolitius/mount/releases)
|
||||||
[](https://clojars.org/mount)
|
[](https://clojars.org/mount)
|
||||||
|
|
||||||
|
|
@ -91,7 +90,7 @@ Creating state is easy:
|
||||||
(defstate conn :start (create-conn))
|
(defstate conn :start (create-conn))
|
||||||
```
|
```
|
||||||
|
|
||||||
where the `create-conn` function is defined elsewhere, can be right above it.
|
where the `create-conn` function creates a connection (for example to a database) and is defined elsewhere, can be right above it.
|
||||||
|
|
||||||
In case this state needs to be cleaned / destroyed between reloads, there is also `:stop`
|
In case this state needs to be cleaned / destroyed between reloads, there is also `:stop`
|
||||||
|
|
||||||
|
|
@ -104,7 +103,7 @@ That is pretty much it. But wait, there is more.. this state is _a top level bei
|
||||||
`required` by other namespaces or in REPL:
|
`required` by other namespaces or in REPL:
|
||||||
|
|
||||||
```clojure
|
```clojure
|
||||||
dev=> (require '[app.nyse :refer [conn]])
|
dev=> (require '[app.db :refer [conn]])
|
||||||
nil
|
nil
|
||||||
dev=> conn
|
dev=> conn
|
||||||
#object[datomic.peer.LocalConnection 0x1661a4eb "datomic.peer.LocalConnection@1661a4eb"]
|
#object[datomic.peer.LocalConnection 0x1661a4eb "datomic.peer.LocalConnection@1661a4eb"]
|
||||||
|
|
@ -173,8 +172,9 @@ this `config`, being top level, can be used in other namespaces, including the o
|
||||||
(defstate conn :start (create-connection config))
|
(defstate conn :start (create-connection config))
|
||||||
```
|
```
|
||||||
|
|
||||||
[here](dev/clj/app/www.clj#L32)
|
[here](dev/clj/app/www.clj#L32) is an example of a web server that "depends" on a similar `config`.
|
||||||
is an example of a web server that "depends" on a similar `config`.
|
|
||||||
|
###### _(the example `load-config` function above comes from [cprop](https://github.com/tolitius/cprop), but could of course be a custom function that loads configuration from a file)_
|
||||||
|
|
||||||
## Value of values
|
## Value of values
|
||||||
|
|
||||||
|
|
@ -861,7 +861,7 @@ The documentation is [here](doc/runtime-arguments.md#passing-runtime-arguments).
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright © 2017 tolitius
|
Copyright © 2020 tolitius
|
||||||
|
|
||||||
Distributed under the Eclipse Public License either version 1.0 or (at
|
Distributed under the Eclipse Public License either version 1.0 or (at
|
||||||
your option) any later version.
|
your option) any later version.
|
||||||
|
|
|
||||||
2
boot.properties
Normal file
2
boot.properties
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
BOOT_VERSION=2.7.1
|
||||||
|
BOOT_CLOJURE_VERSION=1.10.1
|
||||||
25
build.boot
25
build.boot
|
|
@ -1,8 +1,18 @@
|
||||||
(def +version+ "0.1.16-SNAPSHOT")
|
(def +version+ "0.1.18")
|
||||||
|
|
||||||
|
;; -- since boot is no more, this file will go away
|
||||||
|
;; -- once deps.edn "learns" how to run all cljs tests
|
||||||
|
|
||||||
|
;; j8; boot test
|
||||||
|
;; j8; boot test-cljs
|
||||||
|
;; j8; boot test-cljs-advanced
|
||||||
|
;; j8; boot -v build-jar push-snapshot
|
||||||
|
;; j8; boot -v build-jar push-release
|
||||||
|
|
||||||
(set-env!
|
(set-env!
|
||||||
:source-paths #{"src"}
|
:source-paths #{"src"}
|
||||||
:dependencies '[;; mount brings _no dependencies_, everything here is for
|
:resource-paths #{"resources"}
|
||||||
|
:dependencies '[;; mount brings _NO DEPENDENCIES_, everything here is for
|
||||||
;; mount dev, examples apps and tests
|
;; mount dev, examples apps and tests
|
||||||
|
|
||||||
[org.clojure/clojure "1.8.0" :scope "provided"]
|
[org.clojure/clojure "1.8.0" :scope "provided"]
|
||||||
|
|
@ -13,6 +23,7 @@
|
||||||
[cheshire "5.5.0" :scope "provided"]
|
[cheshire "5.5.0" :scope "provided"]
|
||||||
[hiccups "0.3.0" :scope "provided" :exclusions [org.clojure/clojurescript]]
|
[hiccups "0.3.0" :scope "provided" :exclusions [org.clojure/clojurescript]]
|
||||||
[com.andrewmcveigh/cljs-time "0.3.14" :scope "provided"]
|
[com.andrewmcveigh/cljs-time "0.3.14" :scope "provided"]
|
||||||
|
[tolitius/yang "0.1.9" :scope "provided"]
|
||||||
[ch.qos.logback/logback-classic "1.1.3" :scope "provided"]
|
[ch.qos.logback/logback-classic "1.1.3" :scope "provided"]
|
||||||
[org.clojure/tools.logging "0.3.1" :scope "provided"]
|
[org.clojure/tools.logging "0.3.1" :scope "provided"]
|
||||||
[robert/hooke "1.3.0" :scope "provided"]
|
[robert/hooke "1.3.0" :scope "provided"]
|
||||||
|
|
@ -33,11 +44,12 @@
|
||||||
|
|
||||||
;; boot cljs
|
;; boot cljs
|
||||||
[adzerk/boot-cljs "1.7.228-1" :scope "test"]
|
[adzerk/boot-cljs "1.7.228-1" :scope "test"]
|
||||||
[adzerk/boot-cljs-repl "0.3.0" :scope "test"]
|
[adzerk/boot-cljs-repl "0.4.0" :scope "test"]
|
||||||
|
[cider/piggieback "0.3.9" :scope "test" :exclusions [org.clojure/clojurescript]]
|
||||||
|
[weasel "0.7.0" :scope "test" :exclusions [org.clojure/clojurescript]]
|
||||||
|
[nrepl "0.4.5" :scope "test"]
|
||||||
[pandeiro/boot-http "0.7.1-SNAPSHOT" :scope "test"]
|
[pandeiro/boot-http "0.7.1-SNAPSHOT" :scope "test"]
|
||||||
[tolitius/boot-stripper "0.1.0-SNAPSHOT" :scope "test"]
|
[tolitius/boot-stripper "0.1.0-SNAPSHOT" :scope "test"]
|
||||||
[com.cemerick/piggieback "0.2.1" :scope "test" :exclusions [org.clojure/clojurescript]]
|
|
||||||
[weasel "0.7.0" :scope "test" :exclusions [org.clojure/clojurescript]]
|
|
||||||
[adzerk/boot-reload "0.4.8" :scope "test"]
|
[adzerk/boot-reload "0.4.8" :scope "test"]
|
||||||
[crisptrutski/boot-cljs-test "0.2.1-SNAPSHOT" :scope "test"]])
|
[crisptrutski/boot-cljs-test "0.2.1-SNAPSHOT" :scope "test"]])
|
||||||
|
|
||||||
|
|
@ -132,7 +144,8 @@
|
||||||
|
|
||||||
(task-options!
|
(task-options!
|
||||||
tcs/test-cljs {:js-env :phantom}
|
tcs/test-cljs {:js-env :phantom}
|
||||||
push {:ensure-branch nil}
|
push {; :ensure-clean nil
|
||||||
|
:ensure-branch nil}
|
||||||
pom {:project 'mount
|
pom {:project 'mount
|
||||||
:version +version+
|
:version +version+
|
||||||
:description "managing Clojure and ClojureScript app state since (reset)"
|
:description "managing Clojure and ClojureScript app state since (reset)"
|
||||||
|
|
|
||||||
52
deps.edn
Normal file
52
deps.edn
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
{:paths ["src" "resources"]
|
||||||
|
|
||||||
|
:deps {} ;; deps no deps
|
||||||
|
|
||||||
|
:aliases {:dev {:extra-deps {metosin/jsonista {:mvn/version "0.3.8"}
|
||||||
|
com.datomic/datomic-free {:mvn/version "0.9.5359"
|
||||||
|
:exclusions [joda-time/joda-time]}
|
||||||
|
org.clojure/tools.nrepl {:mvn/version "0.2.12"}
|
||||||
|
org.clojure/tools.namespace {:mvn/version "0.2.11"}
|
||||||
|
cheshire/cheshire {:mvn/version "5.5.0"}
|
||||||
|
compojure/compojure {:mvn/version "1.5.0"}
|
||||||
|
ring/ring-jetty-adapter {:mvn/version "1.1.0"}
|
||||||
|
robert/hooke {:mvn/version "1.3.0"}
|
||||||
|
proto-repl/proto-repl {:mvn/version "0.3.1"}
|
||||||
|
proto-repl-charts/proto-repl-charts {:mvn/version "0.3.2"}
|
||||||
|
nrepl/nrepl {:mvn/version "0.7.0"}}}
|
||||||
|
:test {:extra-paths ["test/core" "test/clj" "test/cljs" "test/resources"]
|
||||||
|
:extra-deps {com.datomic/datomic-free {:mvn/version "0.9.5359"
|
||||||
|
:exclusions [joda-time/joda-time]}
|
||||||
|
org.clojure/tools.nrepl {:mvn/version "0.2.12"}
|
||||||
|
robert/hooke {:mvn/version "1.3.0"}
|
||||||
|
org.clojure/tools.logging {:mvn/version "1.3.0"}
|
||||||
|
io.github.cognitect-labs/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git"
|
||||||
|
:sha "e7660458ce25bc4acb4ccc3e2415aae0a4907198"}}
|
||||||
|
:main-opts ["-m" "cognitect.test-runner"]
|
||||||
|
:exec-fn cognitect.test-runner.api/test}
|
||||||
|
:test-cljs {:extra-paths ["test/core" "test/cljs" "test/resources"]
|
||||||
|
:extra-deps {org.clojure/clojure {:mvn/version "1.8.0"}
|
||||||
|
org.clojure/clojurescript {:mvn/version "1.7.228"}
|
||||||
|
com.andrewmcveigh/cljs-time {:mvn/version "0.3.14"}
|
||||||
|
hiccups/hiccups {:mvn/version "0.3.0"}
|
||||||
|
datascript/datascript {:mvn/version "0.15.0"}
|
||||||
|
olical/cljs-test-runner {:mvn/version "3.8.1"}}
|
||||||
|
:main-opts ["-m" "cljs-test-runner.main"]}
|
||||||
|
:repl {:extra-paths ["dev/clj"]
|
||||||
|
:extra-deps {cider/cider-nrepl {:mvn/version "0.22.4"}
|
||||||
|
org.clojure/tools.logging {:mvn/version "1.2.4"}
|
||||||
|
com.bhauman/rebel-readline {:mvn/version "0.1.4"}}
|
||||||
|
:main-opts ["-e" "(require 'dev)(in-ns 'dev)"
|
||||||
|
"-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"
|
||||||
|
"-i" "-f" "rebel-readline.main/-main"]}
|
||||||
|
:outdated {:extra-deps {olical/depot {:mvn/version "2.0.1"}}
|
||||||
|
:main-opts ["-m" "depot.outdated.main" "-a" "outdated"]}
|
||||||
|
:tag {:extra-deps {tolitius/tag {:mvn/version "0.1.7"}}
|
||||||
|
:main-opts ["-m" "tag.core" "tolitius/mount" "managing Clojure and ClojureScript app state since (reset)"]}
|
||||||
|
:jar {:extra-deps {seancorfield/depstar {:mvn/version "1.1.128"}}
|
||||||
|
:extra-paths ["target/about"]
|
||||||
|
:main-opts ["-m" "hf.depstar.jar" "target/mount.jar" "--exclude" "clojure/core/specs/alpha.*"]}
|
||||||
|
:deploy {:extra-deps {deps-deploy/deps-deploy {:mvn/version "RELEASE"}}
|
||||||
|
:main-opts ["-m" "deps-deploy.deps-deploy" "deploy" "target/mount.jar"]}
|
||||||
|
:install {:extra-deps {deps-deploy/deps-deploy {:mvn/version "RELEASE"}}
|
||||||
|
:main-opts ["-m" "deps-deploy.deps-deploy" "install" "target/mount.jar"]}}}
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
(ns dev
|
(ns dev
|
||||||
(:require [clojure.pprint :refer [pprint]]
|
(:require [clojure.pprint :refer [pprint]]
|
||||||
[clojure.tools.namespace.repl :as tn]
|
[clojure.tools.namespace.repl :as tn]
|
||||||
[boot.core :refer [load-data-readers!]]
|
|
||||||
[mount.core :as mount :refer [defstate]]
|
[mount.core :as mount :refer [defstate]]
|
||||||
[mount.tools.graph :refer [states-with-deps]]
|
[mount.tools.graph :refer [states-with-deps]]
|
||||||
[app.utils.logging :refer [with-logging-status]]
|
[app.utils.logging :refer [with-logging-status]]
|
||||||
|
|
@ -41,4 +40,11 @@
|
||||||
(tn/refresh :after 'dev/go))
|
(tn/refresh :after 'dev/go))
|
||||||
|
|
||||||
(mount/in-clj-mode)
|
(mount/in-clj-mode)
|
||||||
|
|
||||||
|
(defn load-data-readers!
|
||||||
|
"Refresh *data-readers* with readers from newly acquired dependencies."
|
||||||
|
[]
|
||||||
|
(#'clojure.core/load-data-readers)
|
||||||
|
(set! *data-readers* (.getRawRoot #'*data-readers*)))
|
||||||
|
|
||||||
(load-data-readers!)
|
(load-data-readers!)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
(ns proto-play
|
(ns proto-play
|
||||||
(:require [mount.tools.graph :as mount]
|
(:require [mount.tools.graph :as mg]
|
||||||
[proto-repl-charts.graph :as proto]))
|
[proto-repl-charts.graph :as proto]))
|
||||||
|
|
||||||
(defn mount->proto [graph]
|
(defn mount->proto [graph]
|
||||||
|
|
@ -10,6 +10,6 @@
|
||||||
{}
|
{}
|
||||||
graph))
|
graph))
|
||||||
|
|
||||||
(->> (mount/states-with-deps)
|
(->> (mg/states-with-deps)
|
||||||
mount->proto
|
mount->proto
|
||||||
(proto/graph "a proto graph of mount states"))
|
(proto/graph "a proto graph of mount states"))
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ the same with or without Mount: there are no extra mental steps.
|
||||||
### Objects vs. Namespaces
|
### Objects vs. Namespaces
|
||||||
|
|
||||||
One thing that feels a bit "unClojure" about Component is "Objects". Objects everywhere, and Objects for everything.
|
One thing that feels a bit "unClojure" about Component is "Objects". Objects everywhere, and Objects for everything.
|
||||||
This is how Component "separates explicit dependencies" and "clears the bounaries".
|
This is how Component "separates explicit dependencies" and "clears the boundaries".
|
||||||
|
|
||||||
This is also how an Object Oriented language does it, which does not leave a lot of room for functions:
|
This is also how an Object Oriented language does it, which does not leave a lot of room for functions:
|
||||||
with Component most of the functions are _methods_ which is an important distinction.
|
with Component most of the functions are _methods_ which is an important distinction.
|
||||||
|
|
@ -146,9 +146,13 @@ no "ceremony".
|
||||||
|
|
||||||
Mount uses namespaces and vars where Component uses records and protocols.
|
Mount uses namespaces and vars where Component uses records and protocols.
|
||||||
|
|
||||||
Component manages protocols and records, and in order to do that it requires a whole app buyin, which makes it a _framework_.
|
Component manages records and protocols,
|
||||||
|
and in order to do that it requires a whole app buy-in,
|
||||||
|
which makes it a _framework_.
|
||||||
|
|
||||||
Mount does not need to manage namespaces and vars, since it is very well managed by the Clojure Compiler, which makes it a _library_.
|
Mount does not need to manage namespaces and vars,
|
||||||
|
since it is very well managed by the Clojure Compiler,
|
||||||
|
which makes it a _library_.
|
||||||
|
|
||||||
## What Component does better
|
## What Component does better
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@tolitius/mount",
|
"name": "@tolitius/mount",
|
||||||
"version": "0.1.15",
|
"version": "0.1.16",
|
||||||
"license": "EPL-1.0",
|
"license": "EPL-1.0",
|
||||||
"homepage": "https://github.com/tolitius/mount",
|
"homepage": "https://github.com/tolitius/mount",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
@ -10,12 +10,14 @@
|
||||||
"author": {
|
"author": {
|
||||||
"name": "tolitius",
|
"name": "tolitius",
|
||||||
"url": "http://www.dotkam.com"
|
"url": "http://www.dotkam.com"
|
||||||
}
|
},
|
||||||
,
|
|
||||||
"files": [
|
"files": [
|
||||||
"src/*"
|
"src/*"
|
||||||
],
|
],
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "src"
|
"lib": "src"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"ws": "^8.16.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
45
pom.xml
Normal file
45
pom.xml
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<groupId>mount</groupId>
|
||||||
|
<artifactId>mount</artifactId>
|
||||||
|
<version>0.1.23</version>
|
||||||
|
<name>mount</name>
|
||||||
|
<description>managing Clojure and ClojureScript app state since (reset)</description>
|
||||||
|
<url>https://github.com/tolitius/mount</url>
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>Eclipse Public License</name>
|
||||||
|
<url>http://www.eclipse.org/legal/epl-v10.html</url>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<name>tolitius</name>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
<scm>
|
||||||
|
<url>https://github.com/tolitius/mount</url>
|
||||||
|
<connection>scm:git:git://github.com/tolitius/mount.git</connection>
|
||||||
|
<developerConnection>scm:git:ssh://git@github.com/tolitius/mount.git</developerConnection>
|
||||||
|
<tag>HEAD</tag>
|
||||||
|
</scm>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.clojure</groupId>
|
||||||
|
<artifactId>clojure</artifactId>
|
||||||
|
<version>1.11.2</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src</sourceDirectory>
|
||||||
|
</build>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>clojars</id>
|
||||||
|
<url>https://repo.clojars.org/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
</project>
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
(defproject mount "0.1.16-SNAPSHOT"
|
(defproject mount "0.1.17"
|
||||||
:description "managing Clojure and ClojureScript app state since (reset)"
|
:description "managing Clojure and ClojureScript app state since (reset)"
|
||||||
:url "https://github.com/tolitius/mount"
|
:url "https://github.com/tolitius/mount"
|
||||||
:license {:name "Eclipse Public License"
|
:license {:name "Eclipse Public License"
|
||||||
|
|
|
||||||
3
resources/clj-kondo.exports/mount/mount/config.edn
Normal file
3
resources/clj-kondo.exports/mount/mount/config.edn
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{:linters {:mount/defstate {:level :warning}}
|
||||||
|
:hooks {:analyze-call {mount.core/defstate hooks.defstate/defstate
|
||||||
|
mount.core/defstate! hooks.defstate/defstate}}}
|
||||||
39
resources/clj-kondo.exports/mount/mount/hooks/defstate.clj
Normal file
39
resources/clj-kondo.exports/mount/mount/hooks/defstate.clj
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
(ns hooks.defstate
|
||||||
|
(:require [clj-kondo.hooks-api :as api]))
|
||||||
|
|
||||||
|
(defn defstate [{:keys [node]}]
|
||||||
|
(let [[n & args] (next (:children node))
|
||||||
|
[docs args] (if (string? (api/sexpr (first args)))
|
||||||
|
[(first args) (next args)]
|
||||||
|
[nil args])
|
||||||
|
m (when-let [m (first (:meta n))]
|
||||||
|
(api/sexpr m))
|
||||||
|
m (if (map? m) m {})
|
||||||
|
ks (cond-> (take 1 args)
|
||||||
|
(> (count args) 2) (conj (nth args 2)))
|
||||||
|
invalid-key (first (remove (comp (partial contains? #{:start :stop}) api/sexpr) ks))]
|
||||||
|
(cond
|
||||||
|
invalid-key
|
||||||
|
(api/reg-finding!
|
||||||
|
{:message (str "lifecycle functions can only contain `:start` and `:stop`. illegal function found: " (api/sexpr invalid-key))
|
||||||
|
:type :mount/defstate
|
||||||
|
:row (:row (meta invalid-key))
|
||||||
|
:col (:col (meta invalid-key))})
|
||||||
|
(not (contains? (set (map api/sexpr ks)) :start))
|
||||||
|
(throw (ex-info "lifecycle functions must include `:start`" {}))
|
||||||
|
((complement contains?) #{2 4} (count args))
|
||||||
|
(throw (ex-info "lifecycle functions must consist of no more than 2 pair forms: `:start` and `:stop`" {}))
|
||||||
|
(and (contains? m :on-reload) (not (contains? #{:noop :stop} (:on-reload m))))
|
||||||
|
(api/reg-finding!
|
||||||
|
{:message "metadata `:on-reload` key can only have value of `noop` or `stop`"
|
||||||
|
:type :mount/defstate
|
||||||
|
:row (:row (meta n))
|
||||||
|
:col (:col (meta n))})
|
||||||
|
:else
|
||||||
|
{:node (api/list-node
|
||||||
|
(cond-> [(api/token-node 'def) n]
|
||||||
|
docs (conj docs)
|
||||||
|
true (conj (api/list-node
|
||||||
|
(list*
|
||||||
|
(api/token-node 'do)
|
||||||
|
args)))))})))
|
||||||
|
|
@ -284,7 +284,7 @@
|
||||||
(if-not (empty? fs) ;; (mount/start) vs. (mount/start #{}) vs. (mount/start #{1 2 3})
|
(if-not (empty? fs) ;; (mount/start) vs. (mount/start #{}) vs. (mount/start #{1 2 3})
|
||||||
(apply start fs)
|
(apply start fs)
|
||||||
{:started #{}})
|
{:started #{}})
|
||||||
(let [states (or (seq states)
|
(let [states (or (->> states (map var-to-str) seq)
|
||||||
(all-without-subs))]
|
(all-without-subs))]
|
||||||
{:started (bring states up <)}))))
|
{:started (bring states up <)}))))
|
||||||
|
|
||||||
|
|
@ -294,7 +294,7 @@
|
||||||
(if-not (empty? fs) ;; (mount/stop) vs. (mount/stop #{}) vs. (mount/stop #{1 2 3})
|
(if-not (empty? fs) ;; (mount/stop) vs. (mount/stop #{}) vs. (mount/stop #{1 2 3})
|
||||||
(apply stop fs)
|
(apply stop fs)
|
||||||
{:stopped #{}})
|
{:stopped #{}})
|
||||||
(let [states (or (seq states)
|
(let [states (or (->> states (map var-to-str) seq)
|
||||||
(find-all-states))
|
(find-all-states))
|
||||||
_ (dorun (map unsub states)) ;; unmark substitutions marked by "start-with" / "swap-states"
|
_ (dorun (map unsub states)) ;; unmark substitutions marked by "start-with" / "swap-states"
|
||||||
stopped (bring states down >)]
|
stopped (bring states down >)]
|
||||||
|
|
@ -308,8 +308,8 @@
|
||||||
set))
|
set))
|
||||||
|
|
||||||
(defn only
|
(defn only
|
||||||
([states]
|
([these]
|
||||||
(only (find-all-states) states))
|
(only (find-all-states) these))
|
||||||
([states these]
|
([states these]
|
||||||
(intersection (mapset var-to-str these)
|
(intersection (mapset var-to-str these)
|
||||||
(mapset var-to-str states))))
|
(mapset var-to-str states))))
|
||||||
|
|
@ -322,8 +322,8 @@
|
||||||
states))
|
states))
|
||||||
|
|
||||||
(defn except
|
(defn except
|
||||||
([states]
|
([these]
|
||||||
(except (find-all-states) states))
|
(except (find-all-states) these))
|
||||||
([states these]
|
([states these]
|
||||||
(remove (mapset var-to-str these)
|
(remove (mapset var-to-str these)
|
||||||
(mapset var-to-str states))))
|
(mapset var-to-str states))))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
(defonce ^:dynamic *logger*
|
(defonce ^:dynamic *logger*
|
||||||
(do
|
(do
|
||||||
(.setCapturing (Console.) true)
|
(.setCapturing (Console.) true)
|
||||||
(glog/getLogger "mount"))))
|
(glog/getLogger "mount" nil))))
|
||||||
|
|
||||||
#?(:clj
|
#?(:clj
|
||||||
(defn log [msg & _]
|
(defn log [msg & _]
|
||||||
|
|
@ -15,6 +15,6 @@
|
||||||
#?(:cljs
|
#?(:cljs
|
||||||
(defn log [msg & level]
|
(defn log [msg & level]
|
||||||
(case (first level)
|
(case (first level)
|
||||||
:error (glog/error *logger* msg)
|
:error (glog/error *logger* msg nil)
|
||||||
(glog/info *logger* msg))))
|
(glog/info *logger* msg nil))))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,9 @@
|
||||||
(defn entity [conn id]
|
(defn entity [conn id]
|
||||||
(d/entity (d/db conn) id))
|
(d/entity (d/db conn) id))
|
||||||
|
|
||||||
(defn touch [conn results]
|
(defn touch
|
||||||
"takes 'entity ids' results from a query
|
"takes 'entity ids' results from a query
|
||||||
e.g. '#{[272678883689461] [272678883689462] [272678883689459] [272678883689457]}'"
|
e.g. '#{[272678883689461] [272678883689462] [272678883689459] [272678883689457]}'"
|
||||||
|
[conn results]
|
||||||
(let [e (partial entity conn)]
|
(let [e (partial entity conn)]
|
||||||
(map #(-> % first e d/touch) results)))
|
(map #(-> % first e d/touch) results)))
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,16 @@
|
||||||
(is (= 42 (dval conn)))
|
(is (= 42 (dval conn)))
|
||||||
(mount/stop)))
|
(mount/stop)))
|
||||||
|
|
||||||
|
(testing "swap-states should swap states on start and rollback on stop"
|
||||||
|
(let [states (swap-states {#'tapp.nyse/conn swap-conn})]
|
||||||
|
(is (= states (#'mount.core/find-all-states)))
|
||||||
|
(mount/start #'tapp.nyse/conn)
|
||||||
|
(is (= 42 (dval conn)))
|
||||||
|
(mount/stop #'tapp.nyse/conn)
|
||||||
|
(mount/start #'tapp.nyse/conn)
|
||||||
|
(is (instance? datomic.peer.LocalConnection (dval conn)))
|
||||||
|
(mount/stop)))
|
||||||
|
|
||||||
(testing "swap-states should swap states with states and return only states that it is given"
|
(testing "swap-states should swap states with states and return only states that it is given"
|
||||||
(let [t-states #{"#'is.not/here" #'mount.test.composable-fns/test-conn #'tapp.nyse/conn}
|
(let [t-states #{"#'is.not/here" #'mount.test.composable-fns/test-conn #'tapp.nyse/conn}
|
||||||
states (swap-states t-states {#'tapp.nyse/conn swap-conn
|
states (swap-states t-states {#'tapp.nyse/conn swap-conn
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,24 @@
|
||||||
mount.test.fun-with-values
|
mount.test.fun-with-values
|
||||||
mount.test.private-fun
|
mount.test.private-fun
|
||||||
mount.test.printing
|
mount.test.printing
|
||||||
|
mount.test.parts
|
||||||
|
mount.test.cleanup-dirty-states
|
||||||
|
mount.test.stop-except
|
||||||
|
mount.test.start-without
|
||||||
|
mount.test.start-with
|
||||||
|
mount.test.start-with-states
|
||||||
))
|
))
|
||||||
|
|
||||||
(t/run-tests
|
(t/run-tests
|
||||||
'mount.test.fun-with-values
|
'mount.test.fun-with-values
|
||||||
'mount.test.private-fun
|
'mount.test.private-fun
|
||||||
'mount.test.printing
|
'mount.test.printing
|
||||||
|
'mount.test.parts
|
||||||
|
'mount.test.cleanup-dirty-states
|
||||||
|
;; 'mount.test.stop-except ;; TODO: can't run with deps.edn (due to "WebSocket is not defined")
|
||||||
|
;; 'mount.test.start-with ;; boot, lein have no problems
|
||||||
|
;; 'mount.test.start-with-states ;; most likely somm misconfigured in node..
|
||||||
|
'mount.test.start-without
|
||||||
)
|
)
|
||||||
|
|
||||||
(defn run-tests []
|
(defn run-tests []
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue