use @actions/github
This commit is contained in:
parent
9da537eb33
commit
0086c2ecdb
199 changed files with 95598 additions and 6141 deletions
66
node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js
generated
vendored
66
node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js
generated
vendored
|
|
@ -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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue