use @actions/github

This commit is contained in:
Robert Brignull 2020-07-06 16:04:02 +01:00
parent 9da537eb33
commit 0086c2ecdb
199 changed files with 95598 additions and 6141 deletions

View file

@ -1,66 +0,0 @@
export function endpointsToMethods(octokit, endpointsMap) {
const newMethods = {};
for (const [scope, endpoints] of Object.entries(endpointsMap)) {
for (const [methodName, endpoint] of Object.entries(endpoints)) {
const [route, defaults, decorations] = endpoint;
const [method, url] = route.split(/ /);
const endpointDefaults = Object.assign({ method, url }, defaults);
if (!newMethods[scope]) {
newMethods[scope] = {};
}
const scopeMethods = newMethods[scope];
if (decorations) {
scopeMethods[methodName] = decorate(octokit, scope, methodName, endpointDefaults, decorations);
continue;
}
scopeMethods[methodName] = octokit.request.defaults(endpointDefaults);
}
}
return newMethods;
}
function decorate(octokit, scope, methodName, defaults, decorations) {
const requestWithDefaults = octokit.request.defaults(defaults);
function withDecorations(...args) {
// @ts-ignore https://github.com/microsoft/TypeScript/issues/25488
let options = requestWithDefaults.endpoint.merge(...args);
// There are currently no other decorations than `.mapToData`
if (decorations.mapToData) {
options = Object.assign({}, options, {
data: options[decorations.mapToData],
[decorations.mapToData]: undefined
});
return requestWithDefaults(options);
}
// NOTE: there are currently no deprecations. But we keep the code
// below for future reference
if (decorations.renamed) {
const [newScope, newMethodName] = decorations.renamed;
octokit.log.warn(`octokit.${scope}.${methodName}() has been renamed to octokit.${newScope}.${newMethodName}()`);
}
if (decorations.deprecated) {
octokit.log.warn(decorations.deprecated);
}
// There currently are no renamed parameters
// if (decorations.renamedParameters) {
// // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488
// const options = requestWithDefaults.endpoint.merge(...args);
// for (const [name, alias] of Object.entries(
// decorations.renamedParameters
// )) {
// if (name in options) {
// octokit.log.warn(
// `"${name}" parameter is deprecated for "octokit.${scope}.${methodName}()". Use "${alias}" instead`
// );
// if (!(alias in options)) {
// options[alias] = options[name];
// }
// delete options[name];
// }
// }
// return requestWithDefaults(options);
// }
// @ts-ignore https://github.com/microsoft/TypeScript/issues/25488
return requestWithDefaults(...args);
}
return Object.assign(withDecorations, requestWithDefaults);
}

File diff suppressed because it is too large Load diff

View file

@ -1,17 +0,0 @@
import ENDPOINTS from "./generated/endpoints";
import { VERSION } from "./version";
import { endpointsToMethods } from "./endpoints-to-methods";
/**
* This plugin is a 1:1 copy of internal @octokit/rest plugins. The primary
* goal is to rebuild @octokit/rest on top of @octokit/core. Once that is
* done, we will remove the registerEndpoints methods and return the methods
* directly as with the other plugins. At that point we will also remove the
* legacy workarounds and deprecations.
*
* See the plan at
* https://github.com/octokit/plugin-rest-endpoint-methods.js/pull/1
*/
export function restEndpointMethods(octokit) {
return endpointsToMethods(octokit, ENDPOINTS);
}
restEndpointMethods.VERSION = VERSION;

View file

@ -1 +0,0 @@
export const VERSION = "3.3.1";