From db3e864ae66da7f7d1034ae95967605144d5ec47 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 27 Jun 2021 20:09:48 -0400 Subject: Made obtaining env variables more granular + partial Lua support. --- stdlib/source/program/aedifex/command/auto.lux | 2 +- stdlib/source/program/aedifex/command/build.lux | 84 +++++++++++------------ stdlib/source/program/aedifex/command/clean.lux | 39 +++++------ stdlib/source/program/aedifex/command/deploy.lux | 5 +- stdlib/source/program/aedifex/command/deps.lux | 1 - stdlib/source/program/aedifex/command/install.lux | 5 +- stdlib/source/program/aedifex/command/pom.lux | 5 +- stdlib/source/program/aedifex/command/test.lux | 4 +- 8 files changed, 73 insertions(+), 72 deletions(-) (limited to 'stdlib/source/program/aedifex/command') diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux index 000384ccd..f74d3069a 100644 --- a/stdlib/source/program/aedifex/command/auto.lux +++ b/stdlib/source/program/aedifex/command/auto.lux @@ -65,7 +65,7 @@ (monad.map ! (..targets fs)) (\ ! map list.concat))] (do {! ///action.monad} - [_ (monad.map ! (\ watcher start watch.all) targets) + [_ (monad.map ! (\ watcher start watch.modification) targets) _ ] (loop [_ []] (do ! diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index e2d6f78b8..6d61475d0 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -23,7 +23,7 @@ [number ["i" int]]] [world - [program (#+ Program)] + ["." program (#+ Program)] ["." file (#+ Path)] ["." shell (#+ Process Shell)] ["." console (#+ Console)] @@ -76,7 +76,6 @@ (exception: #export no_available_compiler) (exception: #export no_specified_program) -(exception: #export no_specified_target) (type: #export Compiler (#JVM Dependency) @@ -169,45 +168,42 @@ (def: #export (do! console program fs shell resolution) (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command [Compiler Path])) (function (_ profile) - (case [(get@ #///.program profile) - (get@ #///.target profile)] - [#.None _] - (promise\wrap (exception.throw ..no_specified_program [])) - - [_ #.None] - (promise\wrap (exception.throw ..no_specified_target [])) - - [(#.Some program_module) (#.Some target)] - (do promise.monad - [environment (\ program environment []) - home (\ program home []) - working_directory (\ program directory [])] - (do ///action.monad - [[resolution compiler] (promise\wrap (..compiler resolution)) - #let [[[command compiler_params] output] (case compiler - (#JVM dependency) [(///runtime.java (..path fs home dependency)) - "program.jar"] - (#JS dependency) [(///runtime.node (..path fs home dependency)) - "program.js"]) - / (\ fs separator) - cache_directory (format working_directory / target)] - _ (console.write_line ..start console) - process (!.use (\ shell execute) - [environment - working_directory - command - (list.concat (list compiler_params - (list "build") - (..plural "--library" (..libraries fs home resolution)) - (..plural "--source" (set.to_list (get@ #///.sources profile))) - (..singular "--target" cache_directory) - (..singular "--module" program_module)))]) - _ (..log_output! console process) - _ (..log_error! console process) - exit (!.use (\ process await) []) - _ (console.write_line (if (i.= shell.normal exit) - ..success - ..failure) - console)] - (wrap [compiler - (format cache_directory / output)])))))) + (let [target (get@ #///.target profile)] + (case (get@ #///.program profile) + #.None + (promise\wrap (exception.throw ..no_specified_program [])) + + (#.Some program_module) + (do promise.monad + [environment (program.environment promise.monad program) + home (\ program home []) + working_directory (\ program directory [])] + (do ///action.monad + [[resolution compiler] (promise\wrap (..compiler resolution)) + #let [[[command compiler_params] output] (case compiler + (#JVM dependency) [(///runtime.java (..path fs home dependency)) + "program.jar"] + (#JS dependency) [(///runtime.node (..path fs home dependency)) + "program.js"]) + / (\ fs separator) + cache_directory (format working_directory / target)] + _ (console.write_line ..start console) + process (!.use (\ shell execute) + [environment + working_directory + command + (list.concat (list compiler_params + (list "build") + (..plural "--library" (..libraries fs home resolution)) + (..plural "--source" (set.to_list (get@ #///.sources profile))) + (..singular "--target" cache_directory) + (..singular "--module" program_module)))]) + _ (..log_output! console process) + _ (..log_error! console process) + exit (!.use (\ process await) []) + _ (console.write_line (if (i.= shell.normal exit) + ..success + ..failure) + console)] + (wrap [compiler + (format cache_directory / output)]))))))) diff --git a/stdlib/source/program/aedifex/command/clean.lux b/stdlib/source/program/aedifex/command/clean.lux index 900de2cc4..ecb71b59d 100644 --- a/stdlib/source/program/aedifex/command/clean.lux +++ b/stdlib/source/program/aedifex/command/clean.lux @@ -8,6 +8,9 @@ ["!" capability]] [concurrency ["." promise (#+ Promise)]]] + [data + [text + ["%" format (#+ format)]]] [world ["." file (#+ Path File Directory)] ["." console (#+ Console)]]] @@ -26,27 +29,21 @@ nodes)] (wrap []))) -(def: #export success - "Success") - -(def: #export failure - "Failure: No 'target' defined for clean-up.") +(def: #export (success path) + (-> ///.Target Text) + (format "Successfully cleaned target directory: " path)) (def: #export (do! console fs profile) (-> (Console Promise) (file.System Promise) (Command Any)) - (case (get@ #///.target profile) - (#.Some target) - (do {! ///action.monad} - [target (: (Promise (Try (Directory Promise))) - (!.use (\ fs directory) target)) - _ (loop [root target] - (do ! - [_ (..clean_files! root) - subs (: (Promise (Try (List (Directory Promise)))) - (!.use (\ root directories) [])) - _ (monad.map ! recur subs)] - (!.use (\ root discard) [])))] - (console.write_line ..success console)) - - #.None - (console.write_line ..failure console))) + (do {! ///action.monad} + [#let [target (get@ #///.target profile)] + root (: (Promise (Try (Directory Promise))) + (!.use (\ fs directory) target)) + _ (loop [root root] + (do ! + [_ (..clean_files! root) + subs (: (Promise (Try (List (Directory Promise)))) + (!.use (\ root directories) [])) + _ (monad.map ! recur subs)] + (!.use (\ root discard) [])))] + (console.write_line (..success target) console))) diff --git a/stdlib/source/program/aedifex/command/deploy.lux b/stdlib/source/program/aedifex/command/deploy.lux index 6546045a4..5ec42be78 100644 --- a/stdlib/source/program/aedifex/command/deploy.lux +++ b/stdlib/source/program/aedifex/command/deploy.lux @@ -52,6 +52,9 @@ ["#/." extension (#+ Extension)] ["#/." type]]]]) +(def: #export success + "Successfully deployed the project.") + (def: #export (do! console repository fs artifact profile) (-> (Console Promise) (Repository Promise) (file.System Promise) Artifact (Command Any)) (do {! ///action.monad} @@ -73,4 +76,4 @@ #///package.pom [pom pom_data (///dependency/status.verified pom_data)]}))] - (console.write_line //clean.success console))) + (console.write_line ..success console))) diff --git a/stdlib/source/program/aedifex/command/deps.lux b/stdlib/source/program/aedifex/command/deps.lux index d699de528..36a129bd1 100644 --- a/stdlib/source/program/aedifex/command/deps.lux +++ b/stdlib/source/program/aedifex/command/deps.lux @@ -45,7 +45,6 @@ [cached (|> (dictionary.keys cache) (list\fold dictionary.remove resolution) (///dependency/deployment.all local)) - _ (console.write_line //clean.success console) _ (console.write_line (exception.report ["Local successes" (exception.enumerate ..format local_successes)] ["Local failures" (exception.enumerate ..format local_failures)] diff --git a/stdlib/source/program/aedifex/command/install.lux b/stdlib/source/program/aedifex/command/install.lux index 375e803ce..2e5ce6d89 100644 --- a/stdlib/source/program/aedifex/command/install.lux +++ b/stdlib/source/program/aedifex/command/install.lux @@ -45,6 +45,9 @@ ["#." artifact (#+ Artifact) ["#/." type]]]]) +(def: #export success + "Successfully installed the project locally.") + (def: #export failure "Failure: No 'identity' defined for the project.") @@ -66,7 +69,7 @@ #///package.pom [pom pom_data (///dependency/status.verified pom_data)]}))] - (console.write_line //clean.success console)) + (console.write_line ..success console)) _ (console.write_line ..failure console))) diff --git a/stdlib/source/program/aedifex/command/pom.lux b/stdlib/source/program/aedifex/command/pom.lux index 7ca26c311..16d036718 100644 --- a/stdlib/source/program/aedifex/command/pom.lux +++ b/stdlib/source/program/aedifex/command/pom.lux @@ -25,6 +25,9 @@ ["#." action (#+ Action)] ["#." pom]]]) +(def: #export success + (format "Successfully created POM file: " ///pom.file)) + (def: #export (do! console fs profile) (-> (Console Promise) (file.System Promise) (Command Path)) (do ///action.monad @@ -35,5 +38,5 @@ (\ xml.codec encode) (\ utf8.codec encode) (!.use (\ file over_write))) - _ (console.write_line //clean.success console)] + _ (console.write_line ..success console)] (wrap ///pom.file))) diff --git a/stdlib/source/program/aedifex/command/test.lux b/stdlib/source/program/aedifex/command/test.lux index e717b7cd6..f3ab6c12a 100644 --- a/stdlib/source/program/aedifex/command/test.lux +++ b/stdlib/source/program/aedifex/command/test.lux @@ -14,7 +14,7 @@ [number ["i" int]]] [world - [program (#+ Program)] + ["." program (#+ Program)] ["." file] ["." shell (#+ Shell)] ["." console (#+ Console)]]] @@ -35,7 +35,7 @@ (def: #export (do! console program fs shell resolution profile) (-> (Console Promise) (Program Promise) (file.System Promise) (Shell Promise) Resolution (Command Any)) (do promise.monad - [environment (\ program environment []) + [environment (program.environment promise.monad program) working_directory (\ program directory [])] (do ///action.monad [[compiler program] (//build.do! console program fs shell resolution -- cgit v1.2.3