renovate 39.240.1 → 39.241.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/util/git/auth.js +1 -1
- package/dist/util/git/auth.js.map +1 -1
- package/dist/util/git/url.js +1 -1
- package/dist/util/git/url.js.map +1 -1
- package/dist/util/string.d.ts +1 -0
- package/dist/util/string.js +4 -0
- package/dist/util/string.js.map +1 -1
- package/dist/workers/global/index.js +4 -2
- package/dist/workers/global/index.js.map +1 -1
- package/package.json +7 -7
package/dist/util/git/auth.js
CHANGED
@@ -97,7 +97,7 @@ function getAuthenticationRules(gitUrl, hostType, token) {
|
|
97
97
|
if (!sshPort || is_1.default.emptyString(sshPort)) {
|
98
98
|
// By default, bitbucket-server SSH port is 7999.
|
99
99
|
// For non-default port, the generated auth config will likely be incorrect.
|
100
|
-
sshPort = 7999;
|
100
|
+
sshPort = '7999';
|
101
101
|
}
|
102
102
|
}
|
103
103
|
const url = { ...insteadUrl };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../lib/util/git/auth.ts"],"names":[],"mappings":";;AAsBA,0FAgEC;AAuBD,wDAyDC;AAED,gEAyCC;;AAjND,kEAAkC;AAClC,yDAAgE;AAChE,yCAAsC;AAEtC,sCAA2C;AAC3C,8CAA6C;AAC7C,oCAAiC;AACjC,gCAA2D;AAE3D,+BAAoC;AAEpC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,YAAY;IACZ,gBAAgB;IAChB,wBAAwB;IACxB,yBAAyB;CAC1B,CAAC,CAAC;AAEH;;;GAGG;AACH,SAAgB,uCAAuC,CACrD,cAAsB,EACtB,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAY,EAC5D,oBAAwC;IAExC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,EAAE,CAAC;QACtC,eAA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B,CAC1B,QAAkB,EAClB,GAAsB;IAEtB,IAAI,oBAAoB,GAAG,GAAG,CAAC;IAC/B,MAAM,OAAO,GAAG,IAAA,4BAAsB,EAAC,QAAQ,CAAC,SAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;IACxE,IAAI,IAAA,eAAS,EAAC,OAAO,CAAC,EAAE,CAAC;QACvB,eAAM,CAAC,KAAK,CAAC,iCAAiC,OAAO,oBAAoB,CAAC,CAAC;QAC3E,oBAAoB,GAAG,uCAAuC,CAC5D,OAAQ,EACR,QAAQ,EACR,oBAAoB,CACrB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,eAAM,CAAC,KAAK,CACV,+BAA+B,QAAQ,CAAC,SAAU,iCAAiC,CACpF,CAAC;IACJ,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC","sourcesContent":["import is from '@sindresorhus/is';\nimport { PLATFORM_HOST_TYPES } from '../../constants/platforms';\nimport { logger } from '../../logger';\nimport type { HostRule } from '../../types';\nimport { detectPlatform } from '../common';\nimport { find, getAll } from '../host-rules';\nimport { regEx } from '../regex';\nimport { createURLFromHostOrURL, isHttpUrl } from '../url';\nimport type { AuthenticationRule } from './types';\nimport { parseGitUrl } from './url';\n\nconst githubApiUrls = new Set([\n 'github.com',\n 'api.github.com',\n 'https://api.github.com',\n 'https://api.github.com/',\n]);\n\n/**\n * Add authorization to a Git Url and returns a new environment variables object\n * @returns a new NodeJS.ProcessEnv object without modifying any input parameters\n */\nexport function getGitAuthenticatedEnvironmentVariables(\n originalGitUrl: string,\n { token, username, password, hostType, matchHost }: HostRule,\n environmentVariables?: NodeJS.ProcessEnv,\n): NodeJS.ProcessEnv {\n if (!token && !(username && password)) {\n logger.warn(\n { host: matchHost },\n `Could not create environment variable for host as neither token or username and password was set`,\n );\n return { ...environmentVariables };\n }\n\n // check if the environmentVariables already contain a GIT_CONFIG_COUNT or if the process has one\n const gitConfigCountEnvVariable =\n environmentVariables?.GIT_CONFIG_COUNT ?? process.env.GIT_CONFIG_COUNT;\n let gitConfigCount = 0;\n if (gitConfigCountEnvVariable) {\n // passthrough the gitConfigCountEnvVariable environment variable as start value of the index count\n gitConfigCount = parseInt(gitConfigCountEnvVariable, 10);\n if (Number.isNaN(gitConfigCount)) {\n logger.warn(\n {\n GIT_CONFIG_COUNT: process.env.GIT_CONFIG_COUNT,\n },\n `Found GIT_CONFIG_COUNT env variable, but couldn't parse the value to an integer. Ignoring it.`,\n );\n gitConfigCount = 0;\n }\n }\n let authenticationRules: AuthenticationRule[];\n if (token) {\n authenticationRules = getAuthenticationRulesWithToken(\n originalGitUrl,\n hostType,\n token,\n );\n } else {\n const encodedUsername = encodeURIComponent(username!);\n const encodedPassword = encodeURIComponent(password!);\n\n authenticationRules = getAuthenticationRules(\n originalGitUrl,\n hostType,\n `${encodedUsername}:${encodedPassword}`,\n );\n }\n\n // create a shallow copy of the environmentVariables as base so we don't modify the input parameter object\n // add the two new config key and value to the returnEnvironmentVariables object\n // increase the CONFIG_COUNT by one for each rule and add it to the object\n const newEnvironmentVariables = {\n ...environmentVariables,\n };\n for (const rule of authenticationRules) {\n newEnvironmentVariables[`GIT_CONFIG_KEY_${gitConfigCount}`] =\n `url.${rule.url}.insteadOf`;\n newEnvironmentVariables[`GIT_CONFIG_VALUE_${gitConfigCount}`] =\n rule.insteadOf;\n gitConfigCount++;\n }\n newEnvironmentVariables.GIT_CONFIG_COUNT = gitConfigCount.toString();\n\n return newEnvironmentVariables;\n}\n\nfunction getAuthenticationRulesWithToken(\n url: string,\n hostType: string | undefined | null,\n authToken: string,\n): AuthenticationRule[] {\n let token = authToken;\n let type = hostType;\n type ??= detectPlatform(url);\n if (type === 'gitlab') {\n token = `gitlab-ci-token:${authToken}`;\n }\n return getAuthenticationRules(url, type, token);\n}\n\n/**\n * Generates the authentication rules for later git usage for the given host\n * @link https://coolaj86.com/articles/vanilla-devops-git-credentials-cheatsheet/\n * @param gitUrl Git repository URL\n * @param hostType Git host type\n * @param token Authentication token or `username:password` string\n */\nexport function getAuthenticationRules(\n gitUrl: string,\n hostType: string | undefined | null,\n token: string,\n): AuthenticationRule[] {\n const authenticationRules = [];\n const hasUser = token.split(':').length > 1;\n const insteadUrl = parseGitUrl(gitUrl);\n let sshPort = insteadUrl.port;\n\n if (hostType === 'bitbucket-server') {\n // For Bitbucket Server/Data Center, `source` must be `bitbucket-server`\n // to generate HTTP(s) URLs correctly.\n // https://github.com/IonicaBizau/git-url-parse/blob/28828546c148d58bbcff61409915a4e1e8f7eb11/lib/index.js#L304\n insteadUrl.source = 'bitbucket-server';\n\n // sshPort is string, wrong type!\n // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/72361\n // https://github.com/IonicaBizau/parse-path/blob/87f71f273da90f85f6845937a70b7c032eeae4e3/lib/index.js#L45\n if (!sshPort || is.emptyString(sshPort)) {\n // By default, bitbucket-server SSH port is 7999.\n // For non-default port, the generated auth config will likely be incorrect.\n sshPort = 7999;\n }\n }\n\n const url = { ...insteadUrl };\n const protocol = regEx(/^https?$/).test(url.protocol)\n ? url.protocol\n : 'https';\n\n // ssh protocol with user if empty\n url.token = hasUser ? token : `ssh:${token}`;\n authenticationRules.push({\n url: url.toString(protocol),\n // only edge case, need to stringify ourself because the exact syntax is not supported by the library\n // https://github.com/IonicaBizau/git-url-parse/blob/246c9119fb42c2ea1c280028fe77c53eb34c190c/lib/index.js#L246\n insteadOf: `ssh://git@${insteadUrl.resource}${\n sshPort ? `:${sshPort}` : ''\n }/${insteadUrl.full_name}${insteadUrl.git_suffix ? '.git' : ''}`,\n });\n\n // alternative ssh protocol with user if empty\n url.token = hasUser ? token : `git:${token}`;\n authenticationRules.push({\n url: url.toString(protocol),\n insteadOf: { ...insteadUrl, port: sshPort }.toString('ssh'),\n });\n\n // https protocol with no user as default fallback\n url.token = token;\n authenticationRules.push({\n url: url.toString(protocol),\n insteadOf: insteadUrl.toString(protocol),\n });\n\n return authenticationRules;\n}\n\nexport function getGitEnvironmentVariables(\n additionalHostTypes: string[] = [],\n): NodeJS.ProcessEnv {\n let environmentVariables: NodeJS.ProcessEnv = {};\n\n // hard-coded logic to use authentication for github.com based on the githubToken for api.github.com\n const gitHubHostRule = find({\n hostType: 'github',\n url: 'https://api.github.com/',\n });\n\n if (gitHubHostRule?.token) {\n environmentVariables = getGitAuthenticatedEnvironmentVariables(\n 'https://github.com/',\n gitHubHostRule,\n );\n }\n\n // construct the Set of allowed hostTypes consisting of the standard Git provides\n // plus additionalHostTypes, which are provided as parameter\n const gitAllowedHostTypes = new Set<string>([\n ...PLATFORM_HOST_TYPES,\n ...additionalHostTypes,\n ]);\n\n // filter rules without `matchHost` and `token` or username and password and github api github rules\n const hostRules = getAll()\n .filter((r) => r.matchHost && (r.token ?? (r.username && r.password)))\n .filter((r) => !gitHubHostRule || !githubApiUrls.has(r.matchHost!));\n\n // for each hostRule without hostType we add additional authentication variables to the environmentVariables\n // for each hostRule with hostType we add additional authentication variables to the environmentVariables\n for (const hostRule of hostRules) {\n if (!hostRule.hostType || gitAllowedHostTypes.has(hostRule.hostType)) {\n environmentVariables = addAuthFromHostRule(\n hostRule,\n environmentVariables,\n );\n }\n }\n return environmentVariables;\n}\n\nfunction addAuthFromHostRule(\n hostRule: HostRule,\n env: NodeJS.ProcessEnv,\n): NodeJS.ProcessEnv {\n let environmentVariables = env;\n const httpUrl = createURLFromHostOrURL(hostRule.matchHost!)?.toString();\n if (isHttpUrl(httpUrl)) {\n logger.trace(`Adding Git authentication for ${httpUrl} using token auth.`);\n environmentVariables = getGitAuthenticatedEnvironmentVariables(\n httpUrl!,\n hostRule,\n environmentVariables,\n );\n } else {\n logger.debug(\n `Could not parse registryUrl ${hostRule.matchHost!} or not using http(s). Ignoring`,\n );\n }\n return environmentVariables;\n}\n"]}
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../lib/util/git/auth.ts"],"names":[],"mappings":";;AAsBA,0FAgEC;AAuBD,wDAyDC;AAED,gEAyCC;;AAjND,kEAAkC;AAClC,yDAA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CAAC,EAAE,EAAE,CAAC,CAAC,cAAc,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,SAAU,CAAC,CAAC,CAAC;IAEtE,4GAA4G;IAC5G,yGAAyG;IACzG,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,QAAQ,CAAC,QAAQ,IAAI,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrE,oBAAoB,GAAG,mBAAmB,CACxC,QAAQ,EACR,oBAAoB,CACrB,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED,SAAS,mBAAmB,CAC1B,QAAkB,EAClB,GAAsB;IAEtB,IAAI,oBAAoB,GAAG,GAAG,CAAC;IAC/B,MAAM,OAAO,GAAG,IAAA,4BAAsB,EAAC,QAAQ,CAAC,SAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;IACxE,IAAI,IAAA,eAAS,EAAC,OAAO,CAAC,EAAE,CAAC;QACvB,eAAM,CAAC,KAAK,CAAC,iCAAiC,OAAO,oBAAoB,CAAC,CAAC;QAC3E,oBAAoB,GAAG,uCAAuC,CAC5D,OAAQ,EACR,QAAQ,EACR,oBAAoB,CACrB,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,eAAM,CAAC,KAAK,CACV,+BAA+B,QAAQ,CAAC,SAAU,iCAAiC,CACpF,CAAC;IACJ,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC","sourcesContent":["import is from '@sindresorhus/is';\nimport { PLATFORM_HOST_TYPES } from '../../constants/platforms';\nimport { logger } from '../../logger';\nimport type { HostRule } from '../../types';\nimport { detectPlatform } from '../common';\nimport { find, getAll } from '../host-rules';\nimport { regEx } from '../regex';\nimport { createURLFromHostOrURL, isHttpUrl } from '../url';\nimport type { AuthenticationRule } from './types';\nimport { parseGitUrl } from './url';\n\nconst githubApiUrls = new Set([\n 'github.com',\n 'api.github.com',\n 'https://api.github.com',\n 'https://api.github.com/',\n]);\n\n/**\n * Add authorization to a Git Url and returns a new environment variables object\n * @returns a new NodeJS.ProcessEnv object without modifying any input parameters\n */\nexport function getGitAuthenticatedEnvironmentVariables(\n originalGitUrl: string,\n { token, username, password, hostType, matchHost }: HostRule,\n environmentVariables?: NodeJS.ProcessEnv,\n): NodeJS.ProcessEnv {\n if (!token && !(username && password)) {\n logger.warn(\n { host: matchHost },\n `Could not create environment variable for host as neither token or username and password was set`,\n );\n return { ...environmentVariables };\n }\n\n // check if the environmentVariables already contain a GIT_CONFIG_COUNT or if the process has one\n const gitConfigCountEnvVariable =\n environmentVariables?.GIT_CONFIG_COUNT ?? process.env.GIT_CONFIG_COUNT;\n let gitConfigCount = 0;\n if (gitConfigCountEnvVariable) {\n // passthrough the gitConfigCountEnvVariable environment variable as start value of the index count\n gitConfigCount = parseInt(gitConfigCountEnvVariable, 10);\n if (Number.isNaN(gitConfigCount)) {\n logger.warn(\n {\n GIT_CONFIG_COUNT: process.env.GIT_CONFIG_COUNT,\n },\n `Found GIT_CONFIG_COUNT env variable, but couldn't parse the value to an integer. Ignoring it.`,\n );\n gitConfigCount = 0;\n }\n }\n let authenticationRules: AuthenticationRule[];\n if (token) {\n authenticationRules = getAuthenticationRulesWithToken(\n originalGitUrl,\n hostType,\n token,\n );\n } else {\n const encodedUsername = encodeURIComponent(username!);\n const encodedPassword = encodeURIComponent(password!);\n\n authenticationRules = getAuthenticationRules(\n originalGitUrl,\n hostType,\n `${encodedUsername}:${encodedPassword}`,\n );\n }\n\n // create a shallow copy of the environmentVariables as base so we don't modify the input parameter object\n // add the two new config key and value to the returnEnvironmentVariables object\n // increase the CONFIG_COUNT by one for each rule and add it to the object\n const newEnvironmentVariables = {\n ...environmentVariables,\n };\n for (const rule of authenticationRules) {\n newEnvironmentVariables[`GIT_CONFIG_KEY_${gitConfigCount}`] =\n `url.${rule.url}.insteadOf`;\n newEnvironmentVariables[`GIT_CONFIG_VALUE_${gitConfigCount}`] =\n rule.insteadOf;\n gitConfigCount++;\n }\n newEnvironmentVariables.GIT_CONFIG_COUNT = gitConfigCount.toString();\n\n return newEnvironmentVariables;\n}\n\nfunction getAuthenticationRulesWithToken(\n url: string,\n hostType: string | undefined | null,\n authToken: string,\n): AuthenticationRule[] {\n let token = authToken;\n let type = hostType;\n type ??= detectPlatform(url);\n if (type === 'gitlab') {\n token = `gitlab-ci-token:${authToken}`;\n }\n return getAuthenticationRules(url, type, token);\n}\n\n/**\n * Generates the authentication rules for later git usage for the given host\n * @link https://coolaj86.com/articles/vanilla-devops-git-credentials-cheatsheet/\n * @param gitUrl Git repository URL\n * @param hostType Git host type\n * @param token Authentication token or `username:password` string\n */\nexport function getAuthenticationRules(\n gitUrl: string,\n hostType: string | undefined | null,\n token: string,\n): AuthenticationRule[] {\n const authenticationRules = [];\n const hasUser = token.split(':').length > 1;\n const insteadUrl = parseGitUrl(gitUrl);\n let sshPort = insteadUrl.port;\n\n if (hostType === 'bitbucket-server') {\n // For Bitbucket Server/Data Center, `source` must be `bitbucket-server`\n // to generate HTTP(s) URLs correctly.\n // https://github.com/IonicaBizau/git-url-parse/blob/28828546c148d58bbcff61409915a4e1e8f7eb11/lib/index.js#L304\n insteadUrl.source = 'bitbucket-server';\n\n // sshPort is string, wrong type!\n // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/72361\n // https://github.com/IonicaBizau/parse-path/blob/87f71f273da90f85f6845937a70b7c032eeae4e3/lib/index.js#L45\n if (!sshPort || is.emptyString(sshPort)) {\n // By default, bitbucket-server SSH port is 7999.\n // For non-default port, the generated auth config will likely be incorrect.\n sshPort = '7999';\n }\n }\n\n const url = { ...insteadUrl };\n const protocol = regEx(/^https?$/).test(url.protocol)\n ? url.protocol\n : 'https';\n\n // ssh protocol with user if empty\n url.token = hasUser ? token : `ssh:${token}`;\n authenticationRules.push({\n url: url.toString(protocol),\n // only edge case, need to stringify ourself because the exact syntax is not supported by the library\n // https://github.com/IonicaBizau/git-url-parse/blob/246c9119fb42c2ea1c280028fe77c53eb34c190c/lib/index.js#L246\n insteadOf: `ssh://git@${insteadUrl.resource}${\n sshPort ? `:${sshPort}` : ''\n }/${insteadUrl.full_name}${insteadUrl.git_suffix ? '.git' : ''}`,\n });\n\n // alternative ssh protocol with user if empty\n url.token = hasUser ? token : `git:${token}`;\n authenticationRules.push({\n url: url.toString(protocol),\n insteadOf: { ...insteadUrl, port: sshPort }.toString('ssh'),\n });\n\n // https protocol with no user as default fallback\n url.token = token;\n authenticationRules.push({\n url: url.toString(protocol),\n insteadOf: insteadUrl.toString(protocol),\n });\n\n return authenticationRules;\n}\n\nexport function getGitEnvironmentVariables(\n additionalHostTypes: string[] = [],\n): NodeJS.ProcessEnv {\n let environmentVariables: NodeJS.ProcessEnv = {};\n\n // hard-coded logic to use authentication for github.com based on the githubToken for api.github.com\n const gitHubHostRule = find({\n hostType: 'github',\n url: 'https://api.github.com/',\n });\n\n if (gitHubHostRule?.token) {\n environmentVariables = getGitAuthenticatedEnvironmentVariables(\n 'https://github.com/',\n gitHubHostRule,\n );\n }\n\n // construct the Set of allowed hostTypes consisting of the standard Git provides\n // plus additionalHostTypes, which are provided as parameter\n const gitAllowedHostTypes = new Set<string>([\n ...PLATFORM_HOST_TYPES,\n ...additionalHostTypes,\n ]);\n\n // filter rules without `matchHost` and `token` or username and password and github api github rules\n const hostRules = getAll()\n .filter((r) => r.matchHost && (r.token ?? (r.username && r.password)))\n .filter((r) => !gitHubHostRule || !githubApiUrls.has(r.matchHost!));\n\n // for each hostRule without hostType we add additional authentication variables to the environmentVariables\n // for each hostRule with hostType we add additional authentication variables to the environmentVariables\n for (const hostRule of hostRules) {\n if (!hostRule.hostType || gitAllowedHostTypes.has(hostRule.hostType)) {\n environmentVariables = addAuthFromHostRule(\n hostRule,\n environmentVariables,\n );\n }\n }\n return environmentVariables;\n}\n\nfunction addAuthFromHostRule(\n hostRule: HostRule,\n env: NodeJS.ProcessEnv,\n): NodeJS.ProcessEnv {\n let environmentVariables = env;\n const httpUrl = createURLFromHostOrURL(hostRule.matchHost!)?.toString();\n if (isHttpUrl(httpUrl)) {\n logger.trace(`Adding Git authentication for ${httpUrl} using token auth.`);\n environmentVariables = getGitAuthenticatedEnvironmentVariables(\n httpUrl!,\n hostRule,\n environmentVariables,\n );\n } else {\n logger.debug(\n `Could not parse registryUrl ${hostRule.matchHost!} or not using http(s). Ignoring`,\n );\n }\n return environmentVariables;\n}\n"]}
|
package/dist/util/git/url.js
CHANGED
@@ -18,7 +18,7 @@ function getHttpUrl(url, token) {
|
|
18
18
|
const origProtocol = protocol;
|
19
19
|
// Convert non-https URLs to https and strip port
|
20
20
|
if (!(0, regex_1.regEx)(/^https?$/).test(protocol)) {
|
21
|
-
parsedUrl.port = 443;
|
21
|
+
parsedUrl.port = '443';
|
22
22
|
protocol = 'https';
|
23
23
|
}
|
24
24
|
parsedUrl.user = '';
|
package/dist/util/git/url.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../../lib/util/git/url.ts"],"names":[],"mappings":";;AAMA,kCAEC;AAED,gCA0CC;AAED,sDA4BC;;AAlFD,0EAAwC;AACxC,yCAAsC;AACtC,sCAA2C;AAC3C,iEAA2C;AAC3C,oCAAiC;AAEjC,SAAgB,WAAW,CAAC,GAAW;IACrC,OAAO,IAAA,uBAAW,EAAC,GAAG,CAAC,CAAC;AAC1B,CAAC;AAED,SAAgB,UAAU,CAAC,GAAW,EAAE,KAAc;IACpD,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAEnC,IAAI,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;IAC7B,MAAM,YAAY,GAAG,QAAQ,CAAC;IAE9B,iDAAiD;IACjD,IAAI,CAAC,IAAA,aAAK,EAAC,UAAU,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtC,SAAS,CAAC,IAAI,GAAG,
|
1
|
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AAG,EAAE,GAAG,eAAe,IAAI,eAAe,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import gitUrlParse from 'git-url-parse';\nimport { logger } from '../../logger';\nimport { detectPlatform } from '../common';\nimport * as hostRules from '../host-rules';\nimport { regEx } from '../regex';\n\nexport function parseGitUrl(url: string): gitUrlParse.GitUrl {\n return gitUrlParse(url);\n}\n\nexport function getHttpUrl(url: string, token?: string): string {\n const parsedUrl = parseGitUrl(url);\n\n let { protocol } = parsedUrl;\n const origProtocol = protocol;\n\n // Convert non-https URLs to https and strip port\n if (!regEx(/^https?$/).test(protocol)) {\n parsedUrl.port = '443';\n protocol = 'https';\n }\n\n parsedUrl.user = '';\n parsedUrl.token = token ?? '';\n\n switch (detectPlatform(parsedUrl.toString(protocol))) {\n case 'gitlab':\n if (token) {\n parsedUrl.token = token.includes(':')\n ? token\n : `gitlab-ci-token:${token}`;\n }\n break;\n case 'github':\n if (token) {\n parsedUrl.token = token.includes(':')\n ? token\n : `x-access-token:${token}`;\n }\n break;\n case 'bitbucket-server':\n // SSH URLs look like ssh://git@git.my.com:7999/project/repo.git\n // HTTPS URLs look like https://git.my.com/scm/project/repo.git\n // git-url-parse can't detect bitbucket-server from SSH URL\n // and thus doesn't know it should insert '/scm/'\n if (origProtocol === 'ssh') {\n parsedUrl.source = 'bitbucket-server';\n }\n break;\n }\n\n return new URL(parsedUrl.toString(protocol)).href;\n}\n\nexport function getRemoteUrlWithToken(url: string, hostType?: string): string {\n let coercedUrl: string;\n\n try {\n coercedUrl = getHttpUrl(url);\n } catch {\n logger.warn({ url }, `Attempting to use non-git url for git operations`);\n\n coercedUrl = url;\n }\n\n const hostRule = hostRules.find({ url: coercedUrl, hostType });\n\n if (hostRule?.token) {\n logger.debug(`Found hostRules token for url ${url}`);\n\n return getHttpUrl(url, encodeURIComponent(hostRule.token));\n }\n\n if (hostRule?.username && hostRule?.password) {\n logger.debug(`Found hostRules username and password for url ${url}`);\n const encodedUsername = encodeURIComponent(hostRule.username);\n const encodedPassword = encodeURIComponent(hostRule.password);\n\n return getHttpUrl(url, `${encodedUsername}:${encodedPassword}`);\n }\n\n return url;\n}\n"]}
|
package/dist/util/string.d.ts
CHANGED
package/dist/util/string.js
CHANGED
@@ -10,6 +10,7 @@ exports.titleCase = titleCase;
|
|
10
10
|
exports.copystr = copystr;
|
11
11
|
exports.coerceString = coerceString;
|
12
12
|
exports.stripTemplates = stripTemplates;
|
13
|
+
exports.capitalize = capitalize;
|
13
14
|
// Return true if the match string is found at index in content
|
14
15
|
function matchAt(content, index, match) {
|
15
16
|
return content.substring(index, index + match.length) === match;
|
@@ -145,4 +146,7 @@ function stripTemplates(content) {
|
|
145
146
|
}
|
146
147
|
return result.join('');
|
147
148
|
}
|
149
|
+
function capitalize(input) {
|
150
|
+
return input[0].toUpperCase() + input.slice(1);
|
151
|
+
}
|
148
152
|
//# sourceMappingURL=string.js.map
|
package/dist/util/string.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../lib/util/string.ts"],"names":[],"mappings":";;AACA,0BAMC;AAGD,8BAWC;AAKD,4BAEC;AAKD,gCAEC;AAED,sCAMC;AAED,kCAQC;AAED,8BASC;AAUD,0BAKC;AAOD,oCAKC;AAgBD,wCA8DC;
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../lib/util/string.ts"],"names":[],"mappings":";;AACA,0BAMC;AAGD,8BAWC;AAKD,4BAEC;AAKD,gCAEC;AAED,sCAMC;AAED,kCAQC;AAED,8BASC;AAUD,0BAKC;AAOD,oCAKC;AAgBD,wCA8DC;AAED,gCAEC;AA7KD,+DAA+D;AAC/D,SAAgB,OAAO,CACrB,OAAe,EACf,KAAa,EACb,KAAa;IAEb,OAAO,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC;AAClE,CAA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GAAG,CAAC,CAAC,2BAA2B;oBAC1C,SAAS;gBACX,CAAC;YACH,CAAC;QACH,CAAC;QAED,GAAG,EAAE,CAAC;IACR,CAAC;IAED,sDAAsD;IACtD,IAAI,OAAO,GAAG,GAAG,EAAE,CAAC;QAClB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC;AAED,SAAgB,UAAU,CAAC,KAAa;IACtC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC","sourcesContent":["// Return true if the match string is found at index in content\nexport function matchAt(\n content: string,\n index: number,\n match: string,\n): boolean {\n return content.substring(index, index + match.length) === match;\n}\n\n// Replace oldString with newString at location index of content\nexport function replaceAt(\n content: string,\n index: number,\n oldString: string,\n newString: string,\n): string {\n return (\n content.substring(0, index) +\n newString +\n content.substring(index + oldString.length)\n );\n}\n\n/**\n * Converts from utf-8 string to base64-encoded string\n */\nexport function toBase64(input: string): string {\n return Buffer.from(input).toString('base64');\n}\n\n/**\n * Converts from base64-encoded string to utf-8 string\n */\nexport function fromBase64(input: string): string {\n return Buffer.from(input, 'base64').toString();\n}\n\nexport function uniqueStrings(\n element: string,\n index: number,\n elements: string[],\n): boolean {\n return elements.indexOf(element) === index;\n}\n\nexport function looseEquals(\n a: string | null | undefined,\n b: string | null | undefined,\n): boolean {\n if (!(a && b)) {\n return a === b;\n }\n return a.localeCompare(b, undefined, { sensitivity: 'base' }) === 0;\n}\n\nexport function titleCase(input: string): string {\n const words = input.toLowerCase().split(' ');\n\n for (let i = 0; i < words.length; i++) {\n const word = words[i];\n words[i] = word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n }\n\n return words.join(' ');\n}\n\n/**\n * Sometimes we extract small strings from a multi-megabyte files.\n * If we then save them in the in-memory cache, V8 may not free\n * the initial buffer, which can lead to memory leaks:\n *\n * https://bugs.chromium.org/p/v8/issues/detail?id=2869\n *\n */\nexport function copystr(x: string): string {\n const len = Buffer.byteLength(x, 'utf8');\n const buf = Buffer.allocUnsafeSlow(len);\n buf.write(x, 'utf8');\n return buf.toString('utf8');\n}\n\n/**\n * Coerce a value to a string with optional default value.\n * @param val value to coerce\n * @returns the coerced value.\n */\nexport function coerceString(\n val: string | null | undefined,\n def?: string,\n): string {\n return val ?? def ?? '';\n}\n\n/**\n * Remove templates from string.\n *\n * This is more performant version of this code:\n *\n * ```\n * content\n * .replaceAll(regEx(/{{`.+?`}}/gs), '')\n * .replaceAll(regEx(/{{.+?}}/gs), '')\n * .replaceAll(regEx(/{%`.+?`%}/gs), '')\n * .replaceAll(regEx(/{%.+?%}/gs), '')\n * .replaceAll(regEx(/{#.+?#}/gs), '')\n * ```\n */\nexport function stripTemplates(content: string): string {\n const result: string[] = [];\n\n const len = content.length;\n let idx = 0;\n let lastPos = 0; // Tracks the start index of the next chunk to push\n while (idx < len) {\n if (content[idx] === '{' && idx + 1 < len) {\n let closing: string | undefined;\n let skipLength = 0;\n\n if (content[idx + 1] === '%') {\n if (idx + 2 < len && content[idx + 2] === '`') {\n // Handle `{%` ... `%}`\n closing = '`%}';\n skipLength = 3;\n } else {\n // Handle `{% ... %}`\n closing = '%}';\n skipLength = 2;\n }\n } else if (content[idx + 1] === '{') {\n if (idx + 2 < len && content[idx + 2] === '`') {\n // Handle `{{` ... `}}`\n closing = '`}}';\n skipLength = 3;\n } else {\n // Handle `{{ ... }}`\n closing = '}}';\n skipLength = 2;\n }\n } else if (content[idx + 1] === '#') {\n // Handle `{# ... #}`\n closing = '#}';\n skipLength = 2;\n }\n\n if (closing) {\n const end = content.indexOf(closing, idx + skipLength);\n if (end !== -1) {\n // Append the content before the pattern\n if (idx > lastPos) {\n result.push(content.slice(lastPos, idx));\n }\n\n // Move `idx` past the closing tag\n idx = end + closing.length;\n lastPos = idx; // Update the last position\n continue;\n }\n }\n }\n\n idx++;\n }\n\n // Append any remaining content after the last pattern\n if (lastPos < len) {\n result.push(content.slice(lastPos));\n }\n\n return result.join('');\n}\n\nexport function capitalize(input: string): string {\n return input[0].toUpperCase() + input.slice(1);\n}\n"]}
|
@@ -115,17 +115,19 @@ async function start() {
|
|
115
115
|
// resolve global presets immediately
|
116
116
|
config = (0, config_1.mergeChildConfig)(await resolveGlobalExtends(config.globalExtends, config.ignorePresets), config);
|
117
117
|
}
|
118
|
-
// Set allowedHeaders in case hostRules headers are configured in file config
|
118
|
+
// Set allowedHeaders and userAgent in case hostRules headers are configured in file config
|
119
119
|
global_1.GlobalConfig.set({
|
120
120
|
allowedHeaders: config.allowedHeaders,
|
121
|
+
userAgent: config.userAgent,
|
121
122
|
});
|
122
123
|
// initialize all submodules
|
123
124
|
config = await (0, initialize_1.globalInitialize)(config);
|
124
|
-
// Set platform, endpoint and
|
125
|
+
// Set platform, endpoint, allowedHeaders and userAgent in case local presets are used
|
125
126
|
global_1.GlobalConfig.set({
|
126
127
|
allowedHeaders: config.allowedHeaders,
|
127
128
|
platform: config.platform,
|
128
129
|
endpoint: config.endpoint,
|
130
|
+
userAgent: config.userAgent,
|
129
131
|
});
|
130
132
|
await validatePresets(config);
|
131
133
|
(0, remap_1.setGlobalLogLevelRemaps)(config.logLevelRemap);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/workers/global/index.ts"],"names":[],"mappings":";;AAgCA,kDAwBC;AA8BD,0CAQC;AAED,oDAaC;AAED,sBA6IC;;AA5PD,kEAAkC;AAClC,mCAA+B;AAC/B,gEAA0B;AAC1B,4DAA4B;AAC5B,0DAA0B;AAC1B,mEAA6C;AAC7C,yCAAgD;AAChD,gDAAmD;AACnD,kDAA4D;AAC5D,kDAA6D;AAM7D,mEAAwE;AACxE,iDAAuC;AACvC,2DAAmD;AACnD,+DAA8E;AAC9E,yCAAsE;AAC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AAC,CAAC;QACxC,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YACrC,eAAM,CAAC,KAAK,CACV,EAAE,YAAY,EAAE,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAC1C,sBAAsB,CACvB,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,eAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC;QACzC,CAAC;QACD,IAAI,CAAC,MAAO,EAAE,CAAC;YACb,gDAAgD;YAChD,eAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAC/B,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,IAAA,2BAAc,EAAC,MAAO,CAAC,CAAC;QAC9B,IAAI,IAAA,iBAAQ,GAAE,KAAK,MAAM,EAAE,CAAC;YAC1B,eAAM,CAAC,IAAI,CACT,kCAAkC,IAAA,iBAAQ,GAAE,6EAA6E,CAC1H,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,YAAY,GAAG,IAAA,oBAAW,GAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,cAAK,CAAC,CAAC;IACnE,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;QACxB,eAAM,CAAC,IAAI,CACT,EAAE,YAAY,EAAE,EAChB,6EAA6E,CAC9E,CAAC;QACF,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["import is from '@sindresorhus/is';\nimport { ERROR } from 'bunyan';\nimport fs from 'fs-extra';\nimport semver from 'semver';\nimport upath from 'upath';\nimport * as configParser from '../../config';\nimport { mergeChildConfig } from '../../config';\nimport { GlobalConfig } from '../../config/global';\nimport { resolveConfigPresets } from '../../config/presets';\nimport { validateConfigSecrets } from '../../config/secrets';\nimport type {\n AllConfig,\n RenovateConfig,\n RenovateRepository,\n} from '../../config/types';\nimport { CONFIG_PRESETS_INVALID } from '../../constants/error-messages';\nimport { pkg } from '../../expose.cjs';\nimport { instrument } from '../../instrumentation';\nimport { exportStats, finalizeReport } from '../../instrumentation/reporting';\nimport { getProblems, logLevel, logger, setMeta } from '../../logger';\nimport { setGlobalLogLevelRemaps } from '../../logger/remap';\nimport * as hostRules from '../../util/host-rules';\nimport * as queue from '../../util/http/queue';\nimport * as throttle from '../../util/http/throttle';\nimport { regexEngineStatus } from '../../util/regex';\nimport { addSecretForSanitizing } from '../../util/sanitize';\nimport * as repositoryWorker from '../repository';\nimport { autodiscoverRepositories } from './autodiscover';\nimport { parseConfigs } from './config/parse';\nimport { globalFinalize, globalInitialize } from './initialize';\nimport { isLimitReached } from './limits';\n\nexport async function getRepositoryConfig(\n globalConfig: RenovateConfig,\n repository: RenovateRepository,\n): Promise<RenovateConfig> {\n const repoConfig = configParser.mergeChildConfig(\n globalConfig,\n is.string(repository) ? { repository } : repository,\n );\n const repoParts = repoConfig.repository.split('/');\n repoParts.pop();\n repoConfig.parentOrg = repoParts.join('/');\n repoConfig.topLevelOrg = repoParts.shift();\n // TODO: types (#22198)\n const platform = GlobalConfig.get('platform')!;\n repoConfig.localDir =\n platform === 'local'\n ? process.cwd()\n : upath.join(\n repoConfig.baseDir,\n `./repos/${platform}/${repoConfig.repository}`,\n );\n await fs.ensureDir(repoConfig.localDir);\n delete repoConfig.baseDir;\n return configParser.filterConfig(repoConfig, 'repository');\n}\n\nfunction getGlobalConfig(): Promise<RenovateConfig> {\n return parseConfigs(process.env, process.argv);\n}\n\nfunction haveReachedLimits(): boolean {\n if (isLimitReached('Commits')) {\n logger.info('Max commits created for this run.');\n return true;\n }\n return false;\n}\n\n/* istanbul ignore next */\nfunction checkEnv(): void {\n const range = pkg.engines!.node!;\n if (process.release?.name !== 'node' || !process.versions?.node) {\n logger.warn(\n { release: process.release, versions: process.versions },\n 'Unknown node environment detected.',\n );\n } else if (!semver.satisfies(process.versions?.node, range)) {\n logger.error(\n { versions: process.versions, range },\n 'Unsupported node environment detected. Please update your node version.',\n );\n }\n}\n\nexport async function validatePresets(config: AllConfig): Promise<void> {\n logger.debug('validatePresets()');\n try {\n await resolveConfigPresets(config);\n } catch (err) /* istanbul ignore next */ {\n logger.error({ err }, CONFIG_PRESETS_INVALID);\n throw new Error(CONFIG_PRESETS_INVALID);\n }\n}\n\nexport async function resolveGlobalExtends(\n globalExtends: string[],\n ignorePresets?: string[],\n): Promise<AllConfig> {\n try {\n // Make a \"fake\" config to pass to resolveConfigPresets and resolve globalPresets\n const config = { extends: globalExtends, ignorePresets };\n const resolvedConfig = await resolveConfigPresets(config);\n return resolvedConfig;\n } catch (err) {\n logger.error({ err }, 'Error resolving config preset');\n throw new Error(CONFIG_PRESETS_INVALID);\n }\n}\n\nexport async function start(): Promise<number> {\n // istanbul ignore next\n if (regexEngineStatus.type === 'available') {\n logger.debug('Using RE2 regex engine');\n } else if (regexEngineStatus.type === 'unavailable') {\n logger.warn(\n { err: regexEngineStatus.err },\n 'RE2 not usable, falling back to RegExp',\n );\n } else if (regexEngineStatus.type === 'ignored') {\n logger.debug('RE2 regex engine is ignored via RENOVATE_X_IGNORE_RE2');\n }\n\n let config: AllConfig;\n try {\n if (is.nonEmptyStringAndNotWhitespace(process.env.AWS_SECRET_ACCESS_KEY)) {\n addSecretForSanitizing(process.env.AWS_SECRET_ACCESS_KEY, 'global');\n }\n if (is.nonEmptyStringAndNotWhitespace(process.env.AWS_SESSION_TOKEN)) {\n addSecretForSanitizing(process.env.AWS_SESSION_TOKEN, 'global');\n }\n\n await instrument('config', async () => {\n // read global config from file, env and cli args\n config = await getGlobalConfig();\n if (is.nonEmptyArray(config?.globalExtends)) {\n // resolve global presets immediately\n config = mergeChildConfig(\n await resolveGlobalExtends(\n config.globalExtends,\n config.ignorePresets,\n ),\n config,\n );\n }\n\n // Set allowedHeaders in case hostRules headers are configured in file config\n GlobalConfig.set({\n allowedHeaders: config.allowedHeaders,\n });\n // initialize all submodules\n config = await globalInitialize(config);\n\n // Set platform, endpoint and allowedHeaders in case local presets are used\n GlobalConfig.set({\n allowedHeaders: config.allowedHeaders,\n platform: config.platform,\n endpoint: config.endpoint,\n });\n\n await validatePresets(config);\n\n setGlobalLogLevelRemaps(config.logLevelRemap);\n\n checkEnv();\n\n // validate secrets. Will throw and abort if invalid\n validateConfigSecrets(config);\n });\n\n // autodiscover repositories (needs to come after platform initialization)\n config = await instrument('discover', () =>\n autodiscoverRepositories(config),\n );\n\n if (is.nonEmptyString(config.writeDiscoveredRepos)) {\n const content = JSON.stringify(config.repositories);\n await fs.writeFile(config.writeDiscoveredRepos, content);\n logger.info(\n `Written discovered repositories to ${config.writeDiscoveredRepos}`,\n );\n return 0;\n }\n\n // Iterate through repositories sequentially\n for (const repository of config.repositories!) {\n if (haveReachedLimits()) {\n break;\n }\n await instrument(\n 'repository',\n async () => {\n const repoConfig = await getRepositoryConfig(config, repository);\n if (repoConfig.hostRules) {\n logger.debug('Reinitializing hostRules for repo');\n hostRules.clear();\n repoConfig.hostRules.forEach((rule) => hostRules.add(rule));\n repoConfig.hostRules = [];\n }\n\n // host rules can change concurrency\n queue.clear();\n throttle.clear();\n\n await repositoryWorker.renovateRepository(repoConfig);\n setMeta({});\n },\n {\n attributes: {\n repository:\n typeof repository === 'string'\n ? repository\n : repository.repository,\n },\n },\n );\n }\n\n finalizeReport();\n await exportStats(config);\n } catch (err) /* istanbul ignore next */ {\n if (err.message.startsWith('Init: ')) {\n logger.fatal(\n { errorMessage: err.message.substring(6) },\n 'Initialization error',\n );\n } else {\n logger.fatal({ err }, 'Unknown error');\n }\n if (!config!) {\n // return early if we can't parse config options\n logger.debug(`Missing config`);\n return 2;\n }\n } finally {\n await globalFinalize(config!);\n if (logLevel() === 'info') {\n logger.info(\n `Renovate was run at log level \"${logLevel()}\". Set LOG_LEVEL=debug in environment variables to see extended debug logs.`,\n );\n }\n }\n const loggerErrors = getProblems().filter((p) => p.level >= ERROR);\n if (loggerErrors.length) {\n logger.info(\n { loggerErrors },\n 'Renovate is exiting with a non-zero code due to the following logged errors',\n );\n return 1;\n }\n return 0;\n}\n"]}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/workers/global/index.ts"],"names":[],"mappings":";;AAgCA,kDAwBC;AA8BD,0CAQC;AAED,oDAaC;AAED,sBA+IC;;AA9PD,kEAAkC;AAClC,mCAA+B;AAC/B,gEAA0B;AAC1B,4DAA4B;AAC5B,0DAA0B;AAC1B,mEAA6C;AAC7C,yCAAgD;AAChD,gDAAmD;AACnD,kDAA4D;AAC5D,kDAA6D;AAM7D,mEAAwE;AACxE,iDAAuC;AACvC,2DAAmD;AACnD,+DAA8E;AAC9E,yCAAsE;AACtE,8CAA6D;AAC7D,yEAAmD;AACnD,qEAA+C;AAC/C,2EAAqD;AACrD,4CAAqD;AACrD,kDAA6D;AAC7D,wEAAkD;AAClD,iDAA0D;AAC1D,0CAA8C;AAC9C,6CAAgE;AAChE,qCAA0C;AAEnC,KAAK,UAAU,mBAAmB,CACvC,YAA4B,EAC5B,UAA8B;IAE9B,MAAM,UAAU,GAAG,YAAY,CAAC,gBAAgB,CAC9C,YAAY,EACZ,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,CACpD,CAAC;IACF,MAAM,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnD,SAAS,CAAC,GAAG,EAAE,CAAC;IAChB,UAAU,CAAC,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3C,UAAU,CAAC,WAAW,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC;IAC3C,uBAAuB;IACvB,MAAM,QAAQ,GAAG,qBAAY,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC;IAC/C,UAAU,CAAC,QAA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CAAC;IACH,CAAC;IACD,MAAM,YAAY,GAAG,IAAA,oBAAW,GAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,cAAK,CAAC,CAAC;IACnE,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;QACxB,eAAM,CAAC,IAAI,CACT,EAAE,YAAY,EAAE,EAChB,6EAA6E,CAC9E,CAAC;QACF,OAAO,CAAC,CAAC;IACX,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC","sourcesContent":["import is from '@sindresorhus/is';\nimport { ERROR } from 'bunyan';\nimport fs from 'fs-extra';\nimport semver from 'semver';\nimport upath from 'upath';\nimport * as configParser from '../../config';\nimport { mergeChildConfig } from '../../config';\nimport { GlobalConfig } from '../../config/global';\nimport { resolveConfigPresets } from '../../config/presets';\nimport { validateConfigSecrets } from '../../config/secrets';\nimport type {\n AllConfig,\n RenovateConfig,\n RenovateRepository,\n} from '../../config/types';\nimport { CONFIG_PRESETS_INVALID } from '../../constants/error-messages';\nimport { pkg } from '../../expose.cjs';\nimport { instrument } from '../../instrumentation';\nimport { exportStats, finalizeReport } from '../../instrumentation/reporting';\nimport { getProblems, logLevel, logger, setMeta } from '../../logger';\nimport { setGlobalLogLevelRemaps } from '../../logger/remap';\nimport * as hostRules from '../../util/host-rules';\nimport * as queue from '../../util/http/queue';\nimport * as throttle from '../../util/http/throttle';\nimport { regexEngineStatus } from '../../util/regex';\nimport { addSecretForSanitizing } from '../../util/sanitize';\nimport * as repositoryWorker from '../repository';\nimport { autodiscoverRepositories } from './autodiscover';\nimport { parseConfigs } from './config/parse';\nimport { globalFinalize, globalInitialize } from './initialize';\nimport { isLimitReached } from './limits';\n\nexport async function getRepositoryConfig(\n globalConfig: RenovateConfig,\n repository: RenovateRepository,\n): Promise<RenovateConfig> {\n const repoConfig = configParser.mergeChildConfig(\n globalConfig,\n is.string(repository) ? { repository } : repository,\n );\n const repoParts = repoConfig.repository.split('/');\n repoParts.pop();\n repoConfig.parentOrg = repoParts.join('/');\n repoConfig.topLevelOrg = repoParts.shift();\n // TODO: types (#22198)\n const platform = GlobalConfig.get('platform')!;\n repoConfig.localDir =\n platform === 'local'\n ? process.cwd()\n : upath.join(\n repoConfig.baseDir,\n `./repos/${platform}/${repoConfig.repository}`,\n );\n await fs.ensureDir(repoConfig.localDir);\n delete repoConfig.baseDir;\n return configParser.filterConfig(repoConfig, 'repository');\n}\n\nfunction getGlobalConfig(): Promise<RenovateConfig> {\n return parseConfigs(process.env, process.argv);\n}\n\nfunction haveReachedLimits(): boolean {\n if (isLimitReached('Commits')) {\n logger.info('Max commits created for this run.');\n return true;\n }\n return false;\n}\n\n/* istanbul ignore next */\nfunction checkEnv(): void {\n const range = pkg.engines!.node!;\n if (process.release?.name !== 'node' || !process.versions?.node) {\n logger.warn(\n { release: process.release, versions: process.versions },\n 'Unknown node environment detected.',\n );\n } else if (!semver.satisfies(process.versions?.node, range)) {\n logger.error(\n { versions: process.versions, range },\n 'Unsupported node environment detected. Please update your node version.',\n );\n }\n}\n\nexport async function validatePresets(config: AllConfig): Promise<void> {\n logger.debug('validatePresets()');\n try {\n await resolveConfigPresets(config);\n } catch (err) /* istanbul ignore next */ {\n logger.error({ err }, CONFIG_PRESETS_INVALID);\n throw new Error(CONFIG_PRESETS_INVALID);\n }\n}\n\nexport async function resolveGlobalExtends(\n globalExtends: string[],\n ignorePresets?: string[],\n): Promise<AllConfig> {\n try {\n // Make a \"fake\" config to pass to resolveConfigPresets and resolve globalPresets\n const config = { extends: globalExtends, ignorePresets };\n const resolvedConfig = await resolveConfigPresets(config);\n return resolvedConfig;\n } catch (err) {\n logger.error({ err }, 'Error resolving config preset');\n throw new Error(CONFIG_PRESETS_INVALID);\n }\n}\n\nexport async function start(): Promise<number> {\n // istanbul ignore next\n if (regexEngineStatus.type === 'available') {\n logger.debug('Using RE2 regex engine');\n } else if (regexEngineStatus.type === 'unavailable') {\n logger.warn(\n { err: regexEngineStatus.err },\n 'RE2 not usable, falling back to RegExp',\n );\n } else if (regexEngineStatus.type === 'ignored') {\n logger.debug('RE2 regex engine is ignored via RENOVATE_X_IGNORE_RE2');\n }\n\n let config: AllConfig;\n try {\n if (is.nonEmptyStringAndNotWhitespace(process.env.AWS_SECRET_ACCESS_KEY)) {\n addSecretForSanitizing(process.env.AWS_SECRET_ACCESS_KEY, 'global');\n }\n if (is.nonEmptyStringAndNotWhitespace(process.env.AWS_SESSION_TOKEN)) {\n addSecretForSanitizing(process.env.AWS_SESSION_TOKEN, 'global');\n }\n\n await instrument('config', async () => {\n // read global config from file, env and cli args\n config = await getGlobalConfig();\n if (is.nonEmptyArray(config?.globalExtends)) {\n // resolve global presets immediately\n config = mergeChildConfig(\n await resolveGlobalExtends(\n config.globalExtends,\n config.ignorePresets,\n ),\n config,\n );\n }\n\n // Set allowedHeaders and userAgent in case hostRules headers are configured in file config\n GlobalConfig.set({\n allowedHeaders: config.allowedHeaders,\n userAgent: config.userAgent,\n });\n // initialize all submodules\n config = await globalInitialize(config);\n\n // Set platform, endpoint, allowedHeaders and userAgent in case local presets are used\n GlobalConfig.set({\n allowedHeaders: config.allowedHeaders,\n platform: config.platform,\n endpoint: config.endpoint,\n userAgent: config.userAgent,\n });\n\n await validatePresets(config);\n\n setGlobalLogLevelRemaps(config.logLevelRemap);\n\n checkEnv();\n\n // validate secrets. Will throw and abort if invalid\n validateConfigSecrets(config);\n });\n\n // autodiscover repositories (needs to come after platform initialization)\n config = await instrument('discover', () =>\n autodiscoverRepositories(config),\n );\n\n if (is.nonEmptyString(config.writeDiscoveredRepos)) {\n const content = JSON.stringify(config.repositories);\n await fs.writeFile(config.writeDiscoveredRepos, content);\n logger.info(\n `Written discovered repositories to ${config.writeDiscoveredRepos}`,\n );\n return 0;\n }\n\n // Iterate through repositories sequentially\n for (const repository of config.repositories!) {\n if (haveReachedLimits()) {\n break;\n }\n await instrument(\n 'repository',\n async () => {\n const repoConfig = await getRepositoryConfig(config, repository);\n if (repoConfig.hostRules) {\n logger.debug('Reinitializing hostRules for repo');\n hostRules.clear();\n repoConfig.hostRules.forEach((rule) => hostRules.add(rule));\n repoConfig.hostRules = [];\n }\n\n // host rules can change concurrency\n queue.clear();\n throttle.clear();\n\n await repositoryWorker.renovateRepository(repoConfig);\n setMeta({});\n },\n {\n attributes: {\n repository:\n typeof repository === 'string'\n ? repository\n : repository.repository,\n },\n },\n );\n }\n\n finalizeReport();\n await exportStats(config);\n } catch (err) /* istanbul ignore next */ {\n if (err.message.startsWith('Init: ')) {\n logger.fatal(\n { errorMessage: err.message.substring(6) },\n 'Initialization error',\n );\n } else {\n logger.fatal({ err }, 'Unknown error');\n }\n if (!config!) {\n // return early if we can't parse config options\n logger.debug(`Missing config`);\n return 2;\n }\n } finally {\n await globalFinalize(config!);\n if (logLevel() === 'info') {\n logger.info(\n `Renovate was run at log level \"${logLevel()}\". Set LOG_LEVEL=debug in environment variables to see extended debug logs.`,\n );\n }\n }\n const loggerErrors = getProblems().filter((p) => p.level >= ERROR);\n if (loggerErrors.length) {\n logger.info(\n { loggerErrors },\n 'Renovate is exiting with a non-zero code due to the following logged errors',\n );\n return 1;\n }\n return 0;\n}\n"]}
|
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": "39.
|
4
|
+
"version": "39.241.1",
|
5
5
|
"type": "commonjs",
|
6
6
|
"bin": {
|
7
7
|
"renovate": "dist/renovate.js",
|
@@ -265,7 +265,7 @@
|
|
265
265
|
},
|
266
266
|
"devDependencies": {
|
267
267
|
"@containerbase/eslint-plugin": "1.1.4",
|
268
|
-
"@eslint/js": "9.
|
268
|
+
"@eslint/js": "9.24.0",
|
269
269
|
"@hyrious/marshal": "0.3.3",
|
270
270
|
"@ls-lint/ls-lint": "2.3.0",
|
271
271
|
"@openpgp/web-stream-tools": "0.1.3",
|
@@ -285,7 +285,7 @@
|
|
285
285
|
"@types/diff": "7.0.2",
|
286
286
|
"@types/eslint-config-prettier": "6.11.3",
|
287
287
|
"@types/fs-extra": "11.0.4",
|
288
|
-
"@types/git-url-parse": "
|
288
|
+
"@types/git-url-parse": "16.0.0",
|
289
289
|
"@types/github-url-from-git": "1.5.3",
|
290
290
|
"@types/global-agent": "3.0.0",
|
291
291
|
"@types/ini": "4.1.1",
|
@@ -319,10 +319,10 @@
|
|
319
319
|
"conventional-changelog-conventionalcommits": "8.0.0",
|
320
320
|
"emojibase-data": "16.0.2",
|
321
321
|
"esbuild": "0.25.2",
|
322
|
-
"eslint": "9.
|
322
|
+
"eslint": "9.24.0",
|
323
323
|
"eslint-config-prettier": "10.1.1",
|
324
324
|
"eslint-formatter-gha": "1.5.2",
|
325
|
-
"eslint-import-resolver-typescript": "4.2
|
325
|
+
"eslint-import-resolver-typescript": "4.3.2",
|
326
326
|
"eslint-plugin-import": "2.31.0",
|
327
327
|
"eslint-plugin-promise": "7.2.1",
|
328
328
|
"expect-more-jest": "5.5.0",
|
@@ -333,7 +333,7 @@
|
|
333
333
|
"lint-staged": "15.5.0",
|
334
334
|
"markdownlint-cli2": "0.17.2",
|
335
335
|
"memfs": "4.17.0",
|
336
|
-
"nock": "14.0.
|
336
|
+
"nock": "14.0.3",
|
337
337
|
"npm-run-all2": "7.0.2",
|
338
338
|
"nyc": "17.1.0",
|
339
339
|
"rimraf": "6.0.1",
|
@@ -343,7 +343,7 @@
|
|
343
343
|
"tsx": "4.19.3",
|
344
344
|
"type-fest": "4.39.1",
|
345
345
|
"typescript": "5.8.3",
|
346
|
-
"typescript-eslint": "8.
|
346
|
+
"typescript-eslint": "8.29.0",
|
347
347
|
"unified": "9.2.2",
|
348
348
|
"vite": "6.2.6",
|
349
349
|
"vite-tsconfig-paths": "5.1.4",
|