renovate 43.207.1 → 43.207.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/util/http/got.js
CHANGED
|
@@ -3,7 +3,6 @@ import { logger } from "../../logger/index.js";
|
|
|
3
3
|
import { HttpStats } from "../stats.js";
|
|
4
4
|
import { coerceNumber } from "../number.js";
|
|
5
5
|
import "./legacy.js";
|
|
6
|
-
import { hooks } from "./hooks.js";
|
|
7
6
|
import { GotExtraOptionKeys } from "./types.js";
|
|
8
7
|
import { isNumber } from "@sindresorhus/is";
|
|
9
8
|
import got, { RequestError, RequestError as RequestError$1 } from "got";
|
|
@@ -26,10 +25,7 @@ async function fetch(url, options, queueStats) {
|
|
|
26
25
|
let duration = 0;
|
|
27
26
|
let statusCode = 0;
|
|
28
27
|
try {
|
|
29
|
-
const resp = await got(url, {
|
|
30
|
-
...options,
|
|
31
|
-
hooks
|
|
32
|
-
});
|
|
28
|
+
const resp = await got(url, { ...options });
|
|
33
29
|
statusCode = resp.statusCode;
|
|
34
30
|
duration = coerceNumber(resp.timings.phases.total, 0);
|
|
35
31
|
return resp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"got.js","names":[],"sources":["../../../lib/util/http/got.ts"],"sourcesContent":["// TODO: refactor code to remove this (#9651)\nimport './legacy.ts';\n\nimport { isNumber } from '@sindresorhus/is';\nimport type { OptionsInit } from 'got';\nimport got, { RequestError } from 'got';\nimport type { SetRequired } from 'type-fest';\nimport { logger } from '../../logger/index.ts';\nimport { coerceNumber } from '../number.ts';\nimport { type HttpRequestStatsDataPoint, HttpStats } from '../stats.ts';\nimport { coerceString } from '../string.ts';\nimport {
|
|
1
|
+
{"version":3,"file":"got.js","names":[],"sources":["../../../lib/util/http/got.ts"],"sourcesContent":["// TODO: refactor code to remove this (#9651)\nimport './legacy.ts';\n\nimport { isNumber } from '@sindresorhus/is';\nimport type { OptionsInit } from 'got';\nimport got, { RequestError } from 'got';\nimport type { SetRequired } from 'type-fest';\nimport { logger } from '../../logger/index.ts';\nimport { coerceNumber } from '../number.ts';\nimport { type HttpRequestStatsDataPoint, HttpStats } from '../stats.ts';\nimport { coerceString } from '../string.ts';\nimport {\n type GotBufferOptions,\n GotExtraOptionKeys,\n type GotOptions,\n type HttpResponse,\n} from './types.ts';\n\nexport { RequestError } from 'got';\n\ntype QueueStatsData = Pick<HttpRequestStatsDataPoint, 'queueMs'>;\n\nexport function configureRejectUnauth(options: OptionsInit): void {\n if (process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0') {\n logger.once.warn(\n 'NODE_TLS_REJECT_UNAUTHORIZED=0 found, this is strongly discouraged.',\n );\n options.https = { ...options.https, rejectUnauthorized: false };\n }\n}\n\nexport async function fetch(\n url: string,\n options: SetRequired<GotOptions, 'method'>,\n queueStats: QueueStatsData,\n): Promise<HttpResponse<unknown>> {\n logger.trace({ url, options }, 'got request');\n configureRejectUnauth(options);\n\n let duration = 0;\n let statusCode = 0;\n try {\n // Cheat the TS compiler using `as` to pick a specific overload.\n // Otherwise it doesn't typecheck.\n const resp = await got(url, { ...options } as GotBufferOptions);\n statusCode = resp.statusCode;\n duration = coerceNumber(resp.timings.phases.total, 0);\n return resp;\n } catch (error) {\n // v8 ignore else -- TODO: add test #40625\n if (error instanceof RequestError) {\n statusCode = coerceNumber(error.response?.statusCode, -1);\n duration = coerceNumber(error.timings?.phases.total, -1);\n const method = options.method.toUpperCase();\n const code = coerceString(error.code, 'UNKNOWN');\n const retryCount = coerceNumber(error.request?.retryCount, -1);\n logger.debug(\n `${method} ${url} = (code=${code}, statusCode=${statusCode} retryCount=${retryCount}, duration=${duration})`,\n );\n }\n\n throw error;\n /* v8 ignore next: 🐛 https://github.com/bcoe/c8/issues/229 */\n } finally {\n HttpStats.write({\n method: options.method,\n url,\n reqMs: duration,\n queueMs: queueStats.queueMs,\n status: statusCode,\n });\n }\n}\n\nexport function stream(\n url: string,\n options: Omit<OptionsInit, 'isStream'>,\n): NodeJS.ReadableStream {\n configureRejectUnauth(options);\n return got.stream(url, options);\n}\n\n/**\n * Removes non-got options and normalizes some options to match got's expected format.\n * @param options options to normalize\n * @returns normalized got options\n */\nexport function normalize<T extends OptionsInit = OptionsInit>(\n options: T,\n keysToRemove: readonly string[],\n): T {\n // flat copy to void mutating the original options object\n const opts = { ...options };\n\n for (const key of [...GotExtraOptionKeys, ...keysToRemove]) {\n // @ts-expect-error -- delete extra options before passing to got\n delete opts[key];\n }\n\n // optimize options for got v12+\n if (isNumber(opts.timeout)) {\n opts.timeout = { request: opts.timeout };\n }\n\n return opts;\n}\n"],"mappings":";;;;;;;;;AAsBA,SAAgB,sBAAsB,SAA4B;CAChE,IAAI,QAAQ,IAAI,iCAAiC,KAAK;EACpD,OAAO,KAAK,KACV,qEACF;EACA,QAAQ,QAAQ;GAAE,GAAG,QAAQ;GAAO,oBAAoB;EAAM;CAChE;AACF;AAEA,eAAsB,MACpB,KACA,SACA,YACgC;CAChC,OAAO,MAAM;EAAE;EAAK;CAAQ,GAAG,aAAa;CAC5C,sBAAsB,OAAO;CAE7B,IAAI,WAAW;CACf,IAAI,aAAa;CACjB,IAAI;EAGF,MAAM,OAAO,MAAM,IAAI,KAAK,EAAE,GAAG,QAAQ,CAAqB;EAC9D,aAAa,KAAK;EAClB,WAAW,aAAa,KAAK,QAAQ,OAAO,OAAO,CAAC;EACpD,OAAO;CACT,SAAS,OAAO;;EAEd,IAAI,iBAAiB,cAAc;GACjC,aAAa,aAAa,MAAM,UAAU,YAAY,EAAE;GACxD,WAAW,aAAa,MAAM,SAAS,OAAO,OAAO,EAAE;GACvD,MAAM,SAAS,QAAQ,OAAO,YAAY;GAC1C,MAAM,OAAO,aAAa,MAAM,MAAM,SAAS;GAC/C,MAAM,aAAa,aAAa,MAAM,SAAS,YAAY,EAAE;GAC7D,OAAO,MACL,GAAG,OAAO,GAAG,IAAI,WAAW,KAAK,eAAe,WAAW,cAAc,WAAW,aAAa,SAAS,EAC5G;EACF;EAEA,MAAM;CAER,UAAU;EACR,UAAU,MAAM;GACd,QAAQ,QAAQ;GAChB;GACA,OAAO;GACP,SAAS,WAAW;GACpB,QAAQ;EACV,CAAC;CACH;AACF;AAEA,SAAgB,OACd,KACA,SACuB;CACvB,sBAAsB,OAAO;CAC7B,OAAO,IAAI,OAAO,KAAK,OAAO;AAChC;;;;;;AAOA,SAAgB,UACd,SACA,cACG;CAEH,MAAM,OAAO,EAAE,GAAG,QAAQ;CAE1B,KAAK,MAAM,OAAO,CAAC,GAAG,oBAAoB,GAAG,YAAY,GAEvD,OAAO,KAAK;CAId,IAAI,SAAS,KAAK,OAAO,GACvB,KAAK,UAAU,EAAE,SAAS,KAAK,QAAQ;CAGzC,OAAO;AACT"}
|
package/package.json
CHANGED
package/dist/util/http/hooks.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region lib/util/http/hooks.ts
|
|
2
|
-
function isResponseOk(response) {
|
|
3
|
-
const { statusCode } = response;
|
|
4
|
-
const limitStatusCode = response.request.options.followRedirect ? 299 : 399;
|
|
5
|
-
return statusCode >= 200 && statusCode <= limitStatusCode || statusCode === 304;
|
|
6
|
-
}
|
|
7
|
-
function hook(response) {
|
|
8
|
-
if (isResponseOk(response)) response.request.destroy();
|
|
9
|
-
return response;
|
|
10
|
-
}
|
|
11
|
-
const hooks = { afterResponse: [hook] };
|
|
12
|
-
//#endregion
|
|
13
|
-
export { hooks };
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=hooks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","names":[],"sources":["../../../lib/util/http/hooks.ts"],"sourcesContent":["// Renovate issue: https://github.com/renovatebot/renovate/issues/12127\n// Got issue: https://github.com/sindresorhus/got/issues/1489\n// From here: https://github.com/sindresorhus/got/issues/1489#issuecomment-805485731\n// fixed in https://github.com/sindresorhus/got/releases/tag/v14.6.0\n// TODO: remove when got is upgraded to v14.6.0+\nimport type { Hooks, Response } from 'got';\n\nexport function isResponseOk(response: Response): boolean {\n const { statusCode } = response;\n const limitStatusCode = response.request.options.followRedirect ? 299 : 399;\n\n return (\n (statusCode >= 200 && statusCode <= limitStatusCode) || statusCode === 304\n );\n}\n\nexport function hook(response: Response): Response {\n if (isResponseOk(response)) {\n response.request.destroy();\n }\n\n return response;\n}\n\nexport const hooks: Partial<Hooks> = {\n afterResponse: [hook],\n};\n"],"mappings":";AAOA,SAAgB,aAAa,UAA6B;CACxD,MAAM,EAAE,eAAe;CACvB,MAAM,kBAAkB,SAAS,QAAQ,QAAQ,iBAAiB,MAAM;CAExE,OACG,cAAc,OAAO,cAAc,mBAAoB,eAAe;AAE3E;AAEA,SAAgB,KAAK,UAA8B;CACjD,IAAI,aAAa,QAAQ,GACvB,SAAS,QAAQ,QAAQ;CAG3B,OAAO;AACT;AAEA,MAAa,QAAwB,EACnC,eAAe,CAAC,IAAI,EACtB"}
|