Skip to content

Commit 4a83d14

Browse files
committed
Bump versions, cleaner sttp backend call
1 parent 5816ed6 commit 4a83d14

File tree

3 files changed

+231
-206
lines changed

3 files changed

+231
-206
lines changed

build.sc

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,18 @@ import io.github.davidgregory084.TpolecatModule
1212

1313
object libVersion {
1414
val scala = "3.2.0"
15-
val scalajs = "1.10.1"
15+
val scalajs = "1.11.0"
1616
val zio = "2.0.2"
1717
val zhttp = "2.0.0-RC11"
18-
val sttp = "3.8.0"
18+
val sttp = "3.8.2"
1919
val organizeimports = "0.6.0"
2020
val scalajsdom = "2.3.0"
21-
val scalatest = "3.2.13"
21+
val scalatest = "3.2.14"
2222
}
2323

2424
trait Common extends ScalaModule with TpolecatModule with ScalafmtModule with ScalafixModule {
2525
override def scalaVersion = libVersion.scala
2626
def scalafixIvyDeps = Agg(ivy"com.github.liancheng::organize-imports:${libVersion.organizeimports}")
27-
// Add repositories for snapshot builds
2827
def repositoriesTask = T.task { // Add snapshot repositories in case needed
2928
super.repositoriesTask() ++ Seq("oss", "s01.oss")
3029
.map(r => s"https://$r.sonatype.org/content/repositories/snapshots")
@@ -36,27 +35,11 @@ trait Common extends ScalaModule with TpolecatModule with ScalafmtModule with Sc
3635
)
3736
}
3837

39-
// -----------------------------------------------------------------------------
40-
// Global commands
41-
// -----------------------------------------------------------------------------
42-
43-
def lint(ev: eval.Evaluator) = T.command {
44-
mill.main.MainModule.evaluateTasks(
45-
ev,
46-
Seq("__.fix", "+", "mill.scalalib.scalafmt.ScalafmtModule/reformatAll", "__.sources"),
47-
mill.define.SelectMode.Separated,
48-
)(identity)
49-
}
50-
51-
def deps(ev: eval.Evaluator) = T.command {
52-
mill.scalalib.Dependency.showUpdates(ev)
53-
}
54-
5538
// -----------------------------------------------------------------------------
5639
// Projects
5740
// -----------------------------------------------------------------------------
5841

59-
object shared extends Common
42+
// object shared extends Common
6043

6144
object backend extends Common with DockerModule {
6245
// Runtime dependencies
@@ -90,6 +73,7 @@ object frontend extends ScalaJSModule with Common {
9073
def moduleKind = T(ModuleKind.ESModule)
9174
def moduleSplitStyle = T(ModuleSplitStyle.SmallModulesFor(List("com.carlosedp.zioscalajs.frontend")))
9275

76+
// These two tasks are used by Vite to get update path
9377
def fastLinkOut() = T.command {
9478
val target = fastLinkJS()
9579
println(target.dest.path)
@@ -107,3 +91,22 @@ object frontend extends ScalaJSModule with Common {
10791
def jsEnvConfig = T(JsEnvConfig.JsDom())
10892
}
10993
}
94+
95+
// -----------------------------------------------------------------------------
96+
// Global commands
97+
// -----------------------------------------------------------------------------
98+
99+
// Toplevel commands
100+
def runTasks(t: Seq[String])(implicit ev: eval.Evaluator) = T.task {
101+
mill.main.MainModule.evaluateTasks(
102+
ev,
103+
t.flatMap(x => x +: Seq("+")).flatMap(x => x.split(" ")).dropRight(1),
104+
mill.define.SelectMode.Separated,
105+
)(identity)
106+
}
107+
def lint(implicit ev: eval.Evaluator) = T.command {
108+
runTasks(Seq("__.fix", "mill.scalalib.scalafmt.ScalafmtModule/reformatAll __.sources"))
109+
}
110+
def deps(ev: eval.Evaluator) = T.command {
111+
mill.scalalib.Dependency.showUpdates(ev)
112+
}

frontend/src/FrontEndApp.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package com.carlosedp
22
package zioscalajs.frontend
33

4-
import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue
54
import scala.scalajs.js.annotation.JSExportTopLevel
65

76
import com.carlosedp.zioscalajs.shared.SharedConfig
87
import org.scalajs.dom._
98
import org.scalajs.dom.html._
10-
import sttp.client3._
9+
import sttp.client3.quick._
1110

1211
object FrontEndApp:
1312

@@ -56,9 +55,9 @@ object FrontEndApp:
5655
nodeType: String,
5756
) =
5857
println(s"Querying backend: $uri...")
59-
sttp.client3.quickRequest
60-
.get(uri"$uri")
61-
.send(FetchBackend())
58+
implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global
59+
simpleHttpClient
60+
.send(quickRequest.get(uri"$uri"))
6261
.map { response =>
6362
callback(node, response.body, nodeType, "")
6463
}

0 commit comments

Comments
 (0)