mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-06-07 04:31:12 +00:00
.
This commit is contained in:
parent
beb1329f9f
commit
2b95e76931
7736 changed files with 1874747 additions and 51184 deletions
node_modules/@octokit/rest/plugins/register-endpoints
91
node_modules/@octokit/rest/plugins/register-endpoints/register-endpoints.js
generated
vendored
91
node_modules/@octokit/rest/plugins/register-endpoints/register-endpoints.js
generated
vendored
|
@ -1,87 +1,98 @@
|
|||
module.exports = registerEndpoints
|
||||
module.exports = registerEndpoints;
|
||||
|
||||
const { Deprecation } = require('deprecation')
|
||||
const { Deprecation } = require("deprecation");
|
||||
|
||||
function registerEndpoints (octokit, routes) {
|
||||
function registerEndpoints(octokit, routes) {
|
||||
Object.keys(routes).forEach(namespaceName => {
|
||||
if (!octokit[namespaceName]) {
|
||||
octokit[namespaceName] = {}
|
||||
octokit[namespaceName] = {};
|
||||
}
|
||||
|
||||
Object.keys(routes[namespaceName]).forEach(apiName => {
|
||||
const apiOptions = routes[namespaceName][apiName]
|
||||
const apiOptions = routes[namespaceName][apiName];
|
||||
|
||||
const endpointDefaults = ['method', 'url', 'headers'].reduce((map, key) => {
|
||||
if (typeof apiOptions[key] !== 'undefined') {
|
||||
map[key] = apiOptions[key]
|
||||
}
|
||||
const endpointDefaults = ["method", "url", "headers"].reduce(
|
||||
(map, key) => {
|
||||
if (typeof apiOptions[key] !== "undefined") {
|
||||
map[key] = apiOptions[key];
|
||||
}
|
||||
|
||||
return map
|
||||
}, {})
|
||||
return map;
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
endpointDefaults.request = {
|
||||
validate: apiOptions.params
|
||||
}
|
||||
};
|
||||
|
||||
let request = octokit.request.defaults(endpointDefaults)
|
||||
let request = octokit.request.defaults(endpointDefaults);
|
||||
|
||||
// patch request & endpoint methods to support deprecated parameters.
|
||||
// Not the most elegant solution, but we don’t want to move deprecation
|
||||
// logic into octokit/endpoint.js as it’s out of scope
|
||||
const hasDeprecatedParam = Object.keys(apiOptions.params || {}).find(key => apiOptions.params[key].deprecated)
|
||||
const hasDeprecatedParam = Object.keys(apiOptions.params || {}).find(
|
||||
key => apiOptions.params[key].deprecated
|
||||
);
|
||||
if (hasDeprecatedParam) {
|
||||
const patch = patchForDeprecation.bind(null, octokit, apiOptions)
|
||||
const patch = patchForDeprecation.bind(null, octokit, apiOptions);
|
||||
request = patch(
|
||||
octokit.request.defaults(endpointDefaults),
|
||||
`.${namespaceName}.${apiName}()`
|
||||
)
|
||||
);
|
||||
request.endpoint = patch(
|
||||
request.endpoint,
|
||||
`.${namespaceName}.${apiName}.endpoint()`
|
||||
)
|
||||
);
|
||||
request.endpoint.merge = patch(
|
||||
request.endpoint.merge,
|
||||
`.${namespaceName}.${apiName}.endpoint.merge()`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (apiOptions.deprecated) {
|
||||
octokit[namespaceName][apiName] = function deprecatedEndpointMethod () {
|
||||
octokit.log.warn(new Deprecation(`[@octokit/rest] ${apiOptions.deprecated}`))
|
||||
octokit[namespaceName][apiName] = request
|
||||
return request.apply(null, arguments)
|
||||
}
|
||||
octokit[namespaceName][apiName] = function deprecatedEndpointMethod() {
|
||||
octokit.log.warn(
|
||||
new Deprecation(`[@octokit/rest] ${apiOptions.deprecated}`)
|
||||
);
|
||||
octokit[namespaceName][apiName] = request;
|
||||
return request.apply(null, arguments);
|
||||
};
|
||||
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
octokit[namespaceName][apiName] = request
|
||||
})
|
||||
})
|
||||
octokit[namespaceName][apiName] = request;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function patchForDeprecation (octokit, apiOptions, method, methodName) {
|
||||
const patchedMethod = (options) => {
|
||||
options = Object.assign({}, options)
|
||||
function patchForDeprecation(octokit, apiOptions, method, methodName) {
|
||||
const patchedMethod = options => {
|
||||
options = Object.assign({}, options);
|
||||
|
||||
Object.keys(options).forEach(key => {
|
||||
if (apiOptions.params[key] && apiOptions.params[key].deprecated) {
|
||||
const aliasKey = apiOptions.params[key].alias
|
||||
const aliasKey = apiOptions.params[key].alias;
|
||||
|
||||
octokit.log.warn(new Deprecation(`[@octokit/rest] "${key}" parameter is deprecated for "${methodName}". Use "${aliasKey}" instead`))
|
||||
octokit.log.warn(
|
||||
new Deprecation(
|
||||
`[@octokit/rest] "${key}" parameter is deprecated for "${methodName}". Use "${aliasKey}" instead`
|
||||
)
|
||||
);
|
||||
|
||||
if (!(aliasKey in options)) {
|
||||
options[aliasKey] = options[key]
|
||||
options[aliasKey] = options[key];
|
||||
}
|
||||
delete options[key]
|
||||
delete options[key];
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
return method(options)
|
||||
}
|
||||
return method(options);
|
||||
};
|
||||
Object.keys(method).forEach(key => {
|
||||
patchedMethod[key] = method[key]
|
||||
})
|
||||
patchedMethod[key] = method[key];
|
||||
});
|
||||
|
||||
return patchedMethod
|
||||
return patchedMethod;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue