aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program/aedifex/command
diff options
context:
space:
mode:
authorEduardo Julian2020-12-29 23:29:54 -0400
committerEduardo Julian2020-12-29 23:29:54 -0400
commit02d27daeacac74785c2b0f4d1ce03d432377a36e (patch)
tree5129c496d136deb57880f202153e96f4f585e355 /stdlib/source/program/aedifex/command
parent832a9361b632331e82a64c07baa560487ca8abde (diff)
Unified repository abstraction for Aedifex.
Diffstat (limited to 'stdlib/source/program/aedifex/command')
-rw-r--r--stdlib/source/program/aedifex/command/build.lux19
-rw-r--r--stdlib/source/program/aedifex/command/deploy.lux115
-rw-r--r--stdlib/source/program/aedifex/command/deps.lux20
-rw-r--r--stdlib/source/program/aedifex/command/install.lux45
4 files changed, 73 insertions, 126 deletions
diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux
index a05d7ad85..7241b1de4 100644
--- a/stdlib/source/program/aedifex/command/build.lux
+++ b/stdlib/source/program/aedifex/command/build.lux
@@ -26,13 +26,14 @@
[program (#+ Program)]
["." file (#+ Path)]
["." shell (#+ Shell)]
- ["." console (#+ Console)]]]
+ ["." console (#+ Console)]
+ [net
+ ["." uri]]]]
["." /// #_
["#" profile]
["#." action]
["#." command (#+ Command)]
["#." local]
- ["#." cache]
["#." repository]
["#." runtime]
["#." dependency (#+ Dependency)
@@ -102,11 +103,19 @@
_
(exception.throw ..no_available_compiler [])))
+(def: (path fs home artifact)
+ (All [!] (-> (file.System !) Path Artifact Path))
+ (let [/ (\ fs separator)]
+ (|> artifact
+ ///local.uri
+ (text.replace_all uri.separator /)
+ (format home /))))
+
(def: (libraries fs home)
(All [!] (-> (file.System !) Path Resolution (List Path)))
(|>> dictionary.keys
(list.filter (|>> (get@ #///dependency.type) (text\= ///artifact/type.lux_library)))
- (list\map (|>> (get@ #///dependency.artifact) (///local.path fs home)))))
+ (list\map (|>> (get@ #///dependency.artifact) (..path fs home)))))
(def: (singular name)
(-> Text Text (List Text))
@@ -138,9 +147,9 @@
(do ///action.monad
[[resolution compiler] (promise\wrap (..compiler resolution))
#let [[command output] (let [[compiler output] (case compiler
- (#JVM artifact) [(///runtime.java (///local.path fs home artifact))
+ (#JVM artifact) [(///runtime.java (..path fs home artifact))
"program.jar"]
- (#JS artifact) [(///runtime.node (///local.path fs home artifact))
+ (#JS artifact) [(///runtime.node (..path fs home artifact))
"program.js"])]
[(format compiler " build") output])
/ (\ fs separator)
diff --git a/stdlib/source/program/aedifex/command/deploy.lux b/stdlib/source/program/aedifex/command/deploy.lux
index b00f964d7..fe96055ef 100644
--- a/stdlib/source/program/aedifex/command/deploy.lux
+++ b/stdlib/source/program/aedifex/command/deploy.lux
@@ -36,9 +36,14 @@
["#." action (#+ Action)]
["#." pom]
["#." hash]
+ ["#." package]
+ ["#." dependency
+ ["#/." deployment]
+ ["#/." status (#+ Status)]]
["#." repository (#+ Repository)
[identity (#+ Identity)]
- ["#/." remote]]
+ ["#/." remote]
+ ["#/." origin]]
["#." metadata
["#/." artifact]
["#/." snapshot]]
@@ -46,94 +51,24 @@
["#/." extension (#+ Extension)]
["#/." type]]]])
-(def: epoch
- Instant
- (instant.from_millis +0))
-
-(template [<name> <type> <uri> <parser> <default>]
- [(def: (<name> repository artifact)
- (-> (Repository Promise) Artifact (Promise (Try <type>)))
- (do promise.monad
- [project (\ repository download (<uri> artifact))]
- (case project
- (#try.Success project)
- (wrap (|> project
- (do> try.monad
- [(\ encoding.utf8 decode)]
- [(\ xml.codec decode)]
- [(<xml>.run <parser>)])))
-
- (#try.Failure error)
- (wrap (#try.Success <default>)))))]
-
- [read_project_metadata ///metadata/artifact.Metadata ///metadata.project ///metadata/artifact.parser
- (let [(^slots [#///artifact.group #///artifact.name #///artifact.version]) artifact]
- {#///metadata/artifact.group group
- #///metadata/artifact.name name
- #///metadata/artifact.versions (list)
- #///metadata/artifact.last_updated ..epoch})]
- [read_version_metadata ///metadata/snapshot.Metadata ///metadata.version ///metadata/snapshot.parser
- (let [(^slots [#///artifact.group #///artifact.name #///artifact.version]) artifact]
- {#///metadata/snapshot.group group
- #///metadata/snapshot.name name
- #///metadata/snapshot.version version
- #///metadata/snapshot.versioning {#///metadata/snapshot.time_stamp ..epoch
- #///metadata/snapshot.build 0
- #///metadata/snapshot.snapshot (list)}})]
- )
-
-(def: snapshot_artifacts
- (List ///artifact/type.Type)
- (list ///artifact/type.pom
- (format ///artifact/type.pom ///artifact/extension.sha-1)
- (format ///artifact/type.pom ///artifact/extension.md5)
- ///artifact/type.lux_library
- (format ///artifact/type.lux_library ///artifact/extension.sha-1)
- (format ///artifact/type.lux_library ///artifact/extension.md5)))
-
(def: #export (do! console repository fs artifact profile)
(-> (Console Promise) (Repository Promise) (file.System Promise) Artifact (Command Any))
- (let [deploy! (: (-> Extension Binary (Action Any))
- (|>> (///repository/remote.uri artifact)
- (\ repository upload)))
- fully_deploy! (: (-> Extension Binary (Action Any))
- (function (_ extension payload)
- (do ///action.monad
- [_ (deploy! extension payload)
- _ (deploy! (format extension ///artifact/extension.sha-1)
- (///hash.data (///hash.sha-1 payload)))
- _ (deploy! (format extension ///artifact/extension.md5)
- (///hash.data (///hash.md5 payload)))]
- (wrap []))))
- (^slots [#///artifact.group #///artifact.name #///artifact.version]) artifact]
- (do promise.monad
- [now (promise.future instant.now)]
- (do {! ///action.monad}
- [project (..read_project_metadata repository artifact)
- snapshot (..read_version_metadata repository artifact)
- pom (\ ! map (|>> (\ xml.codec encode) (\ encoding.utf8 encode))
- (promise\wrap (///pom.write profile)))
- library (|> profile
- (get@ #/.sources)
- set.to_list
- (export.library fs)
- (\ ! map (binary.run tar.writer)))
-
- _ (fully_deploy! ///artifact/extension.pom pom)
- _ (fully_deploy! ///artifact/extension.lux_library library)
- _ (|> snapshot
- (set@ [#///metadata/snapshot.versioning #///metadata/snapshot.time_stamp] now)
- (update@ [#///metadata/snapshot.versioning #///metadata/snapshot.build] inc)
- (set@ [#///metadata/snapshot.versioning #///metadata/snapshot.snapshot] ..snapshot_artifacts)
- ///metadata/snapshot.write
- (\ xml.codec encode)
- (\ encoding.utf8 encode)
- (\ repository upload (///metadata.version artifact)))
- _ (|> project
- (set@ #///metadata/artifact.versions (list version))
- (set@ #///metadata/artifact.last_updated now)
- ///metadata/artifact.write
- (\ xml.codec encode)
- (\ encoding.utf8 encode)
- (\ repository upload (///metadata.project artifact)))]
- (console.write_line //clean.success console)))))
+ (do {! ///action.monad}
+ [library (|> profile
+ (get@ #/.sources)
+ set.to_list
+ (export.library fs)
+ (\ ! map (binary.run tar.writer)))
+ pom (\ promise.monad wrap (///pom.write profile))
+ _ (///dependency/deployment.one
+ repository
+ [artifact ///artifact/type.lux_library]
+ {#///package.origin (#///repository/origin.Remote "")
+ #///package.library [library
+ (///dependency/status.verified library)]
+ #///package.pom [pom
+ (|> pom
+ (\ xml.codec encode)
+ (\ encoding.utf8 encode)
+ ///dependency/status.verified)]})]
+ (console.write_line //clean.success console)))
diff --git a/stdlib/source/program/aedifex/command/deps.lux b/stdlib/source/program/aedifex/command/deps.lux
index 315c6375c..71dffeec1 100644
--- a/stdlib/source/program/aedifex/command/deps.lux
+++ b/stdlib/source/program/aedifex/command/deps.lux
@@ -7,7 +7,9 @@
["." promise (#+ Promise)]]]
[data
[collection
- ["." set (#+ Set)]]]
+ ["." set (#+ Set)]
+ ["." list ("#\." fold)]
+ ["." dictionary]]]
[world
[program (#+ Program)]
["." file]
@@ -20,16 +22,18 @@
[repository (#+ Repository)]
["#" profile]
["#." action (#+ Action)]
- ["#." cache]
["#." dependency #_
- ["#/." resolution (#+ Resolution)]]]])
+ ["#/." resolution (#+ Resolution)]
+ ["#/." deployment]]]])
-(def: #export (do! program console fs repositories profile)
- (-> (Program Promise) (Console Promise) (file.System Promise) (List (Repository Promise)) (Command Resolution))
+(def: #export (do! console local remotes profile)
+ (-> (Console Promise) (Repository Promise) (List (Repository Promise)) (Command Resolution))
(do ///action.monad
[#let [dependencies (set.to_list (get@ #///.dependencies profile))]
- cache (///cache.read_all program fs dependencies ///dependency/resolution.empty)
- resolution (///dependency/resolution.all repositories dependencies cache)
- cached (///cache.write_all program fs resolution)
+ cache (///dependency/resolution.all (list local) dependencies ///dependency/resolution.empty)
+ resolution (///dependency/resolution.all remotes dependencies cache)
+ cached (|> (dictionary.keys cache)
+ (list\fold dictionary.remove resolution)
+ (///dependency/deployment.all local))
_ (console.write_line //clean.success console)]
(wrap resolution)))
diff --git a/stdlib/source/program/aedifex/command/install.lux b/stdlib/source/program/aedifex/command/install.lux
index 033b41b40..b051a4900 100644
--- a/stdlib/source/program/aedifex/command/install.lux
+++ b/stdlib/source/program/aedifex/command/install.lux
@@ -35,36 +35,35 @@
["#." command (#+ Command)]
["#." local]
["#." pom]
+ ["#." package]
+ [repository (#+ Repository)
+ ["#." origin]]
+ ["#." dependency #_
+ ["#/." deployment]
+ ["#/." status]]
["#." artifact (#+ Artifact)
- ["#/." extension]]]])
-
-(def: (save! system content file)
- (-> (file.System Promise) Binary Path (Promise (Try Any)))
- (do (try.with promise.monad)
- [file (: (Promise (Try (File Promise)))
- (file.get_file promise.monad system file))]
- (!.use (\ file over_write) [content])))
+ ["#/." type]]]])
(def: #export failure
"Failure: No 'identity' defined for the project.")
-(def: #export (do! program console system profile)
- (-> (Program Promise) (Console Promise) (file.System Promise) (Command Any))
+(def: #export (do! console system repository profile)
+ (-> (Console Promise) (file.System Promise) (Repository Promise) (Command Any))
(case (get@ #/.identity profile)
(#.Some identity)
- (do promise.monad
- [home (\ program home [])]
- (do ///action.monad
- [package (export.library system (set.to_list (get@ #/.sources profile)))
- repository (: (Promise (Try Path))
- (file.make_directories promise.monad system (///local.path system home identity)))
- #let [artifact_name (format repository (\ system separator) (///artifact.identity identity))]
- _ (..save! system (binary.run tar.writer package)
- (format artifact_name ///artifact/extension.lux_library))
- pom (\ promise.monad wrap (///pom.write profile))
- _ (..save! system (|> pom (\ xml.codec encode) (\ encoding.utf8 encode))
- (format artifact_name ///artifact/extension.pom))]
- (console.write_line //clean.success console)))
+ (do ///action.monad
+ [package (export.library system (set.to_list (get@ #/.sources profile)))
+ pom (\ promise.monad wrap (///pom.write profile))
+ _ (///dependency/deployment.one repository [identity ///artifact/type.lux_library]
+ {#///package.origin (#///origin.Local "")
+ #///package.library (let [library (binary.run tar.writer package)]
+ [library (///dependency/status.verified library)])
+ #///package.pom [pom
+ (|> pom
+ (\ xml.codec encode)
+ (\ encoding.utf8 encode)
+ ///dependency/status.verified)]})]
+ (console.write_line //clean.success console))
_
(console.write_line ..failure console)))