-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start of work supporting workspace in CLI tooling (#17)
* Working on loading up a workspace * Create an example of a multi-project workspace * Basic CLI * Working on the elm binding * Working on Path handling
- Loading branch information
1 parent
fdfba85
commit 699ef81
Showing
68 changed files
with
1,909 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ jobs: | |
with: | ||
java-version: 1.8 | ||
|
||
- name: Write | ||
|
||
- name: Cache SBT ivy cache | ||
uses: actions/cache@v1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "morphir/bindings/elm/morphir-elm"] | ||
path = morphir/toolbox/modules/morphir-elm | ||
url = https://github.com/Morgan-Stanley/morphir-elm.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
version = "2.4.1" | ||
version = "2.4.2" | ||
maxColumn = 120 | ||
align = most | ||
continuationIndent.defnSite = 2 | ||
assumeStandardLibraryStripMargin = true | ||
docstrings = JavaDoc | ||
lineEndings = preserve | ||
includeCurlyBraceInSelectChains = false | ||
danglingParentheses = true | ||
spaces { | ||
inImportCurlyBraces = true | ||
} | ||
optIn.annotationNewlines = true | ||
|
||
rewrite.rules = [SortImports, RedundantBraces] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Elm template | ||
# elm-package generated files | ||
elm-stuff | ||
# elm-repl generated files | ||
repl-temp-* | ||
|
||
### Morphir | ||
# Morphir output | ||
.morphir |
24 changes: 24 additions & 0 deletions
24
examples/workspaces/multi-project-workspace/models/order-taking/elm.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"type": "application", | ||
"source-directories": [ | ||
"src" | ||
], | ||
"elm-version": "0.19.1", | ||
"dependencies": { | ||
"direct": { | ||
"elm/browser": "1.0.2", | ||
"elm/core": "1.0.5", | ||
"elm/html": "1.0.0" | ||
}, | ||
"indirect": { | ||
"elm/json": "1.1.3", | ||
"elm/time": "1.0.0", | ||
"elm/url": "1.0.0", | ||
"elm/virtual-dom": "1.0.2" | ||
} | ||
}, | ||
"test-dependencies": { | ||
"direct": {}, | ||
"indirect": {} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...s/multi-project-workspace/models/order-taking/src/elm/GlobalCo/OrderTaking/OrderInput.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module OrderInput exposing (..) | ||
|
||
|
||
type alias UnvalidatedOrder = | ||
{ orderId : String } |
25 changes: 25 additions & 0 deletions
25
examples/workspaces/multi-project-workspace/models/shared-domain/elm.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"type": "application", | ||
"source-directories": [ | ||
"src/elm" | ||
], | ||
"elm-version": "0.19.1", | ||
"dependencies": { | ||
"direct": { | ||
"elm/browser": "1.0.2", | ||
"elm/core": "1.0.5", | ||
"elm/html": "1.0.0", | ||
"elm/regex": "1.0.0" | ||
}, | ||
"indirect": { | ||
"elm/json": "1.1.3", | ||
"elm/time": "1.0.0", | ||
"elm/url": "1.0.0", | ||
"elm/virtual-dom": "1.0.2" | ||
} | ||
}, | ||
"test-dependencies": { | ||
"direct": {}, | ||
"indirect": {} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ces/multi-project-workspace/models/shared-domain/src/elm/GlobalCo/Comms/CustomerEmail.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module GlobalCo.Comms.CustomerEmail exposing (CustomerEmail(..), VerifiedEmailAddress) | ||
|
||
import EmailAddress exposing (EmailAddress) | ||
|
||
|
||
type VerifiedEmailAddress | ||
= VerifiedEmailAddress String | ||
|
||
|
||
type CustomerEmail | ||
= Unverified EmailAddress | ||
| Verified VerifiedEmailAddress |
30 changes: 30 additions & 0 deletions
30
...aces/multi-project-workspace/models/shared-domain/src/elm/GlobalCo/Comms/EmailAddress.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module EmailAddress exposing (..) | ||
|
||
|
||
type EmailAddress | ||
= EmailAddress String | ||
|
||
|
||
create : String -> Result String EmailAddress | ||
create text = | ||
let | ||
len = | ||
String.length text | ||
|
||
endIdx = | ||
len - 1 | ||
in | ||
if String.isEmpty text then | ||
"An email address cannot be empty" |> Result.Err | ||
|
||
else | ||
case String.indices "@" text of | ||
[] -> | ||
"Invalid email address" |> Result.Err | ||
|
||
idx :: [] -> | ||
if idx < endIdx then | ||
EmailAddress text |> Result.Ok | ||
|
||
else | ||
"Invalid email address" |> Result.Err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[projects.globalco-shared] | ||
projectDir = "models/shared-domain" | ||
|
||
[projects.globalco-order-taking] | ||
projectDir = "models/order-taking" |
57 changes: 57 additions & 0 deletions
57
morphir/cli/shared/src/main/scala/org/morphir/cli/Cli.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.morphir.cli | ||
|
||
import java.nio.file.Path | ||
|
||
import com.monovore.decline._ | ||
import org.morphir.toolbox.cli.CliCommand | ||
import org.morphir.toolbox.cli.commands.{ BuildCommand, WorkspaceInfoCommand } | ||
import zio.{ IO, ZIO } | ||
|
||
object Cli { | ||
|
||
def parse(args: Seq[String]): IO[Help, CliCommand] = | ||
ZIO.fromEither(Cli.rootCommand.parse(args)) | ||
|
||
lazy val rootCommand: Command[CliCommand] = Command("morphir", "Morphir CLI")( | ||
buildCommand orElse projectCommand orElse workspaceCommand | ||
) | ||
|
||
lazy val buildCommand: Opts[BuildCommand] = Opts | ||
.subcommand("build", help = "Build the workspace")( | ||
workspaceOpt.orNone | ||
) | ||
.map(BuildCommand) | ||
|
||
lazy val projectCommand: Opts[CliCommand.ProjectList] = Opts.subcommand("project", help = "Work with projects")( | ||
Opts | ||
.subcommand(name = "list", help = "List projects in the workspace")( | ||
workspaceOpt.orNone | ||
) | ||
.map(CliCommand.ProjectList) | ||
) | ||
|
||
lazy val workspaceCommand: Opts[CliCommand] = | ||
Opts.subcommand("workspace", help = "Work wth workspaces") { | ||
val initCmd = Opts | ||
.subcommand("init", help = "Initialize a workspace")( | ||
workspaceOpt.orNone | ||
) | ||
.map(CliCommand.WorkspaceInit) | ||
|
||
val infoCmd = Opts | ||
.subcommand("info", help = "Get information about a workspace")( | ||
workspaceOpt.orNone | ||
) | ||
.map(WorkspaceInfoCommand) | ||
|
||
infoCmd orElse initCmd | ||
} | ||
|
||
private lazy val workspaceOpt = Opts.option[Path]( | ||
"workspace", | ||
short = "w", | ||
metavar = "workspace-path", | ||
help = "The path to the workspace folder or manifest file." | ||
) | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
morphir/cli/shared/src/main/scala/org/morphir/cli/Main.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.morphir.cli | ||
|
||
import org.morphir.toolbox.workspace.WorkspaceModule | ||
import zio._ | ||
|
||
object Main extends App { | ||
|
||
override def run(args: List[String]): ZIO[zio.ZEnv, Nothing, Int] = | ||
(for { | ||
cmd <- ZIO.fromEither(Cli.rootCommand.parse(args)) | ||
exitCode <- cmd.execute | ||
ec = exitCode.code | ||
} yield ec) | ||
.provideSomeLayer[zio.ZEnv](WorkspaceModule.live) | ||
.catchAll(help => ZIO.effectTotal(System.err.println(help)) *> ZIO.succeed(1)) | ||
|
||
} |
Oops, something went wrong.