|
@@ -3,6 +3,7 @@
|
|
|
namespaces"
|
|
|
(:require [babashka.process :refer [shell]]
|
|
|
[babashka.fs :as fs]
|
|
|
+ [logseq.tasks.util :as task-util]
|
|
|
[clojure.java.io :as io]
|
|
|
[clojure.pprint :as pp]
|
|
|
[clojure.edn :as edn]))
|
|
@@ -37,8 +38,8 @@
|
|
|
(pp/pprint (edn/read-string (:out (shell {:out :string} "node ./static/gen-malli-kondo-config.js")))))]
|
|
|
(spit config-edn config))))
|
|
|
|
|
|
-(defn build-publishing
|
|
|
- "Builds release publishing asset when files have changed"
|
|
|
+(defn build-publishing-frontend
|
|
|
+ "Builds frontend release publishing asset when files have changed"
|
|
|
[& _args]
|
|
|
(if-let [_files (and (not (System/getenv "SKIP_ASSET"))
|
|
|
(seq (set (fs/modified-since (fs/file "static/js/publishing/main.js")
|
|
@@ -47,3 +48,27 @@
|
|
|
(println "Building publishing js asset...")
|
|
|
(shell "clojure -M:cljs release publishing"))
|
|
|
(println "Publishing js asset is up to date")))
|
|
|
+
|
|
|
+(defn publishing-backend
|
|
|
+ "Builds publishing backend and copies over supporting frontend assets"
|
|
|
+ [& args]
|
|
|
+ (apply shell {:dir "scripts"}
|
|
|
+ "yarn -s nbb-logseq -cp src -m logseq.tasks.dev.publishing"
|
|
|
+ (into ["static"] args)))
|
|
|
+
|
|
|
+(defn watch-publishing-frontend
|
|
|
+ [& _args]
|
|
|
+ (shell "clojure -M:cljs watch publishing"))
|
|
|
+
|
|
|
+(defn watch-publishing-backend
|
|
|
+ "Builds publishing backend once watch-publishing-frontend has built initial frontend"
|
|
|
+ [& args]
|
|
|
+ (let [start-time (java.time.Instant/now)]
|
|
|
+ (Thread/sleep 3000)
|
|
|
+ (loop [n 1000]
|
|
|
+ (if (and (fs/exists? "static/js/publishing/main.js")
|
|
|
+ (task-util/file-modified-later-than? "static/js/publishing/main.js" start-time))
|
|
|
+ (apply publishing-backend args)
|
|
|
+ (do (println "Waiting for publishing frontend to build...")
|
|
|
+ (Thread/sleep 1000)
|
|
|
+ (recur (inc n)))))))
|