blob: 636487ee8e6a802d0123482da0bc05c771e6f7df (
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
(.using
[library
[lux (.except local)
[program (.only program:)]
["[0]" debug]
[abstract
[monad (.only do)]]
[control
["[0]" io (.only IO)]
["[0]" maybe]
["[0]" try (.only Try) (.open: "[1]#[0]" functor)]
["[0]" exception (.only exception:)]
[parser
[environment (.only Environment)]]
[concurrency
["[0]" async (.only Async) (.open: "[1]#[0]" monad)]]]
[data
[binary (.only Binary)]
["[0]" text (.only)
["%" \\format (.only format)]
[encoding
["[0]" utf8]]]
[format
["[0]" xml]]
[collection
["[0]" set]
["[0]" dictionary (.only Dictionary)]
["[0]" list (.open: "[1]#[0]" functor)]]]
[tool
[compiler
[language
[lux
["[0]" syntax]]]]]
[world
["[0]" shell (.only Exit Shell)]
["[0]" console (.only Console)]
["[0]" program (.only Program)]
["[0]" file (.only Path)
["[0]" watch]]
[net
["[0]" http
["[1]" client]]]]]]
["[0]" /
["[1]" profile]
["[1][0]" action (.only Action)]
["[1][0]" project (.only Project)]
["[1][0]" input]
["[1][0]" pom]
["[1][0]" cli]
["[1][0]" dependency
["[1]" resolution (.only Resolution)]]
["[1][0]" repository (.only Repository)
["[1]/[0]" remote (.only Address)]
["[1]/[0]" local]]
["[1][0]" command (.only Command)
["[1]/[0]" version]
["[1]/[0]" clean]
["[1]/[0]" pom]
["[1]/[0]" install]
["[1]/[0]" deps]
["[1]/[0]" build]
["[1]/[0]" test]
["[1]/[0]" auto]
["[1]/[0]" deploy]]])
(def: repositories
(-> /.Profile (List (Repository Async)))
(|>> (the /.#repositories)
set.list
(list#each (|>> (/repository/remote.repository http.default {.#None}) /repository.async))))
(def: program (program.async program.default))
(def: fs (file.async file.default))
(def: local (/repository/local.repository ..program ..fs))
(def: (with_dependencies program console command profile)
(All (_ a)
(-> (Program Async) (Console Async)
(-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit a]))
(Command a)))
(do /action.monad
[resolution (/command/deps.do! console
(/repository/local.repository program (file.async file.default))
(..repositories profile)
(|>> (/repository/remote.repository http.default {.#None})
/repository.async)
profile)
[exit_code output] ((command console program (file.async file.default) (shell.async shell.default) resolution) profile)
_ (case exit_code
(pattern (static shell.normal))
(in [])
_
(do async.monad
[_ (at program exit exit_code)]
(in {try.#Failure ""})))]
(in output)))
(exception: (cannot_find_repository [repository Text
options (Dictionary Text Address)])
(exception.report
"Repository" (%.text repository)
"Options" (exception.listing (function (_ [name repo])
(format (%.text name) " := " (%.text repo)))
(dictionary.entries options))))
(def: succeed!
(IO Any)
(at program.default exit shell.normal))
(def: (fail! error)
(-> Text (IO Any))
(exec
(debug.log! error)
(at program.default exit shell.error)))
(def: (command action)
(All (_ a) (-> (Async (Try a)) (IO Any)))
(exec
(do async.monad
[outcome action]
(async.future
(case outcome
{try.#Success _}
..succeed!
{try.#Failure error}
(..fail! error))))
(at io.monad in [])))
(exception: .public invalid_operation)
(`` (def: write_only
(Console IO)
(implementation
(~~ (with_template [<name>]
[(def: (<name> _)
(io.io (exception.except ..invalid_operation [])))]
[read]
[read_line]
[close]
))
(def: (write it)
(<| io.io
{try.#Success}
debug.log!
(if (text.ends_with? text.\n it)
(maybe.trusted (text.clip 0 (-- (text.size it)) it))
it))))))
(program: [[profiles operation] /cli.command]
(do [! io.monad]
[console (at ! each (|>> (try.else ..write_only) console.async)
console.default)]
(case operation
{/cli.#Version}
(..command
(/command/version.do! console (at /.monoid identity)))
_
(do !
[?profile (/input.read io.monad file.default profiles)]
(case ?profile
{try.#Failure error}
(..fail! error)
{try.#Success profile}
(case operation
{/cli.#Version}
(in [])
{/cli.#Clean}
(..command
(/command/clean.do! console (file.async file.default) profile))
{/cli.#POM}
(..command
(/command/pom.do! console (file.async file.default) profile))
{/cli.#Install}
(..command
(/command/install.do! console ..fs ..local profile))
{/cli.#Deploy repository identity}
(..command
(case (the /.#identity profile)
{.#Some artifact}
(case (dictionary.value repository (the /.#deploy_repositories profile))
{.#Some remote}
(/command/deploy.do! ..program
(shell.async shell.default)
console
..local
(/repository.async (/repository/remote.repository http.default {.#Some identity} remote))
(file.async file.default)
artifact
profile)
{.#None}
(async#in (exception.except ..cannot_find_repository [repository (the /.#deploy_repositories profile)])))
{.#None}
(async#in (exception.except /.no_identity []))))
{/cli.#Dependencies}
(..command
(/command/deps.do! console
(/repository/local.repository ..program (file.async file.default))
(..repositories profile)
(|>> (/repository/remote.repository http.default {.#None})
/repository.async)
profile))
{/cli.#Compilation compilation}
(case compilation
{/cli.#Build} (..command
(..with_dependencies ..program console /command/build.do! profile))
{/cli.#Test} (..command
(..with_dependencies ..program console /command/test.do! profile)))
{/cli.#Auto auto}
(do !
[?watcher watch.default]
(case ?watcher
{try.#Failure error}
(..fail! error)
{try.#Success watcher}
(..command
(case auto
{/cli.#Build} (..with_dependencies ..program console (/command/auto.do! /command/auto.delay watcher /command/build.do!) profile)
{/cli.#Test} (..with_dependencies ..program console (/command/auto.do! /command/auto.delay watcher /command/test.do!) profile))))))
)))))
|