Skip to content

Commit

Permalink
Merge pull request #15 from UdashFramework/upgrade
Browse files Browse the repository at this point in the history
Upgrade to jQuery 3.2.1
  • Loading branch information
Starzu authored May 10, 2018
2 parents be4ab57 + f94ea9f commit 9cc0032
Show file tree
Hide file tree
Showing 39 changed files with 375 additions and 296 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ dist: trusty

jdk: oraclejdk8
scala:
- 2.11.11
- 2.12.2
- 2.11.12
- 2.12.6

before_script:
- "export DISPLAY=:99.0"
Expand All @@ -22,6 +22,6 @@ before_script:
- export PATH=$PWD/selenium-bin:$PATH

script:
- sbt ++$TRAVIS_SCALA_VERSION "set (jsEnv in Test := new org.scalajs.jsenv.selenium.SeleniumJSEnv(org.scalajs.jsenv.selenium.Chrome))" test
- sbt ++$TRAVIS_SCALA_VERSION publishLocal
- cd example && sbt ++$TRAVIS_SCALA_VERSION compile
- sbt ++$TRAVIS_SCALA_VERSION test
- sbt ++$TRAVIS_SCALA_VERSION +publishLocal
- cd example && sbt ++$TRAVIS_SCALA_VERSION compile fullOptJS
84 changes: 59 additions & 25 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,37 +1,71 @@
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.remote.DesiredCapabilities
import org.scalajs.jsenv.selenium.SeleniumJSEnv

name := "udash-jquery"

version := "1.1.1"
organization := "io.udash"
scalaVersion := "2.12.2"
crossScalaVersions := Seq("2.11.11", "2.12.2")
scalacOptions in ThisBuild ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-language:implicitConversions",
"-language:existentials",
"-language:dynamics",
"-Xfuture",
"-Xfatal-warnings",
CrossVersion.partialVersion(scalaVersion.value).collect {
// WORKAROUND https://github.com/scala/scala/pull/5402
case (2, 12) => "-Xlint:-unused,_"
}.getOrElse("-Xlint:_")
)
inThisBuild(Seq(
version := "1.2.0",
organization := "io.udash",
scalaVersion := "2.12.6",
crossScalaVersions := Seq("2.11.12", "2.12.6"),
scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-language:implicitConversions",
"-language:existentials",
"-language:dynamics",
"-language:postfixOps",
"-language:experimental.macros",
"-Xfuture",
"-Xfatal-warnings",
"-Xlint:_",
),
scalacOptions ++= {
if (CrossVersion.partialVersion((root / scalaVersion).value).contains((2, 12))) Seq(
"-Ywarn-unused:_,-explicits,-implicits",
"-Ybackend-parallelism", "4",
"-Ycache-plugin-class-loader:last-modified",
"-Ycache-macro-class-loader:last-modified"
) else Seq.empty
},
))

// Settings for JS tests run in browser
val browserCapabilities: DesiredCapabilities = {
// requires ChromeDriver: https://sites.google.com/a/chromium.org/chromedriver/
val capabilities = DesiredCapabilities.chrome()
capabilities.setCapability(ChromeOptions.CAPABILITY, {
val options = new ChromeOptions()
options.addArguments("--headless", "--disable-gpu")
options
})
capabilities
}

jsEnv in Test := new org.scalajs.jsenv.selenium.SeleniumJSEnv(org.scalajs.jsenv.selenium.Firefox())
val commonJSSettings = Seq(
Compile / emitSourceMaps := true,
Test / parallelExecution := false,
Test / scalaJSStage := FastOptStage,
Test / jsEnv := new SeleniumJSEnv(browserCapabilities),
scalacOptions += {
val localDir = (ThisBuild / baseDirectory).value.toURI.toString
val githubDir = "https://raw.githubusercontent.com/UdashFramework/scala-js-jquery"
s"-P:scalajs:mapSourceURI:$localDir->$githubDir/v${version.value}/"
},
scalacOptions += "-P:scalajs:sjsDefinedByDefault",
)

libraryDependencies ++= Seq(
"org.scala-js" %%% "scalajs-dom" % "0.9.2",
"org.scalatest" %%% "scalatest" % "3.0.3" % Test,
"com.lihaoyi" %%% "scalatags" % "0.6.5" % Test
"org.scala-js" %%% "scalajs-dom" % "0.9.5",
"org.scalatest" %%% "scalatest" % "3.0.5" % Test,
"com.lihaoyi" %%% "scalatags" % "0.6.7" % Test
)

jsDependencies +=
"org.webjars" % "jquery" % "3.2.1" / "3.2.1/jquery.js" minified "3.2.1/jquery.min.js"

requiresDOM in Test := true
"org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js"

lazy val root = project.in(file("."))
.enablePlugins(ScalaJSPlugin)
.settings(commonJSSettings)
4 changes: 4 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### How to use?

Run `sbt fastOptJS` or `sbt fullOptJS` to compile this demo. You can find all generated files
in the `generated` directory. Open `index.html` in your browser.
83 changes: 48 additions & 35 deletions example/build.sbt
Original file line number Diff line number Diff line change
@@ -1,48 +1,61 @@
import UdashBuild._
import Dependencies._

name := "jquery-demo"

version in ThisBuild := "1.1.0"
scalaVersion in ThisBuild := "2.12.2"
organization in ThisBuild := "io.udash"
crossPaths in ThisBuild := false
scalacOptions in ThisBuild ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-language:implicitConversions",
"-language:existentials",
"-language:dynamics",
"-Xfuture",
"-Xfatal-warnings"
)
inThisBuild(Seq(
version := "1.2.0",
organization := "io.udash",
scalaVersion := "2.12.6",
scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-language:implicitConversions",
"-language:existentials",
"-language:dynamics",
"-language:postfixOps",
"-Xfuture",
"-Xfatal-warnings",
"-Xlint:_",
),
scalacOptions ++= {
if (CrossVersion.partialVersion((`jquery-demo` / scalaVersion).value).contains((2, 12))) Seq(
"-Ywarn-unused:_,-explicits,-implicits",
"-Ybackend-parallelism", "4",
"-Ycache-plugin-class-loader:last-modified",
"-Ycache-macro-class-loader:last-modified"
) else Seq.empty
},
))

val generatedDir = file("generated")
val copyAssets = taskKey[Unit]("Copies all assets to the target directory.")
val `jquery-demo` = project.in(file(".")).enablePlugins(ScalaJSPlugin)
.settings(
libraryDependencies ++= deps.value,
libraryDependencies ++= Dependencies.deps.value,

/* move these files out of target/. */
crossTarget in (Compile, fullOptJS) := generatedDir,
crossTarget in (Compile, fastOptJS) := generatedDir,
crossTarget in (Compile, packageJSDependencies) := generatedDir,
crossTarget in (Compile, packageMinifiedJSDependencies) := generatedDir,
Compile / fullOptJS / crossTarget := generatedDir,
Compile / fastOptJS / crossTarget := generatedDir,
Compile / packageJSDependencies / crossTarget := generatedDir,
Compile / packageMinifiedJSDependencies / crossTarget := generatedDir,

compile := (compile in Compile).dependsOn(compileStatics).value,
compileStatics := {
compileStaticsForRelease.value
(crossTarget.value / StaticFilesDir).***.get
},
Compile / fastOptJS := (Compile / fastOptJS).dependsOn(copyAssets).value,
Compile / fullOptJS := (Compile / fullOptJS).dependsOn(copyAssets).value,

scalaJSUseMainModuleInitializer := true,

artifactPath in(Compile, fastOptJS) :=
(crossTarget in(Compile, fastOptJS)).value / StaticFilesDir / WebContent / "scripts" / "frontend-impl-fast.js",
artifactPath in(Compile, fullOptJS) :=
(crossTarget in(Compile, fullOptJS)).value / StaticFilesDir / WebContent / "scripts" / "frontend-impl.js",
artifactPath in(Compile, packageJSDependencies) :=
(crossTarget in(Compile, packageJSDependencies)).value / StaticFilesDir / WebContent / "scripts" / "frontend-deps-fast.js",
artifactPath in(Compile, packageMinifiedJSDependencies) :=
(crossTarget in(Compile, packageMinifiedJSDependencies)).value / StaticFilesDir / WebContent / "scripts" / "frontend-deps.js"
copyAssets := {
IO.copyFile(
sourceDirectory.value / "main/assets/index.html",
generatedDir / "index.html"
)
},

Compile / fastOptJS / artifactPath :=
(Compile / fastOptJS / crossTarget).value / "scripts" / "frontend-impl.js",
Compile / fullOptJS / artifactPath :=
(Compile / fullOptJS / crossTarget).value / "scripts" / "frontend-impl.js",
Compile / packageJSDependencies / artifactPath :=
(Compile / packageJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js",
Compile / packageMinifiedJSDependencies / artifactPath :=
(Compile / packageMinifiedJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js"
)
4 changes: 2 additions & 2 deletions example/project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
import sbt._

object Dependencies {
val udashCoreVersion = "0.5.0"
val udashJQueryVersion = "1.1.0"
val udashCoreVersion = "0.6.1"
val udashJQueryVersion = "1.2.0"

val deps = Def.setting(Seq[ModuleID](
"io.udash" %%% "udash-core-frontend" % udashCoreVersion,
Expand Down
36 changes: 0 additions & 36 deletions example/project/UdashBuild.scala

This file was deleted.

2 changes: 1 addition & 1 deletion example/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 0.13.15
sbt.version = 1.1.4
3 changes: 2 additions & 1 deletion example/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
logLevel := Level.Warn
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.18")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22")
14 changes: 0 additions & 14 deletions example/src/main/assets/index.dev.html

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

<script src="scripts/frontend-deps.js"></script>
<script src="scripts/frontend-impl.js"></script>

</head>
<body>
<div id="application"></div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.udash.demos.jquery

import io.udash._
import io.udash.utils.Bidirectional

class RoutingRegistryDef extends RoutingRegistry[RoutingState] {
def matchUrl(url: Url): RoutingState =
Expand All @@ -10,7 +9,7 @@ class RoutingRegistryDef extends RoutingRegistry[RoutingState] {
def matchState(state: RoutingState): Url =
Url(state2Url.apply(state))

private val (url2State, state2Url) = Bidirectional[String, RoutingState] {
private val (url2State, state2Url) = bidirectional {
case "" => IndexState
case "/add" => AddState
case "/addBack" => AddBackState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import io.udash._
import io.udash.demos.jquery.views.functions._
import io.udash.demos.jquery.views.{ErrorViewPresenter, IndexViewPresenter, RootViewPresenter}

class StatesToViewPresenterDef extends ViewPresenterRegistry[RoutingState] {
def matchStateToResolver(state: RoutingState): ViewPresenter[_ <: RoutingState] = state match {
class StatesToViewPresenterDef extends ViewFactoryRegistry[RoutingState] {
def matchStateToResolver(state: RoutingState): ViewFactory[_ <: RoutingState] = state match {
case RootState => RootViewPresenter
case IndexState => IndexViewPresenter
case AddState => AddViewPresenter
Expand Down
5 changes: 2 additions & 3 deletions example/src/main/scala/io/udash/demos/jquery/init.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ package io.udash.demos.jquery
import io.udash._
import io.udash.wrappers.jquery._
import org.scalajs.dom
import org.scalajs.dom.{Element, document}
import org.scalajs.dom.Element

import scala.scalajs.js.JSApp
import scala.scalajs.js.annotation.JSExport

object Context {
implicit val executionContext = scalajs.concurrent.JSExecutionContext.Implicits.queue
private val routingRegistry = new RoutingRegistryDef
private val viewPresenterRegistry = new StatesToViewPresenterDef

implicit val applicationInstance = new Application[RoutingState](routingRegistry, viewPresenterRegistry, RootState)
implicit val applicationInstance = new Application[RoutingState](routingRegistry, viewPresenterRegistry)
}

object Init {
Expand Down
Loading

0 comments on commit 9cc0032

Please sign in to comment.