aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/command/deps.lux
blob: 0cce84d7c0fa316b40d0843a2143b9fdf2e8467b (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
(.module:
  [library
   [lux "*"
    [abstract
     [monad {"+" [do]}]]
    [control
     ["[0]" exception]
     [concurrency
      ["[0]" async {"+" [Async]}]]]
    [data
     [collection
      ["[0]" set {"+" [Set]}]
      ["[0]" list ("[1]\[0]" mix)]
      ["[0]" dictionary]]
     [text
      ["%" format]]]
    [world
     [net {"+" [URL]}]
     [program {"+" [Program]}]
     ["[0]" file]
     ["[0]" console {"+" [Console]}]]]]
  ["[0]" // "_"
   ["[1][0]" clean]
   ["/[1]" // "_"
    [command {"+" [Command]}]
    [repository {"+" [Repository]}]
    ["[1]" profile]
    ["[1][0]" action {"+" [Action]}]
    ["[1][0]" artifact {"+" [Artifact]}]
    ["[1][0]" dependency {"+" [Dependency]}
     ["[1]/[0]" resolution {"+" [Resolution]}]
     ["[1]/[0]" deployment]]]])

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

(def: .public (do! console local remotes new_repository profile)
  (-> (Console Async) (Repository Async) (List (Repository Async)) (-> URL (Repository Async)) (Command Resolution))
  (do async.monad
    [.let [dependencies (|> (value@ #///.dependencies profile)
                            set.list
                            (#.Item (value@ #///.compiler profile)))]
     [local_successes local_failures cache] (///dependency/resolution.all console
                                                                          (list local)
                                                                          new_repository
                                                                          dependencies
                                                                          ///dependency/resolution.empty)
     [remote_successes remote_failures resolution] (///dependency/resolution.all console
                                                                                 remotes
                                                                                 new_repository
                                                                                 dependencies
                                                                                 cache)]
    (do ///action.monad
      [cached (|> (dictionary.keys cache)
                  (list\mix dictionary.lacks resolution)
                  (///dependency/deployment.all local))
       _ (console.write_line (exception.report
                              ["Local successes" (|> local_successes
                                                     (list.sorted (\ ///dependency.order <))
                                                     (exception.listing ..format))]
                              ["Local failures" (|> local_failures
                                                    (list.sorted (\ ///dependency.order <))
                                                    (exception.listing ..format))]
                              ["Remote successes" (|> remote_successes
                                                      (set.of_list ///dependency.hash)
                                                      (set.difference (set.of_list ///dependency.hash local_successes))
                                                      set.list
                                                      (list.sorted (\ ///dependency.order <))
                                                      (exception.listing ..format))]
                              ["Remote failures" (|> remote_failures
                                                     (list.sorted (\ ///dependency.order <))
                                                     (exception.listing ..format))])
                             console)]
      (in resolution))))