From 2d16bdfa2854d851034eff9f042863dcceb8664a Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 3 Oct 2020 20:13:27 -0400 Subject: Gave Aedifex support for multiple profiles. --- stdlib/source/program/aedifex.lux | 107 +++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 54 deletions(-) (limited to 'stdlib/source/program/aedifex.lux') diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux index bfa2377f4..e29af6e7a 100644 --- a/stdlib/source/program/aedifex.lux +++ b/stdlib/source/program/aedifex.lux @@ -19,7 +19,9 @@ ["%" format (#+ format)] ["." encoding]] [format - ["." xml]]] + ["." xml]] + [collection + ["." set]]] [tool [compiler [language @@ -29,7 +31,8 @@ ["." file (#+ Path)]]] ["." / #_ [action (#+ Action)] - ["#" project] + ["#" profile] + ["#." project (#+ Project)] ["#." parser] ["#." pom] ["#." cli] @@ -61,20 +64,20 @@ (#.Right [end lux-code]) (#try.Success lux-code)))) -(def: (write-pom!' path project) - (-> Path /.Project (IO (Try Any))) +(def: (write-pom!' path profile) + (-> Path /.Profile (IO (Try Any))) (do (try.with io.monad) - [file (!.use (:: file.system file) [path])] - (|> project - /pom.project + [file (!.use (:: file.system file) [path]) + pom (:: io.monad wrap (/pom.project profile))] + (|> pom (:: xml.codec encode) encoding.to-utf8 (!.use (:: file over-write))))) -(def: (write-pom! project) - (-> /.Project (IO Any)) +(def: (write-pom! profile) + (-> /.Profile (IO Any)) (do io.monad - [outcome (write-pom!' /pom.file project)] + [outcome (write-pom!' /pom.file profile)] (case outcome (#try.Success value) (wrap (log! "Successfully wrote POM file!")) @@ -83,10 +86,10 @@ (wrap (log! (format "Could not write POM file:" text.new-line error)))))) -(def: (install! project) - (-> /.Project (Promise Any)) +(def: (install! profile) + (-> /.Profile (Promise Any)) (do promise.monad - [outcome (/local.install (file.async file.system) project)] + [outcome (/local.install (file.async file.system) profile)] (wrap (case outcome (#try.Success _) (log! "Successfully installed locally!") @@ -95,16 +98,16 @@ (log! (format "Could not install locally:" text.new-line error)))))) -(def: (fetch-dependencies! project) - (-> /.Project (Promise Any)) +(def: (fetch-dependencies! profile) + (-> /.Profile (Promise Any)) (do promise.monad [outcome (do (try.with promise.monad) [cache (/local.all-cached (file.async file.system) - (get@ #/.dependencies project) + (set.to-list (get@ #/.dependencies profile)) /dependency.empty) resolution (promise.future - (/dependency.resolve-all (get@ #/.repositories project) - (get@ #/.dependencies project) + (/dependency.resolve-all (set.to-list (get@ #/.repositories profile)) + (set.to-list (get@ #/.dependencies profile)) cache))] (/local.cache-all (file.async file.system) resolution))] @@ -117,52 +120,48 @@ error)))))) (def: project - (-> Binary (Try /.Project)) + (-> Binary (Try Project)) (|>> (do> try.monad [encoding.from-utf8] [..read-code] [(list) (.run /parser.project)]))) -(program: [{command /cli.command}] +(program: [{[profile operation] /cli.command}] (do {@ io.monad} [data (..read-file! /.file)] - (case data - (#try.Success data) - (case (..project data) - (#try.Success project) - (case command - #/cli.POM - (..write-pom! project) - - #/cli.Dependencies - (exec (..fetch-dependencies! project) - (wrap [])) + (case (do try.monad + [data data + project (..project data)] + (/project.profile project profile)) + (#try.Success profile) + (case operation + #/cli.POM + (..write-pom! profile) + + #/cli.Dependencies + (exec (..fetch-dependencies! profile) + (wrap [])) - #/cli.Install - (exec (..install! project) - (wrap [])) + #/cli.Install + (exec (..install! profile) + (wrap [])) - (#/cli.Deploy repository user password) - (exec (/deploy.do! repository user password project) - (wrap [])) + (#/cli.Deploy repository user password) + (exec (/deploy.do! repository user password profile) + (wrap [])) - (#/cli.Compilation compilation) - (case compilation - #/cli.Build (exec (/build.do! project) - (wrap [])) - #/cli.Test (exec (/test.do! project) - (wrap []))) + (#/cli.Compilation compilation) + (case compilation + #/cli.Build (exec (/build.do! profile) + (wrap [])) + #/cli.Test (exec (/test.do! profile) + (wrap []))) - (#/cli.Auto auto) - (exec (case auto - #/cli.Build (/auto.do! /build.do! project) - #/cli.Test (/auto.do! /test.do! project)) - (wrap []))) - - (#try.Failure error) - (wrap (log! (format "Invalid format file:" text.new-line - error)))) + (#/cli.Auto auto) + (exec (case auto + #/cli.Build (/auto.do! /build.do! profile) + #/cli.Test (/auto.do! /test.do! profile)) + (wrap []))) (#try.Failure error) - (wrap (log! (format "Could not read file: " - (%.text /.file))))))) + (wrap (log! error))))) -- cgit v1.2.3