|
|
@@ -24,22 +24,28 @@
|
|
|
|
|
|
(defn- setup-init-data
|
|
|
"Setup initial data same as frontend.handler.repo/create-db"
|
|
|
- [conn]
|
|
|
- (let [config-content (or (some-> (find-on-classpath "templates/config.edn") fs/readFileSync str)
|
|
|
- (do (println "Setting graph's config to empty since no templates/config.edn was found.")
|
|
|
- "{}"))]
|
|
|
+ [conn additional-config]
|
|
|
+ (let [config-content
|
|
|
+ (cond-> (or (some-> (find-on-classpath "templates/config.edn") fs/readFileSync str)
|
|
|
+ (do (println "Setting graph's config to empty since no templates/config.edn was found.")
|
|
|
+ "{}"))
|
|
|
+ additional-config
|
|
|
+ ;; TODO: Replace with rewrite-clj when it's available
|
|
|
+ (string/replace-first #"(:file/name-format :triple-lowbar)"
|
|
|
+ (str "$1 "
|
|
|
+ (string/replace-first (str additional-config) #"^\{(.*)\}$" "$1"))))]
|
|
|
(d/transact! conn (sqlite-create-graph/build-db-initial-data @conn config-content))))
|
|
|
|
|
|
(defn init-conn
|
|
|
"Create sqlite DB, initialize datascript connection and sync listener and then
|
|
|
transacts initial data"
|
|
|
- [dir db-name]
|
|
|
+ [dir db-name & {:keys [additional-config]}]
|
|
|
(fs/mkdirSync (node-path/join dir db-name) #js {:recursive true})
|
|
|
;; Same order as frontend.db.conn/start!
|
|
|
(let [conn (sqlite-db/open-db! dir db-name)]
|
|
|
(cli-pipeline/add-listener conn)
|
|
|
(ldb/create-default-pages! conn {:db-graph? true})
|
|
|
- (setup-init-data conn)
|
|
|
+ (setup-init-data conn additional-config)
|
|
|
conn))
|
|
|
|
|
|
(defn- translate-property-value
|