Skip to content

Commit

Permalink
Removes compendium integration (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpedromoreno authored Sep 28, 2021
1 parent 2a6765b commit 6b6aa82
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 330 deletions.
19 changes: 8 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ lazy val core = project
.settings(moduleName := "mu-srcgen-core")
.settings(
libraryDependencies ++= Seq(
"io.higherkindness" %% "mu-rpc-service" % muV,
"io.higherkindness" %% "skeuomorph" % "0.0.29",
"com.github.julien-truffaut" %% "monocle-core" % "2.1.0",
"com.julianpeeters" %% "avrohugger-core" % "1.0.0-RC24",
"io.circe" %% "circe-generic" % "0.14.1",
"org.http4s" %% "http4s-blaze-client" % "0.21.29",
"org.http4s" %% "http4s-circe" % "0.21.29",
"org.scalatest" %% "scalatest" % "3.2.10" % Test,
"org.scalacheck" %% "scalacheck" % "1.15.4" % Test,
"org.scalatestplus" %% "scalacheck-1-14" % "3.2.2.0" % Test,
"org.slf4j" % "slf4j-nop" % "1.7.32" % Test
"io.higherkindness" %% "mu-rpc-service" % muV,
"io.higherkindness" %% "skeuomorph" % "0.0.29",
"com.github.julien-truffaut" %% "monocle-core" % "2.1.0",
"com.julianpeeters" %% "avrohugger-core" % "1.0.0-RC24",
"org.scalatest" %% "scalatest" % "3.2.10" % Test,
"org.scalacheck" %% "scalacheck" % "1.15.4" % Test,
"org.scalatestplus" %% "scalacheck-1-14" % "3.2.2.0" % Test,
"org.slf4j" % "slf4j-nop" % "1.7.32" % Test
)
)

Expand Down
6 changes: 0 additions & 6 deletions core/src/main/scala/higherkindness/mu/rpc/srcgen/Model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ package higherkindness.mu.rpc.srcgen

object Model {

sealed trait ExecutionMode extends Product with Serializable
object ExecutionMode {
case object Compendium extends ExecutionMode
case object Local extends ExecutionMode
}

sealed trait IdlType extends Product with Serializable
object IdlType {
case object Proto extends IdlType
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,12 @@ package higherkindness.mu.rpc.srcgen

import java.io.File

import cats.effect.{ContextShift, IO => IOCats}
import higherkindness.mu.rpc.srcgen.Model.ExecutionMode._
import sbt.Keys._
import sbt.{settingKey, Def, _}
import sbt.io.{Path, PathFinder}
import higherkindness.mu.rpc.srcgen.Model._
import higherkindness.mu.rpc.srcgen.compendium.{CompendiumMode, HttpConfig, ProtocolAndVersion}
import higherkindness.mu.rpc.srcgen.openapi.OpenApiSrcGenerator.HttpImpl

import scala.concurrent.ExecutionContext.global

object SrcGenPlugin extends AutoPlugin {

override def trigger: PluginTrigger = noTrigger
Expand Down Expand Up @@ -109,18 +104,6 @@ object SrcGenPlugin extends AutoPlugin {
"By default, the streaming implementation is FS2 Stream."
)

lazy val muSrcGenExecutionMode = settingKey[ExecutionMode](
"Execution mode of the plugin. If Compendium, it's required a compendium instance where IDL files are saved. `Local` by default."
)

lazy val muSrcGenCompendiumProtocolIdentifiers: SettingKey[Seq[ProtocolAndVersion]] =
settingKey[Seq[ProtocolAndVersion]](
"Protocol identifiers (and version) to be retrieved from compendium server. By default is an empty list."
)

lazy val muSrcGenCompendiumServerUrl: SettingKey[String] =
settingKey[String]("Url of the compendium server. By default, `http://localhost:8080`.")

lazy val muSrcGenAvroGeneratorType: SettingKey[AvroGeneratorTypeGen] =
settingKey[AvroGeneratorTypeGen](
"Specifies the Avro generation type: `SkeumorphGen` or `AvrohuggerGen`. `SkeumorphGen` by default."
Expand Down Expand Up @@ -159,14 +142,11 @@ object SrcGenPlugin extends AutoPlugin {
Nil
}
},
muSrcGenCompressionType := NoCompressionGen,
muSrcGenIdiomaticEndpoints := true,
muSrcGenOpenApiHttpImpl := HttpImpl.Http4sV20,
muSrcGenStreamingImplementation := Fs2Stream,
muSrcGenExecutionMode := Local,
muSrcGenCompendiumProtocolIdentifiers := Nil,
muSrcGenCompendiumServerUrl := "http://localhost:8080",
muSrcGenAvroGeneratorType := SkeumorphGen
muSrcGenCompressionType := NoCompressionGen,
muSrcGenIdiomaticEndpoints := true,
muSrcGenOpenApiHttpImpl := HttpImpl.Http4sV20,
muSrcGenStreamingImplementation := Fs2Stream,
muSrcGenAvroGeneratorType := SkeumorphGen
)

lazy val taskSettings: Seq[Def.Setting[_]] = {
Expand All @@ -184,30 +164,17 @@ object SrcGenPlugin extends AutoPlugin {
)
},
Def.task {
muSrcGenExecutionMode.value match {
case Compendium =>
implicit val cs: ContextShift[IOCats] = IOCats.contextShift(global)
CompendiumMode[IOCats](
muSrcGenCompendiumProtocolIdentifiers.value.toList,
muSrcGenIdlExtension.value,
HttpConfig(
muSrcGenCompendiumServerUrl.value
),
muSrcGenIdlTargetDir.value.getAbsolutePath
).run()
.unsafeRunSync()
case Local =>
muSrcGenSourceDirs.value.toSet.foreach { f: File =>
IO.copyDirectory(
f,
muSrcGenIdlTargetDir.value,
CopyOptions(
overwrite = true,
preserveLastModified = true,
preserveExecutable = true
)
)
}

muSrcGenSourceDirs.value.toSet.foreach { f: File =>
IO.copyDirectory(
f,
muSrcGenIdlTargetDir.value,
CopyOptions(
overwrite = true,
preserveLastModified = true,
preserveExecutable = true
)
)
}
},
Def.task {
Expand Down
Loading

0 comments on commit 6b6aa82

Please sign in to comment.