Working towards lein-adl

This commit is contained in:
Simon Brooke 2018-07-21 11:50:38 +01:00
parent 3b11b678a1
commit 912d417cb6
3 changed files with 88 additions and 90 deletions

View file

@ -2,4 +2,5 @@
:port 8765
:site-title "Project Hope"
:site-logo "img/ProjectHopeLogo.png"
:motd "motd.md"}
:motd "motd.md"
:app-context "/youyesyet"}

View file

@ -54,7 +54,8 @@
:main ^:skip-aot youyesyet.core
:migratus {:store :database :db ~(get (System/getenv) "DATABASE_URL")}
:plugins [[lein-cljsbuild "1.1.4"]
:plugins [[lein-adl ["0.1.1"]]
[lein-cljsbuild "1.1.4"]
[lein-codox "0.10.3"]
[lein-cprop "1.0.1"]
[lein-less "1.7.5"]
@ -64,7 +65,6 @@
[migratus-lein "0.4.2"]
[org.clojars.punkisdead/lein-cucumber "1.0.5"]]
:cucumber-feature-paths ["test/clj/features"]
:codox {:metadata {:doc "FIXME: write docs"}
@ -82,101 +82,95 @@
:release-tasks [["vcs" "assert-committed"]
["change" "version" "leiningen.release/bump-version" "release"]
["adl"]
["vcs" "commit"]
;; ["vcs" "tag"] -- not working, problems with secret key
["clean"]
["npm" "install"]
["ring" "uberjar"]
["uberjar"]
[uberwar]
["docker" "build"]
["docker" "push"]
["change" "version" "leiningen.release/bump-version"]
["vcs" "commit"]]
:uberwar
{:handler youyesyet.handler/app
:init youyesyet.handler/init
:destroy youyesyet.handler/destroy
:name "youyesyet.war"}
:uberwar {:handler youyesyet.handler/app
:init youyesyet.handler/init
:destroy youyesyet.handler/destroy
:name "youyesyet.war"}
:clean-targets ^{:protect false}
[:target-path [:cljsbuild :builds :app :compiler :output-dir]
[:cljsbuild :builds :app :compiler :output-to]]
:clean-targets ^{:protect false} [:target-path [:cljsbuild :builds :app :compiler :output-dir]
[:cljsbuild :builds :app :compiler :output-to]]
:figwheel
{:http-server-root "public"
:nrepl-port 7002
:css-dirs ["resources/public/css"]
:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
:figwheel {:http-server-root "public"
:nrepl-port 7002
:css-dirs ["resources/public/css"]
:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
:profiles
{:uberjar {:omit-source true
:prep-tasks ["compile" ["cljsbuild" "once" "min"]]
:cljsbuild
{:builds
{:min
{:source-paths ["src/cljc" "src/cljs" "env/prod/cljs"]
:compiler
{:output-to "target/cljsbuild/public/js/app.js"
:optimizations :advanced
:pretty-print false
:closure-warnings
{:externs-validation :off :non-standard-jsdoc :off}
:externs ["react/externs/react.js"]}}}}
:profiles {:uberjar {:omit-source true
:prep-tasks ["adl" "compile" ["cljsbuild" "once" "min"]]
:cljsbuild
{:builds
{:min
{:source-paths ["src/cljc" "src/cljs" "env/prod/cljs"]
:compiler
{:output-to "target/cljsbuild/public/js/app.js"
:optimizations :advanced
:pretty-print false
:closure-warnings
{:externs-validation :off :non-standard-jsdoc :off}
:externs ["react/externs/react.js"]}}}}
:aot :all
:uberjar-name "youyesyet.jar"
:source-paths ["env/prod/clj"]
:resource-paths ["env/prod/resources"]}
:dev [:project/dev :profiles/dev]
:aot :all
:uberjar-name "youyesyet.jar"
:source-paths ["env/prod/clj"]
:resource-paths ["env/prod/resources"]}
:test [:project/dev :project/test :profiles/test]
:dev [:project/dev :profiles/dev]
:test [:project/dev :project/test :profiles/test]
:project/dev {:dependencies [[prone "1.1.4"]
[ring/ring-mock "0.3.0"]
[ring/ring-devel "1.5.1"]
[org.webjars/webjars-locator-jboss-vfs "0.1.0"]
[luminus-immutant "0.2.3"]
[pjstadig/humane-test-output "0.8.1"]
[binaryage/devtools "0.9.2"]
[com.cemerick/piggieback "0.2.2-SNAPSHOT"]
[directory-naming/naming-java "0.8"]
[doo "0.1.7"]
[figwheel-sidecar "0.5.15"]]
:plugins [[com.jakemccrary/lein-test-refresh "0.18.1"]
[lein-doo "0.1.7"]
[lein-figwheel "0.5.15"]
[org.clojure/clojurescript "1.9.495"]]
:cljsbuild
{:builds
{:app
{:source-paths ["src/cljs" "src/cljc" "env/dev/cljs"]
:compiler
{:main "youyesyet.canvasser-app.app"
:asset-path "/js/out"
:output-to "target/cljsbuild/public/js/app.js"
:output-dir "target/cljsbuild/public/js/out"
:source-map true
:optimizations :none
:pretty-print true}}}}
:doo {:build "test"}
:source-paths ["env/dev/clj"]
:resource-paths ["env/dev/resources"]
:repl-options {:init-ns user}
:injections [(require 'pjstadig.humane-test-output)
(pjstadig.humane-test-output/activate!)]}
:project/test {:resource-paths ["env/test/resources"]
:cljsbuild
{:builds
{:test
{:source-paths ["src/cljc" "src/cljs" "test/cljs"]
:compiler
{:output-to "target/test.js"
:main "youyesyet.doo-runner"
:optimizations :whitespace
:pretty-print true}}}}
}
:profiles/dev {}
:profiles/test {}})
:project/dev {:dependencies [[prone "1.1.4"]
[ring/ring-mock "0.3.0"]
[ring/ring-devel "1.5.1"]
[org.webjars/webjars-locator-jboss-vfs "0.1.0"]
[luminus-immutant "0.2.3"]
[pjstadig/humane-test-output "0.8.1"]
[binaryage/devtools "0.9.2"]
[com.cemerick/piggieback "0.2.2-SNAPSHOT"]
[directory-naming/naming-java "0.8"]
[doo "0.1.7"]
[figwheel-sidecar "0.5.15"]]
:plugins [[com.jakemccrary/lein-test-refresh "0.18.1"]
[lein-doo "0.1.7"]
[lein-figwheel "0.5.15"]
[org.clojure/clojurescript "1.9.495"]]
:cljsbuild {:builds
{:app
{:source-paths ["src/cljs" "src/cljc" "env/dev/cljs"]
:compiler
{:main "youyesyet.canvasser-app.app"
:asset-path "/js/out"
:output-to "target/cljsbuild/public/js/app.js"
:output-dir "target/cljsbuild/public/js/out"
:source-map true
:optimizations :none
:pretty-print true}}}}
:doo {:build "test"}
:source-paths ["env/dev/clj"]
:resource-paths ["env/dev/resources"]
:repl-options {:init-ns user}
:injections [(require 'pjstadig.humane-test-output)
(pjstadig.humane-test-output/activate!)]}
:project/test {:resource-paths ["env/test/resources"]
:cljsbuild
{:builds
{:test
{:source-paths ["src/cljc" "src/cljs" "test/cljs"]
:compiler
{:output-to "target/test.js"
:main "youyesyet.doo-runner"
:optimizations :whitespace
:pretty-print true}}}}}
:profiles/dev {}
:profiles/test {}})

View file

@ -20,14 +20,17 @@
;; (for example when using mock requests), then
;; .getContextPath might not exist
(try (.getContextPath ^ServletContext context)
(catch IllegalArgumentException err
(log/warn "Failed to initialise servlet-context: " (.getMessage err))
context))
(catch IllegalArgumentException err
(log/warn "Failed to initialise *app-context*: " (.getMessage err))
context))
;; if the context is not specified in the request
;; we check if one has been specified in the environment
;; instead
(:app-context env))]
(handler request))))
(do
(log/info "Taking '" (:app-context env) "' as *app-context* from env")
(:app-context env)))]
(log/debug "Using '" *app-context* "' as *app-context*")
(handler (assoc request :servlet-context *app-context*)))))
(defn wrap-internal-error [handler]