Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
kitlangton committed Jul 16, 2022
1 parent 6192d84 commit 36a0e68
Show file tree
Hide file tree
Showing 14 changed files with 477 additions and 451 deletions.
113 changes: 62 additions & 51 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import xerial.sbt.Sonatype.autoImport.sonatypeCredentialHost

lazy val scala213 = "2.13.8"
lazy val scala212 = "2.12.15"
lazy val scala3 = "3.1.0"

inThisBuild(
Expand All @@ -9,58 +10,63 @@ inThisBuild(
normalizedName := "zio-app",
organization := "io.github.kitlangton",
scalaVersion := scala213,
crossScalaVersions := Seq(scala213),
crossScalaVersions := Seq(scala213, scala212),
homepage := Some(url("https://github.com/kitlangton/zio-app")),
licenses := List("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")),
developers := List(
Developer(
"kitlangton",
"Kit Langton",
"[email protected]",
url("https://github.com/kitlangton")
)
url("https://github.com/kitlangton"),
),
),
sonatypeCredentialHost := "s01.oss.sonatype.org"
)
sonatypeCredentialHost := "s01.oss.sonatype.org",
),
)

lazy val supportedScalaVersions = List(scala213)

Global / onChangedBuildSource := ReloadOnSourceChanges

val animusVersion = "0.1.11"
val animusVersion = "0.2.1"
val boopickleVerison = "1.4.0"
val fansiVersion = "0.3.0"
val fansiVersion = "0.4.0"
val laminarVersion = "0.14.2"
val laminextVersion = "0.14.3"
val postgresVersion = "42.3.1"
val scalaJavaTimeVersion = "2.3.0"
val sttpVersion = "3.4.1"
val zioHttpVersion = "2.0.0-RC6+2-a50397fc-SNAPSHOT"
val zioJsonVersion = "0.3.0-RC7"
val zioNioVersion = "2.0.0-RC6"
val zioProcessVersion = "0.7.0-RC5"
val zioVersion = "2.0.0-RC5"
val zioQueryVersion = "0.2.10"
val quillVersion = "4.1.0"
val scalaJavaTimeVersion = "2.4.0"
val sttpVersion = "3.6.2+66-21235798-SNAPSHOT"
val zioHttpVersion = "1.0.0.0-RC29+29-a7d5340c-SNAPSHOT"
val zioJsonVersion = "0.3.0-RC3"
val zioNioVersion = "2.0.0"
val zioProcessVersion = "0.7.1"
val zioVersion = "2.0.0"
val zioQueryVersion = "0.3.0"

lazy val localZhttp = ProjectRef(file("/Users/kit/code/open-source/zio-http"), "zhttp")

val sharedSettings = Seq(
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.13.2" cross CrossVersion.full),
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"),
scalacOptions ++= Seq("-Xfatal-warnings"),
resolvers ++= Seq(
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
"Sonatype OSS Snapshots s01" at "https://s01.oss.sonatype.org/content/repositories/snapshots"
"Sonatype OSS Snapshots s01" at "https://s01.oss.sonatype.org/content/repositories/snapshots",
),
libraryDependencies ++= Seq(
"io.suzaku" %%% "boopickle" % boopickleVerison,
"dev.zio" %%% "zio" % zioVersion,
"dev.zio" %%% "zio-streams" % zioVersion,
"dev.zio" %%% "zio-test" % zioVersion % Test,
"com.lihaoyi" %%% "fansi" % fansiVersion
"com.lihaoyi" %%% "fansi" % fansiVersion,
),
scalacOptions ++= Seq("-Ymacro-annotations", "-Xfatal-warnings", "-deprecation"),
scalaVersion := scala213,
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"),
// semanticdbVersion := scalafixSemanticdb.revision, // only required for Scala 2.x,
scalacOptions += "-Yrangepos",
)

lazy val root = (project in file("."))
Expand All @@ -70,7 +76,7 @@ lazy val root = (project in file("."))
// crossScalaVersions must be set to Nil on the aggregating project
crossScalaVersions := Nil,
publish / skip := true,
welcomeMessage
welcomeMessage,
)

lazy val cli = (project in file("cli"))
Expand Down Expand Up @@ -105,24 +111,24 @@ lazy val cli = (project in file("cli"))
"--initialize-at-run-time=io.netty.util.AbstractReferenceCounted",
"--initialize-at-run-time=io.netty.channel.kqueue.KQueue",
"--initialize-at-build-time=org.slf4j.LoggerFactory",
"-H:IncludeResources='.*'"
"-H:IncludeResources='.*'",
),
libraryDependencies ++= Seq(
"dev.zio" %% "zio-process" % zioProcessVersion,
"dev.zio" %% "zio-parser" % "0.1.4",
"dev.zio" %% "zio-nio" % zioNioVersion,
"io.d11" %% "zhttp" % zioHttpVersion,
"org.jline" % "jline" % "3.20.0"
"dev.zio" %% "zio-process" % zioProcessVersion,
"dev.zio" %% "zio-nio" % zioNioVersion,
"dev.zio" %% "zio-parser" % "0.1.7",
// "io.d11" %% "zhttp" % zioHttpVersion,
"org.jline" % "jline" % "3.20.0",
),
resolvers ++= Seq(
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
"Sonatype OSS Snapshots s01" at "https://s01.oss.sonatype.org/content/repositories/snapshots"
"Sonatype OSS Snapshots s01" at "https://s01.oss.sonatype.org/content/repositories/snapshots",
),
Compile / mainClass := Some("zio.app.Main"),
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"),
)
.settings(sharedSettings)
.dependsOn(cliShared, coreJVM)
.dependsOn(cliShared, coreJVM, localZhttp)

lazy val cliFrontend = project
.in(file("cli-frontend"))
Expand All @@ -139,12 +145,12 @@ lazy val cliFrontend = project
libraryDependencies ++= Seq(
"io.github.kitlangton" %%% "animus" % animusVersion,
"com.raquo" %%% "laminar" % laminarVersion,
"io.github.cquiroz" %%% "scala-java-time" % "2.3.0",
"io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.3.0",
"io.github.cquiroz" %%% "scala-java-time" % "2.4.0",
"io.github.cquiroz" %%% "scala-java-time-tzdb" % "2.4.0",
"io.laminext" %%% "websocket" % laminextVersion,
"com.softwaremill.sttp.client3" %%% "core" % sttpVersion,
"com.softwaremill.sttp.client3" %%% "monix" % sttpVersion
)
"com.softwaremill.sttp.client3" %%% "monix" % sttpVersion,
),
)
.settings(sharedSettings)
.dependsOn(cliShared, coreJS)
Expand All @@ -160,32 +166,37 @@ lazy val cliShared = project
},
scalaJSLinkerConfig ~= {
_.withSourceMap(false)
}
},
)

lazy val core = crossProject(JSPlatform, JVMPlatform)
.in(file("core"))
.settings(sharedSettings)
.settings(
name := "zio-app",
ThisBuild / scalaVersion := scala213,
crossScalaVersions := supportedScalaVersions,
publish / skip := false,
semanticdbEnabled := true,
semanticdbVersion := "4.5.3", // only required for Scala 2.x,
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"),
resolvers ++= Seq(
"Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
"Sonatype OSS Snapshots s01" at "https://s01.oss.sonatype.org/content/repositories/snapshots"
"Sonatype OSS Snapshots s01" at "https://s01.oss.sonatype.org/content/repositories/snapshots",
),
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"dev.zio" %%% "zio" % zioVersion,
"dev.zio" %%% "zio-streams" % zioVersion,
"dev.zio" %% "zio-query" % zioQueryVersion,
"dev.zio" %% "zio-test" % zioVersion % Test,
"io.suzaku" %%% "boopickle" % boopickleVerison,
"io.d11" %% "zhttp" % zioHttpVersion,
"com.softwaremill.sttp.client3" %%% "core" % sttpVersion,
"org.postgresql" % "postgresql" % postgresVersion
)
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"dev.zio" %%% "zio" % zioVersion,
"dev.zio" %%% "zio-streams" % zioVersion,
"dev.zio" %% "zio-query" % zioQueryVersion,
"dev.zio" %% "zio-test" % zioVersion % Test,
"io.suzaku" %%% "boopickle" % boopickleVerison,
"io.d11" %% "zhttp" % zioHttpVersion,
"com.softwaremill.sttp.client3" %%% "core" % sttpVersion,
"io.getquill" %% "quill-jdbc-zio" % quillVersion,
"org.postgresql" % "postgresql" % postgresVersion,
"org.scalameta" %% "scalameta" % "4.5.9",
),
)

lazy val coreJS = core.js
Expand All @@ -200,14 +211,14 @@ lazy val examples = crossProject(JSPlatform, JVMPlatform)
libraryDependencies ++= Seq(
"dev.zio" %%% "zio" % zioVersion,
"dev.zio" %% "zio-test" % zioVersion % Test,
"io.d11" %% "zhttp" % zioHttpVersion
)
"io.d11" %% "zhttp" % zioHttpVersion,
),
)
.jvmSettings(
libraryDependencies ++= Seq(
"com.softwaremill.sttp.client3" %%% "core" % sttpVersion,
"com.softwaremill.sttp.client3" %% "httpclient-backend-zio" % sttpVersion
)
"com.softwaremill.sttp.client3" %%% "core" % sttpVersion,
"com.softwaremill.sttp.client3" %% "async-http-client-backend-zio" % sttpVersion,
),
)
.jsSettings(
scalaJSLinkerConfig ~= {
Expand All @@ -220,8 +231,8 @@ lazy val examples = crossProject(JSPlatform, JVMPlatform)
libraryDependencies ++= Seq(
"com.raquo" %%% "laminar" % laminarVersion,
"io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion,
"io.github.cquiroz" %%% "scala-java-time-tzdb" % scalaJavaTimeVersion
)
"io.github.cquiroz" %%% "scala-java-time-tzdb" % scalaJavaTimeVersion,
),
)
.dependsOn(core)

Expand Down
2 changes: 1 addition & 1 deletion cli-frontend/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.3
sbt.version=1.6.2
2 changes: 1 addition & 1 deletion cli/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.3
sbt.version=1.6.2
2 changes: 1 addition & 1 deletion cli/src/main/g8/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.5.5
sbt.version = 1.6.2
30 changes: 15 additions & 15 deletions cli/src/main/scala/database/ast/SqlSyntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ import zio.parser.internal.{PUnzippable, PZippable}
import zio.parser.{Regex, Syntax}

object SqlSyntax {
type StringSyntax[A] = Syntax[String, Char, Char, A, A]
type StringSyntax[A] = Syntax[String, Char, Char, A]

// # Utilities

/**
* - not whitespace
* - does not contain parens
*/
val ident: Syntax[String, Char, Char, String, String] =
val ident: Syntax[String, Char, Char, String] =
Syntax
.filterChar(c => !c.isWhitespace && c != '(' && c != ')' && c != ';' && c != ',', "expected valid ident")
.atLeast(0)
.transform(_.mkString, (str: String) => Chunk.fromIterable(str))

// currently used in DEFAULT method (e.g., DEFAULT now())
val method: Syntax[String, Char, Char, String, String] =
val method: Syntax[String, Char, Char, String] =
Syntax
.filterChar(c => !c.isWhitespace && c != ',', "expected anything whitespace or comma")
.atLeast(0)
Expand Down Expand Up @@ -64,7 +64,7 @@ object SqlSyntax {
def caseInsensitive[A](string: String, value: A): StringSyntax[A] =
Syntax.string(string.toUpperCase, value) | Syntax.string(string.toLowerCase, value)

private val int: Syntax[String, Char, Char, Int, Int] = Syntax.digit.repeat.string
private val int: Syntax[String, Char, Char, Int] = Syntax.digit.repeat.string
.transform(_.toInt, (_: Int).toString)

val varchar =
Expand Down Expand Up @@ -112,11 +112,11 @@ object SqlSyntax {

val ifNotExists: StringSyntax[Boolean] =
(spaces1 ~ caseInsensitive("if not exists")).optional
.transform[Boolean, Boolean](_.fold(false)(_ => true), if (_) Some(()) else None)
.transform[Boolean](_.fold(false)(_ => true), if (_) Some(()) else None)

val ifExists: StringSyntax[Boolean] =
(spaces1 ~ caseInsensitive("if exists")).optional
.transform[Boolean, Boolean](_.fold(false)(_ => true), if (_) Some(()) else None)
.transform[Boolean](_.fold(false)(_ => true), if (_) Some(()) else None)

val createTable: StringSyntax[CreateTable] =
(caseInsensitive("create table") ~ ifNotExists ~~ ident ~~ columns ~ Syntax.char(';')).transform(
Expand All @@ -137,7 +137,7 @@ object SqlSyntax {
// ALTER [ COLUMN ] column_name SET DEFAULT expression
val alterColumnDefaultAction =
(caseInsensitive("alter column") ~~ ident ~~ caseInsensitive("set default") ~~ method)
.transform[AlterTable.Action.SetColumnDefault, AlterTable.Action.SetColumnDefault](
.transform[AlterTable.Action.SetColumnDefault](
{ case (column, expression) => AlterTable.Action.SetColumnDefault(column, expression) },
{ case AlterTable.Action.SetColumnDefault(column, expression) => (column, expression) }
)
Expand All @@ -148,11 +148,11 @@ object SqlSyntax {
val dropColumnAction: StringSyntax[AlterTable.Action.DropColumn] = {
val cascade: StringSyntax[Boolean] =
(spaces1 ~ caseInsensitive("cascade")).optional
.transform[Boolean, Boolean](_.fold(false)(_ => true), if (_) Some(()) else None)
.transform[Boolean](_.fold(false)(_ => true), if (_) Some(()) else None)

val restrict: StringSyntax[Boolean] =
(spaces1 ~ caseInsensitive("restrict")).optional
.transform[Boolean, Boolean](_.fold(false)(_ => true), if (_) Some(()) else None)
.transform[Boolean](_.fold(false)(_ => true), if (_) Some(()) else None)

(caseInsensitive("drop column") ~ ifExists ~~ ident ~ cascade ~ restrict).transform(
{ case (ifExists, column, cascade, restrict) =>
Expand Down Expand Up @@ -211,18 +211,18 @@ object SqlSyntax {

// Syntax Extension Methods

implicit class SyntaxOps2[Value, Result](private val self: Syntax[String, Char, Char, Value, Result]) extends AnyVal {
implicit class SyntaxOps2[Result](private val self: Syntax[String, Char, Char, Result]) extends AnyVal {

/** Symbolic alias for zip */
final def ~~[Value2, Result2, ZippedValue, ZippedResult](
that: => Syntax[String, Char, Char, Value2, Result2]
final def ~~[Result2, ZippedValue, ZippedResult](
that: => Syntax[String, Char, Char, Result2]
)(implicit
unzippableValue: PUnzippable.In[Value, Value2, ZippedValue],
unzippableValue: PUnzippable.In[Result, Result2, ZippedResult],
zippableResult: PZippable.Out[Result, Result2, ZippedResult]
): Syntax[String, Char, Char, ZippedValue, ZippedResult] =
): Syntax[String, Char, Char, ZippedResult] =
self ~ (spaces1 ~ that)

def parens: Syntax[String, Char, Char, Value, Result] =
def parens: Syntax[String, Char, Char, Result] =
self
.surroundedBy(spaces)
.between(
Expand Down
Loading

0 comments on commit 36a0e68

Please sign in to comment.