Skip to content

Commit

Permalink
Merge pull request #56 from liquidz/dev
Browse files Browse the repository at this point in the history
0.10.3
  • Loading branch information
liquidz authored Jan 31, 2021
2 parents 5659f92 + 34ee2df commit cffde09
Show file tree
Hide file tree
Showing 24 changed files with 196 additions and 68 deletions.
3 changes: 2 additions & 1 deletion .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
{:output {:exclude-files ["test/resources/dep"]}}
{:linters {:unresolved-namespace {:exclude [z]}}
:output {:exclude-files ["test/resources/dep"]}}
22 changes: 22 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@ All notable changes to this project will be documented in this file. This change

== Unreleased (dev)

== 0.10.3 (2021-02-01)
// {{{
=== Changed

* Bumped org.clojure/clojure to 1.10.2.
* Bumped tools.deps.alpha to 0.9.863.
* Bumped clj-commons/clj-yaml to 0.7.106.
* Updateed lread/rewrite-cljc to be latest.

=== Fixed

* Fixed to return success status when all outdated deps are upgraded.
* Fixed not to confirm for upgrading GitHub Actions YAML.
** Upgrading YAML is not supported yet.
* https://github.com/liquidz/antq/issues/55[#55]: Fixed to check `org.clojure/clojure`.
** If there are some `org.clojure/clojure` versions in the same file, only the newest version will be checked.
* Fixed `deps.edn` extractor to handle `:override-deps` key.
* Fixed `deps.edn` upgrader to handle `:override-deps` key.
* Fixed to work with Clojure 1.8 again.
** `--upgrade` option requires Clojure 1.9 or later instead.
// }}}

== 0.10.2 (2021-01-02)

// {{{
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ outdated:
clojure -M:outdated:nop --upgrade

test:
# NOTE: kaocha does not support Clojure 1.8
clojure -M:outdated:nop:1.8
clojure -M:dev:1.9:test
clojure -M:dev:test

Expand Down
6 changes: 5 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ image:https://codecov.io/gh/liquidz/antq/branch/master/graph/badge.svg["codecov"
image:https://img.shields.io/clojars/v/antq.svg["Clojars Project", link="https://clojars.org/antq"]
image:https://img.shields.io/badge/docker-automated-blue["Docker Hub", link="https://hub.docker.com/r/uochan/antq"]

NOTE: Antq requires Clojure 1.8.0 or later. If you'd like to use with 1.7.0 or earlier, please see link:./doc/clojure-1.7.adoc[here].
[NOTE]
====
Antq requires Clojure 1.8.0 or later. (However `--upgrade` option requires Clojure 1.9.0 or later) +
If you'd like to use with 1.7.0 or earlier, please see link:./doc/clojure-1.7.adoc[here].
====

== Supported files

Expand Down
12 changes: 7 additions & 5 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{:paths ["src"]
:deps
{org.clojure/clojure {:mvn/version "1.10.1"}
{org.clojure/clojure {:mvn/version "1.10.2"}
org.clojure/data.xml {:mvn/version "0.2.0-alpha6"}
org.clojure/data.zip {:mvn/version "1.0.0"}
org.clojure/tools.cli {:mvn/version "1.0.194"}
org.clojure/tools.deps.alpha {:mvn/version "0.9.857"}
org.clojure/tools.deps.alpha {:mvn/version "0.9.863"}
cheshire/cheshire {:mvn/version "5.10.0"}
clj-commons/clj-yaml {:mvn/version "0.7.2"}
clj-commons/clj-yaml {:mvn/version "0.7.106"}
version-clj/version-clj {:mvn/version "0.1.2"}
lread/rewrite-cljc {:git/url "https://github.com/lread/rewrite-cljc-playground"
:sha "cc8ded71f1ca056d4851f4664754e0e004e985ad"}}
:sha "24a27fbf387e7df4e65c83b469f7bab05ee06673"}}

:aliases
{:1.9
{:1.8
{:override-deps {org.clojure/clojure {:mvn/version "1.8.0"}}}
:1.9
{:override-deps {org.clojure/clojure {:mvn/version "1.9.0"}}}

:dev
Expand Down
2 changes: 1 addition & 1 deletion doc/latest-version-of-a-specific-library.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ You can use `-X` option to find out the latest version of a specific library.
clojure -Sdeps '{:deps {antq/antq {:mvn/version "RELEASE"}}}' -X antq.core/latest :name antq
;; You can specify library type
clojure -Sdeps '{:deps {antq/antq {:mvn/version "RELEASE"}}}' -X antq.core/latest :name actions/checkout :type :github-action
clojure -Sdeps '{:deps {antq/antq {:mvn/version "RELEASE"}}}' -X antq.core/latest :name actions/checkout :type :github-tag
----

8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>antq</groupId>
<artifactId>antq</artifactId>
<version>0.10.2</version>
<version>0.10.3</version>
<name>antq</name>
<description>Point out your outdated dependencies</description>
<url>https://github.com/liquidz/antq</url>
Expand All @@ -22,7 +22,7 @@
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
<version>1.10.1</version>
<version>1.10.2</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
Expand All @@ -37,7 +37,7 @@
<dependency>
<groupId>org.clojure</groupId>
<artifactId>tools.deps.alpha</artifactId>
<version>0.9.857</version>
<version>0.9.863</version>
</dependency>
<dependency>
<groupId>org.clojure</groupId>
Expand All @@ -47,7 +47,7 @@
<dependency>
<groupId>clj-commons</groupId>
<artifactId>clj-yaml</artifactId>
<version>0.7.2</version>
<version>0.7.106</version>
</dependency>
<dependency>
<groupId>cheshire</groupId>
Expand Down
34 changes: 24 additions & 10 deletions src/antq/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
[antq.upgrade.shadow]
[antq.ver :as ver]
[antq.ver.git-sha]
[antq.ver.github-action]
[antq.ver.github-tag]
[antq.ver.java]
[clojure.string :as str]
[clojure.tools.cli :as cli]))
[clojure.tools.cli :as cli]
[version-clj.core :as version]))

(defn- concat-assoc-fn
[opt k v]
Expand Down Expand Up @@ -63,16 +64,13 @@
[nil "--upgrade"]
[nil "--force"]])

(def default-skip-artifacts
#{"org.clojure/clojure"})

(def default-repos
{"central" "https://repo1.maven.org/maven2/"
"clojars" "https://repo.clojars.org/"})

(defn skip-artifacts?
[dep options]
(let [exclude-artifacts (apply conj default-skip-artifacts (:exclude options []))
(let [exclude-artifacts (set (:exclude options []))
focus-artifacts (set (:focus options []))]
(cond
;; `focus` is prefer than `exclude`
Expand Down Expand Up @@ -164,20 +162,36 @@
(when-not (skip "leiningen") (dep.lein/load-deps %)))
(distinct (:directory options)))))

(defn unify-org-clojure-deps
"Keep only the newest version of `org.clojure/clojure` in the same file."
[deps]
(let [other-deps (remove #(= "org.clojure/clojure" (:name %)) deps)]
(->> deps
(filter #(= "org.clojure/clojure" (:name %)))
(group-by :file)
(map (fn [[_ deps]]
(->> deps
(sort (fn [a b] (version/version-compare (:version b) (:version a))))
first)))
(concat other-deps))))

(defn -main
[& args]
(let [{:keys [options]} (cli/parse-opts args cli-options)
options (cond-> options
;; Force "format" reporter when :error-format is specified
(some? (:error-format options)) (assoc :reporter "format"))
deps (fetch-deps options)]
deps (fetch-deps options)
deps (unify-org-clojure-deps deps)]
(if (seq deps)
(let [outdated (outdated-deps deps options)]
(report/reporter outdated options)

(when (:upgrade options)
(upgrade/upgrade! outdated (or (:force options) false)))
(cond-> outdated
(:upgrade options)
(upgrade/upgrade! (or (:force options) false))

(exit outdated))
true
(exit)))
(do (println "No project file")
(System/exit 1)))))
2 changes: 1 addition & 1 deletion src/antq/dep/clojure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
edn (edn/read-string deps-edn-content-str)]
(walk/postwalk (fn [form]
(when (and (sequential? form)
(#{:deps :extra-deps :replace-deps} (first form)))
(#{:deps :extra-deps :replace-deps :override-deps} (first form)))
(->> form
(second)
(seq)
Expand Down
2 changes: 1 addition & 1 deletion src/antq/dep/github_action.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{:type :git-sha
:version version
:extra {:url (name->url name)}}
{:type :github-action
{:type :github-tag
:version (u.ver/normalize-version version)}))

(defn extract-deps
Expand Down
15 changes: 15 additions & 0 deletions src/antq/stub/rewrite_cljc/zip.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(ns antq.stub.rewrite-cljc.zip
"Stub rewrite-cljs.zip to support Clojure 1.8"
(:refer-clojure :exclude [next replace]))

(def down (constantly nil))
(def find-value (constantly nil))
(def left (constantly nil))
(def next (constantly nil))
(def of-file (constantly nil))
(def replace (constantly nil))
(def right (constantly nil))
(def root-string (constantly nil))
(def tag (constantly nil))
(def up (constantly nil))
(def value (constantly nil))
61 changes: 42 additions & 19 deletions src/antq/upgrade.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(ns antq.upgrade)
(ns antq.upgrade
(:require
[antq.util.zip :as u.zip]))

(defmulti upgrader
(fn [version-checked-dep]
Expand All @@ -11,26 +13,47 @@
(name (:project dep)))))

(defn- confirm
[dep]
(print (format "Do you upgrade %s '%s' to '%s' in %s (y/n): "
(:name dep)
(:version dep)
(:latest-version dep)
(:file dep)))
(flush)
(contains? #{'y 'Y 'yes 'Yes 'YES} (read)))
[dep force?]
(cond
(not u.zip/rewrite-cljc-supported?)
(do (println "Upgrading is only supported Clojure 1.9 or later.")
false)

(defn upgrade!
[version-checked-deps force?]
(doseq [dep version-checked-deps
:when (and (:latest-version dep)
(if force?
true
(confirm dep)))]
(when-let [upgraded-content (upgrader dep)]
(println (format "Upgraded %s '%s' to '%s' in %s."
(and (:latest-version dep)
force?)
true

;; TODO: Remove this condition when upgrading YAML is supported
(= :github-action (:project dep))
false

(:latest-version dep)
(do (print (format "Do you upgrade %s '%s' to '%s' in %s (y/n): "
(:name dep)
(:version dep)
(:latest-version dep)
(:file dep)))
(spit (:file dep) upgraded-content))))
(flush)
(contains? #{'y 'Y 'yes 'Yes 'YES} (read)))

:else
false))

(defn upgrade!
"Return only non-upgraded deps"
[version-checked-deps force?]
(doall
(remove
(fn [dep]
(if (confirm dep force?)
(if-let [upgraded-content (upgrader dep)]
(do (println (format "Upgraded %s '%s' to '%s' in %s."
(:name dep)
(:version dep)
(:latest-version dep)
(:file dep)))
(spit (:file dep) upgraded-content)
true)
false)
false))
version-checked-deps)))
7 changes: 5 additions & 2 deletions src/antq/upgrade/boot.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
(:require
[antq.upgrade :as upgrade]
[antq.util.dep :as u.dep]
[antq.util.zip :as u.zip]
[rewrite-cljc.zip :as z]))
[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]))

(defn- in-dependencies?
[loc]
Expand Down
9 changes: 6 additions & 3 deletions src/antq/upgrade/clojure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
(:require
[antq.upgrade :as upgrade]
[antq.util.dep :as u.dep]
[antq.util.zip :as u.zip]
[rewrite-cljc.zip :as z]))
[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]))

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

(defn upgrade-dep
[loc version-checked-dep]
Expand Down
7 changes: 5 additions & 2 deletions src/antq/upgrade/leiningen.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
(:require
[antq.upgrade :as upgrade]
[antq.util.dep :as u.dep]
[antq.util.zip :as u.zip]
[rewrite-cljc.zip :as z]))
[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]))

(defn- in-dependencies?
[loc]
Expand Down
7 changes: 5 additions & 2 deletions src/antq/upgrade/shadow.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
(:require
[antq.upgrade :as upgrade]
[antq.util.dep :as u.dep]
[antq.util.zip :as u.zip]
[rewrite-cljc.zip :as z]))
[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]))

(defn- in-dependencies?
[loc]
Expand Down
13 changes: 10 additions & 3 deletions src/antq/util/zip.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
(ns antq.util.zip
(:require
[rewrite-cljc.zip :as z]))
(ns antq.util.zip)

(let [{:keys [major minor]} *clojure-version*]
(def rewrite-cljc-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]))

(defn move-to-root
[loc]
Expand Down
Loading

0 comments on commit cffde09

Please sign in to comment.