Skip to content

Commit 371e847

Browse files
author
Starzu
committed
Demo upgrade
1 parent ab0e793 commit 371e847

30 files changed

+126
-187
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ before_script:
2424
script:
2525
- sbt ++$TRAVIS_SCALA_VERSION test
2626
- sbt ++$TRAVIS_SCALA_VERSION publishLocal
27-
- cd example && sbt ++$TRAVIS_SCALA_VERSION compile
27+
- cd example && sbt ++$TRAVIS_SCALA_VERSION compile fullOptJS

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

0 commit comments

Comments
 (0)