Skip to content

Commit c406c62

Browse files
committed
Switch to our fork of clj-diff
Also switch to lioss-based tooling
1 parent feeb6ca commit c406c62

File tree

8 files changed

+139
-10
lines changed

8 files changed

+139
-10
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
.nrepl-port
33
target
44
repl
5-
bin
65
scratch.clj
76
/out/
87
/checkouts/
@@ -19,3 +18,4 @@ yarn.lock
1918
resources/public/ui
2019
test
2120
resources/public/
21+
.store

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,10 @@ This library was originally developed as part of the
151151

152152
Another library that implements a form of data structure diffing is [editscript](https://github.com/juji-io/editscript).
153153

154+
<!-- license -->
154155
## License
155156

156157
Copyright &copy; 2018-2020 Arne Brasseur and Contributors
157158

158159
Available under the terms of the Eclipse Public License 1.0, see LICENSE.txt
160+
<!-- /license -->

bb_deps.edn

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{:deps
2+
{lambdaisland/open-source {;;:git/url "https://github.com/lambdaisland/open-source"
3+
;;:sha "8232cc6a368db85e3ae0178445dc3bd58c60bbcb"
4+
:local/root "../open-source"}}}

bin/bb

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/usr/bin/env bash
2+
3+
# Wrapper script for babashka to be dropped into projects, will run `bb` from
4+
# the PATH if it exists, or otherwise download it and store it inside the
5+
# project. When using the system `bb` it will do a version check and warn if the
6+
# version is older than what is requested.
7+
#
8+
# Will look for a `bb_deps.edn` and run that through `clojure` to compute a
9+
# classpath.
10+
#
11+
# Will use rlwrap if it is available.
12+
13+
name=babashka
14+
babashka_version="0.1.3"
15+
store_dir="$(pwd)/.store"
16+
install_dir="${store_dir}/$name-$babashka_version"
17+
18+
system_bb="$(which bb)"
19+
set -e
20+
21+
# https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash
22+
vercomp () {
23+
if [[ $1 == $2 ]]
24+
then
25+
return 0
26+
fi
27+
local IFS=.
28+
local i ver1=($1) ver2=($2)
29+
# fill empty fields in ver1 with zeros
30+
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
31+
do
32+
ver1[i]=0
33+
done
34+
for ((i=0; i<${#ver1[@]}; i++))
35+
do
36+
if [[ -z ${ver2[i]} ]]
37+
then
38+
# fill empty fields in ver2 with zeros
39+
ver2[i]=0
40+
fi
41+
if ((10#${ver1[i]} > 10#${ver2[i]}))
42+
then
43+
return 1
44+
fi
45+
if ((10#${ver1[i]} < 10#${ver2[i]}))
46+
then
47+
return 2
48+
fi
49+
done
50+
return 0
51+
}
52+
53+
if [[ -f "$system_bb" ]]; then
54+
bb_path="$system_bb"
55+
elif [[ -f "$install_dir/bb" ]]; then
56+
bb_path="$install_dir/bb"
57+
else
58+
case "$(uname -s)" in
59+
Linux*) platform=linux;;
60+
Darwin*) platform=macos;;
61+
esac
62+
63+
echo "$name $babashka_version not found, installing to $install_dir..."
64+
download_url="https://github.com/borkdude/babashka/releases/download/v$babashka_version/babashka-$babashka_version-$platform-amd64.zip"
65+
66+
mkdir -p $install_dir
67+
echo -e "Downloading $download_url."
68+
curl -o bb.zip -sL "$download_url"
69+
unzip -qqo "bb.zip" -d $install_dir
70+
rm "bb.zip"
71+
bb_path="$install_dir/bb"
72+
fi
73+
74+
set +e
75+
actual_version="$($bb_path --version | sed 's/babashka v//')"
76+
77+
vercomp $actual_version $babashka_version
78+
case $? in
79+
0) ;; # =
80+
1) ;; # >
81+
2) echo "WARNING: babashka version is $actual_version, expected $babashka_version" ;; # <
82+
esac
83+
set -e
84+
85+
try_exec_rlwrap() {
86+
if [ -x "$(command -v rlwrap)" ]; then
87+
exec "rlwrap" "$@"
88+
else
89+
exec "$@"
90+
fi
91+
}
92+
93+
deps_clj="$(pwd)/.store/deps.clj"
94+
95+
ensure_deps_clj() {
96+
if [[ ! -f "${deps_clj}" ]]; then
97+
mkdir -p "${store_dir}"
98+
curl -sL https://raw.githubusercontent.com/borkdude/deps.clj/master/deps.clj -o "${deps_clj}"
99+
fi
100+
}
101+
102+
if [[ -f bb_deps.edn ]]; then
103+
ensure_deps_clj
104+
# Note this will install clojure-tools in ~/.deps.clj/ClojureTools
105+
cp="$($bb_path $deps_clj -Srepro -Sdeps-file bb_deps.edn -Spath)"
106+
try_exec_rlwrap "$bb_path" "-cp" "${cp}" "$@"
107+
else
108+
try_exec_rlwrap "$bb_path" "$@"
109+
fi

bin/kaocha

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
clojure -A:dev:test -m kaocha.runner "$@"

bin/proj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!bin/bb
2+
3+
(ns proj (:require [lioss.main :as lioss]))
4+
5+
(lioss/main
6+
{:license :epl
7+
:inception-year 2018
8+
:description "Recursively compare Clojure or ClojureScript data structures, and produce a colorized diff of the result."})
9+
10+
11+
;; Local Variables:
12+
;; mode:clojure
13+
;; End:

deps.edn

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{:paths ["resources" "src" "test"]
2-
:deps {org.clojure/clojure {:mvn/version "1.10.1"}
3-
fipp {:mvn/version "0.6.22"}
4-
org.clojure/core.rrb-vector {:mvn/version "0.1.1"}
5-
org.clojars.rymndhng/clj-diff {:mvn/version "1.1.1-SNAPSHOT"}
6-
mvxcvi/arrangement {:mvn/version "1.2.0"}}
2+
:deps {fipp {:mvn/version "0.6.23"}
3+
org.clojure/core.rrb-vector {:mvn/version "0.1.1"}
4+
lambdaisland/clj-diff {:mvn/version "1.1.58"}
5+
mvxcvi/arrangement {:mvn/version "1.2.1"}}
76

87
:aliases {:cljs
98
{:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.597"}}}
@@ -12,9 +11,9 @@
1211
{}
1312

1413
:chui
15-
{:extra-deps {lambdaisland/chui {:local/root "../chui"}
16-
thheller/shadow-cljs {:mvn/version "2.8.93"}
17-
garden {:mvn/version "1.3.9"}}
14+
{:extra-deps {lambdaisland/chui {:local/root "../chui"}
15+
thheller/shadow-cljs {:mvn/version "2.8.93"}
16+
garden {:mvn/version "1.3.9"}}
1817
:extra-paths ["../chui/resources" "../chui/dev"]}
1918

2019
:test

src/lambdaisland/deep_diff2/diff_impl.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(ns lambdaisland.deep-diff2.diff-impl
22
(:require [clojure.data :as data]
3-
[clj-diff.core :as seq-diff]))
3+
[lambdaisland.clj-diff.core :as seq-diff]))
44

55
(declare diff diff-similar)
66

0 commit comments

Comments
 (0)