-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract ubiq as a lib and erp as an app, logging is still an issue
- Loading branch information
shivekkhurana
committed
May 8, 2019
1 parent
41c12f4
commit 75954ff
Showing
19 changed files
with
88 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,5 @@ pom.xml.asc | |
.hgignore | ||
.hg/ | ||
.cpcache | ||
resources/dev.db | ||
resources/**/dev.db | ||
log/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{:app-folder "erp_app" | ||
:sqlite-config | ||
#profile | ||
{:dev {:classname "org.sqlite.JDBC" | ||
:subprotocol "sqlite" | ||
:subname #join ["resources/" #ref [:app-folder] "/dev.db"]}} | ||
|
||
:seed-data? | ||
#profile | ||
{:default false | ||
:dev true} | ||
|
||
:system | ||
{:graphql-server {:enable-graphiql? true | ||
:port 8000 | ||
:resolver #ig/ref :resolver | ||
:domain #ig/ref :domain | ||
:schema-resource #join [#ref [:app-folder] "/schema.edn"]} | ||
:migrator {:db #ref [:sqlite-config] | ||
:migrations-folder #join [#ref [:app-folder] "/migrations"]} | ||
:resolver {:domain #ig/ref :domain | ||
:resolver-config-resource #join [#ref [:app-folder] "/resolvers.edn"]} | ||
:domain {:db #ref [:sqlite-config] | ||
:sql-folder #join ["src/" #ref [:app-folder] "/sql"]} | ||
:seeder {:seed-count {:parties 10} | ||
:seed-data? #ref [:seed-data?] | ||
:domain #ig/ref :domain | ||
:migrator #ig/ref :migrator}}} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
(ns ubiq.components.domain | ||
(:require [clojure.java.io :as io] | ||
[clojure.string :as str] | ||
[hugsql.core :as hugsql] | ||
[integrant.core :as ig])) | ||
|
||
(defn- get-db-fns-map [file-path-dot-sql] | ||
(hugsql/map-of-db-fns file-path-dot-sql)) | ||
|
||
(defn- read-file-tree | ||
"Given a directory path, recursively read all files | ||
and return a vector containing path of all files." | ||
[path] | ||
(->> path | ||
io/file | ||
file-seq | ||
(filter #(.isFile %)) | ||
(map #(.getPath %)))) | ||
|
||
(defn- inject-db [db db-fns-map] | ||
(into {} (map (fn [[k v]] | ||
[k (partial (:fn v) db)]) | ||
db-fns-map))) | ||
|
||
(defn- path->file [p] | ||
(last (str/split p #"/"))) | ||
|
||
(defmethod ig/init-key :domain [_ {:keys [db sql-folder]}] | ||
(let [sql-file-paths (read-file-tree sql-folder) ; read all files in src/sql folder returns ("src/erp_app/sql/products.sql" "src/erp_app/sql/parties.sql") | ||
sql-files (map path->file sql-file-paths) ; figure out the name of sql file (sql folder cannot have sub folders with this setup) | ||
sql-folder-without-src (str/replace sql-folder #"src/" "")] | ||
(into {} (map (fn [file-name-dot-sql] | ||
[(keyword (str/replace file-name-dot-sql #".sql" "")) | ||
(inject-db db (get-db-fns-map (str sql-folder-without-src "/" file-name-dot-sql)))]) | ||
sql-files)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/components/migrator.clj → src/ubiq/components/migrator.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
(ns intercepts.auth) | ||
(ns ubiq.intercepts.auth) | ||
|
||
(defn- is-logged-in? [_] | ||
true) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters