diff --git a/src/main/scala/seed/Cli.scala b/src/main/scala/seed/Cli.scala index 79112f7..25eac35 100644 --- a/src/main/scala/seed/Cli.scala +++ b/src/main/scala/seed/Cli.scala @@ -38,6 +38,7 @@ object Cli { packageConfig: PackageConfig, webSocket: Option[WebSocketConfig], watch: Boolean, + optimise: Boolean, modules: List[String] ) extends Command case class BuildEvents(webSocket: WebSocketConfig) extends Command @@ -109,6 +110,7 @@ object Cli { packageConfigArg .and(webSocketConnectArg) .and(flag("--watch")) + .and(flag("--optimise")) .and(repeatedAtLeastOnceFree[String]) .to[Command.Link] @@ -191,8 +193,9 @@ ${underlined("Usage:")} seed [--build=] [--config=] - app:native Only compile Native platform of module ${Ansi.italic("app")} - app: Only build ${Ansi.italic("")} of the module ${Ansi.italic("app")} - ${bold("Command:")} ${underlined("link")} [--connect[=${webSocketDefaultConnection.format}]] [--watch] + ${bold("Command:")} ${underlined("link")} [--connect[=${webSocketDefaultConnection.format}]] [--optimise] [--watch] ${italic("--connect")} Run link command on remote Seed server + ${italic("--optimise")} Instruct the linker to perform optimisations on the build ${italic("--watch")} Link upon source changes (cannot be combined with ${Ansi.italic("--connect")}) ${italic("")} One or multiple space-separated modules. The syntax of a module is: ${italic("")} or ${italic(":")} ${italic("Examples:")} diff --git a/src/main/scala/seed/cli/Link.scala b/src/main/scala/seed/cli/Link.scala index c0a22ca..61f15be 100644 --- a/src/main/scala/seed/cli/Link.scala +++ b/src/main/scala/seed/cli/Link.scala @@ -29,7 +29,8 @@ object Link { import io.circe.syntax._ val build = if (buildPath.isAbsolute) buildPath else buildPath.toAbsolutePath - (WsCommand.Link(build, command.modules): WsCommand).asJson.noSpaces + (WsCommand + .Link(build, command.modules, command.optimise): WsCommand).asJson.noSpaces }, log) client.connect() } @@ -39,6 +40,7 @@ object Link { link( buildPath, command.modules, + command.optimise, command.watch, tmpfs, log, @@ -56,6 +58,7 @@ object Link { def link( buildPath: Path, modules: List[String], + optimise: Boolean, watch: Boolean, tmpfs: Boolean, log: Log, @@ -89,6 +92,7 @@ object Link { build, projectPath, linkModules, + optimise, watch, log, onStdOut(build) diff --git a/src/main/scala/seed/cli/Server.scala b/src/main/scala/seed/cli/Server.scala index 1721272..4a81fd7 100644 --- a/src/main/scala/seed/cli/Server.scala +++ b/src/main/scala/seed/cli/Server.scala @@ -17,7 +17,8 @@ import scala.collection.mutable sealed abstract class WsCommand(val description: String) object WsCommand { - case class Link(build: Path, modules: List[String]) extends WsCommand("Link") + case class Link(build: Path, modules: List[String], optimise: Boolean = false) + extends WsCommand("Link") case class Build(build: Path, targets: List[String]) extends WsCommand("Build") case object BuildEvents extends WsCommand("Build events") @@ -132,10 +133,11 @@ object Server { // TODO Send success state to client too RTS.unsafeRunAsync(uio)(_ => wsClient.close()) } - case WsCommand.Link(buildPath, modules) => + case WsCommand.Link(buildPath, modules, optimise) => seed.cli.Link.link( buildPath, modules, + optimise = optimise, watch = false, tmpfs, clientLog, diff --git a/src/main/scala/seed/cli/util/BloopCli.scala b/src/main/scala/seed/cli/util/BloopCli.scala index 7d609dc..c2ddb5b 100644 --- a/src/main/scala/seed/cli/util/BloopCli.scala +++ b/src/main/scala/seed/cli/util/BloopCli.scala @@ -76,13 +76,17 @@ object BloopCli { build: Build, projectPath: Path, bloopModules: List[String], + optimise: Boolean, watch: Boolean, log: Log, onStdOut: String => Unit ): Option[ProcessHelper.Process] = if (bloopModules.isEmpty) None else { - val args = "link" +: ((if (!watch) List() else List("--watch")) ++ bloopModules) + val watchParam = if (!watch) List() else List("--watch") + val optimiseParam = + if (!optimise) List() else List("--optimize", "release") + val args = List("link") ++ bloopModules ++ watchParam ++ optimiseParam Some(ProcessHelper.runBloop(projectPath, log, onStdOut)(args: _*)) } } diff --git a/src/test/scala/seed/build/LinkSpec.scala b/src/test/scala/seed/build/LinkSpec.scala index 72be505..449d551 100644 --- a/src/test/scala/seed/build/LinkSpec.scala +++ b/src/test/scala/seed/build/LinkSpec.scala @@ -32,6 +32,7 @@ object LinkSpec extends TestSuite[Unit] { build, projectPath, List("example-js"), + optimise = false, watch = false, Log.urgent, onStdOut