Skip to content

Commit 9984b18

Browse files
committed
.
1 parent 1ae2969 commit 9984b18

9 files changed

Lines changed: 56 additions & 17 deletions

File tree

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
jvm: temurin@21
5858

5959
- name: Build the binary
60-
run: mill jsls.native.nativeLink
60+
run: ./mill sjsls.native.nativeLink
6161

6262
- name: Upload artifacts
6363
uses: actions/upload-artifact@v4
@@ -88,12 +88,12 @@ jobs:
8888

8989

9090
- name: Build the binary
91-
run: sbt buildBinaryPlatformRelease
91+
run: ./mill sjsls.native.nativeLink
9292

9393
- name: Upload artifacts
9494
uses: actions/upload-artifact@v4
9595
with:
96-
path: out/release/*
96+
path: out/sjsls/native/nativeLink.dest/*
9797
name: ${{ matrix.os }}-linux-binaries
9898
if-no-files-found: error
9999

@@ -145,13 +145,13 @@ jobs:
145145
clang --version
146146
147147
- name: Build binary (windows)
148-
run: sbt buildBinaryPlatformRelease
148+
run: ./mill sjsls.native.nativeLink
149149
shell: cmd
150150

151151
- name: Upload artifacts
152152
uses: actions/upload-artifact@v4
153153
with:
154-
path: out/release/*
154+
path: out/sjsls/native/nativeLink.dest/*
155155
name: windows-binaries
156156
if-no-files-found: error
157157

sjsls/package.mill

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import mill.scalalib.publish.*
88
import mill.contrib.buildinfo.BuildInfo
99
import mill.api.Task.Simple
1010
import scala.util.Try
11+
import mill.scalanativelib.*
12+
import scalanativelib.api.*
13+
1114
object `package` extends Module:
1215

1316
trait SjslsPlatformModule extends PlatformScalaModule with FormatFixPublish:
@@ -27,10 +30,10 @@ object `package` extends Module:
2730
)
2831

2932
def artifactName = "sjsls"
33+
end SjslsPlatformModule
3034

3135
object jvm extends SjslsPlatformModule:
3236
def moduleDeps = Seq(build.sjsls_routes.jvm)
33-
3437
object test extends Testy with ScalaTests with BuildInfo:
3538
val name = "sjsls"
3639
val buildInfoPackageName = "sjsls"
@@ -46,9 +49,9 @@ object `package` extends Module:
4649
)
4750
override def resources = super.resources()
4851

49-
/**
50-
* Starts a server which squats on the port we want to test with, and busts mill's cache to ensure it's always started in advance...
51-
*/
52+
/** Starts a server which squats on the port we want to test with, and busts mill's cache to ensure it's always
53+
* started in advance...
54+
*/
5255
override def forkEnv: Simple[Map[String, String]] = Task {
5356
squattyServer()
5457
super.forkEnv() ++ Map(
@@ -76,6 +79,17 @@ object `package` extends Module:
7679
end test
7780
end jvm
7881

82+
// Can't test playwright stuff here...
83+
object native extends SjslsPlatformModule with ScalaNativeModule:
84+
override def mvnDeps = super.mvnDeps() ++ Seq(
85+
mvn"com.github.lolgab::scala-native-crypto::0.3.0"
86+
)
87+
override def scalaNativeVersion = V.scalaNativeVersion
88+
def releaseMode = Task{ReleaseMode.ReleaseSize}
89+
def moduleDeps = Seq(sjsls_routes.native)
90+
91+
end native
92+
7993
object cacheJsLibs extends ScalaJSModule:
8094
def scalaVersion = V.scalaVersion
8195
def scalaJSVersion = V.scalaJs
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.github.quafadas.sjsls
2+
3+
import java.awt.Desktop
4+
import java.net.URI
5+
6+
import scribe.Scribe
7+
8+
import cats.effect.IO
9+
10+
private[sjsls] def platformBrowse(uri: URI)(logger: Scribe[IO]): IO[Unit] =
11+
IO(
12+
if Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE) then
13+
IO(Desktop.getDesktop().browse(uri))
14+
else logger.error("Desktop not supported, so can't open browser")
15+
).flatten
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package io.github.quafadas.sjsls
2+
3+
private[sjsls] def currentProcessPid(): Long = ProcessHandle.current().pid()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.github.quafadas.sjsls
2+
3+
import java.net.URI
4+
5+
import scribe.Scribe
6+
7+
import cats.effect.IO
8+
9+
private[sjsls] def platformBrowse(uri: URI)(logger: Scribe[IO]): IO[Unit] = IO.unit
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package io.github.quafadas.sjsls
2+
3+
private[sjsls] def currentProcessPid(): Long = 0L

sjsls/src/dezombify.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private def killProcessesOnPort(port: Port): IO[Unit] =
103103
else
104104
// macOS/Linux: use lsof if available, fallback to fuser
105105
// Exclude the current JVM PID to prevent accidentally killing ourselves.
106-
val currentPid = ProcessHandle.current().pid()
106+
val currentPid = currentProcessPid()
107107
val sh = s"""
108108
|current_pid=$currentPid
109109
|if command -v lsof >/dev/null 2>&1; then

sjsls/src/openBrowser.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,4 @@ def openBrowser(openBrowserAt: Option[String], port: Port)(logger: Scribe[IO]):
1414
case None => logger.trace("No openBrowserAt flag set, so no browser will be opened")
1515
case Some(value) =>
1616
val openAt = URI(s"http://localhost:$port$value")
17-
logger.info(s"Attempting to open browser to $openAt") >>
18-
IO(
19-
if Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE) then
20-
IO(Desktop.getDesktop().browse(openAt))
21-
else logger.error("Desktop not supported, so can't open browser")
22-
).flatten
17+
platformBrowse(openAt)(logger)

sjsls/test/src/dezombify.test.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import munit.CatsEffectSuite
99
class DezombieTest extends CatsEffectSuite:
1010

1111
test("That we kill off a zombie server") {
12-
val portInt = 6789
12+
val portInt = 6789 // Build server starts a zombie server on this port, so we can test dezombification
1313
val port = Port.fromInt(portInt).get
1414

1515
val lsc = LiveServerConfig(

0 commit comments

Comments
 (0)