initial commit
This commit is contained in:
commit
6e190f6bb0
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
/target
|
||||||
|
/classes
|
||||||
|
/checkouts
|
||||||
|
pom.xml
|
||||||
|
pom.xml.asc
|
||||||
|
*.jar
|
||||||
|
*.class
|
||||||
|
/.lein-*
|
||||||
|
/.nrepl-port
|
||||||
|
.hgignore
|
||||||
|
.hg/
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2021 Gered King
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
29
README.md
Normal file
29
README.md
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# Leiningen Template: Simple Clojure App
|
||||||
|
|
||||||
|
A Leiningen template intended for creating new Clojure CLI app or tool projects using a simplified / stripped-down base.
|
||||||
|
|
||||||
|
This template primarily exists for my own personal use, so some stuff is definitely more oriented towards
|
||||||
|
my own particular preferences regarding setup and organization of a Clojure project.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ lein new net.gered/simple-app [your-project-name-here]
|
||||||
|
```
|
||||||
|
|
||||||
|
The resulting project starts up via a `main` function and during startup expects to be able to read an EDN configuration file
|
||||||
|
located in the current working directory called `config.edn`.
|
||||||
|
|
||||||
|
The project can be run simply by:
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ lein run
|
||||||
|
```
|
||||||
|
|
||||||
|
A nREPL server will be started which can be connected to on port 4000 (configured via the aforementioned `config.edn`).
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Copyright © 2021 Gered King
|
||||||
|
|
||||||
|
Distributed under the the MIT License. See LICENSE for more details.
|
7
project.clj
Normal file
7
project.clj
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
(defproject net.gered/lein-template.simple-app "0.1.0-SNAPSHOT"
|
||||||
|
:description "Simple Clojure non-web application project template."
|
||||||
|
:url "https://github.com/gered/simple-app-template"
|
||||||
|
:license {:name "MIT License"
|
||||||
|
:url "http://opensource.org/licenses/MIT"}
|
||||||
|
|
||||||
|
:eval-in-leiningen true)
|
1
resources/leiningen/new/simple_app/config.edn
Normal file
1
resources/leiningen/new/simple_app/config.edn
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{:nrepl {:port 4000}}
|
17
resources/leiningen/new/simple_app/gitignore
Normal file
17
resources/leiningen/new/simple_app/gitignore
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
.DS_Store
|
||||||
|
/target
|
||||||
|
/classes
|
||||||
|
/checkouts
|
||||||
|
pom.xml
|
||||||
|
pom.xml.asc
|
||||||
|
*.jar
|
||||||
|
*.class
|
||||||
|
/.lein-*
|
||||||
|
/.nrepl-port
|
||||||
|
.settings/
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.idea/
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
30
resources/leiningen/new/simple_app/project.clj
Normal file
30
resources/leiningen/new/simple_app/project.clj
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
(defproject {{name}} "0.1.0-SNAPSHOT"
|
||||||
|
|
||||||
|
:description "FIXME: write description"
|
||||||
|
:url "http://example.com/FIXME"
|
||||||
|
:license {:name "MIT License"
|
||||||
|
:url "http://opensource.org/licenses/MIT"}
|
||||||
|
|
||||||
|
:dependencies [[ch.qos.logback/logback-classic "1.2.7"]
|
||||||
|
[cprop "0.1.19"]
|
||||||
|
[mount "0.1.16"]
|
||||||
|
[nrepl "0.9.0"]
|
||||||
|
[org.clojure/clojure "1.10.0"]
|
||||||
|
[org.clojure/tools.logging "1.2.1"]]
|
||||||
|
|
||||||
|
:main {{root-ns}}.core
|
||||||
|
|
||||||
|
:repl-options {:init-ns {{root-ns}}.core}
|
||||||
|
|
||||||
|
:profiles {:dev {:source-paths ["env/dev/src"]
|
||||||
|
:resource-paths ["env/dev/resources"]
|
||||||
|
:dependencies [[pjstadig/humane-test-output "0.11.0"]]
|
||||||
|
:injections [(require 'pjstadig.humane-test-output)
|
||||||
|
(pjstadig.humane-test-output/activate!)]}
|
||||||
|
|
||||||
|
:uberjar {:source-paths ["env/prod/src"]
|
||||||
|
:resource-paths ["env/prod/resources"]
|
||||||
|
:omit-source true
|
||||||
|
:aot :all}}
|
||||||
|
|
||||||
|
:aliases {"uberjar" ["do" ["clean"] ["uberjar"]]})
|
12
resources/leiningen/new/simple_app/resources/logback.xml
Normal file
12
resources/leiningen/new/simple_app/resources/logback.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration>
|
||||||
|
<appender name="C" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{ISO8601} %-5p [%c] - %m%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="${ROOT_LEVEL:-INFO}">
|
||||||
|
<appender-ref ref="C"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
34
resources/leiningen/new/simple_app/src/root_ns/core.clj
Normal file
34
resources/leiningen/new/simple_app/src/root_ns/core.clj
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
(ns {{root-ns}}.core
|
||||||
|
(:gen-class)
|
||||||
|
(:require
|
||||||
|
[clojure.tools.logging :as log]
|
||||||
|
[cprop.core :refer [load-config]]
|
||||||
|
[mount.core :as mount :refer [defstate]]
|
||||||
|
[nrepl.server :as nrepl]))
|
||||||
|
|
||||||
|
;;
|
||||||
|
;; TODO: other app stuff goes here ...
|
||||||
|
;;
|
||||||
|
|
||||||
|
(defstate ^{:on-reload :noop} config
|
||||||
|
:start
|
||||||
|
(do
|
||||||
|
(log/info "Loading config.edn")
|
||||||
|
(load-config :file "config.edn")))
|
||||||
|
|
||||||
|
(defstate ^{:on-reload :noop} repl-server
|
||||||
|
:start
|
||||||
|
(let [{:keys [port bind socket]} (:nrepl config)
|
||||||
|
server (nrepl/start-server :port port :bind bind :socket socket)]
|
||||||
|
(log/info "Started nREPL server:" (:server-socket server))
|
||||||
|
server)
|
||||||
|
:stop
|
||||||
|
(when repl-server
|
||||||
|
(log/info "Stopping nREPL server")
|
||||||
|
(nrepl/stop-server repl-server)))
|
||||||
|
|
||||||
|
(defn -main
|
||||||
|
[& args]
|
||||||
|
(log/info "{{name}} is starting up ...")
|
||||||
|
(mount/start-with-args args)
|
||||||
|
(log/info "Ready!"))
|
|
@ -0,0 +1,4 @@
|
||||||
|
(ns {{root-ns}}.core-test
|
||||||
|
(:require
|
||||||
|
[clojure.test :refer :all]
|
||||||
|
[{{root-ns}}.core :refer :all]))
|
26
src/leiningen/new/simple_app.clj
Normal file
26
src/leiningen/new/simple_app.clj
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
(ns leiningen.new.simple-app
|
||||||
|
(:require
|
||||||
|
[leiningen.new.templates :as t]
|
||||||
|
[leiningen.core.main :as main]))
|
||||||
|
|
||||||
|
(def render (t/renderer "simple_app"))
|
||||||
|
|
||||||
|
(defn simple-app
|
||||||
|
[name]
|
||||||
|
(let [data {:name name
|
||||||
|
:sanitized (t/sanitize name)
|
||||||
|
:root-ns (t/sanitize-ns name)
|
||||||
|
:root-ns-path (t/name-to-path name)}]
|
||||||
|
(main/info (str "Creating new project via net.gered/simple-app called \"" name "\" ..."))
|
||||||
|
(t/->files
|
||||||
|
data
|
||||||
|
"env/dev/resources"
|
||||||
|
"env/dev/src"
|
||||||
|
"env/prod/resources"
|
||||||
|
"env/prod/src"
|
||||||
|
["resources/logback.xml" (render "resources/logback.xml" data)]
|
||||||
|
["src/{{root-ns-path}}/core.clj" (render "src/root_ns/core.clj" data)]
|
||||||
|
["test/{{root-ns-path}}/core_test.clj" (render "test/root_ns/core_test.clj" data)]
|
||||||
|
[".gitignore" (render "gitignore" data)]
|
||||||
|
["config.edn" (render "config.edn" data)]
|
||||||
|
["project.clj" (render "project.clj" data)])))
|
Loading…
Reference in a new issue