aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/command/install.lux
blob: 4cc4ede68e1b8b5c460751347374ff62cb1937bb (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
(.module:
  [library
   [lux #*
    [abstract
     [monad (#+ do)]]
    [control
     ["." try (#+ Try)]
     ["." exception]
     [concurrency
      ["." promise (#+ Promise)]]]
    [data
     [binary (#+ Binary)]
     [text
      [encoding
       ["." utf8]]]
     [collection
      ["." set]]
     [format
      ["." binary]
      ["." tar]
      ["." xml]]]
    [world
     [program (#+ Program)]
     ["." file]
     ["." console (#+ Console)]]]]
  [program
   [compositor
    ["." export]]]
  ["." // #_
   ["#." clean]
   ["/#" // #_
    ["/" profile (#+ Profile)]
    ["#." action (#+ Action)]
    ["#." command (#+ Command)]
    ["#." local]
    ["#." pom]
    ["#." package]
    [repository (#+ Repository)
     ["#." origin]]
    ["#." dependency #_
     ["#/." deployment]
     ["#/." status]]
    ["#." artifact (#+ Artifact)
     ["#/." type]]]])

(def: #export success
  "Successfully installed the project locally.")

(def: #export failure
  "Failure: No 'identity' defined for the project.")

(def: #export (do! console fs repository profile)
  (-> (Console Promise) (file.System Promise) (Repository Promise) (Command Any))
  (case (get@ #/.identity profile)
    (#.Some identity)
    (do ///action.monad
      [package (|> profile
                   (get@ #/.sources)
                   set.to_list
                   (export.library fs))
       pom (|> profile
               ///pom.write
               (\ promise.monad wrap))
       _ (///dependency/deployment.one repository
                                       [identity ///artifact/type.lux_library]
                                       (let [pom_data (|> pom
                                                          (\ xml.codec encode)
                                                          (\ utf8.codec encode))]
                                         {#///package.origin (#///origin.Local "")
                                          #///package.library (let [library (binary.run tar.writer package)]
                                                                [library (///dependency/status.verified library)])
                                          #///package.pom [pom
                                                           pom_data
                                                           (///dependency/status.verified pom_data)]}))]
      (console.write_line ..success console))

    _
    (console.write_line ..failure console)))