renovate 42.19.9 → 42.20.0
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/config/migrate-validate.js +1 -2
- package/dist/config/migrate-validate.js.map +1 -1
- package/dist/config/migration.js +0 -1
- package/dist/config/migration.js.map +1 -1
- package/dist/config/options/index.js +1 -1
- package/dist/config/options/index.js.map +1 -1
- package/dist/instrumentation/index.js +3 -4
- package/dist/instrumentation/index.js.map +1 -1
- package/dist/modules/datasource/crate/index.js +1 -1
- package/dist/modules/datasource/crate/index.js.map +1 -1
- package/dist/modules/datasource/docker/common.js +6 -0
- package/dist/modules/datasource/docker/common.js.map +1 -1
- package/dist/modules/datasource/docker/schema.js +1 -1
- package/dist/modules/datasource/docker/schema.js.map +1 -1
- package/dist/modules/datasource/go/index.js +1 -2
- package/dist/modules/datasource/go/index.js.map +1 -1
- package/dist/modules/datasource/maven/index.js +2 -2
- package/dist/modules/datasource/maven/index.js.map +1 -1
- package/dist/modules/datasource/maven/util.js +2 -2
- package/dist/modules/datasource/maven/util.js.map +1 -1
- package/dist/modules/manager/bazel/artifacts.js +2 -2
- package/dist/modules/manager/bazel/artifacts.js.map +1 -1
- package/dist/modules/manager/maven-wrapper/artifacts.js +2 -2
- package/dist/modules/manager/maven-wrapper/artifacts.js.map +1 -1
- package/dist/modules/manager/npm/extract/common/package-file.js +2 -2
- package/dist/modules/manager/npm/extract/common/package-file.js.map +1 -1
- package/dist/modules/manager/npm/extract/yarn.js +2 -2
- package/dist/modules/manager/npm/extract/yarn.js.map +1 -1
- package/dist/modules/manager/npm/post-update/index.js +14 -18
- package/dist/modules/manager/npm/post-update/index.js.map +1 -1
- package/dist/modules/manager/npm/post-update/npm.js +4 -4
- package/dist/modules/manager/npm/post-update/npm.js.map +1 -1
- package/dist/modules/manager/npm/post-update/pnpm.js +4 -4
- package/dist/modules/manager/npm/post-update/pnpm.js.map +1 -1
- package/dist/modules/manager/npm/post-update/yarn.js +6 -6
- package/dist/modules/manager/npm/post-update/yarn.js.map +1 -1
- package/dist/modules/manager/npm/update/dependency/index.js +3 -4
- package/dist/modules/manager/npm/update/dependency/index.js.map +1 -1
- package/dist/modules/manager/npm/update/dependency/pnpm.js +2 -2
- package/dist/modules/manager/npm/update/dependency/pnpm.js.map +1 -1
- package/dist/modules/manager/npm/update/index.js +1 -0
- package/dist/modules/manager/npm/update/index.js.map +1 -1
- package/dist/modules/manager/npm/update/locked-dependency/common/parent-version.js +8 -8
- package/dist/modules/manager/npm/update/locked-dependency/common/parent-version.js.map +1 -1
- package/dist/modules/manager/npm/update/locked-dependency/package-lock/dep-constraints.js +2 -2
- package/dist/modules/manager/npm/update/locked-dependency/package-lock/dep-constraints.js.map +1 -1
- package/dist/modules/manager/npm/update/locked-dependency/package-lock/index.js +5 -5
- package/dist/modules/manager/npm/update/locked-dependency/package-lock/index.js.map +1 -1
- package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/get-locked.js +4 -4
- package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/get-locked.js.map +1 -1
- package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/index.js +2 -2
- package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/index.js.map +1 -1
- package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/replace.js +2 -2
- package/dist/modules/manager/npm/update/locked-dependency/yarn-lock/replace.js.map +1 -1
- package/dist/modules/manager/npm/update/package-version/index.js +1 -2
- package/dist/modules/manager/npm/update/package-version/index.js.map +1 -1
- package/dist/modules/manager/npm/utils.js +8 -8
- package/dist/modules/manager/npm/utils.js.map +1 -1
- package/dist/modules/platform/azure/azure-helper.js +2 -2
- package/dist/modules/platform/azure/azure-helper.js.map +1 -1
- package/dist/modules/platform/azure/index.js +14 -14
- package/dist/modules/platform/azure/index.js.map +1 -1
- package/dist/modules/platform/bitbucket/comments.js +4 -4
- package/dist/modules/platform/bitbucket/comments.js.map +1 -1
- package/dist/modules/platform/bitbucket/index.js +31 -31
- package/dist/modules/platform/bitbucket/index.js.map +1 -1
- package/dist/modules/platform/bitbucket/utils.js +2 -2
- package/dist/modules/platform/bitbucket/utils.js.map +1 -1
- package/dist/modules/platform/bitbucket-server/index.js +32 -34
- package/dist/modules/platform/bitbucket-server/index.js.map +1 -1
- package/dist/modules/platform/bitbucket-server/utils.js +2 -4
- package/dist/modules/platform/bitbucket-server/utils.js.map +1 -1
- package/dist/modules/platform/codecommit/codecommit-client.js +6 -6
- package/dist/modules/platform/codecommit/codecommit-client.js.map +1 -1
- package/dist/modules/platform/codecommit/index.js +24 -24
- package/dist/modules/platform/codecommit/index.js.map +1 -1
- package/dist/modules/platform/forgejo/forgejo-helper.d.ts +1 -0
- package/dist/modules/platform/forgejo/forgejo-helper.js +26 -0
- package/dist/modules/platform/forgejo/forgejo-helper.js.map +1 -1
- package/dist/modules/platform/forgejo/index.js +35 -20
- package/dist/modules/platform/forgejo/index.js.map +1 -1
- package/dist/modules/platform/gitea/index.js +4 -4
- package/dist/modules/platform/gitea/index.js.map +1 -1
- package/dist/modules/platform/github/index.js +68 -68
- package/dist/modules/platform/github/index.js.map +1 -1
- package/dist/modules/platform/github/massage-markdown-links.js +2 -2
- package/dist/modules/platform/github/massage-markdown-links.js.map +1 -1
- package/dist/modules/platform/github/pr.js +2 -2
- package/dist/modules/platform/github/pr.js.map +1 -1
- package/dist/modules/platform/github/schema.js +1 -2
- package/dist/modules/platform/github/schema.js.map +1 -1
- package/dist/modules/platform/gitlab/index.js +29 -30
- package/dist/modules/platform/gitlab/index.js.map +1 -1
- package/dist/modules/platform/utils/pr-body.js +7 -3
- package/dist/modules/platform/utils/pr-body.js.map +1 -1
- package/dist/proxy.js +1 -2
- package/dist/proxy.js.map +1 -1
- package/dist/util/cache/package/index.js +2 -2
- package/dist/util/cache/package/index.js.map +1 -1
- package/dist/util/cache/package/namespaces.js +1 -1
- package/dist/util/cache/package/namespaces.js.map +1 -1
- package/dist/util/cache/repository/types.d.ts +1 -0
- package/dist/util/cache/repository/types.js.map +1 -1
- package/dist/util/git/error.js +5 -4
- package/dist/util/git/error.js.map +1 -1
- package/dist/util/git/index.js +10 -12
- package/dist/util/git/index.js.map +1 -1
- package/dist/util/git/private-key.js +2 -0
- package/dist/util/git/private-key.js.map +1 -1
- package/dist/util/http/bitbucket.js +1 -2
- package/dist/util/http/bitbucket.js.map +1 -1
- package/dist/util/http/cache/abstract-http-cache-provider.js +2 -2
- package/dist/util/http/cache/abstract-http-cache-provider.js.map +1 -1
- package/dist/util/http/http.js +1 -1
- package/dist/util/http/http.js.map +1 -1
- package/dist/util/stats.js +1 -1
- package/dist/util/stats.js.map +1 -1
- package/dist/workers/global/config/parse/codespaces.js +1 -2
- package/dist/workers/global/config/parse/codespaces.js.map +1 -1
- package/dist/workers/repository/update/branch/auto-replace.js +4 -2
- package/dist/workers/repository/update/branch/auto-replace.js.map +1 -1
- package/dist/workers/repository/update/branch/automerge.js +4 -1
- package/dist/workers/repository/update/branch/automerge.js.map +1 -1
- package/dist/workers/repository/update/branch/execute-post-upgrade-commands.js +1 -0
- package/dist/workers/repository/update/branch/execute-post-upgrade-commands.js.map +1 -1
- package/dist/workers/repository/update/branch/index.js +16 -8
- package/dist/workers/repository/update/branch/index.js.map +1 -1
- package/package.json +3 -2
- package/renovate-schema.json +3 -3
package/dist/util/http/http.js
CHANGED
|
@@ -101,7 +101,7 @@ class HttpBase {
|
|
|
101
101
|
// Cache GET requests unless memCache=false
|
|
102
102
|
if (memCacheKey) {
|
|
103
103
|
resPromise = memCache.get(memCacheKey);
|
|
104
|
-
/* v8 ignore
|
|
104
|
+
/* v8 ignore next: temporary code */
|
|
105
105
|
if (resPromise && !cacheProvider) {
|
|
106
106
|
stats_1.ObsoleteCacheHitLogger.write(url);
|
|
107
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../lib/util/http/http.ts"],"names":[],"mappings":";;;AA+DA,kDAQC;;AAvED,yCAA8D;AAC9D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E,CAAC;YACX,GAAG,CAAC,IAAI,GAAG,MAAM,mBAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,mBAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAkB,CAAC;QAChE,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAxnBD,4BAwnBC","sourcesContent":["import { isPlainObject, isUndefined } from '@sindresorhus/is';\nimport merge from 'deepmerge';\nimport type { Options, RetryObject } from 'got';\nimport type { Merge, SetRequired } from 'type-fest';\nimport type { infer as Infer } from 'zod';\nimport { ZodType } from 'zod';\nimport { GlobalConfig } from '../../config/global';\nimport { HOST_DISABLED } from '../../constants/error-messages';\nimport { pkg } from '../../expose.cjs';\nimport { logger } from '../../logger';\nimport { ExternalHostError } from '../../types/errors/external-host-error';\nimport * as memCache from '../cache/memory';\nimport { getEnv } from '../env';\nimport { hash } from '../hash';\nimport { type AsyncResult, Result } from '../result';\nimport { Toml } from '../schema-utils';\nimport { ObsoleteCacheHitLogger } from '../stats';\nimport { isHttpUrl, parseUrl, resolveBaseUrl } from '../url';\nimport { parseSingleYaml } from '../yaml';\nimport { applyAuthorization, removeAuthorization } from './auth';\nimport type { HttpCacheProvider } from './cache/types';\nimport { fetch, stream } from './got';\nimport { applyHostRule, findMatchingRule } from './host-rules';\n\nimport { getQueue } from './queue';\nimport { getRetryAfter, wrapWithRetry } from './retry-after';\nimport { getThrottle } from './throttle';\nimport type {\n GotOptions,\n GotStreamOptions,\n GotTask,\n HttpMethod,\n HttpOptions,\n HttpResponse,\n SafeJsonError,\n} from './types';\nimport { copyResponse } from './util';\n\nexport interface InternalJsonUnsafeOptions<\n Opts extends HttpOptions = HttpOptions,\n> {\n url: string | URL;\n httpOptions?: Opts;\n}\n\nexport interface InternalJsonOptions<\n Opts extends HttpOptions,\n ResT = unknown,\n Schema extends ZodType<ResT> = ZodType<ResT>,\n> extends InternalJsonUnsafeOptions<Opts> {\n schema?: Schema;\n}\n\nexport type InternalGotOptions = SetRequired<GotOptions, 'method' | 'context'>;\n\nexport interface InternalHttpOptions extends HttpOptions {\n json?: HttpOptions['body'];\n\n method?: HttpMethod;\n\n parseJson?: Options['parseJson'];\n}\n\nexport function applyDefaultHeaders(options: Options): void {\n const renovateVersion = pkg.version;\n options.headers = {\n ...options.headers,\n 'user-agent':\n GlobalConfig.get('userAgent') ??\n `Renovate/${renovateVersion} (https://github.com/renovatebot/renovate)`,\n };\n}\n\nexport abstract class HttpBase<\n JSONOpts extends HttpOptions = HttpOptions,\n Opts extends HttpOptions = HttpOptions,\n> {\n private readonly options: InternalGotOptions;\n\n protected get baseUrl(): string | undefined {\n return undefined;\n }\n\n constructor(\n protected hostType: string,\n options: HttpOptions = {},\n ) {\n const retryLimit = getEnv().NODE_ENV === 'test' ? 0 : 2;\n this.options = merge<InternalGotOptions>(\n options,\n {\n method: 'get',\n context: { hostType },\n retry: {\n calculateDelay: (retryObject) =>\n this.calculateRetryDelay(retryObject),\n limit: retryLimit,\n maxRetryAfter: 0, // Don't rely on `got` retry-after handling, just let it fail and then we'll handle it\n },\n },\n { isMergeableObject: isPlainObject },\n );\n }\n private async request(\n requestUrl: string | URL,\n httpOptions: InternalHttpOptions,\n ): Promise<HttpResponse<string>>;\n private async request(\n requestUrl: string | URL,\n httpOptions: InternalHttpOptions & { responseType: 'text' },\n ): Promise<HttpResponse<string>>;\n private async request(\n requestUrl: string | URL,\n httpOptions: InternalHttpOptions & { responseType: 'buffer' },\n ): Promise<HttpResponse<Buffer>>;\n private async request<T = unknown>(\n requestUrl: string | URL,\n httpOptions: InternalHttpOptions & { responseType: 'json' },\n ): Promise<HttpResponse<T>>;\n\n private async request(\n requestUrl: string | URL,\n httpOptions: InternalHttpOptions,\n ): Promise<HttpResponse<unknown>> {\n const resolvedUrl = this.resolveUrl(requestUrl, httpOptions);\n const url = resolvedUrl.toString();\n\n this.processOptions(resolvedUrl, httpOptions);\n\n let options = merge<InternalGotOptions, InternalHttpOptions>(\n {\n ...this.options,\n hostType: this.hostType,\n },\n httpOptions,\n { isMergeableObject: isPlainObject },\n );\n\n const method = options.method.toLowerCase();\n const isReadMethod = ['head', 'get'].includes(method);\n\n logger.trace(`HTTP request: ${method.toUpperCase()} ${url}`);\n\n options.hooks = {\n beforeRedirect: [removeAuthorization],\n };\n\n applyDefaultHeaders(options);\n\n if (isUndefined(options.readOnly) && isReadMethod) {\n options.readOnly = true;\n }\n\n const hostRule = findMatchingRule(url, options);\n options = applyHostRule(url, options, hostRule);\n if (options.enabled === false) {\n logger.debug(`Host is disabled - rejecting request. HostUrl: ${url}`);\n throw new Error(HOST_DISABLED);\n }\n options = applyAuthorization(options);\n options.timeout ??= 60000;\n\n let cacheProvider: HttpCacheProvider | undefined;\n if (isReadMethod && options.cacheProvider) {\n cacheProvider = options.cacheProvider;\n }\n\n const memCacheKey =\n !process.env.RENOVATE_X_DISABLE_HTTP_MEMCACHE &&\n !cacheProvider &&\n options.memCache !== false &&\n isReadMethod\n ? hash(\n `got-${JSON.stringify({\n url,\n headers: options.headers,\n method,\n })}`,\n )\n : null;\n\n const cachedResponse = await cacheProvider?.bypassServer<unknown>(\n method,\n url,\n );\n if (cachedResponse) {\n return cachedResponse;\n }\n\n let resPromise: Promise<HttpResponse<unknown>> | null = null;\n\n // Cache GET requests unless memCache=false\n if (memCacheKey) {\n resPromise = memCache.get(memCacheKey);\n\n /* v8 ignore start: temporary code */\n if (resPromise && !cacheProvider) {\n ObsoleteCacheHitLogger.write(url);\n }\n /* v8 ignore stop: temporary code */\n }\n\n if (!resPromise) {\n if (cacheProvider) {\n await cacheProvider.setCacheHeaders(method, url, options);\n }\n\n const startTime = Date.now();\n const httpTask: GotTask = () => {\n const queueMs = Date.now() - startTime;\n return fetch(url, options, { queueMs });\n };\n\n const throttle = getThrottle(url);\n const throttledTask = throttle ? () => throttle.add(httpTask) : httpTask;\n\n const queue = getQueue(url);\n const queuedTask = queue ? () => queue.add(throttledTask) : throttledTask;\n\n const { maxRetryAfter = 60 } = hostRule;\n resPromise = wrapWithRetry(queuedTask, url, getRetryAfter, maxRetryAfter);\n\n if (memCacheKey) {\n memCache.set(memCacheKey, resPromise);\n }\n }\n\n try {\n const res = await resPromise;\n const deepCopyNeeded = !!memCacheKey && res.statusCode !== 304;\n const resCopy = copyResponse(res, deepCopyNeeded);\n resCopy.authorization = !!options?.headers?.authorization;\n\n if (cacheProvider) {\n return await cacheProvider.wrapServerResponse(method, url, resCopy);\n }\n\n return resCopy;\n } catch (err) {\n const { abortOnError, abortIgnoreStatusCodes } = options;\n if (abortOnError && !abortIgnoreStatusCodes?.includes(err.statusCode)) {\n throw new ExternalHostError(err);\n }\n\n const staleResponse = await cacheProvider?.bypassServer<string | Buffer>(\n method,\n url,\n true,\n );\n if (staleResponse) {\n logger.debug(\n { err },\n `Request error: returning stale cache instead for ${url}`,\n );\n return staleResponse;\n }\n\n this.handleError(requestUrl, httpOptions, err);\n }\n }\n\n protected processOptions(_url: URL, _options: InternalHttpOptions): void {\n // noop\n }\n\n protected handleError(\n _url: string | URL,\n _httpOptions: HttpOptions,\n err: Error,\n ): never {\n throw err;\n }\n\n resolveUrl(\n requestUrl: string | URL,\n options: HttpOptions | undefined = undefined,\n ): URL {\n let url = requestUrl;\n\n if (url instanceof URL) {\n // already a aboslute URL\n return url;\n }\n\n const baseUrl = options?.baseUrl ?? this.baseUrl;\n if (baseUrl) {\n url = resolveBaseUrl(baseUrl, url);\n }\n\n const parsedUrl = parseUrl(url);\n if (!parsedUrl || !isHttpUrl(parsedUrl)) {\n logger.error(\n { url: requestUrl, baseUrl, resolvedUrl: url },\n 'Request Error: cannot parse url',\n );\n throw new Error('Invalid URL');\n }\n return parsedUrl;\n }\n\n protected calculateRetryDelay({ computedValue }: RetryObject): number {\n return computedValue;\n }\n\n get(\n url: string,\n options: HttpOptions = {},\n ): Promise<HttpResponse<string | Buffer>> {\n return this.request(url, options);\n }\n\n head(url: string, options: HttpOptions = {}): Promise<HttpResponse<never>> {\n // to complex to validate\n return this.request(url, {\n ...options,\n responseType: 'text',\n method: 'head',\n }) as Promise<HttpResponse<never>>;\n }\n\n getText(\n url: string | URL,\n options: HttpOptions = {},\n ): Promise<HttpResponse<string>> {\n return this.request(url, { ...options, responseType: 'text' });\n }\n\n getBuffer(\n url: string | URL,\n options: HttpOptions = {},\n ): Promise<HttpResponse<Buffer>> {\n return this.request(url, { ...options, responseType: 'buffer' });\n }\n\n protected requestJsonUnsafe<ResT>(\n method: HttpMethod,\n { url, httpOptions: requestOptions }: InternalJsonUnsafeOptions<JSONOpts>,\n ): Promise<HttpResponse<ResT>> {\n const { body: json, ...httpOptions } = { ...requestOptions };\n const opts: InternalHttpOptions = {\n ...httpOptions,\n method,\n };\n // signal that we expect a json response\n opts.headers = {\n accept: 'application/json',\n ...opts.headers,\n };\n if (json) {\n opts.json = json;\n }\n return this.request<ResT>(url, { ...opts, responseType: 'json' });\n }\n\n private async requestJson<ResT, Schema extends ZodType<ResT> = ZodType<ResT>>(\n method: HttpMethod,\n options: InternalJsonOptions<JSONOpts, ResT, Schema>,\n ): Promise<HttpResponse<ResT>> {\n const res = await this.requestJsonUnsafe<ResT>(method, options);\n\n if (options.schema) {\n res.body = await options.schema.parseAsync(res.body);\n }\n\n return res;\n }\n\n private resolveArgs<ResT = unknown>(\n arg1: string,\n arg2: JSONOpts | ZodType<ResT> | undefined,\n arg3: ZodType<ResT> | undefined,\n ): InternalJsonOptions<JSONOpts, ResT> {\n const res: InternalJsonOptions<JSONOpts, ResT> = { url: arg1 };\n\n if (arg2 instanceof ZodType) {\n res.schema = arg2;\n } else if (arg2) {\n res.httpOptions = arg2;\n }\n\n if (arg3) {\n res.schema = arg3;\n }\n\n return res;\n }\n\n async getPlain(url: string, options?: Opts): Promise<HttpResponse> {\n const opt = options ?? {};\n return await this.getText(url, {\n headers: {\n Accept: 'text/plain',\n },\n ...opt,\n });\n }\n\n /**\n * @deprecated use `getYaml` instead\n */\n async getYamlUnchecked<ResT>(\n url: string,\n options?: Opts,\n ): Promise<HttpResponse<ResT>> {\n const res = await this.getText(url, options);\n const body = parseSingleYaml<ResT>(res.body);\n return { ...res, body };\n }\n\n async getYaml<Schema extends ZodType<any, any, any>>(\n url: string,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n async getYaml<Schema extends ZodType<any, any, any>>(\n url: string,\n options: Opts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n async getYaml<Schema extends ZodType<any, any, any>>(\n arg1: string,\n arg2?: Opts | Schema,\n arg3?: Schema,\n ): Promise<HttpResponse<Infer<Schema>>> {\n const url = arg1;\n let schema: Schema;\n let httpOptions: Opts | undefined;\n if (arg3) {\n schema = arg3;\n httpOptions = arg2 as Opts;\n } else {\n schema = arg2 as Schema;\n }\n\n const opts: InternalHttpOptions = {\n ...httpOptions,\n method: 'get',\n };\n\n const res = await this.getText(url, opts);\n const body = await schema.parseAsync(parseSingleYaml(res.body));\n return { ...res, body };\n }\n\n getYamlSafe<\n ResT extends NonNullable<unknown>,\n Schema extends ZodType<ResT> = ZodType<ResT>,\n >(url: string, schema: Schema): AsyncResult<Infer<Schema>, SafeJsonError>;\n getYamlSafe<\n ResT extends NonNullable<unknown>,\n Schema extends ZodType<ResT> = ZodType<ResT>,\n >(\n url: string,\n options: Opts,\n schema: Schema,\n ): AsyncResult<Infer<Schema>, SafeJsonError>;\n getYamlSafe<\n ResT extends NonNullable<unknown>,\n Schema extends ZodType<ResT> = ZodType<ResT>,\n >(\n arg1: string,\n arg2: Opts | Schema,\n arg3?: Schema,\n ): AsyncResult<ResT, SafeJsonError> {\n const url = arg1;\n let schema: Schema;\n let httpOptions: Opts | undefined;\n if (arg3) {\n schema = arg3;\n httpOptions = arg2 as Opts;\n } else {\n schema = arg2 as Schema;\n }\n\n let res: AsyncResult<HttpResponse<ResT>, SafeJsonError>;\n if (httpOptions) {\n res = Result.wrap(this.getYaml(url, httpOptions, schema));\n } else {\n res = Result.wrap(this.getYaml(url, schema));\n }\n\n return res.transform((response) => Result.ok(response.body));\n }\n\n /**\n * Request JSON and return the response without any validation.\n *\n * The usage of this method is discouraged, please use `getJson` instead.\n *\n * If you're new to Zod schema validation library:\n * - consult the [documentation of Zod library](https://github.com/colinhacks/zod?tab=readme-ov-file#basic-usage)\n * - search the Renovate codebase for 'zod' module usage\n * - take a look at the `schema-utils.ts` file for Renovate-specific schemas and utilities\n */\n getJsonUnchecked<ResT = unknown>(\n url: string,\n options?: JSONOpts,\n ): Promise<HttpResponse<ResT>> {\n return this.requestJson<ResT>('get', { url, httpOptions: options });\n }\n\n /**\n * Request JSON with a Zod schema for the response,\n * throwing an error if the response is not valid.\n *\n * @param url\n * @param schema Zod schema for the response\n */\n getJson<Schema extends ZodType<any, any, any>>(\n url: string,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n getJson<Schema extends ZodType<any, any, any>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n getJson<Schema extends ZodType<any, any, any>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: Schema,\n ): Promise<HttpResponse<Infer<Schema>>> {\n const args = this.resolveArgs<Infer<Schema>>(arg1, arg2, arg3);\n return this.requestJson<Infer<Schema>>('get', args);\n }\n\n /**\n * Request JSON with a Zod schema for the response,\n * wrapping response data in a `Result` class.\n *\n * @param url\n * @param schema Zod schema for the response\n */\n getJsonSafe<ResT extends NonNullable<unknown>, Schema extends ZodType<ResT>>(\n url: string,\n schema: Schema,\n ): AsyncResult<Infer<Schema>, SafeJsonError>;\n getJsonSafe<ResT extends NonNullable<unknown>, Schema extends ZodType<ResT>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): AsyncResult<Infer<Schema>, SafeJsonError>;\n getJsonSafe<ResT extends NonNullable<unknown>, Schema extends ZodType<ResT>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: Schema,\n ): AsyncResult<ResT, SafeJsonError> {\n const args = this.resolveArgs<ResT>(arg1, arg2, arg3);\n return Result.wrap(this.requestJson<ResT>('get', args)).transform(\n (response) => Result.ok(response.body),\n );\n }\n\n /**\n * @deprecated use `head` instead\n */\n headJson(url: string, httpOptions?: JSONOpts): Promise<HttpResponse<never>> {\n return this.requestJson<never>('head', { url, httpOptions });\n }\n\n postJson<T>(url: string, options?: JSONOpts): Promise<HttpResponse<T>>;\n postJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n postJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n postJson<T = unknown, Schema extends ZodType<T> = ZodType<T>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: Schema,\n ): Promise<HttpResponse<T>> {\n const args = this.resolveArgs(arg1, arg2, arg3);\n return this.requestJson<T>('post', args);\n }\n\n putJson<T>(url: string, options?: JSONOpts): Promise<HttpResponse<T>>;\n putJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n putJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n putJson<T = unknown, Schema extends ZodType<T> = ZodType<T>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: ZodType,\n ): Promise<HttpResponse<T>> {\n const args = this.resolveArgs(arg1, arg2, arg3);\n return this.requestJson<T>('put', args);\n }\n\n patchJson<T>(url: string, options?: JSONOpts): Promise<HttpResponse<T>>;\n patchJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n patchJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n patchJson<T = unknown, Schema extends ZodType<T> = ZodType<T>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: Schema,\n ): Promise<HttpResponse<T>> {\n const args = this.resolveArgs(arg1, arg2, arg3);\n return this.requestJson<T>('patch', args);\n }\n\n deleteJson<T>(url: string, options?: JSONOpts): Promise<HttpResponse<T>>;\n deleteJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n deleteJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n deleteJson<T = unknown, Schema extends ZodType<T> = ZodType<T>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: Schema,\n ): Promise<HttpResponse<T>> {\n const args = this.resolveArgs(arg1, arg2, arg3);\n return this.requestJson<T>('delete', args);\n }\n\n stream(url: string, options?: HttpOptions): NodeJS.ReadableStream {\n let combinedOptions: Merge<\n GotStreamOptions,\n SetRequired<InternalHttpOptions, 'method'>\n > = {\n ...this.options,\n hostType: this.hostType,\n ...options,\n method: 'get',\n };\n\n const resolvedUrl = this.resolveUrl(url, options).toString();\n\n applyDefaultHeaders(combinedOptions);\n\n if (\n isUndefined(combinedOptions.readOnly) &&\n ['head', 'get'].includes(combinedOptions.method)\n ) {\n combinedOptions.readOnly = true;\n }\n\n const hostRule = findMatchingRule(url, combinedOptions);\n combinedOptions = applyHostRule(resolvedUrl, combinedOptions, hostRule);\n if (combinedOptions.enabled === false) {\n throw new Error(HOST_DISABLED);\n }\n combinedOptions = applyAuthorization(combinedOptions);\n\n return stream(resolvedUrl, combinedOptions);\n }\n\n async getToml<Schema extends ZodType<any, any, any>>(\n url: string,\n schema?: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n async getToml<Schema extends ZodType<any, any, any>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n async getToml<Schema extends ZodType<any, any, any>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: Schema,\n ): Promise<HttpResponse<Infer<Schema>>> {\n const { url, schema, httpOptions } = this.resolveArgs<Infer<Schema>>(\n arg1,\n arg2,\n arg3,\n );\n\n const opts: InternalHttpOptions = {\n ...httpOptions,\n method: 'get',\n headers: {\n 'Content-Type': 'application/toml',\n ...httpOptions?.headers,\n },\n };\n\n const res = await this.getText(url, opts);\n if (schema) {\n res.body = await Toml.pipe(schema).parseAsync(res.body);\n } else {\n res.body = (await Toml.parseAsync(res.body)) as Infer<Schema>;\n }\n\n return res;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../lib/util/http/http.ts"],"names":[],"mappings":";;;AA+DA,kDAQC;;AAvED,yCAA8D;AAC9D,kEAA8B;AAI9B,6BAA8B;AAC9B,gDAAmD;AACnD,mEAA+D;AAC/D,iDAAuC;AACvC,yCAAsC;AACtC,gFAA2E;AAC3E,kEAA4C;AAC5C,gCAAgC;AAChC,kCAA+B;AAC/B,sCAAqD;AACrD,kDAAuC;AACvC,oCAAkD;AAClD,gCAA6D;AAC7D,kCAA0C;AAC1C,iCAAiE;AAEjE,+BAAsC;AACtC,6CAA+D;AAE/D,mCAAmC;AACnC,+CAA6D;AAC7D,yCAAyC;AAUzC,iCAAsC;AA2BtC,SAAgB,mBAAmB,CAAC,OAAgB;IAClD,MAAM,eAAe,GAAG,gBAAG,CAAC,OAAO,CAAC;IACpC,OAAO,CAAC,OAAO,GAAG;QAChB,GAAG,OAAO,CAAC,OAAO;QAClB,YAAY,EACV,qBAAY,CAAC,GAAG,CAAC,WAAW,CAAC;YAC7B,YAAY,eAAe,4CAA4C;KAC1E,CAAC;AACJ,CAAC;AAED,MAAsB,QAAQ;IAWhB;IAPK,OAAO,CAAqB;IA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AAC,CAAC;QACjC,CAAC;QACD,eAAe,GAAG,IAAA,yBAAkB,EAAC,eAAe,CAAC,CAAC;QAEtD,OAAO,IAAA,YAAM,EAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAC9C,CAAC;IAWD,KAAK,CAAC,OAAO,CACX,IAAY,EACZ,IAAwB,EACxB,IAAa;QAEb,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,WAAW,CACnD,IAAI,EACJ,IAAI,EACJ,IAAI,CACL,CAAC;QAEF,MAAM,IAAI,GAAwB;YAChC,GAAG,WAAW;YACd,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,GAAG,WAAW,EAAE,OAAO;aACxB;SACF,CAAC;QAEF,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC1C,IAAI,MAAM,EAAE,CAAC;YACX,GAAG,CAAC,IAAI,GAAG,MAAM,mBAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC1D,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,mBAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAkB,CAAC;QAChE,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAxnBD,4BAwnBC","sourcesContent":["import { isPlainObject, isUndefined } from '@sindresorhus/is';\nimport merge from 'deepmerge';\nimport type { Options, RetryObject } from 'got';\nimport type { Merge, SetRequired } from 'type-fest';\nimport type { infer as Infer } from 'zod';\nimport { ZodType } from 'zod';\nimport { GlobalConfig } from '../../config/global';\nimport { HOST_DISABLED } from '../../constants/error-messages';\nimport { pkg } from '../../expose.cjs';\nimport { logger } from '../../logger';\nimport { ExternalHostError } from '../../types/errors/external-host-error';\nimport * as memCache from '../cache/memory';\nimport { getEnv } from '../env';\nimport { hash } from '../hash';\nimport { type AsyncResult, Result } from '../result';\nimport { Toml } from '../schema-utils';\nimport { ObsoleteCacheHitLogger } from '../stats';\nimport { isHttpUrl, parseUrl, resolveBaseUrl } from '../url';\nimport { parseSingleYaml } from '../yaml';\nimport { applyAuthorization, removeAuthorization } from './auth';\nimport type { HttpCacheProvider } from './cache/types';\nimport { fetch, stream } from './got';\nimport { applyHostRule, findMatchingRule } from './host-rules';\n\nimport { getQueue } from './queue';\nimport { getRetryAfter, wrapWithRetry } from './retry-after';\nimport { getThrottle } from './throttle';\nimport type {\n GotOptions,\n GotStreamOptions,\n GotTask,\n HttpMethod,\n HttpOptions,\n HttpResponse,\n SafeJsonError,\n} from './types';\nimport { copyResponse } from './util';\n\nexport interface InternalJsonUnsafeOptions<\n Opts extends HttpOptions = HttpOptions,\n> {\n url: string | URL;\n httpOptions?: Opts;\n}\n\nexport interface InternalJsonOptions<\n Opts extends HttpOptions,\n ResT = unknown,\n Schema extends ZodType<ResT> = ZodType<ResT>,\n> extends InternalJsonUnsafeOptions<Opts> {\n schema?: Schema;\n}\n\nexport type InternalGotOptions = SetRequired<GotOptions, 'method' | 'context'>;\n\nexport interface InternalHttpOptions extends HttpOptions {\n json?: HttpOptions['body'];\n\n method?: HttpMethod;\n\n parseJson?: Options['parseJson'];\n}\n\nexport function applyDefaultHeaders(options: Options): void {\n const renovateVersion = pkg.version;\n options.headers = {\n ...options.headers,\n 'user-agent':\n GlobalConfig.get('userAgent') ??\n `Renovate/${renovateVersion} (https://github.com/renovatebot/renovate)`,\n };\n}\n\nexport abstract class HttpBase<\n JSONOpts extends HttpOptions = HttpOptions,\n Opts extends HttpOptions = HttpOptions,\n> {\n private readonly options: InternalGotOptions;\n\n protected get baseUrl(): string | undefined {\n return undefined;\n }\n\n constructor(\n protected hostType: string,\n options: HttpOptions = {},\n ) {\n const retryLimit = getEnv().NODE_ENV === 'test' ? 0 : 2;\n this.options = merge<InternalGotOptions>(\n options,\n {\n method: 'get',\n context: { hostType },\n retry: {\n calculateDelay: (retryObject) =>\n this.calculateRetryDelay(retryObject),\n limit: retryLimit,\n maxRetryAfter: 0, // Don't rely on `got` retry-after handling, just let it fail and then we'll handle it\n },\n },\n { isMergeableObject: isPlainObject },\n );\n }\n private async request(\n requestUrl: string | URL,\n httpOptions: InternalHttpOptions,\n ): Promise<HttpResponse<string>>;\n private async request(\n requestUrl: string | URL,\n httpOptions: InternalHttpOptions & { responseType: 'text' },\n ): Promise<HttpResponse<string>>;\n private async request(\n requestUrl: string | URL,\n httpOptions: InternalHttpOptions & { responseType: 'buffer' },\n ): Promise<HttpResponse<Buffer>>;\n private async request<T = unknown>(\n requestUrl: string | URL,\n httpOptions: InternalHttpOptions & { responseType: 'json' },\n ): Promise<HttpResponse<T>>;\n\n private async request(\n requestUrl: string | URL,\n httpOptions: InternalHttpOptions,\n ): Promise<HttpResponse<unknown>> {\n const resolvedUrl = this.resolveUrl(requestUrl, httpOptions);\n const url = resolvedUrl.toString();\n\n this.processOptions(resolvedUrl, httpOptions);\n\n let options = merge<InternalGotOptions, InternalHttpOptions>(\n {\n ...this.options,\n hostType: this.hostType,\n },\n httpOptions,\n { isMergeableObject: isPlainObject },\n );\n\n const method = options.method.toLowerCase();\n const isReadMethod = ['head', 'get'].includes(method);\n\n logger.trace(`HTTP request: ${method.toUpperCase()} ${url}`);\n\n options.hooks = {\n beforeRedirect: [removeAuthorization],\n };\n\n applyDefaultHeaders(options);\n\n if (isUndefined(options.readOnly) && isReadMethod) {\n options.readOnly = true;\n }\n\n const hostRule = findMatchingRule(url, options);\n options = applyHostRule(url, options, hostRule);\n if (options.enabled === false) {\n logger.debug(`Host is disabled - rejecting request. HostUrl: ${url}`);\n throw new Error(HOST_DISABLED);\n }\n options = applyAuthorization(options);\n options.timeout ??= 60000;\n\n let cacheProvider: HttpCacheProvider | undefined;\n if (isReadMethod && options.cacheProvider) {\n cacheProvider = options.cacheProvider;\n }\n\n const memCacheKey =\n !process.env.RENOVATE_X_DISABLE_HTTP_MEMCACHE &&\n !cacheProvider &&\n options.memCache !== false &&\n isReadMethod\n ? hash(\n `got-${JSON.stringify({\n url,\n headers: options.headers,\n method,\n })}`,\n )\n : null;\n\n const cachedResponse = await cacheProvider?.bypassServer<unknown>(\n method,\n url,\n );\n if (cachedResponse) {\n return cachedResponse;\n }\n\n let resPromise: Promise<HttpResponse<unknown>> | null = null;\n\n // Cache GET requests unless memCache=false\n if (memCacheKey) {\n resPromise = memCache.get(memCacheKey);\n\n /* v8 ignore next: temporary code */\n if (resPromise && !cacheProvider) {\n ObsoleteCacheHitLogger.write(url);\n }\n /* v8 ignore stop: temporary code */\n }\n\n if (!resPromise) {\n if (cacheProvider) {\n await cacheProvider.setCacheHeaders(method, url, options);\n }\n\n const startTime = Date.now();\n const httpTask: GotTask = () => {\n const queueMs = Date.now() - startTime;\n return fetch(url, options, { queueMs });\n };\n\n const throttle = getThrottle(url);\n const throttledTask = throttle ? () => throttle.add(httpTask) : httpTask;\n\n const queue = getQueue(url);\n const queuedTask = queue ? () => queue.add(throttledTask) : throttledTask;\n\n const { maxRetryAfter = 60 } = hostRule;\n resPromise = wrapWithRetry(queuedTask, url, getRetryAfter, maxRetryAfter);\n\n if (memCacheKey) {\n memCache.set(memCacheKey, resPromise);\n }\n }\n\n try {\n const res = await resPromise;\n const deepCopyNeeded = !!memCacheKey && res.statusCode !== 304;\n const resCopy = copyResponse(res, deepCopyNeeded);\n resCopy.authorization = !!options?.headers?.authorization;\n\n if (cacheProvider) {\n return await cacheProvider.wrapServerResponse(method, url, resCopy);\n }\n\n return resCopy;\n } catch (err) {\n const { abortOnError, abortIgnoreStatusCodes } = options;\n if (abortOnError && !abortIgnoreStatusCodes?.includes(err.statusCode)) {\n throw new ExternalHostError(err);\n }\n\n const staleResponse = await cacheProvider?.bypassServer<string | Buffer>(\n method,\n url,\n true,\n );\n if (staleResponse) {\n logger.debug(\n { err },\n `Request error: returning stale cache instead for ${url}`,\n );\n return staleResponse;\n }\n\n this.handleError(requestUrl, httpOptions, err);\n }\n }\n\n protected processOptions(_url: URL, _options: InternalHttpOptions): void {\n // noop\n }\n\n protected handleError(\n _url: string | URL,\n _httpOptions: HttpOptions,\n err: Error,\n ): never {\n throw err;\n }\n\n resolveUrl(\n requestUrl: string | URL,\n options: HttpOptions | undefined = undefined,\n ): URL {\n let url = requestUrl;\n\n if (url instanceof URL) {\n // already a aboslute URL\n return url;\n }\n\n const baseUrl = options?.baseUrl ?? this.baseUrl;\n if (baseUrl) {\n url = resolveBaseUrl(baseUrl, url);\n }\n\n const parsedUrl = parseUrl(url);\n if (!parsedUrl || !isHttpUrl(parsedUrl)) {\n logger.error(\n { url: requestUrl, baseUrl, resolvedUrl: url },\n 'Request Error: cannot parse url',\n );\n throw new Error('Invalid URL');\n }\n return parsedUrl;\n }\n\n protected calculateRetryDelay({ computedValue }: RetryObject): number {\n return computedValue;\n }\n\n get(\n url: string,\n options: HttpOptions = {},\n ): Promise<HttpResponse<string | Buffer>> {\n return this.request(url, options);\n }\n\n head(url: string, options: HttpOptions = {}): Promise<HttpResponse<never>> {\n // to complex to validate\n return this.request(url, {\n ...options,\n responseType: 'text',\n method: 'head',\n }) as Promise<HttpResponse<never>>;\n }\n\n getText(\n url: string | URL,\n options: HttpOptions = {},\n ): Promise<HttpResponse<string>> {\n return this.request(url, { ...options, responseType: 'text' });\n }\n\n getBuffer(\n url: string | URL,\n options: HttpOptions = {},\n ): Promise<HttpResponse<Buffer>> {\n return this.request(url, { ...options, responseType: 'buffer' });\n }\n\n protected requestJsonUnsafe<ResT>(\n method: HttpMethod,\n { url, httpOptions: requestOptions }: InternalJsonUnsafeOptions<JSONOpts>,\n ): Promise<HttpResponse<ResT>> {\n const { body: json, ...httpOptions } = { ...requestOptions };\n const opts: InternalHttpOptions = {\n ...httpOptions,\n method,\n };\n // signal that we expect a json response\n opts.headers = {\n accept: 'application/json',\n ...opts.headers,\n };\n if (json) {\n opts.json = json;\n }\n return this.request<ResT>(url, { ...opts, responseType: 'json' });\n }\n\n private async requestJson<ResT, Schema extends ZodType<ResT> = ZodType<ResT>>(\n method: HttpMethod,\n options: InternalJsonOptions<JSONOpts, ResT, Schema>,\n ): Promise<HttpResponse<ResT>> {\n const res = await this.requestJsonUnsafe<ResT>(method, options);\n\n if (options.schema) {\n res.body = await options.schema.parseAsync(res.body);\n }\n\n return res;\n }\n\n private resolveArgs<ResT = unknown>(\n arg1: string,\n arg2: JSONOpts | ZodType<ResT> | undefined,\n arg3: ZodType<ResT> | undefined,\n ): InternalJsonOptions<JSONOpts, ResT> {\n const res: InternalJsonOptions<JSONOpts, ResT> = { url: arg1 };\n\n if (arg2 instanceof ZodType) {\n res.schema = arg2;\n } else if (arg2) {\n res.httpOptions = arg2;\n }\n\n if (arg3) {\n res.schema = arg3;\n }\n\n return res;\n }\n\n async getPlain(url: string, options?: Opts): Promise<HttpResponse> {\n const opt = options ?? {};\n return await this.getText(url, {\n headers: {\n Accept: 'text/plain',\n },\n ...opt,\n });\n }\n\n /**\n * @deprecated use `getYaml` instead\n */\n async getYamlUnchecked<ResT>(\n url: string,\n options?: Opts,\n ): Promise<HttpResponse<ResT>> {\n const res = await this.getText(url, options);\n const body = parseSingleYaml<ResT>(res.body);\n return { ...res, body };\n }\n\n async getYaml<Schema extends ZodType<any, any, any>>(\n url: string,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n async getYaml<Schema extends ZodType<any, any, any>>(\n url: string,\n options: Opts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n async getYaml<Schema extends ZodType<any, any, any>>(\n arg1: string,\n arg2?: Opts | Schema,\n arg3?: Schema,\n ): Promise<HttpResponse<Infer<Schema>>> {\n const url = arg1;\n let schema: Schema;\n let httpOptions: Opts | undefined;\n if (arg3) {\n schema = arg3;\n httpOptions = arg2 as Opts;\n } else {\n schema = arg2 as Schema;\n }\n\n const opts: InternalHttpOptions = {\n ...httpOptions,\n method: 'get',\n };\n\n const res = await this.getText(url, opts);\n const body = await schema.parseAsync(parseSingleYaml(res.body));\n return { ...res, body };\n }\n\n getYamlSafe<\n ResT extends NonNullable<unknown>,\n Schema extends ZodType<ResT> = ZodType<ResT>,\n >(url: string, schema: Schema): AsyncResult<Infer<Schema>, SafeJsonError>;\n getYamlSafe<\n ResT extends NonNullable<unknown>,\n Schema extends ZodType<ResT> = ZodType<ResT>,\n >(\n url: string,\n options: Opts,\n schema: Schema,\n ): AsyncResult<Infer<Schema>, SafeJsonError>;\n getYamlSafe<\n ResT extends NonNullable<unknown>,\n Schema extends ZodType<ResT> = ZodType<ResT>,\n >(\n arg1: string,\n arg2: Opts | Schema,\n arg3?: Schema,\n ): AsyncResult<ResT, SafeJsonError> {\n const url = arg1;\n let schema: Schema;\n let httpOptions: Opts | undefined;\n if (arg3) {\n schema = arg3;\n httpOptions = arg2 as Opts;\n } else {\n schema = arg2 as Schema;\n }\n\n let res: AsyncResult<HttpResponse<ResT>, SafeJsonError>;\n if (httpOptions) {\n res = Result.wrap(this.getYaml(url, httpOptions, schema));\n } else {\n res = Result.wrap(this.getYaml(url, schema));\n }\n\n return res.transform((response) => Result.ok(response.body));\n }\n\n /**\n * Request JSON and return the response without any validation.\n *\n * The usage of this method is discouraged, please use `getJson` instead.\n *\n * If you're new to Zod schema validation library:\n * - consult the [documentation of Zod library](https://github.com/colinhacks/zod?tab=readme-ov-file#basic-usage)\n * - search the Renovate codebase for 'zod' module usage\n * - take a look at the `schema-utils.ts` file for Renovate-specific schemas and utilities\n */\n getJsonUnchecked<ResT = unknown>(\n url: string,\n options?: JSONOpts,\n ): Promise<HttpResponse<ResT>> {\n return this.requestJson<ResT>('get', { url, httpOptions: options });\n }\n\n /**\n * Request JSON with a Zod schema for the response,\n * throwing an error if the response is not valid.\n *\n * @param url\n * @param schema Zod schema for the response\n */\n getJson<Schema extends ZodType<any, any, any>>(\n url: string,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n getJson<Schema extends ZodType<any, any, any>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n getJson<Schema extends ZodType<any, any, any>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: Schema,\n ): Promise<HttpResponse<Infer<Schema>>> {\n const args = this.resolveArgs<Infer<Schema>>(arg1, arg2, arg3);\n return this.requestJson<Infer<Schema>>('get', args);\n }\n\n /**\n * Request JSON with a Zod schema for the response,\n * wrapping response data in a `Result` class.\n *\n * @param url\n * @param schema Zod schema for the response\n */\n getJsonSafe<ResT extends NonNullable<unknown>, Schema extends ZodType<ResT>>(\n url: string,\n schema: Schema,\n ): AsyncResult<Infer<Schema>, SafeJsonError>;\n getJsonSafe<ResT extends NonNullable<unknown>, Schema extends ZodType<ResT>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): AsyncResult<Infer<Schema>, SafeJsonError>;\n getJsonSafe<ResT extends NonNullable<unknown>, Schema extends ZodType<ResT>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: Schema,\n ): AsyncResult<ResT, SafeJsonError> {\n const args = this.resolveArgs<ResT>(arg1, arg2, arg3);\n return Result.wrap(this.requestJson<ResT>('get', args)).transform(\n (response) => Result.ok(response.body),\n );\n }\n\n /**\n * @deprecated use `head` instead\n */\n headJson(url: string, httpOptions?: JSONOpts): Promise<HttpResponse<never>> {\n return this.requestJson<never>('head', { url, httpOptions });\n }\n\n postJson<T>(url: string, options?: JSONOpts): Promise<HttpResponse<T>>;\n postJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n postJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n postJson<T = unknown, Schema extends ZodType<T> = ZodType<T>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: Schema,\n ): Promise<HttpResponse<T>> {\n const args = this.resolveArgs(arg1, arg2, arg3);\n return this.requestJson<T>('post', args);\n }\n\n putJson<T>(url: string, options?: JSONOpts): Promise<HttpResponse<T>>;\n putJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n putJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n putJson<T = unknown, Schema extends ZodType<T> = ZodType<T>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: ZodType,\n ): Promise<HttpResponse<T>> {\n const args = this.resolveArgs(arg1, arg2, arg3);\n return this.requestJson<T>('put', args);\n }\n\n patchJson<T>(url: string, options?: JSONOpts): Promise<HttpResponse<T>>;\n patchJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n patchJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n patchJson<T = unknown, Schema extends ZodType<T> = ZodType<T>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: Schema,\n ): Promise<HttpResponse<T>> {\n const args = this.resolveArgs(arg1, arg2, arg3);\n return this.requestJson<T>('patch', args);\n }\n\n deleteJson<T>(url: string, options?: JSONOpts): Promise<HttpResponse<T>>;\n deleteJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n deleteJson<T, Schema extends ZodType<T> = ZodType<T>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n deleteJson<T = unknown, Schema extends ZodType<T> = ZodType<T>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: Schema,\n ): Promise<HttpResponse<T>> {\n const args = this.resolveArgs(arg1, arg2, arg3);\n return this.requestJson<T>('delete', args);\n }\n\n stream(url: string, options?: HttpOptions): NodeJS.ReadableStream {\n let combinedOptions: Merge<\n GotStreamOptions,\n SetRequired<InternalHttpOptions, 'method'>\n > = {\n ...this.options,\n hostType: this.hostType,\n ...options,\n method: 'get',\n };\n\n const resolvedUrl = this.resolveUrl(url, options).toString();\n\n applyDefaultHeaders(combinedOptions);\n\n if (\n isUndefined(combinedOptions.readOnly) &&\n ['head', 'get'].includes(combinedOptions.method)\n ) {\n combinedOptions.readOnly = true;\n }\n\n const hostRule = findMatchingRule(url, combinedOptions);\n combinedOptions = applyHostRule(resolvedUrl, combinedOptions, hostRule);\n if (combinedOptions.enabled === false) {\n throw new Error(HOST_DISABLED);\n }\n combinedOptions = applyAuthorization(combinedOptions);\n\n return stream(resolvedUrl, combinedOptions);\n }\n\n async getToml<Schema extends ZodType<any, any, any>>(\n url: string,\n schema?: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n async getToml<Schema extends ZodType<any, any, any>>(\n url: string,\n options: JSONOpts,\n schema: Schema,\n ): Promise<HttpResponse<Infer<Schema>>>;\n async getToml<Schema extends ZodType<any, any, any>>(\n arg1: string,\n arg2?: JSONOpts | Schema,\n arg3?: Schema,\n ): Promise<HttpResponse<Infer<Schema>>> {\n const { url, schema, httpOptions } = this.resolveArgs<Infer<Schema>>(\n arg1,\n arg2,\n arg3,\n );\n\n const opts: InternalHttpOptions = {\n ...httpOptions,\n method: 'get',\n headers: {\n 'Content-Type': 'application/toml',\n ...httpOptions?.headers,\n },\n };\n\n const res = await this.getText(url, opts);\n if (schema) {\n res.body = await Toml.pipe(schema).parseAsync(res.body);\n } else {\n res.body = (await Toml.parseAsync(res.body)) as Infer<Schema>;\n }\n\n return res;\n }\n}\n"]}
|
package/dist/util/stats.js
CHANGED
|
@@ -324,7 +324,7 @@ class HttpCacheStats {
|
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
exports.HttpCacheStats = HttpCacheStats;
|
|
327
|
-
/* v8 ignore
|
|
327
|
+
/* v8 ignore next: temporary code */
|
|
328
328
|
class ObsoleteCacheHitLogger {
|
|
329
329
|
static getData() {
|
|
330
330
|
return memCache.get('obsolete-cache-stats') ?? {};
|
package/dist/util/stats.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../lib/util/stats.ts"],"names":[],"mappings":";;;AAcA,4CAQC;;AAtBD,sCAAmC;AACnC,iEAA2C;AAC3C,+BAAiC;AAYjC,SAAgB,gBAAgB,CAAC,IAAc;IAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AACpD,CAAC;AAED,MAAa,WAAW;IACtB,MAAM,CAAC,KAAK,CAAC,UAAkB,EAAE,QAAgB;QAC/C,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAkB,c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C;IAED,MAAM,CAAC,SAAS;QACd,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC5B,MAAM,MAAM,GAA2B,EAAE,CAAC;QAE1C,KAAK,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,IAAI,IAAI,EAAE,CAAC;YACpE,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YAC1B,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,GAAG,mBAAmB,CAAC;QACxD,CAAC;QAED,MAAM,YAAY,GAA2B,EAAE,CAAC;QAChD,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YACpD,YAAY,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;YAC9B,KAAK,MAAM,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;gBACjE,YAAY,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,MAAM;QACX,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAChC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnC,eAAM,CAAC,KAAK,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF;AA7CD,sDA6CC","sourcesContent":["import { logger } from '../logger';\nimport * as memCache from './cache/memory';\nimport { parseUrl } from './url';\n\ntype LookupStatsData = Record<string, number[]>;\n\ninterface TimingStatsReport {\n count: number;\n avgMs: number;\n medianMs: number;\n maxMs: number;\n totalMs: number;\n}\n\nexport function makeTimingReport(data: number[]): TimingStatsReport {\n const count = data.length;\n const totalMs = data.reduce((a, c) => a + c, 0);\n const avgMs = count ? Math.round(totalMs / count) : 0;\n const maxMs = Math.max(0, ...data);\n const sorted = data.sort((a, b) => a - b);\n const medianMs = count ? sorted[Math.floor(count / 2)] : 0;\n return { count, avgMs, medianMs, maxMs, totalMs };\n}\n\nexport class LookupStats {\n static write(datasource: string, duration: number): void {\n const data = memCache.get<LookupStatsData>('lookup-stats') ?? {};\n data[datasource] ??= [];\n data[datasource].push(duration);\n memCache.set('lookup-stats', data);\n }\n\n static async wrap<T>(\n datasource: string,\n callback: () => Promise<T>,\n ): Promise<T> {\n const start = Date.now();\n const result = await callback();\n const duration = Date.now() - start;\n LookupStats.write(datasource, duration);\n return result;\n }\n\n static getReport(): Record<string, TimingStatsReport> {\n const report: Record<string, TimingStatsReport> = {};\n const data = memCache.get<LookupStatsData>('lookup-stats') ?? {};\n for (const [datasource, durations] of Object.entries(data)) {\n report[datasource] = makeTimingReport(durations);\n }\n return report;\n }\n\n static report(): void {\n const report = LookupStats.getReport();\n logger.debug(report, 'Lookup statistics');\n }\n}\n\ntype PackageCacheData = number[];\n\nexport class PackageCacheStats {\n static writeSet(duration: number): void {\n const data = memCache.get<PackageCacheData>('package-cache-sets') ?? [];\n data.push(duration);\n memCache.set('package-cache-sets', data);\n }\n\n static async wrapSet<T>(callback: () => Promise<T>): Promise<T> {\n const start = Date.now();\n const result = await callback();\n const duration = Date.now() - start;\n PackageCacheStats.writeSet(duration);\n return result;\n }\n\n static writeGet(duration: number): void {\n const data = memCache.get<PackageCacheData>('package-cache-gets') ?? [];\n data.push(duration);\n memCache.set('package-cache-gets', data);\n }\n\n static async wrapGet<T>(callback: () => Promise<T>): Promise<T> {\n const start = Date.now();\n const result = await callback();\n const duration = Date.now() - start;\n PackageCacheStats.writeGet(duration);\n return result;\n }\n\n static getReport(): { get: TimingStatsReport; set: TimingStatsReport } {\n const packageCacheGets =\n memCache.get<PackageCacheData>('package-cache-gets') ?? [];\n const get = makeTimingReport(packageCacheGets);\n\n const packageCacheSets =\n memCache.get<PackageCacheData>('package-cache-sets') ?? [];\n const set = makeTimingReport(packageCacheSets);\n\n return { get, set };\n }\n\n static report(): void {\n const report = PackageCacheStats.getReport();\n logger.debug(report, 'Package cache statistics');\n }\n}\n\ninterface DatasourceCacheDataPoint {\n datasource: string;\n registryUrl: string;\n packageName: string;\n action: 'hit' | 'miss' | 'set' | 'skip';\n}\n\n/* eslint-disable @typescript-eslint/consistent-indexed-object-style */\nexport interface DatasourceCacheReport {\n long: {\n [datasource in string]: {\n [registryUrl in string]: {\n [packageName in string]: {\n read?: 'hit' | 'miss';\n write?: 'set' | 'skip';\n };\n };\n };\n };\n short: {\n [datasource in string]: {\n [registryUrl in string]: {\n hit: number;\n miss: number;\n set: number;\n skip: number;\n };\n };\n };\n}\n/* eslint-enable @typescript-eslint/consistent-indexed-object-style */\n\nexport class DatasourceCacheStats {\n private static getData(): DatasourceCacheDataPoint[] {\n return (\n memCache.get<DatasourceCacheDataPoint[]>('datasource-cache-stats') ?? []\n );\n }\n\n private static setData(data: DatasourceCacheDataPoint[]): void {\n memCache.set('datasource-cache-stats', data);\n }\n\n static hit(\n datasource: string,\n registryUrl: string,\n packageName: string,\n ): void {\n const data = this.getData();\n data.push({ datasource, registryUrl, packageName, action: 'hit' });\n this.setData(data);\n }\n\n static miss(\n datasource: string,\n registryUrl: string,\n packageName: string,\n ): void {\n const data = this.getData();\n data.push({ datasource, registryUrl, packageName, action: 'miss' });\n this.setData(data);\n }\n\n static set(\n datasource: string,\n registryUrl: string,\n packageName: string,\n ): void {\n const data = this.getData();\n data.push({ datasource, registryUrl, packageName, action: 'set' });\n this.setData(data);\n }\n\n static skip(\n datasource: string,\n registryUrl: string,\n packageName: string,\n ): void {\n const data = this.getData();\n data.push({ datasource, registryUrl, packageName, action: 'skip' });\n this.setData(data);\n }\n\n static getReport(): DatasourceCacheReport {\n const data = this.getData();\n const result: DatasourceCacheReport = { long: {}, short: {} };\n for (const { datasource, registryUrl, packageName, action } of data) {\n result.long[datasource] ??= {};\n result.long[datasource][registryUrl] ??= {};\n result.long[datasource][registryUrl] ??= {};\n result.long[datasource][registryUrl][packageName] ??= {};\n\n result.short[datasource] ??= {};\n result.short[datasource][registryUrl] ??= {\n hit: 0,\n miss: 0,\n set: 0,\n skip: 0,\n };\n\n if (action === 'hit') {\n result.long[datasource][registryUrl][packageName].read = 'hit';\n result.short[datasource][registryUrl].hit += 1;\n continue;\n }\n\n if (action === 'miss') {\n result.long[datasource][registryUrl][packageName].read = 'miss';\n result.short[datasource][registryUrl].miss += 1;\n continue;\n }\n\n if (action === 'set') {\n result.long[datasource][registryUrl][packageName].write = 'set';\n result.short[datasource][registryUrl].set += 1;\n continue;\n }\n\n if (action === 'skip') {\n result.long[datasource][registryUrl][packageName].write = 'skip';\n result.short[datasource][registryUrl].skip += 1;\n continue;\n }\n }\n\n return result;\n }\n\n static report(): void {\n const { long, short } = this.getReport();\n\n if (Object.keys(short).length > 0) {\n logger.debug(short, 'Datasource cache statistics');\n }\n\n if (Object.keys(long).length > 0) {\n logger.trace(long, 'Datasource cache detailed statistics');\n }\n }\n}\n\nexport interface HttpRequestStatsDataPoint {\n method: string;\n url: string;\n reqMs: number;\n queueMs: number;\n status: number;\n}\n\ninterface HostStatsData {\n count: number;\n reqAvgMs: number;\n reqMedianMs: number;\n reqMaxMs: number;\n queueAvgMs: number;\n queueMedianMs: number;\n queueMaxMs: number;\n}\n\n// url -> method -> status -> count\ntype UrlHttpStat = Record<string, Record<string, Record<string, number>>>;\n\ninterface HttpStatsCollection {\n // debug data\n urls: UrlHttpStat;\n hosts: Record<string, HostStatsData>;\n requests: number;\n\n // trace data\n rawRequests: string[];\n hostRequests: Record<string, HttpRequestStatsDataPoint[]>;\n}\n\nexport class HttpStats {\n static write(data: HttpRequestStatsDataPoint): void {\n const httpRequests =\n memCache.get<HttpRequestStatsDataPoint[]>('http-requests') ?? [];\n httpRequests.push(data);\n memCache.set('http-requests', httpRequests);\n }\n\n static getDataPoints(): HttpRequestStatsDataPoint[] {\n const httpRequests =\n memCache.get<HttpRequestStatsDataPoint[]>('http-requests') ?? [];\n\n // istanbul ignore next: sorting is hard and not worth testing\n httpRequests.sort((a, b) => {\n if (a.url < b.url) {\n return -1;\n }\n\n if (a.url > b.url) {\n return 1;\n }\n\n return 0;\n });\n\n return httpRequests;\n }\n\n static getReport(): HttpStatsCollection {\n const dataPoints = HttpStats.getDataPoints();\n\n const requests = dataPoints.length;\n\n const urls: UrlHttpStat = {};\n const rawRequests: string[] = [];\n const hostRequests: Record<string, HttpRequestStatsDataPoint[]> = {};\n\n for (const dataPoint of dataPoints) {\n const { url, reqMs, queueMs, status } = dataPoint;\n const method = dataPoint.method.toUpperCase();\n\n const parsedUrl = parseUrl(url);\n if (!parsedUrl) {\n logger.debug({ url }, 'Failed to parse URL during stats reporting');\n continue;\n }\n const { hostname, origin, pathname } = parsedUrl;\n const baseUrl = `${origin}${pathname}`;\n\n urls[baseUrl] ??= {};\n urls[baseUrl][method] ??= {};\n urls[baseUrl][method][status] ??= 0;\n urls[baseUrl][method][status] += 1;\n\n rawRequests.push(`${method} ${url} ${status} ${reqMs} ${queueMs}`);\n\n hostRequests[hostname] ??= [];\n hostRequests[hostname].push(dataPoint);\n }\n\n const hosts: Record<string, HostStatsData> = {};\n\n for (const [hostname, dataPoints] of Object.entries(hostRequests)) {\n const count = dataPoints.length;\n\n const reqTimes = dataPoints.map((r) => r.reqMs);\n const queueTimes = dataPoints.map((r) => r.queueMs);\n\n const reqReport = makeTimingReport(reqTimes);\n const queueReport = makeTimingReport(queueTimes);\n\n hosts[hostname] = {\n count,\n reqAvgMs: reqReport.avgMs,\n reqMedianMs: reqReport.medianMs,\n reqMaxMs: reqReport.maxMs,\n queueAvgMs: queueReport.avgMs,\n queueMedianMs: queueReport.medianMs,\n queueMaxMs: queueReport.maxMs,\n };\n }\n\n return {\n urls,\n rawRequests,\n hostRequests,\n hosts,\n requests,\n };\n }\n\n static report(): void {\n const { urls, rawRequests, hostRequests, hosts, requests } =\n HttpStats.getReport();\n logger.trace({ rawRequests, hostRequests }, 'HTTP full statistics');\n logger.debug({ hosts, requests }, 'HTTP statistics');\n logger.trace({ urls }, 'HTTP URL statistics');\n }\n}\n\ninterface HttpCacheHostStatsData {\n hit: number;\n miss: number;\n localHit?: number;\n localMiss?: number;\n}\n\ntype HttpCacheStatsData = Record<string, HttpCacheHostStatsData>;\n\nfunction sortObject<T>(obj: Record<string, T>): Record<string, T> {\n const result: Record<string, T> = {};\n for (const key of Object.keys(obj).sort()) {\n result[key] = obj[key];\n }\n return result;\n}\n\nexport class HttpCacheStats {\n static getData(): HttpCacheStatsData {\n return memCache.get<HttpCacheStatsData>('http-cache-stats') ?? {};\n }\n\n static read(key: string): HttpCacheHostStatsData {\n return (\n this.getData()?.[key] ?? {\n hit: 0,\n miss: 0,\n }\n );\n }\n\n static write(key: string, data: HttpCacheHostStatsData): void {\n const stats = memCache.get<HttpCacheStatsData>('http-cache-stats') ?? {};\n stats[key] = data;\n memCache.set('http-cache-stats', stats);\n }\n\n static getBaseUrl(url: string): string | null {\n const parsedUrl = parseUrl(url);\n if (!parsedUrl) {\n logger.debug({ url }, 'Failed to parse URL during cache stats');\n return null;\n }\n const { origin, pathname } = parsedUrl;\n const baseUrl = `${origin}${pathname}`;\n return baseUrl;\n }\n\n static incLocalHits(url: string): void {\n const baseUrl = HttpCacheStats.getBaseUrl(url);\n if (baseUrl) {\n const host = baseUrl;\n const stats = HttpCacheStats.read(host);\n stats.localHit ??= 0;\n stats.localHit += 1;\n HttpCacheStats.write(host, stats);\n }\n }\n\n static incLocalMisses(url: string): void {\n const baseUrl = HttpCacheStats.getBaseUrl(url);\n if (baseUrl) {\n const host = baseUrl;\n const stats = HttpCacheStats.read(host);\n stats.localMiss ??= 0;\n stats.localMiss += 1;\n HttpCacheStats.write(host, stats);\n }\n }\n\n static incRemoteHits(url: string): void {\n const baseUrl = HttpCacheStats.getBaseUrl(url);\n if (baseUrl) {\n const host = baseUrl;\n const stats = HttpCacheStats.read(host);\n stats.hit += 1;\n HttpCacheStats.write(host, stats);\n }\n }\n\n static incRemoteMisses(url: string): void {\n const baseUrl = HttpCacheStats.getBaseUrl(url);\n if (baseUrl) {\n const host = baseUrl;\n const stats = HttpCacheStats.read(host);\n stats.miss += 1;\n HttpCacheStats.write(host, stats);\n }\n }\n\n static report(): void {\n const data = HttpCacheStats.getData();\n let report: Record<string, Record<string, HttpCacheHostStatsData>> = {};\n for (const [url, stats] of Object.entries(data)) {\n const parsedUrl = parseUrl(url);\n if (parsedUrl) {\n const { origin, pathname } = parsedUrl;\n report[origin] ??= {};\n report[origin][pathname] = stats;\n }\n }\n\n for (const [host, hostStats] of Object.entries(report)) {\n report[host] = sortObject(hostStats);\n }\n report = sortObject(report);\n\n logger.debug(report, 'HTTP cache statistics');\n }\n}\n\ntype ObsoleteCacheStats = Record<\n string,\n {\n count: number;\n }\n>;\n\n/* v8 ignore start: temporary code */\nexport class ObsoleteCacheHitLogger {\n static getData(): ObsoleteCacheStats {\n return memCache.get<ObsoleteCacheStats>('obsolete-cache-stats') ?? {};\n }\n\n static write(url: string): void {\n const data = this.getData();\n if (!data[url]) {\n data[url] = { count: 0 };\n }\n data[url].count++;\n memCache.set('obsolete-cache-stats', data);\n }\n\n static report(): void {\n const hits = this.getData();\n logger.debug(\n { count: Object.keys(hits).length, hits },\n 'Cache fallback URLs',\n );\n }\n}\n/* v8 ignore stop: temporary code */\n\ninterface AbandonedPackage {\n datasource: string;\n packageName: string;\n mostRecentTimestamp: string;\n}\n\ntype AbandonedPackageReport = Record<string, Record<string, string>>;\n\nexport class AbandonedPackageStats {\n static getData(): AbandonedPackage[] {\n return memCache.get<AbandonedPackage[]>('abandonment-stats') ?? [];\n }\n\n private static setData(data: AbandonedPackage[]): void {\n memCache.set('abandonment-stats', data);\n }\n\n static write(\n datasource: string,\n packageName: string,\n mostRecentTimestamp: string,\n ): void {\n const data = this.getData();\n data.push({ datasource, packageName, mostRecentTimestamp });\n this.setData(data);\n }\n\n static getReport(): AbandonedPackageReport {\n const data = this.getData();\n const result: AbandonedPackageReport = {};\n\n for (const { datasource, packageName, mostRecentTimestamp } of data) {\n result[datasource] ??= {};\n result[datasource][packageName] = mostRecentTimestamp;\n }\n\n const sortedResult: AbandonedPackageReport = {};\n for (const datasource of Object.keys(result).sort()) {\n sortedResult[datasource] = {};\n for (const packageName of Object.keys(result[datasource]).sort()) {\n sortedResult[datasource][packageName] = result[datasource][packageName];\n }\n }\n\n return sortedResult;\n }\n\n static report(): void {\n const report = this.getReport();\n if (Object.keys(report).length > 0) {\n logger.debug(report, 'Abandoned package statistics');\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../lib/util/stats.ts"],"names":[],"mappings":";;;AAcA,4CAQC;;AAtBD,sCAAmC;AACnC,iEAA2C;AAC3C,+BAAiC;AAYjC,SAAgB,gBAAgB,CAAC,IAAc;IAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG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,CAAC,KAAK,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF;AA7CD,sDA6CC","sourcesContent":["import { logger } from '../logger';\nimport * as memCache from './cache/memory';\nimport { parseUrl } from './url';\n\ntype LookupStatsData = Record<string, number[]>;\n\ninterface TimingStatsReport {\n count: number;\n avgMs: number;\n medianMs: number;\n maxMs: number;\n totalMs: number;\n}\n\nexport function makeTimingReport(data: number[]): TimingStatsReport {\n const count = data.length;\n const totalMs = data.reduce((a, c) => a + c, 0);\n const avgMs = count ? Math.round(totalMs / count) : 0;\n const maxMs = Math.max(0, ...data);\n const sorted = data.sort((a, b) => a - b);\n const medianMs = count ? sorted[Math.floor(count / 2)] : 0;\n return { count, avgMs, medianMs, maxMs, totalMs };\n}\n\nexport class LookupStats {\n static write(datasource: string, duration: number): void {\n const data = memCache.get<LookupStatsData>('lookup-stats') ?? {};\n data[datasource] ??= [];\n data[datasource].push(duration);\n memCache.set('lookup-stats', data);\n }\n\n static async wrap<T>(\n datasource: string,\n callback: () => Promise<T>,\n ): Promise<T> {\n const start = Date.now();\n const result = await callback();\n const duration = Date.now() - start;\n LookupStats.write(datasource, duration);\n return result;\n }\n\n static getReport(): Record<string, TimingStatsReport> {\n const report: Record<string, TimingStatsReport> = {};\n const data = memCache.get<LookupStatsData>('lookup-stats') ?? {};\n for (const [datasource, durations] of Object.entries(data)) {\n report[datasource] = makeTimingReport(durations);\n }\n return report;\n }\n\n static report(): void {\n const report = LookupStats.getReport();\n logger.debug(report, 'Lookup statistics');\n }\n}\n\ntype PackageCacheData = number[];\n\nexport class PackageCacheStats {\n static writeSet(duration: number): void {\n const data = memCache.get<PackageCacheData>('package-cache-sets') ?? [];\n data.push(duration);\n memCache.set('package-cache-sets', data);\n }\n\n static async wrapSet<T>(callback: () => Promise<T>): Promise<T> {\n const start = Date.now();\n const result = await callback();\n const duration = Date.now() - start;\n PackageCacheStats.writeSet(duration);\n return result;\n }\n\n static writeGet(duration: number): void {\n const data = memCache.get<PackageCacheData>('package-cache-gets') ?? [];\n data.push(duration);\n memCache.set('package-cache-gets', data);\n }\n\n static async wrapGet<T>(callback: () => Promise<T>): Promise<T> {\n const start = Date.now();\n const result = await callback();\n const duration = Date.now() - start;\n PackageCacheStats.writeGet(duration);\n return result;\n }\n\n static getReport(): { get: TimingStatsReport; set: TimingStatsReport } {\n const packageCacheGets =\n memCache.get<PackageCacheData>('package-cache-gets') ?? [];\n const get = makeTimingReport(packageCacheGets);\n\n const packageCacheSets =\n memCache.get<PackageCacheData>('package-cache-sets') ?? [];\n const set = makeTimingReport(packageCacheSets);\n\n return { get, set };\n }\n\n static report(): void {\n const report = PackageCacheStats.getReport();\n logger.debug(report, 'Package cache statistics');\n }\n}\n\ninterface DatasourceCacheDataPoint {\n datasource: string;\n registryUrl: string;\n packageName: string;\n action: 'hit' | 'miss' | 'set' | 'skip';\n}\n\n/* eslint-disable @typescript-eslint/consistent-indexed-object-style */\nexport interface DatasourceCacheReport {\n long: {\n [datasource in string]: {\n [registryUrl in string]: {\n [packageName in string]: {\n read?: 'hit' | 'miss';\n write?: 'set' | 'skip';\n };\n };\n };\n };\n short: {\n [datasource in string]: {\n [registryUrl in string]: {\n hit: number;\n miss: number;\n set: number;\n skip: number;\n };\n };\n };\n}\n/* eslint-enable @typescript-eslint/consistent-indexed-object-style */\n\nexport class DatasourceCacheStats {\n private static getData(): DatasourceCacheDataPoint[] {\n return (\n memCache.get<DatasourceCacheDataPoint[]>('datasource-cache-stats') ?? []\n );\n }\n\n private static setData(data: DatasourceCacheDataPoint[]): void {\n memCache.set('datasource-cache-stats', data);\n }\n\n static hit(\n datasource: string,\n registryUrl: string,\n packageName: string,\n ): void {\n const data = this.getData();\n data.push({ datasource, registryUrl, packageName, action: 'hit' });\n this.setData(data);\n }\n\n static miss(\n datasource: string,\n registryUrl: string,\n packageName: string,\n ): void {\n const data = this.getData();\n data.push({ datasource, registryUrl, packageName, action: 'miss' });\n this.setData(data);\n }\n\n static set(\n datasource: string,\n registryUrl: string,\n packageName: string,\n ): void {\n const data = this.getData();\n data.push({ datasource, registryUrl, packageName, action: 'set' });\n this.setData(data);\n }\n\n static skip(\n datasource: string,\n registryUrl: string,\n packageName: string,\n ): void {\n const data = this.getData();\n data.push({ datasource, registryUrl, packageName, action: 'skip' });\n this.setData(data);\n }\n\n static getReport(): DatasourceCacheReport {\n const data = this.getData();\n const result: DatasourceCacheReport = { long: {}, short: {} };\n for (const { datasource, registryUrl, packageName, action } of data) {\n result.long[datasource] ??= {};\n result.long[datasource][registryUrl] ??= {};\n result.long[datasource][registryUrl] ??= {};\n result.long[datasource][registryUrl][packageName] ??= {};\n\n result.short[datasource] ??= {};\n result.short[datasource][registryUrl] ??= {\n hit: 0,\n miss: 0,\n set: 0,\n skip: 0,\n };\n\n if (action === 'hit') {\n result.long[datasource][registryUrl][packageName].read = 'hit';\n result.short[datasource][registryUrl].hit += 1;\n continue;\n }\n\n if (action === 'miss') {\n result.long[datasource][registryUrl][packageName].read = 'miss';\n result.short[datasource][registryUrl].miss += 1;\n continue;\n }\n\n if (action === 'set') {\n result.long[datasource][registryUrl][packageName].write = 'set';\n result.short[datasource][registryUrl].set += 1;\n continue;\n }\n\n if (action === 'skip') {\n result.long[datasource][registryUrl][packageName].write = 'skip';\n result.short[datasource][registryUrl].skip += 1;\n continue;\n }\n }\n\n return result;\n }\n\n static report(): void {\n const { long, short } = this.getReport();\n\n if (Object.keys(short).length > 0) {\n logger.debug(short, 'Datasource cache statistics');\n }\n\n if (Object.keys(long).length > 0) {\n logger.trace(long, 'Datasource cache detailed statistics');\n }\n }\n}\n\nexport interface HttpRequestStatsDataPoint {\n method: string;\n url: string;\n reqMs: number;\n queueMs: number;\n status: number;\n}\n\ninterface HostStatsData {\n count: number;\n reqAvgMs: number;\n reqMedianMs: number;\n reqMaxMs: number;\n queueAvgMs: number;\n queueMedianMs: number;\n queueMaxMs: number;\n}\n\n// url -> method -> status -> count\ntype UrlHttpStat = Record<string, Record<string, Record<string, number>>>;\n\ninterface HttpStatsCollection {\n // debug data\n urls: UrlHttpStat;\n hosts: Record<string, HostStatsData>;\n requests: number;\n\n // trace data\n rawRequests: string[];\n hostRequests: Record<string, HttpRequestStatsDataPoint[]>;\n}\n\nexport class HttpStats {\n static write(data: HttpRequestStatsDataPoint): void {\n const httpRequests =\n memCache.get<HttpRequestStatsDataPoint[]>('http-requests') ?? [];\n httpRequests.push(data);\n memCache.set('http-requests', httpRequests);\n }\n\n static getDataPoints(): HttpRequestStatsDataPoint[] {\n const httpRequests =\n memCache.get<HttpRequestStatsDataPoint[]>('http-requests') ?? [];\n\n // istanbul ignore next: sorting is hard and not worth testing\n httpRequests.sort((a, b) => {\n if (a.url < b.url) {\n return -1;\n }\n\n if (a.url > b.url) {\n return 1;\n }\n\n return 0;\n });\n\n return httpRequests;\n }\n\n static getReport(): HttpStatsCollection {\n const dataPoints = HttpStats.getDataPoints();\n\n const requests = dataPoints.length;\n\n const urls: UrlHttpStat = {};\n const rawRequests: string[] = [];\n const hostRequests: Record<string, HttpRequestStatsDataPoint[]> = {};\n\n for (const dataPoint of dataPoints) {\n const { url, reqMs, queueMs, status } = dataPoint;\n const method = dataPoint.method.toUpperCase();\n\n const parsedUrl = parseUrl(url);\n if (!parsedUrl) {\n logger.debug({ url }, 'Failed to parse URL during stats reporting');\n continue;\n }\n const { hostname, origin, pathname } = parsedUrl;\n const baseUrl = `${origin}${pathname}`;\n\n urls[baseUrl] ??= {};\n urls[baseUrl][method] ??= {};\n urls[baseUrl][method][status] ??= 0;\n urls[baseUrl][method][status] += 1;\n\n rawRequests.push(`${method} ${url} ${status} ${reqMs} ${queueMs}`);\n\n hostRequests[hostname] ??= [];\n hostRequests[hostname].push(dataPoint);\n }\n\n const hosts: Record<string, HostStatsData> = {};\n\n for (const [hostname, dataPoints] of Object.entries(hostRequests)) {\n const count = dataPoints.length;\n\n const reqTimes = dataPoints.map((r) => r.reqMs);\n const queueTimes = dataPoints.map((r) => r.queueMs);\n\n const reqReport = makeTimingReport(reqTimes);\n const queueReport = makeTimingReport(queueTimes);\n\n hosts[hostname] = {\n count,\n reqAvgMs: reqReport.avgMs,\n reqMedianMs: reqReport.medianMs,\n reqMaxMs: reqReport.maxMs,\n queueAvgMs: queueReport.avgMs,\n queueMedianMs: queueReport.medianMs,\n queueMaxMs: queueReport.maxMs,\n };\n }\n\n return {\n urls,\n rawRequests,\n hostRequests,\n hosts,\n requests,\n };\n }\n\n static report(): void {\n const { urls, rawRequests, hostRequests, hosts, requests } =\n HttpStats.getReport();\n logger.trace({ rawRequests, hostRequests }, 'HTTP full statistics');\n logger.debug({ hosts, requests }, 'HTTP statistics');\n logger.trace({ urls }, 'HTTP URL statistics');\n }\n}\n\ninterface HttpCacheHostStatsData {\n hit: number;\n miss: number;\n localHit?: number;\n localMiss?: number;\n}\n\ntype HttpCacheStatsData = Record<string, HttpCacheHostStatsData>;\n\nfunction sortObject<T>(obj: Record<string, T>): Record<string, T> {\n const result: Record<string, T> = {};\n for (const key of Object.keys(obj).sort()) {\n result[key] = obj[key];\n }\n return result;\n}\n\nexport class HttpCacheStats {\n static getData(): HttpCacheStatsData {\n return memCache.get<HttpCacheStatsData>('http-cache-stats') ?? {};\n }\n\n static read(key: string): HttpCacheHostStatsData {\n return (\n this.getData()?.[key] ?? {\n hit: 0,\n miss: 0,\n }\n );\n }\n\n static write(key: string, data: HttpCacheHostStatsData): void {\n const stats = memCache.get<HttpCacheStatsData>('http-cache-stats') ?? {};\n stats[key] = data;\n memCache.set('http-cache-stats', stats);\n }\n\n static getBaseUrl(url: string): string | null {\n const parsedUrl = parseUrl(url);\n if (!parsedUrl) {\n logger.debug({ url }, 'Failed to parse URL during cache stats');\n return null;\n }\n const { origin, pathname } = parsedUrl;\n const baseUrl = `${origin}${pathname}`;\n return baseUrl;\n }\n\n static incLocalHits(url: string): void {\n const baseUrl = HttpCacheStats.getBaseUrl(url);\n if (baseUrl) {\n const host = baseUrl;\n const stats = HttpCacheStats.read(host);\n stats.localHit ??= 0;\n stats.localHit += 1;\n HttpCacheStats.write(host, stats);\n }\n }\n\n static incLocalMisses(url: string): void {\n const baseUrl = HttpCacheStats.getBaseUrl(url);\n if (baseUrl) {\n const host = baseUrl;\n const stats = HttpCacheStats.read(host);\n stats.localMiss ??= 0;\n stats.localMiss += 1;\n HttpCacheStats.write(host, stats);\n }\n }\n\n static incRemoteHits(url: string): void {\n const baseUrl = HttpCacheStats.getBaseUrl(url);\n if (baseUrl) {\n const host = baseUrl;\n const stats = HttpCacheStats.read(host);\n stats.hit += 1;\n HttpCacheStats.write(host, stats);\n }\n }\n\n static incRemoteMisses(url: string): void {\n const baseUrl = HttpCacheStats.getBaseUrl(url);\n if (baseUrl) {\n const host = baseUrl;\n const stats = HttpCacheStats.read(host);\n stats.miss += 1;\n HttpCacheStats.write(host, stats);\n }\n }\n\n static report(): void {\n const data = HttpCacheStats.getData();\n let report: Record<string, Record<string, HttpCacheHostStatsData>> = {};\n for (const [url, stats] of Object.entries(data)) {\n const parsedUrl = parseUrl(url);\n if (parsedUrl) {\n const { origin, pathname } = parsedUrl;\n report[origin] ??= {};\n report[origin][pathname] = stats;\n }\n }\n\n for (const [host, hostStats] of Object.entries(report)) {\n report[host] = sortObject(hostStats);\n }\n report = sortObject(report);\n\n logger.debug(report, 'HTTP cache statistics');\n }\n}\n\ntype ObsoleteCacheStats = Record<\n string,\n {\n count: number;\n }\n>;\n\n/* v8 ignore next: temporary code */\nexport class ObsoleteCacheHitLogger {\n static getData(): ObsoleteCacheStats {\n return memCache.get<ObsoleteCacheStats>('obsolete-cache-stats') ?? {};\n }\n\n static write(url: string): void {\n const data = this.getData();\n if (!data[url]) {\n data[url] = { count: 0 };\n }\n data[url].count++;\n memCache.set('obsolete-cache-stats', data);\n }\n\n static report(): void {\n const hits = this.getData();\n logger.debug(\n { count: Object.keys(hits).length, hits },\n 'Cache fallback URLs',\n );\n }\n}\n/* v8 ignore stop: temporary code */\n\ninterface AbandonedPackage {\n datasource: string;\n packageName: string;\n mostRecentTimestamp: string;\n}\n\ntype AbandonedPackageReport = Record<string, Record<string, string>>;\n\nexport class AbandonedPackageStats {\n static getData(): AbandonedPackage[] {\n return memCache.get<AbandonedPackage[]>('abandonment-stats') ?? [];\n }\n\n private static setData(data: AbandonedPackage[]): void {\n memCache.set('abandonment-stats', data);\n }\n\n static write(\n datasource: string,\n packageName: string,\n mostRecentTimestamp: string,\n ): void {\n const data = this.getData();\n data.push({ datasource, packageName, mostRecentTimestamp });\n this.setData(data);\n }\n\n static getReport(): AbandonedPackageReport {\n const data = this.getData();\n const result: AbandonedPackageReport = {};\n\n for (const { datasource, packageName, mostRecentTimestamp } of data) {\n result[datasource] ??= {};\n result[datasource][packageName] = mostRecentTimestamp;\n }\n\n const sortedResult: AbandonedPackageReport = {};\n for (const datasource of Object.keys(result).sort()) {\n sortedResult[datasource] = {};\n for (const packageName of Object.keys(result[datasource]).sort()) {\n sortedResult[datasource][packageName] = result[datasource][packageName];\n }\n }\n\n return sortedResult;\n }\n\n static report(): void {\n const report = this.getReport();\n if (Object.keys(report).length > 0) {\n logger.debug(report, 'Abandoned package statistics');\n }\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ exports.setConfig = setConfig;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_readline_1 = tslib_1.__importDefault(require("node:readline"));
|
|
6
6
|
const env_1 = require("../../../../util/env");
|
|
7
|
-
/* v8 ignore
|
|
7
|
+
/* v8 ignore next */
|
|
8
8
|
async function setConfig(config) {
|
|
9
9
|
const env = (0, env_1.getEnv)();
|
|
10
10
|
if (env.CODESPACES !== 'true') {
|
|
@@ -23,5 +23,4 @@ async function setConfig(config) {
|
|
|
23
23
|
}
|
|
24
24
|
return config;
|
|
25
25
|
}
|
|
26
|
-
/* v8 ignore stop */
|
|
27
26
|
//# sourceMappingURL=codespaces.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codespaces.js","sourceRoot":"","sources":["../../../../../lib/workers/global/config/parse/codespaces.ts"],"names":[],"mappings":";;AAKA,8BAoBC;;AAzBD,0EAAqC;AAErC,8CAA8C;AAE9C,
|
|
1
|
+
{"version":3,"file":"codespaces.js","sourceRoot":"","sources":["../../../../../lib/workers/global/config/parse/codespaces.ts"],"names":[],"mappings":";;AAKA,8BAoBC;;AAzBD,0EAAqC;AAErC,8CAA8C;AAE9C,oBAAoB;AACb,KAAK,UAAU,SAAS,CAAC,MAAiB;IAC/C,MAAM,GAAG,GAAG,IAAA,YAAM,GAAE,CAAC;IACrB,IAAI,GAAG,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,GAAG,CAAC,YAAY,EAAE,CAAC;QACtC,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;QACjC,MAAM,EAAE,GAAG,uBAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC;YAC3C,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC;QACxD,MAAM,CAAC,YAAY,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import readline from 'node:readline';\nimport type { AllConfig } from '../../../../config/types';\nimport { getEnv } from '../../../../util/env';\n\n/* v8 ignore next */\nexport async function setConfig(config: AllConfig): Promise<AllConfig> {\n const env = getEnv();\n if (env.CODESPACES !== 'true') {\n return config;\n }\n\n if (!config.token && env.GITHUB_TOKEN) {\n config.token = env.GITHUB_TOKEN;\n }\n\n if (!config.repositories?.length) {\n const rl = readline.promises.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n const repo = await rl.question('\\n\\nRepository name: ');\n config.repositories = [repo];\n }\n\n return config;\n}\n"]}
|
|
@@ -36,7 +36,8 @@ async function confirmIfDepUpdated(upgrade, newContent) {
|
|
|
36
36
|
}
|
|
37
37
|
newUpgrade = newExtract.deps[depIndex];
|
|
38
38
|
}
|
|
39
|
-
catch (err)
|
|
39
|
+
catch (err) {
|
|
40
|
+
/* istanbul ignore next */
|
|
40
41
|
logger_1.logger.debug({ manager, packageFile, err }, 'Failed to parse newContent');
|
|
41
42
|
}
|
|
42
43
|
if (!newUpgrade) {
|
|
@@ -287,7 +288,8 @@ async function doAutoReplace(upgrade, existingContent, reuseExistingBranch, firs
|
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
}
|
|
290
|
-
catch (err)
|
|
291
|
+
catch (err) {
|
|
292
|
+
/* istanbul ignore next */
|
|
291
293
|
logger_1.logger.debug({ packageFile, depName, err }, 'doAutoReplace error');
|
|
292
294
|
}
|
|
293
295
|
// istanbul ignore next
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-replace.js","sourceRoot":"","sources":["../../../../../lib/workers/repository/update/branch/auto-replace.ts"],"names":[],"mappings":";;AAYA,kDA+GC;AA4BD,oEAqBC;AA0BD,sCAuQC;AA7cD,cAAc;AACd,yCAAmE;AACnE,yEAAiF;AACjF,+CAA4C;AAC5C,yDAAiE;AAEjE,4CAAqD;AACrD,kDAA6D;AAC7D,oDAA6D;AAC7D,wDAAoD;AAG7C,KAAK,UAAU,mBAAmB,CACvC,OAA4B,EAC5B,UAAkB;IAElB,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACnD,IAAI,UAA6B,CAAC;IAClC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAkB,EACzC,OAAO,EACP,UAAU,EACV,WAAY,EACZ,OAAO,CACR,CAAC;QACF,qBAAqB;QACr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AAG,UAAU,GAAG,CAAC,CAAC;oBAC7B,MAAM,IAAA,mBAAc,EAAC,OAAO,CAAC,WAAY,EAAE,eAAe,CAAC,CAAC;oBAC5D,UAAU,GAAG,eAAe,CAAC;oBAC7B,YAAY,GAAG,CAAC,OAAO,CAAC;oBACxB,aAAa,GAAG,CAAC,QAAQ,CAAC;oBAC1B,cAAc,GAAG,CAAC,SAAS,CAAC;gBAC9B,CAAC;YACH,CAAC;iBAAM,IAAI,IAAA,gBAAO,EAAC,UAAU,EAAE,WAAW,EAAE,aAAc,CAAC,EAAE,CAAC;gBAC5D,eAAM,CAAC,KAAK,CACV,EAAE,WAAW,EAAE,OAAO,EAAE,EACxB,wBAAwB,WAAW,EAAE,CACtC,CAAC;gBACF,iCAAiC;gBACjC,UAAU,GAAG,IAAA,kBAAS,EACpB,UAAU,EACV,WAAW,EACX,aAAc,EACd,SAAS,CACV,CAAC;gBACF,MAAM,IAAA,mBAAc,EAAC,OAAO,CAAC,WAAY,EAAE,UAAU,CAAC,CAAC;gBACvD,IAAI,MAAM,mBAAmB,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC;oBACnD,OAAO,UAAU,CAAC;gBACpB,CAAC;gBACD,MAAM,IAAA,mBAAc,EAAC,OAAO,CAAC,WAAY,EAAE,eAAe,CAAC,CAAC;gBAC5D,UAAU,GAAG,eAAe,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,0BAA0B,CAAC,CAAC;QACxC,eAAM,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,qBAAqB,CAAC,CAAC;IACrE,CAAC;IACD,uBAAuB;IACvB,MAAM,IAAI,KAAK,CAAC,0CAAyB,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["// TODO #22198\nimport { isNumber, isString, isUndefined } from '@sindresorhus/is';\nimport { WORKER_FILE_UPDATE_FAILED } from '../../../../constants/error-messages';\nimport { logger } from '../../../../logger';\nimport { extractPackageFile } from '../../../../modules/manager';\nimport type { PackageDependency } from '../../../../modules/manager/types';\nimport { writeLocalFile } from '../../../../util/fs';\nimport { escapeRegExp, regEx } from '../../../../util/regex';\nimport { matchAt, replaceAt } from '../../../../util/string';\nimport { compile } from '../../../../util/template';\nimport type { BranchUpgradeConfig } from '../../../types';\n\nexport async function confirmIfDepUpdated(\n upgrade: BranchUpgradeConfig,\n newContent: string,\n): Promise<boolean> {\n const { manager, packageFile, depIndex } = upgrade;\n let newUpgrade: PackageDependency;\n try {\n const newExtract = await extractPackageFile(\n manager,\n newContent,\n packageFile!,\n upgrade,\n );\n // istanbul ignore if\n if (!newExtract) {\n // TODO: fix types (#22198)\n logger.debug(\n `Could not extract ${packageFile!} (manager=${manager}) after autoreplace. Did the autoreplace make the file unparseable?`,\n );\n logger.trace(\n { packageFile, content: newContent },\n 'packageFile content after autoreplace',\n );\n return false;\n }\n // istanbul ignore if\n if (!newExtract.deps?.length) {\n logger.debug(\n `Extracted ${packageFile!} after autoreplace has no deps array. Did the autoreplace make the file unparseable?`,\n );\n return false;\n }\n // istanbul ignore if\n if (isNumber(depIndex) && depIndex >= newExtract.deps.length) {\n logger.debug(\n `Extracted ${packageFile!} after autoreplace has fewer deps than expected.`,\n );\n return false;\n }\n newUpgrade = newExtract.deps[depIndex!];\n } catch (err) /* istanbul ignore next */ {\n logger.debug({ manager, packageFile, err }, 'Failed to parse newContent');\n }\n\n if (!newUpgrade!) {\n logger.debug(`No newUpgrade in ${packageFile!}`);\n return false;\n }\n\n if (\n upgrade.depName !== newUpgrade.depName &&\n upgrade.newName !== newUpgrade.depName\n ) {\n logger.debug(\n {\n manager,\n packageFile,\n currentDepName: upgrade.depName,\n newDepName: newUpgrade.depName,\n },\n 'depName mismatch',\n );\n return false;\n }\n\n if (upgrade.newName && upgrade.newName !== newUpgrade.depName) {\n logger.debug(\n {\n manager,\n packageFile,\n currentDepName: upgrade.depName,\n newDepName: newUpgrade.depName,\n },\n 'depName is not updated',\n );\n return false;\n }\n\n if (upgrade.newValue && upgrade.newValue !== newUpgrade.currentValue) {\n logger.debug(\n {\n depName: upgrade.depName,\n manager,\n packageFile,\n expectedValue: upgrade.newValue,\n foundValue: newUpgrade.currentValue,\n },\n 'Value is not updated',\n );\n return false;\n }\n\n if (\n upgrade.newDigest &&\n (upgrade.isPinDigest === true || upgrade.currentDigest) &&\n upgrade.newDigest !== newUpgrade.currentDigest\n ) {\n logger.debug(\n {\n depName: upgrade.depName,\n manager,\n packageFile,\n expectedValue: upgrade.newDigest,\n foundValue: newUpgrade.currentDigest,\n },\n 'Digest is not updated',\n );\n return false;\n }\n\n return true;\n}\n\nfunction getDepsSignature(deps: PackageDependency[]): string {\n // TODO: types (#22198)\n return deps\n .map(\n (dep) =>\n `${(dep.depName ?? dep.packageName)!}${(dep.packageName ??\n dep.depName)!}`,\n )\n .join(',');\n}\n\nfunction firstIndexOf(\n existingContent: string,\n depName: string,\n currentValue: string,\n position = 0,\n): number {\n const depIndex = existingContent.indexOf(depName, position);\n const valIndex = existingContent.indexOf(currentValue, position);\n const index = depIndex < valIndex ? depIndex : valIndex;\n if (index < 0) {\n return position === 0 ? -1 : existingContent.length;\n }\n return index;\n}\n\nexport async function checkBranchDepsMatchBaseDeps(\n upgrade: BranchUpgradeConfig,\n branchContent: string,\n): Promise<boolean> {\n const { baseDeps, manager, packageFile } = upgrade;\n try {\n const res = await extractPackageFile(\n manager,\n branchContent,\n packageFile!,\n upgrade,\n )!;\n const branchDeps = res!.deps;\n return getDepsSignature(baseDeps!) === getDepsSignature(branchDeps);\n } catch /* istanbul ignore next */ {\n logger.info(\n { manager, packageFile },\n 'Failed to parse branchContent - rebasing',\n );\n return false;\n }\n}\n\nasync function checkExistingBranch(\n upgrade: BranchUpgradeConfig,\n existingContent: string,\n): Promise<string | null> {\n const { packageFile, depName } = upgrade;\n if (!(await checkBranchDepsMatchBaseDeps(upgrade, existingContent))) {\n logger.debug(\n { packageFile, depName },\n 'Rebasing branch after deps list has changed',\n );\n return null;\n }\n if (!(await confirmIfDepUpdated(upgrade, existingContent))) {\n logger.debug(\n { packageFile, depName },\n 'Rebasing after outdated branch dep found',\n );\n return null;\n }\n // TODO: fix types (#22198)\n logger.debug(`Branch dep ${depName!} in ${packageFile!} is already updated`);\n return existingContent;\n}\n\nexport async function doAutoReplace(\n upgrade: BranchUpgradeConfig,\n existingContent: string,\n reuseExistingBranch: boolean,\n firstUpdate = true,\n): Promise<string | null> {\n const {\n packageFile,\n depName,\n depNameTemplate,\n newName,\n currentValue,\n currentValueTemplate,\n newValue,\n currentDigest,\n currentDigestShort,\n newDigest,\n autoReplaceGlobalMatch,\n autoReplaceStringTemplate,\n } = upgrade;\n /*\n If replacement support for more managers is added,\n please also update the list in docs/usage/configuration-options.md\n at replacementName and replacementVersion\n */\n if (reuseExistingBranch) {\n return await checkExistingBranch(upgrade, existingContent);\n }\n const replaceWithoutReplaceString =\n isString(newName) &&\n newName !== depName &&\n (isUndefined(upgrade.replaceString) ||\n !upgrade.replaceString?.includes(depName!));\n const replaceString = upgrade.replaceString ?? currentValue ?? currentDigest;\n logger.trace({ depName, replaceString }, 'autoReplace replaceString');\n let searchIndex: number;\n if (replaceWithoutReplaceString) {\n searchIndex = firstIndexOf(existingContent, depName!, currentValue!);\n } else {\n searchIndex = existingContent.indexOf(replaceString!);\n }\n if (searchIndex === -1) {\n logger.info(\n { packageFile, depName, existingContent, replaceString },\n 'Cannot find replaceString in current file content. Was it already updated?',\n );\n return existingContent;\n }\n try {\n let newString: string;\n if (autoReplaceStringTemplate && !newName) {\n newString = compile(autoReplaceStringTemplate, upgrade, false);\n } else {\n newString = replaceString!;\n\n const autoReplaceRegExpFlag = autoReplaceGlobalMatch ? 'g' : '';\n if (currentValue && newValue && currentValue !== newValue) {\n if (!newString.includes(currentValue)) {\n logger.debug(\n { stringToReplace: newString, currentValue, currentValueTemplate },\n 'currentValue not found in string to replace',\n );\n }\n newString = newString.replace(\n regEx(escapeRegExp(currentValue), autoReplaceRegExpFlag),\n newValue,\n );\n }\n if (depName && newName && depName !== newName) {\n if (!newString.includes(depName)) {\n logger.debug(\n { stringToReplace: newString, depName, depNameTemplate },\n 'depName not found in string to replace',\n );\n }\n newString = newString.replace(\n regEx(escapeRegExp(depName), autoReplaceRegExpFlag),\n newName,\n );\n }\n if (currentDigest && newDigest && currentDigest !== newDigest) {\n if (!newString.includes(currentDigest)) {\n logger.debug(\n { stringToReplace: newString, currentDigest },\n 'currentDigest not found in string to replace',\n );\n }\n newString = newString.replace(\n regEx(escapeRegExp(currentDigest), autoReplaceRegExpFlag),\n newDigest,\n );\n } else if (\n currentDigestShort &&\n newDigest &&\n currentDigestShort !== newDigest\n ) {\n if (!newString.includes(currentDigestShort)) {\n logger.debug(\n { stringToReplace: newString, currentDigestShort },\n 'currentDigestShort not found in string to replace',\n );\n }\n newString = newString.replace(\n regEx(escapeRegExp(currentDigestShort), autoReplaceRegExpFlag),\n newDigest,\n );\n }\n }\n if (!firstUpdate && (await confirmIfDepUpdated(upgrade, existingContent))) {\n logger.debug(\n { packageFile, depName },\n 'Package file is already updated - no work to do',\n );\n return existingContent;\n }\n logger.debug(\n { packageFile, depName },\n `Starting search at index ${searchIndex}`,\n );\n let newContent = existingContent;\n let nameReplaced = !newName;\n let valueReplaced = !newValue;\n let digestReplaced = !newDigest;\n let startIndex = searchIndex;\n // Iterate through the rest of the file\n for (; searchIndex < newContent.length; searchIndex += 1) {\n // First check if we have a hit for the old version\n if (replaceWithoutReplaceString) {\n // look for depName and currentValue\n if (newName && matchAt(newContent, searchIndex, depName!)) {\n logger.debug(\n { packageFile, depName },\n `Found depName at index ${searchIndex}`,\n );\n if (nameReplaced) {\n startIndex = firstIndexOf(\n existingContent,\n depName!,\n currentValue!,\n startIndex + 1,\n );\n searchIndex = startIndex - 1;\n await writeLocalFile(upgrade.packageFile!, existingContent);\n newContent = existingContent;\n nameReplaced = !newName;\n valueReplaced = !newValue;\n digestReplaced = !newDigest;\n continue;\n }\n // replace with newName\n newContent = replaceAt(newContent, searchIndex, depName!, newName);\n await writeLocalFile(upgrade.packageFile!, newContent);\n nameReplaced = true;\n searchIndex += newName.length - 1;\n } else if (\n newValue &&\n matchAt(newContent, searchIndex, currentValue!)\n ) {\n logger.debug(\n { packageFile, currentValue },\n `Found currentValue at index ${searchIndex}`,\n );\n if (valueReplaced) {\n startIndex = firstIndexOf(\n existingContent,\n depName!,\n currentValue!,\n startIndex + 1,\n );\n searchIndex = startIndex - 1;\n await writeLocalFile(upgrade.packageFile!, existingContent);\n newContent = existingContent;\n nameReplaced = !newName;\n valueReplaced = !newValue;\n digestReplaced = !newDigest;\n continue;\n }\n // Now test if the result matches\n newContent = replaceAt(\n newContent,\n searchIndex,\n currentValue!,\n newValue,\n );\n await writeLocalFile(upgrade.packageFile!, newContent);\n valueReplaced = true;\n searchIndex += newValue.length - 1;\n } else if (\n newDigest &&\n matchAt(newContent, searchIndex, currentDigest!)\n ) {\n logger.debug(\n { packageFile, currentDigest },\n `Found currentDigest at index ${searchIndex}`,\n );\n if (digestReplaced) {\n startIndex = firstIndexOf(\n existingContent,\n depName!,\n currentValue!,\n startIndex + 1,\n );\n searchIndex = startIndex - 1;\n await writeLocalFile(upgrade.packageFile!, existingContent);\n newContent = existingContent;\n nameReplaced = !newName;\n valueReplaced = !newValue;\n digestReplaced = !newDigest;\n continue;\n }\n // Now test if the result matches\n newContent = replaceAt(\n newContent,\n searchIndex,\n currentDigest!,\n newDigest,\n );\n await writeLocalFile(upgrade.packageFile!, newContent);\n digestReplaced = true;\n searchIndex += newDigest.length - 1;\n }\n if (nameReplaced && valueReplaced && digestReplaced) {\n if (await confirmIfDepUpdated(upgrade, newContent)) {\n return newContent;\n }\n startIndex = firstIndexOf(\n existingContent,\n depName!,\n currentValue!,\n startIndex + 1,\n );\n searchIndex = startIndex - 1;\n await writeLocalFile(upgrade.packageFile!, existingContent);\n newContent = existingContent;\n nameReplaced = !newName;\n valueReplaced = !newValue;\n digestReplaced = !newDigest;\n }\n } else if (matchAt(newContent, searchIndex, replaceString!)) {\n logger.debug(\n { packageFile, depName },\n `Found match at index ${searchIndex}`,\n );\n // Now test if the result matches\n newContent = replaceAt(\n newContent,\n searchIndex,\n replaceString!,\n newString,\n );\n await writeLocalFile(upgrade.packageFile!, newContent);\n if (await confirmIfDepUpdated(upgrade, newContent)) {\n return newContent;\n }\n await writeLocalFile(upgrade.packageFile!, existingContent);\n newContent = existingContent;\n }\n }\n } catch (err) /* istanbul ignore next */ {\n logger.debug({ packageFile, depName, err }, 'doAutoReplace error');\n }\n // istanbul ignore next\n throw new Error(WORKER_FILE_UPDATE_FAILED);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"auto-replace.js","sourceRoot":"","sources":["../../../../../lib/workers/repository/update/branch/auto-replace.ts"],"names":[],"mappings":";;AAYA,kDAgHC;AA4BD,oEAqBC;AA0BD,sCAwQC;AA/cD,cAAc;AACd,yCAAmE;AACnE,yEAAiF;AACjF,+CAA4C;AAC5C,yDAAiE;AAEjE,4CAAqD;AACrD,kDAA6D;AAC7D,oDAA6D;AAC7D,wDAAoD;AAG7C,KAAK,UAAU,mBAAmB,CACvC,OAA4B,EAC5B,UAAkB;IAElB,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACnD,IAAI,UAA6B,CAAC;IAClC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAkB,EACzC,OAAO,EACP,UAAU,EACV,WAAY,EACZ,OAAO,CACR,CAAC;QACF,qBAAqB;QACrB,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,2BAA2B;YAC3B,eAAM,CAAC,KAAK,CACV,qBAAqB,WAAY,aAAa,OAAO,qEAAqE,CAC3H,CAAC;YACF,eAAM,CAAC,KAAK,CACV,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,EACpC,uCAAuC,CACxC,CAAC;YACF,OAAO,KAAK,CAAC;QACf,CAAC;QACD,qBAA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C;YACH,CAAC;iBAAM,IAAI,IAAA,gBAAO,EAAC,UAAU,EAAE,WAAW,EAAE,aAAc,CAAC,EAAE,CAAC;gBAC5D,eAAM,CAAC,KAAK,CACV,EAAE,WAAW,EAAE,OAAO,EAAE,EACxB,wBAAwB,WAAW,EAAE,CACtC,CAAC;gBACF,iCAAiC;gBACjC,UAAU,GAAG,IAAA,kBAAS,EACpB,UAAU,EACV,WAAW,EACX,aAAc,EACd,SAAS,CACV,CAAC;gBACF,MAAM,IAAA,mBAAc,EAAC,OAAO,CAAC,WAAY,EAAE,UAAU,CAAC,CAAC;gBACvD,IAAI,MAAM,mBAAmB,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,CAAC;oBACnD,OAAO,UAAU,CAAC;gBACpB,CAAC;gBACD,MAAM,IAAA,mBAAc,EAAC,OAAO,CAAC,WAAY,EAAE,eAAe,CAAC,CAAC;gBAC5D,UAAU,GAAG,eAAe,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,0BAA0B;QAC1B,eAAM,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,qBAAqB,CAAC,CAAC;IACrE,CAAC;IACD,uBAAuB;IACvB,MAAM,IAAI,KAAK,CAAC,0CAAyB,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["// TODO #22198\nimport { isNumber, isString, isUndefined } from '@sindresorhus/is';\nimport { WORKER_FILE_UPDATE_FAILED } from '../../../../constants/error-messages';\nimport { logger } from '../../../../logger';\nimport { extractPackageFile } from '../../../../modules/manager';\nimport type { PackageDependency } from '../../../../modules/manager/types';\nimport { writeLocalFile } from '../../../../util/fs';\nimport { escapeRegExp, regEx } from '../../../../util/regex';\nimport { matchAt, replaceAt } from '../../../../util/string';\nimport { compile } from '../../../../util/template';\nimport type { BranchUpgradeConfig } from '../../../types';\n\nexport async function confirmIfDepUpdated(\n upgrade: BranchUpgradeConfig,\n newContent: string,\n): Promise<boolean> {\n const { manager, packageFile, depIndex } = upgrade;\n let newUpgrade: PackageDependency;\n try {\n const newExtract = await extractPackageFile(\n manager,\n newContent,\n packageFile!,\n upgrade,\n );\n // istanbul ignore if\n if (!newExtract) {\n // TODO: fix types (#22198)\n logger.debug(\n `Could not extract ${packageFile!} (manager=${manager}) after autoreplace. Did the autoreplace make the file unparseable?`,\n );\n logger.trace(\n { packageFile, content: newContent },\n 'packageFile content after autoreplace',\n );\n return false;\n }\n // istanbul ignore if\n if (!newExtract.deps?.length) {\n logger.debug(\n `Extracted ${packageFile!} after autoreplace has no deps array. Did the autoreplace make the file unparseable?`,\n );\n return false;\n }\n // istanbul ignore if\n if (isNumber(depIndex) && depIndex >= newExtract.deps.length) {\n logger.debug(\n `Extracted ${packageFile!} after autoreplace has fewer deps than expected.`,\n );\n return false;\n }\n newUpgrade = newExtract.deps[depIndex!];\n } catch (err) {\n /* istanbul ignore next */\n logger.debug({ manager, packageFile, err }, 'Failed to parse newContent');\n }\n\n if (!newUpgrade!) {\n logger.debug(`No newUpgrade in ${packageFile!}`);\n return false;\n }\n\n if (\n upgrade.depName !== newUpgrade.depName &&\n upgrade.newName !== newUpgrade.depName\n ) {\n logger.debug(\n {\n manager,\n packageFile,\n currentDepName: upgrade.depName,\n newDepName: newUpgrade.depName,\n },\n 'depName mismatch',\n );\n return false;\n }\n\n if (upgrade.newName && upgrade.newName !== newUpgrade.depName) {\n logger.debug(\n {\n manager,\n packageFile,\n currentDepName: upgrade.depName,\n newDepName: newUpgrade.depName,\n },\n 'depName is not updated',\n );\n return false;\n }\n\n if (upgrade.newValue && upgrade.newValue !== newUpgrade.currentValue) {\n logger.debug(\n {\n depName: upgrade.depName,\n manager,\n packageFile,\n expectedValue: upgrade.newValue,\n foundValue: newUpgrade.currentValue,\n },\n 'Value is not updated',\n );\n return false;\n }\n\n if (\n upgrade.newDigest &&\n (upgrade.isPinDigest === true || upgrade.currentDigest) &&\n upgrade.newDigest !== newUpgrade.currentDigest\n ) {\n logger.debug(\n {\n depName: upgrade.depName,\n manager,\n packageFile,\n expectedValue: upgrade.newDigest,\n foundValue: newUpgrade.currentDigest,\n },\n 'Digest is not updated',\n );\n return false;\n }\n\n return true;\n}\n\nfunction getDepsSignature(deps: PackageDependency[]): string {\n // TODO: types (#22198)\n return deps\n .map(\n (dep) =>\n `${(dep.depName ?? dep.packageName)!}${(dep.packageName ??\n dep.depName)!}`,\n )\n .join(',');\n}\n\nfunction firstIndexOf(\n existingContent: string,\n depName: string,\n currentValue: string,\n position = 0,\n): number {\n const depIndex = existingContent.indexOf(depName, position);\n const valIndex = existingContent.indexOf(currentValue, position);\n const index = depIndex < valIndex ? depIndex : valIndex;\n if (index < 0) {\n return position === 0 ? -1 : existingContent.length;\n }\n return index;\n}\n\nexport async function checkBranchDepsMatchBaseDeps(\n upgrade: BranchUpgradeConfig,\n branchContent: string,\n): Promise<boolean> {\n const { baseDeps, manager, packageFile } = upgrade;\n try {\n const res = await extractPackageFile(\n manager,\n branchContent,\n packageFile!,\n upgrade,\n )!;\n const branchDeps = res!.deps;\n return getDepsSignature(baseDeps!) === getDepsSignature(branchDeps);\n } catch /* istanbul ignore next */ {\n logger.info(\n { manager, packageFile },\n 'Failed to parse branchContent - rebasing',\n );\n return false;\n }\n}\n\nasync function checkExistingBranch(\n upgrade: BranchUpgradeConfig,\n existingContent: string,\n): Promise<string | null> {\n const { packageFile, depName } = upgrade;\n if (!(await checkBranchDepsMatchBaseDeps(upgrade, existingContent))) {\n logger.debug(\n { packageFile, depName },\n 'Rebasing branch after deps list has changed',\n );\n return null;\n }\n if (!(await confirmIfDepUpdated(upgrade, existingContent))) {\n logger.debug(\n { packageFile, depName },\n 'Rebasing after outdated branch dep found',\n );\n return null;\n }\n // TODO: fix types (#22198)\n logger.debug(`Branch dep ${depName!} in ${packageFile!} is already updated`);\n return existingContent;\n}\n\nexport async function doAutoReplace(\n upgrade: BranchUpgradeConfig,\n existingContent: string,\n reuseExistingBranch: boolean,\n firstUpdate = true,\n): Promise<string | null> {\n const {\n packageFile,\n depName,\n depNameTemplate,\n newName,\n currentValue,\n currentValueTemplate,\n newValue,\n currentDigest,\n currentDigestShort,\n newDigest,\n autoReplaceGlobalMatch,\n autoReplaceStringTemplate,\n } = upgrade;\n /*\n If replacement support for more managers is added,\n please also update the list in docs/usage/configuration-options.md\n at replacementName and replacementVersion\n */\n if (reuseExistingBranch) {\n return await checkExistingBranch(upgrade, existingContent);\n }\n const replaceWithoutReplaceString =\n isString(newName) &&\n newName !== depName &&\n (isUndefined(upgrade.replaceString) ||\n !upgrade.replaceString?.includes(depName!));\n const replaceString = upgrade.replaceString ?? currentValue ?? currentDigest;\n logger.trace({ depName, replaceString }, 'autoReplace replaceString');\n let searchIndex: number;\n if (replaceWithoutReplaceString) {\n searchIndex = firstIndexOf(existingContent, depName!, currentValue!);\n } else {\n searchIndex = existingContent.indexOf(replaceString!);\n }\n if (searchIndex === -1) {\n logger.info(\n { packageFile, depName, existingContent, replaceString },\n 'Cannot find replaceString in current file content. Was it already updated?',\n );\n return existingContent;\n }\n try {\n let newString: string;\n if (autoReplaceStringTemplate && !newName) {\n newString = compile(autoReplaceStringTemplate, upgrade, false);\n } else {\n newString = replaceString!;\n\n const autoReplaceRegExpFlag = autoReplaceGlobalMatch ? 'g' : '';\n if (currentValue && newValue && currentValue !== newValue) {\n if (!newString.includes(currentValue)) {\n logger.debug(\n { stringToReplace: newString, currentValue, currentValueTemplate },\n 'currentValue not found in string to replace',\n );\n }\n newString = newString.replace(\n regEx(escapeRegExp(currentValue), autoReplaceRegExpFlag),\n newValue,\n );\n }\n if (depName && newName && depName !== newName) {\n if (!newString.includes(depName)) {\n logger.debug(\n { stringToReplace: newString, depName, depNameTemplate },\n 'depName not found in string to replace',\n );\n }\n newString = newString.replace(\n regEx(escapeRegExp(depName), autoReplaceRegExpFlag),\n newName,\n );\n }\n if (currentDigest && newDigest && currentDigest !== newDigest) {\n if (!newString.includes(currentDigest)) {\n logger.debug(\n { stringToReplace: newString, currentDigest },\n 'currentDigest not found in string to replace',\n );\n }\n newString = newString.replace(\n regEx(escapeRegExp(currentDigest), autoReplaceRegExpFlag),\n newDigest,\n );\n } else if (\n currentDigestShort &&\n newDigest &&\n currentDigestShort !== newDigest\n ) {\n if (!newString.includes(currentDigestShort)) {\n logger.debug(\n { stringToReplace: newString, currentDigestShort },\n 'currentDigestShort not found in string to replace',\n );\n }\n newString = newString.replace(\n regEx(escapeRegExp(currentDigestShort), autoReplaceRegExpFlag),\n newDigest,\n );\n }\n }\n if (!firstUpdate && (await confirmIfDepUpdated(upgrade, existingContent))) {\n logger.debug(\n { packageFile, depName },\n 'Package file is already updated - no work to do',\n );\n return existingContent;\n }\n logger.debug(\n { packageFile, depName },\n `Starting search at index ${searchIndex}`,\n );\n let newContent = existingContent;\n let nameReplaced = !newName;\n let valueReplaced = !newValue;\n let digestReplaced = !newDigest;\n let startIndex = searchIndex;\n // Iterate through the rest of the file\n for (; searchIndex < newContent.length; searchIndex += 1) {\n // First check if we have a hit for the old version\n if (replaceWithoutReplaceString) {\n // look for depName and currentValue\n if (newName && matchAt(newContent, searchIndex, depName!)) {\n logger.debug(\n { packageFile, depName },\n `Found depName at index ${searchIndex}`,\n );\n if (nameReplaced) {\n startIndex = firstIndexOf(\n existingContent,\n depName!,\n currentValue!,\n startIndex + 1,\n );\n searchIndex = startIndex - 1;\n await writeLocalFile(upgrade.packageFile!, existingContent);\n newContent = existingContent;\n nameReplaced = !newName;\n valueReplaced = !newValue;\n digestReplaced = !newDigest;\n continue;\n }\n // replace with newName\n newContent = replaceAt(newContent, searchIndex, depName!, newName);\n await writeLocalFile(upgrade.packageFile!, newContent);\n nameReplaced = true;\n searchIndex += newName.length - 1;\n } else if (\n newValue &&\n matchAt(newContent, searchIndex, currentValue!)\n ) {\n logger.debug(\n { packageFile, currentValue },\n `Found currentValue at index ${searchIndex}`,\n );\n if (valueReplaced) {\n startIndex = firstIndexOf(\n existingContent,\n depName!,\n currentValue!,\n startIndex + 1,\n );\n searchIndex = startIndex - 1;\n await writeLocalFile(upgrade.packageFile!, existingContent);\n newContent = existingContent;\n nameReplaced = !newName;\n valueReplaced = !newValue;\n digestReplaced = !newDigest;\n continue;\n }\n // Now test if the result matches\n newContent = replaceAt(\n newContent,\n searchIndex,\n currentValue!,\n newValue,\n );\n await writeLocalFile(upgrade.packageFile!, newContent);\n valueReplaced = true;\n searchIndex += newValue.length - 1;\n } else if (\n newDigest &&\n matchAt(newContent, searchIndex, currentDigest!)\n ) {\n logger.debug(\n { packageFile, currentDigest },\n `Found currentDigest at index ${searchIndex}`,\n );\n if (digestReplaced) {\n startIndex = firstIndexOf(\n existingContent,\n depName!,\n currentValue!,\n startIndex + 1,\n );\n searchIndex = startIndex - 1;\n await writeLocalFile(upgrade.packageFile!, existingContent);\n newContent = existingContent;\n nameReplaced = !newName;\n valueReplaced = !newValue;\n digestReplaced = !newDigest;\n continue;\n }\n // Now test if the result matches\n newContent = replaceAt(\n newContent,\n searchIndex,\n currentDigest!,\n newDigest,\n );\n await writeLocalFile(upgrade.packageFile!, newContent);\n digestReplaced = true;\n searchIndex += newDigest.length - 1;\n }\n if (nameReplaced && valueReplaced && digestReplaced) {\n if (await confirmIfDepUpdated(upgrade, newContent)) {\n return newContent;\n }\n startIndex = firstIndexOf(\n existingContent,\n depName!,\n currentValue!,\n startIndex + 1,\n );\n searchIndex = startIndex - 1;\n await writeLocalFile(upgrade.packageFile!, existingContent);\n newContent = existingContent;\n nameReplaced = !newName;\n valueReplaced = !newValue;\n digestReplaced = !newDigest;\n }\n } else if (matchAt(newContent, searchIndex, replaceString!)) {\n logger.debug(\n { packageFile, depName },\n `Found match at index ${searchIndex}`,\n );\n // Now test if the result matches\n newContent = replaceAt(\n newContent,\n searchIndex,\n replaceString!,\n newString,\n );\n await writeLocalFile(upgrade.packageFile!, newContent);\n if (await confirmIfDepUpdated(upgrade, newContent)) {\n return newContent;\n }\n await writeLocalFile(upgrade.packageFile!, existingContent);\n newContent = existingContent;\n }\n }\n } catch (err) {\n /* istanbul ignore next */\n logger.debug({ packageFile, depName, err }, 'doAutoReplace error');\n }\n // istanbul ignore next\n throw new Error(WORKER_FILE_UPDATE_FAILED);\n}\n"]}
|
|
@@ -34,11 +34,13 @@ async function tryBranchAutomerge(config) {
|
|
|
34
34
|
logger_1.logger.info({ branch: config.branchName }, 'Branch automerged');
|
|
35
35
|
return 'automerged'; // Branch no longer exists
|
|
36
36
|
}
|
|
37
|
-
catch (err)
|
|
37
|
+
catch (err) {
|
|
38
|
+
/* v8 ignore if -- TODO: needs test */
|
|
38
39
|
if (err.message === 'not ready') {
|
|
39
40
|
logger_1.logger.debug('Branch is not ready for automerge');
|
|
40
41
|
return 'not ready';
|
|
41
42
|
}
|
|
43
|
+
/* v8 ignore if -- TODO: needs test */
|
|
42
44
|
if (err.message.includes('refusing to merge unrelated histories') ||
|
|
43
45
|
err.message.includes('Not possible to fast-forward') ||
|
|
44
46
|
err.message.includes('Updates were rejected because the tip of your current branch is behind')) {
|
|
@@ -46,6 +48,7 @@ async function tryBranchAutomerge(config) {
|
|
|
46
48
|
logger_1.logger.info('Branch is not up to date - cannot automerge');
|
|
47
49
|
return 'stale';
|
|
48
50
|
}
|
|
51
|
+
/* v8 ignore if -- TODO: needs test */
|
|
49
52
|
if (err.message.includes('Protected branch')) {
|
|
50
53
|
if (err.message.includes('status check')) {
|
|
51
54
|
logger_1.logger.debug({ err }, 'Branch is not ready for automerge: required status checks are remaining');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automerge.js","sourceRoot":"","sources":["../../../../../lib/workers/repository/update/branch/automerge.ts"],"names":[],"mappings":";;AAkBA,
|
|
1
|
+
{"version":3,"file":"automerge.js","sourceRoot":"","sources":["../../../../../lib/workers/repository/update/branch/automerge.ts"],"names":[],"mappings":";;AAkBA,gDAmFC;AArGD,sDAAyD;AAEzD,+CAA4C;AAC5C,2DAAwD;AACxD,0DAAuD;AACvD,yCAA4C;AAC5C,mD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,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;SAAM,IAAI,YAAY,KAAK,KAAK,EAAE,CAAC;QAClC,OAAO,qBAAqB,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,eAAM,CAAC,KAAK,CAAC,qBAAqB,YAAY,wBAAwB,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import { GlobalConfig } from '../../../../config/global';\nimport type { RenovateConfig } from '../../../../config/types';\nimport { logger } from '../../../../logger';\nimport { platform } from '../../../../modules/platform';\nimport { scm } from '../../../../modules/platform/scm';\nimport { isScheduledNow } from './schedule';\nimport { resolveBranchStatus } from './status-checks';\n\nexport type AutomergeResult =\n | 'automerged'\n | 'automerge aborted - PR exists'\n | 'branch status error'\n | 'failed'\n | 'no automerge'\n | 'stale'\n | 'off schedule'\n | 'not ready';\n\nexport async function tryBranchAutomerge(\n config: RenovateConfig,\n): Promise<AutomergeResult> {\n logger.debug('Checking if we can automerge branch');\n if (!(config.automerge && config.automergeType === 'branch')) {\n return 'no automerge';\n }\n if (!isScheduledNow(config, 'automergeSchedule')) {\n return 'off schedule';\n }\n const existingPr = await platform.getBranchPr(\n config.branchName!,\n config.baseBranch,\n );\n if (existingPr) {\n return 'automerge aborted - PR exists';\n }\n const branchStatus = await resolveBranchStatus(\n config.branchName!,\n !!config.internalChecksAsSuccess,\n config.ignoreTests,\n );\n if (branchStatus === 'green') {\n logger.debug(`Automerging branch`);\n try {\n if (GlobalConfig.get('dryRun')) {\n // TODO: types (#22198)\n logger.info(`DRY-RUN: Would automerge branch ${config.branchName!}`);\n } else {\n await scm.checkoutBranch(config.baseBranch!);\n await scm.mergeAndPush(config.branchName!);\n }\n logger.info({ branch: config.branchName }, 'Branch automerged');\n return 'automerged'; // Branch no longer exists\n } catch (err) {\n /* v8 ignore if -- TODO: needs test */\n if (err.message === 'not ready') {\n logger.debug('Branch is not ready for automerge');\n return 'not ready';\n }\n /* v8 ignore if -- TODO: needs test */\n if (\n err.message.includes('refusing to merge unrelated histories') ||\n err.message.includes('Not possible to fast-forward') ||\n err.message.includes(\n 'Updates were rejected because the tip of your current branch is behind',\n )\n ) {\n logger.debug({ err }, 'Branch automerge error');\n logger.info('Branch is not up to date - cannot automerge');\n return 'stale';\n }\n /* v8 ignore if -- TODO: needs test */\n if (err.message.includes('Protected branch')) {\n if (err.message.includes('status check')) {\n logger.debug(\n { err },\n 'Branch is not ready for automerge: required status checks are remaining',\n );\n return 'not ready';\n }\n if (err.stack?.includes('reviewers')) {\n logger.info(\n { err },\n 'Branch automerge is not possible due to branch protection (required reviewers)',\n );\n return 'failed';\n }\n logger.info(\n { err },\n 'Branch automerge is not possible due to branch protection',\n );\n return 'failed';\n }\n logger.warn({ err }, 'Unknown error when attempting branch automerge');\n return 'failed';\n }\n } else if (branchStatus === 'red') {\n return 'branch status error';\n } else {\n logger.debug(`Branch status is \"${branchStatus}\" - skipping automerge`);\n }\n return 'no automerge';\n}\n"]}
|
|
@@ -134,6 +134,7 @@ async function postUpgradeCommandsExecutor(filteredUpgradeCommands, config) {
|
|
|
134
134
|
// Check for files which were previously deleted but have been re-added without modification
|
|
135
135
|
const previouslyDeletedFiles = updatedArtifacts.filter((ua) => ua.type === 'deletion');
|
|
136
136
|
for (const previouslyDeletedFile of previouslyDeletedFiles) {
|
|
137
|
+
/* v8 ignore if -- TODO: needs test */
|
|
137
138
|
if (!changedFiles.includes(previouslyDeletedFile.path)) {
|
|
138
139
|
logger_1.logger.debug({ file: previouslyDeletedFile.path }, 'Previously deleted file has been restored without modification');
|
|
139
140
|
updatedArtifacts = updatedArtifacts.filter((ua) => !(ua.type === 'deletion' && ua.path === previouslyDeletedFile.path));
|