mirror of
https://code.forgejo.org/actions/setup-node
synced 2025-05-09 00:22:36 +00:00
Add auth support (#21)
* Updates * Update * Update * Update * Update * Yarn sometimes prefers npmrc, so use same token * Description * Update readme * Feedback * Add type * new toolkit and scoped registries * npmrc in RUNNER_TEMP * Dont always auth * Try exporting blank token * Get auth working for now pending runner changes * Fix string interpolation for auth token. * Don't export both userconfigs * Update authutil.js * Add single quotes for authString * Fix the registry string. * Use userconfig and append trailing slash * Keep in root of repo * Try just adding auth token * Remove auth token * Try changes again * Add tests * Npm and GPR samples * Add types
This commit is contained in:
parent
0675b87d74
commit
78148dae50
391 changed files with 79848 additions and 43 deletions
36
node_modules/octokit-pagination-methods/.travis.yml
generated
vendored
Normal file
36
node_modules/octokit-pagination-methods/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
language: node_js
|
||||
cache:
|
||||
directories:
|
||||
- ~/.npm
|
||||
|
||||
# Trigger a push build on master and greenkeeper branches + PRs build on every branches
|
||||
# Avoid double build on PRs (See https://github.com/travis-ci/travis-ci/issues/1147)
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- /^greenkeeper.*$/
|
||||
|
||||
branches:
|
||||
except:
|
||||
- /^v\d+\.\d+\.\d+$/
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- stage: test
|
||||
node_js: 6
|
||||
- node_js: 8
|
||||
install: npm ci
|
||||
- node_js: 10
|
||||
install: npm ci
|
||||
- node_js: lts/*
|
||||
script: npm run coverage:upload
|
||||
- stage: release
|
||||
env: semantic-release
|
||||
node_js: lts/*
|
||||
install: npm ci
|
||||
script: npm run semantic-release
|
||||
|
||||
stages:
|
||||
- test
|
||||
- name: release
|
||||
if: branch = master AND type IN (push)
|
46
node_modules/octokit-pagination-methods/CODE_OF_CONDUCT.md
generated
vendored
Normal file
46
node_modules/octokit-pagination-methods/CODE_OF_CONDUCT.md
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at opensource+octokit@github.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
22
node_modules/octokit-pagination-methods/LICENSE
generated
vendored
Normal file
22
node_modules/octokit-pagination-methods/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
The MIT License
|
||||
|
||||
Copyright (c) 2012 Cloud9 IDE, Inc. (Mike de Boer)
|
||||
Copyright (c) 2017-2018 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
42
node_modules/octokit-pagination-methods/README.md
generated
vendored
Normal file
42
node_modules/octokit-pagination-methods/README.md
generated
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
# octokit-pagination-methods
|
||||
|
||||
> Legacy Octokit pagination methods from v15
|
||||
|
||||
[](https://travis-ci.com/gr2m/octokit-pagination-methods)
|
||||
[](https://coveralls.io/github/gr2m/octokit-pagination-methods?branch=master)
|
||||
[](https://greenkeeper.io/)
|
||||
|
||||
Several pagination methods such as `octokit.hasNextPage()` and `octokit.getNextPage()` have been removed from `@octokit/request` in v16.0.0 in favor of `octokit.paginate()`. This plugin brings back the methods to ease the upgrade to v16.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const Octokit = require('@octokit/rest')
|
||||
.plugin('octokit-pagination-methods')
|
||||
const octokit = new Octokit()
|
||||
|
||||
octokit.issues.getForRepo()
|
||||
|
||||
.then(async response => {
|
||||
// returns true/false
|
||||
octokit.hasNextPage(response)
|
||||
octokit.hasPreviousPage(response)
|
||||
octokit.hasFirstPage(response)
|
||||
octokit.hasLastPage(response)
|
||||
|
||||
// fetch other pages
|
||||
const nextPage = await octokit.getNextPage(response)
|
||||
const previousPage = await octokit.getPreviousPage(response)
|
||||
const firstPage = await octokit.getFirstPage(response)
|
||||
const lastPage = await octokit.getLastPage(response)
|
||||
})
|
||||
```
|
||||
|
||||
## Credit
|
||||
|
||||
These methods have originally been created for `node-github` by [@mikedeboer](https://github.com/mikedeboer)
|
||||
while working at Cloud9 IDE, Inc. It was adopted and renamed by GitHub in 2017.
|
||||
|
||||
## LICENSE
|
||||
|
||||
[MIT](LICENSE)
|
12
node_modules/octokit-pagination-methods/index.js
generated
vendored
Normal file
12
node_modules/octokit-pagination-methods/index.js
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
module.exports = paginationMethodsPlugin
|
||||
|
||||
function paginationMethodsPlugin (octokit) {
|
||||
octokit.getFirstPage = require('./lib/get-first-page').bind(null, octokit)
|
||||
octokit.getLastPage = require('./lib/get-last-page').bind(null, octokit)
|
||||
octokit.getNextPage = require('./lib/get-next-page').bind(null, octokit)
|
||||
octokit.getPreviousPage = require('./lib/get-previous-page').bind(null, octokit)
|
||||
octokit.hasFirstPage = require('./lib/has-first-page')
|
||||
octokit.hasLastPage = require('./lib/has-last-page')
|
||||
octokit.hasNextPage = require('./lib/has-next-page')
|
||||
octokit.hasPreviousPage = require('./lib/has-previous-page')
|
||||
}
|
12
node_modules/octokit-pagination-methods/lib/deprecate.js
generated
vendored
Normal file
12
node_modules/octokit-pagination-methods/lib/deprecate.js
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
module.exports = deprecate
|
||||
|
||||
const loggedMessages = {}
|
||||
|
||||
function deprecate (message) {
|
||||
if (loggedMessages[message]) {
|
||||
return
|
||||
}
|
||||
|
||||
console.warn(`DEPRECATED (@octokit/rest): ${message}`)
|
||||
loggedMessages[message] = 1
|
||||
}
|
7
node_modules/octokit-pagination-methods/lib/get-first-page.js
generated
vendored
Normal file
7
node_modules/octokit-pagination-methods/lib/get-first-page.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
module.exports = getFirstPage
|
||||
|
||||
const getPage = require('./get-page')
|
||||
|
||||
function getFirstPage (octokit, link, headers) {
|
||||
return getPage(octokit, link, 'first', headers)
|
||||
}
|
7
node_modules/octokit-pagination-methods/lib/get-last-page.js
generated
vendored
Normal file
7
node_modules/octokit-pagination-methods/lib/get-last-page.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
module.exports = getLastPage
|
||||
|
||||
const getPage = require('./get-page')
|
||||
|
||||
function getLastPage (octokit, link, headers) {
|
||||
return getPage(octokit, link, 'last', headers)
|
||||
}
|
7
node_modules/octokit-pagination-methods/lib/get-next-page.js
generated
vendored
Normal file
7
node_modules/octokit-pagination-methods/lib/get-next-page.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
module.exports = getNextPage
|
||||
|
||||
const getPage = require('./get-page')
|
||||
|
||||
function getNextPage (octokit, link, headers) {
|
||||
return getPage(octokit, link, 'next', headers)
|
||||
}
|
15
node_modules/octokit-pagination-methods/lib/get-page-links.js
generated
vendored
Normal file
15
node_modules/octokit-pagination-methods/lib/get-page-links.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
module.exports = getPageLinks
|
||||
|
||||
function getPageLinks (link) {
|
||||
link = link.link || link.headers.link || ''
|
||||
|
||||
const links = {}
|
||||
|
||||
// link format:
|
||||
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"'
|
||||
link.replace(/<([^>]*)>;\s*rel="([\w]*)"/g, (m, uri, type) => {
|
||||
links[type] = uri
|
||||
})
|
||||
|
||||
return links
|
||||
}
|
38
node_modules/octokit-pagination-methods/lib/get-page.js
generated
vendored
Normal file
38
node_modules/octokit-pagination-methods/lib/get-page.js
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
module.exports = getPage
|
||||
|
||||
const deprecate = require('./deprecate')
|
||||
const getPageLinks = require('./get-page-links')
|
||||
const HttpError = require('./http-error')
|
||||
|
||||
function getPage (octokit, link, which, headers) {
|
||||
deprecate(`octokit.get${which.charAt(0).toUpperCase() + which.slice(1)}Page() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`)
|
||||
const url = getPageLinks(link)[which]
|
||||
|
||||
if (!url) {
|
||||
const urlError = new HttpError(`No ${which} page found`, 404)
|
||||
return Promise.reject(urlError)
|
||||
}
|
||||
|
||||
const requestOptions = {
|
||||
url,
|
||||
headers: applyAcceptHeader(link, headers)
|
||||
}
|
||||
|
||||
const promise = octokit.request(requestOptions)
|
||||
|
||||
return promise
|
||||
}
|
||||
|
||||
function applyAcceptHeader (res, headers) {
|
||||
const previous = res.headers && res.headers['x-github-media-type']
|
||||
|
||||
if (!previous || (headers && headers.accept)) {
|
||||
return headers
|
||||
}
|
||||
headers = headers || {}
|
||||
headers.accept = 'application/vnd.' + previous
|
||||
.replace('; param=', '.')
|
||||
.replace('; format=', '+')
|
||||
|
||||
return headers
|
||||
}
|
7
node_modules/octokit-pagination-methods/lib/get-previous-page.js
generated
vendored
Normal file
7
node_modules/octokit-pagination-methods/lib/get-previous-page.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
module.exports = getPreviousPage
|
||||
|
||||
const getPage = require('./get-page')
|
||||
|
||||
function getPreviousPage (octokit, link, headers) {
|
||||
return getPage(octokit, link, 'prev', headers)
|
||||
}
|
9
node_modules/octokit-pagination-methods/lib/has-first-page.js
generated
vendored
Normal file
9
node_modules/octokit-pagination-methods/lib/has-first-page.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
module.exports = hasFirstPage
|
||||
|
||||
const deprecate = require('./deprecate')
|
||||
const getPageLinks = require('./get-page-links')
|
||||
|
||||
function hasFirstPage (link) {
|
||||
deprecate(`octokit.hasFirstPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`)
|
||||
return getPageLinks(link).first
|
||||
}
|
9
node_modules/octokit-pagination-methods/lib/has-last-page.js
generated
vendored
Normal file
9
node_modules/octokit-pagination-methods/lib/has-last-page.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
module.exports = hasLastPage
|
||||
|
||||
const deprecate = require('./deprecate')
|
||||
const getPageLinks = require('./get-page-links')
|
||||
|
||||
function hasLastPage (link) {
|
||||
deprecate(`octokit.hasLastPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`)
|
||||
return getPageLinks(link).last
|
||||
}
|
9
node_modules/octokit-pagination-methods/lib/has-next-page.js
generated
vendored
Normal file
9
node_modules/octokit-pagination-methods/lib/has-next-page.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
module.exports = hasNextPage
|
||||
|
||||
const deprecate = require('./deprecate')
|
||||
const getPageLinks = require('./get-page-links')
|
||||
|
||||
function hasNextPage (link) {
|
||||
deprecate(`octokit.hasNextPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`)
|
||||
return getPageLinks(link).next
|
||||
}
|
9
node_modules/octokit-pagination-methods/lib/has-previous-page.js
generated
vendored
Normal file
9
node_modules/octokit-pagination-methods/lib/has-previous-page.js
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
module.exports = hasPreviousPage
|
||||
|
||||
const deprecate = require('./deprecate')
|
||||
const getPageLinks = require('./get-page-links')
|
||||
|
||||
function hasPreviousPage (link) {
|
||||
deprecate(`octokit.hasPreviousPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`)
|
||||
return getPageLinks(link).prev
|
||||
}
|
15
node_modules/octokit-pagination-methods/lib/http-error.js
generated
vendored
Normal file
15
node_modules/octokit-pagination-methods/lib/http-error.js
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
module.exports = class HttpError extends Error {
|
||||
constructor (message, code, headers) {
|
||||
super(message)
|
||||
|
||||
// Maintains proper stack trace (only available on V8)
|
||||
/* istanbul ignore next */
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor)
|
||||
}
|
||||
|
||||
this.name = 'HttpError'
|
||||
this.code = code
|
||||
this.headers = headers
|
||||
}
|
||||
}
|
76
node_modules/octokit-pagination-methods/package.json
generated
vendored
Normal file
76
node_modules/octokit-pagination-methods/package.json
generated
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
{
|
||||
"_from": "octokit-pagination-methods@^1.1.0",
|
||||
"_id": "octokit-pagination-methods@1.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-fZ4qZdQ2nxJvtcasX7Ghl+WlWS/d9IgnBIwFZXVNNZUmzpno91SX5bc5vuxiuKoCtK78XxGGNuSCrDC7xYB3OQ==",
|
||||
"_location": "/octokit-pagination-methods",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "octokit-pagination-methods@^1.1.0",
|
||||
"name": "octokit-pagination-methods",
|
||||
"escapedName": "octokit-pagination-methods",
|
||||
"rawSpec": "^1.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@octokit/rest"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/octokit-pagination-methods/-/octokit-pagination-methods-1.1.0.tgz",
|
||||
"_shasum": "cf472edc9d551055f9ef73f6e42b4dbb4c80bea4",
|
||||
"_spec": "octokit-pagination-methods@^1.1.0",
|
||||
"_where": "C:\\Users\\Administrator\\Documents\\setup-node\\node_modules\\@octokit\\rest",
|
||||
"author": {
|
||||
"name": "Gregor Martynus",
|
||||
"url": "https://github.com/gr2m"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/gr2m/octokit-pagination-methods/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "Legacy Octokit pagination methods from v15",
|
||||
"devDependencies": {
|
||||
"@octokit/rest": "github:octokit/rest.js#next",
|
||||
"coveralls": "^3.0.2",
|
||||
"nock": "^10.0.2",
|
||||
"semantic-release": "^15.10.8",
|
||||
"simple-mock": "^0.8.0",
|
||||
"standard": "^12.0.1",
|
||||
"standard-markdown": "^5.0.1",
|
||||
"tap": "^12.0.1"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"homepage": "https://github.com/gr2m/octokit-pagination-methods#readme",
|
||||
"keywords": [
|
||||
"octokit",
|
||||
"github",
|
||||
"api",
|
||||
"rest",
|
||||
"plugin"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "octokit-pagination-methods",
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"tag": "latest"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/gr2m/octokit-pagination-methods.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "tap --coverage-report=html",
|
||||
"coverage:upload": "npm run test && tap --coverage-report=text-lcov | coveralls",
|
||||
"pretest": "standard && standard-markdown *.md",
|
||||
"semantic-release": "semantic-release",
|
||||
"test": "tap --coverage test.js"
|
||||
},
|
||||
"version": "1.1.0"
|
||||
}
|
93
node_modules/octokit-pagination-methods/test.js
generated
vendored
Normal file
93
node_modules/octokit-pagination-methods/test.js
generated
vendored
Normal file
|
@ -0,0 +1,93 @@
|
|||
const test = require('tap').test
|
||||
const nock = require('nock')
|
||||
|
||||
const Octokit = require('@octokit/rest')
|
||||
.plugin(require('.'))
|
||||
|
||||
test('@octokit/pagination-methods', (t) => {
|
||||
nock('https://api.github.com', {
|
||||
reqheaders: {
|
||||
authorization: 'token secrettoken123'
|
||||
}
|
||||
})
|
||||
.get('/organizations')
|
||||
.query({ page: 3, per_page: 1 })
|
||||
.reply(200, [{}], {
|
||||
'Link': '<https://api.github.com/organizations?page=4&per_page=1>; rel="next", <https://api.github.com/organizations?page=1&per_page=1>; rel="first", <https://api.github.com/organizations?page=2&per_page=1>; rel="prev"',
|
||||
'X-GitHub-Media-Type': 'octokit.v3; format=json'
|
||||
})
|
||||
.get('/organizations')
|
||||
.query({ page: 1, per_page: 1 })
|
||||
.reply(200, [{}])
|
||||
.get('/organizations')
|
||||
.query({ page: 2, per_page: 1 })
|
||||
.reply(200, [{}])
|
||||
.get('/organizations')
|
||||
.query({ page: 4, per_page: 1 })
|
||||
.reply(404, {})
|
||||
|
||||
const octokit = new Octokit()
|
||||
|
||||
octokit.authenticate({
|
||||
type: 'token',
|
||||
token: 'secrettoken123'
|
||||
})
|
||||
|
||||
return octokit.orgs.getAll({
|
||||
page: 3,
|
||||
per_page: 1
|
||||
})
|
||||
|
||||
.then((response) => {
|
||||
t.ok(octokit.hasNextPage(response))
|
||||
t.ok(octokit.hasPreviousPage(response))
|
||||
t.ok(octokit.hasFirstPage(response))
|
||||
t.notOk(octokit.hasLastPage(response))
|
||||
|
||||
const noop = () => {}
|
||||
|
||||
return Promise.all([
|
||||
octokit.getFirstPage(response)
|
||||
.then(response => {
|
||||
t.doesNotThrow(() => {
|
||||
octokit.hasPreviousPage(response)
|
||||
})
|
||||
t.notOk(octokit.hasPreviousPage(response))
|
||||
}),
|
||||
octokit.getPreviousPage(response, { foo: 'bar', accept: 'application/vnd.octokit.v3+json' }),
|
||||
octokit.getNextPage(response).catch(noop),
|
||||
octokit.getLastPage(response, { foo: 'bar' })
|
||||
.catch(error => {
|
||||
t.equals(error.code, 404)
|
||||
}),
|
||||
// test error with promise
|
||||
octokit.getLastPage(response).catch(noop)
|
||||
])
|
||||
})
|
||||
|
||||
.catch(t.error)
|
||||
})
|
||||
|
||||
test('carries accept header correctly', () => {
|
||||
nock('https://api.github.com', {
|
||||
reqheaders: {
|
||||
accept: 'application/vnd.github.hellcat-preview+json'
|
||||
}
|
||||
})
|
||||
.get('/user/teams')
|
||||
.query({ per_page: 1 })
|
||||
.reply(200, [{}], {
|
||||
'Link': '<https://api.github.com/user/teams?page=2&per_page=1>; rel="next"',
|
||||
'X-GitHub-Media-Type': 'github; param=hellcat-preview; format=json'
|
||||
})
|
||||
.get('/user/teams')
|
||||
.query({ page: 2, per_page: 1 })
|
||||
.reply(200, [])
|
||||
|
||||
const octokit = new Octokit()
|
||||
|
||||
return octokit.users.getTeams({ per_page: 1 })
|
||||
.then(response => {
|
||||
return octokit.getNextPage(response)
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue