Skip to content

Commit

Permalink
test(examples): node-github -> @octokit/rest
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Jan 17, 2018
1 parent 6ba72e5 commit 5a7e697
Show file tree
Hide file tree
Showing 41 changed files with 108 additions and 148 deletions.
7 changes: 3 additions & 4 deletions examples/addCollaborator.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.authenticate({
octokit.authenticate({
type: 'oauth',
token: 'add-your-real-token-here'
})

github.repos.addCollaborator({
octokit.repos.addCollaborator({
owner: 'octokit',
repo: 'rest.js',
username: 'defunkt'
Expand Down
7 changes: 3 additions & 4 deletions examples/addLabelsToIssue.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.authenticate({
octokit.authenticate({
type: 'oauth',
token: 'add-your-real-token-here'
})

github.issues.addLabels({
octokit.issues.addLabels({
owner: 'octokit',
repo: 'rest.js',
number: '1',
Expand Down
7 changes: 3 additions & 4 deletions examples/createFile.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.authenticate({
octokit.authenticate({
type: 'oauth',
token: 'add-your-real-token-here'
})

github.repos.createFile({
octokit.repos.createFile({
owner: 'octokit',
repo: 'rest.js',
path: 'blah.txt',
Expand Down
7 changes: 3 additions & 4 deletions examples/createStatus.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.authenticate({
octokit.authenticate({
type: 'oauth',
token: 'add-your-real-token-here'
})

github.repos.createStatus({
octokit.repos.createStatus({
owner: 'octokit',
repo: 'rest.js',
sha: '81c559e2e8551982235bc86594cd86ffb135b053',
Expand Down
9 changes: 4 additions & 5 deletions examples/enterpriseUploadAsset.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true,
host: 'github.my-ghe-enabled-company.com',
pathPrefix: '/api/v3'
})

github.authenticate({
octokit.authenticate({
type: 'oauth',
token: 'add-your-real-token-here'
})

github.repos.getReleaseByTag({
octokit.repos.getReleaseByTag({
owner: 'octokit-fixture-org',
repo: 'release-assets',
tag: 'v1.0.0'
})

.then(result => {
return github.repos.uploadAsset({
return octokit.repos.uploadAsset({
url: result.data.upload_url,
file: 'Hello, world!\n',
contentType: 'text/plain',
Expand Down
5 changes: 2 additions & 3 deletions examples/getContent.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.repos.getContent({
octokit.repos.getContent({
owner: 'octokit',
repo: 'rest.js',
path: ''
Expand Down
7 changes: 3 additions & 4 deletions examples/getFollowers.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.authenticate({
octokit.authenticate({
type: 'oauth',
token: 'add-your-real-token-here'
})

github.users.getFollowers({})
octokit.users.getFollowers({})
7 changes: 3 additions & 4 deletions examples/getFollowing.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.authenticate({
octokit.authenticate({
type: 'oauth',
token: 'add-your-real-token-here'
})

github.users.getFollowing({})
octokit.users.getFollowing({})
5 changes: 2 additions & 3 deletions examples/getIssuesForRepo.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: false
})

github.issues.getForRepo({
octokit.issues.getForRepo({
owner: 'octokit',
repo: 'rest.js'
})
9 changes: 4 additions & 5 deletions examples/getNextPage.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.repos.getAll({
octokit.repos.getAll({
owner: 'octokit',
repo: 'rest.js',
affiliation: 'owner,organization_member'
})

.then(result => {
if (github.hasNextPage(result)) {
return github.getNextPage(result)
if (octokit.hasNextPage(result)) {
return octokit.getNextPage(result)

.then(handleResults)
}
Expand Down
5 changes: 2 additions & 3 deletions examples/getOrg.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const assert = require('assert')
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.orgs.get({
octokit.orgs.get({
org: 'octokit'
}).then(result => {
// result.data looks like https://developer.github.com/v3/orgs/#response-3
Expand Down
5 changes: 2 additions & 3 deletions examples/getOrgPublicMembers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.orgs.getPublicMembers({
octokit.orgs.getPublicMembers({
org: 'octokit'
})
5 changes: 2 additions & 3 deletions examples/getOutsideCollaborators.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.orgs.getOutsideCollaborators({
octokit.orgs.getOutsideCollaborators({
org: 'octokit'
})
7 changes: 3 additions & 4 deletions examples/getPullRequestReview.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.pullRequests.getReviews({
octokit.pullRequests.getReviews({
owner: 'octokit',
repo: 'rest.js',
number: 640
Expand All @@ -12,7 +11,7 @@ github.pullRequests.getReviews({
.then(result => {
const firstReviewId = result.data[0].id

return github.pullRequests.getReview({
return octokit.pullRequests.getReview({
owner: 'octokit',
repo: 'rest.js',
number: 640,
Expand Down
5 changes: 2 additions & 3 deletions examples/getPullRequestReviews.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.pullRequests.getReviews({
octokit.pullRequests.getReviews({
owner: 'octokit',
repo: 'rest.js',
number: 1
Expand Down
5 changes: 2 additions & 3 deletions examples/getRawBlob.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: false,
headers: {
'Accept': 'application/vnd.github.v3.raw'
}
})

github.gitdata.getBlob({
octokit.gitdata.getBlob({
owner: 'octokit',
repo: 'rest.js',
sha: 'b361f529df9b49f2a6b5748b5d71b792c8383e5e'
Expand Down
5 changes: 2 additions & 3 deletions examples/getReactionsForIssue.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.reactions.getForIssue({
octokit.reactions.getForIssue({
owner: 'octokit',
repo: 'rest.js',
number: '365'
Expand Down
5 changes: 2 additions & 3 deletions examples/getReference.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.gitdata.getReference({
octokit.gitdata.getReference({
owner: 'octokit',
repo: 'rest.js',
ref: 'heads/master'
Expand Down
5 changes: 2 additions & 3 deletions examples/getReferences.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.gitdata.getReferences({
octokit.gitdata.getReferences({
owner: 'octokit',
repo: 'rest.js'
})
9 changes: 4 additions & 5 deletions examples/getReleaseAsset.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.repos.getReleases({
octokit.repos.getReleases({
owner: 'octokit',
repo: 'rest.js'
})
Expand All @@ -16,7 +15,7 @@ github.repos.getReleases({

// get id of first release
const firstRelease = result.data.pop()
return github.repos.getAssets({
return octokit.repos.getAssets({
owner: 'octokit',
repo: 'rest.js',
id: firstRelease.id
Expand All @@ -31,7 +30,7 @@ github.repos.getReleases({

// get id of first asset
const assetId = result.data[0].id
return github.repos.getAsset({
return octokit.repos.getAsset({
owner: 'octokit',
repo: 'rest.js',
id: assetId
Expand Down
7 changes: 3 additions & 4 deletions examples/getRepos.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.authenticate({
octokit.authenticate({
type: 'oauth',
token: 'add-your-real-token-here'
})

github.repos.getAll({
octokit.repos.getAll({
'affiliation': 'owner,organization_member'
})
5 changes: 2 additions & 3 deletions examples/getStarred.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.activity.getStarredRepos({per_page: 100})
octokit.activity.getStarredRepos({per_page: 100})
5 changes: 2 additions & 3 deletions examples/getTimeline.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.issues.getEventsTimeline({
octokit.issues.getEventsTimeline({
owner: 'octokit',
repo: 'rest.js',
issue_number: '447'
Expand Down
5 changes: 2 additions & 3 deletions examples/getUser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.users.get({})
octokit.users.get({})
5 changes: 2 additions & 3 deletions examples/getUserById.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.users.getById({ id: '429706' })
octokit.users.getById({ id: '429706' })
5 changes: 2 additions & 3 deletions examples/getUserOrgs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const GitHubApi = require('@octokit/rest')
const github = new GitHubApi({
const octokit = require('@octokit/rest')({
debug: true
})

github.orgs.getForUser({
octokit.orgs.getForUser({
username: 'defunkt'
})
Loading

0 comments on commit 5a7e697

Please sign in to comment.