From f412df69e8f5f81a2b69ac74f9c583a86d3f610b Mon Sep 17 00:00:00 2001 From: Starzu Date: Fri, 16 Sep 2016 14:56:12 +0200 Subject: [PATCH 1/2] Upgrade to Udash 0.4 --- build.sbt | 2 +- .../udash/generator/GeneratorSettings.scala | 8 +-- .../plugins/core/CoreDemosPlugin.scala | 4 +- .../generator/plugins/core/CorePlugin.scala | 19 +++--- .../plugins/jetty/JettyLauncherPlugin.scala | 31 +++++++++- .../plugins/rpc/RPCDemosPlugin.scala | 4 +- .../plugins/sbt/SBTBootstrapPlugin.scala | 10 +-- .../plugins/sbt/SBTModulesPlugin.scala | 7 +-- .../scalacss/ScalaCSSDemosPlugin.scala | 61 ++++++++++++++++--- .../generator/plugins/utils/UtilPaths.scala | 3 + project/build.properties | 2 +- 11 files changed, 114 insertions(+), 37 deletions(-) diff --git a/build.sbt b/build.sbt index 5ed7b74..b28f743 100644 --- a/build.sbt +++ b/build.sbt @@ -9,7 +9,7 @@ lazy val generator = project.in(file(".")) .settings(publishArtifact := false) lazy val core = project.in(file("core")) - .settings(libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0-M15" % Test) + .settings(libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % Test) lazy val cmd = project.in(file("cmd")) .dependsOn(core) diff --git a/core/src/main/scala/io/udash/generator/GeneratorSettings.scala b/core/src/main/scala/io/udash/generator/GeneratorSettings.scala index de8cb6f..1d3f030 100644 --- a/core/src/main/scala/io/udash/generator/GeneratorSettings.scala +++ b/core/src/main/scala/io/udash/generator/GeneratorSettings.scala @@ -25,10 +25,10 @@ case class GeneratorSettings(rootDirectory: File, def stylesSubPackage: Seq[String] = Seq("styles") def scalaVersion: String = "2.11.8" - def sbtVersion: String = "0.13.11" - def scalaJSVersion: String = "0.6.11" - def scalaCSSVersion: String = "0.4.1" - def udashVersion: String = "0.3.1" + def sbtVersion: String = "0.13.12" + def scalaJSVersion: String = "0.6.12" + def scalaCSSVersion: String = "0.5.0" + def udashVersion: String = "0.4.0" def udashJQueryVersion: String = "1.0.0" def jettyVersion: String = "9.3.11.v20160721" def logbackVersion: String = "1.1.3" diff --git a/core/src/main/scala/io/udash/generator/plugins/core/CoreDemosPlugin.scala b/core/src/main/scala/io/udash/generator/plugins/core/CoreDemosPlugin.scala index 97d763e..3306e7f 100644 --- a/core/src/main/scala/io/udash/generator/plugins/core/CoreDemosPlugin.scala +++ b/core/src/main/scala/io/udash/generator/plugins/core/CoreDemosPlugin.scala @@ -87,9 +87,9 @@ object CoreDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Fronten | p("You typed: ", bind(model)), | h3("Read more"), | a$FrontendStylesLinkBlackPlaceholder(href := "${settings.udashDevGuide}#/frontend/bindings", target := "_blank")("Read more in Udash Guide.") - | ).render + | ) | - | override def getTemplate: Element = content + | override def getTemplate: Modifier = content | | override def renderChild(view: View): Unit = {} |} diff --git a/core/src/main/scala/io/udash/generator/plugins/core/CorePlugin.scala b/core/src/main/scala/io/udash/generator/plugins/core/CorePlugin.scala index 061bd12..175b77a 100644 --- a/core/src/main/scala/io/udash/generator/plugins/core/CorePlugin.scala +++ b/core/src/main/scala/io/udash/generator/plugins/core/CorePlugin.scala @@ -163,7 +163,7 @@ object CorePlugin extends GeneratorPlugin with SBTProjectFiles with FrontendPath | import ${settings.rootPackage.mkPackage()}.Context._ | import scalatags.JsDom.all._ | - | private var child: Element = div().render + | private val child: Element = div().render | | private val content = div( | $FrontendStyledHeaderPlaceholder @@ -173,15 +173,14 @@ object CorePlugin extends GeneratorPlugin with SBTProjectFiles with FrontendPath | child | ) | )$FrontendStyledFooterPlaceholder - | ).render + | ) | - | override def getTemplate: Element = content + | override def getTemplate: Modifier = content | | override def renderChild(view: View): Unit = { | import io.udash.wrappers.jquery._ - | val newChild = view.getTemplate - | jQ(child).replaceWith(newChild) - | child = newChild + | jQ(child).children().remove() + | view.getTemplate.applyTo(child) | } |} |""".stripMargin @@ -223,9 +222,9 @@ object CorePlugin extends GeneratorPlugin with SBTProjectFiles with FrontendPath | a(${FrontendStylesLinkBlackPlaceholder}href := "http://www.lihaoyi.com/scalatags/", target := "_blank")("Read more about ScalaTags") | ) | ) - | ).render + | ) | - | override def getTemplate: Element = content + | override def getTemplate: Modifier = content | | override def renderChild(view: View): Unit = {} |} @@ -246,9 +245,9 @@ object CorePlugin extends GeneratorPlugin with SBTProjectFiles with FrontendPath | | private val content = h3( | "URL not found!" - | ).render + | ) | - | override def getTemplate: Element = content + | override def getTemplate: Modifier = content | | override def renderChild(view: View): Unit = {} |} diff --git a/core/src/main/scala/io/udash/generator/plugins/jetty/JettyLauncherPlugin.scala b/core/src/main/scala/io/udash/generator/plugins/jetty/JettyLauncherPlugin.scala index b9866ed..1388e55 100644 --- a/core/src/main/scala/io/udash/generator/plugins/jetty/JettyLauncherPlugin.scala +++ b/core/src/main/scala/io/udash/generator/plugins/jetty/JettyLauncherPlugin.scala @@ -68,14 +68,17 @@ object JettyLauncherPlugin extends GeneratorPlugin with SBTProjectFiles with Fro } private def createJettyServer(rootPackage: File, settings: GeneratorSettings, backendModuleName: String): Unit = { + val resourcesDir = resources(settings.rootDirectory.subFile(backendModuleName)) + val logbackXml = resourcesDir.subFile("logback.xml") + val jettyDir = "jetty" val jettyPackage = rootPackage.subFile(jettyDir) val appServerScala = jettyPackage.subFile("ApplicationServer.scala") val launcherScala = rootPackage.subFile("Launcher.scala") requireFilesExist(Seq(rootPackage)) - createDirs(Seq(jettyPackage)) - createFiles(Seq(appServerScala, launcherScala)) + createDirs(Seq(jettyPackage, resourcesDir)) + createFiles(Seq(appServerScala, launcherScala, logbackXml)) writeFile(appServerScala)( s"""package ${settings.rootPackage.mkPackage()}.$jettyDir @@ -109,6 +112,30 @@ object JettyLauncherPlugin extends GeneratorPlugin with SBTProjectFiles with Fro """.stripMargin ) + writeFile(logbackXml)( + """ + | + | + | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + | + | + | + | + | + | + | logs/udash-guide-${bySecond}.log + | true + | + | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + | + | + | + | + | + | + | + |""".stripMargin) + writeFile(launcherScala)( s"""package ${settings.rootPackage.mkPackage()} | diff --git a/core/src/main/scala/io/udash/generator/plugins/rpc/RPCDemosPlugin.scala b/core/src/main/scala/io/udash/generator/plugins/rpc/RPCDemosPlugin.scala index 369e0b7..24e69f4 100644 --- a/core/src/main/scala/io/udash/generator/plugins/rpc/RPCDemosPlugin.scala +++ b/core/src/main/scala/io/udash/generator/plugins/rpc/RPCDemosPlugin.scala @@ -97,9 +97,9 @@ object RPCDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Frontend | p("Server response: ", bind(serverResponse)), | h3("Read more"), | a$FrontendStylesLinkBlackPlaceholder(href := "${settings.udashDevGuide}#/rpc", target := "_blank")("Read more in Udash Guide.") - | ).render + | ) | - | override def getTemplate: Element = content + | override def getTemplate: Modifier = content | | override def renderChild(view: View): Unit = {} |} diff --git a/core/src/main/scala/io/udash/generator/plugins/sbt/SBTBootstrapPlugin.scala b/core/src/main/scala/io/udash/generator/plugins/sbt/SBTBootstrapPlugin.scala index 2dc1fdf..5bfdd83 100644 --- a/core/src/main/scala/io/udash/generator/plugins/sbt/SBTBootstrapPlugin.scala +++ b/core/src/main/scala/io/udash/generator/plugins/sbt/SBTBootstrapPlugin.scala @@ -22,7 +22,9 @@ object SBTBootstrapPlugin extends GeneratorPlugin with SBTProjectFiles { val addJsWorkbenchPlugin = if (settings.shouldEnableJsWorkbench) s"""addSbtPlugin("com.lihaoyi" % "workbench" % "0.2.3")""" else "" writeFile(buildSbt(settings))( - s"""${importJsWorkbench} + s"""$importJsWorkbench + |import UdashBuild._ + |import Dependencies._ | |name := "${settings.projectName}" | @@ -52,7 +54,7 @@ object SBTBootstrapPlugin extends GeneratorPlugin with SBTProjectFiles { s"""logLevel := Level.Warn |addSbtPlugin("org.scala-js" % "sbt-scalajs" % "${settings.scalaJSVersion}") | - |${addJsWorkbenchPlugin} + |$addJsWorkbenchPlugin | |""".stripMargin) @@ -61,7 +63,7 @@ object SBTBootstrapPlugin extends GeneratorPlugin with SBTProjectFiles { |import sbt.Keys._ |import sbt._ | - |object UdashBuild extends Build {$UdashBuildPlaceholder} + |object UdashBuild {$UdashBuildPlaceholder} | |""".stripMargin) @@ -69,7 +71,7 @@ object SBTBootstrapPlugin extends GeneratorPlugin with SBTProjectFiles { s"""import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._ |import sbt._ | - |object Dependencies extends Build {$DependenciesPlaceholder} + |object Dependencies {$DependenciesPlaceholder} | |""".stripMargin) diff --git a/core/src/main/scala/io/udash/generator/plugins/sbt/SBTModulesPlugin.scala b/core/src/main/scala/io/udash/generator/plugins/sbt/SBTModulesPlugin.scala index 36dfc92..d93a2e7 100644 --- a/core/src/main/scala/io/udash/generator/plugins/sbt/SBTModulesPlugin.scala +++ b/core/src/main/scala/io/udash/generator/plugins/sbt/SBTModulesPlugin.scala @@ -88,7 +88,7 @@ object SBTModulesPlugin extends GeneratorPlugin with SBTProjectFiles with Fronte | compileStatics := { | IO.copyDirectory(sourceDirectory.value / "main/assets/fonts", crossTarget.value / StaticFilesDir / WebContent / "assets/fonts") | IO.copyDirectory(sourceDirectory.value / "main/assets/images", crossTarget.value / StaticFilesDir / WebContent / "assets/images") - | compileStaticsForRelease.value + | val statics = compileStaticsForRelease.value | (crossTarget.value / StaticFilesDir).***.get | }, | @@ -185,14 +185,13 @@ object SBTModulesPlugin extends GeneratorPlugin with SBTProjectFiles with Fronte | jsDependencies ++= $frontendJSDepsName.value, | persistLauncher in Compile := true, | - | compile <<= (compile in Compile), + | compile <<= (compile in Compile).dependsOn(compileStatics), | compileStatics := { | IO.copyDirectory(sourceDirectory.value / "main/assets/fonts", crossTarget.value / StaticFilesDir / WebContent / "assets/fonts") | IO.copyDirectory(sourceDirectory.value / "main/assets/images", crossTarget.value / StaticFilesDir / WebContent / "assets/images") - | compileStaticsForRelease.value + | val statics = compileStaticsForRelease.value | (crossTarget.value / StaticFilesDir).***.get | }, - | compileStatics <<= compileStatics.dependsOn(compile in Compile), | | artifactPath in(Compile, fastOptJS) := | (crossTarget in(Compile, fastOptJS)).value / StaticFilesDir / WebContent / "scripts" / "${settings.frontendImplFastJs}", diff --git a/core/src/main/scala/io/udash/generator/plugins/scalacss/ScalaCSSDemosPlugin.scala b/core/src/main/scala/io/udash/generator/plugins/scalacss/ScalaCSSDemosPlugin.scala index cf38aff..71624ae 100644 --- a/core/src/main/scala/io/udash/generator/plugins/scalacss/ScalaCSSDemosPlugin.scala +++ b/core/src/main/scala/io/udash/generator/plugins/scalacss/ScalaCSSDemosPlugin.scala @@ -230,9 +230,9 @@ object ScalaCSSDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Fro | a(DemoStyles.underlineLinkBlack)(href := "https://japgolly.github.io/scalacss/book/", target := "_blank")("Read more in ScalaCSS docs.") | ) | ) - | ).render + | ) | - | override def getTemplate: Element = content + | override def getTemplate: Modifier = content | | override def renderChild(view: View): Unit = {} | @@ -279,13 +279,60 @@ object ScalaCSSDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Fro |import ${settings.rootPackage.mkPackage()}.${settings.stylesSubPackage.mkPackage()}.${stylesUtilsPackage.getName}.{MediaQueries, StyleUtils} | |import scala.language.postfixOps - |import scalacss.Attr + |import scalacss.internal.{Attr, Literal} |import scalacss.Defaults._ | |object GlobalStyles extends StyleSheet.Inline { | import dsl._ | - | val reset = style(scalacss.ext.CssReset.meyer) + | val reset = style( + | unsafeRoot(\"\"\"html, body, div, span, applet, object, iframe, + | | h1, h2, h3, h4, h5, h6, p, blockquote, pre, + | | a, abbr, acronym, address, big, cite, code, + | | del, dfn, em, img, ins, kbd, q, s, samp, + | | small, strike, strong, sub, sup, tt, var, + | | b, u, i, center, + | | dl, dt, dd, ol, ul, li, + | | fieldset, form, label, legend, + | | table, caption, tbody, tfoot, thead, tr, th, td, + | | article, aside, canvas, details, embed, + | | figure, figcaption, footer, header, hgroup, + | | menu, nav, output, ruby, section, summary, + | | time, mark, audio, video\"\"\".stripMargin.replaceAll("\\\\s+", ""))( + | margin.`0`, + | padding.`0`, + | border.`0`, + | fontSize(100 %%), + | font := Literal.inherit, + | verticalAlign.baseline + | ), + | + | unsafeRoot("article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section")( + | display.block + | ), + | + | unsafeRoot("body")( + | lineHeight(1) + | ), + | + | unsafeRoot("ol,ul")( + | listStyle := none // TODO + | ), + | + | unsafeRoot ("blockquote, q")( + | quotes.none + | ), + | + | unsafeRoot("blockquote:before, blockquote:after, q:before, q:after")( + | content := "''", + | content := none + | ), + | + | unsafeRoot("table")( + | borderCollapse.collapse, + | borderSpacing.`0` + | ) + | ) | | val global = style( | unsafeRoot("#application") ( @@ -579,7 +626,7 @@ object ScalaCSSDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Fro | |import scala.concurrent.duration.FiniteDuration |import scala.language.postfixOps - |import scalacss.Compose + |import scalacss.internal.Compose |import scalacss.Defaults._ | |object DemoStyles extends StyleSheet.Inline { @@ -773,7 +820,7 @@ object ScalaCSSDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Fro writeFile(stylesFontsScala)( s"""package ${settings.rootPackage.mkPackage()}.${settings.stylesSubPackage.mkPackage()}.${stylesFontsPackage.getName} |import scala.language.postfixOps - |import scalacss.AV + |import scalacss.internal.AV |import scalacss.Defaults._ | |object UdashFonts extends StyleSheet.Inline { @@ -1131,7 +1178,7 @@ object ScalaCSSDemosPlugin extends GeneratorPlugin with SBTProjectFiles with Fro | |import scala.concurrent.duration.FiniteDuration |import scala.language.postfixOps - |import scalacss.{AV, Attr, Length, ValueT} + |import scalacss.internal.{AV, Attr, Length, ValueT} |import scalacss.Defaults._ | |object StyleUtils extends StyleSheet.Inline { diff --git a/core/src/main/scala/io/udash/generator/plugins/utils/UtilPaths.scala b/core/src/main/scala/io/udash/generator/plugins/utils/UtilPaths.scala index e751cc8..e0de553 100644 --- a/core/src/main/scala/io/udash/generator/plugins/utils/UtilPaths.scala +++ b/core/src/main/scala/io/udash/generator/plugins/utils/UtilPaths.scala @@ -6,6 +6,8 @@ import io.udash.generator.GeneratorSettings import io.udash.generator.utils._ trait UtilPaths { + def resources(module: File): File = + module.subFile(resourcesPathPart) def src(module: File): File = module.subFile(srcPathPart) def testSrc(module: File): File = @@ -15,6 +17,7 @@ trait UtilPaths { def rootPackageInTestSrc(module: File, settings: GeneratorSettings): File = module.subFile(Seq(testSrcPathPart, packagePathPart(settings)).mkString(File.separator)) + private val resourcesPathPart = Seq("src", "main", "resources").mkString(File.separator) private val srcPathPart = Seq("src", "main", "scala").mkString(File.separator) private val testSrcPathPart = Seq("src", "test", "scala").mkString(File.separator) private def packagePathPart(settings: GeneratorSettings) = settings.rootPackage.mkString(File.separator) diff --git a/project/build.properties b/project/build.properties index e6a3739..13d3ee7 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 0.13.11 \ No newline at end of file +sbt.version = 0.13.12 \ No newline at end of file From 2120292e85ab15b2781d7f94abe89f6550fd7146 Mon Sep 17 00:00:00 2001 From: Starzu Date: Fri, 16 Sep 2016 15:27:35 +0200 Subject: [PATCH 2/2] Removed `empty` test --- test/empty.cnf | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 test/empty.cnf diff --git a/test/empty.cnf b/test/empty.cnf deleted file mode 100644 index 9c81b4e..0000000 --- a/test/empty.cnf +++ /dev/null @@ -1,12 +0,0 @@ -test-app -true -empty-app -io.udash.app -io.udash.app -2 -backend -shared -frontend -false -true -true \ No newline at end of file