Skip to content

Commit

Permalink
Merge pull request #167 from liquidz/dev
Browse files Browse the repository at this point in the history
Next release
  • Loading branch information
liquidz authored Jul 1, 2022
2 parents 59b3f95 + 50acc9d commit 638cde7
Show file tree
Hide file tree
Showing 61 changed files with 664 additions and 219 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- uses: actions/checkout@v3
- uses: DeLaGuardo/setup-clj-kondo@master
with:
version: '2022.05.31'
version: '2022.06.22'
- run: clj-kondo --lint src:test --config '{:output {:pattern "::{{level}} file={{filename}},line={{row}},col={{col}}::{{message}}"}}'

cljstyle:
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
All notable changes to this project will be documented in this file. This change log follows the conventions of http://keepachangelog.com/[keepachangelog.com].

== Unreleased (dev)
// {{{
=== Added
* https://github.com/liquidz/antq/pull/157[#157]: Added progress bar to `table` reporter.
* https://github.com/liquidz/antq/pull/158[#158]: Added environmental variables to customize timeout milli secs.
** See details link:./doc/timeout.adoc[here].

=== Changed
* https://github.com/liquidz/antq/pull/158[#158]: Applied timeouts to the following operations.
** Fetching data from Maven repositories
** Fetching data from GitHub API
** Fetching data from git repositories
* Bumped kaocha to 1.68.1059.
* Bumped deep-diff2 to 2.3.127.
* Bumped build.edn to 0.5.116.

=== Fixed
* https://github.com/liquidz/antq/pull/166[#166]: Fixed to catch `XmlPullParserExceptio`.
// }}}

== 1.7.804 (2022-06-11)
// {{{
Expand Down
27 changes: 18 additions & 9 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,26 @@ Or add the following alias to your `$HOME/.clojure/deps.edn`.
Then, run `clojure -M:outdated`.
(run `clojure -A:outdated` for Clojure CLI Tool 1.10.1.645 or earlier).

=== Clojure CLI Tools (`1.10.3.933` or later)
=== Clojure CLI Tools (`1.11.1.1139` or later)

From Clojure CLI ver `1.10.3.933`, https://clojure.org/reference/deps_and_cli#tool_install[tool] installation is supported.
From Clojure CLI ver `1.11.1.1139`, https://clojure.org/reference/deps_and_cli#tool_install[tool] installation is supported.

[source,sh]
----
# install
clojure -Ttools install com.github.liquidz/antq '{:git/tag "1.7.804"}' :as antq
# uninstall
# Install tool
clojure -Ttools install-latest :lib com.github.liquidz/antq :as antq
# Uninstall tool
clojure -Ttools remove :tool antq
# execute
# Update tool
clojure -Ttools install-latest :tool antq
# Execute
clojure -Tantq outdated
# execute with parameter
# Execute with parameter
clojure -Tantq outdated :upgrade true
# help
# Show help
clojure -A:deps -Tantq help/doc
# upgrade
# Upgrade oudated dependencies
clojure -Tantq outdated :check-clojure-tools true :upgrade true
----

Expand Down Expand Up @@ -147,6 +150,11 @@ In another way, you can use the following action.
Antq experimentally supports https://gradle.org[Gradle].
See link:./doc/gradle.adoc[here] for details.

=== Timeouts

Antq has timeouts for acquiring various information.
See link:./doc/timeout.adoc[here] for details.

== Options
=== --upgrade
Upgrade outdated versions interactively.
Expand Down Expand Up @@ -289,6 +297,7 @@ You can also upgrade them with `--upgrade` option.
* link:./doc/clojure-1.8.adoc[Antq with Clojure 1.8.0 or earlier]
* link:./doc/gradle.adoc[Work with Gradle]
* link:./doc/proxy.adoc[Run behind proxy]
* link:./doc/timeout.adoc[Timeouts]

== License

Expand Down
9 changes: 3 additions & 6 deletions build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@

(def ^:private config
{:lib 'com.github.liquidz/antq
:version "1.7.{{git/commit-count}}"
:version "1.8.{{git/commit-count}}"
:description "Point out your outdated dependencies"
:main 'antq.core
:documents [{:file "CHANGELOG.adoc"
:match "Unreleased"
:action :append-after
:text "\n== {{version}} ({{now/yyyy}}-{{now/mm}}-{{now/dd}})"}
{:file "README.adoc"
:match "install com\\.github\\.liquidz/antq"
:action :replace
:text "clojure -Ttools install com.github.liquidz/antq '{:git/tag \"{{version}}\"}' :as antq"}]
:text "\n== {{version}} ({{now/yyyy}}-{{now/mm}}-{{now/dd}})"}]
:github-actions? true})

(defn jar
Expand Down
8 changes: 5 additions & 3 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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.206"}
org.clojure/core.async {:mvn/version "1.5.648"}
;; NOTE: tools.deps.alpha v0.12.1098 or later does not work with CLojure 1.9.0
org.clojure/tools.deps.alpha {:mvn/version "0.12.1090"}
org.clojure/data.json {:mvn/version "2.4.0"}
Expand All @@ -25,8 +26,9 @@
:dev
{:extra-paths ["test"
"test/resources"]
:extra-deps {lambdaisland/kaocha {:mvn/version "1.66.1034"}
lambdaisland/deep-diff2 {:mvn/version "2.2.124"}}}
:extra-deps {lambdaisland/kaocha {:mvn/version "1.68.1059"}
lambdaisland/deep-diff2 {:mvn/version "2.3.127"}}
:jvm-opts ["-Dclojure.core.async.go-checking=true"]}

:nop
{:extra-deps {org.slf4j/slf4j-nop {:mvn/version "RELEASE"}}}
Expand All @@ -42,7 +44,7 @@
:main-opts ["-m" "cloverage.coverage" "--ns-exclude-regex" "leiningen.antq"]}

:build
{:deps {com.github.liquidz/build.edn {:git/tag "0.3.90" :git/sha "e3a3e31"}}
{:deps {com.github.liquidz/build.edn {:git/tag "0.5.116" :git/sha "f633fa3"}}
:ns-default build}

;; -X
Expand Down
35 changes: 35 additions & 0 deletions doc/timeout.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
= Timeouts

Antq has timeouts for acquiring various information.
These timeouts are customizable by following environmental variables.

[cols="1,4a,5a"]
|===
| Name | Default | Description

| ANTQ_DEFAULT_TIMEOUT
| `10,000`
| Unit is milli sec.


| ANTQ_LS_REMOTE_TIMEOUT
| Same as `ANTQ_DEFAULT_TIMEOUT`.
| Timeout for `git ls-remote`. +
Unit is milli sec.

| ANTQ_GITHUB_API_TIMEOUT
| Same as `ANTQ_DEFAULT_TIMEOUT`.
| Timeout for GitHub API. +
Unit is milli sec.

| ANTQ_MAVEN_TIMEOUT
| Same as `ANTQ_DEFAULT_TIMEOUT`.
| Timeout for accessing Maven repositories. +
Unit is milli sec.

| ANTQ_POM_TIMEOUT
| Same as `ANTQ_DEFAULT_TIMEOUT`.
| Timeout for reading POM. +
Unit is milli sec.

|===
37 changes: 34 additions & 3 deletions src/antq/constant.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
(ns antq.constant)
(ns antq.constant
(:require
[antq.util.env :as u.env]))

(def retry-limit 5)
(def retry-limit
"Retry count for
- antq.util.maven/read-pom
- antq.util.git/ls-remote*"
5)

(def clojure-deps-keys #{:deps :default-deps :extra-deps :override-deps :replace-deps})
(def clojure-deps-keys
"Keys for detecting dependencies in deps.edn"
#{:deps :default-deps :extra-deps :override-deps :replace-deps})

(def default-timeout-msec
(u.env/getlong "ANTQ_DEFAULT_TIMEOUT" 10000))

(def ls-remote-timeout-msec
"Timeout msec for
- antq.util.git/ls-remote*"
(u.env/getlong "ANTQ_LS_REMOTE_TIMEOUT" default-timeout-msec))

(def github-api-timeout-msec
"Timeout msec for
- antq.ver.github-tag/get-sorted-versions-by-ls-remote*"
(u.env/getlong "ANTQ_GITHUB_API_TIMEOUT" default-timeout-msec))

(def maven-timeout-msec
"Timeout msec for
- antq.ver.java/get-versions"
(u.env/getlong "ANTQ_MAVEN_TIMEOUT" default-timeout-msec))

(def pom-timeout-msec
"Timeout msec for
- antq.util.maven/read-pom*"
(u.env/getlong "ANTQ_POM_TIMEOUT" default-timeout-msec))
24 changes: 17 additions & 7 deletions src/antq/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
[antq.upgrade.leiningen]
[antq.upgrade.pom]
[antq.upgrade.shadow]
[antq.util.exception :as u.ex]
[antq.util.maven :as u.maven]
[antq.ver :as ver]
[antq.ver.git-sha]
Expand All @@ -44,7 +45,9 @@
[antq.ver.java]
[clojure.string :as str]
[clojure.tools.cli :as cli]
[version-clj.core :as version]))
[version-clj.core :as version])
(:import
clojure.lang.ExceptionInfo))

(defn- concat-assoc-fn
[opt k v]
Expand Down Expand Up @@ -117,7 +120,9 @@

(defn- assoc-versions
[dep options]
(assoc dep :_versions (ver/get-sorted-versions dep options)))
(let [res (assoc dep :_versions (ver/get-sorted-versions dep options))]
(report/run-progress dep options)
res))

(defn latest
[arg-map]
Expand Down Expand Up @@ -169,9 +174,9 @@
(let [org-deps (remove #(or (skip-artifacts? % options)
(using-release-version? %))
deps)
uniq-deps-with-vers (->> org-deps
distinct-deps
(pmap #(assoc-versions % options)))
uniq-deps (distinct-deps org-deps)
_ (report/init-progress uniq-deps options)
uniq-deps-with-vers (pmap #(assoc-versions % options) uniq-deps)
assoc-latest-version* #(assoc-latest-version % options)]
(->> org-deps
(pmap #(complete-versions-by % uniq-deps-with-vers))
Expand All @@ -181,7 +186,10 @@

(defn assoc-diff-url
[version-checked-dep]
(if-let [url (diff/get-diff-url version-checked-dep)]
(if-let [url (try (diff/get-diff-url version-checked-dep)
(catch ExceptionInfo ex
(when-not (u.ex/ex-timeout? ex)
(throw ex))))]
(assoc version-checked-dep :diff-url url)
version-checked-dep))

Expand Down Expand Up @@ -236,13 +244,15 @@

(defn antq
[options deps]
(let [deps (->> deps
(let [alog (log/start-async-logger!)
deps (->> deps
(mark-only-newest-version-flag)
(unify-deps-having-only-newest-version-flag))
outdated (->> (outdated-deps deps options)
(map assoc-diff-url)
(concat (unverified-deps deps)))]
(report/reporter outdated options)
(log/stop-async-logger! alog)
outdated))

(defn main*
Expand Down
9 changes: 6 additions & 3 deletions src/antq/dep/gradle.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

(defn- get-repositories
[file-path]
(let [{:keys [exit out]} (sh/sh gradle-command "--build-file" file-path
(let [parent-path (.getParent (io/file file-path))
{:keys [exit out]} (sh/sh gradle-command
"--project-dir" parent-path
"antq_list_repositories")]
(when (= 0 exit)
(->> (str/split-lines out)
Expand All @@ -24,8 +26,9 @@

(defn- filter-deps-from-gradle-dependencies
[file-path]
(let [{:keys [exit out]} (sh/sh gradle-command
"--build-file" file-path
(let [parent-path (.getParent (io/file file-path))
{:keys [exit out]} (sh/sh gradle-command
"--project-dir" parent-path
"--quiet"
"dependencies")]
(if (= 0 exit)
Expand Down
41 changes: 36 additions & 5 deletions src/antq/log.clj
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
(ns antq.log)
(ns antq.log
(:require
[clojure.core.async :as async]))

(defonce logger-ch nil)

(def ^:dynamic *verbose* false)

(defn stop-async-logger!
[logger-end-ch]
(when logger-ch
(async/>!! logger-ch ::eol)
(async/<!! logger-end-ch)
(async/close! logger-ch)
(async/close! logger-end-ch)
(alter-var-root #'logger-ch (fn [_] nil))))

(defn start-async-logger!
[]
(let [end-ch (async/chan)]
(alter-var-root #'logger-ch (fn [_] (async/chan)))
(async/go-loop []
(let [v (async/<! logger-ch)]
(when (string? v)
(print v)
(flush))
(if (= ::eol v)
(async/>! end-ch ::end)
(recur))))
end-ch))

(defn info
[s]
(println s))

(defn warning
[s]
(when *verbose*
(binding [*out* *err*]
(println s))))

(defn error
[s]
(binding [*out* *err*]
(println s)))

(defn warning
(defn async-print
[s]
(when *verbose*
(binding [*out* *err*]
(println s))))
(async/>!! logger-ch s))
12 changes: 12 additions & 0 deletions src/antq/report.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,15 @@
(defmethod reporter :default
[_ options]
(log/error (str "Unknown reporter: " (:reporter options))))

(defmulti init-progress
(fn [_deps options]
(:reporter options)))

(defmethod init-progress :default [_ _] nil)

(defmulti run-progress
(fn [_dep options]
(:reporter options)))

(defmethod run-progress :default [_ _] nil)
Loading

0 comments on commit 638cde7

Please sign in to comment.