Skip to content

Commit

Permalink
malli
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Jun 12, 2022
1 parent a365696 commit 18e55eb
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ print-cli-args/print-cli-args
clojure_logo.png
assets/command-icon.png
doc/electron/index.js
ext/nbb-prismatic-schema/index.mjs
ext/**/index.mjs
2 changes: 2 additions & 0 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,7 @@
(run 'clean)
(run 'release)
(shell {:dir "ext/nbb-prismatic-schema"} "npm publish --access public")
(shell "npm publish --access public")
(shell {:dir "ext/nbb-metosin-malli"} "npm publish --access public")
(shell "npm publish --access public")))
(println "Skipping release."))}}}
14 changes: 9 additions & 5 deletions build/src/nbb/build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
(when building-outside-nbb?
(fs/delete "shadow-cljs.edn"))))

(defn move-ext-lib [src dest]
(fs/move src dest {:replace-existing true})
(spit dest
(-> (slurp dest)
(str/replace "from \"./nbb_core.js\";" "from \"nbb/lib/nbb_core.js\";")
(str/replace "import \"./nbb_goog_string.js\";" "import \"nbb/lib/nbb_goog_string.js\";"))))

(defn release
"Compiles release build."
[args & {:keys [wrap-cmd-fn] :or {wrap-cmd-fn identity}}]
Expand All @@ -71,8 +78,5 @@
(str "#!/usr/bin/env node\n\n" (slurp "lib/nbb_main.js")))
(shell "chmod +x lib/nbb_main.js")
(run! fs/delete (fs/glob "lib" "**.map"))
(fs/move "lib/nbb_schema.js" "ext/nbb-prismatic-schema/index.mjs" {:replace-existing true})
(spit "ext/nbb-prismatic-schema/index.mjs"
(-> (slurp "ext/nbb-prismatic-schema/index.mjs")
(str/replace "from \"./nbb_core.js\";" "from \"nbb/lib/nbb_core.js\";")
(str/replace "import \"./nbb_goog_string.js\";" "import \"nbb/lib/nbb_goog_string.js\";"))))
(move-ext-lib "lib/nbb_schema.js" "ext/nbb-prismatic-schema/index.mjs")
(move-ext-lib "lib/nbb_malli.js" "ext/nbb-metosin-malli/index.mjs"))
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
org.clojure/tools.cli {:mvn/version "1.0.206"}
com.cognitect/transit-cljs {:mvn/version "0.8.269"}
prismatic/schema {:mvn/version "1.3.0"}
}}
metosin/malli {:mvn/version "0.8.4"}}}
4 changes: 4 additions & 0 deletions ext/nbb-metosin-malli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{"name": "@babashka/nbb-metosin-malli",
"version": "0.5.113",
"type": "module",
"peerDependencies": {"nbb": "0.5.113"}}
4 changes: 3 additions & 1 deletion shadow-cljs.edn
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
:nbb_math {:init-fn nbb.impl.math/init
:depends-on #{:nbb_core}}
:nbb_schema {:init-fn nbb.impl.schema/init
:depends-on #{:nbb_core :nbb_goog_string}}}
:depends-on #{:nbb_core :nbb_goog_string}}
:nbb_malli {:init-fn nbb.impl.malli/init
:depends-on #{:nbb_core}}}
:build-hooks [(shadow.cljs.build-report/hook
{:output-to "report.html"})
(nbb.impl.shadow-hooks/hook
Expand Down
5 changes: 4 additions & 1 deletion src/nbb/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@
(load-module "./nbb_math.js" libname as refer rename libspecs)
(schema.core)
(load-module ((.-resolve (:require @ctx)) "@babashka/nbb-prismatic-schema/index.mjs")
libname as refer rename libspecs)
libname as refer rename libspecs)
(malli.core)
(load-module ((.-resolve (:require @ctx)) "@babashka/nbb-metosin-malli/index.mjs")
libname as refer rename libspecs)
(let [feat (get feature-requires libname)]
(cond
feat (load-module feat libname as refer rename libspecs)
Expand Down
16 changes: 16 additions & 0 deletions src/nbb/impl/malli.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(ns nbb.impl.malli
(:require
[malli.core]
[nbb.core :as nbb]
[sci.core :as sci]))

(def sns (sci/create-ns 'malli.core nil))

(def malli-namespace
(sci/copy-ns malli.core sns))

(defn init []
(nbb/register-plugin!
::malli
{:namespaces {'malli.core malli-namespace}}))

0 comments on commit 18e55eb

Please sign in to comment.