renovate 39.7.5 → 39.7.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,6 @@ exports.decryptConfig = decryptConfig;
5
5
  const tslib_1 = require("tslib");
6
6
  const is_1 = tslib_1.__importDefault(require("@sindresorhus/is"));
7
7
  const logger_1 = require("../logger");
8
- const mask_1 = require("../util/mask");
9
8
  const regex_1 = require("../util/regex");
10
9
  const sanitize_1 = require("../util/sanitize");
11
10
  const url_1 = require("../util/url");
@@ -125,24 +124,8 @@ async function decryptConfig(config, repository) {
125
124
  logger_1.logger.debug(`Decrypted ${eKey}`);
126
125
  if (eKey === 'npmToken') {
127
126
  const token = decryptedStr.replace((0, regex_1.regEx)(/\n$/), '');
127
+ decryptedConfig[eKey] = token;
128
128
  (0, sanitize_1.addSecretForSanitizing)(token);
129
- logger_1.logger.debug({ decryptedToken: (0, mask_1.maskToken)(token) }, 'Migrating npmToken to npmrc');
130
- if (is_1.default.string(decryptedConfig.npmrc)) {
131
- /* eslint-disable no-template-curly-in-string */
132
- if (decryptedConfig.npmrc.includes('${NPM_TOKEN}')) {
133
- logger_1.logger.debug('Replacing ${NPM_TOKEN} with decrypted token');
134
- decryptedConfig.npmrc = decryptedConfig.npmrc.replace((0, regex_1.regEx)(/\${NPM_TOKEN}/g), token);
135
- }
136
- else {
137
- logger_1.logger.debug('Appending _authToken= to end of existing npmrc');
138
- decryptedConfig.npmrc = decryptedConfig.npmrc.replace((0, regex_1.regEx)(/\n?$/), `\n_authToken=${token}\n`);
139
- }
140
- /* eslint-enable no-template-curly-in-string */
141
- }
142
- else {
143
- logger_1.logger.debug('Adding npmrc to config');
144
- decryptedConfig.npmrc = `//registry.npmjs.org/:_authToken=${token}\n`;
145
- }
146
129
  }
147
130
  else {
148
131
  decryptedConfig[eKey] = decryptedStr;
@@ -1 +1 @@
1
- {"version":3,"file":"decrypt.js","sourceRoot":"","sources":["../../lib/config/decrypt.ts"],"names":[],"mappings":";;AAgBA,gCAkCC;AA2ED,sCAkGC;;AA/ND,kE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,EAAE,eAAe,EAAE,EAAE,iBAAiB,CAAC,CAAC;IAC7D,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import is from '@sindresorhus/is';\nimport { logger } from '../logger';\nimport { maskToken } from '../util/mask';\nimport { regEx } from '../util/regex';\nimport { addSecretForSanitizing } from '../util/sanitize';\nimport { ensureTrailingSlash } from '../util/url';\nimport { tryDecryptKbPgp } from './decrypt/kbpgp';\nimport {\n tryDecryptPublicKeyDefault,\n tryDecryptPublicKeyPKCS1,\n} from './decrypt/legacy';\nimport { tryDecryptOpenPgp } from './decrypt/openpgp';\nimport { GlobalConfig } from './global';\nimport { DecryptedObject } from './schema';\nimport type { RenovateConfig } from './types';\n\nexport async function tryDecrypt(\n privateKey: string,\n encryptedStr: string,\n repository: string,\n keyName: string,\n): Promise<string | null> {\n let decryptedStr: string | null = null;\n if (privateKey?.startsWith('-----BEGIN PGP PRIVATE KEY BLOCK-----')) {\n const decryptedObjStr =\n process.env.RENOVATE_X_USE_OPENPGP === 'true'\n ? await tryDecryptOpenPgp(privateKey, encryptedStr)\n : await tryDecryptKbPgp(privateKey, encryptedStr);\n if (decryptedObjStr) {\n decryptedStr = validateDecryptedValue(decryptedObjStr, repository);\n }\n } else {\n decryptedStr = tryDecryptPublicKeyDefault(privateKey, encryptedStr);\n if (is.string(decryptedStr)) {\n logger.warn(\n { keyName },\n 'Encrypted value is using deprecated default padding, please change to using PGP encryption.',\n );\n } else {\n decryptedStr = tryDecryptPublicKeyPKCS1(privateKey, encryptedStr);\n // istanbul ignore if\n if (is.string(decryptedStr)) {\n logger.warn(\n { keyName },\n 'Encrypted value is using deprecated PKCS1 padding, please change to using PGP encryption.',\n );\n }\n }\n }\n return decryptedStr;\n}\n\nfunction validateDecryptedValue(\n decryptedObjStr: string,\n repository: string,\n): string | null {\n try {\n const decryptedObj = DecryptedObject.safeParse(decryptedObjStr);\n // istanbul ignore if\n if (!decryptedObj.success) {\n const error = new Error('config-validation');\n error.validationError = `Could not parse decrypted config.`;\n throw error;\n }\n\n const { o: org, r: repo, v: value } = decryptedObj.data;\n if (is.nonEmptyString(value)) {\n if (is.nonEmptyString(org)) {\n const orgPrefixes = org\n .split(',')\n .map((o) => o.trim())\n .map((o) => o.toUpperCase())\n .map((o) => ensureTrailingSlash(o));\n if (is.nonEmptyString(repo)) {\n const scopedRepos = orgPrefixes.map((orgPrefix) =>\n `${orgPrefix}${repo}`.toUpperCase(),\n );\n if (scopedRepos.some((r) => r === repository.toUpperCase())) {\n return value;\n } else {\n logger.debug(\n { scopedRepos },\n 'Secret is scoped to a different repository',\n );\n const error = new Error('config-validation');\n error.validationError = `Encrypted secret is scoped to a different repository: \"${scopedRepos.join(\n ',',\n )}\".`;\n throw error;\n }\n } else {\n if (\n orgPrefixes.some((orgPrefix) =>\n repository.toUpperCase().startsWith(orgPrefix),\n )\n ) {\n return value;\n } else {\n logger.debug(\n { orgPrefixes },\n 'Secret is scoped to a different org',\n );\n const error = new Error('config-validation');\n error.validationError = `Encrypted secret is scoped to a different org: \"${orgPrefixes.join(\n ',',\n )}\".`;\n throw error;\n }\n }\n } else {\n const error = new Error('config-validation');\n error.validationError = `Encrypted value in config is missing a scope.`;\n throw error;\n }\n } else {\n const error = new Error('config-validation');\n error.validationError = `Encrypted value in config is missing a value.`;\n throw error;\n }\n } catch (err) {\n logger.warn({ err }, 'Could not parse decrypted string');\n }\n return null;\n}\n\nexport async function decryptConfig(\n config: RenovateConfig,\n repository: string,\n): Promise<RenovateConfig> {\n logger.trace({ config }, 'decryptConfig()');\n const decryptedConfig = { ...config };\n const privateKey = GlobalConfig.get('privateKey');\n const privateKeyOld = GlobalConfig.get('privateKeyOld');\n for (const [key, val] of Object.entries(config)) {\n if (key === 'encrypted' && is.object(val)) {\n logger.debug({ config: val }, 'Found encrypted config');\n\n const encryptedWarning = GlobalConfig.get('encryptedWarning');\n if (is.string(encryptedWarning)) {\n logger.once.warn(encryptedWarning);\n }\n\n if (privateKey) {\n for (const [eKey, eVal] of Object.entries(val)) {\n logger.debug('Trying to decrypt ' + eKey);\n let decryptedStr = await tryDecrypt(\n privateKey,\n eVal,\n repository,\n eKey,\n );\n if (privateKeyOld && !is.nonEmptyString(decryptedStr)) {\n logger.debug(`Trying to decrypt with old private key`);\n decryptedStr = await tryDecrypt(\n privateKeyOld,\n eVal,\n repository,\n eKey,\n );\n }\n if (!is.nonEmptyString(decryptedStr)) {\n const error = new Error('config-validation');\n error.validationError = `Failed to decrypt field ${eKey}. Please re-encrypt and try again.`;\n throw error;\n }\n logger.debug(`Decrypted ${eKey}`);\n if (eKey === 'npmToken') {\n const token = decryptedStr.replace(regEx(/\\n$/), '');\n addSecretForSanitizing(token);\n logger.debug(\n { decryptedToken: maskToken(token) },\n 'Migrating npmToken to npmrc',\n );\n if (is.string(decryptedConfig.npmrc)) {\n /* eslint-disable no-template-curly-in-string */\n if (decryptedConfig.npmrc.includes('${NPM_TOKEN}')) {\n logger.debug('Replacing ${NPM_TOKEN} with decrypted token');\n decryptedConfig.npmrc = decryptedConfig.npmrc.replace(\n regEx(/\\${NPM_TOKEN}/g),\n token,\n );\n } else {\n logger.debug('Appending _authToken= to end of existing npmrc');\n decryptedConfig.npmrc = decryptedConfig.npmrc.replace(\n regEx(/\\n?$/),\n `\\n_authToken=${token}\\n`,\n );\n }\n /* eslint-enable no-template-curly-in-string */\n } else {\n logger.debug('Adding npmrc to config');\n decryptedConfig.npmrc = `//registry.npmjs.org/:_authToken=${token}\\n`;\n }\n } else {\n decryptedConfig[eKey] = decryptedStr;\n addSecretForSanitizing(decryptedStr);\n }\n }\n } else {\n logger.error('Found encrypted data but no privateKey');\n }\n delete decryptedConfig.encrypted;\n } else if (is.array(val)) {\n decryptedConfig[key] = [];\n for (const item of val) {\n if (is.object(item) && !is.array(item)) {\n (decryptedConfig[key] as RenovateConfig[]).push(\n await decryptConfig(item as RenovateConfig, repository),\n );\n } else {\n (decryptedConfig[key] as unknown[]).push(item);\n }\n }\n } else if (is.object(val) && key !== 'content') {\n decryptedConfig[key] = await decryptConfig(\n val as RenovateConfig,\n repository,\n );\n }\n }\n delete decryptedConfig.encrypted;\n logger.trace({ config: decryptedConfig }, 'decryptedConfig');\n return decryptedConfig;\n}\n"]}
1
+ {"version":3,"file":"decrypt.js","sourceRoot":"","sources":["../../lib/config/decrypt.ts"],"names":[],"mappings":";;AAeA,gCAkCC;AA2ED,sCA2EC;;AAvMD,kEAAkC;AAClC,sCAAmC;AACnC,yCAAsC;AACtC,+CAA0D;AAC1D,qCAAkD;AAClD,2CAAkD;AAClD,6CAG0B;AAC1B,+CAAsD;AACtD,qCAAwC;AACxC,qCAA2C;AAGpC,KAAK,UAAU,UAAU,CAC9B,UAAkB,EAClB,YAAoB,EACpB,UAAkB,EAClB,OAAe;IAEf,IAAI,YAAY,GAAkB,IAAI,CAAC;IACvC,IAAI,UAAU,EAAE,UAAU,CAAC,uCAAuC,CAAC,EAAE,CAAC;QACpE,MAAM,eAAe,GACnB,OAAO,CAAC,GAAG,CAAC,sBAAsB,KAAK,MAAM;YAC3C,CAAC,CAAC,MAAM,IAAA,2BAAiB,EAAC,UAAU,EAAE,YAAY,CAAC;YACnD,CAAC,CAAC,MAAM,IAAA,uBAAe,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACtD,IAAI,eAAe,EAAE,CAAC;YACpB,YAAY,GAAG,sBAAsB,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;SAAM,CAAC;QACN,YAAY,GAAG,IAAA,mCAA0B,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACpE,IAAI,YAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5B,eAAM,CAAC,IAAI,CACT,EAAE,OAAO,EAAE,EACX,6FAA6F,CAC9F,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,YAAY,GAAG,IAAA,iCAAwB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;YAClE,qBAAqB;YACrB,IAAI,YAAE,CA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,EAAE,CAAC;YAC1B,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;gBACvB,IAAI,YAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtC,eAAe,CAAC,GAAG,CAAsB,CAAC,IAAI,CAC7C,MAAM,aAAa,CAAC,IAAsB,EAAE,UAAU,CAAC,CACxD,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACL,eAAe,CAAC,GAAG,CAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACjD,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,YAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YAC/C,eAAe,CAAC,GAAG,CAAC,GAAG,MAAM,aAAa,CACxC,GAAqB,EACrB,UAAU,CACX,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,eAAe,CAAC,SAAS,CAAC;IACjC,eAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,iBAAiB,CAAC,CAAC;IAC7D,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import is from '@sindresorhus/is';\nimport { logger } from '../logger';\nimport { regEx } from '../util/regex';\nimport { addSecretForSanitizing } from '../util/sanitize';\nimport { ensureTrailingSlash } from '../util/url';\nimport { tryDecryptKbPgp } from './decrypt/kbpgp';\nimport {\n tryDecryptPublicKeyDefault,\n tryDecryptPublicKeyPKCS1,\n} from './decrypt/legacy';\nimport { tryDecryptOpenPgp } from './decrypt/openpgp';\nimport { GlobalConfig } from './global';\nimport { DecryptedObject } from './schema';\nimport type { RenovateConfig } from './types';\n\nexport async function tryDecrypt(\n privateKey: string,\n encryptedStr: string,\n repository: string,\n keyName: string,\n): Promise<string | null> {\n let decryptedStr: string | null = null;\n if (privateKey?.startsWith('-----BEGIN PGP PRIVATE KEY BLOCK-----')) {\n const decryptedObjStr =\n process.env.RENOVATE_X_USE_OPENPGP === 'true'\n ? await tryDecryptOpenPgp(privateKey, encryptedStr)\n : await tryDecryptKbPgp(privateKey, encryptedStr);\n if (decryptedObjStr) {\n decryptedStr = validateDecryptedValue(decryptedObjStr, repository);\n }\n } else {\n decryptedStr = tryDecryptPublicKeyDefault(privateKey, encryptedStr);\n if (is.string(decryptedStr)) {\n logger.warn(\n { keyName },\n 'Encrypted value is using deprecated default padding, please change to using PGP encryption.',\n );\n } else {\n decryptedStr = tryDecryptPublicKeyPKCS1(privateKey, encryptedStr);\n // istanbul ignore if\n if (is.string(decryptedStr)) {\n logger.warn(\n { keyName },\n 'Encrypted value is using deprecated PKCS1 padding, please change to using PGP encryption.',\n );\n }\n }\n }\n return decryptedStr;\n}\n\nfunction validateDecryptedValue(\n decryptedObjStr: string,\n repository: string,\n): string | null {\n try {\n const decryptedObj = DecryptedObject.safeParse(decryptedObjStr);\n // istanbul ignore if\n if (!decryptedObj.success) {\n const error = new Error('config-validation');\n error.validationError = `Could not parse decrypted config.`;\n throw error;\n }\n\n const { o: org, r: repo, v: value } = decryptedObj.data;\n if (is.nonEmptyString(value)) {\n if (is.nonEmptyString(org)) {\n const orgPrefixes = org\n .split(',')\n .map((o) => o.trim())\n .map((o) => o.toUpperCase())\n .map((o) => ensureTrailingSlash(o));\n if (is.nonEmptyString(repo)) {\n const scopedRepos = orgPrefixes.map((orgPrefix) =>\n `${orgPrefix}${repo}`.toUpperCase(),\n );\n if (scopedRepos.some((r) => r === repository.toUpperCase())) {\n return value;\n } else {\n logger.debug(\n { scopedRepos },\n 'Secret is scoped to a different repository',\n );\n const error = new Error('config-validation');\n error.validationError = `Encrypted secret is scoped to a different repository: \"${scopedRepos.join(\n ',',\n )}\".`;\n throw error;\n }\n } else {\n if (\n orgPrefixes.some((orgPrefix) =>\n repository.toUpperCase().startsWith(orgPrefix),\n )\n ) {\n return value;\n } else {\n logger.debug(\n { orgPrefixes },\n 'Secret is scoped to a different org',\n );\n const error = new Error('config-validation');\n error.validationError = `Encrypted secret is scoped to a different org: \"${orgPrefixes.join(\n ',',\n )}\".`;\n throw error;\n }\n }\n } else {\n const error = new Error('config-validation');\n error.validationError = `Encrypted value in config is missing a scope.`;\n throw error;\n }\n } else {\n const error = new Error('config-validation');\n error.validationError = `Encrypted value in config is missing a value.`;\n throw error;\n }\n } catch (err) {\n logger.warn({ err }, 'Could not parse decrypted string');\n }\n return null;\n}\n\nexport async function decryptConfig(\n config: RenovateConfig,\n repository: string,\n): Promise<RenovateConfig> {\n logger.trace({ config }, 'decryptConfig()');\n const decryptedConfig = { ...config };\n const privateKey = GlobalConfig.get('privateKey');\n const privateKeyOld = GlobalConfig.get('privateKeyOld');\n for (const [key, val] of Object.entries(config)) {\n if (key === 'encrypted' && is.object(val)) {\n logger.debug({ config: val }, 'Found encrypted config');\n\n const encryptedWarning = GlobalConfig.get('encryptedWarning');\n if (is.string(encryptedWarning)) {\n logger.once.warn(encryptedWarning);\n }\n\n if (privateKey) {\n for (const [eKey, eVal] of Object.entries(val)) {\n logger.debug('Trying to decrypt ' + eKey);\n let decryptedStr = await tryDecrypt(\n privateKey,\n eVal,\n repository,\n eKey,\n );\n if (privateKeyOld && !is.nonEmptyString(decryptedStr)) {\n logger.debug(`Trying to decrypt with old private key`);\n decryptedStr = await tryDecrypt(\n privateKeyOld,\n eVal,\n repository,\n eKey,\n );\n }\n if (!is.nonEmptyString(decryptedStr)) {\n const error = new Error('config-validation');\n error.validationError = `Failed to decrypt field ${eKey}. Please re-encrypt and try again.`;\n throw error;\n }\n logger.debug(`Decrypted ${eKey}`);\n if (eKey === 'npmToken') {\n const token = decryptedStr.replace(regEx(/\\n$/), '');\n decryptedConfig[eKey] = token;\n addSecretForSanitizing(token);\n } else {\n decryptedConfig[eKey] = decryptedStr;\n addSecretForSanitizing(decryptedStr);\n }\n }\n } else {\n logger.error('Found encrypted data but no privateKey');\n }\n delete decryptedConfig.encrypted;\n } else if (is.array(val)) {\n decryptedConfig[key] = [];\n for (const item of val) {\n if (is.object(item) && !is.array(item)) {\n (decryptedConfig[key] as RenovateConfig[]).push(\n await decryptConfig(item as RenovateConfig, repository),\n );\n } else {\n (decryptedConfig[key] as unknown[]).push(item);\n }\n }\n } else if (is.object(val) && key !== 'content') {\n decryptedConfig[key] = await decryptConfig(\n val as RenovateConfig,\n repository,\n );\n }\n }\n delete decryptedConfig.encrypted;\n logger.trace({ config: decryptedConfig }, 'decryptedConfig');\n return decryptedConfig;\n}\n"]}
@@ -4,3 +4,5 @@ export declare function detectConfigFile(): Promise<string | null>;
4
4
  export declare function detectRepoFileConfig(): Promise<RepoFileConfig>;
5
5
  export declare function checkForRepoConfigError(repoConfig: RepoFileConfig): void;
6
6
  export declare function mergeRenovateConfig(config: RenovateConfig): Promise<RenovateConfig>;
7
+ /** needed when using portal secrets for npmToken */
8
+ export declare function setNpmTokenInNpmrc(config: RenovateConfig): void;
@@ -4,6 +4,7 @@ exports.detectConfigFile = detectConfigFile;
4
4
  exports.detectRepoFileConfig = detectRepoFileConfig;
5
5
  exports.checkForRepoConfigError = checkForRepoConfigError;
6
6
  exports.mergeRenovateConfig = mergeRenovateConfig;
7
+ exports.setNpmTokenInNpmrc = setNpmTokenInNpmrc;
7
8
  const tslib_1 = require("tslib");
8
9
  const is_1 = tslib_1.__importDefault(require("@sindresorhus/is"));
9
10
  const config_1 = require("../../../config");
@@ -26,6 +27,8 @@ const fs_1 = require("../../../util/fs");
26
27
  const hostRules = tslib_1.__importStar(require("../../../util/host-rules"));
27
28
  const queue = tslib_1.__importStar(require("../../../util/http/queue"));
28
29
  const throttle = tslib_1.__importStar(require("../../../util/http/throttle"));
30
+ const mask_1 = require("../../../util/mask");
31
+ const regex_1 = require("../../../util/regex");
29
32
  const config_2 = require("../onboarding/branch/config");
30
33
  const create_1 = require("../onboarding/branch/create");
31
34
  const onboarding_branch_cache_1 = require("../onboarding/branch/onboarding-branch-cache");
@@ -197,6 +200,7 @@ async function mergeRenovateConfig(config) {
197
200
  const repository = config.repository;
198
201
  // Decrypt before resolving in case we need npm authentication for any presets
199
202
  const decryptedConfig = await (0, decrypt_1.decryptConfig)(migratedConfig, repository);
203
+ setNpmTokenInNpmrc(decryptedConfig);
200
204
  // istanbul ignore if
201
205
  if (is_1.default.string(decryptedConfig.npmrc)) {
202
206
  logger_1.logger.debug('Found npmrc in decrypted config - setting');
@@ -211,6 +215,7 @@ async function mergeRenovateConfig(config) {
211
215
  logger_1.logger.trace({ config: resolvedConfig }, 'resolved config after migrating');
212
216
  resolvedConfig = migrationResult.migratedConfig;
213
217
  }
218
+ setNpmTokenInNpmrc(resolvedConfig);
214
219
  // istanbul ignore if
215
220
  if (is_1.default.string(resolvedConfig.npmrc)) {
216
221
  logger_1.logger.debug('Ignoring any .npmrc files in repository due to configured npmrc');
@@ -242,4 +247,27 @@ async function mergeRenovateConfig(config) {
242
247
  }
243
248
  return returnConfig;
244
249
  }
250
+ /** needed when using portal secrets for npmToken */
251
+ function setNpmTokenInNpmrc(config) {
252
+ if (!is_1.default.string(config.npmToken)) {
253
+ return;
254
+ }
255
+ const token = config.npmToken;
256
+ logger_1.logger.debug({ npmToken: (0, mask_1.maskToken)(token) }, 'Migrating npmToken to npmrc');
257
+ if (!is_1.default.string(config.npmrc)) {
258
+ logger_1.logger.debug('Adding npmrc to config');
259
+ config.npmrc = `//registry.npmjs.org/:_authToken=${token}\n`;
260
+ delete config.npmToken;
261
+ return;
262
+ }
263
+ if (config.npmrc.includes(`\${NPM_TOKEN}`)) {
264
+ logger_1.logger.debug(`Replacing \${NPM_TOKEN} with npmToken`);
265
+ config.npmrc = config.npmrc.replace((0, regex_1.regEx)(/\${NPM_TOKEN}/g), token);
266
+ }
267
+ else {
268
+ logger_1.logger.debug('Appending _authToken= to end of existing npmrc');
269
+ config.npmrc = config.npmrc.replace((0, regex_1.regEx)(/\n?$/), `\n_authToken=${token}\n`);
270
+ }
271
+ delete config.npmToken;
272
+ }
245
273
  //# sourceMappingURL=merge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../../lib/workers/repository/init/merge.ts"],"names":[],"mappings":";;AAmCA,4CAsBC;AAED,oDA+FC;AAED,0DASC;AAGD,kDA+GC;;AAvRD,kEAAkC;AAClC,4CAAmD;AACnD,6DAA8D;AAC9D,qDAAwD;AACxD,uEAAsE;AACtE,yDAA0D;AAC1D,iDAAwD;AACxD,yEAAmD;AACnD,qDAA+D;AAE/D,sEAG2C;AAC3C,4CAAyC;AACzC,gFAA0D;AAC1D,wDAAqD;AACrD,uDAAoD;AACpD,mFAA8E;AAC9E,+DAA0D;AAC1D,iDAAiD;AACjD,yCAAiD;AACjD,4EAAsD;AACtD,wEAAkD;AAClD,8EAAwD;AACxD,wDAAkE;AAClE,wDAAuE;AACvE,0FAIsD;AACtD,iDAAuD;AAGhD,KAAK,UAAU,gBAAgB;IACpC,MAAM,QAAQ,GAAG,MAAM,SAAG,CAAC,WAAW,EAAE,CAAC;IACzC,KAAK,MAAM,QAAQ,IAAI,6BAAe,EAAE,CAAC;QACvC,IAAI,QAAQ,KAAK,cAAc,EAAE,CAAC;YAChC,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CACtB,CAAC,MAAM,IAAA,kBAAa,EAAC,cAAc,EAAE,MAAM,CAAC,CAAE,CAC/C,CAAC;gBACF,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;oBACnB,eAAM,CAAC,IAAI,CACT,0GAA0G,CAC3G,CAAC;oBACF,OAAO,cAAc,CAAC;gBACxB,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,aAAa;YACf,CAAC;QACH,CAAC;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvC,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAEM,KAAK,UAAU,oBAAoB;IACxC,MAAM,KAAK,G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WAAW,EAAE,MAAM,EAAE,CAAC;QACrC,eAAM,CAAC,KAAK,CACV,EAAE,WAAW,EAAE,YAAY,CAAC,WAAW,EAAE,EACzC,wBAAwB,CACzB,CAAC;IACJ,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import is from '@sindresorhus/is';\nimport { mergeChildConfig } from '../../../config';\nimport { configFileNames } from '../../../config/app-strings';\nimport { decryptConfig } from '../../../config/decrypt';\nimport { migrateAndValidate } from '../../../config/migrate-validate';\nimport { migrateConfig } from '../../../config/migration';\nimport { parseFileConfig } from '../../../config/parse';\nimport * as presets from '../../../config/presets';\nimport { applySecretsToConfig } from '../../../config/secrets';\nimport type { RenovateConfig } from '../../../config/types';\nimport {\n CONFIG_VALIDATION,\n REPOSITORY_CHANGED,\n} from '../../../constants/error-messages';\nimport { logger } from '../../../logger';\nimport * as npmApi from '../../../modules/datasource/npm';\nimport { platform } from '../../../modules/platform';\nimport { scm } from '../../../modules/platform/scm';\nimport { ExternalHostError } from '../../../types/errors/external-host-error';\nimport { getCache } from '../../../util/cache/repository';\nimport { parseJson } from '../../../util/common';\nimport { readLocalFile } from '../../../util/fs';\nimport * as hostRules from '../../../util/host-rules';\nimport * as queue from '../../../util/http/queue';\nimport * as throttle from '../../../util/http/throttle';\nimport { getOnboardingConfig } from '../onboarding/branch/config';\nimport { getDefaultConfigFileName } from '../onboarding/branch/create';\nimport {\n getOnboardingConfigFromCache,\n getOnboardingFileNameFromCache,\n setOnboardingConfigDetails,\n} from '../onboarding/branch/onboarding-branch-cache';\nimport { OnboardingState } from '../onboarding/common';\nimport type { RepoFileConfig } from './types';\n\nexport async function detectConfigFile(): Promise<string | null> {\n const fileList = await scm.getFileList();\n for (const fileName of configFileNames) {\n if (fileName === 'package.json') {\n try {\n const pJson = JSON.parse(\n (await readLocalFile('package.json', 'utf8'))!,\n );\n if (pJson.renovate) {\n logger.warn(\n 'Using package.json for Renovate config is deprecated - please use a dedicated configuration file instead',\n );\n return 'package.json';\n }\n } catch {\n // Do nothing\n }\n } else if (fileList.includes(fileName)) {\n return fileName;\n }\n }\n return null;\n}\n\nexport async function detectRepoFileConfig(): Promise<RepoFileConfig> {\n const cache = getCache();\n let { configFileName } = cache;\n if (is.nonEmptyString(configFileName)) {\n let configFileRaw: string | null;\n try {\n configFileRaw = await platform.getRawFile(configFileName);\n } catch (err) {\n // istanbul ignore if\n if (err instanceof ExternalHostError) {\n throw err;\n }\n configFileRaw = null;\n }\n if (configFileRaw) {\n let configFileParsed = parseJson(configFileRaw, configFileName) as any;\n if (configFileName === 'package.json') {\n configFileParsed = configFileParsed.renovate;\n }\n return { configFileName, configFileParsed };\n } else {\n logger.debug('Existing config file no longer exists');\n delete cache.configFileName;\n }\n }\n\n if (OnboardingState.onboardingCacheValid) {\n configFileName = getOnboardingFileNameFromCache();\n } else {\n configFileName = (await detectConfigFile()) ?? undefined;\n }\n\n if (!configFileName) {\n logger.debug('No renovate config file found');\n cache.configFileName = '';\n return {};\n }\n cache.configFileName = configFileName;\n logger.debug(`Found ${configFileName} config file`);\n // TODO #22198\n let configFileParsed: any;\n let configFileRaw: string | undefined | null;\n\n if (OnboardingState.onboardingCacheValid) {\n const cachedConfig = getOnboardingConfigFromCache();\n const parsedConfig = cachedConfig ? JSON.parse(cachedConfig) : undefined;\n if (parsedConfig) {\n setOnboardingConfigDetails(configFileName, JSON.stringify(parsedConfig));\n return { configFileName, configFileParsed: parsedConfig };\n }\n }\n\n if (configFileName === 'package.json') {\n // We already know it parses\n configFileParsed = JSON.parse(\n // TODO #22198\n (await readLocalFile('package.json', 'utf8'))!,\n ).renovate;\n if (is.string(configFileParsed)) {\n logger.debug('Massaging string renovate config to extends array');\n configFileParsed = { extends: [configFileParsed] };\n }\n logger.debug({ config: configFileParsed }, 'package.json>renovate config');\n } else {\n configFileRaw = await readLocalFile(configFileName, 'utf8');\n // istanbul ignore if\n if (!is.string(configFileRaw)) {\n logger.warn({ configFileName }, 'Null contents when reading config file');\n throw new Error(REPOSITORY_CHANGED);\n }\n // istanbul ignore if\n if (!configFileRaw.length) {\n configFileRaw = '{}';\n }\n\n const parseResult = parseFileConfig(configFileName, configFileRaw);\n\n if (!parseResult.success) {\n return {\n configFileName,\n configFileParseError: {\n validationError: parseResult.validationError,\n validationMessage: parseResult.validationMessage,\n },\n };\n }\n configFileParsed = parseResult.parsedContents;\n logger.debug(\n { fileName: configFileName, config: configFileParsed },\n 'Repository config',\n );\n }\n\n setOnboardingConfigDetails(configFileName, JSON.stringify(configFileParsed));\n return { configFileName, configFileParsed };\n}\n\nexport function checkForRepoConfigError(repoConfig: RepoFileConfig): void {\n if (!repoConfig.configFileParseError) {\n return;\n }\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = repoConfig.configFileName;\n error.validationError = repoConfig.configFileParseError.validationError;\n error.validationMessage = repoConfig.configFileParseError.validationMessage;\n throw error;\n}\n\n// Check for repository config\nexport async function mergeRenovateConfig(\n config: RenovateConfig,\n): Promise<RenovateConfig> {\n let returnConfig = { ...config };\n let repoConfig: RepoFileConfig = {};\n if (config.requireConfig !== 'ignored') {\n repoConfig = await detectRepoFileConfig();\n }\n if (!repoConfig.configFileParsed && config.mode === 'silent') {\n logger.debug(\n 'When mode=silent and repo has no config file, we use the onboarding config as repo config',\n );\n const configFileName = getDefaultConfigFileName(config);\n repoConfig = {\n configFileName,\n configFileParsed: await getOnboardingConfig(config),\n };\n }\n const configFileParsed = repoConfig?.configFileParsed || {};\n if (is.nonEmptyArray(returnConfig.extends)) {\n configFileParsed.extends = [\n ...returnConfig.extends,\n ...(configFileParsed.extends || []),\n ];\n delete returnConfig.extends;\n }\n checkForRepoConfigError(repoConfig);\n const migratedConfig = await migrateAndValidate(config, configFileParsed);\n if (migratedConfig.errors?.length) {\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = repoConfig.configFileName;\n error.validationError =\n 'The renovate configuration file contains some invalid settings';\n error.validationMessage = migratedConfig.errors\n .map((e) => e.message)\n .join(', ');\n throw error;\n }\n if (migratedConfig.warnings) {\n returnConfig.warnings = [\n ...(returnConfig.warnings ?? []),\n ...migratedConfig.warnings,\n ];\n }\n delete migratedConfig.errors;\n delete migratedConfig.warnings;\n // TODO #22198\n const repository = config.repository!;\n // Decrypt before resolving in case we need npm authentication for any presets\n const decryptedConfig = await decryptConfig(migratedConfig, repository);\n // istanbul ignore if\n if (is.string(decryptedConfig.npmrc)) {\n logger.debug('Found npmrc in decrypted config - setting');\n npmApi.setNpmrc(decryptedConfig.npmrc);\n }\n // Decrypt after resolving in case the preset contains npm authentication instead\n let resolvedConfig = await decryptConfig(\n await presets.resolveConfigPresets(\n decryptedConfig,\n config,\n config.ignorePresets,\n ),\n repository,\n );\n logger.trace({ config: resolvedConfig }, 'resolved config');\n const migrationResult = migrateConfig(resolvedConfig);\n if (migrationResult.isMigrated) {\n logger.debug('Resolved config needs migrating');\n logger.trace({ config: resolvedConfig }, 'resolved config after migrating');\n resolvedConfig = migrationResult.migratedConfig;\n }\n // istanbul ignore if\n if (is.string(resolvedConfig.npmrc)) {\n logger.debug(\n 'Ignoring any .npmrc files in repository due to configured npmrc',\n );\n npmApi.setNpmrc(resolvedConfig.npmrc);\n }\n resolvedConfig = applySecretsToConfig(\n resolvedConfig,\n mergeChildConfig(config.secrets ?? {}, resolvedConfig.secrets ?? {}),\n );\n // istanbul ignore if\n if (resolvedConfig.hostRules) {\n logger.debug('Setting hostRules from config');\n for (const rule of resolvedConfig.hostRules) {\n try {\n hostRules.add(rule);\n } catch (err) {\n logger.warn(\n { err, config: rule },\n 'Error setting hostRule from config',\n );\n }\n }\n // host rules can change concurrency\n queue.clear();\n throttle.clear();\n delete resolvedConfig.hostRules;\n }\n returnConfig = mergeChildConfig(returnConfig, resolvedConfig);\n returnConfig = await presets.resolveConfigPresets(returnConfig, config);\n returnConfig.renovateJsonPresent = true;\n // istanbul ignore if\n if (returnConfig.ignorePaths?.length) {\n logger.debug(\n { ignorePaths: returnConfig.ignorePaths },\n `Found repo ignorePaths`,\n );\n }\n return returnConfig;\n}\n"]}
1
+ {"version":3,"file":"merge.js","sourceRoot":"","sources":["../../../../lib/workers/repository/init/merge.ts"],"names":[],"mappings":";;AAqCA,4CAsBC;AAED,oDA+FC;AAED,0DASC;AAGD,kDAiHC;AAGD,gDA2BC;;AAzTD,kEAAkC;AAClC,4CAAmD;AACnD,6DAA8D;AAC9D,qDAAwD;AACxD,uEAAsE;AACtE,yDAA0D;AAC1D,iDAAwD;AACxD,yEAAmD;AACnD,qDAA+D;AAE/D,sEAG2C;AAC3C,4CAAyC;AACzC,gFAA0D;AAC1D,wDAAqD;AACrD,uDAAoD;AACpD,mFAA8E;AAC9E,+DAA0D;AAC1D,iDAAiD;AACjD,yCAAiD;AACjD,4EAAsD;AACtD,wEAAkD;AAClD,8EAAwD;AACxD,6CAA+C;AAC/C,+CAA4C;AAC5C,wDAAkE;AAClE,wDAAuE;AACvE,0FAIsD;AACtD,iDAAuD;AAGhD,KAAK,UAAU,gBAAgB;IACpC,MAAM,QAAQ,GAAG,MAAM,SAAG,CAAC,WAAW,EAAE,CAAC;IACzC,KAAK,MAAM,QAAQ,IAAI,6BAAe,EAAE,CAAC;QACvC,IAAI,QAAQ,KAAK,cAAc,EAAE,CAAC;YAChC,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CACtB,CAAC,MAAM,IAAA,kBAAa,EAAC,cAAc,EAAE,MAAM,CAAC,CAAE,CAC/C,CAAC;gBACF,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;oBACnB,eAAM,CAAC,IAAI,CACT,0GAA0G,CAC3G,CAAC;oBACF,OAAO,cAAc,CAAC;gBACxB,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,aAAa;YACf,CAAC;QACH,CAAC;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvC,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;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,KAAK,CAAC,OAAO,CACjC,IAAA,aAAK,EAAC,MAAM,CAAC,EACb,gBAAgB,KAAK,IAAI,CAC1B,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,QAAQ,CAAC;AACzB,CAAC","sourcesContent":["import is from '@sindresorhus/is';\nimport { mergeChildConfig } from '../../../config';\nimport { configFileNames } from '../../../config/app-strings';\nimport { decryptConfig } from '../../../config/decrypt';\nimport { migrateAndValidate } from '../../../config/migrate-validate';\nimport { migrateConfig } from '../../../config/migration';\nimport { parseFileConfig } from '../../../config/parse';\nimport * as presets from '../../../config/presets';\nimport { applySecretsToConfig } from '../../../config/secrets';\nimport type { RenovateConfig } from '../../../config/types';\nimport {\n CONFIG_VALIDATION,\n REPOSITORY_CHANGED,\n} from '../../../constants/error-messages';\nimport { logger } from '../../../logger';\nimport * as npmApi from '../../../modules/datasource/npm';\nimport { platform } from '../../../modules/platform';\nimport { scm } from '../../../modules/platform/scm';\nimport { ExternalHostError } from '../../../types/errors/external-host-error';\nimport { getCache } from '../../../util/cache/repository';\nimport { parseJson } from '../../../util/common';\nimport { readLocalFile } from '../../../util/fs';\nimport * as hostRules from '../../../util/host-rules';\nimport * as queue from '../../../util/http/queue';\nimport * as throttle from '../../../util/http/throttle';\nimport { maskToken } from '../../../util/mask';\nimport { regEx } from '../../../util/regex';\nimport { getOnboardingConfig } from '../onboarding/branch/config';\nimport { getDefaultConfigFileName } from '../onboarding/branch/create';\nimport {\n getOnboardingConfigFromCache,\n getOnboardingFileNameFromCache,\n setOnboardingConfigDetails,\n} from '../onboarding/branch/onboarding-branch-cache';\nimport { OnboardingState } from '../onboarding/common';\nimport type { RepoFileConfig } from './types';\n\nexport async function detectConfigFile(): Promise<string | null> {\n const fileList = await scm.getFileList();\n for (const fileName of configFileNames) {\n if (fileName === 'package.json') {\n try {\n const pJson = JSON.parse(\n (await readLocalFile('package.json', 'utf8'))!,\n );\n if (pJson.renovate) {\n logger.warn(\n 'Using package.json for Renovate config is deprecated - please use a dedicated configuration file instead',\n );\n return 'package.json';\n }\n } catch {\n // Do nothing\n }\n } else if (fileList.includes(fileName)) {\n return fileName;\n }\n }\n return null;\n}\n\nexport async function detectRepoFileConfig(): Promise<RepoFileConfig> {\n const cache = getCache();\n let { configFileName } = cache;\n if (is.nonEmptyString(configFileName)) {\n let configFileRaw: string | null;\n try {\n configFileRaw = await platform.getRawFile(configFileName);\n } catch (err) {\n // istanbul ignore if\n if (err instanceof ExternalHostError) {\n throw err;\n }\n configFileRaw = null;\n }\n if (configFileRaw) {\n let configFileParsed = parseJson(configFileRaw, configFileName) as any;\n if (configFileName === 'package.json') {\n configFileParsed = configFileParsed.renovate;\n }\n return { configFileName, configFileParsed };\n } else {\n logger.debug('Existing config file no longer exists');\n delete cache.configFileName;\n }\n }\n\n if (OnboardingState.onboardingCacheValid) {\n configFileName = getOnboardingFileNameFromCache();\n } else {\n configFileName = (await detectConfigFile()) ?? undefined;\n }\n\n if (!configFileName) {\n logger.debug('No renovate config file found');\n cache.configFileName = '';\n return {};\n }\n cache.configFileName = configFileName;\n logger.debug(`Found ${configFileName} config file`);\n // TODO #22198\n let configFileParsed: any;\n let configFileRaw: string | undefined | null;\n\n if (OnboardingState.onboardingCacheValid) {\n const cachedConfig = getOnboardingConfigFromCache();\n const parsedConfig = cachedConfig ? JSON.parse(cachedConfig) : undefined;\n if (parsedConfig) {\n setOnboardingConfigDetails(configFileName, JSON.stringify(parsedConfig));\n return { configFileName, configFileParsed: parsedConfig };\n }\n }\n\n if (configFileName === 'package.json') {\n // We already know it parses\n configFileParsed = JSON.parse(\n // TODO #22198\n (await readLocalFile('package.json', 'utf8'))!,\n ).renovate;\n if (is.string(configFileParsed)) {\n logger.debug('Massaging string renovate config to extends array');\n configFileParsed = { extends: [configFileParsed] };\n }\n logger.debug({ config: configFileParsed }, 'package.json>renovate config');\n } else {\n configFileRaw = await readLocalFile(configFileName, 'utf8');\n // istanbul ignore if\n if (!is.string(configFileRaw)) {\n logger.warn({ configFileName }, 'Null contents when reading config file');\n throw new Error(REPOSITORY_CHANGED);\n }\n // istanbul ignore if\n if (!configFileRaw.length) {\n configFileRaw = '{}';\n }\n\n const parseResult = parseFileConfig(configFileName, configFileRaw);\n\n if (!parseResult.success) {\n return {\n configFileName,\n configFileParseError: {\n validationError: parseResult.validationError,\n validationMessage: parseResult.validationMessage,\n },\n };\n }\n configFileParsed = parseResult.parsedContents;\n logger.debug(\n { fileName: configFileName, config: configFileParsed },\n 'Repository config',\n );\n }\n\n setOnboardingConfigDetails(configFileName, JSON.stringify(configFileParsed));\n return { configFileName, configFileParsed };\n}\n\nexport function checkForRepoConfigError(repoConfig: RepoFileConfig): void {\n if (!repoConfig.configFileParseError) {\n return;\n }\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = repoConfig.configFileName;\n error.validationError = repoConfig.configFileParseError.validationError;\n error.validationMessage = repoConfig.configFileParseError.validationMessage;\n throw error;\n}\n\n// Check for repository config\nexport async function mergeRenovateConfig(\n config: RenovateConfig,\n): Promise<RenovateConfig> {\n let returnConfig = { ...config };\n let repoConfig: RepoFileConfig = {};\n if (config.requireConfig !== 'ignored') {\n repoConfig = await detectRepoFileConfig();\n }\n if (!repoConfig.configFileParsed && config.mode === 'silent') {\n logger.debug(\n 'When mode=silent and repo has no config file, we use the onboarding config as repo config',\n );\n const configFileName = getDefaultConfigFileName(config);\n repoConfig = {\n configFileName,\n configFileParsed: await getOnboardingConfig(config),\n };\n }\n const configFileParsed = repoConfig?.configFileParsed || {};\n if (is.nonEmptyArray(returnConfig.extends)) {\n configFileParsed.extends = [\n ...returnConfig.extends,\n ...(configFileParsed.extends || []),\n ];\n delete returnConfig.extends;\n }\n checkForRepoConfigError(repoConfig);\n const migratedConfig = await migrateAndValidate(config, configFileParsed);\n if (migratedConfig.errors?.length) {\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = repoConfig.configFileName;\n error.validationError =\n 'The renovate configuration file contains some invalid settings';\n error.validationMessage = migratedConfig.errors\n .map((e) => e.message)\n .join(', ');\n throw error;\n }\n if (migratedConfig.warnings) {\n returnConfig.warnings = [\n ...(returnConfig.warnings ?? []),\n ...migratedConfig.warnings,\n ];\n }\n delete migratedConfig.errors;\n delete migratedConfig.warnings;\n // TODO #22198\n const repository = config.repository!;\n // Decrypt before resolving in case we need npm authentication for any presets\n const decryptedConfig = await decryptConfig(migratedConfig, repository);\n setNpmTokenInNpmrc(decryptedConfig);\n // istanbul ignore if\n if (is.string(decryptedConfig.npmrc)) {\n logger.debug('Found npmrc in decrypted config - setting');\n npmApi.setNpmrc(decryptedConfig.npmrc);\n }\n // Decrypt after resolving in case the preset contains npm authentication instead\n let resolvedConfig = await decryptConfig(\n await presets.resolveConfigPresets(\n decryptedConfig,\n config,\n config.ignorePresets,\n ),\n repository,\n );\n logger.trace({ config: resolvedConfig }, 'resolved config');\n const migrationResult = migrateConfig(resolvedConfig);\n if (migrationResult.isMigrated) {\n logger.debug('Resolved config needs migrating');\n logger.trace({ config: resolvedConfig }, 'resolved config after migrating');\n resolvedConfig = migrationResult.migratedConfig;\n }\n setNpmTokenInNpmrc(resolvedConfig);\n // istanbul ignore if\n if (is.string(resolvedConfig.npmrc)) {\n logger.debug(\n 'Ignoring any .npmrc files in repository due to configured npmrc',\n );\n npmApi.setNpmrc(resolvedConfig.npmrc);\n }\n resolvedConfig = applySecretsToConfig(\n resolvedConfig,\n mergeChildConfig(config.secrets ?? {}, resolvedConfig.secrets ?? {}),\n );\n // istanbul ignore if\n if (resolvedConfig.hostRules) {\n logger.debug('Setting hostRules from config');\n for (const rule of resolvedConfig.hostRules) {\n try {\n hostRules.add(rule);\n } catch (err) {\n logger.warn(\n { err, config: rule },\n 'Error setting hostRule from config',\n );\n }\n }\n // host rules can change concurrency\n queue.clear();\n throttle.clear();\n delete resolvedConfig.hostRules;\n }\n returnConfig = mergeChildConfig(returnConfig, resolvedConfig);\n returnConfig = await presets.resolveConfigPresets(returnConfig, config);\n returnConfig.renovateJsonPresent = true;\n // istanbul ignore if\n if (returnConfig.ignorePaths?.length) {\n logger.debug(\n { ignorePaths: returnConfig.ignorePaths },\n `Found repo ignorePaths`,\n );\n }\n return returnConfig;\n}\n\n/** needed when using portal secrets for npmToken */\nexport function setNpmTokenInNpmrc(config: RenovateConfig): void {\n if (!is.string(config.npmToken)) {\n return;\n }\n\n const token = config.npmToken;\n logger.debug({ npmToken: maskToken(token) }, 'Migrating npmToken to npmrc');\n\n if (!is.string(config.npmrc)) {\n logger.debug('Adding npmrc to config');\n config.npmrc = `//registry.npmjs.org/:_authToken=${token}\\n`;\n delete config.npmToken;\n return;\n }\n\n if (config.npmrc.includes(`\\${NPM_TOKEN}`)) {\n logger.debug(`Replacing \\${NPM_TOKEN} with npmToken`);\n config.npmrc = config.npmrc.replace(regEx(/\\${NPM_TOKEN}/g), token);\n } else {\n logger.debug('Appending _authToken= to end of existing npmrc');\n config.npmrc = config.npmrc.replace(\n regEx(/\\n?$/),\n `\\n_authToken=${token}\\n`,\n );\n }\n\n delete config.npmToken;\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.7.5",
4
+ "version": "39.7.6",
5
5
  "type": "commonjs",
6
6
  "bin": {
7
7
  "renovate": "dist/renovate.js",