Skip to content

Commit 1f50c95

Browse files
committed
show messages on build
1 parent c55dd8c commit 1f50c95

File tree

6 files changed

+431
-33
lines changed

6 files changed

+431
-33
lines changed

calcit.cirru

+326-20
Large diffs are not rendered by default.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
},
2727
"devDependencies": {
2828
"feather-icons": "^4.28.0",
29-
"shadow-cljs": "^2.9.0",
29+
"node-notifier": "^7.0.0",
30+
"shadow-cljs": "^2.9.2",
3031
"source-map-support": "^0.5.19",
3132
"url-parse": "^1.4.7"
3233
}

shadow-cljs.edn

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
[cirru/bisection-key "0.1.5"]
1717
[cirru/favored-edn "0.1.3"]
1818
[medley "1.3.0"]
19-
[appliedscience/js-interop "0.2.5"]
19+
[applied-science/js-interop "0.2.5"]
2020
[org.clojure/core.incubator "0.1.4"]
2121
]
2222
:open-file-command [
@@ -36,7 +36,7 @@
3636
}
3737
:server {
3838
:target :node-script, :output-to "target/server.js", :main app.server/main!
39-
:devtools {:after-load app.server/reload!}
39+
:devtools {:after-load app.server/reload!, :build-notify app.build-info/on-build!}
4040
:release {:output-to "dist/server.js"}
4141
}
4242
:page {

src/app/build_info.cljs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
(ns app.build-info (:require ["node-notifier" :as notifier] [clojure.string :as string]))
3+
4+
(defn on-build! [status warning]
5+
(case (:type status)
6+
:build-start (do)
7+
:build-init (do)
8+
:build-failure
9+
(.notify
10+
notifier
11+
(clj->js
12+
{:title "Failure",
13+
:message (:report status),
14+
:type "error",
15+
:sound true,
16+
:time 10000}))
17+
:build-complete
18+
(let [warnings (->> status
19+
:info
20+
:sources
21+
(map :warnings)
22+
(filter (fn [xs] (not (empty? xs)))))]
23+
(if (> (count warnings) 0)
24+
(.notify
25+
notifier
26+
(clj->js
27+
{:title "Build",
28+
:message (->> warnings
29+
(apply concat)
30+
(map
31+
(fn [warning] (str (:resource-name warning) " " (:msg warning))))
32+
(string/join "\n")),
33+
:sound true,
34+
:type "warn"}))
35+
(.notify
36+
notifier
37+
(clj->js
38+
{:title (pr-str (:build-id status)), :message "OK", :time 400, :type "info"}))))
39+
(do (println "Unknown:" (:type status)))))

src/app/server.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
[recollect.diff :refer [diff-twig]]
1414
[recollect.twig :refer [render-twig]]
1515
[ws-edn.server :refer [wss-serve! wss-send! wss-each!]]
16-
[favored-edn.core :refer [write-edn]])
16+
[favored-edn.core :refer [write-edn]]
17+
[app.build-info :as build-info])
1718
(:require-macros [clojure.core.strint :refer [<<]]))
1819

1920
(defonce *client-caches (atom {}))

yarn.lock

+60-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)