Skip to content

Commit

Permalink
Merge pull request #43 from clj-commons/issue-42
Browse files Browse the repository at this point in the history
Manage JVM vs. CLJS dependencies better
  • Loading branch information
seancorfield authored Nov 12, 2024
2 parents 0400e26 + 8efe10b commit 57d871b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 50 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/clojure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ cljs-test-runner-out/
.clj-kondo/.cache
.lsp/.cache
.portal/vs-code.edn
.calva/repl.calva-repl
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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"

```
Expand Down Expand Up @@ -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):
Expand Down
13 changes: 5 additions & 8 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}}}
21 changes: 0 additions & 21 deletions test/clj_commons/cljc_test.cljc

This file was deleted.

7 changes: 3 additions & 4 deletions test/clj_commons/humanize_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 57d871b

Please sign in to comment.