mirror of https://github.com/logseq/logseq
enhance: add a --dev mode to publishing that pairs with shadow's watch
parent
ce2341506d
commit
3cd7b2d762
|
@ -18,7 +18,7 @@ can be passed:
|
|||
can be icon, name, alias, title, description and url
|
||||
* :default-notification-fn - Configure how errors are reported when creating the export.
|
||||
Default is to throw an exception when it occurs."
|
||||
[db static-dir graph-dir output-dir {:keys [notification-fn]
|
||||
[db static-dir graph-dir output-dir {:keys [notification-fn dev?]
|
||||
:or {notification-fn default-notification-fn}
|
||||
:as options}]
|
||||
(let [options' (cond-> options
|
||||
|
@ -28,4 +28,5 @@ can be passed:
|
|||
(assoc-in [:app-state :ui/radix-color] (:ui/radix-color options)))
|
||||
{:keys [html asset-filenames]} (publish-html/build-html db options')]
|
||||
(publish-export/create-export html static-dir graph-dir output-dir {:asset-filenames asset-filenames
|
||||
:notification-fn notification-fn})))
|
||||
:notification-fn notification-fn
|
||||
:dev? dev?})))
|
||||
|
|
|
@ -22,21 +22,30 @@
|
|||
|
||||
(defn- cleanup-js-dir
|
||||
"Moves used js files to the correct dir and removes unused js files"
|
||||
[output-static-dir]
|
||||
[output-static-dir source-static-dir {:keys [dev?]}]
|
||||
(let [publishing-dir (node-path/join output-static-dir "js" "publishing")]
|
||||
(p/let [_ (p/all (map (fn [file]
|
||||
(fs/rmSync (node-path/join output-static-dir "js" file) #js {:force true}))
|
||||
js-files))
|
||||
_ (when dev?
|
||||
(fse/remove (node-path/join output-static-dir "js" "cljs-runtime")))
|
||||
_ (p/all (map (fn [file]
|
||||
(if dev?
|
||||
(fs/symlinkSync
|
||||
(node-path/join source-static-dir "js" "publishing" file)
|
||||
(node-path/join output-static-dir "js" file))
|
||||
(fs/renameSync
|
||||
(node-path/join publishing-dir file)
|
||||
(node-path/join output-static-dir "js" file)))
|
||||
(node-path/join output-static-dir "js" file))))
|
||||
js-files))
|
||||
_ (when dev?
|
||||
(fs/symlinkSync (node-path/join source-static-dir "js" "publishing" "cljs-runtime")
|
||||
(node-path/join output-static-dir "js" "cljs-runtime")))
|
||||
;; remove publishing-dir
|
||||
_ (p/all (map (fn [file]
|
||||
_ (when-not dev? (p/all (map (fn [file]
|
||||
(fs/rmSync (node-path/join publishing-dir file)))
|
||||
(fs/readdirSync publishing-dir)))
|
||||
_ (fs/rmdirSync publishing-dir)
|
||||
(fs/readdirSync publishing-dir))))
|
||||
_ (when-not dev? (fs/rmdirSync 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}))
|
||||
|
@ -90,7 +99,7 @@
|
|||
_ (fs/writeFileSync (node-path/join output-static-dir "css" "custom.css") custom-css)
|
||||
custom-js (if (fs/existsSync custom-js-path) (str (fs/readFileSync custom-js-path)) "")
|
||||
_ (fs/writeFileSync (node-path/join output-static-dir "js" "custom.js") custom-js)
|
||||
_ (cleanup-js-dir output-static-dir)]
|
||||
_ (cleanup-js-dir output-static-dir static-dir options)]
|
||||
(notification-fn {:type "success"
|
||||
:payload (str "Export public pages and publish assets to " output-dir " successfully 🎉")}))
|
||||
(p/catch (fn [error]
|
||||
|
|
|
@ -307,10 +307,14 @@ point out:
|
|||
```sh
|
||||
# One time setup
|
||||
$ cd scripts && yarn install && cd -
|
||||
# Build the export
|
||||
# Build a release export
|
||||
$ bb dev:publishing /path/to/graph-dir tmp/publish
|
||||
# OR build a dev export with `clojure -M:cljs watch publishing` and then
|
||||
$ bb dev:publishing /path/to/graph-dir tmp/publish --dev
|
||||
|
||||
# View the app in a browser
|
||||
$ open tmp/publish/index.html
|
||||
$ python3 -m http.server 8080 -d tmp/db-publish &; open http://localhost:8080
|
||||
|
||||
```
|
||||
|
||||
There are also some tasks under `nbb:` which are useful for inspecting database
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
(defn -main
|
||||
[& args]
|
||||
(when-not (= 3 (count args))
|
||||
(when (< (count args) 3)
|
||||
(println "Usage: $0 STATIC-DIR GRAPH-DIR OUT-DIR")
|
||||
(js/process.exit 1))
|
||||
(let [[static-dir graph-dir output-path]
|
||||
|
@ -23,4 +23,4 @@
|
|||
static-dir
|
||||
graph-dir
|
||||
output-path
|
||||
{:repo-config repo-config :ui/theme "dark" :ui/radix-color :purple})))
|
||||
{:repo-config repo-config :ui/theme "dark" :ui/radix-color :purple :dev? (contains? (set args) "--dev")})))
|
||||
|
|
Loading…
Reference in New Issue