Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Miikka Koskinen committed Jul 22, 2019
0 parents commit 4e5e9b8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.cpcache/
target/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# clj-nvd

A sketch of using [lein-nvd](https://github.com/rm-hull/lein-nvd) with deps.edn.
3 changes: 3 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{:deps {nvd-clojure {:mvn/version "1.1.1"}
metosin/jsonista {:mvn/version "0.2.3"}
org.clojure/tools.deps.alpha {:mvn/version "0.7.527" :exclusions [org.slf4j/slf4j-nop]}}}
33 changes: 33 additions & 0 deletions src/clj_nvd/core.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
(ns clj-nvd.core
(:require [clojure.java.io :as io]
[clojure.tools.deps.alpha :as deps]
[clojure.tools.deps.alpha.reader :as deps.reader]
[jsonista.core :as json]
[nvd.task.check]
[nvd.task.purge-database]
[nvd.task.update-database]))

(defn make-classpath []
(let [lib-map (-> (deps.reader/read-deps [(io/file "deps.edn")])
(deps/resolve-deps nil))]
(mapcat :paths (vals lib-map))))

(defn -main [command & args]
(let [config (try
(read-string (slurp "clj-nvd.edn"))
(catch java.io.FileNotFoundException _
nil))
temp-file (java.io.File/createTempFile "clj-nvd" ".json")
path (.getAbsolutePath temp-file)
classpath (make-classpath)
opts {:nvd config
:classpath classpath
:cmd-args args}]
(spit path (json/write-value-as-string opts))
(case command
"check" (nvd.task.check/-main path)
"purge" (nvd.task.purge-database/-main path)
"update" (nvd.task.update-database/-main path)
(do
(.println *err* (str "No such command: " command))
(System/exit 1)))))

0 comments on commit 4e5e9b8

Please sign in to comment.