Skip to content

Commit

Permalink
WIP: Scala 3 port
Browse files Browse the repository at this point in the history
  • Loading branch information
davegurnell committed Oct 22, 2024
1 parent 79aafbf commit d667973
Show file tree
Hide file tree
Showing 57 changed files with 959 additions and 3,993 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version = "3.7.17"
runner.dialect=scala213
runner.dialect=scala3

style = defaultWithAlign

Expand Down
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Here's an example for Typescript:

~~~scala
import bridges.typescript._
import bridges.typescript.syntax._

Typescript.render(List(
decl[Color],
Expand Down Expand Up @@ -109,15 +108,14 @@ for defining structural types directly:
~~~scala
import bridges.typescript._
import bridges.typescript.TsType._
import bridges.typescript.syntax._

val logMessage: TsDecl =
decl("LogMessage")(struct(
"level" --> union(lit("error"), lit("warning")),
text --> Str
text --> Str
)

Typescript.render(logMessage)
Typescript.render(logMessage)
// res0: String =
// export interface LogMessage {
// level: "error" | "warning";
Expand All @@ -131,15 +129,14 @@ which is something the shapeless derivation currently can't handle:
~~~scala
import bridges.typescript._
import bridges.typescript.TsType._
import bridges.typescript.syntax._

val pair: TsDecl =
decl("Pair", "A", "B")(struct(
"head" --> Ref("A"),
"tail" --> Ref("B"),
)

Typescript.render(pair)
Typescript.render(pair)
// res0: String =
// export interface Pair<A, B> {
// head: A;
Expand Down
70 changes: 11 additions & 59 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,20 @@ enablePlugins(GitBranchPrompt)
organization := "com.davegurnell"
name := "bridges"

ThisBuild / scalaVersion := "3.5.0"

ThisBuild / crossScalaVersions := Seq("2.13.13", "3.5.0")

ThisBuild / scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) =>
Seq(
"-feature",
"-unchecked",
"-deprecation",
"-Xfatal-warnings",
"-Ypartial-unification"
)

case Some((2, _)) =>
Seq(
"-feature",
"-unchecked",
"-deprecation",
"-Xfatal-warnings",
)

case Some((3, _)) =>
Seq(
"-feature",
"-unchecked",
"-deprecation",
"-Xfatal-warnings",
"-old-syntax",
)

case _ =>
Seq(
"-feature",
"-unchecked",
"-deprecation",
"-rewrite",
"-new-syntax",
)
}
}
ThisBuild / scalaVersion := "3.5.0"

ThisBuild / libraryDependencies ++= Seq(
"com.davegurnell" %% "unindent" % "1.8.0",
"org.apache.commons" % "commons-text" % "1.9",
"org.scalatest" %% "scalatest" % "3.2.13" % Test,
"eu.timepit" %% "refined" % "0.10.1" % Provided,
ThisBuild / scalacOptions ++= Seq(
"-feature",
"-unchecked",
"-deprecation",
"-Xfatal-warnings",
)

ThisBuild / libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) =>
Seq(
"com.chuusai" %% "shapeless" % "2.3.10",
"eu.timepit" %% "refined-shapeless" % "0.10.1" % Provided
)

case _ =>
Seq.empty
}
}
ThisBuild / libraryDependencies ++= Seq(
"com.davegurnell" %% "unindent" % "1.8.0",
"org.apache.commons" % "commons-text" % "1.9",
"org.scalameta" %% "munit" % "1.0.1" % Test,
)

// Versioning -----------------------------------

Expand Down
62 changes: 0 additions & 62 deletions src/main/scala-2/bridges/core/DerivedEncoderInstances.scala

This file was deleted.

15 changes: 0 additions & 15 deletions src/main/scala-2/bridges/core/TypeName.scala

This file was deleted.

33 changes: 0 additions & 33 deletions src/main/scala-2/bridges/core/syntax.scala

This file was deleted.

66 changes: 0 additions & 66 deletions src/main/scala-2/bridges/flow/syntax.scala

This file was deleted.

66 changes: 0 additions & 66 deletions src/main/scala-2/bridges/typescript/syntax.scala

This file was deleted.

Loading

0 comments on commit d667973

Please sign in to comment.