aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/program/aedifex/command/auto.lux2
-rw-r--r--stdlib/source/program/aedifex/command/build.lux84
-rw-r--r--stdlib/source/program/aedifex/command/clean.lux39
-rw-r--r--stdlib/source/program/aedifex/command/deploy.lux5
-rw-r--r--stdlib/source/program/aedifex/command/deps.lux1
-rw-r--r--stdlib/source/program/aedifex/command/install.lux5
-rw-r--r--stdlib/source/program/aedifex/command/pom.lux5
-rw-r--r--stdlib/source/program/aedifex/command/test.lux4
-rw-r--r--stdlib/source/program/aedifex/dependency/deployment.lux58
-rw-r--r--stdlib/source/program/aedifex/format.lux2
-rw-r--r--stdlib/source/program/aedifex/parser.lux7
-rw-r--r--stdlib/source/program/aedifex/pom.lux37
-rw-r--r--stdlib/source/program/aedifex/profile.lux12
-rw-r--r--stdlib/source/program/compositor.lux15
14 files changed, 164 insertions, 112 deletions
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)
_ <call>]
(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
diff --git a/stdlib/source/program/aedifex/dependency/deployment.lux b/stdlib/source/program/aedifex/dependency/deployment.lux
index 963602494..0fdf7956f 100644
--- a/stdlib/source/program/aedifex/dependency/deployment.lux
+++ b/stdlib/source/program/aedifex/dependency/deployment.lux
@@ -23,7 +23,7 @@
[format
["." xml]]]
[time
- ["." instant]]
+ ["." instant (#+ Instant)]]
[world
[program (#+ Program)]
["." file (#+ Path File Directory)]]]
@@ -32,6 +32,7 @@
["#." hash (#+ Hash SHA-1 MD5)]
["#." package (#+ Package)]
["#." artifact (#+ Artifact)
+ ["#/." time]
["#/." type]
["#/." extension (#+ Extension)]
["#/." versioning]
@@ -40,7 +41,7 @@
["#/." value]]]]
["#." metadata
["#/." artifact]
- ["#/." snapshot]]
+ ["#/." snapshot (#+ Metadata)]]
["#." dependency (#+ Dependency)
[resolution (#+ Resolution)]
["#/." status (#+ Status)]]
@@ -93,6 +94,35 @@
(#///dependency/status.Verified _)
(list <sha-1> <md5>)))))
+(def: (update_snapshot [artifact type] now snapshot)
+ (-> Dependency Instant Metadata (Try Metadata))
+ (do try.monad
+ [now (: (Try ///artifact/time.Time)
+ (///artifact/time.from_instant now))
+ #let [version_template (get@ #///artifact.version artifact)
+ snapshot (|> snapshot
+ (update@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot]
+ (function (_ snapshot)
+ (case snapshot
+ #///artifact/snapshot.Local
+ #///artifact/snapshot.Local
+
+ (#///artifact/snapshot.Remote [_ build])
+ (#///artifact/snapshot.Remote [now (inc build)]))))
+ (set@ [#///metadata/snapshot.versioning #///artifact/versioning.last_updated] now))
+ versioning_snapshot (get@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot] snapshot)]]
+ (wrap (|> snapshot
+ (set@ [#///metadata/snapshot.versioning #///artifact/versioning.versions]
+ (list {#///artifact/snapshot/version.extension type
+ #///artifact/snapshot/version.value (///artifact/snapshot/version/value.format
+ {#///artifact/snapshot/version/value.version version_template
+ #///artifact/snapshot/version/value.snapshot versioning_snapshot})
+ #///artifact/snapshot/version.updated now}))
+ ## (set@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot]
+ ## (list\compose (..artifacts type (product.right (get@ #///package.library package)))
+ ## (..artifacts ///artifact/type.pom (product.right (get@ #///package.pom package)))))
+ ))))
+
(def: #export (one repository [artifact type] package)
(-> (Repository Promise) Dependency Package (Promise (Try Artifact)))
(do {! promise.monad}
@@ -109,28 +139,8 @@
status]))
snapshot (///metadata/snapshot.read repository artifact)
- #let [snapshot (|> snapshot
- (update@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot]
- (function (_ snapshot)
- (case snapshot
- #///artifact/snapshot.Local
- #///artifact/snapshot.Local
-
- (#///artifact/snapshot.Remote [_ build])
- (#///artifact/snapshot.Remote [now (inc build)]))))
- (set@ [#///metadata/snapshot.versioning #///artifact/versioning.last_updated] now))
- versioning_snapshot (get@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot] snapshot)]
- _ (|> snapshot
- (set@ [#///metadata/snapshot.versioning #///artifact/versioning.versions]
- (list {#///artifact/snapshot/version.extension type
- #///artifact/snapshot/version.value (///artifact/snapshot/version/value.format
- {#///artifact/snapshot/version/value.version version_template
- #///artifact/snapshot/version/value.snapshot versioning_snapshot})
- #///artifact/snapshot/version.updated now}))
- ## (set@ [#///metadata/snapshot.versioning #///artifact/versioning.snapshot]
- ## (list\compose (..artifacts type (product.right (get@ #///package.library package)))
- ## (..artifacts ///artifact/type.pom (product.right (get@ #///package.pom package)))))
- (///metadata/snapshot.write repository artifact))
+ snapshot (\ ! wrap (..update_snapshot [artifact type] now snapshot))
+ _ (///metadata/snapshot.write repository artifact snapshot)
project (///metadata/artifact.read repository artifact)
_ (|> project
(set@ #///metadata/artifact.versions (list version_template))
diff --git a/stdlib/source/program/aedifex/format.lux b/stdlib/source/program/aedifex/format.lux
index 6fcbb2db7..7778e7641 100644
--- a/stdlib/source/program/aedifex/format.lux
+++ b/stdlib/source/program/aedifex/format.lux
@@ -140,7 +140,7 @@
(..on_set "repositories" (get@ #/.repositories value) code.text)
(..on_set "dependencies" (get@ #/.dependencies value) ..dependency)
(..on_set "sources" (get@ #/.sources value) code.text)
- (..on_maybe "target" (get@ #/.target value) code.text)
+ (dictionary.put "target" (code.text (get@ #/.target value)))
(..on_maybe "program" (get@ #/.program value) code.text)
(..on_maybe "test" (get@ #/.test value) code.text)
(..on_dictionary "deploy_repositories" (get@ #/.deploy_repositories value) code.text code.text)
diff --git a/stdlib/source/program/aedifex/parser.lux b/stdlib/source/program/aedifex/parser.lux
index 3c1b4144a..60e491dac 100644
--- a/stdlib/source/program/aedifex/parser.lux
+++ b/stdlib/source/program/aedifex/parser.lux
@@ -200,9 +200,10 @@
(|> (..plural input "sources" ..source)
(\ ! map (set.from_list text.hash))
(<>.default (set.from_list text.hash (list /.default_source)))))
- ^target (: (Parser (Maybe /.Target))
- (<>.maybe
- (..singular input "target" ..target)))
+ ^target (: (Parser /.Target)
+ (|> ..target
+ (..singular input "target")
+ (<>.default /.default_target)))
^program (: (Parser (Maybe Module))
(<>.maybe
(..singular input "program" ..module)))
diff --git a/stdlib/source/program/aedifex/pom.lux b/stdlib/source/program/aedifex/pom.lux
index f105f07b6..0d468d5f2 100644
--- a/stdlib/source/program/aedifex/pom.lux
+++ b/stdlib/source/program/aedifex/pom.lux
@@ -30,6 +30,9 @@
(def: project_tag "project")
(def: dependencies_tag "dependencies")
+(def: repositories_tag "repositories")
+(def: repository_tag "repository")
+(def: url_tag "url")
(def: group_tag "groupId")
(def: artifact_tag "artifactId")
(def: version_tag "version")
@@ -63,15 +66,15 @@
(def: (license [name url distribution])
(-> /.License XML)
(|> (list (..property "name" name)
- (..property "url" url)
+ (..property ..url_tag url)
(..distribution distribution))
(#_.Node ["" "license"] _.attributes)))
(def: repository
(-> Address XML)
- (|>> (..property "url")
+ (|>> (..property ..url_tag)
list
- (#_.Node ["" "repository"] _.attributes)))
+ (#_.Node ["" ..repository_tag] _.attributes)))
(def: (dependency value)
(-> Dependency XML)
@@ -87,14 +90,14 @@
(comment
(def: scm
(-> /.SCM XML)
- (|>> (..property "url")
+ (|>> (..property ..url_tag)
list
(#_.Node ["" "scm"] _.attributes)))
(def: (organization [name url])
(-> /.Organization XML)
(|> (list (..property "name" name)
- (..property "url" url))
+ (..property ..url_tag url))
(#_.Node ["" "organization"] _.attributes)))
(def: (developer_organization [name url])
@@ -120,7 +123,7 @@
(def: (info value)
(-> /.Info (List XML))
($_ list\compose
- (|> value (get@ #/.url) (maybe\map (..property "url")) maybe.to_list)
+ (|> value (get@ #/.url) (maybe\map (..property ..url_tag)) maybe.to_list)
(|> value (get@ #/.description) (maybe\map (..property "description")) maybe.to_list)
(|> value (get@ #/.licenses) (list\map ..license) (..group "licenses") list)
(|> value (get@ #/.scm) (maybe\map ..scm) maybe.to_list)
@@ -178,6 +181,21 @@
[_ (<xml>.node ["" ..dependencies_tag])]
(<xml>.children (<>.some (..parse_dependency own_version parent_version)))))
+(def: parse_repository
+ (Parser Address)
+ (do {! <>.monad}
+ [_ (<xml>.node ["" ..repository_tag])]
+ (<xml>.children
+ (do !
+ [_ (<xml>.node ["" ..url_tag])]
+ (<xml>.children <xml>.text)))))
+
+(def: parse_repositories
+ (Parser (List Address))
+ (do {! <>.monad}
+ [_ (<xml>.node ["" ..repositories_tag])]
+ (<xml>.children (<>.some ..parse_repository))))
+
(def: own_version
(Parser Text)
(do <>.monad
@@ -201,7 +219,12 @@
[dependencies (|> (..parse_dependencies own_version parent_version)
<xml>.somewhere
(<>.default (list)))
+ repositories (|> ..parse_repositories
+ <xml>.somewhere
+ (<>.default (list)))
_ (<>.some <xml>.ignore)]
(wrap (|> (\ /.monoid identity)
(update@ #/.dependencies (function (_ empty)
- (list\fold set.add empty dependencies)))))))))
+ (list\fold set.add empty dependencies)))
+ (update@ #/.repositories (function (_ empty)
+ (list\fold set.add empty repositories)))))))))
diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux
index 592e221fd..98eb1c43e 100644
--- a/stdlib/source/program/aedifex/profile.lux
+++ b/stdlib/source/program/aedifex/profile.lux
@@ -8,7 +8,7 @@
[data
["." product]
["." maybe ("#\." monoid)]
- ["." text]
+ ["." text ("#\." equivalence)]
[collection
["." dictionary (#+ Dictionary)]
["." list ("#\." monoid)]
@@ -150,7 +150,7 @@
#repositories (Set Address)
#dependencies (Set dependency.Dependency)
#sources (Set Source)
- #target (Maybe Target)
+ #target Target
#program (Maybe Module)
#test (Maybe Module)
#deploy_repositories (Dictionary Text Address)})
@@ -171,7 +171,7 @@
## #sources
set.equivalence
## #target
- (maybe.equivalence text.equivalence)
+ text.equivalence
## #program
(maybe.equivalence text.equivalence)
## #test
@@ -189,7 +189,7 @@
#repositories (set.new text.hash)
#dependencies (set.new dependency.hash)
#sources (set.new text.hash)
- #target #.None
+ #target ..default_target
#program #.None
#test #.None
#deploy_repositories (dictionary.new text.hash)})
@@ -201,7 +201,9 @@
#repositories (set.union (get@ #repositories baseline) (get@ #repositories override))
#dependencies (set.union (get@ #dependencies baseline) (get@ #dependencies override))
#sources (set.union (get@ #sources baseline) (get@ #sources override))
- #target (maybe\compose (get@ #target override) (get@ #target baseline))
+ #target (if (text\= ..default_target (get@ #target baseline))
+ (get@ #target override)
+ (get@ #target baseline))
#program (maybe\compose (get@ #program override) (get@ #program baseline))
#test (maybe\compose (get@ #test override) (get@ #test baseline))
#deploy_repositories (dictionary.merge (get@ #deploy_repositories override) (get@ #deploy_repositories baseline))}))
diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux
index a6b85ccf0..557e9d22a 100644
--- a/stdlib/source/program/compositor.lux
+++ b/stdlib/source/program/compositor.lux
@@ -20,6 +20,8 @@
[collection
["." dictionary]
["." row (#+ Row)]]]
+ [time
+ ["." instant]]
["." world #_
["." file (#+ File Path)]
["#/." program]
@@ -71,6 +73,18 @@
(#try.Success output)
(wrap output))))
+(def: (timed process)
+ (All [a]
+ (-> (Promise (Try a)) (Promise (Try a))))
+ (do promise.monad
+ [#let [start (io.run instant.now)]
+ output process
+ #let [_ ("lux io log" (|> (io.run instant.now)
+ (instant.span start)
+ %.duration
+ (format "Duration: ")))]]
+ (wrap output)))
+
(def: (package! monad file_system [packager package] static archive context)
(All [!] (-> (Monad !) (file.System !) [Packager Path] Static Archive Context (! (Try Any))))
(for {@.old
@@ -132,6 +146,7 @@
(case service
(#/cli.Compilation compilation)
(<| (or_crash! "Compilation failed:")
+ ..timed
(do (try.with promise.monad)
[#let [[compilation_sources compilation_libraries compilation_target compilation_module] compilation]
import (/import.import (get@ #platform.&file_system platform) compilation_libraries)