aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/command
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/program/aedifex/command')
-rw-r--r--stdlib/source/program/aedifex/command/install.lux62
1 files changed, 62 insertions, 0 deletions
diff --git a/stdlib/source/program/aedifex/command/install.lux b/stdlib/source/program/aedifex/command/install.lux
new file mode 100644
index 000000000..818283cc5
--- /dev/null
+++ b/stdlib/source/program/aedifex/command/install.lux
@@ -0,0 +1,62 @@
+(.module:
+ [lux #*
+ [abstract
+ [monad (#+ do)]]
+ [control
+ ["." try (#+ Try)]
+ ["." exception]
+ [concurrency
+ ["." promise (#+ Promise)]]
+ [security
+ ["!" capability]]]
+ [data
+ [binary (#+ Binary)]
+ [text
+ ["%" format (#+ format)]
+ ["." encoding]]
+ [collection
+ ["." set]]
+ [format
+ ["." binary]
+ ["." tar]
+ ["." xml]]]
+ [world
+ ["." file (#+ Path File)]]]
+ [program
+ [compositor
+ ["." export]]]
+ ["." /// #_
+ ["/" profile (#+ Profile)]
+ ["#." action (#+ Action)]
+ ["#." command (#+ Command)]
+ ["#." local]
+ ["#." pom]
+ ["#." artifact (#+ Artifact)
+ ["#/." extension]]])
+
+(def: (save! system content file)
+ (-> (file.System Promise) Binary Path (Promise (Try Any)))
+ (do (try.with promise.monad)
+ [file (: (Promise (Try (File Promise)))
+ (file.get-file promise.monad system file))]
+ (!.use (:: file over-write) [content])))
+
+(def: #export (do! system profile)
+ (-> (file.System Promise) (Command Any))
+ (case (get@ #/.identity profile)
+ (#.Some identity)
+ (do ///action.monad
+ [package (export.library system (set.to-list (get@ #/.sources profile)))
+ repository (: (Promise (Try Path))
+ (file.make-directories promise.monad system (///local.path system identity)))
+ #let [artifact-name (format repository (:: system separator) (///artifact.identity identity))]
+ _ (..save! system (binary.run tar.writer package)
+ (format artifact-name ///artifact/extension.lux-library))
+ pom (:: promise.monad wrap (///pom.write profile))
+ _ (..save! system (|> pom (:: xml.codec encode) encoding.to-utf8)
+ (format artifact-name ///artifact/extension.pom))
+ #let [_ (log! "Successfully installed locally!")]]
+ (wrap []))
+
+ _
+ (:: promise.monad wrap (exception.throw /.no-identity []))))