aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex.lux
blob: f3f222d90d985189cc87c8fd90cef2fcb949d955 (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
(.module:
  [lux (#- Name)
   [abstract
    [monad (#+ do)]]
   [control
    [pipe (#+ do>)]
    ["." try (#+ Try)]
    ["." io (#+ IO)]
    [parser
     ["." cli (#+ program:)]
     ["<c>" code]]
    [security
     ["!" capability]]
    [concurrency
     ["." promise (#+ Promise)]]]
   [data
    [binary (#+ Binary)]
    ["." text
     ["%" format (#+ format)]
     ["." encoding]]
    [format
     ["." xml]]
    [collection
     ["." set]]]
   [tool
    [compiler
     [language
      [lux
       ["." syntax]]]]]
   [world
    ["." file (#+ Path)]]]
  ["." / #_
   [action (#+ Action)]
   ["#" profile]
   ["#." project (#+ Project)]
   ["#." input]
   ["#." parser]
   ["#." pom]
   ["#." cli]
   ["#." local]
   ["#." dependency #_
    ["#" resolution]]
   ["#." command
    ["#/." pom]
    ["#/." install]
    ["#/." build]
    ["#/." test]
    ["#/." auto]
    ["#/." deploy]]])

(def: (fetch-dependencies! profile)
  (-> /.Profile (Promise Any))
  (do promise.monad
    [outcome (do (try.with promise.monad)
               [cache (/local.all-cached (file.async file.default)
                                         (set.to-list (get@ #/.dependencies profile))
                                         /dependency.empty)
                resolution (promise.future
                            (/dependency.resolve-all (set.to-list (get@ #/.repositories profile))
                                                     (set.to-list (get@ #/.dependencies profile))
                                                     cache))]
               (/local.cache-all (file.async file.default)
                                 resolution))]
    (wrap (case outcome
            (#try.Success _)
            (log! "Successfully resolved dependencies!")
            
            (#try.Failure error)
            (log! (format "Could not resolve dependencies:" text.new-line
                          error))))))

(program: [{[profile operation] /cli.command}]
  (do {! io.monad}
    [?profile (/input.read io.monad file.default profile)]
    (case ?profile
      (#try.Success profile)
      (case operation
        #/cli.POM
        (exec (/command/pom.do! (file.async file.default) profile)
          (wrap []))
        
        #/cli.Dependencies
        (exec (..fetch-dependencies! profile)
          (wrap []))

        #/cli.Install
        (exec (/command/install.do! (file.async file.default) profile)
          (wrap []))

        (#/cli.Deploy repository user password)
        (exec (/command/deploy.do! repository user password profile)
          (wrap []))

        (#/cli.Compilation compilation)
        (case compilation
          #/cli.Build (exec (/command/build.do! profile)
                        (wrap []))
          #/cli.Test (exec (/command/test.do! profile)
                       (wrap [])))

        (#/cli.Auto auto)
        (exec (case auto
                #/cli.Build (/command/auto.do! /command/build.do! profile)
                #/cli.Test (/command/auto.do! /command/test.do! profile))
          (wrap [])))
      
      (#try.Failure error)
      (wrap (log! error)))))