diff --git a/packages/kmono/src/k16/kmono/adapters/clojure_deps.clj b/packages/kmono/src/k16/kmono/adapters/clojure_deps.clj index a29f813..f847e63 100644 --- a/packages/kmono/src/k16/kmono/adapters/clojure_deps.clj +++ b/packages/kmono/src/k16/kmono/adapters/clojure_deps.clj @@ -47,48 +47,49 @@ (->adapter package-path 10000)) ([package-path timeout-ms] (let [deps-edn (read-deps-edn package-path) - {:keys [group artifact] :as config} - (-> (:kmono/config deps-edn) - (adapter/ensure-artifact package-path)) - coord (str group "/" artifact) - managed-deps (get-local-deps config deps-edn)] - (reify Adapter + kmono-config (:kmono/config deps-edn)] + (when kmono-config + (let [{:keys [group artifact] :as config} + (-> kmono-config + (adapter/ensure-artifact package-path)) + coord (str group "/" artifact) + managed-deps (get-local-deps config deps-edn)] + (reify Adapter - (prepare-deps-env [_ changes] - (binding [*print-namespace-maps* false] - (str "'" - {:deps - (into {} (map - (fn [dep] - [(symbol dep) - {:mvn/version - (get-in changes [dep :version])}])) - managed-deps)} - "'"))) + (prepare-deps-env [_ changes] + (binding [*print-namespace-maps* false] + (str "'" + {:deps + (into {} (map + (fn [dep] + [(symbol dep) + {:mvn/version + (get-in changes [dep :version])}])) + managed-deps)} + "'"))) - (get-managed-deps [_] managed-deps) + (get-managed-deps [_] managed-deps) - (get-kmono-config [_] config) - - (release-published? [_ version] - (-> (p/vthread - (let [;; ignore user's local repository cache - local-repo (str package-path "/.kmono/" artifact "/.m2")] - (try (deps.util.session/with-session - (let [;; ignoring user's machine local m2 repo - versions (->> (deps.ext/find-versions - (symbol coord) - nil - :mvn {:mvn/local-repo local-repo - :mvn/repos - (merge deps.util.maven/standard-repos - (:mvn/repos deps-edn))}) - (map :mvn/version) - (set))] - (contains? versions version))) - (finally - (try (fs/delete-tree local-repo) - (catch Throwable _)))))) - (p/timeout timeout-ms (str "Timeout resolving mvn version for package " coord)) - (deref))))))) + (get-kmono-config [_] config) + (release-published? [_ version] + (-> (p/vthread + (let [;; ignore user's local repository cache + local-repo (str package-path "/.kmono/" artifact "/.m2")] + (try (deps.util.session/with-session + (let [;; ignoring user's machine local m2 repo + versions (->> (deps.ext/find-versions + (symbol coord) + nil + :mvn {:mvn/local-repo local-repo + :mvn/repos + (merge deps.util.maven/standard-repos + (:mvn/repos deps-edn))}) + (map :mvn/version) + (set))] + (contains? versions version))) + (finally + (try (fs/delete-tree local-repo) + (catch Throwable _)))))) + (p/timeout timeout-ms (str "Timeout resolving mvn version for package " coord)) + (deref))))))))) diff --git a/packages/kmono/src/k16/kmono/adapters/kmono_edn.clj b/packages/kmono/src/k16/kmono/adapters/kmono_edn.clj index 3862e40..9b5d332 100644 --- a/packages/kmono/src/k16/kmono/adapters/kmono_edn.clj +++ b/packages/kmono/src/k16/kmono/adapters/kmono_edn.clj @@ -10,25 +10,27 @@ ([package-path] (->adapter package-path 10000)) ([package-path _] - (let [kmono-config (-> (fs/file package-path "kmono.edn") - (slurp) - (edn/read-string)) - config (adapter/ensure-artifact kmono-config package-path) - managed-deps (get config :local-deps [])] - (reify Adapter - - (prepare-deps-env [_ changes] - (string/join - ";" - (map - (fn [dep] - (str (symbol dep) - "@" - (get-in changes [dep :version]))) - managed-deps))) - - (get-managed-deps [_] managed-deps) - - (get-kmono-config [_] config) - - (release-published? [_ _] false))))) + (let [kmono-file (fs/file package-path "kmono.edn")] + (when (fs/exists? kmono-file) + (let [kmono-config (-> kmono-file + (slurp) + (edn/read-string)) + config (adapter/ensure-artifact kmono-config package-path) + managed-deps (get config :local-deps [])] + (reify Adapter + + (prepare-deps-env [_ changes] + (string/join + ";" + (map + (fn [dep] + (str (symbol dep) + "@" + (get-in changes [dep :version]))) + managed-deps))) + + (get-managed-deps [_] managed-deps) + + (get-kmono-config [_] config) + + (release-published? [_ _] false))))))) diff --git a/packages/kmono/src/k16/kmono/config.clj b/packages/kmono/src/k16/kmono/config.clj index da7f9bc..fb0ea3c 100644 --- a/packages/kmono/src/k16/kmono/config.clj +++ b/packages/kmono/src/k16/kmono/config.clj @@ -15,9 +15,8 @@ (defn get-adapter [pkg-dir] - (if (fs/exists? (fs/file pkg-dir "kmono.edn")) - (kmono.edn/->adapter (fs/file pkg-dir)) - (clj.deps/->adapter (fs/file pkg-dir)))) + (or (kmono.edn/->adapter (fs/file pkg-dir)) + (clj.deps/->adapter (fs/file pkg-dir)))) (defn- assert-schema! [?schema value] @@ -30,28 +29,32 @@ (assert-schema! schema/?Config config)) (defn- create-package-config [package-dir] - (let [adapter (get-adapter package-dir) - kb-pkg-config (->> (adapter/get-kmono-config adapter) - (assert-schema! schema/?KmonoPackageConfig)) - artifact (or (:artifact kb-pkg-config) - (symbol (fs/file-name package-dir))) - pkg-name (str (:group kb-pkg-config) "/" artifact) - pkg-commit-sha (git/subdir-commit-sha package-dir)] + (when-let [adapter (get-adapter package-dir)] + (let [kb-pkg-config (->> (adapter/get-kmono-config adapter) + (assert-schema! schema/?KmonoPackageConfig)) + artifact (or (:artifact kb-pkg-config) + (symbol (fs/file-name package-dir))) + pkg-name (str (:group kb-pkg-config) "/" artifact) + pkg-commit-sha (git/subdir-commit-sha package-dir) - (let [pkg-config (merge kb-pkg-config + pkg-config (merge kb-pkg-config {:artifact (or (:artifact kb-pkg-config) (symbol (fs/file-name package-dir))) :name pkg-name :commit-sha pkg-commit-sha :adapter adapter :dir (str package-dir)})] + (->> (assoc pkg-config :depends-on (adapter/get-managed-deps adapter)) (assert-schema! schema/?Package))))) (defn- create-config [repo-root glob] (let [package-dirs (fs/glob repo-root glob)] - {:packages (mapv create-package-config package-dirs)})) + {:packages (->> package-dirs + (map create-package-config) + (remove nil?) + vec)})) (defn create-graph {:malli/schema [:=> [:cat schema/?Packages] schema/?Graph]} @@ -149,4 +152,3 @@ :package-map (->pkg-map packages) :graph graph :build-order (parallel-topo-sort graph)}))))) -