Update plugins.json schema

This commit is contained in:
Naoki Takezoe
2017-12-23 04:31:01 +09:00
parent ea41786f8c
commit b7bb6b0787
4 changed files with 13 additions and 17 deletions

View File

@@ -160,10 +160,9 @@ executableKey := {
IO copyFile(Keys.baseDirectory.value / "plugins.json", pluginsDir / "plugins.json")
val json = IO read(Keys.baseDirectory.value / "plugins.json")
PluginsJson.parse(json).foreach { case (plugin, version, file) =>
val url = s"https://github.com/gitbucket/${plugin}/releases/download/${version}/${file}"
PluginsJson.getUrls(json).foreach { url =>
log info s"Download: ${url}"
IO transfer(new java.net.URL(url).openStream, pluginsDir / file)
IO transfer(new java.net.URL(url).openStream, pluginsDir / url.substring(url.lastIndexOf("/") + 1))
}
// zip it up

View File

@@ -7,7 +7,7 @@
{
"version": "1.4.0",
"range": ">=4.19.0",
"file": "gitbucket-notifications-plugin_2.12-1.4.0.jar"
"url": "https://github.com/gitbucket/gitbucket-notifications-plugin/releases/download/1.4.0/gitbucket-notifications-plugin_2.12-1.4.0.jar"
}
],
"default": true
@@ -20,7 +20,7 @@
{
"version": "4.5.0",
"range": ">=4.18.0",
"file": "gitbucket-emoji-plugin_2.12-4.5.0.jar"
"url": "https://github.com/gitbucket/gitbucket-emoji-plugin/releases/download/4.5.0/gitbucket-emoji-plugin_2.12-4.5.0.jar"
}
],
"default": false
@@ -33,7 +33,7 @@
{
"version": "4.11.0",
"range": ">=4.19.0",
"file": "gitbucket-gist-plugin-assembly-4.11.0.jar"
"url": "https://github.com/gitbucket/gitbucket-gist-plugin/releases/download/4.11.0/gitbucket-gist-plugin-assembly-4.11.0.jar"
}
],
"default": false
@@ -44,9 +44,9 @@
"description": "Project pages for gitbucket",
"versions": [
{
"version": "v1.6.0",
"version": "1.6.0",
"range": ">=4.19.0",
"file": "gitbucket-pages-plugin_2.12-1.6.0.jar"
"url": "https://github.com/gitbucket/gitbucket-pages-plugin/releases/download/v1.6.0/gitbucket-pages-plugin_2.12-1.6.0.jar"
}
],
"default": false

View File

@@ -3,17 +3,12 @@ import scala.collection.JavaConverters._
object PluginsJson {
def parse(json: String): Seq[(String, String, String)] = {
def getUrls(json: String): Seq[String] = {
val value = Json.parse(json)
value.asArray.values.asScala.map { plugin =>
val pluginObject = plugin.asObject
val pluginName = "gitbucket-" + pluginObject.get("id").asString + "-plugin"
val latestVersionObject = pluginObject.get("versions").asArray.asScala.head.asObject
val file = latestVersionObject.get("file").asString
val version = latestVersionObject.get("version").asString
(pluginName, version, file)
latestVersionObject.get("url").asString
}
}

View File

@@ -35,7 +35,9 @@ case class PluginMetadata(
case class VersionDef(
version: String,
file: String,
url: String,
range: String
)
){
lazy val file = url.substring(url.lastIndexOf("/") + 1)
}