Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add settings and tasks #3

Merged
merged 4 commits into from
May 8, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion src/main/scala/cloud/golem/GolemScalaPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,39 @@ object GolemScalaPlugin extends AutoPlugin {
val scalaMacrosParadise = "2.1.1"
}

object autoImport {
val witBindgen =
taskKey[Unit]("Runs golem-scalajs-wit-bindgen to generate WIT bindings")

val component =
taskKey[Unit]("Runs componentize-js on the generated main.js file")

lazy val baseSettings: Seq[Setting[?]] =
Def.settings(
witBindgen := {
import scala.sys.process.*
Seq(
"bash",
"-xc",
"golem-scalajs-wit-bindgen -w wit/main.wit -p example"
).!!
},
component := {
import scala.sys.process.*
Seq("bash", "-xc", "npm install").!!
Seq("bash", "-xc", "npm run build").!!
},
component := (component dependsOn (Compile / fullLinkJS)).value
)
}

import autoImport.*

override def trigger: PluginTrigger = allRequirements

override def requires: Plugins = JvmPlugin && ScalaJSPlugin

override lazy val projectSettings: Seq[Setting[?]] = Seq(
override lazy val projectSettings: Seq[Setting[?]] = baseSettings ++ Seq(
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.ESModule) },
libraryDependencies += "cloud.golem" %% "golem-scala-macros" % Versions.macros
) ++ macroParadiseSettings
Expand Down