-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
80 lines (66 loc) · 2.36 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
name := "scalajs-octokit"
organization := "laughedelic"
description := "Scala.js wrapper for the octokit/rest.js library (GitHub REST API)"
homepage := Some(url(s"https://github.com/laughedelic/${name.value}"))
scmInfo in ThisBuild := Some(ScmInfo(
homepage.value.get,
s"scm:git:git@github.com:laughedelic/${name.value}.git"
))
licenses := Seq("MPL-2.0" -> url("https://www.mozilla.org/en-US/MPL/2.0"))
developers := List(Developer(
"laughedelic",
"Alexey Alekhin",
"laughedelic@gmail.com",
url("https://github.com/laughedelic")
))
scalaVersion := "2.12.6"
scalacOptions ++= Seq(
"-Yrangepos",
"-P:scalajs:sjsDefinedByDefault",
"-language:implicitConversions",
"-deprecation",
"-feature",
"-Xlint"
)
enablePlugins(ScalaJSPlugin)
releaseEarlyWith := BintrayPublisher
releaseEarlyEnableSyncToMaven := false
releaseEarlyNoGpg := true
publishMavenStyle := true
bintrayReleaseOnPublish := !isSnapshot.value
bintrayPackageLabels := Seq("scalajs", "github", "octokit", "facades")
ghreleaseAssets := Seq()
val octokitV = "15.8.0"
lazy val downloadRoutesJson = settingKey[File]("Download routes.json file from the octokit/rest.js repository")
downloadRoutesJson := {
import sys.process._
val log = sLog.value
val url = s"https://raw.githubusercontent.com/octokit/rest.js/v${octokitV}/lib/routes.json"
val file = baseDirectory.value / "routes.json"
log.info(s"Downloading routes.json v${octokitV} ...")
val exitCode = (new java.net.URL(url) #> file).!(log)
if (exitCode != 0) sys.error("Download failed")
file
}
Compile/sourceGenerators += Def.task {
import laughedelic.sbt.octokit._, Generator._
import upickle.default._
import java.nio.file.Files
import scala.collection.JavaConverters._
val log = streams.value.log
val routesJson = downloadRoutesJson.value
log.info(s"Parsing Github routes from ${routesJson} ...")
val parsed = ParseRoutesTypes(routesJson)
val out = (Compile/sourceManaged).value / "octokit" / "rest" / "routes.scala"
log.info(s"Writing generated routes to ${out} ...")
IO.createDirectory(out.getParentFile)
Files.write(
out.toPath,
generateRoutes(parsed).asJava
)
Seq(out)
}.taskValue
libraryDependencies += "com.lihaoyi" %%% "utest" % "0.6.3" % Test
testFrameworks += new TestFramework("utest.runner.Framework")
enablePlugins(ScalaJSBundlerPlugin)
npmDependencies in Test += "@octokit/rest" -> octokitV