-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #463 from innFactory/feat/v5
Feat/v5
- Loading branch information
Showing
183 changed files
with
5,038 additions
and
2,658 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
This file was deleted.
Oops, something went wrong.
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 @@ | ||
version: '3.1' | ||
|
||
services: | ||
mock: | ||
container_name: mock-server | ||
image: stoplight/prism:4.10.3 | ||
command: > | ||
mock -p 4010 --host 0.0.0.0 -m false /root/apis/openapi.yaml | ||
ports: | ||
- 9003:4010 | ||
volumes: | ||
- ./yaml/openapi:/root/apis |
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,4 @@ | ||
.bin/swagger/merge.sh && docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \ | ||
-i /local/output.swagger.json \ | ||
-g openapi-yaml \ | ||
-o /local/.bin/mock/yaml && cd .bin/mock && docker-compose up |
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,9 @@ | ||
schemaspy.t=pgsql | ||
schemaspy.host=localhost | ||
schemaspy.port=5432 | ||
schemaspy.db=test | ||
schemaspy.u=test | ||
schemaspy.p=test | ||
schemaspy.schemas=postgis | ||
schemaspy.o=./output | ||
schemaspy.dp=./ |
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 @@ | ||
version=3.5.9 | ||
runner.dialect=scala213 | ||
maxColumn = 120 | ||
docstrings.style = Asterisk | ||
lineEndings = preserve | ||
includeCurlyBraceInSelectChains = false | ||
newlines.alwaysBeforeMultilineDef = false | ||
newlines.penalizeSingleSelectMultiArgList = false | ||
align.openParenCallSite = false | ||
rewrite.rules = [SortImports, RedundantBraces, RedundantParens, PreferCurlyFors] | ||
rewrite.redundantBraces.generalExpressions = false | ||
optIn.annotationNewlines = true |
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,22 @@ | ||
import sbtassembly.MergeStrategy | ||
|
||
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/" | ||
|
||
lazy val root = (project in file(".")) | ||
.settings( | ||
name := "Setup", | ||
version := "0.0.1", | ||
scalaVersion := "2.13.8", | ||
libraryDependencies ++= Seq( | ||
"org.typelevel" %% "cats-core" % "2.8.0", | ||
"com.typesafe.play" %% "play-json" % "2.9.2", | ||
"org.rogach" %% "scallop" % "4.1.0" | ||
), | ||
assembly / assemblyMergeStrategy := { | ||
case "module-info.class" => MergeStrategy.discard | ||
case x => | ||
// For all the other files, use the default sbt-assembly merge strategy | ||
val oldStrategy = (assembly / assemblyMergeStrategy).value | ||
oldStrategy(x) | ||
} | ||
) |
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 @@ | ||
sbt.version=1.6.2 |
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 @@ | ||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.0.0-RC1") |
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 @@ | ||
#!/usr/bin/env bash | ||
|
||
PATH_TO_SETUP_JAR=$(dirname "$0")"/target/scala-2.13/Setup-assembly-0.0.1.jar" | ||
|
||
if [ ! -f "$PATH_TO_SETUP_JAR" ]; then | ||
echo "$PATH_TO_SETUP_JAR does not exist." | ||
echo "Creating..." | ||
(cd $(dirname "$0"); sbt assembly) | ||
: | ||
|
||
fi | ||
exec scala "$PATH_TO_SETUP_JAR" "$@" |
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,9 @@ | ||
{ | ||
"project": { | ||
"name": "bootstrap-play2", | ||
"domain": "de.innfactory.bootstrapplay2" | ||
}, | ||
"bootstrap": { | ||
"paths": ["conf", "test", ".github"] | ||
} | ||
} |
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,55 @@ | ||
import packagedomain.PackageDomain | ||
import arguments.Args | ||
import bootstrap.Bootstrap | ||
import cats.data.Validated | ||
import config.SetupConfig | ||
import config.SetupConfig.{BootstrapConfig, ProjectConfig, SmithyConfig} | ||
|
||
import java.nio.file.{Files, Paths} | ||
|
||
object Setup extends App { | ||
|
||
implicit val config: SetupConfig = SetupConfig.get() | ||
val arguments = new Args(args) | ||
|
||
workingDirectoryIsProjectRoot() match { | ||
case Left(_) => | ||
println( | ||
s"Execute this script from your project root! Your project root must contain the directories ${config.project.sourcesRoot} and ${config.smithy.sourcesRoot}" | ||
) | ||
case Right(_) => | ||
if (args.isEmpty) { | ||
arguments.printHelp() | ||
} | ||
if (args.contains(Args.packageDomainKey)) { | ||
PackageDomain.create( | ||
arguments.packageDomain.packageName.toOption, | ||
arguments.packageDomain.domain.toOption, | ||
arguments.packageDomain.withCrud.toOption | ||
) | ||
} | ||
if (args.contains(Args.bootstrapKey)) { | ||
Bootstrap.init( | ||
SetupConfig( | ||
project = ProjectConfig( | ||
domain = arguments.bootstrap.projectDomain.toOption.getOrElse(""), | ||
name = arguments.bootstrap.projectName.toOption.getOrElse("") | ||
), | ||
bootstrap = BootstrapConfig( | ||
paths = arguments.bootstrap.bootstrapPaths.toOption.getOrElse(Seq.empty) | ||
) | ||
) | ||
) | ||
} | ||
} | ||
|
||
def workingDirectoryIsProjectRoot()(implicit config: SetupConfig) = | ||
Validated | ||
.cond( | ||
Files.exists(Paths.get(System.getProperty("user.dir") + "/" + config.project.sourcesRoot.replace('.', '/'))) && | ||
Files.exists(Paths.get(System.getProperty("user.dir") + "/" + config.smithy.sourcesRoot.replace('.', '/'))), | ||
(), | ||
() | ||
) | ||
.toEither | ||
} |
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,52 @@ | ||
package arguments | ||
|
||
import arguments.booleanarg.BooleanArgValidations | ||
import arguments.stringarg.StringArgValidations | ||
import org.rogach.scallop.{ScallopConf, ScallopOption, Subcommand} | ||
|
||
class Args(arguments: Seq[String]) extends ScallopConf(arguments) { | ||
object packageDomain extends Subcommand(Args.packageDomainKey) { | ||
val packageName: ScallopOption[String] = opt[String]( | ||
descr = "Name of the package e.g. companies", | ||
validate = (input: String) => StringArgValidations.onlyLetters(input).isRight | ||
) | ||
val domain: ScallopOption[String] = opt[String]( | ||
descr = "Name of the domain e.g. company", | ||
validate = (input: String) => StringArgValidations.onlyLettersDot(input).isRight | ||
) | ||
val withCrud: ScallopOption[String] = | ||
opt[String]( | ||
name = "crud", | ||
short = 'c', | ||
descr = "(y/n) generates code for crud operations", | ||
validate = (booleanString: String) => BooleanArgValidations.isBooleanString(booleanString).isRight | ||
) | ||
} | ||
|
||
object bootstrap extends Subcommand(Args.bootstrapKey) { | ||
val projectName: ScallopOption[String] = | ||
opt[String]( | ||
descr = "Name of the project e.g. bootstrap-play2", | ||
validate = (input: String) => StringArgValidations.onlyLettersNumbersHyphen(input).isRight | ||
) | ||
val projectDomain: ScallopOption[String] = | ||
opt[String]( | ||
descr = "Folder name of the projects packages, e.g. de.innfactory.bootstrapplay2", | ||
validate = (input: String) => StringArgValidations.onlyLettersDot(input).isRight | ||
) | ||
val bootstrapPaths: ScallopOption[List[String]] = opt[List[String]]( | ||
descr = | ||
"Paths of files and directories which shall be included during the bootstrap process, sources roots and build.sbt are always included", | ||
validate = | ||
(inputs: List[String]) => inputs.forall(input => StringArgValidations.onlyLettersDotSlash(input).isRight) | ||
) | ||
} | ||
addSubcommand(packageDomain) | ||
addSubcommand(bootstrap) | ||
verify() | ||
} | ||
|
||
object Args { | ||
val packageDomainKey = "package" | ||
val bootstrapKey = "bootstrap" | ||
} |
18 changes: 18 additions & 0 deletions
18
.bin/setup/src/main/scala/arguments/booleanarg/BooleanArgRetriever.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,18 @@ | ||
package arguments.booleanarg | ||
|
||
import scala.annotation.tailrec | ||
import scala.io.StdIn.readLine | ||
|
||
object BooleanArgRetriever { | ||
@tailrec | ||
def askFor(message: String): Boolean = { | ||
println(s"$message (y/n)") | ||
val is = readLine().toLowerCase() | ||
BooleanArgValidations.isBooleanString(is) match { | ||
case Left(error) => | ||
println(error) | ||
askFor(message) | ||
case Right(boolean) => boolean | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
.bin/setup/src/main/scala/arguments/booleanarg/BooleanArgValidations.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,9 @@ | ||
package arguments.booleanarg | ||
|
||
object BooleanArgValidations { | ||
def isBooleanString(booleanString: String): Either[String, Boolean] = booleanString.toLowerCase match { | ||
case "y" | "yes" => Right(true) | ||
case "n" | "no" => Right(false) | ||
case _ => Left("Invalid! Valid: y | yes | n | no") | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
.bin/setup/src/main/scala/arguments/stringarg/StringArgRetriever.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,34 @@ | ||
package arguments.stringarg | ||
|
||
import scala.annotation.tailrec | ||
import scala.io.StdIn.readLine | ||
|
||
object StringArgRetriever { | ||
@tailrec | ||
def askFor( | ||
message: String, | ||
validations: Seq[String => Either[String, Unit]] = | ||
Seq(StringArgValidations.cantBeEmpty, StringArgValidations.onlyLetters) | ||
): String = { | ||
println(message) | ||
val arg = readLine().toLowerCase() | ||
validateInput(validations.map(validate => validate(arg))) match { | ||
case Left(validationErrors) => | ||
println(validationErrors) | ||
askFor(message, validations) | ||
case Right(_) => arg | ||
} | ||
} | ||
|
||
private def validateInput(validations: Seq[Either[String, Unit]]) = | ||
validations.fold(Right(())) { (result, validation) => | ||
validation match { | ||
case Left(validationError) => | ||
result match { | ||
case Left(resultError) => Left(s"$resultError\n$validationError") | ||
case Right(_) => Left(validationError) | ||
} | ||
case Right(_) => result | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
.bin/setup/src/main/scala/arguments/stringarg/StringArgValidations.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,42 @@ | ||
package arguments.stringarg | ||
|
||
import cats.data.Validated | ||
|
||
object StringArgValidations { | ||
val cantBeEmpty: String => Either[String, Unit] = (toValidate: String) => | ||
Validated.cond(toValidate.nonEmpty, (), "Can't be empty!").toEither | ||
val onlyLetters: String => Either[String, Unit] = (toValidate: String) => | ||
Validated.cond(toValidate.matches("^[a-zA-Z]*?$"), (), "Can only consist out of letters!").toEither | ||
val onlyLettersNumbersHyphen: String => Either[String, Unit] = (toValidate: String) => | ||
Validated | ||
.cond( | ||
toValidate.matches("^([a-zA-Z0-9]+(?:\\-?[a-zA-Z0-9]+))*?$"), | ||
(), | ||
"Can only consist out of letters and numbers separated by a single hyphen!" | ||
) | ||
.toEither | ||
val onlyLettersDot: String => Either[String, Unit] = (toValidate: String) => | ||
Validated | ||
.cond( | ||
toValidate.matches("^([a-zA-Z]+(?:\\.[a-zA-Z]+))*?$"), | ||
(), | ||
"Can only consist out of letters separated by a single dot!" | ||
) | ||
.toEither | ||
val onlyLettersDotHyphen: String => Either[String, Unit] = (toValidate: String) => | ||
Validated | ||
.cond( | ||
toValidate.matches("^([a-zA-Z]+(?:[\\.\\-]?[a-zA-Z]+))*?$"), | ||
(), | ||
"Can only consist out of letters separated by a single dot or hyphen!" | ||
) | ||
.toEither | ||
val onlyLettersDotSlash: String => Either[String, Unit] = (toValidate: String) => | ||
Validated | ||
.cond( | ||
toValidate.matches("^([a-zA-Z]+(?:[\\.\\/]?[a-zA-Z]+))*?$"), | ||
(), | ||
"Can only consist out of letters separated by a single dot or slash!" | ||
) | ||
.toEither | ||
} |
Oops, something went wrong.