├── README.md ├── deps.edn ├── .gitignore └── src └── spootnik └── deps_check.clj /README.md: -------------------------------------------------------------------------------- 1 | # deps-check: namespace checker 2 | 3 | documentation coming soon 4 | -------------------------------------------------------------------------------- /deps.edn: -------------------------------------------------------------------------------- 1 | {:paths ["src"] 2 | :deps {org.clojure/clojure {:mvn/version "1.11.1"} 3 | timofreiberg/bultitude {:mvn/version "0.3.1"}} 4 | :aliases 5 | {:build {:extra-deps {slipset/deps-deploy {:mvn/version "RELEASE"} 6 | io.github.clojure/tools.build {:git/tag "v0.8.2" :git/sha "ba1a2bf"}} 7 | :paths ["src" "build"] 8 | :ns-default build}} 9 | :tools/usage {:ns-default spootnik.deps-check}} 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .calva/output-window/ 2 | .classpath 3 | .clj-kondo/.cache 4 | .cpcache 5 | .eastwood 6 | .factorypath 7 | .hg/ 8 | .hgignore 9 | .java-version 10 | .lein-* 11 | .lsp/.cache 12 | .lsp/sqlite.db 13 | .nrepl-history 14 | .nrepl-port 15 | .project 16 | .rebel_readline_history 17 | .settings 18 | .socket-repl-port 19 | .sw* 20 | .vscode 21 | *.class 22 | *.jar 23 | *.swp 24 | *~ 25 | /checkouts 26 | /classes 27 | /target 28 | **/resources/git-version 29 | .clj-kondo/.cache 30 | pom.xml 31 | pom.properties -------------------------------------------------------------------------------- /src/spootnik/deps_check.clj: -------------------------------------------------------------------------------- 1 | (ns spootnik.deps-check 2 | "Inspired from https://github.com/athos/clj-check" 3 | (:require [bultitude.core :as bultitude] 4 | [clojure.java.io :as io] 5 | [clojure.string :as str])) 6 | 7 | (defn- file-for 8 | [ns] 9 | (-> ns 10 | name 11 | (str/replace \- \_) 12 | (str/replace \. \/))) 13 | 14 | (defn- check-ns 15 | [ns] 16 | (println "compiling namespace" ns) 17 | (try 18 | (binding [*warn-on-reflection* true] 19 | (load (file-for ns))) 20 | nil 21 | (catch Exception e 22 | (binding [*out* *err*] 23 | (println "failed to load namespace" ns ":" (ex-message (ex-cause e))) 24 | ns)))) 25 | 26 | (defn- find-namespaces 27 | [dirs] 28 | (bultitude/namespaces-on-classpath 29 | :classpath (map io/file dirs) 30 | :ignore-unreadable? false)) 31 | 32 | (defn check 33 | [{:keys [paths] :as opts}] 34 | (let [namespaces (find-namespaces paths) 35 | errored-namespaces (into [] (remove nil?) (map check-ns namespaces))] 36 | (when (seq errored-namespaces) 37 | (binding [*out* *err*] 38 | (println "the following namespaces failed to load:" errored-namespaces) 39 | (System/exit 1))) 40 | (shutdown-agents)) 41 | opts) 42 | --------------------------------------------------------------------------------