blob: 29f49b61a38e97de8930ff58e4518476daecafb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
(.module:
[library
[lux "*"
[abstract
[codec {"+" Codec}]
["[0]" monad {"+" do}]]
[control
["[0]" try {"+" Try}]
[concurrency
["[0]" async {"+" Async}]]]
[data
[binary {"+" Binary}]
["[0]" product]
[text
["%" format {"+" format}]
[encoding
["[0]" utf8]]]
[collection
["[0]" dictionary]
["[0]" set {"+" Set}]
["[0]" list ("[1]#[0]" monoid)]]]
[time
["[0]" instant {"+" Instant}]]]]
["[0]" /// "_"
[repository {"+" Repository}]
["[1][0]" hash {"+" Hash}]
["[1][0]" package {"+" Package}]
["[1][0]" artifact {"+" Artifact}
["[1]/[0]" time]
["[1]/[0]" type]
["[1]/[0]" extension {"+" Extension}]
["[1]/[0]" versioning]
["[1]/[0]" snapshot
["[1]/[0]" version
["[1]/[0]" value]]]]
["[1][0]" metadata "_"
["[1]/[0]" artifact]
["[1]/[0]" snapshot {"+" Metadata}]]
["[1][0]" dependency {"+" Dependency}
[resolution {"+" Resolution}]
["[1]/[0]" status {"+" 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 (: (All (_ h) (-> (Codec Text (Hash h)) Extension (Hash h) (Async (Try Any))))
(function (_ codec extension hash)
(|> hash
(# codec encoded)
(# utf8.codec encoded)
(# repository upload (format artifact extension)))))]
(do [! (try.with async.monad)]
[_ (# 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 [<sha-1> (format type ///artifact/extension.sha-1)
<md5> (format type ///artifact/extension.md5)]
(list& type
(case status
{///dependency/status.#Unverified}
(list)
{///dependency/status.#Partial partial}
(list (case partial
{.#Left _} <sha-1>
{.#Right _} <md5>))
{///dependency/status.#Verified _}
(list <sha-1> <md5>)))))
(def: (update_snapshot [artifact type] now snapshot)
(-> Dependency Instant Metadata (Try Metadata))
(do try.monad
[now (: (Try ///artifact/time.Time)
(///artifact/time.of_instant now))
.let [version_template (value@ ///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)]})))
(with@ [///metadata/snapshot.#versioning ///artifact/versioning.#last_updated] now))
versioning_snapshot (value@ [///metadata/snapshot.#versioning ///artifact/versioning.#snapshot] snapshot)]]
(in (|> snapshot
(with@ [///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]))
... (with@ [///metadata/snapshot.#versioning ///artifact/versioning.#snapshot]
... (list#composite (..artifacts type (product.right (value@ ///package.#library package)))
... (..artifacts ///artifact/type.pom (product.right (value@ ///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 (value@ ///artifact.#version artifact)]]
(do (try.with !)
[_ (with_status repository version_template [artifact type] (value@ ///package.#library package))
_ (let [[pom pom_data status] (value@ ///package.#pom package)]
(with_status repository
version_template
[artifact ///artifact/type.pom]
[pom_data
status]))
snapshot (///metadata/snapshot.read repository artifact)
snapshot (# ! in (..update_snapshot [artifact type] now snapshot))
_ (///metadata/snapshot.write repository artifact snapshot)
project (///metadata/artifact.read repository artifact)
_ (|> project
(with@ ///metadata/artifact.#versions (list version_template))
(with@ ///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)))
(# ! each (set.of_list ///artifact.hash)))))
|