renovate 43.31.2 → 43.31.4
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-validator.js +1 -1
- package/dist/config-validator.js.map +1 -1
- package/dist/instrumentation/index.js +2 -4
- package/dist/instrumentation/index.js.map +1 -1
- package/dist/renovate.js +11 -11
- package/dist/renovate.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/redis.d.ts +2 -2
- package/dist/util/cache/package/redis.js +5 -4
- package/dist/util/cache/package/redis.js.map +1 -1
- package/dist/workers/global/index.js +1 -1
- package/dist/workers/repository/index.js +1 -1
- package/package.json +6 -6
- package/renovate-schema.json +2 -2
package/dist/config-validator.js
CHANGED
|
@@ -11,8 +11,8 @@ import { validateConfig } from "./config/validation.js";
|
|
|
11
11
|
import { getParsedContent } from "./workers/global/config/parse/util.js";
|
|
12
12
|
import { getConfig } from "./workers/global/config/parse/file.js";
|
|
13
13
|
import { parseConfigs } from "./workers/global/config/parse/index.js";
|
|
14
|
-
import { Command, CommanderError } from "commander";
|
|
15
14
|
import "source-map-support/register.js";
|
|
15
|
+
import { Command, CommanderError } from "commander";
|
|
16
16
|
import { dequal } from "dequal";
|
|
17
17
|
import fs from "fs-extra";
|
|
18
18
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-validator.js","names":["getFileConfig"],"sources":["../lib/config-validator.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command, CommanderError } from 'commander';\nimport 'source-map-support/register.js';\nimport './punycode.cjs';\nimport { dequal } from 'dequal';\nimport fs from 'fs-extra';\nimport { getConfigFileNames } from './config/app-strings.ts';\nimport { GlobalConfig } from './config/global.ts';\nimport { massageConfig } from './config/massage.ts';\nimport { migrateConfig } from './config/migration.ts';\nimport type { RenovateConfig } from './config/types.ts';\nimport { validateConfig } from './config/validation.ts';\nimport { pkg } from './expose.ts';\nimport { logger } from './logger/index.ts';\nimport { getEnv } from './util/env.ts';\nimport { getConfig as getFileConfig } from './workers/global/config/parse/file.ts';\nimport { parseConfigs } from './workers/global/config/parse/index.ts';\nimport { getParsedContent } from './workers/global/config/parse/util.ts';\n\nconst { pathExists, readFile } = fs;\n\nlet returnVal = 0;\n\n/**\n * Make sure that we've resolved configuration from the different places that Renovate users would expect them to be specified\n *\n * This then allows a `configType=repo` config to i.e. be validated alongside a `config.js` or `env RENOVATE_ALLOWED_COMMANDS=...`\n *\n * Note that we intentionally don't fully initialize Renovate and its modules, as we're not fully running, and it would require a Platform to be configured\n * */\nasync function partiallyGlobalInitialize(): Promise<void> {\n // NOTE that this doesn't allow command-line arguments\n const globalConfig = await parseConfigs(getEnv(), []);\n GlobalConfig.set(globalConfig);\n}\n\nasync function validate(\n configType: 'global' | 'repo',\n desc: string,\n config: RenovateConfig,\n strict: boolean,\n isPreset = false,\n): Promise<void> {\n const { isMigrated, migratedConfig } = migrateConfig(config);\n if (isMigrated) {\n logger.warn(\n {\n oldConfig: config,\n newConfig: migratedConfig,\n },\n 'Config migration necessary',\n );\n if (strict) {\n returnVal = 1;\n }\n }\n const massagedConfig = massageConfig(migratedConfig);\n const res = await validateConfig(configType, massagedConfig, isPreset);\n if (res.errors.length) {\n logger.error(\n { file: desc, errors: res.errors },\n 'Found errors in configuration',\n );\n returnVal = 1;\n }\n if (res.warnings.length) {\n logger.warn(\n { file: desc, warnings: res.warnings },\n 'Found errors in configuration',\n );\n returnVal = 1;\n }\n}\n\ninterface PackageJson {\n renovate?: RenovateConfig;\n 'renovate-config'?: Record<string, RenovateConfig>;\n}\n\n(async () => {\n await partiallyGlobalInitialize();\n\n const program = new Command('renovate-config-validator')\n .summary('Validate Renovate configuration files')\n .description(\n `Validate your Renovate configuration (repo config, shared presets or global configuration) files\\n` +\n 'If no [config-files...] are given, renovate-config-validator will look at the default config file locations (https://docs.renovatebot.com/configuration-options/)',\n )\n .addHelpText(\n 'after',\n `\nWhen specifying [config-files...], Renovate will treat them as global self-hosted configuration files. You can disable this behaviour with --no-global\n\nExamples:\n\n $ renovate-config-validator\n $ renovate-config-validator --strict\n $ renovate-config-validator first_config.json\n $ renovate-config-validator --strict config.js\n $ renovate-config-validator --no-global renovate.json5\n $ env RENOVATE_CONFIG_FILE=obscure-name.json renovate-config-validator\n\nGlobal configuration:\n\nIf you have specified global self-hosted configuration (https://docs.renovatebot.com/self-hosted-configuration/) in environment variables or in a \\`config.js\\`, this will be detected:\n\n $ env RENOVATE_ALLOWED_ENV='[\"GO*\"]' renovate-config-validator\n # if passing the filename, make sure it's not validating as a global config\n $ env RENOVATE_ALLOWED_ENV='[\"GO*\"]' renovate-config-validator --no-global renovate.json`,\n )\n .argument('[config-files...]')\n .version(pkg.version, '-v, --version')\n .option(\n '--strict',\n 'Fail command if any configuration warnings, errors, or a migration is needed',\n )\n .option(\n '--no-global',\n 'When specifying [config-files], do not treat them as global self-hosted configuration file(s)',\n true,\n )\n // allow us to manage the exit code\n .exitOverride();\n\n program.action(async (files, opts) => {\n const strict = opts.strict ?? false;\n\n if (files.length) {\n let isGlobalConfig = true;\n if (opts.global === false) {\n isGlobalConfig = false;\n }\n const configType = isGlobalConfig ? 'global' : 'repo';\n for (const file of files) {\n try {\n if (!(await pathExists(file))) {\n returnVal = 1;\n logger.error({ file }, 'File does not exist');\n break;\n }\n const parsedContent = await getParsedContent(file);\n try {\n logger.info(`Validating ${file} as ${configType} config`);\n await validate(configType, file, parsedContent, strict);\n } catch (err) {\n logger.warn({ file, err }, 'File is not valid Renovate config');\n returnVal = 1;\n }\n } catch (err) {\n logger.warn({ file, err }, 'File could not be parsed');\n returnVal = 1;\n }\n }\n } else {\n for (const file of getConfigFileNames().filter(\n (name) => name !== 'package.json',\n )) {\n try {\n if (!(await pathExists(file))) {\n continue;\n }\n const parsedContent = await getParsedContent(file);\n try {\n logger.info(`Validating ${file}`);\n await validate('repo', file, parsedContent, strict);\n } catch (err) {\n logger.warn({ file, err }, 'File is not valid Renovate config');\n returnVal = 1;\n }\n } catch (err) {\n logger.warn({ file, err }, 'File could not be parsed');\n returnVal = 1;\n }\n }\n try {\n const pkgJson = JSON.parse(\n await readFile('package.json', 'utf8'),\n ) as PackageJson;\n if (pkgJson.renovate) {\n logger.info(`Validating package.json > renovate`);\n await validate(\n 'repo',\n 'package.json > renovate',\n pkgJson.renovate,\n strict,\n );\n }\n if (pkgJson['renovate-config']) {\n logger.info(`Validating package.json > renovate-config`);\n for (const presetConfig of Object.values(\n pkgJson['renovate-config'],\n )) {\n await validate(\n 'repo',\n 'package.json > renovate-config',\n presetConfig,\n strict,\n true,\n );\n }\n }\n } catch {\n // ignore\n }\n try {\n const env = getEnv();\n const fileConfig = await getFileConfig(env);\n if (!dequal(fileConfig, {})) {\n const file = env.RENOVATE_CONFIG_FILE ?? 'config.js';\n logger.info(`Validating ${file}`);\n try {\n await validate('global', file, fileConfig, strict);\n } catch (err) {\n logger.error({ file, err }, 'File is not valid Renovate config');\n returnVal = 1;\n }\n }\n } catch {\n // ignore\n }\n }\n if (returnVal !== 0) {\n process.exit(returnVal);\n }\n logger.info('Config validated successfully');\n });\n\n await program.parseAsync();\n})().catch((e) => {\n if (e instanceof CommanderError) {\n // Commander throws an error at the end of Action execution i.e. as part of the `help` command, and so we don't want to return an error code in this case\n if (e.code === 'commander.helpDisplayed') {\n return;\n }\n }\n\n // oxlint-disable-next-line no-console -- intentional: display critical error on CLI\n console.error(e);\n process.exit(99);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,EAAE,YAAY,aAAa;AAEjC,IAAI,YAAY;;;;;;;;AAShB,eAAe,4BAA2C;CAExD,MAAM,eAAe,MAAM,aAAa,QAAQ,EAAE,EAAE,CAAC;AACrD,cAAa,IAAI,aAAa;;AAGhC,eAAe,SACb,YACA,MACA,QACA,QACA,WAAW,OACI;CACf,MAAM,EAAE,YAAY,mBAAmB,cAAc,OAAO;AAC5D,KAAI,YAAY;AACd,SAAO,KACL;GACE,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ACb;;AAKJ,SAAQ,MAAM,EAAE;AAChB,SAAQ,KAAK,GAAG;EAChB"}
|
|
1
|
+
{"version":3,"file":"config-validator.js","names":["getFileConfig"],"sources":["../lib/config-validator.ts"],"sourcesContent":["#!/usr/bin/env node\nimport 'source-map-support/register.js';\nimport './punycode.cjs';\n\nimport { Command, CommanderError } from 'commander';\nimport { dequal } from 'dequal';\nimport fs from 'fs-extra';\nimport { getConfigFileNames } from './config/app-strings.ts';\nimport { GlobalConfig } from './config/global.ts';\nimport { massageConfig } from './config/massage.ts';\nimport { migrateConfig } from './config/migration.ts';\nimport type { RenovateConfig } from './config/types.ts';\nimport { validateConfig } from './config/validation.ts';\nimport { pkg } from './expose.ts';\nimport { logger } from './logger/index.ts';\nimport { getEnv } from './util/env.ts';\nimport { getConfig as getFileConfig } from './workers/global/config/parse/file.ts';\nimport { parseConfigs } from './workers/global/config/parse/index.ts';\nimport { getParsedContent } from './workers/global/config/parse/util.ts';\n\nconst { pathExists, readFile } = fs;\n\nlet returnVal = 0;\n\n/**\n * Make sure that we've resolved configuration from the different places that Renovate users would expect them to be specified\n *\n * This then allows a `configType=repo` config to i.e. be validated alongside a `config.js` or `env RENOVATE_ALLOWED_COMMANDS=...`\n *\n * Note that we intentionally don't fully initialize Renovate and its modules, as we're not fully running, and it would require a Platform to be configured\n * */\nasync function partiallyGlobalInitialize(): Promise<void> {\n // NOTE that this doesn't allow command-line arguments\n const globalConfig = await parseConfigs(getEnv(), []);\n GlobalConfig.set(globalConfig);\n}\n\nasync function validate(\n configType: 'global' | 'repo',\n desc: string,\n config: RenovateConfig,\n strict: boolean,\n isPreset = false,\n): Promise<void> {\n const { isMigrated, migratedConfig } = migrateConfig(config);\n if (isMigrated) {\n logger.warn(\n {\n oldConfig: config,\n newConfig: migratedConfig,\n },\n 'Config migration necessary',\n );\n if (strict) {\n returnVal = 1;\n }\n }\n const massagedConfig = massageConfig(migratedConfig);\n const res = await validateConfig(configType, massagedConfig, isPreset);\n if (res.errors.length) {\n logger.error(\n { file: desc, errors: res.errors },\n 'Found errors in configuration',\n );\n returnVal = 1;\n }\n if (res.warnings.length) {\n logger.warn(\n { file: desc, warnings: res.warnings },\n 'Found errors in configuration',\n );\n returnVal = 1;\n }\n}\n\ninterface PackageJson {\n renovate?: RenovateConfig;\n 'renovate-config'?: Record<string, RenovateConfig>;\n}\n\n(async () => {\n await partiallyGlobalInitialize();\n\n const program = new Command('renovate-config-validator')\n .summary('Validate Renovate configuration files')\n .description(\n `Validate your Renovate configuration (repo config, shared presets or global configuration) files\\n` +\n 'If no [config-files...] are given, renovate-config-validator will look at the default config file locations (https://docs.renovatebot.com/configuration-options/)',\n )\n .addHelpText(\n 'after',\n `\nWhen specifying [config-files...], Renovate will treat them as global self-hosted configuration files. You can disable this behaviour with --no-global\n\nExamples:\n\n $ renovate-config-validator\n $ renovate-config-validator --strict\n $ renovate-config-validator first_config.json\n $ renovate-config-validator --strict config.js\n $ renovate-config-validator --no-global renovate.json5\n $ env RENOVATE_CONFIG_FILE=obscure-name.json renovate-config-validator\n\nGlobal configuration:\n\nIf you have specified global self-hosted configuration (https://docs.renovatebot.com/self-hosted-configuration/) in environment variables or in a \\`config.js\\`, this will be detected:\n\n $ env RENOVATE_ALLOWED_ENV='[\"GO*\"]' renovate-config-validator\n # if passing the filename, make sure it's not validating as a global config\n $ env RENOVATE_ALLOWED_ENV='[\"GO*\"]' renovate-config-validator --no-global renovate.json`,\n )\n .argument('[config-files...]')\n .version(pkg.version, '-v, --version')\n .option(\n '--strict',\n 'Fail command if any configuration warnings, errors, or a migration is needed',\n )\n .option(\n '--no-global',\n 'When specifying [config-files], do not treat them as global self-hosted configuration file(s)',\n true,\n )\n // allow us to manage the exit code\n .exitOverride();\n\n program.action(async (files, opts) => {\n const strict = opts.strict ?? false;\n\n if (files.length) {\n let isGlobalConfig = true;\n if (opts.global === false) {\n isGlobalConfig = false;\n }\n const configType = isGlobalConfig ? 'global' : 'repo';\n for (const file of files) {\n try {\n if (!(await pathExists(file))) {\n returnVal = 1;\n logger.error({ file }, 'File does not exist');\n break;\n }\n const parsedContent = await getParsedContent(file);\n try {\n logger.info(`Validating ${file} as ${configType} config`);\n await validate(configType, file, parsedContent, strict);\n } catch (err) {\n logger.warn({ file, err }, 'File is not valid Renovate config');\n returnVal = 1;\n }\n } catch (err) {\n logger.warn({ file, err }, 'File could not be parsed');\n returnVal = 1;\n }\n }\n } else {\n for (const file of getConfigFileNames().filter(\n (name) => name !== 'package.json',\n )) {\n try {\n if (!(await pathExists(file))) {\n continue;\n }\n const parsedContent = await getParsedContent(file);\n try {\n logger.info(`Validating ${file}`);\n await validate('repo', file, parsedContent, strict);\n } catch (err) {\n logger.warn({ file, err }, 'File is not valid Renovate config');\n returnVal = 1;\n }\n } catch (err) {\n logger.warn({ file, err }, 'File could not be parsed');\n returnVal = 1;\n }\n }\n try {\n const pkgJson = JSON.parse(\n await readFile('package.json', 'utf8'),\n ) as PackageJson;\n if (pkgJson.renovate) {\n logger.info(`Validating package.json > renovate`);\n await validate(\n 'repo',\n 'package.json > renovate',\n pkgJson.renovate,\n strict,\n );\n }\n if (pkgJson['renovate-config']) {\n logger.info(`Validating package.json > renovate-config`);\n for (const presetConfig of Object.values(\n pkgJson['renovate-config'],\n )) {\n await validate(\n 'repo',\n 'package.json > renovate-config',\n presetConfig,\n strict,\n true,\n );\n }\n }\n } catch {\n // ignore\n }\n try {\n const env = getEnv();\n const fileConfig = await getFileConfig(env);\n if (!dequal(fileConfig, {})) {\n const file = env.RENOVATE_CONFIG_FILE ?? 'config.js';\n logger.info(`Validating ${file}`);\n try {\n await validate('global', file, fileConfig, strict);\n } catch (err) {\n logger.error({ file, err }, 'File is not valid Renovate config');\n returnVal = 1;\n }\n }\n } catch {\n // ignore\n }\n }\n if (returnVal !== 0) {\n process.exit(returnVal);\n }\n logger.info('Config validated successfully');\n });\n\n await program.parseAsync();\n})().catch((e) => {\n if (e instanceof CommanderError) {\n // Commander throws an error at the end of Action execution i.e. as part of the `help` command, and so we don't want to return an error code in this case\n if (e.code === 'commander.helpDisplayed') {\n return;\n }\n }\n\n // oxlint-disable-next-line no-console -- intentional: display critical error on CLI\n console.error(e);\n process.exit(99);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,EAAE,YAAY,aAAa;AAEjC,IAAI,YAAY;;;;;;;;AAShB,eAAe,4BAA2C;CAExD,MAAM,eAAe,MAAM,aAAa,QAAQ,EAAE,EAAE,CAAC;AACrD,cAAa,IAAI,aAAa;;AAGhC,eAAe,SACb,YACA,MACA,QACA,QACA,WAAW,OACI;CACf,MAAM,EAAE,YAAY,mBAAmB,cAAc,OAAO;AAC5D,KAAI,YAAY;AACd,SAAO,KACL;GACE,WAAW;GACX,WAAW;GACZ,EACD,6BACD;AACD,MAAI,OACF,aAAY;;CAIhB,MAAM,MAAM,MAAM,eAAe,YADV,cAAc,eAAe,EACS,SAAS;AACtE,KAAI,IAAI,OAAO,QAAQ;AACrB,SAAO,MACL;GAAE,MAAM;GAAM,QAAQ,IAAI;GAAQ,EAClC,gCACD;AACD,cAAY;;AAEd,KAAI,IAAI,SAAS,QAAQ;AACvB,SAAO,KACL;GAAE,MAAM;GAAM,UAAU,IAAI;GAAU,EACtC,gCACD;AACD,cAAY;;;CASf,YAAY;AACX,OAAM,2BAA2B;CAEjC,MAAM,UAAU,IAAI,QAAQ,4BAA4B,CACrD,QAAQ,wCAAwC,CAChD,YACC,sQAED,CACA,YACC,SACA;;;;;;;;;;;;;;;;;;4FAmBD,CACA,SAAS,oBAAoB,CAC7B,QAAQ,IAAI,SAAS,gBAAgB,CACrC,OACC,YACA,+EACD,CACA,OACC,eACA,iGACA,KACD,CAEA,cAAc;AAEjB,SAAQ,OAAO,OAAO,OAAO,SAAS;EACpC,MAAM,SAAS,KAAK,UAAU;AAE9B,MAAI,MAAM,QAAQ;GAChB,IAAI,iBAAiB;AACrB,OAAI,KAAK,WAAW,MAClB,kBAAiB;GAEnB,MAAM,aAAa,iBAAiB,WAAW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AAMA,UAAc,IAAI;AAC3C,QAAI,CAAC,OAAO,YAAY,EAAE,CAAC,EAAE;KAC3B,MAAM,OAAO,IAAI,wBAAwB;AACzC,YAAO,KAAK,cAAc,OAAO;AACjC,SAAI;AACF,YAAM,SAAS,UAAU,MAAM,YAAY,OAAO;cAC3C,KAAK;AACZ,aAAO,MAAM;OAAE;OAAM;OAAK,EAAE,oCAAoC;AAChE,kBAAY;;;WAGV;;AAIV,MAAI,cAAc,EAChB,SAAQ,KAAK,UAAU;AAEzB,SAAO,KAAK,gCAAgC;GAC5C;AAEF,OAAM,QAAQ,YAAY;IACxB,CAAC,OAAO,MAAM;AAChB,KAAI,aAAa,gBAEf;MAAI,EAAE,SAAS,0BACb;;AAKJ,SAAQ,MAAM,EAAE;AAChB,SAAQ,KAAK,GAAG;EAChB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { pkg } from "../expose.js";
|
|
2
|
-
import { getEnv } from "../util/env.js";
|
|
3
2
|
import { GitOperationSpanProcessor } from "../util/git/span-processor.js";
|
|
4
3
|
import { isTraceDebuggingEnabled, isTraceSendingEnabled, isTracingEnabled, massageThrowable } from "./utils.js";
|
|
5
4
|
import { isPromise } from "@sindresorhus/is";
|
|
@@ -23,7 +22,6 @@ import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from "@opentelemetry/semantic
|
|
|
23
22
|
|
|
24
23
|
//#region lib/instrumentation/index.ts
|
|
25
24
|
let instrumentations = [];
|
|
26
|
-
init();
|
|
27
25
|
function init() {
|
|
28
26
|
if (!isTracingEnabled()) return;
|
|
29
27
|
// v8 ignore if -- TODO add tests
|
|
@@ -35,7 +33,7 @@ function init() {
|
|
|
35
33
|
spanProcessors.push(new BatchSpanProcessor(exporter));
|
|
36
34
|
spanProcessors.push(new GitOperationSpanProcessor());
|
|
37
35
|
}
|
|
38
|
-
const env =
|
|
36
|
+
const env = process.env;
|
|
39
37
|
const baseResource = resourceFromAttributes({
|
|
40
38
|
[ATTR_SERVICE_NAME]: env.OTEL_SERVICE_NAME ?? "renovate",
|
|
41
39
|
["service.namespace"]: env.OTEL_SERVICE_NAMESPACE ?? "renovatebot.com",
|
|
@@ -111,5 +109,5 @@ function instrument(name, fn, options = {}, context = api.context.active()) {
|
|
|
111
109
|
}
|
|
112
110
|
|
|
113
111
|
//#endregion
|
|
114
|
-
export { instrument, shutdown };
|
|
112
|
+
export { init, instrument, shutdown };
|
|
115
113
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../lib/instrumentation/index.ts"],"sourcesContent":["import { ClientRequest } from 'node:http';\nimport type { Context, Span, Tracer, TracerProvider } from '@opentelemetry/api';\nimport * as api from '@opentelemetry/api';\nimport { ProxyTracerProvider, SpanStatusCode } from '@opentelemetry/api';\nimport { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport type { Instrumentation } from '@opentelemetry/instrumentation';\nimport { registerInstrumentations } from '@opentelemetry/instrumentation';\nimport { BunyanInstrumentation } from '@opentelemetry/instrumentation-bunyan';\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http';\nimport { RedisInstrumentation } from '@opentelemetry/instrumentation-redis';\nimport {\n awsBeanstalkDetector,\n awsEc2Detector,\n awsEcsDetector,\n awsEksDetector,\n awsLambdaDetector,\n} from '@opentelemetry/resource-detector-aws';\nimport {\n azureAppServiceDetector,\n azureFunctionsDetector,\n azureVmDetector,\n} from '@opentelemetry/resource-detector-azure';\nimport { gcpDetector } from '@opentelemetry/resource-detector-gcp';\nimport { gitHubDetector } from '@opentelemetry/resource-detector-github';\nimport {\n detectResources,\n envDetector,\n resourceFromAttributes,\n} from '@opentelemetry/resources';\nimport {\n BatchSpanProcessor,\n ConsoleSpanExporter,\n SimpleSpanProcessor,\n type SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport {\n ATTR_SERVICE_NAME,\n ATTR_SERVICE_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport { isPromise } from '@sindresorhus/is';\nimport { pkg } from '../expose.ts';\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../lib/instrumentation/index.ts"],"sourcesContent":["import { ClientRequest } from 'node:http';\nimport type { Context, Span, Tracer, TracerProvider } from '@opentelemetry/api';\nimport * as api from '@opentelemetry/api';\nimport { ProxyTracerProvider, SpanStatusCode } from '@opentelemetry/api';\nimport { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport type { Instrumentation } from '@opentelemetry/instrumentation';\nimport { registerInstrumentations } from '@opentelemetry/instrumentation';\nimport { BunyanInstrumentation } from '@opentelemetry/instrumentation-bunyan';\nimport { HttpInstrumentation } from '@opentelemetry/instrumentation-http';\nimport { RedisInstrumentation } from '@opentelemetry/instrumentation-redis';\nimport {\n awsBeanstalkDetector,\n awsEc2Detector,\n awsEcsDetector,\n awsEksDetector,\n awsLambdaDetector,\n} from '@opentelemetry/resource-detector-aws';\nimport {\n azureAppServiceDetector,\n azureFunctionsDetector,\n azureVmDetector,\n} from '@opentelemetry/resource-detector-azure';\nimport { gcpDetector } from '@opentelemetry/resource-detector-gcp';\nimport { gitHubDetector } from '@opentelemetry/resource-detector-github';\nimport {\n detectResources,\n envDetector,\n resourceFromAttributes,\n} from '@opentelemetry/resources';\nimport {\n BatchSpanProcessor,\n ConsoleSpanExporter,\n SimpleSpanProcessor,\n type SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport {\n ATTR_SERVICE_NAME,\n ATTR_SERVICE_VERSION,\n} from '@opentelemetry/semantic-conventions';\nimport { isPromise } from '@sindresorhus/is';\nimport { pkg } from '../expose.ts';\nimport { GitOperationSpanProcessor } from '../util/git/span-processor.ts';\nimport type { RenovateSpanOptions } from './types.ts';\nimport {\n isTraceDebuggingEnabled,\n isTraceSendingEnabled,\n isTracingEnabled,\n massageThrowable,\n} from './utils.ts';\n\nlet instrumentations: Instrumentation[] = [];\n\nexport function init(): void {\n if (!isTracingEnabled()) {\n return;\n }\n\n // v8 ignore if -- TODO add tests\n if (process.env.OTEL_LOG_LEVEL) {\n api.diag.setLogger(\n new api.DiagConsoleLogger(),\n api.DiagLogLevel[\n process.env.OTEL_LOG_LEVEL.toUpperCase() as keyof typeof api.DiagLogLevel\n ],\n );\n }\n\n const spanProcessors: SpanProcessor[] = [];\n // add processors\n if (isTraceDebuggingEnabled()) {\n spanProcessors.push(new SimpleSpanProcessor(new ConsoleSpanExporter()));\n }\n\n // OTEL specification environment variable\n if (isTraceSendingEnabled()) {\n const exporter = new OTLPTraceExporter();\n spanProcessors.push(new BatchSpanProcessor(exporter));\n // TODO: fix me, transitive initializes logger\n spanProcessors.push(new GitOperationSpanProcessor());\n }\n\n const env = process.env; // don't use getEnv() here to avoid circular dependency with env variables used in the resource detectors\n const baseResource = resourceFromAttributes({\n // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#semantic-attributes-with-sdk-provided-default-value\n [ATTR_SERVICE_NAME]: env.OTEL_SERVICE_NAME ?? 'renovate',\n // https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n // https://github.com/open-telemetry/opentelemetry-js/blob/e9d3c71918635d490b6a9ac9f8259265b38394d0/semantic-conventions/src/experimental_attributes.ts#L7688\n ['service.namespace']: env.OTEL_SERVICE_NAMESPACE ?? 'renovatebot.com',\n [ATTR_SERVICE_VERSION]: env.OTEL_SERVICE_VERSION ?? pkg.version,\n });\n\n const detectedResource = detectResources({\n detectors: [\n awsBeanstalkDetector,\n awsEc2Detector,\n awsEcsDetector,\n awsEksDetector,\n awsLambdaDetector,\n azureAppServiceDetector,\n azureFunctionsDetector,\n azureVmDetector,\n gcpDetector,\n gitHubDetector,\n envDetector,\n ],\n });\n\n const traceProvider = new NodeTracerProvider({\n resource: baseResource.merge(detectedResource),\n spanProcessors,\n });\n\n const contextManager = new AsyncLocalStorageContextManager();\n traceProvider.register({\n contextManager,\n });\n\n instrumentations = [\n new HttpInstrumentation({\n /* v8 ignore start -- not easily testable */\n applyCustomAttributesOnSpan: (span, request, response) => {\n // ignore 404 errors when the branch protection of Github could not be found. This is expected if no rules are configured\n if (\n request instanceof ClientRequest &&\n request.host === `api.github.com` &&\n request.path.endsWith(`/protection`) &&\n response.statusCode === 404\n ) {\n span.setStatus({ code: SpanStatusCode.OK });\n }\n },\n /* v8 ignore stop -- not easily testable */\n }),\n new BunyanInstrumentation(),\n new RedisInstrumentation(),\n ];\n registerInstrumentations({\n instrumentations,\n });\n}\n\n// https://github.com/open-telemetry/opentelemetry-js-api/issues/34\n/* v8 ignore next -- not easily testable */\nexport async function shutdown(): Promise<void> {\n const traceProvider = getTracerProvider();\n if (traceProvider instanceof NodeTracerProvider) {\n await traceProvider.shutdown();\n } else if (traceProvider instanceof ProxyTracerProvider) {\n const delegateProvider = traceProvider.getDelegate();\n if (delegateProvider instanceof NodeTracerProvider) {\n await delegateProvider.shutdown();\n }\n }\n}\n\nexport function disableInstrumentations(): void {\n for (const instrumentation of instrumentations) {\n instrumentation.disable();\n }\n}\n\nexport function getTracerProvider(): TracerProvider {\n return api.trace.getTracerProvider();\n}\n\nfunction getTracer(): Tracer {\n return getTracerProvider().getTracer('renovate');\n}\n\nexport function instrument<F extends () => ReturnType<F>>(\n name: string,\n fn: F,\n): ReturnType<F>;\nexport function instrument<F extends () => ReturnType<F>>(\n name: string,\n fn: F,\n options: RenovateSpanOptions,\n): ReturnType<F>;\nexport function instrument<F extends () => ReturnType<F>>(\n name: string,\n fn: F,\n options: RenovateSpanOptions,\n context: Context,\n): ReturnType<F>;\nexport function instrument<F extends () => ReturnType<F>>(\n name: string,\n fn: F,\n options: RenovateSpanOptions = {},\n context: Context = api.context.active(),\n): ReturnType<F> {\n return getTracer().startActiveSpan(name, options, context, (span: Span) => {\n try {\n const ret = fn();\n if (isPromise(ret)) {\n return ret\n .catch((e) => {\n span.recordException(e);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: massageThrowable(e),\n });\n throw e;\n })\n .finally(() => span.end()) as ReturnType<F>;\n }\n span.end();\n return ret;\n } catch (e) {\n span.recordException(e);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: massageThrowable(e),\n });\n span.end();\n throw e;\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoDA,IAAI,mBAAsC,EAAE;AAE5C,SAAgB,OAAa;AAC3B,KAAI,CAAC,kBAAkB,CACrB;;AAIF,KAAI,QAAQ,IAAI,eACd,KAAI,KAAK,UACP,IAAI,IAAI,mBAAmB,EAC3B,IAAI,aACF,QAAQ,IAAI,eAAe,aAAa,EAE3C;CAGH,MAAM,iBAAkC,EAAE;AAE1C,KAAI,yBAAyB,CAC3B,gBAAe,KAAK,IAAI,oBAAoB,IAAI,qBAAqB,CAAC,CAAC;AAIzE,KAAI,uBAAuB,EAAE;EAC3B,MAAM,WAAW,IAAI,mBAAmB;AACxC,iBAAe,KAAK,IAAI,mBAAmB,SAAS,CAAC;AAErD,iBAAe,KAAK,IAAI,2BAA2B,CAAC;;CAGtD,MAAM,MAAM,QAAQ;CACpB,MAAM,eAAe,uBAAuB;GAEzC,oBAAoB,IAAI,qBAAqB;GAG7C,sBAAsB,IAAI,0BAA0B;GACpD,uBAAuB,IAAI,wBAAwB,IAAI;EACzD,CAAC;CAEF,MAAM,mBAAmB,gBAAgB,EACvC,WAAW;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,EACF,CAAC;CAEF,MAAM,gBAAgB,IAAI,mBAAmB;EAC3C,UAAU,aAAa,MAAM,iBAAiB;EAC9C;EACD,CAAC;CAEF,MAAM,iBAAiB,IAAI,iCAAiC;AAC5D,eAAc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,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { require_punycode } from "./punycode.js";
|
|
3
|
-
import { logger } from "./logger/index.js";
|
|
4
|
-
import { bootstrap } from "./proxy.js";
|
|
5
|
-
import { instrument, shutdown } from "./instrumentation/index.js";
|
|
6
|
-
import { start } from "./workers/global/index.js";
|
|
7
3
|
import "source-map-support/register.js";
|
|
8
4
|
|
|
9
5
|
//#region lib/renovate.ts
|
|
10
6
|
var import_punycode = require_punycode();
|
|
11
|
-
/* v8 ignore next 3 -- not easily testable */
|
|
12
|
-
process.on("unhandledRejection", (err) => {
|
|
13
|
-
logger.error({ err }, "unhandledRejection");
|
|
14
|
-
});
|
|
15
|
-
bootstrap();
|
|
16
7
|
(async () => {
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
const otel = await import("./instrumentation/index.js");
|
|
9
|
+
otel.init();
|
|
10
|
+
(await import("./proxy.js")).bootstrap();
|
|
11
|
+
const { logger } = await import("./logger/index.js");
|
|
12
|
+
const { start } = await import("./workers/global/index.js");
|
|
13
|
+
/* v8 ignore next 3 -- not easily testable */
|
|
14
|
+
process.on("unhandledRejection", (err) => {
|
|
15
|
+
logger.error({ err }, "unhandledRejection");
|
|
16
|
+
});
|
|
17
|
+
process.exitCode = await otel.instrument("run", start);
|
|
18
|
+
await otel.shutdown();
|
|
19
19
|
/* v8 ignore next 3 -- no test required */
|
|
20
20
|
if (process.env.RENOVATE_X_HARD_EXIT) process.exit(process.exitCode);
|
|
21
21
|
})();
|
package/dist/renovate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renovate.js","names":[
|
|
1
|
+
{"version":3,"file":"renovate.js","names":[],"sources":["../lib/renovate.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport 'source-map-support/register.js';\nimport './punycode.cjs';\n\nvoid (async (): Promise<void> => {\n // has to be imported before logger and other libraries which are instrumentalised\n const otel = await import('./instrumentation/index.ts');\n otel.init();\n (await import('./proxy.ts')).bootstrap();\n const { logger } = await import('./logger/index.ts');\n const { start } = await import('./workers/global/index.ts');\n /* v8 ignore next 3 -- not easily testable */\n process.on('unhandledRejection', (err) => {\n logger.error({ err }, 'unhandledRejection');\n });\n process.exitCode = await otel.instrument('run', start);\n await otel.shutdown(); //gracefully shutdown OpenTelemetry\n\n /* v8 ignore next 3 -- no test required */\n if (process.env.RENOVATE_X_HARD_EXIT) {\n process.exit(process.exitCode);\n }\n})();\n"],"mappings":";;;;;;CAKM,YAA2B;CAE/B,MAAM,OAAO,MAAM,OAAO;AAC1B,MAAK,MAAM;AACX,EAAC,MAAM,OAAO,eAAe,WAAW;CACxC,MAAM,EAAE,WAAW,MAAM,OAAO;CAChC,MAAM,EAAE,UAAU,MAAM,OAAO;;AAE/B,SAAQ,GAAG,uBAAuB,QAAQ;AACxC,SAAO,MAAM,EAAE,KAAK,EAAE,qBAAqB;GAC3C;AACF,SAAQ,WAAW,MAAM,KAAK,WAAW,OAAO,MAAM;AACtD,OAAM,KAAK,UAAU;;AAGrB,KAAI,QAAQ,IAAI,qBACd,SAAQ,KAAK,QAAQ,SAAS;IAE9B"}
|
|
@@ -3,7 +3,7 @@ import { getEnv } from "../../env.js";
|
|
|
3
3
|
import { PackageCacheStats } from "../../stats.js";
|
|
4
4
|
import { cleanup as cleanup$1, get as get$2, init as init$1, set as set$2 } from "./file.js";
|
|
5
5
|
import { getCombinedKey } from "./key.js";
|
|
6
|
-
import {
|
|
6
|
+
import { destroy, get as get$3, init as init$2, set as set$3 } from "./redis.js";
|
|
7
7
|
import { SqlitePackageCache } from "./sqlite.js";
|
|
8
8
|
import { getTtlOverride } from "./ttl.js";
|
|
9
9
|
|
|
@@ -71,7 +71,7 @@ async function init(config) {
|
|
|
71
71
|
}
|
|
72
72
|
async function cleanup(config) {
|
|
73
73
|
cacheType = void 0;
|
|
74
|
-
if (config?.redisUrl)
|
|
74
|
+
if (config?.redisUrl) destroy();
|
|
75
75
|
if (cacheProxy?.cleanup) await cacheProxy.cleanup();
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["memCache.get","redisCache.init","redisCache.get","redisCache.set","fileCache.get","fileCache.set","fileCache.cleanup"
|
|
1
|
+
{"version":3,"file":"index.js","names":["memCache.get","redisCache.init","redisCache.get","redisCache.set","fileCache.get","fileCache.set","fileCache.cleanup"],"sources":["../../../../lib/util/cache/package/index.ts"],"sourcesContent":["import type { AllConfig } from '../../../config/types.ts';\nimport { getEnv } from '../../env.ts';\nimport { PackageCacheStats } from '../../stats.ts';\nimport * as memCache from '../memory/index.ts';\nimport * as fileCache from './file.ts';\nimport { getCombinedKey } from './key.ts';\nimport * as redisCache from './redis.ts';\nimport { SqlitePackageCache } from './sqlite.ts';\nimport { getTtlOverride } from './ttl.ts';\nimport type { PackageCache, PackageCacheNamespace } from './types.ts';\n\nlet cacheProxy: PackageCache | undefined;\n\nlet cacheType: 'redis' | 'sqlite' | 'memory' | 'file' | undefined;\n\n/* v8 ignore next -- not important */\nexport function getCacheType(): typeof cacheType {\n return cacheType;\n}\n\nexport async function get<T = any>(\n namespace: PackageCacheNamespace,\n key: string,\n): Promise<T | undefined> {\n if (!cacheProxy) {\n return undefined;\n }\n\n const combinedKey = getCombinedKey(namespace, key);\n let p = memCache.get(combinedKey);\n if (!p) {\n p = PackageCacheStats.wrapGet(() =>\n cacheProxy!.get<number[]>(namespace, key),\n );\n memCache.set(combinedKey, p);\n }\n\n const result = await p;\n return result;\n}\n\n/**\n * Set cache value with user-defined TTL overrides.\n */\nexport async function set(\n namespace: PackageCacheNamespace,\n key: string,\n value: unknown,\n hardTtlMinutes: number,\n): Promise<void> {\n const rawTtl = getTtlOverride(namespace) ?? hardTtlMinutes;\n await setWithRawTtl(namespace, key, value, rawTtl);\n}\n\n/**\n * Set cache value ignoring user-defined TTL overrides.\n * This MUST NOT be used outside of cache implementation\n */\nexport async function setWithRawTtl(\n namespace: PackageCacheNamespace,\n key: string,\n value: unknown,\n hardTtlMinutes: number,\n): Promise<void> {\n if (!cacheProxy) {\n return;\n }\n\n await PackageCacheStats.wrapSet(() =>\n cacheProxy!.set(namespace, key, value, hardTtlMinutes),\n );\n\n const combinedKey = getCombinedKey(namespace, key);\n const p = Promise.resolve(value);\n memCache.set(combinedKey, p);\n}\n\nexport async function init(config: AllConfig): Promise<void> {\n cacheType = undefined;\n\n if (config.redisUrl) {\n await redisCache.init(config.redisUrl, config.redisPrefix);\n cacheProxy = {\n get: redisCache.get,\n set: redisCache.set,\n };\n cacheType = 'redis';\n return;\n }\n\n if (getEnv().RENOVATE_X_SQLITE_PACKAGE_CACHE) {\n cacheProxy = await SqlitePackageCache.init(config.cacheDir!);\n cacheType = 'sqlite';\n return;\n }\n\n // v8 ignore else -- TODO: add test #40625\n if (config.cacheDir) {\n fileCache.init(config.cacheDir);\n cacheProxy = {\n get: fileCache.get,\n set: fileCache.set,\n cleanup: fileCache.cleanup,\n };\n cacheType = 'file';\n return;\n }\n}\n\nexport async function cleanup(config: AllConfig): Promise<void> {\n cacheType = undefined;\n if (config?.redisUrl) {\n redisCache.destroy();\n }\n if (cacheProxy?.cleanup) {\n await cacheProxy.cleanup();\n }\n}\n"],"mappings":";;;;;;;;;;AAWA,IAAI;AAEJ,IAAI;;AAGJ,SAAgB,eAAiC;AAC/C,QAAO;;AAGT,eAAsB,IACpB,WACA,KACwB;AACxB,KAAI,CAAC,WACH;CAGF,MAAM,cAAc,eAAe,WAAW,IAAI;CAClD,IAAI,IAAIA,MAAa,YAAY;AACjC,KAAI,CAAC,GAAG;AACN,MAAI,kBAAkB,cACpB,WAAY,IAAc,WAAW,IAAI,CAC1C;AACD,QAAa,aAAa,EAAE;;AAI9B,QADe,MAAM;;;;;AAOvB,eAAsB,IACpB,WACA,KACA,OACA,gBACe;AAEf,OAAM,cAAc,WAAW,KAAK,OADrB,eAAe,UAAU,IAAI,eACM;;;;;;AAOpD,eAAsB,cACpB,WACA,KACA,OACA,gBACe;AACf,KAAI,CAAC,WACH;AAGF,OAAM,kBAAkB,cACtB,WAAY,IAAI,WAAW,KAAK,OAAO,eAAe,CACvD;CAED,MAAM,cAAc,eAAe,WAAW,IAAI;CAClD,MAAM,IAAI,QAAQ,QAAQ,MAAM;AAChC,OAAa,aAAa,EAAE;;AAG9B,eAAsB,KAAK,QAAkC;AAC3D,aAAY;AAEZ,KAAI,OAAO,UAAU;AACnB,QAAMC,OAAgB,OAAO,UAAU,OAAO,YAAY;AAC1D,eAAa;GACX,KAAKC;GACL,KAAKC;GACN;AACD,cAAY;AACZ;;AAGF,KAAI,QAAQ,CAAC,iCAAiC;AAC5C,eAAa,MAAM,mBAAmB,KAAK,OAAO,SAAU;AAC5D,cAAY;AACZ;;;AAIF,KAAI,OAAO,UAAU;AACnB,SAAe,OAAO,SAAS;AAC/B,eAAa;GACX,KAAKC;GACL,KAAKC;GACL,SAASC;GACV;AACD,cAAY;AACZ;;;AAIJ,eAAsB,QAAQ,QAAkC;AAC9D,aAAY;AACZ,KAAI,QAAQ,SACV,UAAoB;AAEtB,KAAI,YAAY,QACd,OAAM,WAAW,SAAS"}
|
|
@@ -2,10 +2,10 @@ import { PackageCacheNamespace } from "./namespaces.js";
|
|
|
2
2
|
|
|
3
3
|
//#region lib/util/cache/package/redis.d.ts
|
|
4
4
|
declare function normalizeRedisUrl(url: string): string;
|
|
5
|
-
declare function
|
|
5
|
+
declare function destroy(): void;
|
|
6
6
|
declare function get<T = never>(namespace: PackageCacheNamespace, key: string): Promise<T | undefined>;
|
|
7
7
|
declare function set(namespace: PackageCacheNamespace, key: string, value: unknown, hardTtlMinutes?: number): Promise<void>;
|
|
8
8
|
declare function init(url: string, prefix: string | undefined): Promise<void>;
|
|
9
9
|
//#endregion
|
|
10
|
-
export {
|
|
10
|
+
export { destroy, get, init, normalizeRedisUrl, set };
|
|
11
11
|
//# sourceMappingURL=redis.d.ts.map
|
|
@@ -13,11 +13,12 @@ function getKey(namespace, key) {
|
|
|
13
13
|
function normalizeRedisUrl(url) {
|
|
14
14
|
return url.replace(regEx(/^(rediss?)\+cluster:\/\//), "$1://");
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
function destroy() {
|
|
17
17
|
try {
|
|
18
|
-
|
|
18
|
+
client?.destroy();
|
|
19
|
+
client = void 0;
|
|
19
20
|
} catch (err) {
|
|
20
|
-
logger.warn({ err }, "Redis cache
|
|
21
|
+
logger.warn({ err }, "Redis cache destroy failed");
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
async function rm(namespace, key) {
|
|
@@ -103,5 +104,5 @@ async function init(url, prefix) {
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
//#endregion
|
|
106
|
-
export {
|
|
107
|
+
export { destroy, get, init, normalizeRedisUrl, set };
|
|
107
108
|
//# sourceMappingURL=redis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.js","names":[],"sources":["../../../../lib/util/cache/package/redis.ts"],"sourcesContent":["import type { RedisClusterOptions } from '@redis/client';\nimport { createClient, createCluster } from '@redis/client';\nimport { DateTime } from 'luxon';\nimport { logger } from '../../../logger/index.ts';\nimport { compressToBase64, decompressFromBase64 } from '../../compress.ts';\nimport { regEx } from '../../regex.ts';\nimport type { PackageCacheNamespace } from './types.ts';\n\nlet client:\n | ReturnType<typeof createClient>\n | ReturnType<typeof createCluster>\n | undefined;\nlet rprefix: string | undefined;\n\nfunction getKey(namespace: PackageCacheNamespace, key: string): string {\n return `${rprefix}${namespace}-${key}`;\n}\n\nexport function normalizeRedisUrl(url: string): string {\n return url.replace(regEx(/^(rediss?)\\+cluster:\\/\\//), '$1://');\n}\n\nexport
|
|
1
|
+
{"version":3,"file":"redis.js","names":[],"sources":["../../../../lib/util/cache/package/redis.ts"],"sourcesContent":["import type { RedisClusterOptions } from '@redis/client';\nimport { createClient, createCluster } from '@redis/client';\nimport { DateTime } from 'luxon';\nimport { logger } from '../../../logger/index.ts';\nimport { compressToBase64, decompressFromBase64 } from '../../compress.ts';\nimport { regEx } from '../../regex.ts';\nimport type { PackageCacheNamespace } from './types.ts';\n\nlet client:\n | ReturnType<typeof createClient>\n | ReturnType<typeof createCluster>\n | undefined;\nlet rprefix: string | undefined;\n\nfunction getKey(namespace: PackageCacheNamespace, key: string): string {\n return `${rprefix}${namespace}-${key}`;\n}\n\nexport function normalizeRedisUrl(url: string): string {\n return url.replace(regEx(/^(rediss?)\\+cluster:\\/\\//), '$1://');\n}\n\nexport function destroy(): void {\n try {\n // https://github.com/redis/node-redis#disconnecting\n client?.destroy();\n client = undefined;\n } catch (err) {\n logger.warn({ err }, 'Redis cache destroy failed');\n }\n}\n\nasync function rm(\n namespace: PackageCacheNamespace,\n key: string,\n): Promise<void> {\n logger.trace({ rprefix, namespace, key }, 'Removing cache entry');\n await client?.del(getKey(namespace, key));\n}\n\nexport async function get<T = never>(\n namespace: PackageCacheNamespace,\n key: string,\n): Promise<T | undefined> {\n if (!client) {\n return undefined;\n }\n logger.trace(`cache.get(${namespace}, ${key})`);\n try {\n const res = await client?.get(getKey(namespace, key));\n const cachedValue = res && JSON.parse(res);\n if (cachedValue) {\n if (DateTime.local() < DateTime.fromISO(cachedValue.expiry)) {\n logger.trace({ rprefix, namespace, key }, 'Returning cached value');\n // istanbul ignore if\n if (!cachedValue.compress) {\n return cachedValue.value;\n }\n const res = await decompressFromBase64(cachedValue.value);\n return JSON.parse(res);\n }\n // istanbul ignore next\n await rm(namespace, key);\n }\n } catch {\n logger.trace({ rprefix, namespace, key }, 'Cache miss');\n }\n return undefined;\n}\n\nexport async function set(\n namespace: PackageCacheNamespace,\n key: string,\n value: unknown,\n hardTtlMinutes = 5,\n): Promise<void> {\n logger.trace(\n { rprefix, namespace, key, hardTtlMinutes },\n 'Saving cached value',\n );\n\n // Redis requires TTL to be integer, not float\n const redisTTL = Math.floor(hardTtlMinutes * 60);\n\n try {\n await client?.set(\n getKey(namespace, key),\n JSON.stringify({\n compress: true,\n value: await compressToBase64(JSON.stringify(value)),\n expiry: DateTime.local().plus({ minutes: hardTtlMinutes }),\n }),\n { EX: redisTTL },\n );\n } catch (err) {\n logger.once.warn({ err }, 'Error while setting Redis cache value');\n }\n}\n\nexport async function init(\n url: string,\n prefix: string | undefined,\n): Promise<void> {\n if (!url) {\n return;\n }\n rprefix = prefix ?? '';\n logger.debug('Redis cache init');\n\n const rewrittenUrl = normalizeRedisUrl(url);\n // If any replacement was made, it means the regex matched and we are in clustered mode\n const clusteredMode = rewrittenUrl.length !== url.length;\n\n const config = {\n url: rewrittenUrl,\n socket: {\n reconnectStrategy: (retries: number) => {\n // Reconnect after this time\n return Math.min(retries * 100, 3000);\n },\n },\n pingInterval: 30000, // 30s\n };\n if (clusteredMode) {\n const clusterConfig: RedisClusterOptions = { rootNodes: [config] };\n\n // only add defaults if username or password are present in the URL\n const parsedUrl = new URL(rewrittenUrl);\n if (parsedUrl.username) {\n clusterConfig.defaults = {\n username: parsedUrl.username,\n };\n }\n\n if (parsedUrl.password) {\n clusterConfig.defaults ??= {};\n clusterConfig.defaults.password = parsedUrl.password;\n }\n\n client = createCluster(clusterConfig);\n } else {\n client = createClient(config);\n }\n await client.connect();\n logger.debug('Redis cache connected');\n}\n"],"mappings":";;;;;;;AAQA,IAAI;AAIJ,IAAI;AAEJ,SAAS,OAAO,WAAkC,KAAqB;AACrE,QAAO,GAAG,UAAU,UAAU,GAAG;;AAGnC,SAAgB,kBAAkB,KAAqB;AACrD,QAAO,IAAI,QAAQ,MAAM,2BAA2B,EAAE,QAAQ;;AAGhE,SAAgB,UAAgB;AAC9B,KAAI;AAEF,UAAQ,SAAS;AACjB,WAAS;UACF,KAAK;AACZ,SAAO,KAAK,EAAE,KAAK,EAAE,6BAA6B;;;AAItD,eAAe,GACb,WACA,KACe;AACf,QAAO,MAAM;EAAE;EAAS;EAAW;EAAK,EAAE,uBAAuB;AACjE,OAAM,QAAQ,IAAI,OAAO,WAAW,IAAI,CAAC;;AAG3C,eAAsB,IACpB,WACA,KACwB;AACx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O,KAAK,IAAI,UAAU,KAAK,IAAK;KAEvC;EACD,cAAc;EACf;AACD,KAAI,eAAe;EACjB,MAAM,gBAAqC,EAAE,WAAW,CAAC,OAAO,EAAE;EAGlE,MAAM,YAAY,IAAI,IAAI,aAAa;AACvC,MAAI,UAAU,SACZ,eAAc,WAAW,EACvB,UAAU,UAAU,UACrB;AAGH,MAAI,UAAU,UAAU;AACtB,iBAAc,aAAa,EAAE;AAC7B,iBAAc,SAAS,WAAW,UAAU;;AAG9C,WAAS,cAAc,cAAc;OAErC,UAAS,aAAa,OAAO;AAE/B,OAAM,OAAO,SAAS;AACtB,QAAO,MAAM,wBAAwB"}
|
|
@@ -15,10 +15,10 @@ import { mergeChildConfig } from "../../config/utils.js";
|
|
|
15
15
|
import { resolveConfigPresets } from "../../config/presets/index.js";
|
|
16
16
|
import { validateConfigSecretsAndVariables } from "../../config/secrets.js";
|
|
17
17
|
import { parseConfigs } from "./config/parse/index.js";
|
|
18
|
+
import { autodiscoverRepositories } from "./autodiscover.js";
|
|
18
19
|
import { filterConfig } from "../../config/index.js";
|
|
19
20
|
import { exportStats, finalizeReport } from "../../instrumentation/reporting.js";
|
|
20
21
|
import { renovateRepository } from "../repository/index.js";
|
|
21
|
-
import { autodiscoverRepositories } from "./autodiscover.js";
|
|
22
22
|
import { globalFinalize, globalInitialize } from "./initialize.js";
|
|
23
23
|
import fs from "fs-extra";
|
|
24
24
|
import { isNonEmptyString, isNonEmptyStringAndNotWhitespace, isString } from "@sindresorhus/is";
|
|
@@ -13,6 +13,7 @@ import { instrument } from "../../instrumentation/index.js";
|
|
|
13
13
|
import { removeDanglingContainers } from "../../util/exec/docker/index.js";
|
|
14
14
|
import { isCloned } from "../../util/git/index.js";
|
|
15
15
|
import { applySecretsAndVariablesToConfig } from "../../config/secrets.js";
|
|
16
|
+
import { processResult } from "./result.js";
|
|
16
17
|
import { addExtractionStats } from "../../instrumentation/reporting.js";
|
|
17
18
|
import { detectSemanticCommits } from "../../util/git/semantic.js";
|
|
18
19
|
import { addSplit, getSplits, splitInit } from "../../util/split.js";
|
|
@@ -27,7 +28,6 @@ import { pruneStaleBranches } from "./finalize/prune.js";
|
|
|
27
28
|
import { finalizeRepo } from "./finalize/index.js";
|
|
28
29
|
import { initRepo } from "./init/index.js";
|
|
29
30
|
import { ensureOnboardingPr } from "./onboarding/pr/index.js";
|
|
30
|
-
import { processResult } from "./result.js";
|
|
31
31
|
import fs from "fs-extra";
|
|
32
32
|
|
|
33
33
|
//#region lib/workers/repository/index.ts
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "renovate",
|
|
3
3
|
"description": "Automated dependency updates. Flexible so you don't need to be.",
|
|
4
|
-
"version": "43.31.
|
|
4
|
+
"version": "43.31.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"renovate": "dist/renovate.js",
|
|
@@ -105,12 +105,12 @@
|
|
|
105
105
|
"@opentelemetry/context-async-hooks": "2.5.1",
|
|
106
106
|
"@opentelemetry/exporter-trace-otlp-http": "0.212.0",
|
|
107
107
|
"@opentelemetry/instrumentation": "0.212.0",
|
|
108
|
-
"@opentelemetry/instrumentation-bunyan": "0.
|
|
108
|
+
"@opentelemetry/instrumentation-bunyan": "0.57.0",
|
|
109
109
|
"@opentelemetry/instrumentation-http": "0.212.0",
|
|
110
|
-
"@opentelemetry/instrumentation-redis": "0.
|
|
111
|
-
"@opentelemetry/resource-detector-aws": "2.
|
|
112
|
-
"@opentelemetry/resource-detector-azure": "0.
|
|
113
|
-
"@opentelemetry/resource-detector-gcp": "0.
|
|
110
|
+
"@opentelemetry/instrumentation-redis": "0.60.0",
|
|
111
|
+
"@opentelemetry/resource-detector-aws": "2.12.0",
|
|
112
|
+
"@opentelemetry/resource-detector-azure": "0.20.0",
|
|
113
|
+
"@opentelemetry/resource-detector-gcp": "0.47.0",
|
|
114
114
|
"@opentelemetry/resource-detector-github": "0.32.0",
|
|
115
115
|
"@opentelemetry/resources": "2.5.1",
|
|
116
116
|
"@opentelemetry/sdk-trace-base": "2.5.1",
|
package/renovate-schema.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"title": "JSON schema for Renovate 43.31.
|
|
2
|
+
"title": "JSON schema for Renovate 43.31.4 config files (https://renovatebot.com/)",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
-
"x-renovate-version": "43.31.
|
|
4
|
+
"x-renovate-version": "43.31.4",
|
|
5
5
|
"allowComments": true,
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|