aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/command/deps.lux
blob: 14b5d803fa5df22f7eac3d7926557bfaeab0ef2b (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
(.module:
  [lux #*
   [abstract
    [monad (#+ do)]]
   [control
    ["." exception]
    [concurrency
     ["." promise (#+ Promise)]]]
   [data
    [collection
     ["." set (#+ Set)]
     ["." list ("#\." fold)]
     ["." dictionary]]
    [text
     ["%" format (#+ format)]]]
   [world
    [program (#+ Program)]
    ["." file]
    ["." console (#+ Console)]]]
  ["." // #_
   ["#." clean]
   ["/#" // #_
    [command (#+ Command)]
    [repository (#+ Repository)]
    ["#" profile]
    ["#." action (#+ Action)]
    ["#." artifact (#+ Artifact)]
    ["#." dependency (#+ Dependency)
     ["#/." resolution (#+ Resolution)]
     ["#/." deployment]]]])

(def: %dependency
  (%.Format Dependency)
  (|>> (get@ #///dependency.artifact)
       ///artifact.format
       %.text))

(def: #export (do! console local remotes profile)
  (-> (Console Promise) (Repository Promise) (List (Repository Promise)) (Command Resolution))
  (do promise.monad
    [#let [dependencies (set.to_list (get@ #///.dependencies profile))]
     [local_successes local_failures cache] (///dependency/resolution.all (list local) dependencies ///dependency/resolution.empty)
     [remote_successes remote_failures resolution] (///dependency/resolution.all remotes dependencies cache)]
    (do ///action.monad
      [cached (|> (dictionary.keys cache)
                  (list\fold dictionary.remove resolution)
                  (///dependency/deployment.all local))
       _ (console.write_line //clean.success console)
       _ (console.write_line (exception.report
                              ["Local successes" (exception.enumerate %dependency local_successes)]
                              ["Local failures" (exception.enumerate %dependency local_failures)]
                              ["Remote successes" (let [remote_successes (|> remote_successes
                                                                             (set.from_list ///dependency.hash)
                                                                             (set.difference (set.from_list ///dependency.hash local_successes))
                                                                             set.to_list)]
                                                    (exception.enumerate %dependency remote_successes))]
                              ["Remote failures" (exception.enumerate %dependency remote_failures)])
                             console)]
      (wrap resolution))))