first commit

This commit is contained in:
tbushman
2018-10-29 19:41:46 -06:00
committed by mrugesh mohapatra
parent d341b9c45e
commit 5bb3556bfd
14042 changed files with 1580673 additions and 0 deletions

View File

@ -0,0 +1,9 @@
# The ID of your GitHub App
APP_ID=
WEBHOOK_SECRET=development
# Use `trace` to get verbose logging or `info` to show less
LOG_LEVEL=debug
# Go to https://smee.io/new set this to the URL that you are redirected to.
WEBHOOK_PROXY_URL=

2
probot/presolver/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.env
.git

View File

@ -0,0 +1,74 @@
# 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,
education, socio-economic status, 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 tbushman@pu.bli.sh. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and 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 https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org

View File

@ -0,0 +1,41 @@
## Contributing
[fork]: /fork
[pr]: /compare
[style]: https://standardjs.com/
[code-of-conduct]: CODE_OF_CONDUCT.md
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.
## Issues and PRs
If you have suggestions for how this project could be improved, or want to report a bug, open an issue! We'd love all and any contributions. If you have questions, too, we'd love to hear them.
We'd also love PRs. If you're thinking of a large PR, we advise opening up an issue first to talk about it, though! Look at the links below if you're not sure how to open a PR.
## Submitting a pull request
1. [Fork][fork] and clone the repository.
1. Configure and install the dependencies: `npm install`.
1. Make sure the tests pass on your machine: `npm test`, note: these tests also apply the linter, so there's no need to lint separately.
1. Create a new branch: `git checkout -b my-branch-name`.
1. Make your change, add tests, and make sure the tests still pass.
1. Push to your fork and [submit a pull request][pr].
1. Pat your self on the back and wait for your pull request to be reviewed and merged.
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
- Follow the [style guide][style] which is using standard. Any linting errors should be shown when running `npm test`.
- Write and update tests.
- Keep your changes as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
Work in Progress pull requests are also welcome to get feedback early on, or if there is something blocked you.
## Resources
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
- [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
- [GitHub Help](https://help.github.com)

15
probot/presolver/LICENSE Normal file
View File

@ -0,0 +1,15 @@
ISC License
Copyright (c) 2018, tbushman <tbushman@pu.bli.sh>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@ -0,0 +1,23 @@
# presolver
> A GitHub App built with [Probot](https://github.com/probot/probot) that A Probot app
## Setup
```sh
# Install dependencies
npm install
# Run the bot
npm start
```
## Contributing
If you have suggestions for how presolver could be improved, or want to report a bug, open an issue! We'd love all and any contributions.
For more, check out the [Contributing Guide](CONTRIBUTING.md).
## License
[ISC](LICENSE) © 2018 tbushman <tbushman@pu.bli.sh>

139
probot/presolver/app.yml Normal file
View File

@ -0,0 +1,139 @@
# This is a GitHub App Manifest. These settings will be used by default when
# initially configuring your GitHub App.
#
# NOTE: changing this file will not update your GitHub App settings.
# You must visit github.com/settings/apps/your-app-name to edit them.
#
# Read more about configuring your GitHub App:
# https://probot.github.io/docs/development/#configuring-a-github-app
#
# Read more about GitHub App Manifests:
# https://developer.github.com/apps/building-github-apps/creating-github-apps-from-a-manifest/
# The list of events the GitHub App subscribes to.
# Uncomment the event names below to enable them.
default_events:
# - check_run
# - check_suite
# - commit_comment
# - create
# - delete
# - deployment
# - deployment_status
# - fork
# - gollum
# - issue_comment
- issues
# - label
# - milestone
# - member
# - membership
# - org_block
# - organization
# - page_build
# - project
# - project_card
# - project_column
# - public
# - pull_request
# - pull_request_review
# - pull_request_review_comment
# - push
# - release
# - repository
# - repository_import
# - status
# - team
# - team_add
# - watch
# The set of permissions needed by the GitHub App. The format of the object uses
# the permission name for the key (for example, issues) and the access type for
# the value (for example, write).
# Valid values are `read`, `write`, and `none`
default_permissions:
# Repository creation, deletion, settings, teams, and collaborators.
# https://developer.github.com/v3/apps/permissions/#permission-on-administration
# administration: read
# Checks on code.
# https://developer.github.com/v3/apps/permissions/#permission-on-checks
# checks: read
# Repository contents, commits, branches, downloads, releases, and merges.
# https://developer.github.com/v3/apps/permissions/#permission-on-contents
# contents: read
# Deployments and deployment statuses.
# https://developer.github.com/v3/apps/permissions/#permission-on-deployments
# deployments: read
# Issues and related comments, assignees, labels, and milestones.
# https://developer.github.com/v3/apps/permissions/#permission-on-issues
issues: write
# Search repositories, list collaborators, and access repository metadata.
# https://developer.github.com/v3/apps/permissions/#metadata-permissions
# metadata: read
# Retrieve Pages statuses, configuration, and builds, as well as create new builds.
# https://developer.github.com/v3/apps/permissions/#permission-on-pages
# pages: read
# Pull requests and related comments, assignees, labels, milestones, and merges.
# https://developer.github.com/v3/apps/permissions/#permission-on-pull-requests
# pull_requests: read
# Manage the post-receive hooks for a repository.
# https://developer.github.com/v3/apps/permissions/#permission-on-repository-hooks
# repository_hooks: read
# Manage repository projects, columns, and cards.
# https://developer.github.com/v3/apps/permissions/#permission-on-repository-projects
# repository_projects: read
# Retrieve security vulnerability alerts.
# https://developer.github.com/v4/object/repositoryvulnerabilityalert/
# vulnerability_alerts: read
# Commit statuses.
# https://developer.github.com/v3/apps/permissions/#permission-on-statuses
# statuses: read
# Organization members and teams.
# https://developer.github.com/v3/apps/permissions/#permission-on-members
# members: read
# View and manage users blocked by the organization.
# https://developer.github.com/v3/apps/permissions/#permission-on-organization-user-blocking
# organization_user_blocking: read
# Manage organization projects, columns, and cards.
# https://developer.github.com/v3/apps/permissions/#permission-on-organization-projects
# organization_projects: read
# Manage team discussions and related comments.
# https://developer.github.com/v3/apps/permissions/#permission-on-team-discussions
# team_discussions: read
# Manage the post-receive hooks for an organization.
# https://developer.github.com/v3/apps/permissions/#permission-on-organization-hooks
# organization_hooks: read
# Get notified of, and update, content references.
# https://developer.github.com/v3/apps/permissions/
# organization_administration: read
# The name of the GitHub App. Defaults to the name specified in package.json
# name: My Probot App
# The homepage of your GitHub App.
# url: https://example.com/
# A description of the GitHub App.
# description: A description of my awesome app
# Set to true when your GitHub App is available to the public or false when it is only accessible to the owner of the app.
# Default: true
# public: false

15
probot/presolver/index.js Normal file
View File

@ -0,0 +1,15 @@
module.exports = app => {
// Your code here
app.log('Yay, the app was loaded!')
app.on('issues.opened', async context => {
const issueComment = context.issue({ body: 'Thanks for opening this issue!' })
return context.github.issues.createComment(issueComment)
})
// For more information on building apps:
// https://probot.github.io/docs/
// To get your app running against GitHub, see:
// https://probot.github.io/docs/development/
}

1
probot/presolver/node_modules/.bin/acorn generated vendored Symbolic link
View File

@ -0,0 +1 @@
../acorn/bin/acorn

1
probot/presolver/node_modules/.bin/atob generated vendored Symbolic link
View File

@ -0,0 +1 @@
../atob/bin/atob.js

1
probot/presolver/node_modules/.bin/babylon generated vendored Symbolic link
View File

@ -0,0 +1 @@
../babylon/bin/babylon.js

1
probot/presolver/node_modules/.bin/bunyan generated vendored Symbolic link
View File

@ -0,0 +1 @@
../bunyan/bin/bunyan

1
probot/presolver/node_modules/.bin/escodegen generated vendored Symbolic link
View File

@ -0,0 +1 @@
../escodegen/bin/escodegen.js

1
probot/presolver/node_modules/.bin/esgenerate generated vendored Symbolic link
View File

@ -0,0 +1 @@
../escodegen/bin/esgenerate.js

1
probot/presolver/node_modules/.bin/eslint generated vendored Symbolic link
View File

@ -0,0 +1 @@
../eslint/bin/eslint.js

1
probot/presolver/node_modules/.bin/esparse generated vendored Symbolic link
View File

@ -0,0 +1 @@
../esprima/bin/esparse.js

1
probot/presolver/node_modules/.bin/esvalidate generated vendored Symbolic link
View File

@ -0,0 +1 @@
../esprima/bin/esvalidate.js

1
probot/presolver/node_modules/.bin/handlebars generated vendored Symbolic link
View File

@ -0,0 +1 @@
../handlebars/bin/handlebars

1
probot/presolver/node_modules/.bin/import-local-fixture generated vendored Symbolic link
View File

@ -0,0 +1 @@
../import-local/fixtures/cli.js

1
probot/presolver/node_modules/.bin/is-ci generated vendored Symbolic link
View File

@ -0,0 +1 @@
../is-ci/bin.js

1
probot/presolver/node_modules/.bin/jest generated vendored Symbolic link
View File

@ -0,0 +1 @@
../jest/bin/jest.js

1
probot/presolver/node_modules/.bin/jest-runtime generated vendored Symbolic link
View File

@ -0,0 +1 @@
../jest-runtime/bin/jest-runtime.js

1
probot/presolver/node_modules/.bin/js-yaml generated vendored Symbolic link
View File

@ -0,0 +1 @@
../js-yaml/bin/js-yaml.js

1
probot/presolver/node_modules/.bin/jsesc generated vendored Symbolic link
View File

@ -0,0 +1 @@
../jsesc/bin/jsesc

1
probot/presolver/node_modules/.bin/json5 generated vendored Symbolic link
View File

@ -0,0 +1 @@
../json5/lib/cli.js

1
probot/presolver/node_modules/.bin/loose-envify generated vendored Symbolic link
View File

@ -0,0 +1 @@
../loose-envify/cli.js

1
probot/presolver/node_modules/.bin/mime generated vendored Symbolic link
View File

@ -0,0 +1 @@
../mime/cli.js

1
probot/presolver/node_modules/.bin/mkdirp generated vendored Symbolic link
View File

@ -0,0 +1 @@
../mkdirp/bin/cmd.js

1
probot/presolver/node_modules/.bin/ncp generated vendored Symbolic link
View File

@ -0,0 +1 @@
../ncp/bin/ncp

1
probot/presolver/node_modules/.bin/nodemon generated vendored Symbolic link
View File

@ -0,0 +1 @@
../nodemon/bin/nodemon.js

1
probot/presolver/node_modules/.bin/nodetouch generated vendored Symbolic link
View File

@ -0,0 +1 @@
../touch/bin/nodetouch.js

1
probot/presolver/node_modules/.bin/nopt generated vendored Symbolic link
View File

@ -0,0 +1 @@
../nopt/bin/nopt.js

1
probot/presolver/node_modules/.bin/probot generated vendored Symbolic link
View File

@ -0,0 +1 @@
../probot/bin/probot.js

1
probot/presolver/node_modules/.bin/raven generated vendored Symbolic link
View File

@ -0,0 +1 @@
../raven/bin/raven

1
probot/presolver/node_modules/.bin/rc generated vendored Symbolic link
View File

@ -0,0 +1 @@
../rc/cli.js

1
probot/presolver/node_modules/.bin/rimraf generated vendored Symbolic link
View File

@ -0,0 +1 @@
../rimraf/bin.js

1
probot/presolver/node_modules/.bin/sane generated vendored Symbolic link
View File

@ -0,0 +1 @@
../sane/src/cli.js

1
probot/presolver/node_modules/.bin/semver generated vendored Symbolic link
View File

@ -0,0 +1 @@
../semver/bin/semver

1
probot/presolver/node_modules/.bin/shjs generated vendored Symbolic link
View File

@ -0,0 +1 @@
../shelljs/bin/shjs

1
probot/presolver/node_modules/.bin/smee generated vendored Symbolic link
View File

@ -0,0 +1 @@
../smee-client/bin/smee.js

1
probot/presolver/node_modules/.bin/sshpk-conv generated vendored Symbolic link
View File

@ -0,0 +1 @@
../sshpk/bin/sshpk-conv

1
probot/presolver/node_modules/.bin/sshpk-sign generated vendored Symbolic link
View File

@ -0,0 +1 @@
../sshpk/bin/sshpk-sign

1
probot/presolver/node_modules/.bin/sshpk-verify generated vendored Symbolic link
View File

@ -0,0 +1 @@
../sshpk/bin/sshpk-verify

1
probot/presolver/node_modules/.bin/standard generated vendored Symbolic link
View File

@ -0,0 +1 @@
../standard/bin/cmd.js

1
probot/presolver/node_modules/.bin/uglifyjs generated vendored Symbolic link
View File

@ -0,0 +1 @@
../uglify-js/bin/uglifyjs

1
probot/presolver/node_modules/.bin/uuid generated vendored Symbolic link
View File

@ -0,0 +1 @@
../uuid/bin/uuid

1
probot/presolver/node_modules/.bin/watch generated vendored Symbolic link
View File

@ -0,0 +1 @@
../watch/cli.js

1
probot/presolver/node_modules/.bin/which generated vendored Symbolic link
View File

@ -0,0 +1 @@
../which/bin/which

View File

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-2018 Sebastian McKenzie <sebmck@gmail.com>
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.

View File

@ -0,0 +1,19 @@
# @babel/code-frame
> Generate errors that contain a code frame that point to source locations.
See our website [@babel/code-frame](https://babeljs.io/docs/en/next/babel-code-frame.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/code-frame
```
or using yarn:
```sh
yarn add @babel/code-frame --dev
```

View File

@ -0,0 +1,173 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.codeFrameColumns = codeFrameColumns;
exports.default = _default;
function _highlight() {
const data = _interopRequireWildcard(require("@babel/highlight"));
_highlight = function () {
return data;
};
return data;
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
let deprecationWarningShown = false;
function getDefs(chalk) {
return {
gutter: chalk.grey,
marker: chalk.red.bold,
message: chalk.red.bold
};
}
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
function getMarkerLines(loc, source, opts) {
const startLoc = Object.assign({
column: 0,
line: -1
}, loc.start);
const endLoc = Object.assign({}, startLoc, loc.end);
const {
linesAbove = 2,
linesBelow = 3
} = opts || {};
const startLine = startLoc.line;
const startColumn = startLoc.column;
const endLine = endLoc.line;
const endColumn = endLoc.column;
let start = Math.max(startLine - (linesAbove + 1), 0);
let end = Math.min(source.length, endLine + linesBelow);
if (startLine === -1) {
start = 0;
}
if (endLine === -1) {
end = source.length;
}
const lineDiff = endLine - startLine;
const markerLines = {};
if (lineDiff) {
for (let i = 0; i <= lineDiff; i++) {
const lineNumber = i + startLine;
if (!startColumn) {
markerLines[lineNumber] = true;
} else if (i === 0) {
const sourceLength = source[lineNumber - 1].length;
markerLines[lineNumber] = [startColumn, sourceLength - startColumn];
} else if (i === lineDiff) {
markerLines[lineNumber] = [0, endColumn];
} else {
const sourceLength = source[lineNumber - i].length;
markerLines[lineNumber] = [0, sourceLength];
}
}
} else {
if (startColumn === endColumn) {
if (startColumn) {
markerLines[startLine] = [startColumn, 0];
} else {
markerLines[startLine] = true;
}
} else {
markerLines[startLine] = [startColumn, endColumn - startColumn];
}
}
return {
start,
end,
markerLines
};
}
function codeFrameColumns(rawLines, loc, opts = {}) {
const highlighted = (opts.highlightCode || opts.forceColor) && (0, _highlight().shouldHighlight)(opts);
const chalk = (0, _highlight().getChalk)(opts);
const defs = getDefs(chalk);
const maybeHighlight = (chalkFn, string) => {
return highlighted ? chalkFn(string) : string;
};
if (highlighted) rawLines = (0, _highlight().default)(rawLines, opts);
const lines = rawLines.split(NEWLINE);
const {
start,
end,
markerLines
} = getMarkerLines(loc, lines, opts);
const hasColumns = loc.start && typeof loc.start.column === "number";
const numberMaxWidth = String(end).length;
let frame = lines.slice(start, end).map((line, index) => {
const number = start + 1 + index;
const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
const gutter = ` ${paddedNumber} | `;
const hasMarker = markerLines[number];
const lastMarkerLine = !markerLines[number + 1];
if (hasMarker) {
let markerLine = "";
if (Array.isArray(hasMarker)) {
const markerSpacing = line.slice(0, Math.max(hasMarker[0] - 1, 0)).replace(/[^\t]/g, " ");
const numberOfMarkers = hasMarker[1] || 1;
markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^").repeat(numberOfMarkers)].join("");
if (lastMarkerLine && opts.message) {
markerLine += " " + maybeHighlight(defs.message, opts.message);
}
}
return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join("");
} else {
return ` ${maybeHighlight(defs.gutter, gutter)}${line}`;
}
}).join("\n");
if (opts.message && !hasColumns) {
frame = `${" ".repeat(numberMaxWidth + 1)}${opts.message}\n${frame}`;
}
if (highlighted) {
return chalk.reset(frame);
} else {
return frame;
}
}
function _default(rawLines, lineNumber, colNumber, opts = {}) {
if (!deprecationWarningShown) {
deprecationWarningShown = true;
const message = "Passing lineNumber and colNumber is deprecated to @babel/code-frame. Please use `codeFrameColumns`.";
if (process.emitWarning) {
process.emitWarning(message, "DeprecationWarning");
} else {
const deprecationError = new Error(message);
deprecationError.name = "DeprecationWarning";
console.warn(new Error(message));
}
}
colNumber = Math.max(colNumber, 0);
const location = {
start: {
column: colNumber,
line: lineNumber
}
};
return codeFrameColumns(rawLines, location, opts);
}

View File

@ -0,0 +1,49 @@
{
"_from": "@babel/code-frame@^7.0.0-beta.35",
"_id": "@babel/code-frame@7.0.0",
"_inBundle": false,
"_integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==",
"_location": "/@babel/code-frame",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/code-frame@^7.0.0-beta.35",
"name": "@babel/code-frame",
"escapedName": "@babel%2fcode-frame",
"scope": "@babel",
"rawSpec": "^7.0.0-beta.35",
"saveSpec": null,
"fetchSpec": "^7.0.0-beta.35"
},
"_requiredBy": [
"/jest-message-util"
],
"_resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz",
"_shasum": "06e2ab19bdb535385559aabb5ba59729482800f8",
"_spec": "@babel/code-frame@^7.0.0-beta.35",
"_where": "/Users/traceybushman/Documents/FreeCodeCamp/presolver/node_modules/jest-message-util",
"author": {
"name": "Sebastian McKenzie",
"email": "sebmck@gmail.com"
},
"bundleDependencies": false,
"dependencies": {
"@babel/highlight": "^7.0.0"
},
"deprecated": false,
"description": "Generate errors that contain a code frame that point to source locations.",
"devDependencies": {
"chalk": "^2.0.0",
"strip-ansi": "^4.0.0"
},
"homepage": "https://babeljs.io/",
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/code-frame",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-code-frame"
},
"version": "7.0.0"
}

22
probot/presolver/node_modules/@babel/highlight/LICENSE generated vendored Normal file
View File

@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-2018 Sebastian McKenzie <sebmck@gmail.com>
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.

View File

@ -0,0 +1,19 @@
# @babel/highlight
> Syntax highlight JavaScript strings for output in terminals.
See our website [@babel/highlight](https://babeljs.io/docs/en/next/babel-highlight.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/highlight
```
or using yarn:
```sh
yarn add @babel/highlight --dev
```

View File

@ -0,0 +1,129 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.shouldHighlight = shouldHighlight;
exports.getChalk = getChalk;
exports.default = highlight;
function _jsTokens() {
const data = _interopRequireWildcard(require("js-tokens"));
_jsTokens = function () {
return data;
};
return data;
}
function _esutils() {
const data = _interopRequireDefault(require("esutils"));
_esutils = function () {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require("chalk"));
_chalk = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function getDefs(chalk) {
return {
keyword: chalk.cyan,
capitalized: chalk.yellow,
jsx_tag: chalk.yellow,
punctuator: chalk.yellow,
number: chalk.magenta,
string: chalk.green,
regex: chalk.magenta,
comment: chalk.grey,
invalid: chalk.white.bgRed.bold
};
}
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
const JSX_TAG = /^[a-z][\w-]*$/i;
const BRACKET = /^[()[\]{}]$/;
function getTokenType(match) {
const [offset, text] = match.slice(-2);
const token = (0, _jsTokens().matchToToken)(match);
if (token.type === "name") {
if (_esutils().default.keyword.isReservedWordES6(token.value)) {
return "keyword";
}
if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) {
return "jsx_tag";
}
if (token.value[0] !== token.value[0].toLowerCase()) {
return "capitalized";
}
}
if (token.type === "punctuator" && BRACKET.test(token.value)) {
return "bracket";
}
if (token.type === "invalid" && (token.value === "@" || token.value === "#")) {
return "punctuator";
}
return token.type;
}
function highlightTokens(defs, text) {
return text.replace(_jsTokens().default, function (...args) {
const type = getTokenType(args);
const colorize = defs[type];
if (colorize) {
return args[0].split(NEWLINE).map(str => colorize(str)).join("\n");
} else {
return args[0];
}
});
}
function shouldHighlight(options) {
return _chalk().default.supportsColor || options.forceColor;
}
function getChalk(options) {
let chalk = _chalk().default;
if (options.forceColor) {
chalk = new (_chalk().default.constructor)({
enabled: true,
level: 1
});
}
return chalk;
}
function highlight(code, options = {}) {
if (shouldHighlight(options)) {
const chalk = getChalk(options);
const defs = getDefs(chalk);
return highlightTokens(defs, code);
} else {
return code;
}
}

View File

@ -0,0 +1,151 @@
### Version 4.0.0 (2018-01-28) ###
- Added: Support for ES2018. The only change needed was recognizing the `s`
regex flag.
- Changed: _All_ tokens returned by the `matchToToken` function now have a
`closed` property. It is set to `undefined` for the tokens where “closed”
doesnt make sense. This means that all tokens objects have the same shape,
which might improve performance.
These are the breaking changes:
- `'/a/s'.match(jsTokens)` no longer returns `['/', 'a', '/', 's']`, but
`['/a/s']`. (There are of course other variations of this.)
- Code that rely on some token objects not having the `closed` property could
now behave differently.
### Version 3.0.2 (2017-06-28) ###
- No code changes. Just updates to the readme.
### Version 3.0.1 (2017-01-30) ###
- Fixed: ES2015 unicode escapes with more than 6 hex digits are now matched
correctly.
### Version 3.0.0 (2017-01-11) ###
This release contains one breaking change, that should [improve performance in
V8][v8-perf]:
> So how can you, as a JavaScript developer, ensure that your RegExps are fast?
> If you are not interested in hooking into RegExp internals, make sure that
> neither the RegExp instance, nor its prototype is modified in order to get the
> best performance:
>
> ```js
> var re = /./g;
> re.exec(''); // Fast path.
> re.new_property = 'slow';
> ```
This module used to export a single regex, with `.matchToToken` bolted
on, just like in the above example. This release changes the exports of
the module to avoid this issue.
Before:
```js
import jsTokens from "js-tokens"
// or:
var jsTokens = require("js-tokens")
var matchToToken = jsTokens.matchToToken
```
After:
```js
import jsTokens, {matchToToken} from "js-tokens"
// or:
var jsTokens = require("js-tokens").default
var matchToToken = require("js-tokens").matchToToken
```
[v8-perf]: http://v8project.blogspot.se/2017/01/speeding-up-v8-regular-expressions.html
### Version 2.0.0 (2016-06-19) ###
- Added: Support for ES2016. In other words, support for the `**` exponentiation
operator.
These are the breaking changes:
- `'**'.match(jsTokens)` no longer returns `['*', '*']`, but `['**']`.
- `'**='.match(jsTokens)` no longer returns `['*', '*=']`, but `['**=']`.
### Version 1.0.3 (2016-03-27) ###
- Improved: Made the regex ever so slightly smaller.
- Updated: The readme.
### Version 1.0.2 (2015-10-18) ###
- Improved: Limited npm package contents for a smaller download. Thanks to
@zertosh!
### Version 1.0.1 (2015-06-20) ###
- Fixed: Declared an undeclared variable.
### Version 1.0.0 (2015-02-26) ###
- Changed: Merged the 'operator' and 'punctuation' types into 'punctuator'. That
type is now equivalent to the Punctuator token in the ECMAScript
specification. (Backwards-incompatible change.)
- Fixed: A `-` followed by a number is now correctly matched as a punctuator
followed by a number. It used to be matched as just a number, but there is no
such thing as negative number literals. (Possibly backwards-incompatible
change.)
### Version 0.4.1 (2015-02-21) ###
- Added: Support for the regex `u` flag.
### Version 0.4.0 (2015-02-21) ###
- Improved: `jsTokens.matchToToken` performance.
- Added: Support for octal and binary number literals.
- Added: Support for template strings.
### Version 0.3.1 (2015-01-06) ###
- Fixed: Support for unicode spaces. They used to be allowed in names (which is
very confusing), and some unicode newlines were wrongly allowed in strings and
regexes.
### Version 0.3.0 (2014-12-19) ###
- Changed: The `jsTokens.names` array has been replaced with the
`jsTokens.matchToToken` function. The capturing groups of `jsTokens` are no
longer part of the public API; instead use said function. See this [gist] for
an example. (Backwards-incompatible change.)
- Changed: The empty string is now considered an “invalid” token, instead an
“empty” token (its own group). (Backwards-incompatible change.)
- Removed: component support. (Backwards-incompatible change.)
[gist]: https://gist.github.com/lydell/be49dbf80c382c473004
### Version 0.2.0 (2014-06-19) ###
- Changed: Match ES6 function arrows (`=>`) as an operator, instead of its own
category (“functionArrow”), for simplicity. (Backwards-incompatible change.)
- Added: ES6 splats (`...`) are now matched as an operator (instead of three
punctuations). (Backwards-incompatible change.)
### Version 0.1.0 (2014-03-08) ###
- Initial release.

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014, 2015, 2016, 2017, 2018 Simon Lydell
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.

View File

@ -0,0 +1,240 @@
Overview [![Build Status](https://travis-ci.org/lydell/js-tokens.svg?branch=master)](https://travis-ci.org/lydell/js-tokens)
========
A regex that tokenizes JavaScript.
```js
var jsTokens = require("js-tokens").default
var jsString = "var foo=opts.foo;\n..."
jsString.match(jsTokens)
// ["var", " ", "foo", "=", "opts", ".", "foo", ";", "\n", ...]
```
Installation
============
`npm install js-tokens`
```js
import jsTokens from "js-tokens"
// or:
var jsTokens = require("js-tokens").default
```
Usage
=====
### `jsTokens` ###
A regex with the `g` flag that matches JavaScript tokens.
The regex _always_ matches, even invalid JavaScript and the empty string.
The next match is always directly after the previous.
### `var token = matchToToken(match)` ###
```js
import {matchToToken} from "js-tokens"
// or:
var matchToToken = require("js-tokens").matchToToken
```
Takes a `match` returned by `jsTokens.exec(string)`, and returns a `{type:
String, value: String}` object. The following types are available:
- string
- comment
- regex
- number
- name
- punctuator
- whitespace
- invalid
Multi-line comments and strings also have a `closed` property indicating if the
token was closed or not (see below).
Comments and strings both come in several flavors. To distinguish them, check if
the token starts with `//`, `/*`, `'`, `"` or `` ` ``.
Names are ECMAScript IdentifierNames, that is, including both identifiers and
keywords. You may use [is-keyword-js] to tell them apart.
Whitespace includes both line terminators and other whitespace.
[is-keyword-js]: https://github.com/crissdev/is-keyword-js
ECMAScript support
==================
The intention is to always support the latest ECMAScript version whose feature
set has been finalized.
If adding support for a newer version requires changes, a new version with a
major verion bump will be released.
Currently, ECMAScript 2018 is supported.
Invalid code handling
=====================
Unterminated strings are still matched as strings. JavaScript strings cannot
contain (unescaped) newlines, so unterminated strings simply end at the end of
the line. Unterminated template strings can contain unescaped newlines, though,
so they go on to the end of input.
Unterminated multi-line comments are also still matched as comments. They
simply go on to the end of the input.
Unterminated regex literals are likely matched as division and whatever is
inside the regex.
Invalid ASCII characters have their own capturing group.
Invalid non-ASCII characters are treated as names, to simplify the matching of
names (except unicode spaces which are treated as whitespace). Note: See also
the [ES2018](#es2018) section.
Regex literals may contain invalid regex syntax. They are still matched as
regex literals. They may also contain repeated regex flags, to keep the regex
simple.
Strings may contain invalid escape sequences.
Limitations
===========
Tokenizing JavaScript using regexes—in fact, _one single regex_—wont be
perfect. But thats not the point either.
You may compare jsTokens with [esprima] by using `esprima-compare.js`.
See `npm run esprima-compare`!
[esprima]: http://esprima.org/
### Template string interpolation ###
Template strings are matched as single tokens, from the starting `` ` `` to the
ending `` ` ``, including interpolations (whose tokens are not matched
individually).
Matching template string interpolations requires recursive balancing of `{` and
`}`—something that JavaScript regexes cannot do. Only one level of nesting is
supported.
### Division and regex literals collision ###
Consider this example:
```js
var g = 9.82
var number = bar / 2/g
var regex = / 2/g
```
A human can easily understand that in the `number` line were dealing with
division, and in the `regex` line were dealing with a regex literal. How come?
Because humans can look at the whole code to put the `/` characters in context.
A JavaScript regex cannot. It only sees forwards. (Well, ES2018 regexes can also
look backwards. See the [ES2018](#es2018) section).
When the `jsTokens` regex scans throught the above, it will see the following
at the end of both the `number` and `regex` rows:
```js
/ 2/g
```
It is then impossible to know if that is a regex literal, or part of an
expression dealing with division.
Here is a similar case:
```js
foo /= 2/g
foo(/= 2/g)
```
The first line divides the `foo` variable with `2/g`. The second line calls the
`foo` function with the regex literal `/= 2/g`. Again, since `jsTokens` only
sees forwards, it cannot tell the two cases apart.
There are some cases where we _can_ tell division and regex literals apart,
though.
First off, we have the simple cases where theres only one slash in the line:
```js
var foo = 2/g
foo /= 2
```
Regex literals cannot contain newlines, so the above cases are correctly
identified as division. Things are only problematic when there are more than
one non-comment slash in a single line.
Secondly, not every character is a valid regex flag.
```js
var number = bar / 2/e
```
The above example is also correctly identified as division, because `e` is not a
valid regex flag. I initially wanted to future-proof by allowing `[a-zA-Z]*`
(any letter) as flags, but it is not worth it since it increases the amount of
ambigous cases. So only the standard `g`, `m`, `i`, `y` and `u` flags are
allowed. This means that the above example will be identified as division as
long as you dont rename the `e` variable to some permutation of `gmiyus` 1 to 6
characters long.
Lastly, we can look _forward_ for information.
- If the token following what looks like a regex literal is not valid after a
regex literal, but is valid in a division expression, then the regex literal
is treated as division instead. For example, a flagless regex cannot be
followed by a string, number or name, but all of those three can be the
denominator of a division.
- Generally, if what looks like a regex literal is followed by an operator, the
regex literal is treated as division instead. This is because regexes are
seldomly used with operators (such as `+`, `*`, `&&` and `==`), but division
could likely be part of such an expression.
Please consult the regex source and the test cases for precise information on
when regex or division is matched (should you need to know). In short, you
could sum it up as:
If the end of a statement looks like a regex literal (even if it isnt), it
will be treated as one. Otherwise it should work as expected (if you write sane
code).
### ES2018 ###
ES2018 added some nice regex improvements to the language.
- [Unicode property escapes] should allow telling names and invalid non-ASCII
characters apart without blowing up the regex size.
- [Lookbehind assertions] should allow matching telling division and regex
literals apart in more cases.
- [Named capture groups] might simplify some things.
These things would be nice to do, but are not critical. They probably have to
wait until the oldest maintained Node.js LTS release supports those features.
[Unicode property escapes]: http://2ality.com/2017/07/regexp-unicode-property-escapes.html
[Lookbehind assertions]: http://2ality.com/2017/05/regexp-lookbehind-assertions.html
[Named capture groups]: http://2ality.com/2017/05/regexp-named-capture-groups.html
License
=======
[MIT](LICENSE).

View File

@ -0,0 +1,23 @@
// Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell
// License: MIT. (See LICENSE.)
Object.defineProperty(exports, "__esModule", {
value: true
})
// This regex comes from regex.coffee, and is inserted here by generate-index.js
// (run `npm run build`).
exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g
exports.matchToToken = function(match) {
var token = {type: "invalid", value: match[0], closed: undefined}
if (match[ 1]) token.type = "string" , token.closed = !!(match[3] || match[4])
else if (match[ 5]) token.type = "comment"
else if (match[ 6]) token.type = "comment", token.closed = !!match[7]
else if (match[ 8]) token.type = "regex"
else if (match[ 9]) token.type = "number"
else if (match[10]) token.type = "name"
else if (match[11]) token.type = "punctuator"
else if (match[12]) token.type = "whitespace"
return token
}

View File

@ -0,0 +1,64 @@
{
"_from": "js-tokens@^4.0.0",
"_id": "js-tokens@4.0.0",
"_inBundle": false,
"_integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
"_location": "/@babel/highlight/js-tokens",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "js-tokens@^4.0.0",
"name": "js-tokens",
"escapedName": "js-tokens",
"rawSpec": "^4.0.0",
"saveSpec": null,
"fetchSpec": "^4.0.0"
},
"_requiredBy": [
"/@babel/highlight"
],
"_resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
"_shasum": "19203fb59991df98e3a287050d4647cdeaf32499",
"_spec": "js-tokens@^4.0.0",
"_where": "/Users/traceybushman/Documents/FreeCodeCamp/presolver/node_modules/@babel/highlight",
"author": {
"name": "Simon Lydell"
},
"bugs": {
"url": "https://github.com/lydell/js-tokens/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "A regex that tokenizes JavaScript.",
"devDependencies": {
"coffeescript": "2.1.1",
"esprima": "4.0.0",
"everything.js": "1.0.3",
"mocha": "5.0.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/lydell/js-tokens#readme",
"keywords": [
"JavaScript",
"js",
"token",
"tokenize",
"regex"
],
"license": "MIT",
"name": "js-tokens",
"repository": {
"type": "git",
"url": "git+https://github.com/lydell/js-tokens.git"
},
"scripts": {
"build": "node generate-index.js",
"dev": "npm run build && npm test",
"esprima-compare": "node esprima-compare ./index.js everything.js/es5.js",
"test": "mocha --ui tdd"
},
"version": "4.0.0"
}

View File

@ -0,0 +1,50 @@
{
"_from": "@babel/highlight@^7.0.0",
"_id": "@babel/highlight@7.0.0",
"_inBundle": false,
"_integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==",
"_location": "/@babel/highlight",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@babel/highlight@^7.0.0",
"name": "@babel/highlight",
"escapedName": "@babel%2fhighlight",
"scope": "@babel",
"rawSpec": "^7.0.0",
"saveSpec": null,
"fetchSpec": "^7.0.0"
},
"_requiredBy": [
"/@babel/code-frame"
],
"_resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz",
"_shasum": "f710c38c8d458e6dd9a201afb637fcb781ce99e4",
"_spec": "@babel/highlight@^7.0.0",
"_where": "/Users/traceybushman/Documents/FreeCodeCamp/presolver/node_modules/@babel/code-frame",
"author": {
"name": "suchipi",
"email": "me@suchipi.com"
},
"bundleDependencies": false,
"dependencies": {
"chalk": "^2.0.0",
"esutils": "^2.0.2",
"js-tokens": "^4.0.0"
},
"deprecated": false,
"description": "Syntax highlight JavaScript strings for output in terminals.",
"devDependencies": {
"strip-ansi": "^4.0.0"
},
"homepage": "https://babeljs.io/",
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/highlight",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-highlight"
},
"version": "7.0.0"
}

22
probot/presolver/node_modules/@octokit/rest/LICENSE generated vendored Normal file
View 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.

230
probot/presolver/node_modules/@octokit/rest/README.md generated vendored Normal file
View File

@ -0,0 +1,230 @@
# rest.js
> GitHub REST API client for JavaScript
[![@latest](https://img.shields.io/npm/v/@octokit/rest.svg)](https://www.npmjs.com/package/@octokit/rest)
[![Build Status](https://travis-ci.org/octokit/rest.js.svg?branch=master)](https://travis-ci.org/octokit/rest.js)
[![Coverage Status](https://coveralls.io/repos/github/octokit/rest.js/badge.svg)](https://coveralls.io/github/octokit/rest.js)
[![Greenkeeper](https://badges.greenkeeper.io/octokit/rest.js.svg)](https://greenkeeper.io/)
## Usage
### Node
Install with `npm install @octokit/rest`.
```js
const octokit = require('@octokit/rest')()
// Compare: https://developer.github.com/v3/repos/#list-organization-repositories
octokit.repos.getForOrg({
org: 'octokit',
type: 'public'
}).then(({ data, headers, status }) => {
// handle data
})
```
### Browser
1. Download `octokit-rest.min.js` from the latest release: https://github.com/octokit/rest.js/releases
2. Load it as script into your web application:
```html
<script src="octokit-rest.min.js"></script>
```
3. Initialize `octokit`
```js
const octokit = new Octokit()
// Compare: https://developer.github.com/v3/repos/#list-organization-repositories
octokit.repos.getForOrg({
org: 'octokit',
type: 'public'
}).then(({data, headers, status}) => {
// handle data
})
```
### Client options
All available client options with default values
<!-- HEADS UP: when changing the options for the constructor, make sure to also
update the type definition templates in scripts/templates/* -->
```js
const octokit = require('@octokit/rest')({
timeout: 0, // 0 means no request timeout
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': 'octokit/rest.js v1.2.3' // v1.2.3 will be current version
},
// custom GitHub Enterprise URL
baseUrl: 'https://api.github.com',
// Node only: advanced request options can be passed as http(s) agent
agent: undefined
})
```
`@octokit/rest` API docs: https://octokit.github.io/rest.js/
GitHub v3 REST API docs: https://developer.github.com/v3/
## API Previews
To take advantage of [GitHubs API Previews](https://developer.github.com/v3/previews/),
pass a custom `accept` header, which you can do with any endpoint method documented
in the [API docs](https://octokit.github.io/rest.js/), e.g.
```js
const { data: { topics } } = octokit.repos.get({
owner: 'octokit',
repo: 'rest.js',
headers: {
accept: 'application/vnd.github.mercy-preview+json'
}
})
```
Multiple preview headers can be combined by separating them with commas
```js
const { data: { topics, codeOfConduct } } = octokit.repos.get({
owner: 'octokit',
repo: 'rest.js',
headers: {
accept: 'application/vnd.github.mercy-preview+json,application/vnd.github.scarlet-witch-preview+json'
}
})
```
## Authentication
Most GitHub API calls don't require authentication. Rules of thumb:
1. If you can see the information by visiting the site without being logged in, you don't have to be authenticated to retrieve the same information through the API.
2. If you want to change data, you have to be authenticated.
```javascript
// basic
octokit.authenticate({
type: 'basic',
username: 'yourusername',
password: 'password'
})
// oauth
octokit.authenticate({
type: 'oauth',
token: 'secrettoken123'
})
// oauth key/secret (to get a token)
octokit.authenticate({
type: 'oauth',
key: 'client_id',
secret: 'client_secret'
})
// token (https://github.com/settings/tokens)
octokit.authenticate({
type: 'token',
token: 'secrettoken123'
})
// GitHub app
octokit.authenticate({
type: 'app',
token: 'secrettoken123'
})
```
Note: `authenticate` is synchronous because it only sets the credentials
for the following requests.
## Pagination
There are a few pagination-related methods:
- `hasNextPage(response)`
- `hasPreviousPage(response)`
- `hasFirstPage(response)`
- `hasLastPage(response)`
- `getNextPage(response)`
- `getPreviousPage(response)`
- `getFirstPage(response)`
- `getLastPage(response)`
Usage
```js
async function paginate (method) {
let response = await method({ per_page: 100 })
let { data } = response
while (octokit.hasNextPage(response)) {
response = await octokit.getNextPage(response)
data = data.concat(response.data)
}
return data
}
paginate(octokit.repos.getAll)
.then(data => {
// handle all results
})
```
## Debug
Set `DEBUG=octokit:rest*` for additional debug logs.
## Tests
Before running any tests you have to start the [fixtures server](https://github.com/octokit/fixtures-server)
```
$ npm run start-fixtures-server
```
In a second terminal, run the tests
```bash
$ npm test
```
Or run a specific test
```bash
$ ./node_modules/.bin/mocha test/scenarios/get-repository-test.js
```
Run browser tests
```bash
$ npm run test:browser
```
**Note**: In order to run the same [scenario tests](test/scenarios) in both Node
and browser, we simulate the Cypress environment in Node, see [test/mocha-node-setup.js](test/mocha-node-setup.js).
The examples are run as part of the tests. You can set an `EXAMPLES_GITHUB_TOKEN` environment
variable (or set it in a `.env` file) to avoid running against GitHub's rate limit.
## Contributing
We would love you to contribute to `@octokit/rest`, pull requests are very welcomed!
Please see [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
## Credits
`@octokit/rest` was originally created as [`node-github`](https://www.npmjs.com/package/github)
in 2012 by Mike de Boer from Cloud9 IDE, Inc.
It was adopted and renamed by GitHub in 2017
## LICENSE
[MIT](LICENSE)

25841
probot/presolver/node_modules/@octokit/rest/index.d.ts generated vendored Normal file

File diff suppressed because one or more lines are too long

31
probot/presolver/node_modules/@octokit/rest/index.js generated vendored Normal file
View File

@ -0,0 +1,31 @@
module.exports = GitHubApi
const defaultsDeep = require('lodash/defaultsDeep')
const Hook = require('before-after-hook')
const parseClientOptions = require('./lib/parse-client-options')
const request = require('./lib/request')
const ENDPOINT_DEFAULTS = require('./lib/endpoint').DEFAULTS
const PLUGINS = [
require('./lib/plugins/authentication'),
require('./lib/plugins/endpoint-methods'),
require('./lib/plugins/pagination')
]
function GitHubApi (options) {
const defaults = defaultsDeep(parseClientOptions(options), ENDPOINT_DEFAULTS)
const hook = new Hook()
const api = {
// NOTE: github.hook, github.plugin and github.request are experimental APIs
// at this point and can change at any time
hook,
plugin: (pluginFunction) => pluginFunction(api),
request: (options) => api.hook('request', defaultsDeep(options, defaults), request)
}
PLUGINS.forEach(api.plugin)
return api
}

4293
probot/presolver/node_modules/@octokit/rest/index.js.flow generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
module.exports = {
agent: undefined, // https://nodejs.org/api/https.html#https_class_https_agent
headers: {
accept: 'application/vnd.github.v3+json'
},
timeout: 0,
baseUrl: 'https://api.github.com'
}

View 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
}

View File

@ -0,0 +1,69 @@
[back to `@octokit/rest`]('../..')
# `@octokit/rest/endpoint`
> Turn REST API endpoint options into generic request options
---
# ⚠️ This is not a public API at this point and can change at any time
---
## Usage
```js
const octokitRestEndpoint = require('@octokit/rest/lib/endpoint')
const options = octokitRestEndpoint({
// request options
method: 'GET',
url: '/orgs/:org/repos',
// parameters
org: 'octokit',
type: 'private'
})
```
`options` would now look something like
```js
{
method: 'GET',
url: 'https://api.github.com/orgs/octokit/repos?type=private',
headers: {
'user-agent': 'myApp v1.2.3',
accept: 'application/vnd.github.v3+json'
}
}
```
You can pass them to your request library of preference.
## Options
### `method`
Any supported [http verb](https://developer.github.com/v3/#http-verbs), case insensitive.
### `url`
A path or full URL which may contain `:variable` or `{variable}` placeholders,
e.g. `/orgs/:org/repos`. The `url` is parsed using
## Defaults
| Name | Value |
|------------------------|-------------------------------------------------------------------------------------|
| **method** | `'get'` |
| **baseUrl** | `'https://api.github.com'` |
| **headers.accept** | `'application/vnd.github.v3+json'` |
| **headers.user-agent** | `'octokit/rest.js v1.2.3'` (1.2.3 being the current `@octokit/rest` version number) plus what ever [universal-user-agent](https://www.npmjs.com/package/universal-user-agent) returns. If you pass a custom value such as `myApp v1.2.3` then it will be used as prefix |
_To be done_: change defaults with
```js
const octokitRestEndpoint = require('@octokit/rest/lib/endpoint').defaults({
baseUrl: 'http://my-custom-host/api/v3'
})
```

View File

@ -0,0 +1,22 @@
module.exports = addQueryParameters
function addQueryParameters (url, parameters) {
const separator = /\?/.test(url) ? '&' : '?'
const names = Object.keys(parameters)
if (names.length === 0) {
return url
}
return url + separator + names
.map(name => {
if (name === 'q') {
return 'q=' + parameters.q.split('+')
.map(encodeURIComponent)
.join('+')
}
return `${name}=${encodeURIComponent(parameters[name])}`
})
.join('&')
}

View File

@ -0,0 +1,8 @@
module.exports = {
method: 'get',
baseUrl: 'https://api.github.com',
headers: {
accept: 'application/vnd.github.v3+json'
},
request: {}
}

View File

@ -0,0 +1,18 @@
module.exports = extractUrlVariableName
const flatten = require('lodash/flatten')
const urlVariableRegex = /\{[^}]+\}/g
function extractUrlVariableName (url) {
const matches = url.match(urlVariableRegex)
if (!matches) {
return []
}
return flatten(matches.map(removeNonChars))
}
function removeNonChars (variableName) {
return variableName.replace(/^\W+|\W+$/g, '').split(/,/)
}

View File

@ -0,0 +1,72 @@
'use strict'
module.exports = restEndpoint
const defaultsDeep = require('lodash/defaultsDeep')
const intersection = require('lodash/intersection')
const mapKeys = require('lodash/mapKeys')
const omit = require('lodash/omit')
const urlTemplate = require('url-template')
const getUserAgent = require('universal-user-agent')
const addQueryParameters = require('./add-query-parameters')
const extractUrlVariableNames = require('./extract-url-variable-names')
const pkg = require('../../package.json')
const DEFAULTS = module.exports.DEFAULTS = require('./defaults')
const NON_PARAMETERS = [
'request',
'baseUrl'
]
function restEndpoint (options) {
// lowercase header names (#760)
options.headers = mapKeys(options.headers, (value, key) => key.toLowerCase())
let userAgent = `octokit.js/${pkg.version} ${getUserAgent()}`
if (options.headers['user-agent']) {
userAgent = `${options.headers['user-agent']} ${userAgent}`
}
options.headers['user-agent'] = userAgent
options = defaultsDeep({}, options, DEFAULTS)
let method = options.method.toLowerCase()
let baseUrl = options.baseUrl
let url = options.url
let body = options.body
let headers = options.headers
let remainingOptions = omit(options, ['method', 'baseUrl', 'url', 'headers'])
// replace :varname with {varname} to make it RFC 6570 compatible
url = url.replace(/:([a-z]\w+)/g, '{+$1}')
// extract variable names from URL to calculate remaining variables later
const urlVariableNames = extractUrlVariableNames(url)
url = urlTemplate.parse(url).expand(remainingOptions)
if (!/^http/.test(url)) {
url = (baseUrl) + url
}
const requestOptions = remainingOptions.request
remainingOptions = omit(remainingOptions, intersection(Object.keys(options), urlVariableNames).concat(NON_PARAMETERS))
if (method === 'get' || method === 'head') {
url = addQueryParameters(url, remainingOptions)
} else {
if ('input' in remainingOptions) {
body = remainingOptions.input
} else {
body = Object.keys(remainingOptions).length ? remainingOptions : undefined
}
}
return Object.assign(requestOptions, {
method,
url,
headers,
body
})
}

View File

@ -0,0 +1,53 @@
module.exports = getRequestAgent
const urlParse = require('url').parse
const HttpAgent = require('http').Agent
const HttpsAgent = require('https').Agent
const HttpProxyAgent = require('http-proxy-agent')
const HttpsProxyAgent = require('https-proxy-agent')
const merge = require('lodash/merge')
const omit = require('lodash/omit')
const pick = require('lodash/pick')
const deprecate = require('./deprecate')
function getRequestAgent (baseUrl, options) {
if (options.agent) {
return options.agent
}
const agentOptionNames = ['ca', 'proxy', 'rejectUnauthorized', 'family'].filter(key => key in options)
if (agentOptionNames.length === 0) {
return
}
agentOptionNames.forEach(option => {
deprecate(`options.${option} (use "options.agent" instead)`)
})
const agentOptions = pick(options, agentOptionNames)
const protocol = urlParse(baseUrl).protocol.replace(':', '')
/* istanbul ignore if */
if ('proxy' in options) {
const proxyAgentOptions = merge(
urlParse(agentOptions.proxy),
omit(agentOptions, 'proxy')
)
if (protocol === 'http') {
return new HttpProxyAgent(proxyAgentOptions)
}
return new HttpsProxyAgent(proxyAgentOptions)
}
/* istanbul ignore if */
if (protocol === 'http') {
return new HttpAgent(agentOptions)
}
return new HttpsAgent(agentOptions)
}

View File

@ -0,0 +1,75 @@
module.exports = parseOptions
const defaults = require('lodash/defaults')
const pick = require('lodash/pick')
const deprecate = require('./deprecate')
const getRequestAgent = require('./get-request-agent')
const DEFAULTS = require('./defaults')
const OPTION_NAMES = [
'timeout',
'baseUrl',
'agent',
'headers'
]
function parseOptions (userOptions) {
if (!userOptions) {
userOptions = {}
}
if ('followRedirects' in userOptions) {
deprecate('followRedirects option is no longer supported. All redirects are followed correctly')
}
if ('protocol' in userOptions) {
deprecate('protocol option is no longer supported')
}
if ('host' in userOptions) {
deprecate('host option is no longer supported')
}
if ('port' in userOptions) {
deprecate('port option is no longer supported')
}
if ('pathPrefix' in userOptions) {
deprecate('pathPrefix option is no longer supported')
}
if ('Promise' in userOptions) {
deprecate('Promise option is no longer supported. The native Promise API is used')
}
const options = defaults(pick(userOptions, OPTION_NAMES), DEFAULTS)
const clientDefaults = {
baseUrl: options.baseUrl,
headers: options.headers,
request: {
timeout: options.timeout
}
}
if (userOptions.protocol) {
clientDefaults.baseUrl = `${userOptions.protocol}://${userOptions.host}`
/* istanbul ignore else */
if (userOptions.port) {
clientDefaults.baseUrl += `:${userOptions.port}`
}
// Check if a prefix is passed in the options and strip any leading or trailing slashes from it.
/* istanbul ignore else */
if (userOptions.pathPrefix) {
clientDefaults.baseUrl += '/' + userOptions.pathPrefix.replace(/(^[/]+|[/]+$)/g, '')
}
}
/* istanbul ignore else */
if (!process.browser) {
clientDefaults.request.agent = getRequestAgent(clientDefaults.baseUrl, userOptions)
}
return clientDefaults
}

View File

@ -0,0 +1,31 @@
# `@octokit/plugins/*`
---
# ⚠️ Plugins are currently experimental. APIs can change at any time.
---
## Usage
```js
const octokit = require('@octokit/rest')()
function myPlugin (octokit) {
octokit.myMethod = function () {
// ...
}
octokit.hook.before('request', (options) => {
// change options or cancel request.
// return promise for async methods
})
octokit.hook.after('request', (result, options) => {
// ...
})
}
octokit.plugin(myPlugin)
octokit.myMethod()
octokit.request({ url: '/' }) // runs before/after hooks defined above
```

View File

@ -0,0 +1,35 @@
module.exports = authenticate
function authenticate (state, options) {
if (!options) {
state.auth = false
return
}
switch (options.type) {
case 'basic':
if (!options.username || !options.password) {
throw new Error('Basic authentication requires both a username and password to be set')
}
break
case 'oauth':
if (!options.token && !(options.key && options.secret)) {
throw new Error('OAuth2 authentication requires a token or key & secret to be set')
}
break
case 'token':
case 'integration':
case 'app':
if (!options.token) {
throw new Error('Token authentication requires a token to be set')
}
break
default:
throw new Error("Invalid authentication type, must be 'basic', 'integration', or 'oauth'")
}
state.auth = options
}

View File

@ -0,0 +1,48 @@
module.exports = authenticationBeforeRequest
const btoa = require('btoa-lite')
const uniq = require('lodash/uniq')
const deprecate = require('../../deprecate')
function authenticationBeforeRequest (state, options) {
if (!state.auth.type) {
return
}
if (state.auth.type === 'basic') {
const hash = btoa(`${state.auth.username}:${state.auth.password}`)
options.headers['authorization'] = `Basic ${hash}`
return
}
if (state.auth.type === 'token') {
options.headers['authorization'] = `token ${state.auth.token}`
return
}
// deprecate state.auth.type === 'integration', rename to 'app'
if (state.auth.type === 'integration') {
deprecate('authentication type "integration" is deprecated. Use "app" instead.')
state.auth.type = 'app'
}
if (state.auth.type === 'app') {
options.headers['authorization'] = `Bearer ${state.auth.token}`
const acceptHeaders = options.headers['accept'].split(',')
.concat('application/vnd.github.machine-man-preview+json')
options.headers['accept'] = uniq(acceptHeaders).filter(Boolean).join(',')
return
}
options.url += options.url.indexOf('?') === -1 ? '?' : '&'
if (state.auth.token) {
options.url += `access_token=${encodeURIComponent(state.auth.token)}`
return
}
const key = encodeURIComponent(state.auth.key)
const secret = encodeURIComponent(state.auth.secret)
options.url += `client_id=${key}&client_secret=${secret}`
}

View File

@ -0,0 +1,12 @@
module.exports = authenticationPlugin
const authenticate = require('./authenticate')
const beforeRequest = require('./before-request')
function authenticationPlugin (octokit) {
const state = {
auth: false
}
octokit.authenticate = authenticate.bind(null, state)
octokit.hook.before('request', beforeRequest.bind(null, state))
}

View File

@ -0,0 +1,33 @@
'use strict'
module.exports = apiPlugin
const get = require('lodash/get')
const pick = require('lodash/pick')
const method = require('./method')
const ENDPOINT_DEFAULTS = require('../../routes.json')
function apiPlugin (octokit) {
Object.keys(ENDPOINT_DEFAULTS).forEach(namespaceName => {
octokit[namespaceName] = {}
Object.keys(ENDPOINT_DEFAULTS[namespaceName]).forEach(apiName => {
let apiOptions = ENDPOINT_DEFAULTS[namespaceName][apiName]
let deprecated
if (apiOptions.alias) {
deprecated = apiOptions.deprecated
apiOptions = get(ENDPOINT_DEFAULTS, apiOptions.alias)
}
const endpointDefaults = pick(apiOptions, ['method', 'url', 'headers', 'request'])
if (deprecated) {
endpointDefaults.deprecated = deprecated
}
octokit[namespaceName][apiName] = method.bind(null, octokit, endpointDefaults, apiOptions.params)
})
})
}

View File

@ -0,0 +1,34 @@
module.exports = apiMethod
const clone = require('lodash/clone')
const defaultsDeep = require('lodash/defaultsDeep')
const mapKeys = require('lodash/mapKeys')
const deprecate = require('../../deprecate')
const validate = require('./validate')
function apiMethod (octokit, endpointDefaults, endpointParams, options, callback) {
// Do not alter passed options (#786)
options = clone(options) || {}
// lowercase header names (#760)
options.headers = mapKeys(options.headers, (value, key) => key.toLowerCase())
if (endpointDefaults.deprecated) {
deprecate(endpointDefaults.deprecated)
delete endpointDefaults.deprecated
}
const endpointOptions = defaultsDeep(options, endpointDefaults)
const promise = Promise.resolve(endpointOptions)
.then(validate.bind(null, endpointParams))
.then(octokit.request)
if (callback) {
promise.then(callback.bind(null, null), callback)
return
}
return promise
}

View File

@ -0,0 +1,117 @@
'use strict'
module.exports = validate
const set = require('lodash/set')
const get = require('lodash/get')
const HttpError = require('../../request/http-error')
const deprecate = require('../../deprecate')
function validate (endpointParams, options) {
// Alias are handled before validation, as validation rules
// ar set the aliased parameter. The `mapTo` property is the other way
// around, the final parameter name is the mapTo value, but validation
// rules are on parameter with the mapTo property
Object.keys(options).forEach(optionName => {
if (!endpointParams[optionName] || !endpointParams[optionName].alias) {
return
}
set(options, endpointParams[optionName].alias, options[optionName])
delete options[optionName]
// right now all parameters with an alias property also have a deprecated
// property, but that might change in future, so we wrap it in the if block,
// but ignore if for coverage
/* istanbul ignore else */
if (endpointParams[optionName].deprecated) {
deprecate(`"${optionName}" parameter has been renamed to "${endpointParams[optionName].alias}"`)
}
})
Object.keys(endpointParams).forEach(parameterName => {
const parameter = get(endpointParams, parameterName)
const expectedType = parameter.type
let parentParameterName
let parentValue
let parentParamIsPresent = true
let parentParameterIsArray = false
if (/\./.test(parameterName)) {
parentParameterName = parameterName.replace(/\.[^.]+$/, '')
parentParameterIsArray = parentParameterName.slice(-2) === '[]'
if (parentParameterIsArray) {
parentParameterName = parentParameterName.slice(0, -2)
}
parentValue = get(options, parentParameterName)
parentParamIsPresent = parentParameterName === 'headers' || (typeof parentValue === 'object' && parentValue !== null)
}
let values = parentParameterIsArray
? (get(options, parentParameterName) || []).map(value => value[parameterName.split(/\./).pop()])
: [get(options, parameterName)]
values.forEach((value, i) => {
const valueIsPresent = typeof value !== 'undefined'
const valueIsNull = value === null
const currentParameterName = parentParameterIsArray
? parameterName.replace(/\[\]/, `[${i}]`)
: parameterName
if (!parameter.required && !valueIsPresent) {
return
}
// if the parent parameter is of type object but allows null
// then the child parameters can be ignored
if (!parentParamIsPresent) {
return
}
if (parameter.allowNull && valueIsNull) {
return
}
if (!parameter.allowNull && valueIsNull) {
throw new HttpError(`'${currentParameterName}' cannot be null`, 400)
}
if (parameter.required && !valueIsPresent) {
throw new HttpError(`Empty value for parameter '${currentParameterName}': ${JSON.stringify(value)}`, 400)
}
// parse to integer before checking for enum
// so that string "1" will match enum with number 1
if (expectedType === 'integer') {
const unparsedValue = value
value = parseInt(value, 10)
if (isNaN(value)) {
throw new HttpError(`Invalid value for parameter '${currentParameterName}': ${JSON.stringify(unparsedValue)} is NaN`, 400)
}
}
if (parameter.enum && parameter.enum.indexOf(value) === -1) {
throw new HttpError(`Invalid value for parameter '${currentParameterName}': ${JSON.stringify(value)}`, 400)
}
if (parameter.validation) {
const regex = new RegExp(parameter.validation)
if (!regex.test(value)) {
throw new HttpError(`Invalid value for parameter '${currentParameterName}': ${JSON.stringify(value)}`, 400)
}
}
if (expectedType === 'object' && typeof value === 'string') {
try {
value = JSON.parse(value)
} catch (exception) {
throw new HttpError(`JSON parse error of value for parameter '${currentParameterName}': ${JSON.stringify(value)}`, 400)
}
}
set(options, parameter.mapTo || currentParameterName, value)
})
})
return options
}

View File

@ -0,0 +1,7 @@
module.exports = getFirstPage
const getPage = require('./get-page')
function getFirstPage (octokit, link, headers, callback) {
return getPage(octokit, link, 'first', headers, callback)
}

View File

@ -0,0 +1,7 @@
module.exports = getLastPage
const getPage = require('./get-page')
function getLastPage (octokit, link, headers, callback) {
return getPage(octokit, link, 'last', headers, callback)
}

View File

@ -0,0 +1,7 @@
module.exports = getNextPage
const getPage = require('./get-page')
function getNextPage (octokit, link, headers, callback) {
return getPage(octokit, link, 'next', headers, callback)
}

View 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
}

View File

@ -0,0 +1,49 @@
module.exports = getPage
const HttpError = require('../../request/http-error')
const getPageLinks = require('./get-page-links')
function getPage (octokit, link, which, headers, callback) {
if (typeof headers === 'function') {
callback = headers
headers = null
}
const url = getPageLinks(link)[which]
if (!url) {
const urlError = new HttpError(`No ${which} page found`, 404)
if (callback) {
return callback(urlError)
}
return Promise.reject(urlError)
}
const requestOptions = {
url,
headers: applyAcceptHeader(link, headers)
}
const promise = octokit.request(requestOptions)
if (callback) {
promise.then(callback.bind(null, null), callback)
return
}
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
}

View File

@ -0,0 +1,7 @@
module.exports = getPreviousPage
const getPage = require('./get-page')
function getPreviousPage (octokit, link, headers, callback) {
return getPage(octokit, link, 'prev', headers, callback)
}

View File

@ -0,0 +1,7 @@
module.exports = hasFirstPage
const getPageLinks = require('./get-page-links')
function hasFirstPage (link) {
return getPageLinks(link).first
}

View File

@ -0,0 +1,7 @@
module.exports = hasLastPage
const getPageLinks = require('./get-page-links')
function hasLastPage (link) {
return getPageLinks(link).last
}

View File

@ -0,0 +1,7 @@
module.exports = hasNextPage
const getPageLinks = require('./get-page-links')
function hasNextPage (link) {
return getPageLinks(link).next
}

View File

@ -0,0 +1,7 @@
module.exports = hasPreviousPage
const getPageLinks = require('./get-page-links')
function hasPreviousPage (link) {
return getPageLinks(link).prev
}

View File

@ -0,0 +1,12 @@
module.exports = paginationPlugin
function paginationPlugin (octokit) {
octokit.getFirstPage = require('./get-first-page').bind(null, octokit)
octokit.getLastPage = require('./get-last-page').bind(null, octokit)
octokit.getNextPage = require('./get-next-page').bind(null, octokit)
octokit.getPreviousPage = require('./get-previous-page').bind(null, octokit)
octokit.hasFirstPage = require('./has-first-page')
octokit.hasLastPage = require('./has-last-page')
octokit.hasNextPage = require('./has-next-page')
octokit.hasPreviousPage = require('./has-previous-page')
}

View File

@ -0,0 +1,31 @@
[back to `@octokit/rest`]('../..')
# `@octokit/rest/request`
> Turn REST API endpoint options into generic request options
---
# ⚠️ This is not a public API at this point and can change at any time
---
## Usage
```js
const octokitRestRequest = require('@octokit/rest/lib/request')
octokitRestRequest({
// request options
method: 'GET',
url: '/orgs/:org/repos',
// parameters
org: 'octokit',
type: 'private'
}) // returns promise
```
Sends a `GET` request to https://api.github.com/orgs/octokit/repos?type=private&per_page=20&page=2
with `user-agent` and `accept` headers set.
It accepts the same options and has the same defaults as [`@octokit/rest/endpoint`](../endpoint)

View File

@ -0,0 +1,5 @@
module.exports = getBufferResponse
function getBufferResponse (response) {
return response.arrayBuffer()
}

View File

@ -0,0 +1,5 @@
module.exports = getBufferResponse
function getBufferResponse (response) {
return response.buffer()
}

View File

@ -0,0 +1,36 @@
'use strict'
const STATUS_CODES = {
304: 'Not Modified', // See PR #673 (https://github.com/octokit/rest.js/pull/673)
400: 'Bad Request',
404: 'Not Found',
500: 'Internal Server Error',
504: 'Gateway Timeout'
}
module.exports = class HttpError extends Error {
constructor (message, code, headers) {
super(message)
// Maintains proper stack trace for where our error was thrown (only available on V8)
/* istanbul ignore else */
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor)
}
this.name = 'HttpError'
this.code = code
this.status = STATUS_CODES[code]
this.headers = headers
}
toString () {
return this.message
}
toJSON () {
return {
code: this.code,
status: this.status,
message: this.message
}
}
}

View File

@ -0,0 +1,9 @@
module.exports = restRequest
const restEndpoint = require('../endpoint')
const request = require('./request')
function restRequest (endpointOptions) {
const requestOptions = restEndpoint(endpointOptions)
return request(requestOptions)
}

View File

@ -0,0 +1,32 @@
/*!
* isArrayBuffer v1.0.0
* https://github.com/fengyuanchen/is-array-buffer
*
* Copyright (c) 2015-2017 Chen Fengyuan
* Released under the MIT license
*
* Date: 2017-07-26T11:00:44.931Z
*/
'use strict'
// temporary workaround for https://github.com/octokit/rest.js/issues/774
const hasArrayBuffer = typeof ArrayBuffer === 'function'
const toString = Object.prototype.toString
/**
* Check if the given value is an ArrayBuffer.
* @param {*} value - The value to check.
* @returns {boolean} Returns `true` if the given is an ArrayBuffer, else `false`.
* @example
* isArrayBuffer(new ArrayBuffer())
* // => true
* isArrayBuffer(new Array())
* // => false
*/
function isArrayBuffer (value) {
return hasArrayBuffer && (value instanceof ArrayBuffer || toString.call(value) === '[object ArrayBuffer]')
}
module.exports = isArrayBuffer

View File

@ -0,0 +1,107 @@
'use strict'
module.exports = request
const fetch = require('node-fetch').default
const debug = require('debug')('octokit:rest')
const defaults = require('lodash/defaults')
const isPlainObject = require('lodash/isPlainObject')
const pick = require('lodash/pick')
const deprecate = require('../deprecate')
const getBuffer = require('./get-buffer-response')
const HttpError = require('./http-error')
function request (requestOptions) {
debug('REQUEST:', requestOptions)
// calculate content length unless body is a stream, in which case the
// content length is already set per option
if (requestOptions.body) {
defaults(requestOptions.headers, {
'content-type': 'application/json; charset=utf-8'
})
}
// https://fetch.spec.whatwg.org/#methods
requestOptions.method = requestOptions.method.toUpperCase()
// GitHub expects "content-length: 0" header for PUT/PATCH requests without body
// fetch does not allow to set `content-length` header, but we can set body to an empty string
if (['PATCH', 'PUT'].indexOf(requestOptions.method) >= 0 && !requestOptions.body) {
requestOptions.body = ''
}
if (isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) {
requestOptions.body = JSON.stringify(requestOptions.body)
}
let headers = {}
let status
return fetch(requestOptions.url, pick(requestOptions, 'method', 'body', 'headers', 'timeout', 'agent'))
.then(response => {
status = response.status
for (const keyAndValue of response.headers.entries()) {
headers[keyAndValue[0]] = keyAndValue[1]
}
if (status === 204 || status === 205) {
return
}
// GitHub API returns 200 for HEAD requsets
if (requestOptions.method === 'HEAD') {
if (status < 400) {
return
}
throw new HttpError(response.statusText, status, headers)
}
if (status === 304) {
requestOptions.url = response.headers.location
throw new HttpError('Not modified', status, headers)
}
if (status >= 400) {
return response.text()
.then(message => {
throw new HttpError(message, status, headers)
})
}
const contentType = response.headers.get('content-type')
if (/application\/json/.test(contentType)) {
return response.json()
}
if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) {
return response.text()
}
return getBuffer(response)
})
.then(data => {
return {
data,
status,
headers,
get meta () {
deprecate('response.meta use response.headers instead (#896)')
return headers
}
}
})
.catch(error => {
if (error instanceof HttpError) {
throw error
}
throw new HttpError(error.message, 500, headers)
})
}

Some files were not shown because too many files have changed in this diff Show More