From e5e4c2aff562e5c01fefb808d1d68a40f29c9cc5 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 8 Apr 2022 01:49:29 -0400 Subject: Can now deploy releases with Aedifex. --- .github/workflows/setup_aedifex/action.yml | 4 +- documentation/bookmark/error/exception.md | 5 + documentation/bookmark/error/handling.md | 4 + documentation/bookmark/error/message.md | 7 + documentation/bookmark/error_messages.md | 7 - documentation/bookmark/exception.md | 5 - stdlib/commands.md | 19 ++- stdlib/project.lux | 7 +- .../compiler/meta/cache/dependency/artifact.lux | 10 +- .../lux/tool/compiler/meta/packager/jvm.lux | 24 ++- stdlib/source/program/aedifex.lux | 12 +- stdlib/source/program/aedifex/artifact.lux | 13 +- stdlib/source/program/aedifex/command/deploy.lux | 14 +- .../program/aedifex/command/deploy/release.lux | 173 +++++++++++++++++++++ .../program/aedifex/command/deploy/snapshot.lux | 10 +- stdlib/source/program/aedifex/format.lux | 1 + stdlib/source/program/aedifex/parser.lux | 1 + stdlib/source/program/aedifex/pom.lux | 91 +++++------ stdlib/source/program/aedifex/profile.lux | 7 +- stdlib/source/program/aedifex/repository/local.lux | 28 ++-- stdlib/source/test/aedifex/command/deploy.lux | 9 +- stdlib/source/test/aedifex/profile.lux | 3 +- 22 files changed, 339 insertions(+), 115 deletions(-) create mode 100644 documentation/bookmark/error/exception.md create mode 100644 documentation/bookmark/error/handling.md create mode 100644 documentation/bookmark/error/message.md delete mode 100644 documentation/bookmark/error_messages.md delete mode 100644 documentation/bookmark/exception.md create mode 100644 stdlib/source/program/aedifex/command/deploy/release.lux diff --git a/.github/workflows/setup_aedifex/action.yml b/.github/workflows/setup_aedifex/action.yml index e9d904779..a571dea74 100644 --- a/.github/workflows/setup_aedifex/action.yml +++ b/.github/workflows/setup_aedifex/action.yml @@ -13,10 +13,12 @@ runs: # Presumably, whoever invokes this action has already done a checkout. # - uses: actions/checkout@v2 + # Install Aedifex - run: wget https://github.com/LuxLang/lux/releases/download/0.6.5/aedifex_do_not_touch_5.jar && mv aedifex_do_not_touch_5.jar aedifex.jar shell: bash - - run: PATH="$PATH:./shell" + # Make the `lux` command available. + - run: echo "$HOME/shell" >> $GITHUB_PATH shell: bash - run: cd ./stdlib/ && lux clean && cd .. diff --git a/documentation/bookmark/error/exception.md b/documentation/bookmark/error/exception.md new file mode 100644 index 000000000..09b43b1eb --- /dev/null +++ b/documentation/bookmark/error/exception.md @@ -0,0 +1,5 @@ +# Reference + +0. [Using Coroutines to Implement C++ Exceptions for Freestanding Environments - Eyal Zedaka - CppCon 21](https://www.youtube.com/watch?v=TsXYqnUXrwM) +0. [You don't understand exceptions, but you should](https://matt.might.net/articles/implementing-exceptions/) + diff --git a/documentation/bookmark/error/handling.md b/documentation/bookmark/error/handling.md new file mode 100644 index 000000000..ebc537c09 --- /dev/null +++ b/documentation/bookmark/error/handling.md @@ -0,0 +1,4 @@ +# Reference + +0. [Failing Successfully: Reporting and Handling Errors - Robert Leahy - CppCon 2021](https://www.youtube.com/watch?v=dQaRLmM7KKk) + diff --git a/documentation/bookmark/error/message.md b/documentation/bookmark/error/message.md new file mode 100644 index 000000000..62c93e8dd --- /dev/null +++ b/documentation/bookmark/error/message.md @@ -0,0 +1,7 @@ +# Reference + +0. [Rethinking errors, warnings, and lints](http://neugierig.org/software/blog/2022/01/rethinking-errors.html) +0. [Error Message Style Guides of Various Languages](https://www.pypy.org/posts/2021/12/error-message-style-guides.html) +0. [Error Messages in Haskell, and how to Improve them](https://anthony.noided.media/blog/haskell/programming/2020/05/14/haskell-errors.html) +0. [The Futhark Error Index](https://futhark-lang.org/blog/2021-09-24-the-futhark-error-index.html) + diff --git a/documentation/bookmark/error_messages.md b/documentation/bookmark/error_messages.md deleted file mode 100644 index 62c93e8dd..000000000 --- a/documentation/bookmark/error_messages.md +++ /dev/null @@ -1,7 +0,0 @@ -# Reference - -0. [Rethinking errors, warnings, and lints](http://neugierig.org/software/blog/2022/01/rethinking-errors.html) -0. [Error Message Style Guides of Various Languages](https://www.pypy.org/posts/2021/12/error-message-style-guides.html) -0. [Error Messages in Haskell, and how to Improve them](https://anthony.noided.media/blog/haskell/programming/2020/05/14/haskell-errors.html) -0. [The Futhark Error Index](https://futhark-lang.org/blog/2021-09-24-the-futhark-error-index.html) - diff --git a/documentation/bookmark/exception.md b/documentation/bookmark/exception.md deleted file mode 100644 index 09b43b1eb..000000000 --- a/documentation/bookmark/exception.md +++ /dev/null @@ -1,5 +0,0 @@ -# Reference - -0. [Using Coroutines to Implement C++ Exceptions for Freestanding Environments - Eyal Zedaka - CppCon 21](https://www.youtube.com/watch?v=TsXYqnUXrwM) -0. [You don't understand exceptions, but you should](https://matt.might.net/articles/implementing-exceptions/) - diff --git a/stdlib/commands.md b/stdlib/commands.md index 6305050dc..874ee070a 100644 --- a/stdlib/commands.md +++ b/stdlib/commands.md @@ -48,6 +48,9 @@ cd ~/lux/stdlib/ \ cd ~/lux/stdlib/ \ && lux deploy snapshots $NEXUS_USERNAME $NEXUS_PASSWORD + +cd ~/lux/stdlib/ \ +&& lux deploy releases $NEXUS_USERNAME $NEXUS_PASSWORD ``` ## Generate documentation @@ -100,21 +103,21 @@ cd ~/lux/stdlib/ \ ``` cd ~/lux/stdlib/ \ -&& lein clean \ -&& lein with-profile aedifex lux auto build +&& lux clean \ +&& lux with aedifex auto build cd ~/lux/stdlib/ \ -&& lein clean \ -&& lein with-profile aedifex lux build \ +&& lux clean \ +&& lux with aedifex build \ && mv target/program.jar aedifex.jar cd ~/lux/stdlib/ \ -&& lux clean \ -&& lux with aedifex auto build +&& lein clean \ +&& lein with-profile aedifex lux auto build cd ~/lux/stdlib/ \ -&& lux clean \ -&& lux with aedifex build \ +&& lein clean \ +&& lein with-profile aedifex lux build \ && mv target/program.jar aedifex.jar ``` diff --git a/stdlib/project.lux b/stdlib/project.lux index 4644c56e8..67ffc7c6b 100644 --- a/stdlib/project.lux +++ b/stdlib/project.lux @@ -5,7 +5,9 @@ "identity" ["com.github.luxlang" "stdlib" "0.7.0-SNAPSHOT"] ... Every piece of information, and the whole "info" bundle, are optional. - "info" ["url" "https://github.com/LuxLang/lux" + "info" ["name" "stdlib" + "description" "Standard Library for the Lux programming language." + "url" "https://github.com/LuxLang/lux" "scm" "https://github.com/LuxLang/lux.git" "licenses" [["name" "Lux License v0.1.2" "url" "https://github.com/LuxLang/lux/blob/master/license.txt" @@ -80,8 +82,7 @@ ] "bibliotheca" - ["info" ["description" "Standard Library for the Lux programming language."] - "test" "test/lux"] + ["test" "test/lux"] "scriptum" ["info" ["description" "Documentation for the Standard Library for the Lux programming language."] diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux index d87c2ccd6..90bee909d 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux @@ -132,9 +132,13 @@ {synthesis.#Loop value} (case value {synthesis.#Scope value} - (|> value - (the synthesis.#iteration) - references) + (let [of_inits (|> value + (the synthesis.#inits) + (list#each references)) + of_iteration (|> value + (the synthesis.#iteration) + references)] + (list#conjoint (partial_list of_iteration of_inits))) {synthesis.#Again value} (|> value diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux index 2de06bf46..ac4987646 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -136,12 +136,18 @@ (-> (Maybe unit.ID) java/util/jar/Manifest) (let [manifest (java/util/jar/Manifest::new) attrs (do_to (java/util/jar/Manifest::getMainAttributes manifest) - (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MANIFEST_VERSION) ..manifest_version))] + (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MANIFEST_VERSION) + (ffi.as_string ..manifest_version)))] (exec (case program {.#Some program} (do_to attrs - (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MAIN_CLASS) (|> program runtime.class_name name.internal name.external))) + (java/util/jar/Attributes::put (java/util/jar/Attributes$Name::MAIN_CLASS) + (|> program + runtime.class_name + name.internal + name.external + ffi.as_string))) {.#None} attrs) @@ -156,7 +162,8 @@ (text.replaced "." "/") (text.suffix (the context.#artifact_extension static)))] (do try.monad - [_ (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new class_path) sink)] + [_ (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new (ffi.as_string class_path)) + sink)] (in (do_to sink (java/util/zip/ZipOutputStream::write content (ffi.as_int +0) (ffi.as_int (.int (binary.size content)))) (java/io/Flushable::flush) @@ -205,7 +212,7 @@ (def: (read_jar_entry entry input) (-> java/util/jar/JarEntry java/util/jar/JarInputStream [Nat Binary]) - (case (java/util/zip/ZipEntry::getSize entry) + (case (ffi.of_long (java/util/zip/ZipEntry::getSize entry)) -1 (..read_jar_entry_with_unknown_size input) @@ -234,14 +241,15 @@ {try.#Success [entries duplicates sink]}) {.#Some entry} - (let [entry_path (java/util/zip/ZipEntry::getName entry) - entry_size (java/util/zip/ZipEntry::getSize entry)] - (if (not (or (java/util/zip/ZipEntry::isDirectory entry) + (let [entry_path (ffi.of_string (java/util/zip/ZipEntry::getName entry)) + entry_size (ffi.of_long (java/util/zip/ZipEntry::getSize entry))] + (if (not (or (ffi.of_boolean (java/util/zip/ZipEntry::isDirectory entry)) (or (text.starts_with? "META-INF/maven/" entry_path) (text.starts_with? "META-INF/leiningen/" entry_path)) (or (text.ends_with? ".SF" entry_path) (text.ends_with? ".DSA" entry_path)))) - (case (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new entry_path) sink) + (case (java/util/jar/JarOutputStream::putNextEntry (java/util/jar/JarEntry::new (ffi.as_string entry_path)) + sink) {try.#Failure error} (again entries (set.has entry_path duplicates) diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux index 0c04ff7bb..b964e8fef 100644 --- a/stdlib/source/program/aedifex.lux +++ b/stdlib/source/program/aedifex.lux @@ -69,6 +69,10 @@ set.list (list#each (|>> (/repository/remote.repository http.default {.#None}) /repository.async)))) +(def: program (program.async program.default)) +(def: fs (file.async file.default)) +(def: local (/repository/local.repository ..program ..fs)) + (def: (with_dependencies program console command profile) (All (_ a) (-> (Program Async) (Console Async) @@ -146,10 +150,6 @@ (maybe.trusted (text.clip 0 (-- (text.size it)) it)) it))))) -(def: program (program.async program.default)) -(def: fs (file.async file.default)) -(def: local (/repository/local.repository ..program ..fs)) - (program: [[profiles operation] /cli.command] (do [! io.monad] [console (# ! each (|>> (try.else ..write_only) console.async) @@ -189,7 +189,9 @@ {.#Some artifact} (case (dictionary.value repository (the /.#deploy_repositories profile)) {.#Some remote} - (/command/deploy.do! console + (/command/deploy.do! ..program + (shell.async shell.default) + console ..local (/repository.async (/repository/remote.repository http.default {.#Some identity} remote)) (file.async file.default) diff --git a/stdlib/source/program/aedifex/artifact.lux b/stdlib/source/program/aedifex/artifact.lux index c1c707a98..cc90d0b78 100644 --- a/stdlib/source/program/aedifex/artifact.lux +++ b/stdlib/source/program/aedifex/artifact.lux @@ -91,14 +91,17 @@ (text.all_split_by ..group_separator) (text.interposed separator))) -(def: .public (uri version artifact) +(def: .public (bundle version artifact) (-> Version Artifact URI) (let [/ uri.separator group (..directory / (the #group artifact)) - name (the #name artifact) - ... version (the #version artifact) - identity (..identity artifact)] - (%.format group / name / version / identity))) + name (the #name artifact)] + (%.format group / name / version))) + +(def: .public (uri version artifact) + (-> Version Artifact URI) + (let [/ uri.separator] + (%.format (..bundle version artifact) / (..identity artifact)))) (def: .public (local artifact) (-> Artifact (List Text)) diff --git a/stdlib/source/program/aedifex/command/deploy.lux b/stdlib/source/program/aedifex/command/deploy.lux index 4ff3b9011..504a9206f 100644 --- a/stdlib/source/program/aedifex/command/deploy.lux +++ b/stdlib/source/program/aedifex/command/deploy.lux @@ -8,25 +8,29 @@ [concurrency [async {"+" Async}]]] [world + [program {"+" Program}] + [shell {"+" Shell}] ["[0]" file] ["[0]" console {"+" Console}]]]] ["[0]" / "_" ["[1][0]" snapshot] + ["[1][0]" release] ["/[1]" // "_" - ["[1][0]" install] ["/[1]" // "_" [command {"+" Command}] [repository {"+" Repository}] [artifact {"+" Artifact}] + ["/" profile] ["[1][0]" action]]]]) (def: .public success "Successfully deployed the project.") -(def: .public (do! console local remote fs artifact profile) - (-> (Console Async) (Repository Async) (Repository Async) (file.System Async) Artifact (Command Any)) +(def: .public (do! program shell console local remote fs artifact profile) + (-> (Program Async) (Shell Async) (Console Async) (Repository Async) (Repository Async) (file.System Async) Artifact (Command Any)) (do [! ///action.monad] - [_ (//install.do! console fs local profile) - _ (/snapshot.do! console remote fs artifact profile)] + [_ (if (/snapshot.snapshot? artifact) + (/snapshot.do! console remote fs artifact profile) + (/release.do! program shell console local remote fs artifact profile))] (is (Async (Try Any)) (console.write_line ..success console)))) diff --git a/stdlib/source/program/aedifex/command/deploy/release.lux b/stdlib/source/program/aedifex/command/deploy/release.lux new file mode 100644 index 000000000..b8b6e2531 --- /dev/null +++ b/stdlib/source/program/aedifex/command/deploy/release.lux @@ -0,0 +1,173 @@ +(.using + [library + [lux "*" + ["[0]" ffi {"+" import:}] + [abstract + [predicate {"+" Predicate}] + ["[0]" monad {"+" do}]] + [control + ["[0]" pipe] + ["[0]" try {"+" Try}] + ["[0]" io {"+" IO}] + [concurrency + ["[0]" async {"+" Async}]] + [parser + ["[0]" environment]]] + [data + ["[0]" binary {"+" Binary}] + ["[0]" text + ["%" format] + [encoding + ["[0]" utf8]]] + [collection + ["[0]" set] + ["[0]" dictionary]] + [format + ["[0]" binary] + ["[0]" tar] + ["[0]" xml]]] + [tool + [compiler + [meta + ["[0]" export] + ["[0]" archive] + ["[0]" context] + ["[0]" packager "_" + ["[1]" jvm]]]]] + [world + [program {"+" Program}] + [console {"+" Console}] + ["[0]" shell {"+" Shell}] + ["[0]" file]]]] + ["[0]" // "_" + ["[1][0]" snapshot] + ["/[1]" // "_" + ["[1][0]" install] + ["/[1]" // "_" + [command {"+" Command}] + ["/" profile] + ["[1][0]" action] + ["[1][0]" pom] + ["[1][0]" package] + ["[1][0]" hash] + ["[1][0]" dependency "_" + ["[1]/[0]" deployment] + ["[1]/[0]" status]] + ["[1][0]" repository {"+" Repository} + ["[1]/[0]" origin] + ["[1]/[0]" local]] + ["[1][0]" artifact {"+" Artifact} + ["[1]/[0]" type] + ["[1]/[0]" extension {"+" Extension}]]]]]) + +(import: java/lang/String + "[1]::[0]" + (toLowerCase [] java/lang/String)) + +(import: java/lang/System + "[1]::[0]" + ("static" getProperty [java/lang/String] "io" "try" java/lang/String)) + +(def: windows? + (IO (Try Bit)) + (# (try.with io.monad) each + (|>> java/lang/String::toLowerCase ffi.of_string (text.starts_with? "windows")) + (java/lang/System::getProperty (ffi.as_string "os.name")))) + +(def: dummy_jar + Binary + (|> (packager.package (context.jvm "") + (dictionary.empty text.hash) + archive.empty + {.#None}) + try.trusted + (pipe.case + {.#Left it} + it + + {.#Right _} + (undefined)))) + +(template [ ] + [(def: + (-> Text Text) + (text.suffix ))] + + [asc ".asc"] + [pom ////artifact/extension.pom] + [tar ////artifact/extension.lux_library] + [jar ////artifact/extension.jvm_library] + [md5 ////artifact/extension.md5] + ) + +(template [ ] + [(def: + (-> Text Text) + (|>> (text.suffix ) ..jar))] + + [javadoc "-javadoc"] + [sources "-sources"] + ) + +(def: .public release? + (Predicate Artifact) + (|>> //snapshot.snapshot? not)) + +(def: (install_dummies! program local fs artifact) + (-> (Program Async) (Repository Async) (file.System Async) Artifact (Async (Try Any))) + (do (try.with async.monad) + [.let [$artifact (////artifact.uri (the ////artifact.#version artifact) artifact)] + _ (# local upload (..jar $artifact) ..dummy_jar) + _ (# local upload (..javadoc $artifact) ..dummy_jar) + _ (# local upload (..sources $artifact) ..dummy_jar)] + (in []))) + +(def: (signed it) + (-> Text [Text Text]) + [it (..asc it)]) + +(def: (release_unsigned_artifact! local remote uri) + (-> (Repository Async) (Repository Async) Text (Async (Try Binary))) + (do [! ////action.monad] + [it (# local download uri) + _ (# remote upload uri it)] + (in it))) + +(def: (release_signed_artifact! local remote [artifact signature]) + (-> (Repository Async) (Repository Async) [Text Text] (Async (Try Any))) + (do [! ////action.monad] + [it (..release_unsigned_artifact! local remote artifact) + _ (|> it + ////hash.md5 + (# ////hash.md5_codec encoded) + (# utf8.codec encoded) + (# remote upload (..md5 artifact))) + _ (..release_unsigned_artifact! local remote signature)] + (in []))) + +(def: .public (do! program shell console local remote fs artifact profile) + (-> (Program Async) (Shell Async) (Console Async) (Repository Async) (Repository Async) (file.System Async) Artifact (Command Any)) + (do [! ////action.monad] + [_ (///install.do! console fs local profile) + _ (install_dummies! program local fs artifact) + .let [working_directory (# program directory) + @root (////repository/local.root program fs) + $bundle (////artifact.bundle (the ////artifact.#version artifact) artifact) + / (# fs separator) + @local (%.format @root / $bundle)] + windows? (async.future ..windows?) + process (is (Async (Try (shell.Process Async))) + (# shell execute [environment.empty @local + (if windows? + ["cmd" (list "/c" "for %file in (.\*) do gpg.exe -ab %file")] + ["sh" (list "-c" "for file in *.*; do gpg -ab $file; done")])])) + exit (is (Async (Try shell.Exit)) + (# process await [])) + .let [$artifact (////artifact.uri (the ////artifact.#version artifact) artifact)] + _ (monad.each ! (release_signed_artifact! local remote) + (list (..signed (..pom $artifact)) + (..signed (..tar $artifact)) + (..signed (..jar $artifact)) + (..signed (..javadoc $artifact)) + (..signed (..sources $artifact))))] + (in []))) diff --git a/stdlib/source/program/aedifex/command/deploy/snapshot.lux b/stdlib/source/program/aedifex/command/deploy/snapshot.lux index 9770965d9..fa69e8311 100644 --- a/stdlib/source/program/aedifex/command/deploy/snapshot.lux +++ b/stdlib/source/program/aedifex/command/deploy/snapshot.lux @@ -2,12 +2,13 @@ [library [lux "*" [abstract - [monad {"+" do}]] + [monad {"+" do}] + [predicate {"+" Predicate}]] [control [concurrency ["[0]" async {"+" Async}]]] [data - [text + ["[0]" text [encoding ["[0]" utf8]]] [collection @@ -37,6 +38,11 @@ ["[1][0]" artifact {"+" Artifact} ["[1]/[0]" type]]]) +(def: .public snapshot? + (Predicate Artifact) + (|>> (the ////artifact.#version) + (text.contains? "-SNAPSHOT"))) + (def: .public (do! console remote fs artifact profile) (-> (Console Async) (Repository Async) (file.System Async) Artifact (Command Any)) (do [! ////action.monad] diff --git a/stdlib/source/program/aedifex/format.lux b/stdlib/source/program/aedifex/format.lux index b7dd105c1..12f676cc7 100644 --- a/stdlib/source/program/aedifex/format.lux +++ b/stdlib/source/program/aedifex/format.lux @@ -115,6 +115,7 @@ (def: (info value) (Format /.Info) (|> ..empty + (..on_maybe "name" (the /.#name value) code.text) (..on_maybe "url" (the /.#url value) code.text) (..on_maybe "scm" (the /.#scm value) code.text) (..on_maybe "description" (the /.#description value) code.text) diff --git a/stdlib/source/program/aedifex/parser.lux b/stdlib/source/program/aedifex/parser.lux index 280c518e7..09ae15ed5 100644 --- a/stdlib/source/program/aedifex/parser.lux +++ b/stdlib/source/program/aedifex/parser.lux @@ -127,6 +127,7 @@ (.tuple (<>.some (<>.and .text .any))))] ($_ <>.and + (<>.maybe (..singular input "name" ..name)) (<>.maybe (..singular input "url" ..url)) (<>.maybe (..singular input "scm" ..scm)) (<>.maybe (..singular input "description" ..description)) diff --git a/stdlib/source/program/aedifex/pom.lux b/stdlib/source/program/aedifex/pom.lux index 8b4e8e0ed..683e1bb6d 100644 --- a/stdlib/source/program/aedifex/pom.lux +++ b/stdlib/source/program/aedifex/pom.lux @@ -94,52 +94,51 @@ (-> Text (-> (List XML) XML)) (|>> {_.#Node ["" tag] _.attributes})) -(comment - (def: scm - (-> /.SCM XML) - (|>> (..property ..url_tag) - list - {_.#Node ["" "scm"] _.attributes})) - - (def: (organization [name url]) - (-> /.Organization XML) - (|> (list (..property "name" name) - (..property ..url_tag url)) - {_.#Node ["" "organization"] _.attributes})) - - (def: (developer_organization [name url]) - (-> /.Organization (List XML)) - (list (..property "organization" name) - (..property "organizationUrl" url))) - - (def: (developer' [name email organization]) - (-> /.Developer (List XML)) - (partial_list (..property "name" name) - (..property "email" email) - (|> organization (maybe#each ..developer_organization) (maybe.else (list))))) - - (template [ ] - [(def: - (-> XML) - (|>> ..developer' {_.#Node ["" ] _.attributes}))] - - [developer /.Developer "developer"] - [contributor /.Contributor "contributor"] - ) - - (def: (info value) - (-> /.Info (List XML)) - ($_ list#composite - (|> value (the /.#url) (maybe#each (..property ..url_tag)) maybe.list) - (|> value (the /.#description) (maybe#each (..property "description")) maybe.list) - (|> value (the /.#licenses) (list#each ..license) (..group "licenses") list) - (|> value (the /.#scm) (maybe#each ..scm) maybe.list) - (|> value (the /.#organization) (maybe#each ..organization) maybe.list) - (|> value (the /.#developers) (list#each ..developer) (..group "developers") list) - (|> value (the /.#contributors) (list#each ..contributor) (..group "contributors") list) - )) +(def: scm + (-> /.SCM XML) + (|>> (..property ..url_tag) + list + {_.#Node ["" "scm"] _.attributes})) + +(def: (organization [name url]) + (-> /.Organization XML) + (|> (list (..property "name" name) + (..property ..url_tag url)) + {_.#Node ["" "organization"] _.attributes})) + +(def: (developer_organization [name url]) + (-> /.Organization (List XML)) + (list (..property "organization" name) + (..property "organizationUrl" url))) + +(def: (developer' [name email organization]) + (-> /.Developer (List XML)) + (partial_list (..property "name" name) + (..property "email" email) + (|> organization (maybe#each ..developer_organization) (maybe.else (list))))) + +(template [ ] + [(def: + (-> XML) + (|>> ..developer' {_.#Node ["" ] _.attributes}))] + + [developer /.Developer "developer"] + [contributor /.Contributor "contributor"] ) +(def: (info value) + (-> /.Info (List XML)) + ($_ list#composite + (|> value (the /.#name) (maybe#each (..property "name")) maybe.list) + (|> value (the /.#url) (maybe#each (..property ..url_tag)) maybe.list) + (|> value (the /.#description) (maybe#each (..property "description")) maybe.list) + (|> value (the /.#licenses) (list#each ..license) (..group "licenses") list) + (|> value (the /.#scm) (maybe#each ..scm) maybe.list) + (|> value (the /.#organization) (maybe#each ..organization) maybe.list) + (|> value (the /.#developers) (list#each ..developer) (..group "developers") list) + (|> value (the /.#contributors) (list#each ..contributor) (..group "contributors") list) + )) + (def: .public (write value) (-> /.Profile (Try XML)) (case (the /.#identity value) @@ -149,6 +148,10 @@ ($_ list#composite (list ..version) (..artifact identity) + (|> value + (the /.#info) + (maybe#each ..info) + (maybe.else (list))) (|> value (the /.#repositories) set.list (list#each ..repository) (..group "repositories") list) (|> value (the /.#dependencies) set.list (list#each ..dependency) (..group ..dependencies_tag) list) )}} diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux index 8fca5dffa..39f788b4b 100644 --- a/stdlib/source/program/aedifex/profile.lux +++ b/stdlib/source/program/aedifex/profile.lux @@ -108,7 +108,8 @@ (type: .public Info (Record - [#url (Maybe URL) + [#name (Maybe Text) + #url (Maybe URL) #scm (Maybe SCM) #description (Maybe Text) #licenses (List License) @@ -122,6 +123,7 @@ (maybe.equivalence text.equivalence) (maybe.equivalence text.equivalence) (maybe.equivalence text.equivalence) + (maybe.equivalence text.equivalence) (list.equivalence ..license_equivalence) (maybe.equivalence ..organization_equivalence) (list.equivalence ..developer_equivalence) @@ -129,7 +131,8 @@ (def: .public default_info Info - [#url {.#None} + [#name {.#None} + #url {.#None} #scm {.#None} #description {.#None} #licenses (list) diff --git a/stdlib/source/program/aedifex/repository/local.lux b/stdlib/source/program/aedifex/repository/local.lux index ada14650b..2c6ff8b9b 100644 --- a/stdlib/source/program/aedifex/repository/local.lux +++ b/stdlib/source/program/aedifex/repository/local.lux @@ -20,35 +20,37 @@ ["[1][0]" local] ["[1][0]" metadata]]]) -(def: (root program /) - (-> (Program Async) Text file.Path) - (|> ///local.repository - (text.replaced uri.separator /) - (format (# program home) /))) +(def: .public (root program fs) + (-> (Program Async) (file.System Async) file.Path) + (let [/ (# fs separator)] + (|> ///local.repository + (text.replaced uri.separator /) + (format (# program home) /)))) (def: (path /) (-> Text (-> URI file.Path)) (text.replaced uri.separator /)) -(def: (absolute_path program /) - (-> (Program Async) Text (-> URI file.Path)) - (|>> ///metadata.local_uri - (..path /) - (format (..root program /) /))) +(def: (absolute_path program fs) + (-> (Program Async) (file.System Async) (-> URI file.Path)) + (let [/ (# fs separator)] + (|>> ///metadata.local_uri + (..path /) + (format (..root program fs) /)))) (implementation: .public (repository program fs) (-> (Program Async) (file.System Async) (//.Repository Async)) (def: description - (..root program (# fs separator))) + (..root program fs)) (def: download - (|>> (..absolute_path program (# fs separator)) + (|>> (..absolute_path program fs) (# fs read))) (def: (upload uri content) (do [! async.monad] - [.let [absolute_path (..absolute_path program (# fs separator) uri)] + [.let [absolute_path (..absolute_path program fs uri)] ? (# fs file? absolute_path) _ (is (Async (Try Any)) (if ? diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index 0aec02f72..7ce8710c9 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -31,8 +31,10 @@ ["[0]" export]]]] [world ["[0]" file] - ["[0]" program {"+" Program}]]]] + ["[0]" program {"+" Program}] + ["[0]" shell]]]] [// + ["$[0]" build] ["$[0]" install] ["$[0]" version] [// @@ -56,9 +58,10 @@ Artifact ///.Profile (Async (Try Text))) (do ///action.monad - [.let [console ($version.echo "")] + [.let [console ($version.echo "") + shell (shell.async ($build.bad_shell []))] _ ($install.make_sources! fs (the ///.#sources profile)) - _ (/.do! console local remote fs artifact profile)] + _ (/.do! program shell console local remote fs artifact profile)] (# console read_line []))) (def: .public test diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux index aa2159929..e674942e0 100644 --- a/stdlib/source/test/aedifex/profile.lux +++ b/stdlib/source/test/aedifex/profile.lux @@ -98,8 +98,9 @@ (Random /.Info) ($_ random.and (random.maybe (random.ascii/alpha 1)) + (random.maybe (random.ascii/alpha 2)) (random.maybe ..scm) - (random.maybe (random.ascii/alpha 1)) + (random.maybe (random.ascii/alpha 3)) (..list_of ..license) (random.maybe ..organization) (..list_of ..developer) -- cgit v1.2.3