Description:
Initial working version.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r0:5847e68f6afb -

@@ -0,0 +1,15
1 syntax: glob
2 pom.xml
3 pom.xml.asc
4 *.jar
5 *.class
6 .gitignore
7 .git/**
8 node_modules/*
9
10 syntax: regexp
11 ^.nrepl-port
12 ^.lein-.*
13 ^target/
14 ^classes/
15 ^checkouts/
@@ -0,0 +1,38
1 (defproject project-checkup "0.1.0-SNAPSHOT"
2 :description "FIXME: write description"
3 :url "http://example.com/FIXME"
4 :license {:name "Eclipse Public License"
5 :url "http://www.eclipse.org/legal/epl-v10.html"}
6 :dependencies [[org.clojure/clojure "1.8.0"]
7 [org.clojure/clojurescript "1.9.521"]
8 ; [andare "0.9.0"]
9 [org.clojure/core.async "0.4.474"]
10
11 ]
12
13 :plugins [[lein-cljsbuild "1.1.5"]]
14
15 :cljsbuild {:builds [{:id "development"
16 :source-paths ["src"]
17 :compiler {:main project-checkup.core
18 :output-to "package/index.js"
19 :target :nodejs
20 :output-dir "target/development"
21 :install-deps true
22 :optimizations :none
23 :pretty-print true
24 :parallel-build true}}
25 {:id "optimized"
26 :source-paths ["src"]
27 :compiler {:main project-checkup.core
28 :output-to "package/index.js"
29 :target :nodejs
30 :output-dir "target/optimized"
31 ;; :externs ["externs.js"]
32 :install-deps true
33 :optimizations :advanced
34 :pretty-print true
35 :parallel-build true}}]}
36 :main ^:skip-aot project-checkup.core
37 :target-path "target/%s"
38 :profiles {:uberjar {:aot :all}})
@@ -0,0 +1,90
1 #!/usr/bin/env lumo
2 (ns project-checkup.core
3 (:gen-class)
4 (:require [clojure.java.shell :as shell]
5 [clojure.string :as string]))
6
7 (defn get-extension [path] (re-find #"\.[a-zA-Z]+" path))
8
9 (defn gather-project-info
10 "Creates a dictionary of project information"
11 []
12 (let [files (set (map str (file-seq (clojure.java.io/file "."))))]
13 {:files files
14 :extensions (frequencies (map get-extension files ))
15 :path (:out (shell/sh "pwd"))
16 :untracked-files (string/split (:out (shell/sh "hg" "st" "-u" "-n")) #"\n") }))
17
18 (defn color [color string]
19 (let [color-sequence (case color
20 :green "\u001B[32m"
21 :yellow "\u001B[33m"
22 :blue "\u001B[34m"
23 )
24 reset "\u001B[m" ]
25 (str color-sequence string reset)) )
26
27
28 (defn check-vcs [project]
29 (let [{files :files } project]
30 (boolean (some #{"./.git" "./.hg"} files)) ))
31
32 (defn check-readme [project]
33 (let [{files :files } project]
34 (boolean (some #{"./README.md" "./README.txt" "./README.mkd"} files)) ))
35
36 (defn check-untracked [project]
37 (let [{untracked :untracked-files } project]
38 (= (count untracked) 0)) )
39
40 (defn check-taskpaper [project]
41 (let [{extensions :extensions } project]
42 (>= (get ".taskpaper" extensions 0) 1) ))
43
44 (def checks [{:name "Has VCS"
45 :description ""
46 :function check-vcs
47 :level :error
48 :follow-up "Initialize a repository." }
49 {:name "Always True"
50 :function #(or true %)
51 :level :error
52 :follow-up "This is a bug." }
53 {:name "Has Untracked"
54 :description ""
55 :function check-untracked
56 :level :warning
57 :follow-up "Commit or ignore files from 'hg st -u'." }
58 {:name "No Todo"
59 :function check-taskpaper
60 :description ""
61 :level :suggestion
62 :follow-up "Add a todo file using Taskpaper." }
63 {:name "Has Readme"
64 :function check-readme
65 :description "Readme exists"
66 :level :suggestion
67 :follow-up "Add a README." } ])
68
69 (defn perform-check [check project]
70 (let [{check-name :name function :function follow-up :follow-up
71 level :level } check
72 result (function project)
73 false-color (case level
74 :suggestion :blue
75 :warning :yellow
76 :error :red
77 :red) ]
78 {:name check-name
79 :result result
80 :output (if result
81 (color :green (str "✓" check-name " passed!"))
82 (str check-name (color false-color " failed! ") "\n\tFollow up: " follow-up))}))
83
84
85 (defn -main
86 "I don't do a whole lot ... yet."
87 [& args]
88 (doseq [check checks]
89 (println (:output (perform-check check (gather-project-info) ))))
90 (shutdown-agents) )
You need to be logged in to leave comments. Login now