Create a GitHub token from https://github.com/settings/tokens and save it:
$ git config --global --add github.token 1234************
Create a GitHub token from https://github.com/settings/tokens and save it:
$ git config --global --add github.token 1234************
| name := "sbt-plugin-ranking" | |
| scalaVersion := "2.12.20" | |
| libraryDependencies ++= List( | |
| "com.eed3si9n" %% "gigahorse-github" % "gigahorse0.3.1_0.2.0", | |
| "com.eed3si9n" %% "gigahorse-okhttp" % "0.3.1" | |
| ) |
| package sbt_plugin_ranking | |
| import gigahorse._, support.okhttp.Gigahorse | |
| import gigahorse.github.Github | |
| import scala.concurrent._, duration._ | |
| import ExecutionContext.Implicits._ | |
| object Main extends App { | |
| val repo = """https:\/\/github.com\/([a-zA-Z0-9_\-]+)\/([a-zA-Z0-9_\-]+)""".r | |
| val url = "https://www.scala-sbt.org/1.x/docs/Community-Plugins.html" | |
| Gigahorse.withHttp { http => | |
| val r = Gigahorse.url(url).get | |
| val f = http.run(r, Gigahorse.asString) | |
| val html = Await.result(f, 120.seconds) | |
| val repoList = repo.findAllIn(html).map { case repo(user,name) => user -> name }.toList.distinct | |
| val client = Github.localConfigClient | |
| val promises = repoList map { case (u,r) => | |
| http.run(client(Github.repo(u, r)), Github.asRepo) | |
| } | |
| val info0 = for { | |
| p <- promises | |
| } yield Await.ready(p, 1.minutes).value.get | |
| val info = info0.collect { | |
| case t if t.isSuccess => t.get | |
| } | |
| info.sortBy(_.watchers_count).reverse foreach{ repo => | |
| println("- " + repo.html_url.get + " " + repo.watchers_count.get)} | |
| } | |
| } |