Update to the latest version of @actions/github.

This commit is contained in:
Chris Gavin 2020-09-18 15:40:23 +01:00
parent 55458a1ab1
commit 9ed519fa12
No known key found for this signature in database
GPG key ID: 07F950B80C27E4DA
419 changed files with 56978 additions and 151535 deletions

View file

@ -1,13 +1,14 @@
import { request } from '@octokit/request';
import { getUserAgent } from 'universal-user-agent';
const VERSION = "4.3.1";
const VERSION = "4.5.6";
class GraphqlError extends Error {
constructor(request, response) {
const message = response.data.errors[0].message;
super(message);
Object.assign(this, response.data);
Object.assign(this, { headers: response.headers });
this.name = "GraphqlError";
this.request = request;
// Maintains proper stack trace (only available on V8)
@ -24,28 +25,41 @@ const NON_VARIABLE_OPTIONS = [
"url",
"headers",
"request",
"query"
"query",
"mediaType",
];
const GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/;
function graphql(request, query, options) {
options =
typeof query === "string"
? (options = Object.assign({ query }, options))
: (options = query);
const requestOptions = Object.keys(options).reduce((result, key) => {
if (typeof query === "string" && options && "query" in options) {
return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`));
}
const parsedOptions = typeof query === "string" ? Object.assign({ query }, options) : query;
const requestOptions = Object.keys(parsedOptions).reduce((result, key) => {
if (NON_VARIABLE_OPTIONS.includes(key)) {
result[key] = options[key];
result[key] = parsedOptions[key];
return result;
}
if (!result.variables) {
result.variables = {};
}
result.variables[key] = options[key];
result.variables[key] = parsedOptions[key];
return result;
}, {});
return request(requestOptions).then(response => {
// workaround for GitHub Enterprise baseUrl set with /api/v3 suffix
// https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451
const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl;
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {
requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql");
}
return request(requestOptions).then((response) => {
if (response.data.errors) {
const headers = {};
for (const key of Object.keys(response.headers)) {
headers[key] = response.headers[key];
}
throw new GraphqlError(requestOptions, {
data: response.data
headers,
data: response.data,
});
}
return response.data.data;
@ -59,21 +73,21 @@ function withDefaults(request$1, newDefaults) {
};
return Object.assign(newApi, {
defaults: withDefaults.bind(null, newRequest),
endpoint: request.endpoint
endpoint: request.endpoint,
});
}
const graphql$1 = withDefaults(request, {
headers: {
"user-agent": `octokit-graphql.js/${VERSION} ${getUserAgent()}`
"user-agent": `octokit-graphql.js/${VERSION} ${getUserAgent()}`,
},
method: "POST",
url: "/graphql"
url: "/graphql",
});
function withCustomRequest(customRequest) {
return withDefaults(customRequest, {
method: "POST",
url: "/graphql"
url: "/graphql",
});
}

File diff suppressed because one or more lines are too long