-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.sbt
195 lines (179 loc) · 6.54 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
ThisBuild / tlBaseVersion := "0.2"
ThisBuild / organization := "com.armanbilge"
ThisBuild / organizationName := "Arman Bilge"
ThisBuild / startYear := Some(2022)
ThisBuild / developers := List(
tlGitHubDev("armanbilge", "Arman Bilge")
)
ThisBuild / tlCiReleaseBranches ++= Seq("series/0.1")
ThisBuild / tlSitePublishBranch := Some("main")
ThisBuild / tlSonatypeUseLegacyHost := false
ThisBuild / crossScalaVersions := Seq("3.3.4")
ThisBuild / scalacOptions ++= Seq("-new-syntax", "-indent", "-source:future")
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("21"))
val CatsVersion = "2.12.0"
val CatsEffectVersion = "3.5.4"
val Fs2Version = "3.11.0"
val Fs2DomVersion = "0.2.1"
val Http4sVersion = "0.23.28"
val Http4sDomVersion = "0.2.11"
val MonocleVersion = "3.3.0"
lazy val root =
tlCrossRootProject.aggregate(frp, calico, router, sandbox, todoMvc, unidocs)
lazy val frp = crossProject(JVMPlatform, JSPlatform)
.crossType(CrossType.Pure)
.in(file("frp"))
.settings(
name := "calico-frp",
tlVersionIntroduced := Map("3" -> "0.1.1"),
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % CatsVersion,
"org.typelevel" %%% "cats-effect" % CatsEffectVersion,
"co.fs2" %%% "fs2-core" % Fs2Version,
"org.typelevel" %%% "cats-laws" % CatsVersion % Test,
"org.typelevel" %%% "cats-effect-testkit" % CatsEffectVersion % Test,
"org.typelevel" %%% "discipline-munit" % "2.0.0" % Test,
"org.typelevel" %%% "munit-cats-effect" % "2.0.0" % Test,
"org.scalameta" %%% "munit-scalacheck" % "1.0.0" % Test
)
)
lazy val generateDomDefs = taskKey[Seq[File]]("Generate SDT sources")
lazy val calico = project
.in(file("calico"))
.enablePlugins(ScalaJSPlugin)
.settings(
name := "calico",
libraryDependencies ++= Seq(
"com.armanbilge" %%% "fs2-dom" % Fs2DomVersion,
"org.typelevel" %%% "shapeless3-deriving" % "3.4.3",
"dev.optics" %%% "monocle-core" % MonocleVersion,
"org.scala-js" %%% "scalajs-dom" % "2.8.0"
),
Compile / generateDomDefs := {
import _root_.calico.html.codegen.DomDefsGenerator
import cats.effect.unsafe.implicits.global
import sbt.util.CacheImplicits._
(Compile / generateDomDefs).previous(sbt.fileJsonFormatter).getOrElse {
DomDefsGenerator.generate((Compile / sourceManaged).value / "domdefs").unsafeRunSync()
}
},
Compile / sourceGenerators += (Compile / generateDomDefs)
)
.dependsOn(frp.js)
lazy val router = project
.in(file("router"))
.enablePlugins(ScalaJSPlugin)
.settings(
name := "calico-router",
tlVersionIntroduced := Map("3" -> "0.1.2"),
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % CatsVersion,
"org.typelevel" %%% "cats-effect" % CatsEffectVersion,
"com.armanbilge" %%% "fs2-dom" % Fs2DomVersion,
"org.http4s" %%% "http4s-core" % Http4sVersion
)
)
lazy val sandbox = project
.in(file("sandbox"))
.enablePlugins(ScalaJSPlugin, NoPublishPlugin)
.dependsOn(calico, router)
.settings(
scalaJSUseMainModuleInitializer := true,
Compile / fastLinkJS / scalaJSLinkerConfig ~= {
import org.scalajs.linker.interface.ModuleSplitStyle
_.withModuleKind(ModuleKind.ESModule)
.withModuleSplitStyle(ModuleSplitStyle.SmallModulesFor(List("calico")))
},
libraryDependencies ++= Seq(
"org.http4s" %%% "http4s-dom" % Http4sDomVersion,
"dev.optics" %%% "monocle-macro" % MonocleVersion
),
scalacOptions ~= (_.filterNot(_.startsWith("-Wunused")))
)
lazy val todoMvc = project
.in(file("todo-mvc"))
.enablePlugins(ScalaJSPlugin, BundleMonPlugin, NoPublishPlugin)
.dependsOn(calico, router)
.settings(
scalaJSUseMainModuleInitializer := true,
Compile / fastLinkJS / scalaJSLinkerConfig ~= {
import org.scalajs.linker.interface.ModuleSplitStyle
_.withModuleKind(ModuleKind.ESModule)
.withModuleSplitStyle(ModuleSplitStyle.SmallModulesFor(List("todomvc")))
},
libraryDependencies ++= Seq(
"io.circe" %%% "circe-jawn" % "0.14.10"
),
bundleMonCheckRun := true,
bundleMonCommitStatus := false,
bundleMonPrComment := false
)
ThisBuild / githubWorkflowBuild +=
WorkflowStep.Sbt(
List("bundleMon"),
name = Some("Monitor artifact size"),
cond = Some("matrix.project == 'rootJS'")
)
lazy val unidocs = project
.in(file("unidocs"))
.enablePlugins(ScalaJSPlugin, TypelevelUnidocPlugin)
.settings(
name := "calico-docs",
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(frp.js, calico, router),
ScalaUnidoc / unidoc / fullClasspath := (todoMvc / Compile / fullClasspath).value
)
lazy val jsdocs = project
.settings(
scalacOptions ~= (_.filterNot(_.startsWith("-Wunused"))),
libraryDependencies ++= Seq(
"org.http4s" %%% "http4s-dom" % Http4sDomVersion,
"org.http4s" %%% "http4s-circe" % Http4sVersion
)
)
.dependsOn(calico, router)
.enablePlugins(ScalaJSPlugin)
lazy val docs = project
.in(file("site"))
.enablePlugins(TypelevelSitePlugin)
.settings(
tlSiteApiPackage := Some("calico"),
tlSiteIsTypelevelProject := Some(TypelevelProject.Affiliate),
mdocJS := Some(jsdocs),
laikaConfig ~= { _.withRawContent },
tlSiteHelium ~= {
import laika.helium.config._
_.site.mainNavigation(appendLinks = Seq(
ThemeNavigationSection(
"Related Projects",
TextLink.external("https://typelevel.org/cats-effect/", "Cats Effect"),
TextLink.external("https://fs2.io/", "FS2"),
TextLink.external("https://github.com/armanbilge/fs2-dom/", "fs2-dom"),
TextLink.external("https://http4s.github.io/http4s-dom/", "http4s-dom")
)
))
},
laikaInputs := {
import laika.ast.Path.Root
import laika.io.model.FilePath
val jsArtifact = (todoMvc / Compile / fullOptJS / artifactPath).value
val sourcemap = jsArtifact.getName + ".map"
laikaInputs
.value
.delegate
.addFile(
FilePath.fromJavaFile(jsArtifact),
Root / "todomvc" / "index.js"
)
.addFile(
FilePath.fromNioPath(jsArtifact.toPath.resolveSibling(sourcemap)),
Root / "todomvc" / sourcemap
)
},
mdocVariables += ("HTTP4S_DOM_VERSION" -> Http4sDomVersion),
mdocVariables += {
val src = IO.readLines(
(todoMvc / sourceDirectory).value / "main" / "scala" / "todomvc" / "TodoMvc.scala")
"TODO_MVC_SRC" -> src.dropWhile(!_.startsWith("package")).mkString("\n")
},
laikaSite := laikaSite.dependsOn(todoMvc / Compile / fullOptJS).value
)