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

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

(def: #export (do! console local remotes new_repository profile)
  (-> (Console Promise) (Repository Promise) (List (Repository Promise)) (-> URL (Repository Promise)) (Command Resolution))
  (do promise.monad
    [#let [dependencies (|> (get@ #///.dependencies profile)
                            set.to_list
                            (#.Cons (get@ #///.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\fold dictionary.remove resolution)
                  (///dependency/deployment.all local))
       _ (console.write_line (exception.report
                              ["Local successes" (|> local_successes
                                                     (list.sort (\ ///dependency.order <))
                                                     (exception.enumerate ..format))]
                              ["Local failures" (|> local_failures
                                                    (list.sort (\ ///dependency.order <))
                                                    (exception.enumerate ..format))]
                              ["Remote successes" (|> remote_successes
                                                      (set.from_list ///dependency.hash)
                                                      (set.difference (set.from_list ///dependency.hash local_successes))
                                                      set.to_list
                                                      (list.sort (\ ///dependency.order <))
                                                      (exception.enumerate ..format))]
                              ["Remote failures" (|> remote_failures
                                                     (list.sort (\ ///dependency.order <))
                                                     (exception.enumerate ..format))])
                             console)]
      (wrap resolution))))