add aqua run services support (#551)

This commit is contained in:
Dima 2022-08-29 18:10:54 +04:00 committed by GitHub
parent 98ee1c7083
commit 5bd30c7918
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 7 deletions

View File

@ -42,12 +42,17 @@ class FuncCompiler[F[_]: Files: AquaIO: Async](
func: CliFunc,
services: List[JsonService]
): ValidatedNec[String, (FuncArrow, List[Service])] =
contexts
.collectFirstSome(c => c.allFuncs.get(func.name))
func.ability
.fold(
contexts
.collectFirstSome(_.allFuncs.get(func.name))
)(ab =>
contexts.collectFirstSome(_.abilities.get(ab).flatMap(_.allFuncs.get(func.name)))
)
.map(validNec)
.getOrElse(
Validated.invalidNec[String, FuncArrow](
s"There is no function '${func.name}' or it is not exported. Check the spelling or see https://doc.fluence.dev/aqua-book/language/header#export"
s"There is no function '${func.ability.map(_ + ".").getOrElse("")}${func.name}' or it is not exported. Check the spelling or see https://doc.fluence.dev/aqua-book/language/header#export"
)
)
.andThen { func =>
@ -62,7 +67,8 @@ class FuncCompiler[F[_]: Files: AquaIO: Async](
): ValidatedNec[String, List[Service]] = {
services
.map(js =>
contexts.collectFirstSome(_.services.get(js.name))
contexts
.collectFirstSome(_.services.get(js.name))
.map(sm => (js, sm))
.map(validNec)
.getOrElse(
@ -90,7 +96,10 @@ class FuncCompiler[F[_]: Files: AquaIO: Async](
case h :: _ =>
Conversions.ts2aqua(jf.result, TypeDefinitionJs(TypeDefinition(h)))
case Nil =>
Conversions.ts2aqua(jf.result, TypeDefinitionJs(TypeDefinition(NilType)))
Conversions.ts2aqua(
jf.result,
TypeDefinitionJs(TypeDefinition(NilType))
)
}
js.Promise.resolve(converted)

View File

@ -113,7 +113,7 @@ object Plugin {
def opt[F[_]: Files: Concurrent]: Opts[F[ValidatedNec[String, List[String]]]] = {
Opts
.options[String]("plugin", "[experimental] Path to a directory with JS plugins", "p", "path")
.options[String]("plugin", "[experimental] Path to a directory with JS plugins", "", "path")
.map { strs =>
strs.toList.map(s => pathToMjsFilesList(s)).sequence.map(_.sequence.map(_.flatten))
}

View File

@ -219,7 +219,7 @@ object ScriptOpts extends Logging {
def remove[F[_]: Async]: SubCommandBuilder[F] =
SubCommandBuilder.valid[F](
"remove",
"Remove a service from a remote peer",
"Remove a script from a remote peer",
(
commonScriptOpts,
scriptIdOpt