github-api-node - A higher-level wrapper around the Github API.
Github.js provides a minimal higher-level wrapper around git's plumbing commands, exposing an API for manipulating GitHub repositories on the file level. It was formerly developed in the context of Prose, a content editor for GitHub.
$ sbt clean publish-local
Before running the tests the first time, you must ensure the npm packages are installed:
$ npm install
Then you can run the tests:
$ sbt test
import io.scalajs.nodejs.util.Util
import io.scalajs.npm.githubapinode._
import io.scalajs.util.JSONHelper._
import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue
import scala.scalajs.js
val gitHub = new GitHub(new GithubOptions())
// get the "bignum" repo for user "scalajs-io"
val repo = gitHub.getRepo("scalajs-io", "bignum")
// list the branches in the repo
repo.listBranchesFuture foreach { branches =>
println(s"branches: ${branches.toJson}")
}
// list the contributors to the repo
repo.contributorsFuture foreach { contributors =>
println(s"contributors: ${Util.inspect(contributors)}")
}
// retrieve the contents of the master branch
repo.contentsFuture(branch = "master", pathToDir = ".") foreach { contents =>
println(s"contents: ${Util.inspect(contents)}")
}
// asynchronously read the contents of a file in the repo's master branch
repo.readFuture(branch = "master", pathToFile = "package.json") foreach { data =>
println(s"package.json: ${Util.inspect(data)}")
}
To add the GitHub
binding to your project, add the following to your build.sbt:
libraryDependencies += "io.scalajs.npm" %%% "github-api-node" % "0.5.0"
Optionally, you may add the Sonatype Repository resolver:
resolvers += Resolver.sonatypeRepo("releases")