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/auto.lux61
-rw-r--r--stdlib/source/program/aedifex/command/build.lux114
-rw-r--r--stdlib/source/program/aedifex/command/deploy.lux4
-rw-r--r--stdlib/source/program/aedifex/command/pom.lux4
-rw-r--r--stdlib/source/program/aedifex/command/test.lux36
5 files changed, 123 insertions, 96 deletions
diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux
index 80ff8ac8c..aa230daba 100644
--- a/stdlib/source/program/aedifex/command/auto.lux
+++ b/stdlib/source/program/aedifex/command/auto.lux
@@ -14,7 +14,9 @@
["." list]
["." set]]]
[world
- ["." file (#+ Path)]]]
+ [environment (#+ Environment)]
+ ["." file (#+ Path)]
+ ["." shell (#+ Shell)]]]
["." // #_
["/#" // #_
["#" profile]
@@ -126,31 +128,34 @@
#.None
(wrap []))))
-(def: #export (do! command fs resolution profile)
+(def: #export (do! command)
(All [a]
- (-> (-> (file.System Promise) Resolution (Command a))
- (-> (file.System Promise) Resolution (Command Any))))
- (do {! ///action.monad}
- [watcher (promise.future
- (java/nio/file/FileSystem::newWatchService
- (java/nio/file/FileSystems::getDefault)))
- targets (|> profile
- (get@ #///.sources)
- set.to-list
- (monad.map ! ..targets)
- (:: ! map list.concat))
- _ (monad.map ! (..watch! watcher) targets)
- _ (command fs resolution profile)]
- (loop [_ []]
- (do !
- [?key (..poll! watcher)
- _ (case ?key
- (#.Some key)
- (do !
- [_ (promise.future (..drain! watcher))
- _ (command fs resolution profile)]
- (wrap []))
-
- #.None
- (wrap []))]
- (recur [])))))
+ (-> (-> Environment (file.System Promise) (Shell Promise) Resolution (Command a))
+ (-> Environment (file.System Promise) (Shell Promise) Resolution (Command Any))))
+ (function (_ environment fs shell resolution)
+ (function (_ profile)
+ (with-expansions [<call> ((command environment fs shell resolution) profile)]
+ (do {! ///action.monad}
+ [watcher (promise.future
+ (java/nio/file/FileSystem::newWatchService
+ (java/nio/file/FileSystems::getDefault)))
+ targets (|> profile
+ (get@ #///.sources)
+ set.to-list
+ (monad.map ! ..targets)
+ (:: ! map list.concat))
+ _ (monad.map ! (..watch! watcher) targets)
+ _ <call>]
+ (loop [_ []]
+ (do !
+ [?key (..poll! watcher)
+ _ (case ?key
+ (#.Some key)
+ (do !
+ [_ (promise.future (..drain! watcher))
+ _ <call>]
+ (wrap []))
+
+ #.None
+ (wrap []))]
+ (recur []))))))))
diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux
index 72f96b25e..94d6760b6 100644
--- a/stdlib/source/program/aedifex/command/build.lux
+++ b/stdlib/source/program/aedifex/command/build.lux
@@ -1,6 +1,5 @@
(.module:
[lux (#- Name)
- ["." host (#+ import:)]
[abstract
[monad (#+ do)]]
[control
@@ -8,18 +7,24 @@
["." exception (#+ exception:)]
["." io (#+ IO)]
[concurrency
- ["." promise (#+ Promise) ("#@." monad)]]]
+ ["." promise (#+ Promise) ("#\." monad)]]
+ [security
+ ["!" capability]]]
[data
["." product]
["." maybe]
- ["." text ("#@." equivalence)
+ ["." text ("#\." equivalence)
["%" format (#+ format)]]
[collection
- ["." list ("#@." functor)]
+ ["." list ("#\." functor)]
["." dictionary]
- ["." set]]]
+ ["." set]]
+ [number
+ ["i" int]]]
[world
- ["." file (#+ Path)]]]
+ [environment (#+ Environment)]
+ ["." file (#+ Path)]
+ ["." shell (#+ Shell)]]]
["." /// #_
["#" profile]
["#." action]
@@ -41,22 +46,30 @@
(-> Group Name Finder)
(|>> dictionary.entries
(list.one (function (_ [dependency package])
- (if (and (text@= group (get@ [#///dependency.artifact #///artifact.group] dependency))
- (text@= name (get@ [#///dependency.artifact #///artifact.name] dependency)))
+ (if (and (text\= group (get@ [#///dependency.artifact #///artifact.group] dependency))
+ (text\= name (get@ [#///dependency.artifact #///artifact.name] dependency)))
(#.Some dependency)
#.None)))))
-(def: lux-group
+(def: #export lux-group
Group
"com.github.luxlang")
-(template [<name> <finder>]
+(def: #export jvm-compiler-name
+ Name
+ "lux-jvm")
+
+(def: #export js-compiler-name
+ Name
+ "lux-js")
+
+(template [<finder> <name>]
[(def: <finder>
Finder
(..dependency-finder ..lux-group <name>))]
- ["lux-jvm" jvm-compiler]
- ["lux-js" js-compiler]
+ [jvm-compiler ..jvm-compiler-name]
+ [js-compiler ..js-compiler-name]
)
(exception: #export no-available-compiler)
@@ -91,58 +104,55 @@
(def: (libraries fs)
(All [!] (-> (file.System !) Resolution (List Path)))
(|>> dictionary.keys
- (list.filter (|>> (get@ #///dependency.type) (text@= ///artifact/type.lux-library)))
- (list@map (|>> (get@ #///dependency.artifact) (///local.path fs)))))
-
-(import: java/lang/String)
-
-## https://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
-(import: java/lang/System
- ["#::."
- (#static getProperty [java/lang/String] #io #? java/lang/String)])
+ (list.filter (|>> (get@ #///dependency.type) (text\= ///artifact/type.lux-library)))
+ (list\map (|>> (get@ #///dependency.artifact) (///local.path fs)))))
(def: #export working-directory
- (IO (Try Text))
- (do io.monad
- [?value (java/lang/System::getProperty "user.dir")]
- (wrap (#try.Success (maybe.default "~" ?value)))))
+ (-> Environment (Try Text))
+ (|>> (dictionary.get "user.dir") try.from-maybe))
-(def: (singular-parameter name value)
- (-> Text Text Text)
- (format name " " value))
+(def: (singular name)
+ (-> Text Text (List Text))
+ (|>> (list name)))
-(def: (plural-parameter name values)
- (-> Text (List Text) Text)
- (|> values (list@map (|>> (format name " "))) (text.join-with " ")))
+(def: (plural name)
+ (-> Text (List Text) (List Text))
+ (|>> (list\map (|>> (list name))) list.concat))
-(def: #export (do! fs resolution profile)
- (-> (file.System Promise) Resolution (Command [Compiler Path]))
+(def: #export (do! environment fs shell resolution profile)
+ (-> Environment (file.System Promise) (Shell Promise) Resolution (Command [Compiler Path]))
(case [(get@ #///.program profile)
(get@ #///.target profile)]
[#.None _]
- (promise@wrap (exception.throw ..no-specified-program []))
+ (promise\wrap (exception.throw ..no-specified-program []))
[_ #.None]
- (promise@wrap (exception.throw ..no-specified-target []))
+ (promise\wrap (exception.throw ..no-specified-target []))
[(#.Some program) (#.Some target)]
(do ///action.monad
- [[resolution compiler] (promise@wrap (..compiler resolution))
- working-directory (promise.future ..working-directory)
- #let [[prefix output] (case compiler
- (#JVM artifact) [(///runtime.java (///local.path fs artifact))
- "program.jar"]
- (#JS artifact) [(///runtime.node (///local.path fs artifact))
- "program.js"])
- cache-directory (format working-directory (:: fs separator) target)
- command (format prefix " build"
- " " (..plural-parameter "--library" (..libraries fs resolution))
- " " (..plural-parameter "--source" (set.to-list (get@ #///.sources profile)))
- " " (..singular-parameter "--target" cache-directory)
- " " (..singular-parameter "--module" program))]
+ [[resolution compiler] (promise\wrap (..compiler resolution))
+ working-directory (promise\wrap (..working-directory environment))
+ #let [[command output] (let [[compiler output] (case compiler
+ (#JVM artifact) [(///runtime.java (///local.path fs artifact))
+ "program.jar"]
+ (#JS artifact) [(///runtime.node (///local.path fs artifact))
+ "program.js"])]
+ [(format compiler " build") output])
+ / (:: fs separator)
+ cache-directory (format working-directory / target)]
#let [_ (log! "[BUILD STARTED]")]
- outcome (///shell.execute command working-directory)
- #let [_ (log! "[BUILD ENDED]")]]
+ process (!.use (:: shell execute)
+ [environment
+ working-directory
+ command
+ (list.concat (list (..plural "--library" (..libraries fs resolution))
+ (..plural "--source" (set.to-list (get@ #///.sources profile)))
+ (..singular "--target" cache-directory)
+ (..singular "--module" program)))])
+ exit (!.use (:: process await) [])
+ #let [_ (log! (if (i.= shell.normal exit)
+ "[BUILD ENDED]"
+ "[BUILD FAILED]"))]]
(wrap [compiler
- (format cache-directory (:: fs separator) output)]))
- ))
+ (format cache-directory / output)]))))
diff --git a/stdlib/source/program/aedifex/command/deploy.lux b/stdlib/source/program/aedifex/command/deploy.lux
index 37a5a0f40..839bc7906 100644
--- a/stdlib/source/program/aedifex/command/deploy.lux
+++ b/stdlib/source/program/aedifex/command/deploy.lux
@@ -4,7 +4,7 @@
[monad (#+ do)]]
[control
[concurrency
- ["." promise (#+ Promise) ("#@." monad)]]]
+ ["." promise (#+ Promise) ("#\." monad)]]]
[data
[binary (#+ Binary)]
[text
@@ -40,7 +40,7 @@
set.to-list
(export.library fs)
(:: ! map (binary.run tar.writer)))
- pom (promise@wrap (///pom.write profile))
+ pom (promise\wrap (///pom.write profile))
_ (deploy! ///artifact/extension.pom (|> pom (:: xml.codec encode) encoding.to-utf8))
_ (deploy! ///artifact/extension.lux-library library)
_ (deploy! ///artifact/extension.sha-1 (///hash.data (///hash.sha-1 library)))
diff --git a/stdlib/source/program/aedifex/command/pom.lux b/stdlib/source/program/aedifex/command/pom.lux
index f493092a5..695a7839f 100644
--- a/stdlib/source/program/aedifex/command/pom.lux
+++ b/stdlib/source/program/aedifex/command/pom.lux
@@ -7,7 +7,7 @@
[security
["!" capability]]
[concurrency
- ["." promise (#+ Promise) ("#@." monad)]]]
+ ["." promise (#+ Promise) ("#\." monad)]]]
[data
["." text
["%" format (#+ format)]
@@ -24,7 +24,7 @@
(def: #export (do! fs profile)
(-> (file.System Promise) (Command Path))
(do ///action.monad
- [pom (promise@wrap (///pom.write profile))
+ [pom (promise\wrap (///pom.write profile))
file (: (Promise (Try (File Promise)))
(file.get-file promise.monad fs ///pom.file))
outcome (|> pom
diff --git a/stdlib/source/program/aedifex/command/test.lux b/stdlib/source/program/aedifex/command/test.lux
index d4519b2d0..2996a6741 100644
--- a/stdlib/source/program/aedifex/command/test.lux
+++ b/stdlib/source/program/aedifex/command/test.lux
@@ -4,12 +4,18 @@
[monad (#+ do)]]
[control
[concurrency
- ["." promise (#+ Promise)]]]
+ ["." promise (#+ Promise) ("#\." monad)]]
+ [security
+ ["!" capability]]]
[data
[text
- ["%" format (#+ format)]]]
+ ["%" format (#+ format)]]
+ [number
+ ["i" int]]]
[world
- ["." file]]]
+ [environment (#+ Environment)]
+ ["." file]
+ ["." shell (#+ Shell)]]]
["." // #_
["#." build]
["/#" // #_
@@ -20,15 +26,21 @@
[dependency
[resolution (#+ Resolution)]]]])
-(def: #export (do! fs resolution profile)
- (-> (file.System Promise) Resolution (Command Any))
+(def: #export (do! environment fs shell resolution profile)
+ (-> Environment (file.System Promise) (Shell Promise) Resolution (Command Any))
(do ///action.monad
- [[compiler program] (//build.do! fs resolution profile)
- working-directory (promise.future //build.working-directory)
- #let [command (case compiler
- (#//build.JVM artifact) (///runtime.java program)
- (#//build.JS artifact) (///runtime.node program))]
+ [[compiler program] (//build.do! environment fs shell resolution profile)
+ working-directory (promise\wrap (//build.working-directory environment))
#let [_ (log! "[TEST STARTED]")]
- outcome (///shell.execute command working-directory)
- #let [_ (log! "[TEST ENDED]")]]
+ process (!.use (:: shell execute)
+ [environment
+ working-directory
+ (case compiler
+ (#//build.JVM artifact) (///runtime.java program)
+ (#//build.JS artifact) (///runtime.node program))
+ (list)])
+ exit (!.use (:: process await) [])
+ #let [_ (log! (if (i.= shell.normal exit)
+ "[TEST ENDED]"
+ "[TEST FAILED]"))]]
(wrap [])))