WIP
parent
b7a77cc3f4
commit
347da0634e
|
@ -24,12 +24,12 @@ PlayKeys.externalizeResources := false
|
|||
scriptClasspath := Seq("*")
|
||||
// offline := true
|
||||
libraryDependencies ++= Seq(
|
||||
macwire, play.json, akka.actor, akka.slf4j, jodaForms, ws,
|
||||
macwire, play.json, jodaForms, ws,
|
||||
scalaz, chess, compression, scalalib, hasher,
|
||||
reactivemongo.driver, reactivemongo.bson, reactivemongo.native,
|
||||
maxmind, prismic, markdown, scalatags,
|
||||
kamon.core, kamon.influxdb, kamon.metrics,
|
||||
semver, scrimage, scaffeine, lettuce, epoll
|
||||
scrimage, scaffeine, lettuce, epoll
|
||||
)
|
||||
resourceDirectory in Assets := (sourceDirectory in Compile).value / "assets"
|
||||
unmanagedResourceDirectories in Assets ++= (if (scala.sys.env.get("SERVE_ASSETS").exists(_ == "1")) Seq(baseDirectory.value / "public") else Nil)
|
||||
|
@ -37,8 +37,6 @@ unmanagedResourceDirectories in Assets ++= (if (scala.sys.env.get("SERVE_ASSETS"
|
|||
scalariformPreferences := scalariformPrefs(scalariformPreferences.value)
|
||||
excludeFilter in scalariformFormat := "*Routes*"
|
||||
|
||||
Global / onChangedBuildSource := ReloadOnSourceChanges
|
||||
|
||||
lazy val modules = Seq(
|
||||
common, db, rating, user, security, hub, socket,
|
||||
message, notifyModule, i18n, game, bookmark, search,
|
||||
|
@ -234,7 +232,7 @@ lazy val simul = module("simul", Seq(
|
|||
)
|
||||
|
||||
lazy val fishnet = module("fishnet", Seq(common, game, analyse, db, evalCache)).settings(
|
||||
libraryDependencies ++= provided(play.api, semver, lettuce) ++ reactivemongo.bundle
|
||||
libraryDependencies ++= provided(play.api, lettuce) ++ reactivemongo.bundle
|
||||
)
|
||||
|
||||
lazy val irwin = module("irwin", Seq(common, db, user, game, tournament, mod)).settings(
|
||||
|
|
|
@ -2,14 +2,14 @@ package lila.db
|
|||
|
||||
import org.joda.time.DateTime
|
||||
import ornicar.scalalib.Zero
|
||||
import reactivemongo.bson._
|
||||
import reactivemongo.api.bson._
|
||||
|
||||
import dsl._
|
||||
import lila.common.Iso
|
||||
|
||||
abstract class BSON[T]
|
||||
extends BSONReadOnly[T]
|
||||
with BSONHandler[Bdoc, T]
|
||||
with BSONHandler[T]
|
||||
with BSONDocumentReader[T]
|
||||
with BSONDocumentWriter[T] {
|
||||
|
||||
|
@ -40,8 +40,8 @@ abstract class BSONReadOnly[T] extends BSONDocumentReader[T] {
|
|||
|
||||
object BSON extends Handlers {
|
||||
|
||||
def toDocHandler[A](implicit handler: BSONHandler[BSONDocument, A]): BSONDocumentHandler[A] =
|
||||
new BSONDocumentReader[A] with BSONDocumentWriter[A] with BSONHandler[BSONDocument, A] {
|
||||
def toDocHandler[A](implicit handler: BSONHandler[A]): BSONDocumentHandler[A] =
|
||||
new BSONDocumentReader[A] with BSONDocumentWriter[A] with BSONHandler[A] {
|
||||
def read(doc: BSONDocument) = handler read doc
|
||||
def write(o: A) = handler write o
|
||||
}
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package lila.db
|
||||
|
||||
import scala.collection.breakOut
|
||||
import scala.collection.generic.CanBuildFrom
|
||||
import scala.util.{ Success, Failure }
|
||||
|
||||
import reactivemongo.api._
|
||||
import reactivemongo.api.collections.bson.BSONBatchCommands._
|
||||
import reactivemongo.api.commands.GetLastError
|
||||
import reactivemongo.bson._
|
||||
import reactivemongo.api.bson._
|
||||
import reactivemongo.core.protocol.MongoWireVersion
|
||||
|
||||
trait CollExt { self: dsl with QueryBuilderExt =>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package lila.db
|
||||
|
||||
import scala.collection.breakOut
|
||||
import org.joda.time.DateTime
|
||||
import reactivemongo.bson._
|
||||
import scalaz.NonEmptyList
|
||||
|
|
|
@ -19,11 +19,11 @@ package lila.db
|
|||
import ornicar.scalalib.Zero
|
||||
import reactivemongo.api._
|
||||
import reactivemongo.api.collections.GenericQueryBuilder
|
||||
import reactivemongo.bson._
|
||||
import reactivemongo.api.bson._
|
||||
|
||||
trait dsl extends LowPriorityDsl {
|
||||
trait dsl {
|
||||
|
||||
type Coll = reactivemongo.api.collections.bson.BSONCollection
|
||||
type Coll = reactivemongo.api.bson.collection.BSONCollection
|
||||
type Bdoc = BSONDocument
|
||||
type Barr = BSONArray
|
||||
|
||||
|
@ -377,16 +377,16 @@ trait dsl extends LowPriorityDsl {
|
|||
with LogicalOperators
|
||||
with ArrayOperators
|
||||
|
||||
implicit def toBSONDocument[V <: BSONValue](expression: Expression[V])(implicit writer: BSONWriter[V, _ <: BSONValue]): BSONDocument =
|
||||
$doc(expression.field -> expression.value)
|
||||
// implicit def toBSONDocument(expression: Expression[V])(implicit writer: BSONWriter[V): BSONDocument =
|
||||
// $doc(expression.field -> expression.value)
|
||||
|
||||
}
|
||||
|
||||
sealed trait LowPriorityDsl { self: dsl =>
|
||||
// Priority lower than toBSONDocument
|
||||
implicit def toBSONElement[V <: BSONValue](expression: Expression[V])(implicit writer: BSONWriter[V, _ <: BSONValue]): Producer[BSONElement] = {
|
||||
BSONElement(expression.field, expression.value)
|
||||
}
|
||||
}
|
||||
// sealed trait LowPriorityDsl { self: dsl =>
|
||||
// // Priority lower than toBSONDocument
|
||||
// implicit def toBSONElement[V <: BSONValue](expression: Expression[V])(implicit writer: BSONWriter[V, _ <: BSONValue]): Producer[BSONElement] = {
|
||||
// BSONElement(expression.field, expression.value)
|
||||
// }
|
||||
// }
|
||||
|
||||
object dsl extends dsl with CollExt with QueryBuilderExt with CursorExt with Handlers
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
// credit: https://github.com/saksdirect/gfc-semver/blob/master/src/main/scala/com/gilt/gfc/semver/SemVer.scala
|
||||
package com.gilt.gfc.semver
|
||||
|
||||
object SemVer {
|
||||
def apply(version: String): SemVer = {
|
||||
val bits = version.split("[\\.\\-]")
|
||||
val (nums, extras) = bits.take(3).foldLeft((Nil: List[Long], Nil: List[String])) {
|
||||
case ((num, extra), bit) =>
|
||||
import scala.util.control.Exception._
|
||||
allCatch opt bit.toLong match {
|
||||
case Some(long) => (long :: num, extra)
|
||||
case None => (num, bit :: extra)
|
||||
}
|
||||
}
|
||||
nums.reverse match {
|
||||
case x :: y :: z :: Nil => SemVer(x, y, z, {
|
||||
val e = extras.reverse ::: bits.drop(3).toList
|
||||
if (e.isEmpty) None else Some(e.mkString("-"))
|
||||
}, version)
|
||||
case x :: y :: Nil => SemVer(x, y, 0, {
|
||||
val e = extras.reverse ::: bits.drop(2).toList
|
||||
if (e.isEmpty) None else Some(e.mkString("-"))
|
||||
}, version)
|
||||
case x :: Nil => SemVer(x, 0, 0, {
|
||||
val e = extras.reverse ::: bits.drop(1).toList
|
||||
if (e.isEmpty) None else Some(e.mkString("-"))
|
||||
}, version)
|
||||
case _ =>
|
||||
sys.error("Cannot parse version: [%s]".format(version))
|
||||
}
|
||||
}
|
||||
|
||||
val Snapshot = "-SNAPSHOT"
|
||||
def isSnapshotVersion(v: String): Boolean = v.trim.endsWith(Snapshot)
|
||||
|
||||
def isIntegrationVersion(v: String): Boolean = {
|
||||
val Rx = """(\d+).(\d+).(\d+).(\d{14})""".r
|
||||
v match {
|
||||
case Rx(_, _, _, _) => true
|
||||
case _ => false
|
||||
}
|
||||
}
|
||||
|
||||
def isReleaseVersion(v: String): Boolean = !isSnapshotVersion(v) && !isIntegrationVersion(v)
|
||||
}
|
||||
|
||||
case class SemVer(major: Long, minor: Long, point: Long, extra: Option[String], original: String) extends Ordered[SemVer] {
|
||||
|
||||
override def equals(obj: Any): Boolean = {
|
||||
obj match {
|
||||
case version: SemVer => this.compareTo(version) == 0
|
||||
case _ => false
|
||||
}
|
||||
}
|
||||
|
||||
def compare(o: SemVer): Int = {
|
||||
if (major != o.major) major.compare(o.major)
|
||||
else if (minor != o.minor) minor.compare(o.minor)
|
||||
else if (point != o.point) point.compare(o.point)
|
||||
else {
|
||||
import scala.util.control.Exception._
|
||||
val thsNumPrefix: Option[Long] = allCatch opt extra.get.takeWhile(_.isDigit).toLong
|
||||
val thtNumPrefix: Option[Long] = allCatch opt o.extra.get.takeWhile(_.isDigit).toLong
|
||||
(extra, thsNumPrefix, o.extra, thtNumPrefix) match {
|
||||
case (Some(ths), _, Some(tht), _) if ths == "SNAPSHOT" || tht == "SNAPSHOT" => 0 // At least one SNAPSHOT: Can't decide
|
||||
case (Some(_), Some(thsNum), Some(_), Some(thtNum)) if thsNum < thtNum => -1 // Number prefixes compared
|
||||
case (Some(_), Some(thsNum), Some(_), Some(thtNum)) if thsNum > thtNum => 1 // Number prefixes compared
|
||||
case (Some(ths), Some(_), Some(tht), Some(_)) => ths.compareTo(tht) // Number prefixes same: Compare lexicographically
|
||||
case (Some(_), Some(_), Some(_), None) => 0 // One starts with number the other doesn't: Can't decide
|
||||
case (Some(_), None, Some(_), Some(_)) => 0 // One starts with number the other doesn't: Can't decide
|
||||
case (Some(ths), None, Some(tht), None) => ths.compareTo(tht) // No number prefixes: Compare lexicographically
|
||||
case (Some(_), _, None, _) => -1 // One has extra, the other doesn't
|
||||
case (None, _, Some(_), _) => 1 // One has extra, the other doesn't
|
||||
case _ => 0 // Both have no extra: They are the same
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def isSnapshotVersion = SemVer.isSnapshotVersion(this.original)
|
||||
def isIntegrationVersion = SemVer.isIntegrationVersion(this.original)
|
||||
def isReleaseVersion = SemVer.isReleaseVersion(this.original)
|
||||
}
|
|
@ -5,12 +5,11 @@ object Dependencies {
|
|||
|
||||
object Resolvers {
|
||||
|
||||
// val typesafe = "typesafe.com" at "http://repo.typesafe.com/typesafe/releases/"
|
||||
val sonatype = "sonatype" at "https://oss.sonatype.org/content/repositories/releases"
|
||||
// val typesafe = Resolver.typesafeRepo("releases")
|
||||
val sonatype = Resolver.sonatypeRepo("releases")
|
||||
// val sonatypeS = "sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
|
||||
// val awesomepom = "awesomepom" at "https://raw.githubusercontent.com/jibs/maven-repo-scala/master"
|
||||
val lilaMaven = "lila-maven" at "https://raw.githubusercontent.com/ornicar/lila-maven/master"
|
||||
// val prismic = "Prismic.io kits" at "https://s3.amazonaws.com/prismic-maven-kits/repository/maven/"
|
||||
|
||||
val commons = Seq(
|
||||
// sonatypeS,
|
||||
|
@ -27,11 +26,10 @@ object Dependencies {
|
|||
// val findbugs = "com.google.code.findbugs" % "jsr305" % "3.0.1"
|
||||
val hasher = "com.roundeights" %% "hasher" % "1.2.1"
|
||||
val jodaTime = "joda-time" % "joda-time" % "2.10.5"
|
||||
val chess = "org.lichess" %% "scalachess" % "9.0.26"
|
||||
val chess = "org.lichess" %% "scalachess" % "9.0.27"
|
||||
val compression = "org.lichess" %% "compression" % "1.5"
|
||||
val maxmind = "com.sanoma.cda" %% "maxmind-geoip2-scala" % "1.3.1-THIB"
|
||||
val prismic = "io.prismic" %% "scala-kit" % "1.2.13-THIB211"
|
||||
val semver = "com.gilt" %% "gfc-semver" % "0.0.5"
|
||||
val prismic = "io.prismic" %% "scala-kit" % "1.2.13-THIB213"
|
||||
val scrimage = "com.sksamuel.scrimage" %% "scrimage-core" % "2.1.8-SNAPSHOT"
|
||||
val scaffeine = "com.github.blemale" %% "scaffeine" % "3.1.0" % "compile"
|
||||
val googleOAuth = "com.google.auth" % "google-auth-library-oauth2-http" % "0.18.0"
|
||||
|
@ -41,7 +39,7 @@ object Dependencies {
|
|||
val scalatags = "com.lihaoyi" %% "scalatags" % "0.7.0"
|
||||
val lettuce = "io.lettuce" % "lettuce-core" % "5.2.1.RELEASE"
|
||||
val epoll = "io.netty" % "netty-transport-native-epoll" % "4.1.43.Final" classifier "linux-x86_64"
|
||||
val markdown = "com.vladsch.flexmark" % "flexmark-all" % "0.59.58"
|
||||
val markdown = "com.vladsch.flexmark" % "flexmark-all" % "0.50.44"
|
||||
val macwire = "com.softwaremill.macwire" %% "macros" % "2.3.3" % "provided"
|
||||
val autoconfig = "io.methvin.play" %% "autoconfig-macros" % "0.3.0"
|
||||
|
||||
|
@ -54,17 +52,13 @@ object Dependencies {
|
|||
}
|
||||
|
||||
object play {
|
||||
val version = "2.8.0-RC1"
|
||||
val version = "2.8.0-RC2"
|
||||
val libVersion = "2.8.0"
|
||||
val api = "com.typesafe.play" %% "play" % version
|
||||
val json = "com.typesafe.play" %% "play-json" % version
|
||||
val joda = "com.typesafe.play" %% "play-json-joda" % version
|
||||
val json = "com.typesafe.play" %% "play-json" % libVersion
|
||||
val joda = "com.typesafe.play" %% "play-json-joda" % libVersion
|
||||
// val test = "com.typesafe.play" %% "play-test" % version
|
||||
}
|
||||
object akka {
|
||||
val version = "2.6.0"
|
||||
val actor = "com.typesafe.akka" %% "akka-actor" % version
|
||||
val slf4j = "com.typesafe.akka" %% "akka-slf4j" % version
|
||||
}
|
||||
object kamon {
|
||||
val core = "io.kamon" %% "kamon-core" % "2.0.1"
|
||||
val influxdb = "io.kamon" %% "kamon-influxdb" % "2.0.0"
|
||||
|
|
|
@ -1 +1 @@
|
|||
sbt.version=1.3.3
|
||||
sbt.version=1.3.4
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.0-RC1")
|
||||
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.0-RC2")
|
||||
|
||||
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")
|
||||
|
|
Loading…
Reference in New Issue