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

Auto-populate startYear and SJS version in docs #316

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 24 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,28 @@ lazy val docs = project
"mdoc" -> url("https://scalameta.org/mdoc/"),
"Laika" -> url("https://planet42.github.io/Laika/"),
"sbt-unidoc" -> url("https://github.com/sbt/sbt-unidoc")
)
),
mdocVariables ++= {
import coursier.complete.Complete
import java.time._
import scala.concurrent._
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits._

val startYear = YearMonth.now().getYear.toString

val sjsVersionFuture =
Complete().withInput(s"org.scala-js:scalajs-library_2.13:").complete().future()
Comment on lines +211 to +212
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spun in circles for a bit trying to find the latest version via the sbt-scalajs artifact until I remembered this issue exists:

which of course is because of:

val sjsVersion =
try {
Await.result(sjsVersionFuture, 5.seconds)._2.last
} catch {
case ex: TimeoutException => scalaJSVersion // not the latest but better than nothing
}

Map(
"START_YEAR" -> startYear,
"LATEST_SJS_VERSION" -> sjsVersion
)
}
)
2 changes: 1 addition & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Check out the [**sbt-typelevel-site**](site.md) plugin.
We recommend explicitly setting your Scala.js version in `project/plugins.sbt`.

```scala
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "@LATEST_SJS_VERSION@")
```

**sbt-typelevel** ships with a conservative Scala.js version to enable certain settings.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ ThisBuild / tlBaseVersion := "0.4" // your current series x.y

ThisBuild / organization := "org.typelevel"
ThisBuild / organizationName := "Typelevel"
ThisBuild / startYear := Some(2022)
ThisBuild / startYear := Some(@START_YEAR@)
ThisBuild / licenses := Seq(License.Apache2)
ThisBuild / developers := List(
// your GitHub handle and name
Expand Down
4 changes: 4 additions & 0 deletions project/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ Compile / unmanagedSourceDirectories ++= modules.map { module =>
Compile / unmanagedResourceDirectories ++= modules.map { module =>
baseDirectory.value.getParentFile / module / "src" / "main" / "resources"
}

libraryDependencies ++= Seq(
"io.get-coursier" %% "coursier" % "2.1.0-M6"
)