Skip to content

Commit

Permalink
Print included openapi spec versions with app version
Browse files Browse the repository at this point in the history
  • Loading branch information
joodie committed Jan 31, 2024
1 parent 981f04e commit 61550b3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{:paths ["profiles" "src"]
:deps {nl.surf/apie {:git/url "https://github.com/SURFnet/apie.git"
:git/sha "b20c848b9898df038ebd582a913c7feac03ac899"}}
:git/sha "2d2cea531b3d29eb2ea4f4df46feb0f8ff5fb921"}}
:aliases {:test {:extra-deps {lambdaisland/kaocha {:mvn/version "RELEASE"}}
:main-opts ["-m" "kaocha.runner"]}
:clj-kondo {:replace-deps {clj-kondo/clj-kondo {:mvn/version "RELEASE"}}
Expand Down
28 changes: 24 additions & 4 deletions src/nl/surf/eduhub_validator/main.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns nl.surf.eduhub-validator.main
(:require [clojure.java.io :as io]
(:require [babashka.json :as json]
[clojure.java.io :as io]
[clojure.string :as string]
[clojure.tools.cli :refer [parse-opts]]
[nl.jomco.apie.main :as apie]))
Expand All @@ -21,18 +22,37 @@
option))
apie/cli-options))

(defn version
"Return app version"
(defn app-version
"Return version of app."
[]
(when-let [r (io/resource "nl/surf/eduhub_validator/version.txt")]
(string/trim (slurp r))))

(defn spec-version
"Return version of openapi spec for built-in profile."
[profile]
(-> profile
apie/file-or-resource
apie/read-edn
:openapi-spec
apie/file-or-resource
apie/read-json
(get-in ["info" "version"])))

(defn versions
"Return version of app and included openapi specs."
[]
(str "eduhub-validator " (app-version) "\n"
"included profiles:\n"
(string/join "\n" (map (fn [p]
(str " - " p " " (spec-version p)))
included-profiles))))

(defn -main
[& args]
(let [{:keys [errors summary options]} (parse-opts args cli-options)]
(when (:print-version? options)
(println (version))
(println (versions))
(System/exit 0))
(when (seq errors)
(run! println errors)
Expand Down

0 comments on commit 61550b3

Please sign in to comment.