Add scalafmt.conf and elm compile options

This commit is contained in:
Eike Kettner 2019-12-29 20:52:43 +01:00
parent a9e70401de
commit 546f1a6ee3
6 changed files with 53 additions and 11 deletions

15
.scalafmt.conf Normal file
View File

@ -0,0 +1,15 @@
version = "2.3.0"
align = most
#align.arrowEnumeratorGenerator = true
maxColumn = 100
rewrite.rules = [
AvoidInfix
RedundantBraces
RedundantParens
AsciiSortImports
PreferCurlyFors
SortModifiers
]

View File

@ -3,6 +3,8 @@ import scala.sys.process._
import com.typesafe.sbt.SbtGit.GitKeys._
import docspell.build._
val elmCompileMode = settingKey[ElmCompileMode]("How to compile elm sources")
val sharedSettings = Seq(
organization := "com.github.eikek",
scalaVersion := "2.13.1",
@ -31,12 +33,14 @@ val testSettings = Seq(
)
val elmSettings = Seq(
elmCompileMode := ElmCompileMode.Debug,
Compile/resourceGenerators += Def.task {
compileElm(streams.value.log
, (Compile/baseDirectory).value
, (Compile/resourceManaged).value
, name.value
, version.value)
, version.value
, elmCompileMode.value)
}.taskValue,
watchSources += Watched.WatchSource(
(Compile/sourceDirectory).value/"elm"
@ -381,10 +385,11 @@ def copyWebjarResources(src: Seq[File], base: File, artifact: String, version: S
}
}
def compileElm(logger: Logger, wd: File, outBase: File, artifact: String, version: String): Seq[File] = {
def compileElm(logger: Logger, wd: File, outBase: File, artifact: String, version: String, mode: ElmCompileMode): Seq[File] = {
logger.info("Compile elm files ...")
val target = outBase/"META-INF"/"resources"/"webjars"/artifact/version/"docspell-app.js"
val proc = Process(Seq("elm", "make", "--output", target.toString) ++ Seq(wd/"src"/"main"/"elm"/"Main.elm").map(_.toString), Some(wd))
val cmd = Seq("elm", "make") ++ mode.flags ++ Seq("--output", target.toString)
val proc = Process(cmd ++ Seq(wd/"src"/"main"/"elm"/"Main.elm").map(_.toString), Some(wd))
val out = proc.!!
logger.info(out)
Seq(target)

View File

@ -1,5 +1,8 @@
{
"excludedPaths": [
"modules/webapp/target/elm-src"
]
"modules/webapp/target/elm-src/"
],
"checks" : {
"ImportAll": false
}
}

1
elm-package.json Symbolic link
View File

@ -0,0 +1 @@
elm.json

View File

@ -0,0 +1,14 @@
trait ElmCompileMode {
def flags: Seq[String]
}
object ElmCompileMode {
case object Production extends ElmCompileMode {
val flags = Seq("--optimize")
}
case object Debug extends ElmCompileMode {
val flags = Seq("--debug")
}
case object Dev extends ElmCompileMode {
val flags = Seq.empty
}
}

View File

@ -1,7 +1,11 @@
addSbtPlugin("com.github.eikek" % "sbt-openapi-schema" % "0.5.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.5.2")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
addSbtPlugin("com.47deg" % "sbt-microsites" % "0.9.2")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
addSbtPlugin("com.github.eikek" % "sbt-openapi-schema" % "0.5.0")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.12")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.5.2")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.0.3")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8.1")