Skip to content

Commit 9cc0032

Browse files
authored
Merge pull request #15 from UdashFramework/upgrade
Upgrade to jQuery 3.2.1
2 parents be4ab57 + f94ea9f commit 9cc0032

39 files changed

+375
-296
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ dist: trusty
33

44
jdk: oraclejdk8
55
scala:
6-
- 2.11.11
7-
- 2.12.2
6+
- 2.11.12
7+
- 2.12.6
88

99
before_script:
1010
- "export DISPLAY=:99.0"
@@ -22,6 +22,6 @@ before_script:
2222
- export PATH=$PWD/selenium-bin:$PATH
2323

2424
script:
25-
- sbt ++$TRAVIS_SCALA_VERSION "set (jsEnv in Test := new org.scalajs.jsenv.selenium.SeleniumJSEnv(org.scalajs.jsenv.selenium.Chrome))" test
26-
- sbt ++$TRAVIS_SCALA_VERSION publishLocal
27-
- cd example && sbt ++$TRAVIS_SCALA_VERSION compile
25+
- sbt ++$TRAVIS_SCALA_VERSION test
26+
- sbt ++$TRAVIS_SCALA_VERSION +publishLocal
27+
- cd example && sbt ++$TRAVIS_SCALA_VERSION compile fullOptJS

build.sbt

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,71 @@
1+
import org.openqa.selenium.chrome.ChromeOptions
2+
import org.openqa.selenium.remote.DesiredCapabilities
3+
import org.scalajs.jsenv.selenium.SeleniumJSEnv
14

25
name := "udash-jquery"
36

4-
version := "1.1.1"
5-
organization := "io.udash"
6-
scalaVersion := "2.12.2"
7-
crossScalaVersions := Seq("2.11.11", "2.12.2")
8-
scalacOptions in ThisBuild ++= Seq(
9-
"-feature",
10-
"-deprecation",
11-
"-unchecked",
12-
"-language:implicitConversions",
13-
"-language:existentials",
14-
"-language:dynamics",
15-
"-Xfuture",
16-
"-Xfatal-warnings",
17-
CrossVersion.partialVersion(scalaVersion.value).collect {
18-
// WORKAROUND https://github.com/scala/scala/pull/5402
19-
case (2, 12) => "-Xlint:-unused,_"
20-
}.getOrElse("-Xlint:_")
21-
)
7+
inThisBuild(Seq(
8+
version := "1.2.0",
9+
organization := "io.udash",
10+
scalaVersion := "2.12.6",
11+
crossScalaVersions := Seq("2.11.12", "2.12.6"),
12+
scalacOptions ++= Seq(
13+
"-feature",
14+
"-deprecation",
15+
"-unchecked",
16+
"-language:implicitConversions",
17+
"-language:existentials",
18+
"-language:dynamics",
19+
"-language:postfixOps",
20+
"-language:experimental.macros",
21+
"-Xfuture",
22+
"-Xfatal-warnings",
23+
"-Xlint:_",
24+
),
25+
scalacOptions ++= {
26+
if (CrossVersion.partialVersion((root / scalaVersion).value).contains((2, 12))) Seq(
27+
"-Ywarn-unused:_,-explicits,-implicits",
28+
"-Ybackend-parallelism", "4",
29+
"-Ycache-plugin-class-loader:last-modified",
30+
"-Ycache-macro-class-loader:last-modified"
31+
) else Seq.empty
32+
},
33+
))
34+
35+
// Settings for JS tests run in browser
36+
val browserCapabilities: DesiredCapabilities = {
37+
// requires ChromeDriver: https://sites.google.com/a/chromium.org/chromedriver/
38+
val capabilities = DesiredCapabilities.chrome()
39+
capabilities.setCapability(ChromeOptions.CAPABILITY, {
40+
val options = new ChromeOptions()
41+
options.addArguments("--headless", "--disable-gpu")
42+
options
43+
})
44+
capabilities
45+
}
2246

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

2560
libraryDependencies ++= Seq(
26-
"org.scala-js" %%% "scalajs-dom" % "0.9.2",
27-
"org.scalatest" %%% "scalatest" % "3.0.3" % Test,
28-
"com.lihaoyi" %%% "scalatags" % "0.6.5" % Test
61+
"org.scala-js" %%% "scalajs-dom" % "0.9.5",
62+
"org.scalatest" %%% "scalatest" % "3.0.5" % Test,
63+
"com.lihaoyi" %%% "scalatags" % "0.6.7" % Test
2964
)
3065

3166
jsDependencies +=
32-
"org.webjars" % "jquery" % "3.2.1" / "3.2.1/jquery.js" minified "3.2.1/jquery.min.js"
33-
34-
requiresDOM in Test := true
67+
"org.webjars" % "jquery" % "3.3.1" / "3.3.1/jquery.js" minified "3.3.1/jquery.min.js"
3568

3669
lazy val root = project.in(file("."))
3770
.enablePlugins(ScalaJSPlugin)
71+
.settings(commonJSSettings)

example/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### How to use?
2+
3+
Run `sbt fastOptJS` or `sbt fullOptJS` to compile this demo. You can find all generated files
4+
in the `generated` directory. Open `index.html` in your browser.

example/build.sbt

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,61 @@
1-
import UdashBuild._
2-
import Dependencies._
3-
41
name := "jquery-demo"
52

6-
version in ThisBuild := "1.1.0"
7-
scalaVersion in ThisBuild := "2.12.2"
8-
organization in ThisBuild := "io.udash"
9-
crossPaths in ThisBuild := false
10-
scalacOptions in ThisBuild ++= Seq(
11-
"-feature",
12-
"-deprecation",
13-
"-unchecked",
14-
"-language:implicitConversions",
15-
"-language:existentials",
16-
"-language:dynamics",
17-
"-Xfuture",
18-
"-Xfatal-warnings"
19-
)
3+
inThisBuild(Seq(
4+
version := "1.2.0",
5+
organization := "io.udash",
6+
scalaVersion := "2.12.6",
7+
scalacOptions ++= Seq(
8+
"-feature",
9+
"-deprecation",
10+
"-unchecked",
11+
"-language:implicitConversions",
12+
"-language:existentials",
13+
"-language:dynamics",
14+
"-language:postfixOps",
15+
"-Xfuture",
16+
"-Xfatal-warnings",
17+
"-Xlint:_",
18+
),
19+
scalacOptions ++= {
20+
if (CrossVersion.partialVersion((`jquery-demo` / scalaVersion).value).contains((2, 12))) Seq(
21+
"-Ywarn-unused:_,-explicits,-implicits",
22+
"-Ybackend-parallelism", "4",
23+
"-Ycache-plugin-class-loader:last-modified",
24+
"-Ycache-macro-class-loader:last-modified"
25+
) else Seq.empty
26+
},
27+
))
2028

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

2635
/* move these files out of target/. */
27-
crossTarget in (Compile, fullOptJS) := generatedDir,
28-
crossTarget in (Compile, fastOptJS) := generatedDir,
29-
crossTarget in (Compile, packageJSDependencies) := generatedDir,
30-
crossTarget in (Compile, packageMinifiedJSDependencies) := generatedDir,
36+
Compile / fullOptJS / crossTarget := generatedDir,
37+
Compile / fastOptJS / crossTarget := generatedDir,
38+
Compile / packageJSDependencies / crossTarget := generatedDir,
39+
Compile / packageMinifiedJSDependencies / crossTarget := generatedDir,
3140

32-
compile := (compile in Compile).dependsOn(compileStatics).value,
33-
compileStatics := {
34-
compileStaticsForRelease.value
35-
(crossTarget.value / StaticFilesDir).***.get
36-
},
41+
Compile / fastOptJS := (Compile / fastOptJS).dependsOn(copyAssets).value,
42+
Compile / fullOptJS := (Compile / fullOptJS).dependsOn(copyAssets).value,
3743

3844
scalaJSUseMainModuleInitializer := true,
3945

40-
artifactPath in(Compile, fastOptJS) :=
41-
(crossTarget in(Compile, fastOptJS)).value / StaticFilesDir / WebContent / "scripts" / "frontend-impl-fast.js",
42-
artifactPath in(Compile, fullOptJS) :=
43-
(crossTarget in(Compile, fullOptJS)).value / StaticFilesDir / WebContent / "scripts" / "frontend-impl.js",
44-
artifactPath in(Compile, packageJSDependencies) :=
45-
(crossTarget in(Compile, packageJSDependencies)).value / StaticFilesDir / WebContent / "scripts" / "frontend-deps-fast.js",
46-
artifactPath in(Compile, packageMinifiedJSDependencies) :=
47-
(crossTarget in(Compile, packageMinifiedJSDependencies)).value / StaticFilesDir / WebContent / "scripts" / "frontend-deps.js"
46+
copyAssets := {
47+
IO.copyFile(
48+
sourceDirectory.value / "main/assets/index.html",
49+
generatedDir / "index.html"
50+
)
51+
},
52+
53+
Compile / fastOptJS / artifactPath :=
54+
(Compile / fastOptJS / crossTarget).value / "scripts" / "frontend-impl.js",
55+
Compile / fullOptJS / artifactPath :=
56+
(Compile / fullOptJS / crossTarget).value / "scripts" / "frontend-impl.js",
57+
Compile / packageJSDependencies / artifactPath :=
58+
(Compile / packageJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js",
59+
Compile / packageMinifiedJSDependencies / artifactPath :=
60+
(Compile / packageMinifiedJSDependencies / crossTarget).value / "scripts" / "frontend-deps.js"
4861
)

example/project/Dependencies.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
22
import sbt._
33

44
object Dependencies {
5-
val udashCoreVersion = "0.5.0"
6-
val udashJQueryVersion = "1.1.0"
5+
val udashCoreVersion = "0.6.1"
6+
val udashJQueryVersion = "1.2.0"
77

88
val deps = Def.setting(Seq[ModuleID](
99
"io.udash" %%% "udash-core-frontend" % udashCoreVersion,

example/project/UdashBuild.scala

Lines changed: 0 additions & 36 deletions
This file was deleted.

example/project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version = 0.13.15
1+
sbt.version = 1.1.4

example/project/plugins.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
logLevel := Level.Warn
2-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.18")
2+
3+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22")

example/src/main/assets/index.dev.html

Lines changed: 0 additions & 14 deletions
This file was deleted.

example/src/main/assets/index.prod.html renamed to example/src/main/assets/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
<script src="scripts/frontend-deps.js"></script>
88
<script src="scripts/frontend-impl.js"></script>
9-
109
</head>
1110
<body>
1211
<div id="application"></div>

example/src/main/scala/io/udash/demos/jquery/RoutingRegistryDef.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.udash.demos.jquery
22

33
import io.udash._
4-
import io.udash.utils.Bidirectional
54

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

13-
private val (url2State, state2Url) = Bidirectional[String, RoutingState] {
12+
private val (url2State, state2Url) = bidirectional {
1413
case "" => IndexState
1514
case "/add" => AddState
1615
case "/addBack" => AddBackState

example/src/main/scala/io/udash/demos/jquery/StatesToViewPresenterDef.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import io.udash._
44
import io.udash.demos.jquery.views.functions._
55
import io.udash.demos.jquery.views.{ErrorViewPresenter, IndexViewPresenter, RootViewPresenter}
66

7-
class StatesToViewPresenterDef extends ViewPresenterRegistry[RoutingState] {
8-
def matchStateToResolver(state: RoutingState): ViewPresenter[_ <: RoutingState] = state match {
7+
class StatesToViewPresenterDef extends ViewFactoryRegistry[RoutingState] {
8+
def matchStateToResolver(state: RoutingState): ViewFactory[_ <: RoutingState] = state match {
99
case RootState => RootViewPresenter
1010
case IndexState => IndexViewPresenter
1111
case AddState => AddViewPresenter

example/src/main/scala/io/udash/demos/jquery/init.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ package io.udash.demos.jquery
33
import io.udash._
44
import io.udash.wrappers.jquery._
55
import org.scalajs.dom
6-
import org.scalajs.dom.{Element, document}
6+
import org.scalajs.dom.Element
77

8-
import scala.scalajs.js.JSApp
98
import scala.scalajs.js.annotation.JSExport
109

1110
object Context {
1211
implicit val executionContext = scalajs.concurrent.JSExecutionContext.Implicits.queue
1312
private val routingRegistry = new RoutingRegistryDef
1413
private val viewPresenterRegistry = new StatesToViewPresenterDef
1514

16-
implicit val applicationInstance = new Application[RoutingState](routingRegistry, viewPresenterRegistry, RootState)
15+
implicit val applicationInstance = new Application[RoutingState](routingRegistry, viewPresenterRegistry)
1716
}
1817

1918
object Init {

0 commit comments

Comments
 (0)