[#407] datascript feature
This commit is contained in:
parent
1a8742af89
commit
0805efd27b
9 changed files with 40 additions and 5 deletions
3
deps.edn
3
deps.edn
|
|
@ -14,7 +14,8 @@
|
||||||
com.cognitect/transit-clj {:mvn/version "1.0.324"}
|
com.cognitect/transit-clj {:mvn/version "1.0.324"}
|
||||||
seancorfield/next.jdbc {:mvn/version "1.0.424"}
|
seancorfield/next.jdbc {:mvn/version "1.0.424"}
|
||||||
org.postgresql/postgresql {:mvn/version "42.2.12"}
|
org.postgresql/postgresql {:mvn/version "42.2.12"}
|
||||||
org.hsqldb/hsqldb {:mvn/version "2.4.0"}}
|
org.hsqldb/hsqldb {:mvn/version "2.4.0"}
|
||||||
|
datascript {:mvn/version "0.18.11"}}
|
||||||
:aliases {:main
|
:aliases {:main
|
||||||
{:main-opts ["-m" "babashka.main"]}
|
{:main-opts ["-m" "babashka.main"]}
|
||||||
:profile
|
:profile
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,9 @@ Babashka supports the following feature flags:
|
||||||
| `BABASHKA_FEATURE_XML` | Includes the [clojure.data.xml](https://github.com/clojure/data.xml) library | `true` |
|
| `BABASHKA_FEATURE_XML` | Includes the [clojure.data.xml](https://github.com/clojure/data.xml) library | `true` |
|
||||||
| `BABASHKA_FEATURE_YAML` | Includes the [clj-yaml](https://github.com/clj-commons/clj-yaml) library | `true` |
|
| `BABASHKA_FEATURE_YAML` | Includes the [clj-yaml](https://github.com/clj-commons/clj-yaml) library | `true` |
|
||||||
| `BABASHKA_FEATURE_JDBC` | Includes the [next.jdbc](https://github.com/seancorfield/next-jdbc) library | `false` |
|
| `BABASHKA_FEATURE_JDBC` | Includes the [next.jdbc](https://github.com/seancorfield/next-jdbc) library | `false` |
|
||||||
| `BABASHKA_FEATURE_POSTGRESQL` | Includes the [PostgresSQL](https://jdbc.postgresql.org/) JDBC driver | `false`
|
| `BABASHKA_FEATURE_POSTGRESQL` | Includes the [PostgresSQL](https://jdbc.postgresql.org/) JDBC driver | `false` |
|
||||||
| `BABASHKA_FEATURE_HSQLDB` | Includes the [HSQLDB](http://www.hsqldb.org/) JDBC driver | `false`
|
| `BABASHKA_FEATURE_HSQLDB` | Includes the [HSQLDB](http://www.hsqldb.org/) JDBC driver | `false` |
|
||||||
|
| `BABASHKA_FEATURE_DATASCRIPT` | Includes [datascript](https://github.com/tonsky/datascript) | `false` |
|
||||||
|
|
||||||
To disable all of the above features, you can set `BABASHKA_LEAN` to `true`.
|
To disable all of the above features, you can set `BABASHKA_LEAN` to `true`.
|
||||||
|
|
||||||
|
|
|
||||||
12
feature-datascript/babashka/impl/datascript.clj
Normal file
12
feature-datascript/babashka/impl/datascript.clj
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
(ns babashka.impl.datascript
|
||||||
|
{:no-doc true}
|
||||||
|
(:require [datascript.core :as d]
|
||||||
|
[sci.impl.namespaces :refer [copy-var]]
|
||||||
|
[sci.impl.vars :as vars]))
|
||||||
|
|
||||||
|
(def datascript-ns (vars/->SciNamespace 'datascript.core nil))
|
||||||
|
|
||||||
|
(def datascript-namespace
|
||||||
|
{'create-conn (copy-var d/create-conn datascript-ns)
|
||||||
|
'transact! (copy-var d/transact! datascript-ns)
|
||||||
|
'q (copy-var d/q datascript-ns)})
|
||||||
|
|
@ -33,6 +33,8 @@
|
||||||
:dependencies [[org.clojure/data.csv "1.0.0"]]}
|
:dependencies [[org.clojure/data.csv "1.0.0"]]}
|
||||||
:feature/transit {:source-paths ["feature-transit"]
|
:feature/transit {:source-paths ["feature-transit"]
|
||||||
:dependencies [[com.cognitect/transit-clj "1.0.324"]]}
|
:dependencies [[com.cognitect/transit-clj "1.0.324"]]}
|
||||||
|
:feature/datascript {:source-paths ["feature-datascript"]
|
||||||
|
:dependencies [[datascript "0.18.11"]]}
|
||||||
:test [:feature/xml
|
:test [:feature/xml
|
||||||
:feature/yaml
|
:feature/yaml
|
||||||
:feature/postgresql
|
:feature/postgresql
|
||||||
|
|
@ -40,6 +42,7 @@
|
||||||
:feature/core-async
|
:feature/core-async
|
||||||
:feature/csv
|
:feature/csv
|
||||||
:feature/transit
|
:feature/transit
|
||||||
|
:feature/datascript
|
||||||
{:dependencies [[clj-commons/conch "0.9.2"]
|
{:dependencies [[clj-commons/conch "0.9.2"]
|
||||||
[com.clojure-goes-fast/clj-async-profiler "0.4.1"]]}]
|
[com.clojure-goes-fast/clj-async-profiler "0.4.1"]]}]
|
||||||
:uberjar {:global-vars {*assert* false}
|
:uberjar {:global-vars {*assert* false}
|
||||||
|
|
|
||||||
2
sci
2
sci
|
|
@ -1 +1 @@
|
||||||
Subproject commit 87f6160dd84d569a93967b644761bb374d0204c3
|
Subproject commit 67fd9bc9cbde315c78e5178d450094d2255b3414
|
||||||
|
|
@ -74,6 +74,13 @@ else
|
||||||
BABASHKA_LEIN_PROFILES+=",-feature/transit"
|
BABASHKA_LEIN_PROFILES+=",-feature/transit"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$BABASHKA_FEATURE_DATASCRIPT" = "true" ]
|
||||||
|
then
|
||||||
|
BABASHKA_LEIN_PROFILES+=",+feature/datascript"
|
||||||
|
else
|
||||||
|
BABASHKA_LEIN_PROFILES+=",-feature/datascript"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$BABASHKA_JAR" ]; then
|
if [ -z "$BABASHKA_JAR" ]; then
|
||||||
lein with-profiles "$BABASHKA_LEIN_PROFILES,+reflection,-uberjar" do run
|
lein with-profiles "$BABASHKA_LEIN_PROFILES,+reflection,-uberjar" do run
|
||||||
lein with-profiles "$BABASHKA_LEIN_PROFILES" do clean, uberjar
|
lein with-profiles "$BABASHKA_LEIN_PROFILES" do clean, uberjar
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,12 @@ if not "%BABASHKA_FEATURE_TRANSIT%"=="false" (
|
||||||
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/transit
|
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/transit
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if "%BABASHKA_FEATURE_DATASCRIPT%"=="true" (
|
||||||
|
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,+feature/datascript
|
||||||
|
) else (
|
||||||
|
set BABASHKA_LEIN_PROFILES=%BABASHKA_LEIN_PROFILES%,-feature/datascript
|
||||||
|
)
|
||||||
|
|
||||||
call lein with-profiles %BABASHKA_LEIN_PROFILES% bb "(+ 1 2 3)"
|
call lein with-profiles %BABASHKA_LEIN_PROFILES% bb "(+ 1 2 3)"
|
||||||
|
|
||||||
call lein with-profiles %BABASHKA_LEIN_PROFILES%,+reflection,-uberjar do run
|
call lein with-profiles %BABASHKA_LEIN_PROFILES%,+reflection,-uberjar do run
|
||||||
|
|
|
||||||
|
|
@ -14,3 +14,4 @@
|
||||||
(def jdbc? (= "true" (System/getenv "BABASHKA_FEATURE_JDBC")))
|
(def jdbc? (= "true" (System/getenv "BABASHKA_FEATURE_JDBC")))
|
||||||
(def postgresql? (= "true" (System/getenv "BABASHKA_FEATURE_POSTGRESQL")))
|
(def postgresql? (= "true" (System/getenv "BABASHKA_FEATURE_POSTGRESQL")))
|
||||||
(def hsqldb? (= "true" (System/getenv "BABASHKA_FEATURE_HSQLDB")))
|
(def hsqldb? (= "true" (System/getenv "BABASHKA_FEATURE_HSQLDB")))
|
||||||
|
(def datascript? (= "true" (System/getenv "BABASHKA_FEATURE_DATASCRIPT")))
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,9 @@
|
||||||
(when features/transit?
|
(when features/transit?
|
||||||
(require '[babashka.impl.transit]))
|
(require '[babashka.impl.transit]))
|
||||||
|
|
||||||
|
(when features/datascript?
|
||||||
|
(require '[babashka.impl.datascript]))
|
||||||
|
|
||||||
(sci/alter-var-root sci/in (constantly *in*))
|
(sci/alter-var-root sci/in (constantly *in*))
|
||||||
(sci/alter-var-root sci/out (constantly *out*))
|
(sci/alter-var-root sci/out (constantly *out*))
|
||||||
(sci/alter-var-root sci/err (constantly *err*))
|
(sci/alter-var-root sci/err (constantly *err*))
|
||||||
|
|
@ -354,7 +357,8 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that
|
||||||
features/core-async? (assoc 'clojure.core.async @(resolve 'babashka.impl.async/async-namespace)
|
features/core-async? (assoc 'clojure.core.async @(resolve 'babashka.impl.async/async-namespace)
|
||||||
'clojure.core.async.impl.protocols @(resolve 'babashka.impl.async/async-protocols-namespace))
|
'clojure.core.async.impl.protocols @(resolve 'babashka.impl.async/async-protocols-namespace))
|
||||||
features/csv? (assoc 'clojure.data.csv @(resolve 'babashka.impl.csv/csv-namespace))
|
features/csv? (assoc 'clojure.data.csv @(resolve 'babashka.impl.csv/csv-namespace))
|
||||||
features/transit? (assoc 'cognitect.transit @(resolve 'babashka.impl.transit/transit-namespace))))
|
features/transit? (assoc 'cognitect.transit @(resolve 'babashka.impl.transit/transit-namespace))
|
||||||
|
features/datascript? (assoc 'datascript.core @(resolve 'babashka.impl.datascript/datascript-namespace))))
|
||||||
|
|
||||||
(def bindings
|
(def bindings
|
||||||
{'java.lang.System/exit exit ;; override exit, so we have more control
|
{'java.lang.System/exit exit ;; override exit, so we have more control
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue