jar stuff. rename ns
This commit is contained in:
parent
c226669a09
commit
f448684b30
14 changed files with 144 additions and 20 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -12,3 +12,5 @@
|
||||||
.clj-kondo/
|
.clj-kondo/
|
||||||
.lsp/
|
.lsp/
|
||||||
.portal/
|
.portal/
|
||||||
|
*.jar
|
||||||
|
*.db
|
||||||
|
|
|
||||||
6
Makefile
6
Makefile
|
|
@ -4,7 +4,7 @@ tidy:
|
||||||
|
|
||||||
.PHONY: storage/site.db
|
.PHONY: storage/site.db
|
||||||
storage/site.db:
|
storage/site.db:
|
||||||
rm -f storage/*
|
rm -f storage/site.db*
|
||||||
sqlite3 storage/site.db 'PRAGMA journal_mode=WAL;'
|
sqlite3 storage/site.db 'PRAGMA journal_mode=WAL;'
|
||||||
clj -M dev/migration.clj
|
clj -M dev/migration.clj
|
||||||
uv run dev/sqlite-history.py
|
uv run dev/sqlite-history.py
|
||||||
|
|
@ -14,3 +14,7 @@ db: storage/site.db
|
||||||
|
|
||||||
repl: storage/site.db
|
repl: storage/site.db
|
||||||
clj -M:dev dev
|
clj -M:dev dev
|
||||||
|
|
||||||
|
jar: db
|
||||||
|
clojure -T:build uberjar
|
||||||
|
mv target/*.jar .
|
||||||
|
|
|
||||||
24
build.clj
Normal file
24
build.clj
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
(ns build
|
||||||
|
(:require [clojure.tools.build.api :as b]
|
||||||
|
[clojure.edn :as edn]))
|
||||||
|
|
||||||
|
(def class-dir "target/classes")
|
||||||
|
|
||||||
|
(def basis (delay (b/create-basis {:project "deps.edn"})))
|
||||||
|
|
||||||
|
(def jar-file "target/score-the-pigs.jar")
|
||||||
|
|
||||||
|
(defn clean [_]
|
||||||
|
(b/delete {:path "target"}))
|
||||||
|
|
||||||
|
(defn uberjar [_]
|
||||||
|
(clean nil)
|
||||||
|
(b/copy-dir {:src-dirs ["src" "resources"]
|
||||||
|
:target-dir class-dir})
|
||||||
|
(b/compile-clj {:basis @basis
|
||||||
|
:src-dirs ["src"]
|
||||||
|
:class-dir class-dir})
|
||||||
|
(b/uber {:class-dir class-dir
|
||||||
|
:uber-file jar-file
|
||||||
|
:basis @basis
|
||||||
|
:main 'com.score-the-pigs}))
|
||||||
6
deps.edn
6
deps.edn
|
|
@ -43,4 +43,8 @@
|
||||||
:prod {:jvm-opts ["-XX:-OmitStackTraceInFastThrow"
|
:prod {:jvm-opts ["-XX:-OmitStackTraceInFastThrow"
|
||||||
"-XX:+CrashOnOutOfMemoryError"
|
"-XX:+CrashOnOutOfMemoryError"
|
||||||
"-Dbiff.env.BIFF_PROFILE=prod"]
|
"-Dbiff.env.BIFF_PROFILE=prod"]
|
||||||
:main-opts ["-m" "com.biffweb.my-project"]}}}
|
:main-opts ["-m" "com.biffweb.my-project"]}
|
||||||
|
:build {:deps {io.github.clojure/tools.build {:git/tag "v0.10.7"
|
||||||
|
:git/sha "573711e"}
|
||||||
|
slipset/deps-deploy {:mvn/version "0.2.2"}}
|
||||||
|
:ns-default build}}}
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[clojure.tools.namespace.repl :as tn-repl]
|
[clojure.tools.namespace.repl :as tn-repl]
|
||||||
[com.biffweb.my-project :as main :refer [system]]
|
[com.score-the-pigs :as main :refer [system]]
|
||||||
[com.biffweb.my-project.util.db :as db]
|
[com.score-the-pigs.util.db :as db]
|
||||||
[honey.sql :as sql]
|
[honey.sql :as sql]
|
||||||
[honey.sql.helpers :refer [drop-table]]
|
[honey.sql.helpers :refer [drop-table]]
|
||||||
[next.jdbc :as jdbc]))
|
[next.jdbc :as jdbc]))
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@
|
||||||
:default "localhost"}
|
:default "localhost"}
|
||||||
:biff/port 8080
|
:biff/port 8080
|
||||||
|
|
||||||
:example/db-url #profile {:prod "jdbc:sqlite:storage/site.db"
|
:example/db-url "jdbc:sqlite:storage/site.db"
|
||||||
:dev "jdbc:sqlite:storage/site.db"}
|
|
||||||
|
|
||||||
:biff.beholder/enabled #profile {:dev true
|
:biff.beholder/enabled #profile {:dev true
|
||||||
:default false}
|
:default false}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
(:require
|
(:require
|
||||||
[clojure.test :as test]
|
[clojure.test :as test]
|
||||||
[com.biffweb :as biff]
|
[com.biffweb :as biff]
|
||||||
[com.biffweb.my-project.app :as app]
|
[com.score-the-pigs.app :as app]
|
||||||
[com.biffweb.my-project.middleware :as mid]
|
[com.score-the-pigs.middleware :as mid]
|
||||||
[com.biffweb.my-project.ui :as ui]
|
[com.score-the-pigs.ui :as ui]
|
||||||
[migratus.core :as migratus]
|
[migratus.core :as migratus]
|
||||||
[next.jdbc :as jdbc]
|
[next.jdbc :as jdbc]
|
||||||
[nrepl.cmdline :as nrepl-cmd]
|
[nrepl.cmdline :as nrepl-cmd]
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
(ns com.biffweb.my-project.settings)
|
|
||||||
|
|
||||||
(def app-name "my_project")
|
|
||||||
91
src/com/score_the_pigs.clj
Normal file
91
src/com/score_the_pigs.clj
Normal file
|
|
@ -0,0 +1,91 @@
|
||||||
|
(ns com.score-the-pigs
|
||||||
|
(:require
|
||||||
|
[clojure.pprint :as pp]
|
||||||
|
[clojure.test :as test]
|
||||||
|
[com.biffweb :as biff]
|
||||||
|
[com.score-the-pigs.app :as app]
|
||||||
|
[com.score-the-pigs.middleware :as mid]
|
||||||
|
[com.score-the-pigs.ui :as ui]
|
||||||
|
[migratus.core :as migratus]
|
||||||
|
[next.jdbc :as jdbc]
|
||||||
|
[nrepl.cmdline :as nrepl-cmd]
|
||||||
|
[taoensso.telemere.timbre :as log])
|
||||||
|
(:gen-class))
|
||||||
|
|
||||||
|
(def modules
|
||||||
|
[app/module])
|
||||||
|
|
||||||
|
(def routes [["" {:middleware [mid/wrap-site-defaults]}
|
||||||
|
(keep :routes modules)]
|
||||||
|
["" {:middleware [mid/wrap-api-defaults]}
|
||||||
|
(keep :api-routes modules)]])
|
||||||
|
|
||||||
|
(def handler (-> (biff/reitit-handler {:routes routes})
|
||||||
|
mid/wrap-base-defaults))
|
||||||
|
|
||||||
|
(def static-pages (apply biff/safe-merge (map :static modules)))
|
||||||
|
|
||||||
|
(defn generate-assets! [_ctx]
|
||||||
|
(biff/export-rum static-pages "target/resources/public")
|
||||||
|
(biff/delete-old-files {:dir "target/resources/public"
|
||||||
|
:exts [".html"]}))
|
||||||
|
|
||||||
|
(defn on-save [ctx]
|
||||||
|
(biff/add-libs)
|
||||||
|
(biff/eval-files! ctx)
|
||||||
|
(generate-assets! ctx)
|
||||||
|
(biff/catchall (require 'com.biffweb.my-project-test))
|
||||||
|
(test/run-all-tests #"com.biffweb.my-project.*-test"))
|
||||||
|
|
||||||
|
(def initial-system
|
||||||
|
{:biff/modules #'modules
|
||||||
|
:biff/merge-context-fn identity
|
||||||
|
:biff/handler #'handler
|
||||||
|
:biff.beholder/on-save #'on-save
|
||||||
|
:biff.middleware/on-error #'ui/on-error
|
||||||
|
:example/chat-clients (atom {})})
|
||||||
|
|
||||||
|
(defonce system (atom {}))
|
||||||
|
|
||||||
|
(defn ctx->migratus-config [ctx]
|
||||||
|
{:store :database
|
||||||
|
:migration-dir "migrations/"
|
||||||
|
:db {:connection (jdbc/get-connection (:example/db-url ctx))
|
||||||
|
:managed-connection? true}})
|
||||||
|
|
||||||
|
(defn use-sqlite [ctx]
|
||||||
|
(let [db-url (get ctx :example/db-url)
|
||||||
|
ds (jdbc/get-datasource db-url)
|
||||||
|
;; migration-config (ctx->migratus-config ctx)
|
||||||
|
]
|
||||||
|
|
||||||
|
;; (migratus/init migration-config)
|
||||||
|
;; (migratus/migrate migration-config)
|
||||||
|
(assoc ctx :example/ds ds)))
|
||||||
|
|
||||||
|
(def components
|
||||||
|
[biff/use-aero-config
|
||||||
|
use-sqlite
|
||||||
|
biff/use-queues
|
||||||
|
biff/use-htmx-refresh
|
||||||
|
biff/use-jetty
|
||||||
|
biff/use-chime
|
||||||
|
biff/use-beholder])
|
||||||
|
|
||||||
|
(defn start []
|
||||||
|
(let [new-system (reduce (fn [system component]
|
||||||
|
(pp/pprint system)
|
||||||
|
(log/info "starting:" (str component))
|
||||||
|
(component system))
|
||||||
|
initial-system
|
||||||
|
components)]
|
||||||
|
(reset! system new-system)
|
||||||
|
(generate-assets! new-system)
|
||||||
|
(log/info "System started.")
|
||||||
|
(log/info "Go to" (:biff/base-url new-system))
|
||||||
|
new-system))
|
||||||
|
|
||||||
|
(defn -main []
|
||||||
|
(let [{:keys [biff.nrepl/args]} (start)]
|
||||||
|
(apply nrepl-cmd/-main args)))
|
||||||
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
(ns com.biffweb.my-project.app
|
(ns com.score-the-pigs.app
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[com.biffweb :as biff]
|
[com.biffweb :as biff]
|
||||||
[com.biffweb.my-project.middleware :refer [wrap-clean-up-param-vals]]
|
[com.score-the-pigs.middleware :refer [wrap-clean-up-param-vals]]
|
||||||
[com.biffweb.my-project.settings :as settings]
|
[com.score-the-pigs.settings :as settings]
|
||||||
[com.biffweb.my-project.ui :as ui]
|
[com.score-the-pigs.ui :as ui]
|
||||||
[honey.sql :as sql]
|
[honey.sql :as sql]
|
||||||
[next.jdbc :as jdbc]
|
[next.jdbc :as jdbc]
|
||||||
[org.sqids.clojure :as sqids]
|
[org.sqids.clojure :as sqids]
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
(ns com.biffweb.my-project.middleware
|
(ns com.score-the-pigs.middleware
|
||||||
(:require
|
(:require
|
||||||
[camel-snake-kebab.core :as csk]
|
[camel-snake-kebab.core :as csk]
|
||||||
[clojure.pprint :as pp]
|
[clojure.pprint :as pp]
|
||||||
3
src/com/score_the_pigs/settings.clj
Normal file
3
src/com/score_the_pigs/settings.clj
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
(ns com.score-the-pigs.settings)
|
||||||
|
|
||||||
|
(def app-name "my_project")
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
(ns com.biffweb.my-project.ui
|
(ns com.score-the-pigs.ui
|
||||||
(:require
|
(:require
|
||||||
[cheshire.core :as cheshire]
|
[cheshire.core :as cheshire]
|
||||||
[com.biffweb.my-project.settings :as settings]
|
[com.score-the-pigs.settings :as settings]
|
||||||
[ring.middleware.anti-forgery :as csrf]
|
[ring.middleware.anti-forgery :as csrf]
|
||||||
[rum.core :as rum]))
|
[rum.core :as rum]))
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
(ns com.biffweb.my-project.util.db
|
(ns com.score-the-pigs.util.db
|
||||||
(:require
|
(:require
|
||||||
[next.jdbc :as jdbc]))
|
[next.jdbc :as jdbc]))
|
||||||
|
|
||||||
Loading…
Reference in a new issue