Skip to content

Commit fb16db8

Browse files
committed
docs, tests: zprint is now using rewrite-clj v1! woot!
No band-aids needed anymore for canary testing zprint. Also, setup is easier. Thanks @kkinnear!
1 parent bd0e993 commit fb16db8

File tree

2 files changed

+10
-35
lines changed

2 files changed

+10
-35
lines changed

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Some projects using rewrite-clj v1
6262
* https://github.com/borkdude/rewrite-edn[rewrite-edn] {canary-tested}
6363
* https://github.com/lread/test-doc-blocks[test-doc-blocks] {canary-tested}
6464
* https://github.com/nubank/umschreiben-clj[umschreiben-clj] {canary-tested}
65+
* https://github.com/kkinnear/zprint[zprint] {canary-tested}
6566

6667
Some projects using rewrite-clj v0 and/or rewrite-cljs
6768

@@ -74,7 +75,6 @@ Some projects using rewrite-clj v0 and/or rewrite-cljs
7475
* https://github.com/juxt/pack.alpha[pack (alpha)] {not-canary-tested}
7576
* https://github.com/mauricioszabo/repl-tooling[repl-tooling] {not-canary-tested}
7677
* https://github.com/atomist-skills/update-leiningen-dependencies-skill[update-leiningen-dependencies-skill] {not-canary-tested}
77-
* https://github.com/kkinnear/zprint[zprint] {canary-tested} {canary-needed-patch}
7878

7979
Have an update? Let us know!
8080

script/test_libs.clj

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@
142142

143143
(defn- project-clj-v1-patch [{:keys [home-dir rewrite-clj-version]}]
144144
(patch-deps {:filename (str (fs/file home-dir "project.clj"))
145-
:removals #{'rewrite-clj}
146-
:additions [['rewrite-clj rewrite-clj-version]]}))
145+
:removals #{'rewrite-clj 'rewrite-clj/rewrite-clj}
146+
:additions [['rewrite-clj/rewrite-clj rewrite-clj-version]]}))
147147

148148
(defn- replace-in-file [fname match replacement]
149149
(let [orig-filename (str fname ".orig")
@@ -252,40 +252,16 @@
252252
;; zprint
253253
;;
254254

255-
(defn- zprint-patch [{:keys [home-dir rewrite-clj-version]}]
256-
(patch-deps {:filename (str (fs/file home-dir "project.clj"))
257-
:removals #{'rewrite-clj 'rewrite-cljs}
258-
:additions [['rewrite-clj rewrite-clj-version]]})
259-
260-
(status/line :detail "=> Hacking lift-ns to compensate for rewrite-clj v0->v1 change in sexpr on nsmap keys")
261-
(status/line :detail "- note the word 'hacking' - hacked for to get test passing only")
262-
(let [src-filename (str (fs/file home-dir "src/zprint/zutil.cljc"))
263-
orig-filename (str src-filename ".orig")
264-
content (slurp src-filename)
265-
find-str "(namespace (z/sexpr k))"
266-
replace-str "(namespace (keyword (z/string k)))"]
267-
(fs/copy src-filename orig-filename)
268-
(status/line :detail "- hacking %s" src-filename)
269-
(if-let [ndx (string/last-index-of content find-str)]
270-
(spit src-filename
271-
(str (subs content 0 ndx)
272-
replace-str
273-
(subs content (+ ndx (count find-str)))))
274-
(throw (ex-info "hacking zprint failed" {})))))
275-
276-
(defn- zprint-prep [{:keys [target-root-dir home-dir]}]
277-
(status/line :detail "=> Installing not-yet-released expectations/cljc-test")
278-
(let [clone-to-dir (str (fs/file target-root-dir "clojure-test"))]
279-
(shcmd "git" "clone" "--branch" "enhancements"
280-
"https://github.com/kkinnear/clojure-test.git" clone-to-dir)
281-
(run! #(shcmd {:dir clone-to-dir} %)
282-
["git reset --hard a6c3be067ab06f677d3b1703ee4092d25db2bb60"
283-
"clojure -M:jar"
284-
"mvn install:install-file -Dfile=expectations.jar -DpomFile=pom.xml"]))
255+
(defn- zprint-patch [lib]
256+
;; zprint has a project.clj and a deps.edn, patch 'em both
257+
(deps-edn-v1-patch lib)
258+
(project-clj-v1-patch lib))
285259

260+
(defn- zprint-prep [{:keys [home-dir]}]
286261
(status/line :detail "=> Building uberjar for uberjar tests")
287262
(shcmd {:dir home-dir} "lein uberjar")
288263

264+
;; not sure if this is still necessary, but probably does not hurt(?)
289265
(status/line :detail "=> Installing zprint locally for ClojureScript tests")
290266
(shcmd {:dir home-dir} "lein install"))
291267

@@ -422,9 +398,8 @@
422398
:show-deps-fn lein-deps-tree
423399
:test-cmds ["lein test"]}
424400
{:name "zprint"
425-
:version "1.1.1"
401+
:version "1.2.0"
426402
:platforms [:clj :cljs]
427-
:note "1 minor hack to pass with rewrite-clj v1, skip version 1.1.2 release, skip 1.2.0-alpha1 tag"
428403
:github-release {:repo "kkinnear/zprint"}
429404
:patch-fn zprint-patch
430405
:prep-fn zprint-prep

0 commit comments

Comments
 (0)