mirror of
https://github.com/status-im/pluto.git
synced 2025-02-24 16:38:16 +00:00
Simplified build system
This commit is contained in:
parent
1935f0eaa5
commit
1e6ede7ed6
12
README.md
12
README.md
@ -1,4 +1,14 @@
|
|||||||
Launch figwheel with ./scripts/figwheel.sh then open http://127.0.0.1/index.html
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
Development requires [Deps and CLI](https://clojure.org/guides/getting_started) tooling installed.
|
||||||
|
|
||||||
|
Run Clojure tests using `clojure -Atest-clj`
|
||||||
|
Run ClojureScript tests using `clojure -Atest-cljs`
|
||||||
|
|
||||||
|
Run figwheel using `clojure -Afigwheel`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### IPFS
|
### IPFS
|
||||||
|
|
||||||
|
127
build.clj
127
build.clj
@ -1,127 +0,0 @@
|
|||||||
(require '[cljs.build.api :as api]
|
|
||||||
'[clojure.java.shell :as shell]
|
|
||||||
'[clojure.string :as string])
|
|
||||||
|
|
||||||
;;; Configuration.
|
|
||||||
|
|
||||||
(def source-dir "src")
|
|
||||||
|
|
||||||
(def test-dir "test")
|
|
||||||
|
|
||||||
(def compiler-config {:main 'pluto.demo
|
|
||||||
:asset-path "assets/pluto"
|
|
||||||
:output-to "resources/public/assets/pluto.js"
|
|
||||||
:output-dir "resources/public/assets/pluto"
|
|
||||||
:optimizations :none
|
|
||||||
:static-fns true
|
|
||||||
:elide-asserts false
|
|
||||||
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}
|
|
||||||
:preloads ['day8.re-frame-10x.preload]
|
|
||||||
:source-map true})
|
|
||||||
|
|
||||||
(def compiler-release-config {:main 'pluto.demo
|
|
||||||
:output-to "resources/public/assets/pluto.js"
|
|
||||||
:optimizations :advanced
|
|
||||||
:static-fns true
|
|
||||||
:elide-asserts true})
|
|
||||||
|
|
||||||
(def test-config {:main 'pluto.runner
|
|
||||||
:output-to "target/test.js"
|
|
||||||
:output-dir "target/test"
|
|
||||||
:optimizations :none
|
|
||||||
:target :nodejs
|
|
||||||
:source-map true})
|
|
||||||
|
|
||||||
(def test-environment {:SOME_ENV_VAR "some-env-value"})
|
|
||||||
|
|
||||||
(def dev-config (merge compiler-config
|
|
||||||
{:optimizations :none
|
|
||||||
:source-map true}))
|
|
||||||
|
|
||||||
|
|
||||||
;;; Tasks mechanism.
|
|
||||||
|
|
||||||
(defmulti task first)
|
|
||||||
|
|
||||||
(defmethod task :default
|
|
||||||
[args]
|
|
||||||
(let [all-tasks (-> task methods (dissoc :default) keys sort (->> (interpose ", ") (apply str)))]
|
|
||||||
(println "unknown or missing task argument. Choose one of:" all-tasks)
|
|
||||||
(System/exit 1)))
|
|
||||||
|
|
||||||
|
|
||||||
;;; Helper functions.
|
|
||||||
|
|
||||||
(defn run-node-tests []
|
|
||||||
(let [{:keys [out err exit]} (shell/sh "node" "target/test.js" :env test-environment)]
|
|
||||||
(println out err)
|
|
||||||
(= exit 0)))
|
|
||||||
|
|
||||||
(defn try-require [ns-sym]
|
|
||||||
(try (require ns-sym) true (catch Exception e (.printStackTrace e) false)))
|
|
||||||
|
|
||||||
(defmacro with-namespaces
|
|
||||||
[namespaces & body]
|
|
||||||
(if (every? try-require namespaces)
|
|
||||||
`(do ~@body)
|
|
||||||
`(do (println "task not available - required dependencies not found")
|
|
||||||
(System/exit 1))))
|
|
||||||
|
|
||||||
|
|
||||||
;;; Compiling task.
|
|
||||||
|
|
||||||
(defn compile-once []
|
|
||||||
(api/build source-dir compiler-release-config))
|
|
||||||
|
|
||||||
(defn compile-refresh []
|
|
||||||
(api/watch source-dir compiler-config))
|
|
||||||
|
|
||||||
(defmethod task "compile" [[_ type]]
|
|
||||||
(case type
|
|
||||||
(nil "once") (compile-once)
|
|
||||||
"watch" (compile-refresh)
|
|
||||||
(do (println "Unknown argument to compile task:" type)
|
|
||||||
(System/exit 1))))
|
|
||||||
|
|
||||||
|
|
||||||
;;; Testing task
|
|
||||||
|
|
||||||
(defn test-once []
|
|
||||||
(api/build (api/inputs source-dir test-dir) test-config)
|
|
||||||
(let [success? (run-node-tests)]
|
|
||||||
(System/exit (if success? 0 1))))
|
|
||||||
|
|
||||||
(defn test-refresh []
|
|
||||||
(api/watch (api/inputs source-dir test-dir)
|
|
||||||
(assoc test-config :watch-fn run-node-tests)))
|
|
||||||
|
|
||||||
(defmethod task "test" [[_ type]]
|
|
||||||
(case type
|
|
||||||
(nil "once") (test-once)
|
|
||||||
"watch" (test-refresh)
|
|
||||||
(do (println "Unknown argument to test task:" type)
|
|
||||||
(System/exit 1))))
|
|
||||||
|
|
||||||
|
|
||||||
;;; Figwheeling task
|
|
||||||
|
|
||||||
(defmethod task "figwheel" [[_ port]]
|
|
||||||
(with-namespaces [figwheel-sidecar.repl-api]
|
|
||||||
(figwheel-sidecar.repl-api/start-figwheel!
|
|
||||||
{:figwheel-options (cond-> {}
|
|
||||||
port (merge {:http-server-root "public"
|
|
||||||
:server-ip "localhost"
|
|
||||||
:nrepl-port (some-> port Long/parseLong)
|
|
||||||
:on-jsload "pluto.demo/run"
|
|
||||||
:nrepl-middleware ["cemerick.piggieback/wrap-cljs-repl"]}))
|
|
||||||
:all-builds [{:id "dev"
|
|
||||||
:figwheel true
|
|
||||||
:source-paths [source-dir]
|
|
||||||
:compiler dev-config}]})
|
|
||||||
(when-not port
|
|
||||||
(figwheel-sidecar.repl-api/cljs-repl))))
|
|
||||||
|
|
||||||
|
|
||||||
;;; Build script entrypoint.
|
|
||||||
|
|
||||||
(task (map string/trim *command-line-args*))
|
|
29
deps.edn
29
deps.edn
@ -1,17 +1,18 @@
|
|||||||
{:deps {org.clojure/clojurescript {:mvn/version "1.10.238"}
|
{:deps {org.clojure/clojure {:mvn/version "1.9.0"}
|
||||||
|
org.clojure/clojurescript {:mvn/version "1.10.238"}
|
||||||
org.clojure/tools.reader {:mvn/version "1.2.1"}
|
org.clojure/tools.reader {:mvn/version "1.2.1"}
|
||||||
reagent {:mvn/version "0.8.0"}
|
reagent {:mvn/version "0.8.0"}
|
||||||
re-frame {:mvn/version "0.10.5"}
|
re-frame {:mvn/version "0.10.5"}}
|
||||||
com.bhauman/rebel-readline-cljs {:mvn/version "0.1.1"}
|
|
||||||
binaryage/devtools {:mvn/version "0.9.10"}
|
|
||||||
day8.re-frame/re-frame-10x {:mvn/version "0.3.2"}}
|
|
||||||
:paths ["src" "resources"]
|
:paths ["src" "resources"]
|
||||||
:aliases {:test {:extra-deps {olical/cljs-test-runner {:mvn/version "0.1.1"}}
|
:aliases {:figwheel {:extra-paths ["target" "figwheel-resources" "examples/src" "examples/resources"]
|
||||||
:main-opts ["-m" "cljs-test-runner.main"]}
|
:extra-deps {com.bhauman/figwheel-main {:mvn/version "0.1.0-SNAPSHOT"}
|
||||||
:repl
|
com.bhauman/rebel-readline-cljs {:mvn/version "0.1.1"}
|
||||||
{:extra-deps
|
binaryage/devtools {:mvn/version "0.9.10"}}
|
||||||
{;; Figwheel ClojureScript REPL
|
:main-opts ["-m" "figwheel.main" "-c" "pluto.demo" "-r"]}
|
||||||
com.cemerick/piggieback {:mvn/version "0.2.2"
|
:test-clj {:extra-paths ["test"]
|
||||||
:exclusions [com.google.javascript/closure-compiler]}
|
:extra-deps {com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git"
|
||||||
figwheel-sidecar {:mvn/version "0.5.14"
|
:sha "5fb4fc46ad0bf2e0ce45eba5b9117a2e89166479"}}
|
||||||
:exclusions [com.google.javascript/closure-compiler]}}}}}
|
:main-opts ["-m" "cognitect.test-runner"]}
|
||||||
|
:test-cljs {:extra-paths ["test"]
|
||||||
|
:extra-deps {olical/cljs-test-runner {:mvn/version "1.0.0"}}
|
||||||
|
:main-opts ["-m" "cljs-test-runner.main"]}}}
|
||||||
|
1
figwheel-resources/README.md
Normal file
1
figwheel-resources/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
This folder contains file needed during figwheel development sessions.
|
@ -51,4 +51,4 @@
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
<script src="assets/pluto.js"></script>
|
<script src="cljs-out/main.js"></script>
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
clj -R:repl build.clj figwheel
|
|
@ -1,4 +1,5 @@
|
|||||||
mkdir -p docs/assets
|
mkdir -p docs/assets
|
||||||
clj -R:repl build.clj compile once
|
clj -m cljs.main -v -O advanced -d target/js -o target/js/pluto.js -c pluto.demo
|
||||||
|
cp target/js/pluto.js docs/assets
|
||||||
cp -R resources/public/assets/* docs/assets
|
cp -R resources/public/assets/* docs/assets
|
||||||
cp resources/public/index.html docs/
|
cp resources/public/index.html docs/
|
||||||
|
@ -1 +0,0 @@
|
|||||||
clojure -Sdeps '{:deps {olical/cljs-test-runner {:mvn/version "1.0.0"}}}' -m cljs-test-runner.main
|
|
@ -1,5 +1,5 @@
|
|||||||
(ns pluto.reader.blocks-test
|
(ns pluto.reader.block-test
|
||||||
(:require [cljs.test :refer-macros [is deftest async use-fixtures]]
|
(:require [clojure.test :refer [is deftest]]
|
||||||
[pluto.reader.blocks :as blocks]))
|
[pluto.reader.blocks :as blocks]))
|
||||||
|
|
||||||
(deftest parse
|
(deftest parse
|
@ -1,5 +1,5 @@
|
|||||||
(ns pluto.reader-test
|
(ns pluto.reader-test
|
||||||
(:require [cljs.test :refer-macros [is deftest async use-fixtures]]
|
(:require [clojure.test :refer [is deftest]]
|
||||||
[pluto.reader :as reader]
|
[pluto.reader :as reader]
|
||||||
[pluto.reader.reference :refer [Reference]]
|
[pluto.reader.reference :refer [Reference]]
|
||||||
[pluto.reader.blocks :as blocks]))
|
[pluto.reader.blocks :as blocks]))
|
@ -1,7 +0,0 @@
|
|||||||
(ns pluto.runner
|
|
||||||
(:require [doo.runner :refer-macros [doo-tests]]
|
|
||||||
[pluto.reader-test]
|
|
||||||
[pluto.reader.blocks-test]))
|
|
||||||
|
|
||||||
(doo-tests 'pluto.reader-test
|
|
||||||
'pluto.reader.blocks-test)
|
|
Loading…
x
Reference in New Issue
Block a user