mirror of https://github.com/logseq/logseq
enhance: publishing --dev also watches frontend
also provide a dedicated backend command for simpler rebuilding of backendpull/10922/head
parent
3cd7b2d762
commit
dc5127b48a
31
bb.edn
31
bb.edn
|
@ -31,15 +31,32 @@
|
|||
dev:app-watch
|
||||
logseq.tasks.dev.mobile/app-watch
|
||||
|
||||
dev:build-publishing
|
||||
logseq.tasks.dev/build-publishing
|
||||
-dev:build-publishing-frontend
|
||||
logseq.tasks.dev/build-publishing-frontend
|
||||
|
||||
dev:publishing-backend
|
||||
logseq.tasks.dev/publishing-backend
|
||||
|
||||
-dev:publishing-release
|
||||
{:depends [-dev:build-publishing-frontend]
|
||||
:doc "Build release publishing spa app given graph and output dirs"
|
||||
:task (run 'dev:publishing-backend)}
|
||||
|
||||
-dev:watch-publishing-frontend
|
||||
logseq.tasks.dev/watch-publishing-frontend
|
||||
|
||||
-dev:watch-publishing-backend
|
||||
logseq.tasks.dev/watch-publishing-backend
|
||||
|
||||
-dev:publishing-dev
|
||||
{:depends [-dev:watch-publishing-frontend -dev:watch-publishing-backend]
|
||||
:doc "Watch dev publishing spa app given graph and output dirs"}
|
||||
|
||||
dev:publishing
|
||||
{:depends [dev:build-publishing]
|
||||
:doc "Build publishing spa app given graph and output dirs"
|
||||
:task (apply shell {:dir "scripts"}
|
||||
"yarn -s nbb-logseq -cp src -m logseq.tasks.dev.publishing"
|
||||
(into ["static"] *command-line-args*))}
|
||||
{:doc "Builds full publishing app given graph and output dirs. Append --dev to watch frontend"
|
||||
:task (if ((set *command-line-args*) "--dev")
|
||||
(run '-dev:publishing-dev {:parallel true})
|
||||
(run '-dev:publishing-release))}
|
||||
|
||||
dev:npx-cap-run-ios
|
||||
logseq.tasks.dev.mobile/npx-cap-run-ios
|
||||
|
|
|
@ -42,10 +42,7 @@
|
|||
(fs/symlinkSync (node-path/join source-static-dir "js" "publishing" "cljs-runtime")
|
||||
(node-path/join output-static-dir "js" "cljs-runtime")))
|
||||
;; remove publishing-dir
|
||||
_ (when-not dev? (p/all (map (fn [file]
|
||||
(fs/rmSync (node-path/join publishing-dir file)))
|
||||
(fs/readdirSync publishing-dir))))
|
||||
_ (when-not dev? (fs/rmdirSync publishing-dir))
|
||||
_ (when-not dev? (fse/remove publishing-dir))
|
||||
;; remove source map files
|
||||
_ (p/all (map (fn [file]
|
||||
(fs/rmSync (node-path/join output-static-dir "js" (str file ".map")) #js {:force true}))
|
||||
|
|
|
@ -307,13 +307,20 @@ point out:
|
|||
```sh
|
||||
# One time setup
|
||||
$ cd scripts && yarn install && cd -
|
||||
# Build a release export
|
||||
|
||||
# Build a release publishing app
|
||||
$ bb dev:publishing /path/to/graph-dir tmp/publish
|
||||
# OR build a dev export with `clojure -M:cljs watch publishing` and then
|
||||
|
||||
# OR build a dev publishing app that watches frontend changes
|
||||
$ bb dev:publishing /path/to/graph-dir tmp/publish --dev
|
||||
|
||||
# View the app in a browser
|
||||
$ python3 -m http.server 8080 -d tmp/db-publish &; open http://localhost:8080
|
||||
# View the publishing app in a browser
|
||||
$ python3 -m http.server 8080 -d tmp/publish &; open http://localhost:8080
|
||||
|
||||
# Rebuild the publishing backend for dev/release.
|
||||
# Handy when making backend changes in deps/publishing or
|
||||
# to test a different graph
|
||||
$ bb dev:publishing-backend /path/graph-dir tmp/publish
|
||||
|
||||
```
|
||||
|
||||
|
|
|
@ -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)))))))
|
Loading…
Reference in New Issue