demo
This commit is contained in:
parent
b2b89060cc
commit
54075f2644
4 changed files with 51 additions and 17 deletions
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
(defn- build-cmd [cmd scittle-dir]
|
(defn- build-cmd [cmd scittle-dir]
|
||||||
(let [files (feature-files)
|
(let [files (feature-files)
|
||||||
_ (prn :files files)
|
|
||||||
feature-configs (read-configs files)
|
feature-configs (read-configs files)
|
||||||
;; Each ./src/scittle_plugin.edn has a ./deps.edn
|
;; Each ./src/scittle_plugin.edn has a ./deps.edn
|
||||||
feature-dirs (map (comp fs/parent fs/parent) files)
|
feature-dirs (map (comp fs/parent fs/parent) files)
|
||||||
|
|
@ -36,7 +35,6 @@
|
||||||
{'scittle/deps {:local/root scittle-dir}})}
|
{'scittle/deps {:local/root scittle-dir}})}
|
||||||
cmd)
|
cmd)
|
||||||
cmd)]
|
cmd)]
|
||||||
(prn :cmd' cmd')
|
|
||||||
(when (seq feature-configs)
|
(when (seq feature-configs)
|
||||||
(println "Building features:" (str/join ", " (map :name feature-configs)) "..."))
|
(println "Building features:" (str/join ", " (map :name feature-configs)) "..."))
|
||||||
(if (seq feature-configs)
|
(if (seq feature-configs)
|
||||||
|
|
@ -46,7 +44,7 @@
|
||||||
cmd')))
|
cmd')))
|
||||||
|
|
||||||
(defn- build*
|
(defn- build*
|
||||||
[cmd args]
|
[cmd]
|
||||||
(let [building-outside-scittle? (not (fs/exists? "shadow-cljs.edn"))
|
(let [building-outside-scittle? (not (fs/exists? "shadow-cljs.edn"))
|
||||||
scittle-dir (when building-outside-scittle?
|
scittle-dir (when building-outside-scittle?
|
||||||
(->> (classpath/get-classpath)
|
(->> (classpath/get-classpath)
|
||||||
|
|
@ -57,7 +55,8 @@
|
||||||
(when building-outside-scittle?
|
(when building-outside-scittle?
|
||||||
(fs/copy (fs/file scittle-dir "shadow-cljs.edn") "shadow-cljs.edn"))
|
(fs/copy (fs/file scittle-dir "shadow-cljs.edn") "shadow-cljs.edn"))
|
||||||
(let [cmd (build-cmd cmd (str scittle-dir))]
|
(let [cmd (build-cmd cmd (str scittle-dir))]
|
||||||
(apply clojure {:extra-env {"SCI_ELIDE_VARS" "true"}} cmd args))
|
(println "> clojure" cmd)
|
||||||
|
(clojure {:extra-env {"SCI_ELIDE_VARS" "true"}} cmd))
|
||||||
(when building-outside-scittle?
|
(when building-outside-scittle?
|
||||||
(fs/delete "shadow-cljs.edn"))))
|
(fs/delete "shadow-cljs.edn"))))
|
||||||
|
|
||||||
|
|
@ -68,7 +67,5 @@
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
* :action - compile action, defaults to release, but may also be compile or watch"
|
* :action - compile action, defaults to release, but may also be compile or watch"
|
||||||
[args & {:keys [wrap-cmd-fn action] :or {wrap-cmd-fn identity
|
[{:keys [action] :or {action "release"}}]
|
||||||
action "release"}}]
|
(build* (format "-M -m shadow.cljs.devtools.cli --force-spawn %s main" action)))
|
||||||
(build* (wrap-cmd-fn (format "-M -m shadow.cljs.devtools.cli --force-spawn %s main" action))
|
|
||||||
args))
|
|
||||||
|
|
|
||||||
25
plugins/demo/README.md
Normal file
25
plugins/demo/README.md
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Demo
|
||||||
|
|
||||||
|
A demo project of a custom scittle build.
|
||||||
|
|
||||||
|
See:
|
||||||
|
|
||||||
|
- `bb.edn` with
|
||||||
|
- `:deps` which includes:
|
||||||
|
- a dependency on the `scittle.build` project to build scittle + custom features
|
||||||
|
- zero or more plugin dependencies
|
||||||
|
- helpers like static file server
|
||||||
|
- development `:tasks`. Run `bb dev` for development and `bb release` to produce release artifacts.
|
||||||
|
- `deps.edn`: this only contains a dependency on scittle itself
|
||||||
|
|
||||||
|
Available plugins are in the `plugins` directory inside the top level directory of this repo.
|
||||||
|
|
||||||
|
Writing a plugin involves writing
|
||||||
|
|
||||||
|
- SCI configuration (this can be shared with users in the [sci.configs](https://github.com/babashka/sci.configs) project
|
||||||
|
- Adding a `scittle_plugin.edn` file on the plugin's classpath (e.g. in the `src` directory). This EDN file contains:
|
||||||
|
- `:name`, name of the plugin
|
||||||
|
- `:namespaces`: the namespaces exposed to SCI
|
||||||
|
- `:js`: the name of the produced `.js` module file
|
||||||
|
- `:shadow-config`: the shadow-cljs configuration specific to this plugin
|
||||||
|
- A `.cljs` file with an `init` function which calls `scittle/register-plugin!`.
|
||||||
|
|
@ -1,4 +1,20 @@
|
||||||
{:deps {acme/custom.scittle {:local/root "."}}
|
{:deps {io.github.babashka/scittle.build {:local/root "../../build"}
|
||||||
:tasks {:requires ([scittle.build :as build])
|
;; datascript plugin
|
||||||
release {:task (build/build {})}}}
|
io.github.babashka/scittle.datascript {:local/root "../../plugins/datascript"}
|
||||||
x
|
io.github.babashka/http-server
|
||||||
|
{:git/sha "b38c1f16ad2c618adae2c3b102a5520c261a7dd3"}}
|
||||||
|
:tasks
|
||||||
|
{:requires ([scittle.build :as build])
|
||||||
|
watch {:doc "Watch build"
|
||||||
|
:task (build/build {:action "watch"})}
|
||||||
|
serve {:doc "Starts http server for serving static files"
|
||||||
|
:requires ([babashka.http-server :as http])
|
||||||
|
:task (do (http/serve {:port 1341 :dir "resources/public"})
|
||||||
|
(println "Serving static assets at http://localhost:1341"))}
|
||||||
|
-dev {:depends [watch serve]
|
||||||
|
:parallel true}
|
||||||
|
dev {:doc "Run compilation in watch mode and start http server"
|
||||||
|
:task (do (run '-dev {:parallel true})
|
||||||
|
(deref (promise)))}
|
||||||
|
release {:doc "Release build (advanced compiled JS)"
|
||||||
|
:task (build/build {})}}}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1 @@
|
||||||
{:deps
|
{:deps {io.github.babashka/scittle {:local/root "../.."}}}
|
||||||
{io.github.babashka/scittle {:local/root "../.."}
|
|
||||||
io.github.babashka/scittle.build {:local/root "../../build"}
|
|
||||||
;; datascript plugin
|
|
||||||
io.github.babashka/scittle.datascript {:local/root "../../plugins/datascript"}}}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue