resources with prefix

This commit is contained in:
Roman Volosovskyi 2019-05-31 18:33:15 +03:00
parent 86c0bfdb73
commit db8b76c02a
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 28 additions and 12 deletions

View File

@ -108,22 +108,36 @@
(defn get-modules
[resource-dirs js-modules]
(->> (for [dir resource-dirs]
(->> (file-seq (io/file dir))
(filter #(and (not (re-find #"DS_Store" (str %)))
(.isFile %)))
(map (fn [file] (when-let [unix-path (->> file .toPath .iterator iterator-seq (str/join "/"))]
(-> (str "./" unix-path)
(str/replace "\\" "/")
(str/replace "@2x" "")
(str/replace "@3x" "")))))))
flatten
(->> (mapcat
(fn [dir]
(let [{:keys [path prefix]} (if (map? dir)
dir
{:path dir
:prefix "./"})]
(->> (file-seq (io/file path))
(filter #(and (not (re-find #"DS_Store" (str %)))
(.isFile %)))
(map (fn [file] (when-let [unix-path (->> file .toPath .iterator iterator-seq (str/join "/"))]
[(-> (str prefix unix-path)
(str/replace "\\" "/")
(str/replace "@2x" "")
(str/replace "@3x" ""))
(-> (str "./" unix-path)
(str/replace "\\" "/")
(str/replace "@2x" "")
(str/replace "@3x" ""))]))))))
resource-dirs)
(concat js-modules ["react" "react-native" "create-react-class"])
distinct))
(defn generate-modules-map
[modules]
(str/join ";" (map #(str "modules['" % "']=require('" % "')") modules)))
(str/join ";" (map (fn [module]
(let [[module-name path] (if (vector? module)
module
[module module])]
(str "modules['" module-name "']=require('" path "')")))
modules)))
(defn rebuild-index-js
[platform {:keys [app-name host-ip js-modules desktop-modules resource-dirs figwheel-bridge]}]

View File

@ -36,7 +36,9 @@
(s/def :config/name (and not-empty-string? #(re-matches #"^[A-Z][A-Za-z0-9]+$" %)))
(s/def :config/js-modules (s/coll-of not-empty-string?))
(s/def :config/desktop-modules (s/coll-of not-empty-string?))
(s/def :config/resource-dirs (s/coll-of not-empty-string?))
(defn resource-dir? [dir]
(or (not-empty-string? dir) (map? dir)))
(s/def :config/resource-dirs (s/coll-of resource-dir?))
(s/def :config/figwheel-bridge not-empty-string?)
(s/def :config/figwheel-options map?)
(s/def :config/builds (s/coll-of map?))