This commit is contained in:
Tommy Byrd
2021-12-16 15:43:22 -05:00
parent 1f4c55833c
commit 6f6ef625b6
3 changed files with 644 additions and 2 deletions

588
dist/index.js vendored
View File

@@ -1273,6 +1273,481 @@ function checkBypass(reqUrl) {
exports.checkBypass = checkBypass;
/***/ }),
/***/ 7400:
/***/ ((module) => {
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
module.exports = _asyncToGenerator;
module.exports.default = module.exports, module.exports.__esModule = true;
/***/ }),
/***/ 3561:
/***/ ((module) => {
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
module.exports = _defineProperty;
module.exports.default = module.exports, module.exports.__esModule = true;
/***/ }),
/***/ 3298:
/***/ ((module) => {
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
"default": obj
};
}
module.exports = _interopRequireDefault;
module.exports.default = module.exports, module.exports.__esModule = true;
/***/ }),
/***/ 1042:
/***/ ((module) => {
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
module.exports = _typeof = function _typeof(obj) {
return typeof obj;
};
module.exports.default = module.exports, module.exports.__esModule = true;
} else {
module.exports = _typeof = function _typeof(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
module.exports.default = module.exports, module.exports.__esModule = true;
}
return _typeof(obj);
}
module.exports = _typeof;
module.exports.default = module.exports, module.exports.__esModule = true;
/***/ }),
/***/ 9032:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
module.exports = __nccwpck_require__(4307);
/***/ }),
/***/ 9179:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
const axiosRetry = __nccwpck_require__(3728)/* .default */ .ZP;
module.exports = axiosRetry;
module.exports.default = axiosRetry;
/***/ }),
/***/ 3728:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict";
var __webpack_unused_export__;
var _interopRequireDefault = __nccwpck_require__(3298);
__webpack_unused_export__ = ({
value: true
});
__webpack_unused_export__ = isNetworkError;
__webpack_unused_export__ = isRetryableError;
__webpack_unused_export__ = isSafeRequestError;
__webpack_unused_export__ = isIdempotentRequestError;
__webpack_unused_export__ = isNetworkOrIdempotentRequestError;
__webpack_unused_export__ = exponentialDelay;
exports.ZP = axiosRetry;
var _regenerator = _interopRequireDefault(__nccwpck_require__(9032));
var _typeof2 = _interopRequireDefault(__nccwpck_require__(1042));
var _asyncToGenerator2 = _interopRequireDefault(__nccwpck_require__(7400));
var _defineProperty2 = _interopRequireDefault(__nccwpck_require__(3561));
var _isRetryAllowed = _interopRequireDefault(__nccwpck_require__(841));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var namespace = 'axios-retry';
/**
* @param {Error} error
* @return {boolean}
*/
function isNetworkError(error) {
return !error.response && Boolean(error.code) && // Prevents retrying cancelled requests
error.code !== 'ECONNABORTED' && // Prevents retrying timed out requests
(0, _isRetryAllowed.default)(error); // Prevents retrying unsafe errors
}
var SAFE_HTTP_METHODS = ['get', 'head', 'options'];
var IDEMPOTENT_HTTP_METHODS = SAFE_HTTP_METHODS.concat(['put', 'delete']);
/**
* @param {Error} error
* @return {boolean}
*/
function isRetryableError(error) {
return error.code !== 'ECONNABORTED' && (!error.response || error.response.status >= 500 && error.response.status <= 599);
}
/**
* @param {Error} error
* @return {boolean}
*/
function isSafeRequestError(error) {
if (!error.config) {
// Cannot determine if the request can be retried
return false;
}
return isRetryableError(error) && SAFE_HTTP_METHODS.indexOf(error.config.method) !== -1;
}
/**
* @param {Error} error
* @return {boolean}
*/
function isIdempotentRequestError(error) {
if (!error.config) {
// Cannot determine if the request can be retried
return false;
}
return isRetryableError(error) && IDEMPOTENT_HTTP_METHODS.indexOf(error.config.method) !== -1;
}
/**
* @param {Error} error
* @return {boolean | Promise}
*/
function isNetworkOrIdempotentRequestError(error) {
return isNetworkError(error) || isIdempotentRequestError(error);
}
/**
* @return {number} - delay in milliseconds, always 0
*/
function noDelay() {
return 0;
}
/**
* @param {number} [retryNumber=0]
* @return {number} - delay in milliseconds
*/
function exponentialDelay() {
var retryNumber = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var delay = Math.pow(2, retryNumber) * 100;
var randomSum = delay * 0.2 * Math.random(); // 0-20% of the delay
return delay + randomSum;
}
/**
* Initializes and returns the retry state for the given request/config
* @param {AxiosRequestConfig} config
* @return {Object}
*/
function getCurrentState(config) {
var currentState = config[namespace] || {};
currentState.retryCount = currentState.retryCount || 0;
config[namespace] = currentState;
return currentState;
}
/**
* Returns the axios-retry options for the current request
* @param {AxiosRequestConfig} config
* @param {AxiosRetryConfig} defaultOptions
* @return {AxiosRetryConfig}
*/
function getRequestOptions(config, defaultOptions) {
return _objectSpread(_objectSpread({}, defaultOptions), config[namespace]);
}
/**
* @param {Axios} axios
* @param {AxiosRequestConfig} config
*/
function fixConfig(axios, config) {
if (axios.defaults.agent === config.agent) {
delete config.agent;
}
if (axios.defaults.httpAgent === config.httpAgent) {
delete config.httpAgent;
}
if (axios.defaults.httpsAgent === config.httpsAgent) {
delete config.httpsAgent;
}
}
/**
* Checks retryCondition if request can be retried. Handles it's retruning value or Promise.
* @param {number} retries
* @param {Function} retryCondition
* @param {Object} currentState
* @param {Error} error
* @return {boolean}
*/
function shouldRetry(_x, _x2, _x3, _x4) {
return _shouldRetry.apply(this, arguments);
}
/**
* Adds response interceptors to an axios instance to retry requests failed due to network issues
*
* @example
*
* import axios from 'axios';
*
* axiosRetry(axios, { retries: 3 });
*
* axios.get('http://example.com/test') // The first request fails and the second returns 'ok'
* .then(result => {
* result.data; // 'ok'
* });
*
* // Exponential back-off retry delay between requests
* axiosRetry(axios, { retryDelay : axiosRetry.exponentialDelay});
*
* // Custom retry delay
* axiosRetry(axios, { retryDelay : (retryCount) => {
* return retryCount * 1000;
* }});
*
* // Also works with custom axios instances
* const client = axios.create({ baseURL: 'http://example.com' });
* axiosRetry(client, { retries: 3 });
*
* client.get('/test') // The first request fails and the second returns 'ok'
* .then(result => {
* result.data; // 'ok'
* });
*
* // Allows request-specific configuration
* client
* .get('/test', {
* 'axios-retry': {
* retries: 0
* }
* })
* .catch(error => { // The first request fails
* error !== undefined
* });
*
* @param {Axios} axios An axios instance (the axios object or one created from axios.create)
* @param {Object} [defaultOptions]
* @param {number} [defaultOptions.retries=3] Number of retries
* @param {boolean} [defaultOptions.shouldResetTimeout=false]
* Defines if the timeout should be reset between retries
* @param {Function} [defaultOptions.retryCondition=isNetworkOrIdempotentRequestError]
* A function to determine if the error can be retried
* @param {Function} [defaultOptions.retryDelay=noDelay]
* A function to determine the delay between retry requests
*/
function _shouldRetry() {
_shouldRetry = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(retries, retryCondition, currentState, error) {
var shouldRetryOrPromise;
return _regenerator.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
shouldRetryOrPromise = currentState.retryCount < retries && retryCondition(error); // This could be a promise
if (!((0, _typeof2.default)(shouldRetryOrPromise) === 'object')) {
_context2.next = 11;
break;
}
_context2.prev = 2;
_context2.next = 5;
return shouldRetryOrPromise;
case 5:
return _context2.abrupt("return", true);
case 8:
_context2.prev = 8;
_context2.t0 = _context2["catch"](2);
return _context2.abrupt("return", false);
case 11:
return _context2.abrupt("return", shouldRetryOrPromise);
case 12:
case "end":
return _context2.stop();
}
}
}, _callee2, null, [[2, 8]]);
}));
return _shouldRetry.apply(this, arguments);
}
function axiosRetry(axios, defaultOptions) {
axios.interceptors.request.use(function (config) {
var currentState = getCurrentState(config);
currentState.lastRequestTime = Date.now();
return config;
});
axios.interceptors.response.use(null, /*#__PURE__*/function () {
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(error) {
var config, _getRequestOptions, _getRequestOptions$re, retries, _getRequestOptions$re2, retryCondition, _getRequestOptions$re3, retryDelay, _getRequestOptions$sh, shouldResetTimeout, currentState, delay, lastRequestDuration;
return _regenerator.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
config = error.config; // If we have no information to retry the request
if (config) {
_context.next = 3;
break;
}
return _context.abrupt("return", Promise.reject(error));
case 3:
_getRequestOptions = getRequestOptions(config, defaultOptions), _getRequestOptions$re = _getRequestOptions.retries, retries = _getRequestOptions$re === void 0 ? 3 : _getRequestOptions$re, _getRequestOptions$re2 = _getRequestOptions.retryCondition, retryCondition = _getRequestOptions$re2 === void 0 ? isNetworkOrIdempotentRequestError : _getRequestOptions$re2, _getRequestOptions$re3 = _getRequestOptions.retryDelay, retryDelay = _getRequestOptions$re3 === void 0 ? noDelay : _getRequestOptions$re3, _getRequestOptions$sh = _getRequestOptions.shouldResetTimeout, shouldResetTimeout = _getRequestOptions$sh === void 0 ? false : _getRequestOptions$sh;
currentState = getCurrentState(config);
_context.next = 7;
return shouldRetry(retries, retryCondition, currentState, error);
case 7:
if (!_context.sent) {
_context.next = 14;
break;
}
currentState.retryCount += 1;
delay = retryDelay(currentState.retryCount, error); // Axios fails merging this configuration to the default configuration because it has an issue
// with circular structures: https://github.com/mzabriskie/axios/issues/370
fixConfig(axios, config);
if (!shouldResetTimeout && config.timeout && currentState.lastRequestTime) {
lastRequestDuration = Date.now() - currentState.lastRequestTime; // Minimum 1ms timeout (passing 0 or less to XHR means no timeout)
config.timeout = Math.max(config.timeout - lastRequestDuration - delay, 1);
}
config.transformRequest = [function (data) {
return data;
}];
return _context.abrupt("return", new Promise(function (resolve) {
return setTimeout(function () {
return resolve(axios(config));
}, delay);
}));
case 14:
return _context.abrupt("return", Promise.reject(error));
case 15:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return function (_x5) {
return _ref.apply(this, arguments);
};
}());
} // Compatibility with CommonJS
axiosRetry.isNetworkError = isNetworkError;
axiosRetry.isSafeRequestError = isSafeRequestError;
axiosRetry.isIdempotentRequestError = isIdempotentRequestError;
axiosRetry.isNetworkOrIdempotentRequestError = isNetworkOrIdempotentRequestError;
axiosRetry.exponentialDelay = exponentialDelay;
axiosRetry.isRetryableError = isRetryableError;
//# sourceMappingURL=index.js.map
/***/ }),
/***/ 6545:
@@ -5129,6 +5604,53 @@ module.exports = (flag, argv = process.argv) => {
};
/***/ }),
/***/ 841:
/***/ ((module) => {
"use strict";
const denyList = new Set([
'ENOTFOUND',
'ENETUNREACH',
// SSL errors from https://github.com/nodejs/node/blob/fc8e3e2cdc521978351de257030db0076d79e0ab/src/crypto/crypto_common.cc#L301-L328
'UNABLE_TO_GET_ISSUER_CERT',
'UNABLE_TO_GET_CRL',
'UNABLE_TO_DECRYPT_CERT_SIGNATURE',
'UNABLE_TO_DECRYPT_CRL_SIGNATURE',
'UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY',
'CERT_SIGNATURE_FAILURE',
'CRL_SIGNATURE_FAILURE',
'CERT_NOT_YET_VALID',
'CERT_HAS_EXPIRED',
'CRL_NOT_YET_VALID',
'CRL_HAS_EXPIRED',
'ERROR_IN_CERT_NOT_BEFORE_FIELD',
'ERROR_IN_CERT_NOT_AFTER_FIELD',
'ERROR_IN_CRL_LAST_UPDATE_FIELD',
'ERROR_IN_CRL_NEXT_UPDATE_FIELD',
'OUT_OF_MEM',
'DEPTH_ZERO_SELF_SIGNED_CERT',
'SELF_SIGNED_CERT_IN_CHAIN',
'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',
'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
'CERT_CHAIN_TOO_LONG',
'CERT_REVOKED',
'INVALID_CA',
'PATH_LENGTH_EXCEEDED',
'INVALID_PURPOSE',
'CERT_UNTRUSTED',
'CERT_REJECTED',
'HOSTNAME_MISMATCH'
]);
// TODO: Use `error?.code` when targeting Node.js 14
module.exports = error => !denyList.has(error && error.code);
/***/ }),
/***/ 900:
@@ -6651,6 +7173,70 @@ class Deployment {
module.exports = {Deployment}
/***/ }),
/***/ 9557:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
const core = __nccwpck_require__(2186)
const axios = __nccwpck_require__(6545)
const axiosRetry = __nccwpck_require__(9179)
const retryAttempt = 3
axiosRetry(axios, {
retries: retryAttempt,
retryDelay: retryCount => {
core.info(`retrying to send pages telemetry with attempt: ${retryCount}`)
return retryCount * 1000 // time interval between retries, with 1s, 2s, 3s
},
// retry on error greater than 500
retryCondition: error => {
return error.response.status >= 500
}
})
const {Deployment} = __nccwpck_require__(2877)
async function emitTelemetry() {
// All variables we need from the runtime are set in the Deployment constructor
const deployment = new Deployment()
const telemetryUrl = `https://api.github.com/repos/${deployment.repositoryNwo}/pages/telemetry`
core.info(`Sending telemetry for run id ${deployment.workflowRun}`)
await axios
.post(
telemetryUrl,
{github_run_id: deployment.workflowRun},
{
headers: {
Accept: 'application/vnd.github.v3+json',
Authorization: `Bearer ${deployment.githubToken}`,
'Content-type': 'application/json'
}
}
)
.catch(err => {
if (err.response.status !== 200) {
throw new Error(
`failed to emit metric with status code: ${err.response.status} after ${retryAttempt} retry attempts`
)
}
})
}
async function main() {
try {
await emitTelemetry()
} catch (error) {
core.error('failed to emit pages build telemetry')
}
}
main()
module.exports = {emitTelemetry}
/***/ }),
/***/ 2357:
@@ -6860,7 +7446,7 @@ process.on('SIGINT', cancelHandler)
process.on('SIGTERM', cancelHandler)
// Main
main()
main().then(() => __nccwpck_require__(9557))
})();

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

56
dist/licenses.txt vendored
View File

@@ -35,6 +35,32 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@babel/runtime
MIT
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other 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.
axios
MIT
Copyright (c) 2014-present Matt Zabriskie
@@ -58,6 +84,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
axios-retry
Apache-2.0
Copyright 2019 Softonic International S.A.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
debug
MIT
(The MIT License)
@@ -116,6 +158,20 @@ The above copyright notice and this permission notice shall be included in all c
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.
is-retry-allowed
MIT
MIT License
Copyright (c) Vsevolod Strukchinsky <floatdrop@gmail.com> (github.com/floatdrop)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.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.
ms
MIT
The MIT License (MIT)