(.require [library [lux (.except all) [abstract [codec (.only Codec)] ["[0]" monad (.only do)]] [control ["[0]" try (.only Try)] [concurrency ["[0]" async (.only Async)]]] [data [binary (.only Binary)] ["[0]" product] [text ["%" \\format (.only format)] [encoding ["[0]" utf8]]] [collection ["[0]" dictionary] ["[0]" set (.only Set)] ["[0]" list (.use "[1]#[0]" monoid)]]] [world [time ["[0]" instant (.only Instant)]]]]] ["[0]" /// [repository (.only Repository)] ["[1][0]" hash (.only Hash)] ["[1][0]" package (.only Package)] ["[1][0]" artifact (.only Artifact) ["[1]/[0]" time] ["[1]/[0]" type] ["[1]/[0]" extension (.only Extension)] ["[1]/[0]" versioning] ["[1]/[0]" snapshot (.only) ["[1]/[0]" version (.only) ["[1]/[0]" value]]]] ["[1][0]" metadata ["[1]/[0]" artifact] ["[1]/[0]" snapshot (.only Metadata)]] ["[1][0]" dependency (.only Dependency) [resolution (.only Resolution)] ["[1]/[0]" status (.only Status)]]]) (def (with_status repository version_template [artifact type] [data status]) (-> (Repository Async) ///artifact.Version Dependency [Binary Status] (Async (Try Any))) (let [artifact (format (///artifact.uri version_template artifact) (///artifact/extension.extension type)) deploy_hash (is (All (_ h) (-> (Codec Text (Hash h)) Extension (Hash h) (Async (Try Any)))) (function (_ codec extension hash) (|> hash (at codec encoded) (at utf8.codec encoded) (at repository upload (format artifact extension)))))] (do [! (try.with async.monad)] [_ (at repository upload artifact data)] (case status {///dependency/status.#Unverified} (in []) {///dependency/status.#Partial partial} (case partial {.#Left sha-1} (deploy_hash ///hash.sha-1_codec ///artifact/extension.sha-1 sha-1) {.#Right md5} (deploy_hash ///hash.md5_codec ///artifact/extension.md5 md5)) {///dependency/status.#Verified sha-1 md5} (do ! [_ (deploy_hash ///hash.sha-1_codec ///artifact/extension.sha-1 sha-1)] (deploy_hash ///hash.md5_codec ///artifact/extension.md5 md5)))))) (def (artifacts type status) (-> ///artifact/type.Type Status (List ///artifact/type.Type)) (with_expansions [ (format type ///artifact/extension.sha-1) (format type ///artifact/extension.md5)] (list.partial type (case status {///dependency/status.#Unverified} (list) {///dependency/status.#Partial partial} (list (case partial {.#Left _} {.#Right _} )) {///dependency/status.#Verified _} (list ))))) (def (update_snapshot [artifact type] now snapshot) (-> Dependency Instant Metadata (Try Metadata)) (do try.monad [now (is (Try ///artifact/time.Time) (///artifact/time.of_instant now)) .let [version_template (the ///artifact.#version artifact) snapshot (|> snapshot (revised [///metadata/snapshot.#versioning ///artifact/versioning.#snapshot] (function (_ snapshot) (case snapshot {///artifact/snapshot.#Local} {///artifact/snapshot.#Local} {///artifact/snapshot.#Remote [_ build]} {///artifact/snapshot.#Remote [now (++ build)]}))) (has [///metadata/snapshot.#versioning ///artifact/versioning.#last_updated] now)) versioning_snapshot (the [///metadata/snapshot.#versioning ///artifact/versioning.#snapshot] snapshot)]] (in (|> snapshot (has [///metadata/snapshot.#versioning ///artifact/versioning.#versions] (list [///artifact/snapshot/version.#extension type ///artifact/snapshot/version.#value (///artifact/snapshot/version/value.format [///artifact/snapshot/version/value.#version version_template ///artifact/snapshot/version/value.#snapshot versioning_snapshot]) ///artifact/snapshot/version.#updated now])) ... (has [///metadata/snapshot.#versioning ///artifact/versioning.#snapshot] ... (list#composite (..artifacts type (product.right (the ///package.#library package))) ... (..artifacts ///artifact/type.pom (product.right (the ///package.#pom package))))) )))) (def .public (one repository [artifact type] package) (-> (Repository Async) Dependency Package (Async (Try Artifact))) (do [! async.monad] [now (async.future instant.now) .let [version_template (the ///artifact.#version artifact)]] (do (try.with !) [_ (with_status repository version_template [artifact type] (the ///package.#library package)) _ (let [[pom pom_data status] (the ///package.#pom package)] (with_status repository version_template [artifact ///artifact/type.pom] [pom_data status])) snapshot (///metadata/snapshot.read repository artifact) snapshot (at ! in (..update_snapshot [artifact type] now snapshot)) _ (///metadata/snapshot.write repository artifact snapshot) project (///metadata/artifact.read repository artifact) _ (|> project (has ///metadata/artifact.#versions (list version_template)) (has ///metadata/artifact.#last_updated now) (///metadata/artifact.write repository artifact))] (in artifact)))) (def .public (all repository resolution) (-> (Repository Async) Resolution (Async (Try (Set Artifact)))) (let [! (try.with async.monad)] (|> (dictionary.entries resolution) (monad.each ! (function (_ [dependency package]) (..one repository dependency package))) (at ! each (set.of_list ///artifact.hash)))))