From 15cd11343bea722276dd2e233d98bf040e6b5a2b Mon Sep 17 00:00:00 2001 From: Mark Sto Date: Tue, 5 Dec 2023 03:10:13 +0400 Subject: [PATCH 01/12] Migrate to latest (Dev) Local and Client Cloud versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The following things have changed: - Dev Local name — from `dev-local` to just `local` - `local` is released under Apache 2.0, thus available through Maven - `:server-type` value — from `:dev-local` to `:datomic-local` https://docs.datomic.com/cloud/datomic-local.html?search=1.0.126#267 --- deps.edn | 15 +++++++++------ pom.xml | 2 +- src/dev_local_tu/core.clj | 8 ++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/deps.edn b/deps.edn index 658b384..00bd827 100644 --- a/deps.edn +++ b/deps.edn @@ -1,6 +1,9 @@ -{:deps {} - :aliases {:dev {:extra-paths ["examples"] - :extra-deps {com.datomic/client-cloud {:mvn/version "0.8.102"} - com.datomic/dev-local {:local/root "dev-local-0.9.225.jar"}}} - :jar {:extra-deps {seancorfield/depstar {:mvn/version "1.1.132"}} - :main-opts ["-m" "hf.depstar.jar" "lib.jar"]}}} \ No newline at end of file +{:deps {} + + :mvn/repos {"datomic-cloud" {:url "s3://datomic-releases-1fc2183a/maven/releases"}} + + :aliases {:dev {:extra-paths ["examples"] + :extra-deps {com.datomic/client-cloud {:mvn/version "1.0.123"} + com.datomic/local {:mvn/version "1.0.267"}}} + :jar {:extra-deps {seancorfield/depstar {:mvn/version "1.1.132"}} + :main-opts ["-m" "hf.depstar.jar" "lib.jar"]}}} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3b2c5e2..63d74ae 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.clojure clojure - 1.10.1 + 1.11.1 diff --git a/src/dev_local_tu/core.clj b/src/dev_local_tu/core.clj index 6ed9fa6..55e19cc 100644 --- a/src/dev_local_tu/core.clj +++ b/src/dev_local_tu/core.clj @@ -2,7 +2,7 @@ (:require [clojure.string :as str] [datomic.client.api :as d] - [datomic.dev-local] + [datomic.local] [clojure.java.io :as io] [dev-local-tu.internal.impl :as impl]) (:import (java.io Closeable File))) @@ -36,7 +36,7 @@ (cond-> {} storage-dir (assoc ::storage-dir storage-dir))))) - client-map {:server-type :dev-local + client-map {:server-type :datomic-local :system system :storage-dir storage-dir}] {:client (d/client client-map) @@ -65,8 +65,8 @@ "Releases all DBs." [client system] (doseq [db-name (d/list-databases client {})] - ;; https://docs.datomic.com/cloud/dev-local.html#release-db - (datomic.dev-local/release-db + ;; https://docs.datomic.com/cloud/datomic-local.html#release-db + (datomic.local/release-db {:system system :db-name db-name}))) (defn cleanup-env! From cf6a888c086c3d12361457604ad26cc4e12d38b3 Mon Sep 17 00:00:00 2001 From: Mark Sto Date: Tue, 5 Dec 2023 03:10:35 +0400 Subject: [PATCH 02/12] Simplify `delete-dev-local-system!` fn impl --- src/dev_local_tu/core.clj | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/dev_local_tu/core.clj b/src/dev_local_tu/core.clj index 55e19cc..827219c 100644 --- a/src/dev_local_tu/core.clj +++ b/src/dev_local_tu/core.clj @@ -51,11 +51,9 @@ ([system-name storage-dir] (let [f (dev-local-directory {:system-name system-name :storage-dir storage-dir})] - (if (.exists ^File f) - (do - (impl/delete-directory! f) - true) - true)))) + (when (.exists ^File f) + (impl/delete-directory! f)) + true))) (comment (-new-env-map {}) From 8bafb6f97c4a56d306e6cae4a66be8667bf55d54 Mon Sep 17 00:00:00 2001 From: Mark Sto Date: Tue, 5 Dec 2023 03:10:55 +0400 Subject: [PATCH 03/12] v0.3.0 --- README.md | 4 ++-- pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9aca338..517b38a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Test utility for Datomic dev-local. ```clojure -dev-local-tu {:mvn/version "0.2.2"} +dev-local-tu {:mvn/version "0.3.0"} ``` ## Rationale @@ -52,4 +52,4 @@ See `examples/example_fixture.clj` for the complete example. (f)))) (use-fixtures :each client-fixture) -``` \ No newline at end of file +``` diff --git a/pom.xml b/pom.xml index 63d74ae..3e5b0e4 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 dev-local-tu dev-local-tu - 0.2.2 + 0.3.0 dev-local-tu From 42b2c6dd8343815d4a169f5314e27f7ea4de68bb Mon Sep 17 00:00:00 2001 From: Mark Sto Date: Tue, 5 Dec 2023 04:08:10 +0400 Subject: [PATCH 04/12] Fix a compiler reflection warning Reflection warning, dev_local_tu/core.clj:34:23 - reference to field getAbsolutePath can't be resolved. --- src/dev_local_tu/core.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dev_local_tu/core.clj b/src/dev_local_tu/core.clj index 827219c..d5e78fd 100644 --- a/src/dev_local_tu/core.clj +++ b/src/dev_local_tu/core.clj @@ -15,8 +15,8 @@ (.getAbsolutePath (io/file (System/getProperty "user.home") ".datomic" "data"))) (defn dev-local-directory - [{:keys [system-name db-name storage-dir] - :or {storage-dir default-datomic-dev-local-storage-dir}}] + ^File [{:keys [system-name db-name storage-dir] + :or {storage-dir default-datomic-dev-local-storage-dir}}] (let [file-args (cond-> [storage-dir] system-name (conj system-name) db-name (conj db-name))] From d088cf968aae7c2c5f3ca1f8633a76df65bfa246 Mon Sep 17 00:00:00 2001 From: Mark Sto Date: Sun, 15 Sep 2024 18:52:18 +0400 Subject: [PATCH 05/12] Set returned value type hints + update the docs link --- src/dev_local_tu/core.clj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dev_local_tu/core.clj b/src/dev_local_tu/core.clj index d5e78fd..0bf7588 100644 --- a/src/dev_local_tu/core.clj +++ b/src/dev_local_tu/core.clj @@ -63,7 +63,7 @@ "Releases all DBs." [client system] (doseq [db-name (d/list-databases client {})] - ;; https://docs.datomic.com/cloud/datomic-local.html#release-db + ;; See "https://docs.datomic.com/api/datomic-local.html#release-db" (datomic.local/release-db {:system system :db-name db-name}))) @@ -95,8 +95,8 @@ When closed, the test environment will release the resources used by the client and delete the data directory." - ([] (test-env {})) - ([env-argm] + (^TestEnv [] (test-env {})) + (^TestEnv [env-argm] (let [env (-new-env-map env-argm)] (map->TestEnv env)))) @@ -109,4 +109,4 @@ (d/transact conn {:tx-data [{:db/ident ::foo :db/valueType :db.type/string :db/cardinality :db.cardinality/one}]}) - ) \ No newline at end of file + ) From f95574dd4855f3bd39470544a42960c82d8618bb Mon Sep 17 00:00:00 2001 From: Mark Sto Date: Sun, 15 Sep 2024 18:55:43 +0400 Subject: [PATCH 06/12] Upgrade to the latest Clojure version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3e5b0e4..286719f 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.clojure clojure - 1.11.1 + 1.12.0 From b7a4aa254860df958c1ce0a3f9bce47fe03c0a4b Mon Sep 17 00:00:00 2001 From: Mark Sto Date: Sat, 15 Feb 2025 12:08:21 +0400 Subject: [PATCH 07/12] BREAKING: Rename all the remaining `dev-local` occurrences --- README.md | 32 +++++++++------- examples/example1.clj | 6 +-- examples/example_fixture.clj | 6 +-- .../core.clj | 37 ++++++++++--------- .../internal/impl.clj | 4 +- 5 files changed, 46 insertions(+), 39 deletions(-) rename src/{dev_local_tu => datomic_local_tu}/core.clj (76%) rename src/{dev_local_tu => datomic_local_tu}/internal/impl.clj (89%) diff --git a/README.md b/README.md index 517b38a..d165793 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,30 @@ -# dev-local-tu +# datomic-local-tu -Test utility for Datomic dev-local. +Test utility for Datomic Local. ```clojure dev-local-tu {:mvn/version "0.3.0"} ``` -## Rationale +## Rationale -Datomic dev-local provides a way to create clean environments useful for testing. -It does not provide a methodology for how to use it. -This library provides an opinionated way to use dev-local in your tests. +Datomic Local provides a way to create clean environments useful for testing. +It does not provide a methodology for how to use it. +This library provides an opinionated way to use `:datomic-local` in your tests. ## Usage -The primary function exposed by the api is `test-env`. +The primary function exposed by the api is `test-env`. This function returns a test environment. -A test environment will contain a Datomic client, created by dev local, that can be cleaned up by simply calling `.close`. +A test environment will contain a Datomic client, created by Datomic Local, +that can be cleaned up by simply calling `.close`. A test environment is typically used within a `with-open`. ```clojure -(require '[dev-local-tu.core :as dev-local-tu] +(require '[datomic-local-tu.core :as datomic-local-tu] '[datomic.client.api :as d]) -(with-open [db-env (dev-local-tu/test-env)] +(with-open [db-env (datomic-local-tu/test-env)] (let [_ (d/create-database (:client db-env) {:db-name "test"}) conn (d/connect (:client db-env) {:db-name "test"}) _ (d/transact conn {:tx-data [{:db/ident ::name @@ -37,9 +38,10 @@ A test environment is typically used within a `with-open`. => #:example1{:name "hi"} ``` -If you would prefer to manage the lifecycle, use `new-env` to generate a new, random system and `cleanup-env!` to remove the associated resources. +If you would prefer to manage the lifecycle, use `new-env` to generate a new, +random system and `cleanup-env!` to remove the associated resources. -Alternatively, you can use test-env with fixtures. +Alternatively, you can use test-env with fixtures. See `examples/example_fixture.clj` for the complete example. ```clojure @@ -47,9 +49,13 @@ See `examples/example_fixture.clj` for the complete example. (defn client-fixture [f] - (with-open [db-env (dev-local-tu/test-env)] + (with-open [db-env (datomic-local-tu/test-env)] (binding [*client* (:client db-env)] (f)))) (use-fixtures :each client-fixture) ``` + +## Author + +Kenny Williams @kennyjwilli diff --git a/examples/example1.clj b/examples/example1.clj index 496a899..f1ff7d9 100644 --- a/examples/example1.clj +++ b/examples/example1.clj @@ -2,10 +2,10 @@ (:require [clojure.test :refer :all] [datomic.client.api :as d] - [dev-local-tu.core :as dev-local-tu])) + [datomic-local-tu.core :as datomic-local-tu])) (deftest test1 - (with-open [db-env (dev-local-tu/test-env)] + (with-open [db-env (datomic-local-tu/test-env)] (let [_ (d/create-database (:client db-env) {:db-name "test"}) conn (d/connect (:client db-env) {:db-name "test"}) _ (d/transact conn {:tx-data [{:db/ident ::name @@ -16,4 +16,4 @@ (is (= {::name "hi"} (d/pull (d/db conn) [::name] - (get tempids "a"))))))) \ No newline at end of file + (get tempids "a"))))))) diff --git a/examples/example_fixture.clj b/examples/example_fixture.clj index 0070e35..36c576a 100644 --- a/examples/example_fixture.clj +++ b/examples/example_fixture.clj @@ -2,13 +2,13 @@ (:require [clojure.test :refer :all] [datomic.client.api :as d] - [dev-local-tu.core :as dev-local-tu])) + [datomic-local-tu.core :as datomic-local-tu])) (def ^:dynamic *client* nil) (defn client-fixture [f] - (with-open [db-env (dev-local-tu/test-env)] + (with-open [db-env (datomic-local-tu/test-env)] (binding [*client* (:client db-env)] (f)))) @@ -25,4 +25,4 @@ (is (= {::name "hi"} (d/pull (d/db conn) [::name] - (get tempids "a")))))) \ No newline at end of file + (get tempids "a")))))) diff --git a/src/dev_local_tu/core.clj b/src/datomic_local_tu/core.clj similarity index 76% rename from src/dev_local_tu/core.clj rename to src/datomic_local_tu/core.clj index 0bf7588..1d178c8 100644 --- a/src/dev_local_tu/core.clj +++ b/src/datomic_local_tu/core.clj @@ -1,41 +1,42 @@ -(ns dev-local-tu.core +(ns datomic-local-tu.core + "Test utility for Datomic Local" (:require [clojure.string :as str] [datomic.client.api :as d] [datomic.local] [clojure.java.io :as io] - [dev-local-tu.internal.impl :as impl]) + [datomic-local-tu.internal.impl :as impl]) (:import (java.io Closeable File))) (defn gen-name! [prefix] (str prefix "-" (impl/rand-str! 7))) -(def default-datomic-dev-local-storage-dir +(def default-datomic-local-storage-dir (.getAbsolutePath (io/file (System/getProperty "user.home") ".datomic" "data"))) -(defn dev-local-directory +(defn datomic-local-dir ^File [{:keys [system-name db-name storage-dir] - :or {storage-dir default-datomic-dev-local-storage-dir}}] + :or {storage-dir default-datomic-local-storage-dir}}] (let [file-args (cond-> [storage-dir] - system-name (conj system-name) - db-name (conj db-name))] + system-name (conj system-name) + db-name (conj db-name))] (apply io/file file-args))) (defn -new-env-map [{:keys [prefix system storage-dir] - :or {prefix "dev-local"}}] + :or {prefix "datomic-local"}}] (let [system (or system (gen-name! prefix)) storage-dir (if (or (= storage-dir :mem) (and storage-dir - (str/starts-with? storage-dir "/"))) + (str/starts-with? storage-dir "/"))) storage-dir (.getAbsolutePath - (dev-local-directory + (datomic-local-dir (cond-> {} - storage-dir - (assoc ::storage-dir storage-dir))))) + storage-dir + (assoc ::storage-dir storage-dir))))) client-map {:server-type :datomic-local :system system :storage-dir storage-dir}] @@ -44,13 +45,13 @@ :system system :storage-dir storage-dir})) -(defn delete-dev-local-system! - "Deletes a :dev-local system's data. Always returns true. Throws on failure." +(defn delete-datomic-local-system! + "Deletes a `:datomic-local` system's data. Always returns true. Throws on failure." ([system-name] - (delete-dev-local-system! system-name default-datomic-dev-local-storage-dir)) + (delete-datomic-local-system! system-name default-datomic-local-storage-dir)) ([system-name storage-dir] - (let [f (dev-local-directory {:system-name system-name - :storage-dir storage-dir})] + (let [f (datomic-local-dir {:system-name system-name + :storage-dir storage-dir})] (when (.exists ^File f) (impl/delete-directory! f)) true))) @@ -72,7 +73,7 @@ [{:keys [client system client-map]}] (release-dbs client system) (when (string? (:storage-dir client-map)) - (delete-dev-local-system! system))) + (delete-datomic-local-system! system))) (defrecord TestEnv [system client] Closeable diff --git a/src/dev_local_tu/internal/impl.clj b/src/datomic_local_tu/internal/impl.clj similarity index 89% rename from src/dev_local_tu/internal/impl.clj rename to src/datomic_local_tu/internal/impl.clj index 5ef915d..0a76f45 100644 --- a/src/dev_local_tu/internal/impl.clj +++ b/src/datomic_local_tu/internal/impl.clj @@ -1,4 +1,4 @@ -(ns dev-local-tu.internal.impl +(ns datomic-local-tu.internal.impl (:require [clojure.java.io :as io]) (:import (java.nio.file Files SimpleFileVisitor FileVisitResult) (java.security SecureRandom) @@ -22,4 +22,4 @@ [length] (let [buffer (byte-array length) _ (.nextBytes random buffer)] - (.encodeToString encoder buffer)))) \ No newline at end of file + (.encodeToString encoder buffer)))) From f38f96dec3a8a12c0109c65707651c019ab614f8 Mon Sep 17 00:00:00 2001 From: Mark Sto Date: Sat, 15 Feb 2025 12:09:14 +0400 Subject: [PATCH 08/12] v1.0.0 Release under the `org.clojars.marksto/datomic-local-tu` artifact name --- README.md | 2 +- pom.xml | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d165793..9811336 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Test utility for Datomic Local. ```clojure -dev-local-tu {:mvn/version "0.3.0"} +org.clojars.marksto/datomic-local-tu {:mvn/version "1.0.0"} ``` ## Rationale diff --git a/pom.xml b/pom.xml index 286719f..26db83e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,10 +1,10 @@ 4.0.0 - dev-local-tu - dev-local-tu - 0.3.0 - dev-local-tu + org.clojars.marksto + datomic-local-tu + 1.0.0 + datomic-local-tu org.clojure @@ -20,5 +20,15 @@ clojars https://repo.clojars.org/ + + datomic-cloud + s3://datomic-releases-1fc2183a/maven/releases + + + + Eclipse Public License + http://www.eclipse.org/legal/epl-v10.html + + From fa0c53728db6ddd34e38863ae85d08bd516559b1 Mon Sep 17 00:00:00 2001 From: Mark Sto Date: Sat, 15 Feb 2025 12:17:53 +0400 Subject: [PATCH 09/12] Add an `scm` section to the POM file --- pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pom.xml b/pom.xml index 26db83e..56dc49a 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,10 @@ src + + https://github.com/marksto/dev-local-tu/ + f38f96dec3a8a12c0109c65707651c019ab614f8 + clojars From 206503958fedac58f759599e02a4f97a6410b099 Mon Sep 17 00:00:00 2001 From: Mark Sto Date: Sat, 15 Feb 2025 12:22:03 +0400 Subject: [PATCH 10/12] v1.0.1 --- README.md | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9811336..1a3fc07 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Test utility for Datomic Local. ```clojure -org.clojars.marksto/datomic-local-tu {:mvn/version "1.0.0"} +org.clojars.marksto/datomic-local-tu {:mvn/version "1.0.1"} ``` ## Rationale diff --git a/pom.xml b/pom.xml index 56dc49a..4805b40 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.clojars.marksto datomic-local-tu - 1.0.0 + 1.0.1 datomic-local-tu From aa65bae785704447a497e1552dadc87ba8235ce8 Mon Sep 17 00:00:00 2001 From: Mark Sto Date: Sat, 15 Feb 2025 12:56:42 +0400 Subject: [PATCH 11/12] Change SCM URL to a new one --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4805b40..ebb6b0d 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ src - https://github.com/marksto/dev-local-tu/ + https://github.com/marksto/datomic-local-tu/ f38f96dec3a8a12c0109c65707651c019ab614f8 From e4a08bcb6ee34db66edef886bb3ec1a849b87827 Mon Sep 17 00:00:00 2001 From: Mark Sto Date: Sat, 15 Feb 2025 12:57:13 +0400 Subject: [PATCH 12/12] v1.0.2 --- README.md | 2 +- pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1a3fc07..f17eb25 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Test utility for Datomic Local. ```clojure -org.clojars.marksto/datomic-local-tu {:mvn/version "1.0.1"} +org.clojars.marksto/datomic-local-tu {:mvn/version "1.0.2"} ``` ## Rationale diff --git a/pom.xml b/pom.xml index ebb6b0d..ef18bf1 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.clojars.marksto datomic-local-tu - 1.0.1 + 1.0.2 datomic-local-tu @@ -17,7 +17,7 @@ https://github.com/marksto/datomic-local-tu/ - f38f96dec3a8a12c0109c65707651c019ab614f8 + aa65bae785704447a497e1552dadc87ba8235ce8