wip
This commit is contained in:
parent
11b7a56ab8
commit
b9ff6eb8c1
4 changed files with 79 additions and 4 deletions
10
bb.edn
10
bb.edn
|
|
@ -2,10 +2,13 @@
|
||||||
#_{:local/root "../sci.nrepl"}
|
#_{:local/root "../sci.nrepl"}
|
||||||
{:git/sha "2f8a9ed2d39a1b09d2b4d34d95494b56468f4a23"}
|
{:git/sha "2f8a9ed2d39a1b09d2b4d34d95494b56468f4a23"}
|
||||||
io.github.babashka/http-server
|
io.github.babashka/http-server
|
||||||
{:git/sha "b38c1f16ad2c618adae2c3b102a5520c261a7dd3"}}
|
{:git/sha "b38c1f16ad2c618adae2c3b102a5520c261a7dd3"}
|
||||||
|
io.github.scittle/build
|
||||||
|
{:local/root "build"}}
|
||||||
|
|
||||||
:tasks
|
:tasks
|
||||||
{:requires ([babashka.fs :as fs]
|
{:requires ([scittle.build :as build]
|
||||||
|
[babashka.fs :as fs]
|
||||||
[cheshire.core :as json]
|
[cheshire.core :as json]
|
||||||
[babashka.process :as p :refer [process]])
|
[babashka.process :as p :refer [process]])
|
||||||
|
|
||||||
|
|
@ -34,7 +37,8 @@
|
||||||
(deref (promise)))}
|
(deref (promise)))}
|
||||||
|
|
||||||
prod {:doc "Builds production artifacts."
|
prod {:doc "Builds production artifacts."
|
||||||
:task (clojure {:extra-env {"SCI_ELIDE_VARS" "true"}}
|
:task (build/release *command-line-args* #_{:wrap-cmd-fn nil #_wrap-cmd})
|
||||||
|
#_(clojure {:extra-env {"SCI_ELIDE_VARS" "true"}}
|
||||||
"-M:dev -m shadow.cljs.devtools.cli release main")}
|
"-M:dev -m shadow.cljs.devtools.cli release main")}
|
||||||
|
|
||||||
dist {:doc "Prepare dist folder for npm package"
|
dist {:doc "Prepare dist folder for npm package"
|
||||||
|
|
|
||||||
1
build/deps.edn
Normal file
1
build/deps.edn
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{}
|
||||||
69
build/src/scittle/build.clj
Normal file
69
build/src/scittle/build.clj
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
(ns scittle.build
|
||||||
|
"Provides bb tasks for building and releasing scittle"
|
||||||
|
(:require
|
||||||
|
[babashka.classpath :as classpath]
|
||||||
|
[babashka.fs :as fs]
|
||||||
|
[babashka.tasks :refer [clojure]]
|
||||||
|
[clojure.edn :as edn]
|
||||||
|
[clojure.string :as str]))
|
||||||
|
|
||||||
|
(defn- feature-files
|
||||||
|
[]
|
||||||
|
(filter fs/exists?
|
||||||
|
(map (fn [d]
|
||||||
|
(fs/file d "scittle_features.edn"))
|
||||||
|
(classpath/split-classpath (classpath/get-classpath)))))
|
||||||
|
|
||||||
|
(defn- read-configs
|
||||||
|
[files]
|
||||||
|
(->> files
|
||||||
|
(mapcat (comp edn/read-string slurp str))))
|
||||||
|
|
||||||
|
(defn- build-cmd [cmd scittle-dir]
|
||||||
|
(let [files (feature-files)
|
||||||
|
feature-configs (read-configs files)
|
||||||
|
;; Each ./src/scittle_features.edn has a ./deps.edn
|
||||||
|
feature-dirs (map (comp fs/parent fs/parent) files)
|
||||||
|
cmd' (if (seq files)
|
||||||
|
(format "-Sdeps '%s' %s"
|
||||||
|
{:deps
|
||||||
|
(merge (into {}
|
||||||
|
(map (fn [dir]
|
||||||
|
[(symbol (str (fs/file-name dir) "/deps"))
|
||||||
|
{:local/root (str dir)}])
|
||||||
|
feature-dirs))
|
||||||
|
{'scittle/deps {:local/root scittle-dir}})}
|
||||||
|
cmd)
|
||||||
|
cmd)]
|
||||||
|
(when (seq feature-configs)
|
||||||
|
(println "Building features:" (str/join ", " (map :name feature-configs)) "..."))
|
||||||
|
(if (seq feature-configs)
|
||||||
|
(apply str cmd'
|
||||||
|
(map (fn [m] (format " --config-merge '%s'" (pr-str (:shadow-config m))))
|
||||||
|
feature-configs))
|
||||||
|
cmd')))
|
||||||
|
|
||||||
|
(defn build
|
||||||
|
"Build scittle shadow builds using clojure cmd and commandline args. Features on
|
||||||
|
classpath are automatically added"
|
||||||
|
[cmd args]
|
||||||
|
(let [building-outside-scittle? (not (fs/exists? "shadow-cljs.edn"))
|
||||||
|
scittle-dir (when building-outside-scittle?
|
||||||
|
(->> (classpath/get-classpath)
|
||||||
|
classpath/split-classpath
|
||||||
|
;; Pull out scittle from local/root or git/url
|
||||||
|
(some #(when (re-find #"(scittle/[0-9a-f]+|scittle)/src" %) %))
|
||||||
|
fs/parent))]
|
||||||
|
(when building-outside-scittle?
|
||||||
|
(fs/copy (fs/file scittle-dir "shadow-cljs.edn") "shadow-cljs.edn"))
|
||||||
|
(apply clojure {:extra-env {"SCI_ELIDE_VARS" "true"}}
|
||||||
|
(build-cmd cmd (str scittle-dir)) args)
|
||||||
|
(when building-outside-scittle?
|
||||||
|
(fs/delete "shadow-cljs.edn"))))
|
||||||
|
|
||||||
|
(defn release
|
||||||
|
"Compiles release build."
|
||||||
|
[args & {:keys [wrap-cmd-fn] :or {wrap-cmd-fn identity}}]
|
||||||
|
(build (wrap-cmd-fn "-M -m shadow.cljs.devtools.cli --force-spawn release main")
|
||||||
|
args)
|
||||||
|
(run! fs/delete (fs/glob "lib" "**.map")))
|
||||||
3
deps.edn
3
deps.edn
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
:deps
|
:deps
|
||||||
{org.clojure/clojure {:mvn/version "1.11.1"}
|
{org.clojure/clojure {:mvn/version "1.11.1"}
|
||||||
|
thheller/shadow-cljs {:mvn/version "2.20.15"}
|
||||||
org.babashka/sci {:git/url "https://github.com/babashka/sci"
|
org.babashka/sci {:git/url "https://github.com/babashka/sci"
|
||||||
:git/sha "a85c488ee45700bcbe67bc01ab1c27407fff7887"}
|
:git/sha "a85c488ee45700bcbe67bc01ab1c27407fff7887"}
|
||||||
#_{:local/root "../babashka/sci"}
|
#_{:local/root "../babashka/sci"}
|
||||||
|
|
@ -23,4 +24,4 @@
|
||||||
:aliases
|
:aliases
|
||||||
{:dev
|
{:dev
|
||||||
{:extra-paths ["dev"]
|
{:extra-paths ["dev"]
|
||||||
:extra-deps {thheller/shadow-cljs {:mvn/version "2.20.15"}}}}}
|
:extra-deps {}}}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue