renovate 44.62.0 → 44.62.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.
@@ -1,6 +1,7 @@
1
1
  import { regEx } from "../../../../util/regex.js";
2
2
  import { coerceArray } from "../../../../util/array.js";
3
3
  import { matchRegexOrGlobList } from "../../../../util/string-match.js";
4
+ import { safeStringify } from "../../../../util/stringify.js";
4
5
  import { logger } from "../../../../logger/index.js";
5
6
  import { compile } from "../../../../util/template/index.js";
6
7
  import { readLocalFile } from "../../../../util/fs/index.js";
@@ -9,8 +10,8 @@ import { getFilteredFileList } from "../../extract/file-match.js";
9
10
  import { inc } from "semver";
10
11
  //#region lib/workers/repository/update/branch/bump-versions.ts
11
12
  async function bumpVersions(config) {
12
- const bumpVersions = config.bumpVersions;
13
- if (!bumpVersions?.length) return;
13
+ const bumpVersions = getBumpVersions(config);
14
+ if (!bumpVersions.length) return;
14
15
  if (!config.updatedPackageFiles?.length && !config.updatedArtifacts?.length) return;
15
16
  const allFiles = await scm.getFileList();
16
17
  const fileList = getFilteredFileList(config, allFiles);
@@ -20,6 +21,26 @@ async function bumpVersions(config) {
20
21
  config.updatedPackageFiles = Object.values(packageFileChanges).flat();
21
22
  config.updatedArtifacts = Object.values(artifactFileChanges).flat();
22
23
  }
24
+ /**
25
+ * `config.bumpVersions` is derived from `upgrades[0]` only (see `generateBranchConfig()`), so
26
+ * relying on it alone would silently drop `bumpVersions` config attached (e.g. via a `packageRule`)
27
+ * to any upgrade other than the first one in the branch. Collect `bumpVersions` from every
28
+ * upgrade instead, de-duplicating identical entries, and fall back to the top-level value for
29
+ * back-compat (e.g. when `config.upgrades` is empty).
30
+ */
31
+ function getBumpVersions(config) {
32
+ const seen = /* @__PURE__ */ new Set();
33
+ const bumpVersions = [];
34
+ for (const upgrade of coerceArray(config.upgrades)) for (const bumpVersionConfig of coerceArray(upgrade.bumpVersions)) {
35
+ const key = safeStringify(bumpVersionConfig);
36
+ if (!seen.has(key)) {
37
+ seen.add(key);
38
+ bumpVersions.push(bumpVersionConfig);
39
+ }
40
+ }
41
+ if (!bumpVersions.length) bumpVersions.push(...coerceArray(config.bumpVersions));
42
+ return bumpVersions;
43
+ }
23
44
  async function bumpVersion(config, branchConfig, fileList, packageFiles, artifactFiles) {
24
45
  const rawBumpType = config.bumpType ?? "patch";
25
46
  const bumpVersionsDescr = config.name ? `bumpVersions(${config.name})` : "bumpVersions";
@@ -1 +1 @@
1
- {"version":3,"file":"bump-versions.js","names":[],"sources":["../../../../../lib/workers/repository/update/branch/bump-versions.ts"],"sourcesContent":["import { type ReleaseType, inc } from 'semver';\nimport type { BumpVersionConfig } from '../../../../config/types.ts';\nimport { logger } from '../../../../logger/index.ts';\nimport { scm } from '../../../../modules/platform/scm.ts';\nimport { coerceArray } from '../../../../util/array.ts';\nimport { readLocalFile } from '../../../../util/fs/index.ts';\nimport type { FileChange } from '../../../../util/git/types.ts';\nimport { regEx } from '../../../../util/regex.ts';\nimport { matchRegexOrGlobList } from '../../../../util/string-match.ts';\nimport { compile } from '../../../../util/template/index.ts';\nimport type { BranchConfig } from '../../../types.ts';\nimport { getFilteredFileList } from '../../extract/file-match.ts';\n\ntype ParseFileChangesResult =\n | { state: 'modified'; content: string | null }\n | { state: 'deleted' }\n | { state: 'unmodified' };\n\nexport async function bumpVersions(config: BranchConfig): Promise<void> {\n const bumpVersions = config.bumpVersions;\n if (!bumpVersions?.length) {\n return;\n }\n\n // skip if no packageFiles or artifacts have been updated\n if (!config.updatedPackageFiles?.length && !config.updatedArtifacts?.length) {\n return;\n }\n\n const allFiles = await scm.getFileList();\n const fileList = getFilteredFileList(config, allFiles);\n\n const packageFileChanges = fileChangeListToMap(config.updatedPackageFiles);\n const artifactFileChanges = fileChangeListToMap(config.updatedArtifacts);\n\n for (const bumpVersionConfig of bumpVersions) {\n await bumpVersion(\n bumpVersionConfig,\n config,\n fileList,\n packageFileChanges,\n artifactFileChanges,\n );\n }\n\n // update the config with the new files\n config.updatedPackageFiles = Object.values(packageFileChanges).flat();\n config.updatedArtifacts = Object.values(artifactFileChanges).flat();\n}\n\nasync function bumpVersion(\n config: BumpVersionConfig,\n branchConfig: BranchConfig,\n fileList: string[],\n packageFiles: Record<string, FileChange[]>,\n artifactFiles: Record<string, FileChange[]>,\n): Promise<void> {\n const rawBumpType = config.bumpType ?? 'patch';\n\n // all log messages should be prefixed with this string to facilitate easier logLevelRemapping\n const bumpVersionsDescr = config.name\n ? `bumpVersions(${config.name})`\n : 'bumpVersions';\n\n const files: string[] = [];\n try {\n files.push(\n ...getMatchedFiles(\n bumpVersionsDescr,\n config.filePatterns,\n branchConfig,\n fileList,\n ),\n );\n } catch (e) {\n addArtifactError(\n branchConfig,\n `Failed to calculate matched files for bumpVersions: ${e.message}`,\n );\n return;\n }\n\n if (!files.length) {\n logger.debug(`${bumpVersionsDescr}: filePatterns did not match any files`);\n return;\n }\n\n logger.trace(\n { files },\n `${bumpVersionsDescr}: Found ${files.length} files to bump versions`,\n );\n\n // keeping this only for logging purposes\n const matchStrings: string[] = [];\n\n // prepare the matchStrings\n const matchStringsRegexes: RegExp[] = [];\n for (const matchString of config.matchStrings) {\n try {\n const templated = compile(matchString, branchConfig);\n matchStrings.push(templated);\n matchStringsRegexes.push(regEx(templated));\n } catch (e) {\n addArtifactError(\n branchConfig,\n `Failed to compile matchString for ${bumpVersionsDescr}: ${e.message}`,\n matchString,\n );\n }\n }\n\n logger.trace({ matchStrings }, `${bumpVersionsDescr}: Compiled matchStrings`);\n\n for (const filePath of files) {\n let fileBumped = false;\n\n const fileContents = await getFileContent(\n bumpVersionsDescr,\n filePath,\n packageFiles,\n artifactFiles,\n );\n if (!fileContents) {\n continue;\n }\n\n for (const matchStringRegex of matchStringsRegexes) {\n // extracting the version from the file\n const regexResult = matchStringRegex.exec(fileContents);\n if (!regexResult) {\n continue;\n }\n const version = regexResult.groups?.version;\n if (!version) {\n logger.debug(\n { file: filePath },\n `${bumpVersionsDescr}: No version found`,\n );\n continue;\n }\n\n // getting new version\n let newVersion: string | null = null;\n try {\n const bumpType = compile(rawBumpType, branchConfig);\n\n // Handle 'sync' type - use version from branch upgrades\n if (bumpType === 'sync') {\n if (branchConfig.upgrades?.length) {\n // Use the newVersion from the first upgrade\n newVersion = branchConfig.upgrades[0].newVersion ?? null;\n if (!newVersion) {\n logger.debug(\n { file: filePath },\n `${bumpVersionsDescr}: No newVersion found in branch upgrades for sync type`,\n );\n continue;\n }\n } else {\n logger.debug(\n { file: filePath },\n `${bumpVersionsDescr}: No upgrades found in branch config for sync type`,\n );\n continue;\n }\n } else {\n // Existing logic for major/minor/patch\n const parts = regEx('^(?<major>\\\\d+)(?:\\\\.(?<minor>\\\\d+))?$').exec(\n version,\n );\n if (parts?.groups) {\n const { major, minor } = parts.groups;\n if (bumpType === 'major') {\n newVersion = `${parseInt(major, 10) + 1}${minor ? `.0` : ''}`;\n } else if (bumpType === 'minor') {\n newVersion = `${major}.${parseInt(minor, 10) + 1}`;\n } else {\n throw new Error(\n `Unsupported bump type for {major}.{minor} version: ${bumpType}`,\n );\n }\n } else {\n newVersion = inc(version, bumpType as ReleaseType);\n }\n }\n } catch (e) {\n addArtifactError(\n branchConfig,\n `Failed to calculate new version for ${bumpVersionsDescr}: ${e.message}`,\n filePath,\n );\n }\n if (!newVersion) {\n logger.debug(\n { file: filePath },\n `${bumpVersionsDescr}: Could not bump version`,\n );\n continue;\n }\n\n // replace the content of the `version` group with newVersion\n const newFileContents: string = fileContents\n .toString()\n .replace(matchStringRegex, (match, ...groups) => {\n const { version } = groups.pop();\n return match.replace(version, newVersion);\n });\n\n // update the file. Add it to the buckets if exists or create a new artifact update\n if (packageFiles[filePath]) {\n packageFiles[filePath].push({\n type: 'addition',\n path: filePath,\n contents: newFileContents,\n });\n } else {\n artifactFiles[filePath] ??= [];\n artifactFiles[filePath].push({\n type: 'addition',\n path: filePath,\n contents: newFileContents,\n });\n }\n\n fileBumped = true;\n }\n\n if (!fileBumped) {\n logger.debug(\n { file: filePath },\n `${bumpVersionsDescr}: No match found for bumping version`,\n );\n }\n }\n}\n\n/**\n * Get files that match ANY of the fileMatches pattern. fileMatches are compiled with the branchConfig.\n * @param bumpVersionsDescr log description for the bump version config\n * @param filePatternTemplates list of regex patterns\n * @param branchConfig compile metadata\n * @param fileList list of files to match against\n */\nfunction getMatchedFiles(\n bumpVersionsDescr: string,\n filePatternTemplates: string[],\n branchConfig: BranchConfig,\n fileList: string[],\n): string[] {\n // prepare file regex\n const filePatterns: string[] = [];\n for (const filePatternTemplateElement of filePatternTemplates) {\n const filePattern = compile(filePatternTemplateElement, branchConfig);\n filePatterns.push(filePattern);\n }\n\n logger.trace({ filePatterns }, `${bumpVersionsDescr}: Compiled filePatterns`);\n\n // get files that match the fileMatch\n const files: string[] = [];\n for (const file of fileList) {\n if (matchRegexOrGlobList(file, filePatterns)) {\n files.push(file);\n }\n }\n return files;\n}\n\nfunction fileChangeListToMap(\n list: FileChange[] | undefined,\n): Record<string, FileChange[]> {\n const record: Record<string, FileChange[]> = {};\n for (const fileChange of coerceArray(list)) {\n record[fileChange.path] ??= [];\n record[fileChange.path].push(fileChange);\n }\n return record;\n}\n\nfunction addArtifactError(\n branchConfig: BranchConfig,\n message: string,\n fileName?: string,\n): void {\n branchConfig.artifactErrors ??= [];\n branchConfig.artifactErrors.push({\n stderr: message,\n fileName,\n });\n}\n\nasync function getFileContent(\n bumpVersionsDescr: string,\n filePath: string,\n packageFiles: Record<string, FileChange[]>,\n artifactFiles: Record<string, FileChange[]>,\n): Promise<string | null> {\n const packageFileChanges = parseFileChanges(filePath, packageFiles);\n const artifactFileChanges = parseFileChanges(filePath, artifactFiles);\n\n // skip if the file is deleted as it virtually doesn't exist\n if (\n packageFileChanges.state === 'deleted' ||\n artifactFileChanges.state === 'deleted'\n ) {\n return null;\n }\n\n if (packageFileChanges.state === 'modified') {\n const lastChange = packageFileChanges.content;\n if (lastChange) {\n return lastChange;\n }\n }\n if (artifactFileChanges.state === 'modified') {\n const lastChange = artifactFileChanges.content;\n if (lastChange) {\n return lastChange;\n }\n }\n\n try {\n return await readLocalFile(filePath, 'utf8');\n } catch (e) {\n logger.warn(\n { file: filePath, bumpVersionsDescr, err: e },\n 'bumpVersions: Could not read file',\n );\n return null;\n }\n}\n\nfunction parseFileChanges(\n filePath: string,\n changeRecord: Record<string, FileChange[]>,\n): ParseFileChangesResult {\n const changes = coerceArray(changeRecord[filePath]);\n\n // skip if we can fetch from record\n if (!changes.length) {\n return { state: 'unmodified' };\n }\n\n const lastChange = changes.at(-1)!;\n if (lastChange.type === 'deletion') {\n return { state: 'deleted' };\n }\n return {\n state: 'modified',\n content: lastChange.contents?.toString() ?? null,\n };\n}\n"],"mappings":";;;;;;;;;;AAkBA,eAAsB,aAAa,QAAqC;CACtE,MAAM,eAAe,OAAO;CAC5B,IAAI,CAAC,cAAc,QACjB;CAIF,IAAI,CAAC,OAAO,qBAAqB,UAAU,CAAC,OAAO,kBAAkB,QACnE;CAGF,MAAM,WAAW,MAAM,IAAI,YAAY;CACvC,MAAM,WAAW,oBAAoB,QAAQ,QAAQ;CAErD,MAAM,qBAAqB,oBAAoB,OAAO,mBAAmB;CACzE,MAAM,sBAAsB,oBAAoB,OAAO,gBAAgB;CAEvE,KAAK,MAAM,qBAAqB,cAC9B,MAAM,YACJ,mBACA,QACA,UACA,oBACA,mBACF;CAIF,OAAO,sBAAsB,OAAO,OAAO,kBAAkB,CAAC,CAAC,KAAK;CACpE,OAAO,mBAAmB,OAAO,OAAO,mBAAmB,CAAC,CAAC,KAAK;AACpE;AAEA,eAAe,YACb,QACA,cACA,UACA,cACA,eACe;CACf,MAAM,cAAc,OAAO,YAAY;CAGvC,MAAM,oBAAoB,OAAO,OAC7B,gBAAgB,OAAO,KAAK,KAC5B;CAEJ,MAAM,QAAkB,CAAC;CACzB,IAAI;EACF,MAAM,KACJ,GAAG,gBACD,mBACA,OAAO,cACP,cACA,QACF,CACF;CACF,SAAS,GAAG;EACV,iBACE,cACA,uDAAuD,EAA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"version":3,"file":"bump-versions.js","names":[],"sources":["../../../../../lib/workers/repository/update/branch/bump-versions.ts"],"sourcesContent":["import { type ReleaseType, inc } from 'semver';\nimport type { BumpVersionConfig } from '../../../../config/types.ts';\nimport { logger } from '../../../../logger/index.ts';\nimport { scm } from '../../../../modules/platform/scm.ts';\nimport { coerceArray } from '../../../../util/array.ts';\nimport { readLocalFile } from '../../../../util/fs/index.ts';\nimport type { FileChange } from '../../../../util/git/types.ts';\nimport { regEx } from '../../../../util/regex.ts';\nimport { matchRegexOrGlobList } from '../../../../util/string-match.ts';\nimport { safeStringify } from '../../../../util/stringify.ts';\nimport { compile } from '../../../../util/template/index.ts';\nimport type { BranchConfig } from '../../../types.ts';\nimport { getFilteredFileList } from '../../extract/file-match.ts';\n\ntype ParseFileChangesResult =\n | { state: 'modified'; content: string | null }\n | { state: 'deleted' }\n | { state: 'unmodified' };\n\nexport async function bumpVersions(config: BranchConfig): Promise<void> {\n const bumpVersions = getBumpVersions(config);\n if (!bumpVersions.length) {\n return;\n }\n\n // skip if no packageFiles or artifacts have been updated\n if (!config.updatedPackageFiles?.length && !config.updatedArtifacts?.length) {\n return;\n }\n\n const allFiles = await scm.getFileList();\n const fileList = getFilteredFileList(config, allFiles);\n\n const packageFileChanges = fileChangeListToMap(config.updatedPackageFiles);\n const artifactFileChanges = fileChangeListToMap(config.updatedArtifacts);\n\n for (const bumpVersionConfig of bumpVersions) {\n await bumpVersion(\n bumpVersionConfig,\n config,\n fileList,\n packageFileChanges,\n artifactFileChanges,\n );\n }\n\n // update the config with the new files\n config.updatedPackageFiles = Object.values(packageFileChanges).flat();\n config.updatedArtifacts = Object.values(artifactFileChanges).flat();\n}\n\n/**\n * `config.bumpVersions` is derived from `upgrades[0]` only (see `generateBranchConfig()`), so\n * relying on it alone would silently drop `bumpVersions` config attached (e.g. via a `packageRule`)\n * to any upgrade other than the first one in the branch. Collect `bumpVersions` from every\n * upgrade instead, de-duplicating identical entries, and fall back to the top-level value for\n * back-compat (e.g. when `config.upgrades` is empty).\n */\nfunction getBumpVersions(config: BranchConfig): BumpVersionConfig[] {\n const seen = new Set<string>();\n const bumpVersions: BumpVersionConfig[] = [];\n for (const upgrade of coerceArray(config.upgrades)) {\n for (const bumpVersionConfig of coerceArray(upgrade.bumpVersions)) {\n const key = safeStringify(bumpVersionConfig);\n if (!seen.has(key)) {\n seen.add(key);\n bumpVersions.push(bumpVersionConfig);\n }\n }\n }\n\n if (!bumpVersions.length) {\n bumpVersions.push(...coerceArray(config.bumpVersions));\n }\n\n return bumpVersions;\n}\n\nasync function bumpVersion(\n config: BumpVersionConfig,\n branchConfig: BranchConfig,\n fileList: string[],\n packageFiles: Record<string, FileChange[]>,\n artifactFiles: Record<string, FileChange[]>,\n): Promise<void> {\n const rawBumpType = config.bumpType ?? 'patch';\n\n // all log messages should be prefixed with this string to facilitate easier logLevelRemapping\n const bumpVersionsDescr = config.name\n ? `bumpVersions(${config.name})`\n : 'bumpVersions';\n\n const files: string[] = [];\n try {\n files.push(\n ...getMatchedFiles(\n bumpVersionsDescr,\n config.filePatterns,\n branchConfig,\n fileList,\n ),\n );\n } catch (e) {\n addArtifactError(\n branchConfig,\n `Failed to calculate matched files for bumpVersions: ${e.message}`,\n );\n return;\n }\n\n if (!files.length) {\n logger.debug(`${bumpVersionsDescr}: filePatterns did not match any files`);\n return;\n }\n\n logger.trace(\n { files },\n `${bumpVersionsDescr}: Found ${files.length} files to bump versions`,\n );\n\n // keeping this only for logging purposes\n const matchStrings: string[] = [];\n\n // prepare the matchStrings\n const matchStringsRegexes: RegExp[] = [];\n for (const matchString of config.matchStrings) {\n try {\n const templated = compile(matchString, branchConfig);\n matchStrings.push(templated);\n matchStringsRegexes.push(regEx(templated));\n } catch (e) {\n addArtifactError(\n branchConfig,\n `Failed to compile matchString for ${bumpVersionsDescr}: ${e.message}`,\n matchString,\n );\n }\n }\n\n logger.trace({ matchStrings }, `${bumpVersionsDescr}: Compiled matchStrings`);\n\n for (const filePath of files) {\n let fileBumped = false;\n\n const fileContents = await getFileContent(\n bumpVersionsDescr,\n filePath,\n packageFiles,\n artifactFiles,\n );\n if (!fileContents) {\n continue;\n }\n\n for (const matchStringRegex of matchStringsRegexes) {\n // extracting the version from the file\n const regexResult = matchStringRegex.exec(fileContents);\n if (!regexResult) {\n continue;\n }\n const version = regexResult.groups?.version;\n if (!version) {\n logger.debug(\n { file: filePath },\n `${bumpVersionsDescr}: No version found`,\n );\n continue;\n }\n\n // getting new version\n let newVersion: string | null = null;\n try {\n const bumpType = compile(rawBumpType, branchConfig);\n\n // Handle 'sync' type - use version from branch upgrades\n if (bumpType === 'sync') {\n if (branchConfig.upgrades?.length) {\n // Use the newVersion from the first upgrade\n newVersion = branchConfig.upgrades[0].newVersion ?? null;\n if (!newVersion) {\n logger.debug(\n { file: filePath },\n `${bumpVersionsDescr}: No newVersion found in branch upgrades for sync type`,\n );\n continue;\n }\n } else {\n logger.debug(\n { file: filePath },\n `${bumpVersionsDescr}: No upgrades found in branch config for sync type`,\n );\n continue;\n }\n } else {\n // Existing logic for major/minor/patch\n const parts = regEx('^(?<major>\\\\d+)(?:\\\\.(?<minor>\\\\d+))?$').exec(\n version,\n );\n if (parts?.groups) {\n const { major, minor } = parts.groups;\n if (bumpType === 'major') {\n newVersion = `${parseInt(major, 10) + 1}${minor ? `.0` : ''}`;\n } else if (bumpType === 'minor') {\n newVersion = `${major}.${parseInt(minor, 10) + 1}`;\n } else {\n throw new Error(\n `Unsupported bump type for {major}.{minor} version: ${bumpType}`,\n );\n }\n } else {\n newVersion = inc(version, bumpType as ReleaseType);\n }\n }\n } catch (e) {\n addArtifactError(\n branchConfig,\n `Failed to calculate new version for ${bumpVersionsDescr}: ${e.message}`,\n filePath,\n );\n }\n if (!newVersion) {\n logger.debug(\n { file: filePath },\n `${bumpVersionsDescr}: Could not bump version`,\n );\n continue;\n }\n\n // replace the content of the `version` group with newVersion\n const newFileContents: string = fileContents\n .toString()\n .replace(matchStringRegex, (match, ...groups) => {\n const { version } = groups.pop();\n return match.replace(version, newVersion);\n });\n\n // update the file. Add it to the buckets if exists or create a new artifact update\n if (packageFiles[filePath]) {\n packageFiles[filePath].push({\n type: 'addition',\n path: filePath,\n contents: newFileContents,\n });\n } else {\n artifactFiles[filePath] ??= [];\n artifactFiles[filePath].push({\n type: 'addition',\n path: filePath,\n contents: newFileContents,\n });\n }\n\n fileBumped = true;\n }\n\n if (!fileBumped) {\n logger.debug(\n { file: filePath },\n `${bumpVersionsDescr}: No match found for bumping version`,\n );\n }\n }\n}\n\n/**\n * Get files that match ANY of the fileMatches pattern. fileMatches are compiled with the branchConfig.\n * @param bumpVersionsDescr log description for the bump version config\n * @param filePatternTemplates list of regex patterns\n * @param branchConfig compile metadata\n * @param fileList list of files to match against\n */\nfunction getMatchedFiles(\n bumpVersionsDescr: string,\n filePatternTemplates: string[],\n branchConfig: BranchConfig,\n fileList: string[],\n): string[] {\n // prepare file regex\n const filePatterns: string[] = [];\n for (const filePatternTemplateElement of filePatternTemplates) {\n const filePattern = compile(filePatternTemplateElement, branchConfig);\n filePatterns.push(filePattern);\n }\n\n logger.trace({ filePatterns }, `${bumpVersionsDescr}: Compiled filePatterns`);\n\n // get files that match the fileMatch\n const files: string[] = [];\n for (const file of fileList) {\n if (matchRegexOrGlobList(file, filePatterns)) {\n files.push(file);\n }\n }\n return files;\n}\n\nfunction fileChangeListToMap(\n list: FileChange[] | undefined,\n): Record<string, FileChange[]> {\n const record: Record<string, FileChange[]> = {};\n for (const fileChange of coerceArray(list)) {\n record[fileChange.path] ??= [];\n record[fileChange.path].push(fileChange);\n }\n return record;\n}\n\nfunction addArtifactError(\n branchConfig: BranchConfig,\n message: string,\n fileName?: string,\n): void {\n branchConfig.artifactErrors ??= [];\n branchConfig.artifactErrors.push({\n stderr: message,\n fileName,\n });\n}\n\nasync function getFileContent(\n bumpVersionsDescr: string,\n filePath: string,\n packageFiles: Record<string, FileChange[]>,\n artifactFiles: Record<string, FileChange[]>,\n): Promise<string | null> {\n const packageFileChanges = parseFileChanges(filePath, packageFiles);\n const artifactFileChanges = parseFileChanges(filePath, artifactFiles);\n\n // skip if the file is deleted as it virtually doesn't exist\n if (\n packageFileChanges.state === 'deleted' ||\n artifactFileChanges.state === 'deleted'\n ) {\n return null;\n }\n\n if (packageFileChanges.state === 'modified') {\n const lastChange = packageFileChanges.content;\n if (lastChange) {\n return lastChange;\n }\n }\n if (artifactFileChanges.state === 'modified') {\n const lastChange = artifactFileChanges.content;\n if (lastChange) {\n return lastChange;\n }\n }\n\n try {\n return await readLocalFile(filePath, 'utf8');\n } catch (e) {\n logger.warn(\n { file: filePath, bumpVersionsDescr, err: e },\n 'bumpVersions: Could not read file',\n );\n return null;\n }\n}\n\nfunction parseFileChanges(\n filePath: string,\n changeRecord: Record<string, FileChange[]>,\n): ParseFileChangesResult {\n const changes = coerceArray(changeRecord[filePath]);\n\n // skip if we can fetch from record\n if (!changes.length) {\n return { state: 'unmodified' };\n }\n\n const lastChange = changes.at(-1)!;\n if (lastChange.type === 'deletion') {\n return { state: 'deleted' };\n }\n return {\n state: 'modified',\n content: lastChange.contents?.toString() ?? null,\n };\n}\n"],"mappings":";;;;;;;;;;;AAmBA,eAAsB,aAAa,QAAqC;CACtE,MAAM,eAAe,gBAAgB,MAAM;CAC3C,IAAI,CAAC,aAAa,QAChB;CAIF,IAAI,CAAC,OAAO,qBAAqB,UAAU,CAAC,OAAO,kBAAkB,QACnE;CAGF,MAAM,WAAW,MAAM,IAAI,YAAY;CACvC,MAAM,WAAW,oBAAoB,QAAQ,QAAQ;CAErD,MAAM,qBAAqB,oBAAoB,OAAO,mBAAmB;CACzE,MAAM,sBAAsB,oBAAoB,OAAO,gBAAgB;CAEvE,KAAK,MAAM,qBAAqB,cAC9B,MAAM,YACJ,mBACA,QACA,UACA,oBACA,mBACF;CAIF,OAAO,sBAAsB,OAAO,OAAO,kBAAkB,CAAC,CAAC,KAAK;CACpE,OAAO,mBAAmB,OAAO,OAAO,mBAAmB,CAAC,CAAC,KAAK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AiB,UAAU,aAAa;CAGpE,IACE,mBAAmB,UAAU,aAC7B,oBAAoB,UAAU,WAE9B,OAAO;CAGT,IAAI,mBAAmB,UAAU,YAAY;EAC3C,MAAM,aAAa,mBAAmB;EACtC,IAAI,YACF,OAAO;CAEX;CACA,IAAI,oBAAoB,UAAU,YAAY;EAC5C,MAAM,aAAa,oBAAoB;EACvC,IAAI,YACF,OAAO;CAEX;CAEA,IAAI;EACF,OAAO,MAAM,cAAc,UAAU,MAAM;CAC7C,SAAS,GAAG;EACV,OAAO,KACL;GAAE,MAAM;GAAU;GAAmB,KAAK;EAAE,GAC5C,mCACF;EACA,OAAO;CACT;AACF;AAEA,SAAS,iBACP,UACA,cACwB;CACxB,MAAM,UAAU,YAAY,aAAa,SAAS;CAGlD,IAAI,CAAC,QAAQ,QACX,OAAO,EAAE,OAAO,aAAa;CAG/B,MAAM,aAAa,QAAQ,GAAG,EAAE;CAChC,IAAI,WAAW,SAAS,YACtB,OAAO,EAAE,OAAO,UAAU;CAE5B,OAAO;EACL,OAAO;EACP,SAAS,WAAW,UAAU,SAAS,KAAK;CAC9C;AACF"}
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": "44.62.0",
4
+ "version": "44.62.1",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "renovate": "dist/renovate.js",
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$id": "https://docs.renovatebot.com/renovate-schema.json",
3
- "title": "JSON schema for Renovate 44.62.0 config files (https://renovatebot.com/)",
3
+ "title": "JSON schema for Renovate 44.62.1 config files (https://renovatebot.com/)",
4
4
  "$schema": "http://json-schema.org/draft-07/schema#",
5
- "x-renovate-version": "44.62.0",
5
+ "x-renovate-version": "44.62.1",
6
6
  "allowComments": true,
7
7
  "type": "object",
8
8
  "definitions": {