-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use sources defined in deps.edn instead of hard coded values (#224)
Use sources defined in `deps.edn` files + use transducers (thanks @imrekoszo).
- Loading branch information
1 parent
0904efc
commit adf957c
Showing
22 changed files
with
320 additions
and
174 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
11 changes: 11 additions & 0 deletions
11
components/common/src/polylith/clj/core/common/interface/config.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(ns polylith.clj.core.common.interface.config) | ||
|
||
(defn src-paths [config] | ||
(-> config :paths)) | ||
|
||
(defn test-paths [config] | ||
(-> config :aliases :test :extra-paths)) | ||
|
||
(defn source-paths [config] | ||
(concat (src-paths config) | ||
(test-paths config))) |
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
22 changes: 13 additions & 9 deletions
22
components/path-finder/src/polylith/clj/core/path_finder/sources_on_disk.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
(ns polylith.clj.core.path-finder.sources-on-disk | ||
(:require [polylith.clj.core.file.interface :as file])) | ||
|
||
(defn entity-source-paths [ws-dir entity-type entity] | ||
(map #(str entity-type "/" entity "/" %) | ||
(filter #(contains? #{"src" "resources" "test"} %) | ||
(file/directories (str ws-dir "/" entity-type "/" entity))))) | ||
(defn- entity-source-paths [ws-dir entity-type entity] | ||
(eduction | ||
(filter file/not-hidden?) | ||
(map #(str entity-type "/" entity "/" %)) | ||
(file/directories (str ws-dir "/" entity-type "/" entity)))) | ||
|
||
(defn entity-paths [ws-dir entity-type] | ||
(mapcat #(entity-source-paths ws-dir entity-type %) | ||
(file/directories (str ws-dir "/" entity-type)))) | ||
(defn- entity-paths [ws-dir entity-type] | ||
(eduction | ||
(mapcat #(entity-source-paths ws-dir entity-type %)) | ||
(file/directories (str ws-dir "/" entity-type)))) | ||
|
||
(defn source-paths [ws-dir] | ||
(vec (sort (mapcat #(entity-paths ws-dir %) | ||
["bases" "components" "projects"])))) | ||
(->> ["bases" "components" "projects"] | ||
(into [] (mapcat #(entity-paths ws-dir %))) | ||
(sort) | ||
(vec))) |
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
25 changes: 15 additions & 10 deletions
25
components/workspace-clj/src/polylith/clj/core/workspace_clj/bases_from_disk.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
(ns polylith.clj.core.workspace-clj.bases-from-disk | ||
(:require [polylith.clj.core.file.interface :as file] | ||
(:require [polylith.clj.core.common.interface.config :as config] | ||
[polylith.clj.core.file.interface :as file] | ||
[polylith.clj.core.lib.interface :as lib] | ||
[polylith.clj.core.util.interface :as util] | ||
[polylith.clj.core.workspace-clj.brick-dirs :as brick-dirs] | ||
[polylith.clj.core.workspace-clj.brick-paths :as brick-paths] | ||
[polylith.clj.core.workspace-clj.config-from-disk :as config-from-disk] | ||
[polylith.clj.core.workspace-clj.namespaces-from-disk :as ns-from-disk])) | ||
[polylith.clj.core.workspace-clj.namespaces-from-disk :as ns-from-disk] | ||
[polylith.clj.core.workspace-clj.non-top-namespace :as non-top-ns])) | ||
|
||
(defn read-base [ws-dir ws-type user-home top-namespace ns-to-lib top-src-dir brick->non-top-namespaces base-name] | ||
(defn read-base [ws-dir ws-type user-home top-namespace ns-to-lib top-src-dir base-name] | ||
(let [base-dir (str ws-dir "/bases/" base-name) | ||
src-dir (str base-dir "/src/" top-src-dir) | ||
test-dir (str base-dir "/test/" top-src-dir) | ||
namespaces (ns-from-disk/namespaces-from-disk src-dir test-dir) | ||
config (config-from-disk/read-config-file ws-type base-dir) | ||
base-src-dirs (brick-dirs/top-src-dirs base-dir top-src-dir config) | ||
base-test-dirs (brick-dirs/top-test-dirs base-dir top-src-dir config) | ||
namespaces (ns-from-disk/namespaces-from-disk base-src-dirs base-test-dirs) | ||
entity-root-path (str "bases/" base-name) | ||
lib-deps (lib/brick-lib-deps ws-dir ws-type config top-namespace ns-to-lib namespaces entity-root-path user-home)] | ||
lib-deps (lib/brick-lib-deps ws-dir ws-type config top-namespace ns-to-lib namespaces entity-root-path user-home) | ||
source-paths (config/source-paths config) | ||
non-top-namespaces (non-top-ns/non-top-namespaces "base" base-name base-dir top-src-dir source-paths)] | ||
(util/ordered-map :name base-name | ||
:type "base" | ||
:maven-repos (:mvn/repos config) | ||
:paths (brick-paths/source-paths base-dir config) | ||
:namespaces namespaces | ||
:non-top-namespaces (brick->non-top-namespaces base-name) | ||
:non-top-namespaces non-top-namespaces | ||
:lib-deps lib-deps))) | ||
|
||
(defn read-bases | ||
[ws-dir ws-type user-home top-namespace ns-to-lib top-src-dir brick->non-top-namespaces] | ||
(vec (sort-by :name (map #(read-base ws-dir ws-type user-home top-namespace ns-to-lib top-src-dir brick->non-top-namespaces %) | ||
[ws-dir ws-type user-home top-namespace ns-to-lib top-src-dir] | ||
(vec (sort-by :name (map #(read-base ws-dir ws-type user-home top-namespace ns-to-lib top-src-dir %) | ||
(file/directories (str ws-dir "/bases")))))) |
18 changes: 18 additions & 0 deletions
18
components/workspace-clj/src/polylith/clj/core/workspace_clj/brick_dirs.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
(ns polylith.clj.core.workspace-clj.brick-dirs | ||
(:require [polylith.clj.core.common.interface.config :as config])) | ||
|
||
(defn source-dirs [brick-dir paths] | ||
(into [] | ||
(comp (filter #(not= "resources" %)) | ||
(map #(str brick-dir "/" %))) | ||
paths)) | ||
|
||
(defn top-source-dirs [brick-dir top-src-dir paths] | ||
(mapv #(str % "/" top-src-dir) | ||
(source-dirs brick-dir paths))) | ||
|
||
(defn top-src-dirs [brick-dir top-src-dir config] | ||
(top-source-dirs brick-dir top-src-dir (config/src-paths config))) | ||
|
||
(defn top-test-dirs [brick-dir top-src-dir config] | ||
(top-source-dirs brick-dir top-src-dir (config/test-paths config))) |
47 changes: 27 additions & 20 deletions
47
components/workspace-clj/src/polylith/clj/core/workspace_clj/components_from_disk.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,42 @@ | ||
(ns polylith.clj.core.workspace-clj.components-from-disk | ||
(:require [polylith.clj.core.common.interface :as common] | ||
[polylith.clj.core.common.interface.config :as config] | ||
[polylith.clj.core.file.interface :as file] | ||
[polylith.clj.core.lib.interface :as lib] | ||
[polylith.clj.core.util.interface :as util] | ||
[polylith.clj.core.workspace-clj.brick-dirs :as brick-dirs] | ||
[polylith.clj.core.workspace-clj.brick-paths :as brick-paths] | ||
[polylith.clj.core.workspace-clj.non-top-namespace :as non-top-ns] | ||
[polylith.clj.core.workspace-clj.config-from-disk :as config-from-disk] | ||
[polylith.clj.core.workspace-clj.namespaces-from-disk :as ns-from-disk] | ||
[polylith.clj.core.workspace-clj.interface-defs-from-disk :as defs-from-disk])) | ||
|
||
(defn read-component [ws-dir ws-type user-home top-namespace ns-to-lib top-src-dir component-name interface-ns brick->non-top-namespaces] | ||
(defn read-component [ws-dir ws-type user-home top-namespace ns-to-lib top-src-dir component-name interface-ns] | ||
(let [component-dir (str ws-dir "/components/" component-name) | ||
component-src-dir (str component-dir "/src/" top-src-dir) | ||
component-test-dir (str component-dir "/test/" top-src-dir) | ||
interface-path-name (-> component-src-dir file/directories first) | ||
interface-name (common/path-to-ns interface-path-name) | ||
src-dir (str component-src-dir interface-path-name) | ||
namespaces (ns-from-disk/namespaces-from-disk component-src-dir component-test-dir) | ||
definitions (defs-from-disk/defs-from-disk src-dir interface-ns) | ||
config (config-from-disk/read-config-file ws-type component-dir) | ||
component-top-src-dirs (brick-dirs/top-src-dirs component-dir top-src-dir config) | ||
component-top-test-dirs (brick-dirs/top-test-dirs component-dir top-src-dir config) | ||
interface-path-name (first (mapcat file/directories component-top-src-dirs)) | ||
interface-name (common/path-to-ns interface-path-name) | ||
src-dirs (mapv #(str % interface-path-name) | ||
component-top-src-dirs) | ||
namespaces (ns-from-disk/namespaces-from-disk component-top-src-dirs component-top-test-dirs) | ||
definitions (defs-from-disk/defs-from-disk src-dirs interface-ns) | ||
entity-root-path (str "components/" component-name) | ||
lib-deps (lib/brick-lib-deps ws-dir ws-type config top-namespace ns-to-lib namespaces entity-root-path user-home)] | ||
(util/ordered-map :name component-name | ||
:type "component" | ||
:maven-repos (:mvn/repos config) | ||
:paths (brick-paths/source-paths component-dir config) | ||
:namespaces namespaces | ||
:non-top-namespaces (brick->non-top-namespaces component-name) | ||
:lib-deps lib-deps | ||
:interface (util/ordered-map :name interface-name | ||
:definitions definitions)))) | ||
lib-deps (lib/brick-lib-deps ws-dir ws-type config top-namespace ns-to-lib namespaces entity-root-path user-home) | ||
paths (brick-paths/source-paths component-dir config) | ||
source-paths (config/source-paths config) | ||
non-top-namespaces (non-top-ns/non-top-namespaces "component" component-name component-dir top-src-dir source-paths)] | ||
(util/ordered-map :name component-name | ||
:type "component" | ||
:maven-repos (:mvn/repos config) | ||
:paths paths | ||
:namespaces namespaces | ||
:non-top-namespaces non-top-namespaces | ||
:lib-deps lib-deps | ||
:interface (util/ordered-map :name interface-name | ||
:definitions definitions)))) | ||
|
||
(defn read-components [ws-dir ws-type user-home top-namespace ns-to-lib top-src-dir interface-ns brick->non-top-namespaces] | ||
(vec (sort-by :name (map #(read-component ws-dir ws-type user-home top-namespace ns-to-lib top-src-dir % interface-ns brick->non-top-namespaces) | ||
(defn read-components [ws-dir ws-type user-home top-namespace ns-to-lib top-src-dir interface-ns] | ||
(vec (sort-by :name (map #(read-component ws-dir ws-type user-home top-namespace ns-to-lib top-src-dir % interface-ns) | ||
(file/directories (str ws-dir "/components")))))) |
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
Oops, something went wrong.