Skip to content

scalajs-io/github-api-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub API for Scala.js

github-api-node - A higher-level wrapper around the Github API.

Description

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.

Build Dependencies

Build/publish the SDK locally

 $ sbt clean publish-local

Running the tests

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

Examples

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)}")
}

Artifacts and Resolvers

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") 

Releases

No releases published

Packages

No packages published

Languages