Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding load project #298

Draft
wants to merge 1 commit into
base: spree02
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions morphir/lang/elm/src/org/finos/morphir/lang/elm/services.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.finos.morphir.lang.elm

import kyo.{Path as _, _}
import kyo.Result.Fail
import kyo.{Path as _, *}
import metaconfig.{ConfError, Input}

import java.net.{URI, URL}
import org.finos.morphir.Path
import org.finos.morphir.GenericPath
import org.finos.morphir.{FilePath, GenericPath, Path, VirtualPath}
import os.*

// trait ElmProjectInfoService:
// self =>
Expand All @@ -24,8 +27,15 @@ trait ElmProjectLoader:

object ElmProjectLoader:
final case class Live() extends ElmProjectLoader:
override def loadProject(path: GenericPath): ElmProject < IO & Abort[String | Exception] = ???
override def loadProject(uri: URI): ElmProject < IO & Abort[String | Exception] = ???
override def loadProject(path: GenericPath): ElmProject < IO & Abort[String | Exception] = path match
case path: FilePath => ???
case path: VirtualPath => ???
case _ => ???

override def loadProject(uri: URI): ElmProject < IO & Abort[String | Exception] =
IO(ElmProject.parseFile(os.Path(uri))) match
case Result.Success(value): Result.Success[ElmProject] => kyo.Path
case Result.Fail(error): Result.Fail[ConfError] => Abort.fail(error.msg)

trait ElmPackageResolver:
import ElmPackageResolver.*
Expand Down
2 changes: 1 addition & 1 deletion morphir/src/org/finos/morphir/lang/elm/project.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object ElmProject extends ConfigCompanion[ElmProject]:
) extends ElmProject

object ElmApplication:
private val default: ElmApplication = ElmApplication(
val default: ElmApplication = ElmApplication(
List("src"),
SemVerString("0.0.1"),
ElmApplicationDependencies.default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ object ElmProjectSpec extends MorphirSpecDefault {
},
test("Can get the namespace from a module name with one") {
val moduleName = ElmModuleName("Morphir.Sdk")
assertTrue(moduleName.namespace == Some("Morphir"))
assertTrue(moduleName.namespace.contains("Morphir"))
},
test("Can get the namespace from a module name with a longer namespace") {
val moduleName = ElmModuleName("Morphir.IR.SDK.String")
assertTrue(moduleName.namespace == Some("Morphir.IR.SDK"))
assertTrue(moduleName.namespace.contains("Morphir.IR.SDK"))
},
test("should parse a valid Elm module name") {
val result = ElmModuleName.parse("Morphir.Core")
Expand Down
Loading