-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
228 lines (201 loc) · 5.67 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
val scala3 = "3.6.2"
ThisBuild / tlBaseVersion := "0.7"
ThisBuild / crossScalaVersions := Seq(scala3)
ThisBuild / tlCiReleaseBranches := Seq("main")
ThisBuild / githubWorkflowBuildTimeoutMinutes := Some(120)
ThisBuild / githubWorkflowBuildSbtStepPreamble := Seq()
ThisBuild / githubWorkflowArtifactUpload := true
ThisBuild / githubWorkflowTargetBranches += "!dependabot/**"
ThisBuild / githubWorkflowBuildPreamble ++= Seq(
WorkflowStep.Use(
UseRef.Public("actions", "setup-node", "v3"),
params = Map("node-version" -> "20", "cache" -> "npm")
),
WorkflowStep.Run(
List("npm ci")
)
)
ThisBuild / githubWorkflowBuild ~= { steps =>
WorkflowStep.Sbt(List("lucumaTypedGenerate")) +: steps
}
ThisBuild / mergifyPrRules +=
MergifyPrRule(
"merge dependabot PRs",
MergifyCondition.Custom("author=dependabot[bot]") :: mergifySuccessConditions.value.toList,
List(MergifyAction.Merge())
)
lazy val stBase = Def.setting { (npm: String) =>
val fn = npm.replace("@", "").replace("/", "__")
(LocalRootProject / target).value / "scalably-typed" / fn(0).toString / fn
}
lazy val stOut = Def.setting { (npm: String) =>
val finder: PathFinder = stBase.value(npm) / "src" / "main" ** "*.scala"
finder.get
}
lazy val lucumaTypedGenerate = taskKey[Unit]("Generate the ST facades")
lucumaTypedGenerate := {
STConvert.main(
Array(
"--outputPackage",
"lucuma.typed",
"-f",
"scalajs-react",
"--scala",
scala3,
"--scalajs",
scalaJSVersion
)
)
stOut.value("primereact").foreach { f =>
val content = IO.read(f)
// use the ESM-style sources in imports
val transformed = content.replaceAll(
"""@JSImport\("primereact\/((.+?)(?<!\.esm))",""",
"""@JSImport("primereact/$1.esm","""
)
if (transformed != content)
IO.write(f, transformed)
}
}
ThisBuild / tlFatalWarnings := false
ThisBuild / scalacOptions += "-language:implicitConversions"
lazy val root = project
.in(file("."))
.enablePlugins(NoPublishPlugin)
.settings(
githubWorkflowArtifactUpload := true // sources are generated here
)
.aggregate(
std,
csstype,
dateFns,
highcharts,
propTypes,
scheduler,
react,
reactTransitionGroup,
primereact,
reactPopper,
reactDatepicker,
tanstackTableCore,
tanstackReactTable,
tanstackVirtualCore,
tanstackReactVirtual
)
def facadeSettings(npm: String) = Seq(
Compile / managedSources ++= stOut.value(npm),
Compile / packageSrc / mappings := {
val base = stBase.value(npm)
(Compile / managedSources).value.map { file =>
file -> file.relativeTo(base).get.getPath
}
}
)
lazy val std = project
.settings(
name := "lucuma-typed-std",
libraryDependencies ++= Seq(
"com.github.japgolly.scalajs-react" %%% "core" % "3.0.0-beta6",
"com.olvind" %%% "scalablytyped-runtime" % "2.4.2"
)
)
.settings(facadeSettings("std"))
.enablePlugins(ScalaJSPlugin)
lazy val csstype = project
.settings(
name := "lucuma-typed-csstype"
)
.settings(facadeSettings("csstype"))
.dependsOn(std)
.enablePlugins(ScalaJSPlugin)
lazy val dateFns = project
.settings(
name := "lucuma-typed-date-fns"
)
.settings(facadeSettings("date-fns"))
.dependsOn(std)
.enablePlugins(ScalaJSPlugin)
lazy val highcharts = project
.settings(
name := "lucuma-typed-highcharts"
)
.settings(facadeSettings("highcharts"))
.dependsOn(std)
.enablePlugins(ScalaJSPlugin)
lazy val propTypes = project
.settings(
name := "lucuma-typed-prop-types"
)
.settings(facadeSettings("prop-types"))
.dependsOn(std)
.enablePlugins(ScalaJSPlugin)
lazy val scheduler = project
.settings(
name := "lucuma-typed-scheduler"
)
.settings(facadeSettings("scheduler"))
.dependsOn(std)
.enablePlugins(ScalaJSPlugin)
lazy val react = project
.settings(
name := "lucuma-typed-react"
)
.settings(facadeSettings("react"))
.dependsOn(csstype, propTypes, scheduler)
.enablePlugins(ScalaJSPlugin)
lazy val reactTransitionGroup = project
.settings(
name := "lucuma-typed-react-transition-group"
)
.settings(facadeSettings("react-transition-group"))
.dependsOn(react)
.enablePlugins(ScalaJSPlugin)
lazy val primereact = project
.settings(
name := "lucuma-typed-primereact"
)
.settings(facadeSettings("primereact"))
.dependsOn(reactTransitionGroup)
.enablePlugins(ScalaJSPlugin)
lazy val reactPopper = project
.settings(
name := "lucuma-typed-react-popper"
)
.settings(facadeSettings("react-popper"))
.dependsOn(react)
.enablePlugins(ScalaJSPlugin)
lazy val reactDatepicker = project
.settings(
name := "lucuma-typed-react-datepicker"
)
.settings(facadeSettings("react-datepicker"))
.dependsOn(react, reactPopper, dateFns)
.enablePlugins(ScalaJSPlugin)
lazy val tanstackTableCore = project
.settings(
name := "lucuma-typed-tanstack-table-core"
)
.settings(facadeSettings("@tanstack/table-core"))
.dependsOn(std)
.enablePlugins(ScalaJSPlugin)
lazy val tanstackReactTable = project
.settings(
name := "lucuma-typed-tanstack-react-table"
)
.settings(facadeSettings("@tanstack/react-table"))
.dependsOn(react, tanstackTableCore)
.enablePlugins(ScalaJSPlugin)
lazy val tanstackVirtualCore = project
.settings(
name := "lucuma-typed-tanstack-virtual-core"
)
.settings(facadeSettings("@tanstack/virtual-core"))
.dependsOn(std)
.enablePlugins(ScalaJSPlugin)
lazy val tanstackReactVirtual = project
.settings(
name := "lucuma-typed-tanstack-react-virtual"
)
.settings(facadeSettings("@tanstack/react-virtual"))
.dependsOn(react, tanstackVirtualCore)
.enablePlugins(ScalaJSPlugin)