Skip to content

Commit 6ca059f

Browse files
Add ClojureScript support
1 parent 7bf0581 commit 6ca059f

File tree

24 files changed

+161
-133
lines changed

24 files changed

+161
-133
lines changed

components/clojure-test-test-runner/src/polylith/clj/core/clojure_test_test_runner/core.clj

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,26 @@
1010
(require '~ns-symbol)
1111
(clojure.test/run-tests '~ns-symbol))))
1212

13+
(defn- clj-namespace? [{:keys [file-path]}]
14+
(or (str/ends-with? file-path ".clj")
15+
(str/ends-with? file-path ".cljc")))
16+
1317
(defn brick-test-namespaces [bricks test-brick-names]
14-
(let [brick-name->namespaces (into {} (map (juxt :name #(-> % :namespaces :test))) bricks)]
15-
(into []
16-
(comp (mapcat brick-name->namespaces)
17-
(map :namespace))
18-
test-brick-names)))
18+
(let [brick-name->namespaces (->> bricks
19+
(map (juxt :name #(-> % :namespaces :test)))
20+
(into {}))]
21+
(->> test-brick-names
22+
(mapcat brick-name->namespaces)
23+
(filter clj-namespace?)
24+
(map :namespace)
25+
(into []))))
1926

2027
(defn project-test-namespaces [project-name projects-to-test namespaces]
2128
(when (contains? (set projects-to-test) project-name)
22-
(mapv :namespace (:test namespaces))))
29+
(->> (:test namespaces)
30+
(filter clj-namespace?)
31+
(map :namespace)
32+
(into []))))
2333

2434
(defn components-msg [component-names color-mode]
2535
(when (seq component-names)

components/common/src/polylith/clj/core/common/core.clj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
[polylith.clj.core.util.interface :as util]
55
[polylith.clj.core.user-config.interface :as user-config]))
66

7-
(def cljs? false)
8-
97
(def entity->short {"w" "w"
108
"p" "p"
119
"b" "b"
@@ -67,11 +65,12 @@
6765
(defn hidden-file? [path]
6866
(str/starts-with? (path->filename path) "."))
6967

70-
(defn filter-clojure-paths [paths]
68+
(defn filter-clojure-paths [ws-dialects paths]
7169
(filterv #(and
72-
(or (str/ends-with? % ".clj")
73-
(and cljs? (str/ends-with? % ".cljs"))
74-
(str/ends-with? % ".cljc"))
70+
(or (str/ends-with? % ".cljc")
71+
(str/ends-with? % ".clj")
72+
(and (contains? ws-dialects "cljs")
73+
(str/ends-with? % ".cljs")))
7574
;; E.g. temporary emacs files might give problems
7675
(not (hidden-file? %)))
7776
paths))

components/common/src/polylith/clj/core/common/interface.clj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
[polylith.clj.core.common.validate-args :as validate-args]
99
[polylith.clj.core.version.interface :as version]))
1010

11-
(def cljs? core/cljs?)
12-
1311
(def entity->short core/entity->short)
1412
(def entity->long core/entity->long)
1513

@@ -43,8 +41,8 @@
4341
(defn extract-namespace [suffixed-top-ns ns-to-extract]
4442
(ns-extractor/extract suffixed-top-ns ns-to-extract))
4543

46-
(defn filter-clojure-paths [paths]
47-
(core/filter-clojure-paths paths))
44+
(defn filter-clojure-paths [ws-dialects paths]
45+
(core/filter-clojure-paths ws-dialects paths))
4846

4947
(defn find-base [base-name bases]
5048
(core/find-base base-name bases))

components/config-reader/src/polylith/clj/core/config_reader/config_reader.clj

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,20 @@
7070
(dirs-with-deps-file ws-dir "project")))
7171

7272
(defn read-development-deps-config-file [ws-dir ws-type]
73-
(let [deps-filename (str ws-dir "/deps.edn")]
74-
(let [{:keys [config error]} (deps-reader/read-deps-file deps-filename "deps.edn")]
75-
(if error
76-
{:error error}
77-
(let [message (validator/validate-project-dev-config ws-type config "./deps.edn")]
78-
(if message
79-
{:error message}
80-
{:deps config
81-
:is-dev true
82-
:name "development"
83-
:type "project"
84-
:project-name "development"
85-
:project-dir (str ws-dir "/development")
86-
:project-config-dir ws-dir}))))))
73+
(let [deps-filename (str ws-dir "/deps.edn")
74+
{:keys [config error]} (deps-reader/read-deps-file deps-filename "deps.edn")]
75+
(if error
76+
{:error error}
77+
(let [message (validator/validate-project-dev-config ws-type config "./deps.edn")]
78+
(if message
79+
{:error message}
80+
{:deps config
81+
:is-dev true
82+
:name "development"
83+
:type "project"
84+
:project-name "development"
85+
:project-dir (str ws-dir "/development")
86+
:project-config-dir ws-dir})))))
8787

8888
(defn clean-project-configs [configs]
8989
(mapv #(dissoc %
@@ -99,12 +99,12 @@
9999
(filter-config-files)))
100100

101101
(defn read-workspace-config-file [ws-dir]
102-
(let [filename-path (str ws-dir "/workspace.edn")]
103-
(let [{:keys [config error]} (deps-reader/read-deps-file filename-path "workspace.edn")]
104-
(if error
105-
{:error error}
106-
(let [message (validator/validate-workspace-config config)]
107-
(if message
108-
{:error (str "Error in ./workspace.edn: " message)
109-
:config config}
110-
{:config config}))))))
102+
(let [filename-path (str ws-dir "/workspace.edn")
103+
{:keys [config error]} (deps-reader/read-deps-file filename-path "workspace.edn")]
104+
(if error
105+
{:error error}
106+
(let [message (validator/validate-workspace-config config)]
107+
(if message
108+
{:error (str "Error in ./workspace.edn: " message)
109+
:config config}
110+
{:config config})))))

components/config-reader/src/polylith/clj/core/config_reader/deps_reader.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
new-paths
1616
[new-paths]))))
1717

18-
(defn substitute-alias [sources alias->path]
18+
(defn substitute-alias
1919
"If the incoming vector of sources are strings, e.g. ['src' 'resources'] then do nothing,
2020
but if it is an alias, e.g. [:src-paths :resources-paths], then return the substituted values
2121
taken from the alias->path map."
22+
[sources alias->path]
2223
(vec (mapcat #(substitute-if-alias % alias->path)
2324
sources)))
2425

components/config-reader/src/polylith/clj/core/config_reader/interface.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
[polylith.clj.core.config-reader.ws-root :as ws-root]))
66

77
(defn file-exists?
8-
[filename _]
98
"The second argument is used for test purposes."
9+
[filename _]
1010
(check-file/file-exists? filename))
1111

1212
(defn clean-project-configs [configs]

components/creator/resources/creator/templates/workspace.edn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{:top-namespace "{{top-ns}}"
22
:interface-ns "interface"
33
:default-profile-name "default"
4+
:dialects #{"clj"}
45
:compact-views #{}
56
:vcs {:name "git"
67
:auto-add false}

components/creator/test/polylith/clj/core/creator/workspace_test.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
(is (= ["{:top-namespace \"se.example\""
136136
" :interface-ns \"interface\""
137137
" :default-profile-name \"default\""
138+
" :dialects #{\"clj\"}"
138139
" :compact-views #{}"
139140
" :vcs {:name \"git\""
140141
" :auto-add false}"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(ns ^:no-doc polylith.clj.core.util.interface.dialects)
2+
3+
(def valid-dialects #{"clj" "cljs"})
4+
5+
(defn valid-dialect? [dialect]
6+
(contains? valid-dialects dialect))
7+
8+
(defn clean-dialects [dialects]
9+
(let [valid-dialects (if (coll? dialects)
10+
(->> dialects (filter valid-dialect?) (into #{}))
11+
#{})]
12+
(if (empty? valid-dialects)
13+
#{"clj"}
14+
valid-dialects)))

components/validator/src/polylith/clj/core/validator/datashape/toolsdeps2.clj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@
5757
[:or project-test-config-schema
5858
vector?]]]) ;; legacy
5959

60+
(def dialect
61+
[:enum "clj" "cljs"])
62+
63+
(def dialects-schema
64+
[:or
65+
[:vector {:min 1} dialect]
66+
[:set {:min 1} dialect]])
67+
6068
(def workspace-schema
6169
[:map
6270
[:vcs {:optional true} [:or string? map?]]
@@ -69,7 +77,8 @@
6977
[:tag-patterns {:optional true} map?]
7078
[:projects {:optional true}
7179
[:map-of :string project-settings-schema]]
72-
[:test {:optional true} test-runner-config-schema]])
80+
[:test {:optional true} test-runner-config-schema]
81+
[:dialects {:optional true} dialects-schema]])
7382

7483
(defn validate-workspace-config [config]
7584
(-> workspace-schema

0 commit comments

Comments
 (0)