diff --git a/.github/workflows/clojure.yml b/.github/workflows/clojure.yml index 9133370..f9ab5fc 100644 --- a/.github/workflows/clojure.yml +++ b/.github/workflows/clojure.yml @@ -15,21 +15,21 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3.4.0 + uses: actions/checkout@v4 - name: Setup Java - uses: actions/setup-java@v3.10.0 + uses: actions/setup-java@v4 with: java-version: '11' distribution: 'corretto' - name: Install clojure tools - uses: DeLaGuardo/setup-clojure@10.2 + uses: DeLaGuardo/setup-clojure@12.6 with: - cli: 1.11.1.1165 + cli: 1.12.0.1479 - name: Cache clojure dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.m2/repository @@ -48,8 +48,7 @@ jobs: run: clojure -X:test - name: Run ClojureScript tests (Chrome) - run: clojure -Mcljs-test -x chrome-headless + run: clojure -M:cljs-test -x chrome-headless - name: Run ClojureScript tests (Firefox) - run: clojure -Mcljs-test -x firefox-headless - + run: clojure -M:cljs-test -x firefox-headless diff --git a/.gitignore b/.gitignore index 029aa1d..cabc26f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ cljs-test-runner-out/ .clj-kondo/.cache .lsp/.cache .portal/vs-code.edn +.calva/repl.calva-repl diff --git a/README.md b/README.md index 3d862bf..e166cf6 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Converts a large integer to a friendly text representation. Works best for numbers over 1 million. For example, 1000000 becomes '1.0 million', 1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'. Supports up to decillion (33 digits) and googol (100 -digits). +digits). ```clojure user> (h/intword 2000000000) @@ -188,7 +188,7 @@ user> (i/pluralize-noun 6 "buzz") ``` Other functions in the inflect namespace are used to extend the rules -for how particular words, or particular letter patterns in words, +for how particular words, or particular letter patterns in words, can be pluralized. ### datetime @@ -197,19 +197,19 @@ Given a datetime or date, return a human-friendly representation of the amount of time difference, relative to the current time. ```clojure -user> (require '[clj-time.core :as t]) -nil +user> (import '(java.time LocalDateTime) '(java.time.temporal ChronoUnit)) +java.time.temporal.ChronoUnit -user> (h/datetime (t/plus (t/now) (t/seconds -30))) +user> (h/datetime (.plusSeconds (LocalDateTime/now) -30)) "30 seconds ago" -user> (h/datetime (t/plus (t/now) (t/seconds 30))) +user> (h/datetime (.plusSeconds (LocalDateTime/now) 30)) "in 30 seconds" -user> (h/datetime (t/plus (t/now) (t/years -20))) +user> (h/datetime (.plus (LocalDateTime/now) -20 ChronoUnit/YEARS)) "2 decades ago" -user> (h/datetime (t/plus (t/now) (t/years -7))) +user> (h/datetime (.plus (LocalDateTime/now) -7 ChronoUnit/YEARS)) "7 years ago" ``` @@ -277,7 +277,7 @@ clojure -T:build jar Deploy a snapshot: ```clj - clojure -T:build deploy + clojure -T:build deploy ``` Set `:release` to `true` for a release version (make sure the version number in `build.clj` is correct first): diff --git a/deps.edn b/deps.edn index a48aead..ae2b968 100644 --- a/deps.edn +++ b/deps.edn @@ -1,7 +1,5 @@ -{:deps {org.clojure/clojure {:mvn/version "1.11.1"} - clj-time/clj-time {:mvn/version "0.15.2"} - com.widdindustries/cljc.java-time {:mvn/version "0.1.21"} - henryw374/js-joda {:mvn/version "3.2.0-0"}} +{:deps {org.clojure/clojure {:mvn/version "1.11.4"} + com.widdindustries/cljc.java-time {:mvn/version "0.1.21"}} :paths ["src"] :net.lewisship.build/scm @@ -14,12 +12,11 @@ {:git/tag "v0.5.1" :git/sha "dfb30dd"}} :exec-fn cognitect.test-runner.api/test} :cljs-test {:extra-paths ["test"] - :extra-deps {kongeor/cljs-test-runner - {:git/url "https://github.com/kongeor/cljs-test-runner" - :git/sha "fa604e9e5f4e74a544958dfdf4c5ccc2a4b2c916"}} + :extra-deps {olical/cljs-test-runner {:mvn/version "3.8.1"} + henryw374/js-joda {:mvn/version "3.2.0-0"}} :main-opts ["-m" "cljs-test-runner.main"]} :clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "RELEASE"}} :main-opts ["-m" "clj-kondo.main"]} :build {:deps {io.github.hlship/build-tools - {:git/tag "0.9" :git/sha "4efa3c9"}} + {:git/tag "0.10.2" :git/sha "3c446e4"}} :ns-default build}}} diff --git a/test/clj_commons/cljc_test.cljc b/test/clj_commons/cljc_test.cljc deleted file mode 100644 index 095b578..0000000 --- a/test/clj_commons/cljc_test.cljc +++ /dev/null @@ -1,21 +0,0 @@ -(ns clj-commons.cljc-test - (:require #?(:clj [clojure.test :as test] - :cljs [cljs.test :as test :include-macros true]) - [clj-commons.humanize-test] - [clj-commons.inflect-test])) - -#?(:cljs (enable-console-print!)) - -#?(:cljs - (defmethod test/report [::test/default :summary] [m] - (println "\nRan" (:test m) "tests containing" - (+ (:pass m) (:fail m) (:error m)) "assertions.") - (println (:fail m) "failures," (:error m) "errors.") - (aset js/window "test-failures" (+ (:fail m) (:error m))))) - -(defn test-runner [] - (test/run-tests - 'clj-commons.humanize-test - 'clj-commons.inflect-test)) - -#?(:clj (defn test-ns-hook [] (test-runner))) diff --git a/test/clj_commons/humanize_test.cljc b/test/clj_commons/humanize_test.cljc index d74af3a..8346528 100644 --- a/test/clj_commons/humanize_test.cljc +++ b/test/clj_commons/humanize_test.cljc @@ -5,11 +5,10 @@ filesize truncate oxford datetime duration] :as h] - #?@(:clj [[clojure.math :as math]]) + [clojure.math :as math] [cljc.java-time.local-date-time :as jt.ldt])) -#?(:clj (def ^:private expt math/pow) - :cljs (def ^:private expt (.-pow js/Math))) +(def ^:private expt math/pow) (deftest intcomma-test (are [input expected] (= expected (intcomma input)) @@ -228,7 +227,7 @@ (is (= "10 minutes ago" (datetime (jt.ldt/now) :now-dt (jt.ldt/plus-minutes (jt.ldt/now) 10))))) - #?@(:cljs + #?(:cljs (testing "datetime accepts js/Date" (is (= "a moment ago" (datetime (js/Date.)))) (is (= "10 minutes ago"