/
m203_path_exists_in_both_dev_and_profile.clj
23 lines (22 loc) · 1.28 KB
/
m203_path_exists_in_both_dev_and_profile.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(ns polylith.clj.core.validator.m203-path-exists-in-both-dev-and-profile
(:require [clojure.set :as set]
[clojure.string :as str]
[polylith.clj.core.common.interface :as common]
[polylith.clj.core.util.interface :as util]
[polylith.clj.core.util.interface.color :as color]))
(defn profile-warning [[profile {:keys [paths]}] dev-paths color-mode]
(let [shared-paths (set/intersection dev-paths (set paths))
message (str "The same path exists in both the " (color/project "development" color-mode) " project "
"and the " (color/profile profile color-mode) " profile: "
(str/join ", " (map #(color/path % color-mode) shared-paths)))]
(when (-> shared-paths empty? not)
[(util/ordered-map :type "warning"
:code 203
:message (color/clean-colors message)
:colorized-message message)])))
(defn warnings [settings projects color-mode]
(let [profile-to-settings (:profile-to-settings settings)
{:keys [unmerged]} (common/find-project "dev" projects)
{:keys [paths]} unmerged
dev-paths (set (concat (:src paths) (:test paths)))]
(mapcat #(profile-warning % dev-paths color-mode) profile-to-settings)))