Skip to content

Commit

Permalink
Move to rewrite-clj #64
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidz committed Mar 13, 2021
1 parent 58b46e7 commit 4a248e3
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 27 deletions.
3 changes: 1 addition & 2 deletions deps.edn
Expand Up @@ -8,8 +8,7 @@
cheshire/cheshire {:mvn/version "5.10.0"}
clj-commons/clj-yaml {:mvn/version "0.7.106"}
version-clj/version-clj {:mvn/version "2.0.1"}
lread/rewrite-cljc {:git/url "https://github.com/lread/rewrite-cljc-playground"
:sha "24a27fbf387e7df4e65c83b469f7bab05ee06673"}}
rewrite-clj/rewrite-clj {:mvn/version "1.0.579-alpha"}}

:aliases
{:1.8
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Expand Up @@ -34,6 +34,11 @@
<artifactId>data.zip</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>rewrite-clj</groupId>
<artifactId>rewrite-clj</artifactId>
<version>1.0.579-alpha</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>tools.deps.alpha</artifactId>
Expand Down
@@ -1,5 +1,5 @@
(ns antq.stub.rewrite-cljc.zip
"Stub rewrite-cljs.zip to support Clojure 1.8"
(ns antq.stub.rewrite-clj.zip
"Stub rewrite-clj.zip to support Clojure 1.8"
(:refer-clojure :exclude [next replace]))

(def down (constantly nil))
Expand All @@ -12,4 +12,4 @@
(def root-string (constantly nil))
(def tag (constantly nil))
(def up (constantly nil))
(def value (constantly nil))
(def sexpr (constantly nil))
2 changes: 1 addition & 1 deletion src/antq/upgrade.clj
Expand Up @@ -17,7 +17,7 @@
(defn- confirm
[dep force?]
(cond
(not u.zip/rewrite-cljc-supported?)
(not u.zip/rewrite-clj-supported?)
(do (log/error "Upgrading is only supported Clojure 1.9 or later.")
false)

Expand Down
8 changes: 4 additions & 4 deletions src/antq/upgrade/boot.clj
Expand Up @@ -4,13 +4,13 @@
[antq.util.dep :as u.dep]
[antq.util.zip :as u.zip]))

(require (if u.zip/rewrite-cljc-supported?
'[rewrite-cljc.zip :as z]
'[antq.stub.rewrite-cljc.zip :as z]))
(require (if u.zip/rewrite-clj-supported?
'[rewrite-clj.zip :as z]
'[antq.stub.rewrite-clj.zip :as z]))

(defn- in-dependencies?
[loc]
(-> loc z/up z/up z/up z/left z/value
(-> loc z/up z/up z/up z/left z/sexpr
(= :dependencies)))

(defn upgrade-dep
Expand Down
8 changes: 4 additions & 4 deletions src/antq/upgrade/clojure.clj
Expand Up @@ -4,13 +4,13 @@
[antq.util.dep :as u.dep]
[antq.util.zip :as u.zip]))

(require (if u.zip/rewrite-cljc-supported?
'[rewrite-cljc.zip :as z]
'[antq.stub.rewrite-cljc.zip :as z]))
(require (if u.zip/rewrite-clj-supported?
'[rewrite-clj.zip :as z]
'[antq.stub.rewrite-clj.zip :as z]))

(defn- in-deps?
[loc]
(->> loc z/up z/left z/value
(->> loc z/up z/left z/sexpr
(contains? #{:deps :extra-deps :replace-deps :override-deps})))

(defn upgrade-dep
Expand Down
8 changes: 4 additions & 4 deletions src/antq/upgrade/leiningen.clj
Expand Up @@ -4,15 +4,15 @@
[antq.util.dep :as u.dep]
[antq.util.zip :as u.zip]))

(require (if u.zip/rewrite-cljc-supported?
'[rewrite-cljc.zip :as z]
'[antq.stub.rewrite-cljc.zip :as z]))
(require (if u.zip/rewrite-clj-supported?
'[rewrite-clj.zip :as z]
'[antq.stub.rewrite-clj.zip :as z]))

(defn- in-dependencies?
[loc]
(loop [loc (-> loc z/up z/up)]
(if (= :vector (z/tag loc))
(contains? #{:dependencies :plugins} (-> loc z/left z/value))
(contains? #{:dependencies :plugins} (-> loc z/left z/sexpr))
;; skip elements like metadata
(recur (z/up loc)))))

Expand Down
8 changes: 4 additions & 4 deletions src/antq/upgrade/shadow.clj
Expand Up @@ -4,13 +4,13 @@
[antq.util.dep :as u.dep]
[antq.util.zip :as u.zip]))

(require (if u.zip/rewrite-cljc-supported?
'[rewrite-cljc.zip :as z]
'[antq.stub.rewrite-cljc.zip :as z]))
(require (if u.zip/rewrite-clj-supported?
'[rewrite-clj.zip :as z]
'[antq.stub.rewrite-clj.zip :as z]))

(defn- in-dependencies?
[loc]
(-> loc z/up z/up z/left z/value
(-> loc z/up z/up z/left z/sexpr
(= :dependencies)))

(defn upgrade-dep
Expand Down
8 changes: 4 additions & 4 deletions src/antq/util/zip.clj
@@ -1,13 +1,13 @@
(ns antq.util.zip)

(let [{:keys [major minor]} *clojure-version*]
(def rewrite-cljc-supported?
(def rewrite-clj-supported?
(or (and (= major 1) (>= minor 9))
(> major 1))))

(require (if rewrite-cljc-supported?
'[rewrite-cljc.zip :as z]
'[antq.stub.rewrite-cljc.zip :as z]))
(require (if rewrite-clj-supported?
'[rewrite-clj.zip :as z]
'[antq.stub.rewrite-clj.zip :as z]))

(defn move-to-root
[loc]
Expand Down
2 changes: 1 addition & 1 deletion test/antq/util/zip_test.clj
Expand Up @@ -2,7 +2,7 @@
(:require
[antq.util.zip :as sut]
[clojure.test :as t]
[rewrite-cljc.zip :as z]))
[rewrite-clj.zip :as z]))

(t/deftest move-to-root-test
(let [loc (z/of-string "(foo (bar (baz)))")
Expand Down

0 comments on commit 4a248e3

Please sign in to comment.