diff --git a/lib/workers/repository/changelog/index.ts b/lib/workers/repository/changelog/index.ts index 270bb1e622b38b18beaabb2ee8ba097bf5a39b9c..b0c0697b1a9ec01fe5ceaab453d790fff48fea95 100644 --- a/lib/workers/repository/changelog/index.ts +++ b/lib/workers/repository/changelog/index.ts @@ -3,7 +3,7 @@ import { getChangeLogJSON } from '../../pr/changelog'; import type { BranchUpgradeConfig } from '../../types'; // istanbul ignore next -async function embedChangelog(upgrade): Promise<void> { +async function embedChangelog(upgrade: BranchUpgradeConfig): Promise<void> { upgrade.logJSON = await getChangeLogJSON(upgrade); // eslint-disable-line } diff --git a/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap b/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap index b5a898d274c43a5e382c9e7e60774433979c7f55..ae7f6b7755724c8f3ce087ac125e952b331b78e3 100644 --- a/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap +++ b/lib/workers/repository/process/lookup/__snapshots__/index.spec.ts.snap @@ -90,6 +90,7 @@ Object { "updateType": "pin", }, ], + "versioning": "npm", "warnings": Array [], } `; @@ -103,6 +104,7 @@ Object { "updateType": "pin", }, ], + "versioning": "npm", "warnings": Array [], } `; @@ -122,6 +124,7 @@ Object { "updateType": "pin", }, ], + "versioning": "npm", "warnings": Array [], } `; @@ -151,6 +154,7 @@ Object { "updateType": "digest", }, ], + "versioning": "npm", "warnings": Array [], } `; @@ -164,6 +168,7 @@ Object { "updateType": "digest", }, ], + "versioning": "npm", "warnings": Array [], } `; @@ -179,6 +184,7 @@ Object { "updateType": "digest", }, ], + "versioning": "git", "warnings": Array [], } `; @@ -209,6 +215,7 @@ Object { "updateType": "major", }, ], + "versioning": "npm", "warnings": Array [], } `; @@ -256,6 +263,7 @@ Marking the latest version of an npm package as deprecated results in the entire "updateType": "minor", }, ], + "versioning": "npm", "warnings": Array [], } `; @@ -301,6 +309,7 @@ Object { "updateType": "minor", }, ], + "versioning": "npm", "warnings": Array [], } `; @@ -449,6 +458,7 @@ Object { "updateType": "minor", }, ], + "versioning": "npm", "warnings": Array [], } `; @@ -765,6 +775,7 @@ Object { "updateType": "major", }, ], + "versioning": "docker", "warnings": Array [], } `; @@ -796,6 +807,7 @@ Object { "updateType": "major", }, ], + "versioning": "docker", "warnings": Array [], } `; @@ -819,6 +831,7 @@ Object { "updateType": "minor", }, ], + "versioning": "docker", "warnings": Array [], } `; @@ -827,6 +840,7 @@ exports[`workers/repository/process/lookup/index .lookupUpdates() skips undefine Object { "skipReason": "invalid-value", "updates": Array [], + "versioning": "npm", "warnings": Array [], } `; @@ -835,6 +849,7 @@ exports[`workers/repository/process/lookup/index .lookupUpdates() skips unsuppor Object { "skipReason": "invalid-value", "updates": Array [], + "versioning": "npm", "warnings": Array [], } `; diff --git a/lib/workers/repository/process/lookup/bucket.ts b/lib/workers/repository/process/lookup/bucket.ts index 8b912a6b98da58d14ffc445cfdea6ebbe3a4b5b5..daa6c5f3842d98ffd1989398905ad9481eea9385 100644 --- a/lib/workers/repository/process/lookup/bucket.ts +++ b/lib/workers/repository/process/lookup/bucket.ts @@ -1,4 +1,4 @@ -import * as allVersioning from '../../../../versioning'; +import type { VersioningApi } from '../../../../versioning/types'; export interface BucketConfig { separateMajorMinor?: boolean; @@ -10,7 +10,7 @@ export function getBucket( config: BucketConfig, currentVersion: string, newVersion: string, - versioning: allVersioning.VersioningApi + versioning: VersioningApi ): string { const { separateMajorMinor, separateMultipleMajor, separateMinorPatch } = config; diff --git a/lib/workers/repository/process/lookup/current.ts b/lib/workers/repository/process/lookup/current.ts index f1364d537e41ad5027e5789fb90dc77ac365a241..dad2de7908c7f8dc205b970cc5276351431e4ce7 100644 --- a/lib/workers/repository/process/lookup/current.ts +++ b/lib/workers/repository/process/lookup/current.ts @@ -1,10 +1,10 @@ import { logger } from '../../../../logger'; -import * as allVersioning from '../../../../versioning'; +import type { VersioningApi } from '../../../../versioning/types'; import type { LookupUpdateConfig } from './types'; export function getCurrentVersion( config: LookupUpdateConfig, - versioning: allVersioning.VersioningApi, + versioning: VersioningApi, rangeStrategy: string, latestVersion: string, allVersions: string[] diff --git a/lib/workers/repository/process/lookup/filter.ts b/lib/workers/repository/process/lookup/filter.ts index 4d59ad3681b383215ab1d9794f5a5447c616afd2..e5c039e8afed3dc8719063288372650093c899a7 100644 --- a/lib/workers/repository/process/lookup/filter.ts +++ b/lib/workers/repository/process/lookup/filter.ts @@ -3,7 +3,7 @@ import { CONFIG_VALIDATION } from '../../../../constants/error-messages'; import type { Release } from '../../../../datasource/types'; import { logger } from '../../../../logger'; import { configRegexPredicate, isConfigRegex } from '../../../../util/regex'; -import * as allVersioning from '../../../../versioning'; +import type { VersioningApi } from '../../../../versioning'; import * as npmVersioning from '../../../../versioning/npm'; import * as pep440 from '../../../../versioning/pep440'; import * as poetryVersioning from '../../../../versioning/poetry'; @@ -13,11 +13,11 @@ export function filterVersions( config: FilterConfig, currentVersion: string, latestVersion: string, - releases: Release[] + releases: Release[], + versioning: VersioningApi ): Release[] { const { ignoreUnstable, ignoreDeprecated, respectLatest, allowedVersions } = config; - let versioning; function isVersionStable(version: string): boolean { if (!versioning.isStable(version)) { return false; @@ -29,7 +29,6 @@ export function filterVersions( } return true; } - versioning = allVersioning.get(config.versioning); if (!currentVersion) { return []; } diff --git a/lib/workers/repository/process/lookup/index.ts b/lib/workers/repository/process/lookup/index.ts index 9f5f226bf6ee189e5f42d47f269bc85d3df67c3d..b60c91f4ba87d807c8deb61d9cc6065b7207d389 100644 --- a/lib/workers/repository/process/lookup/index.ts +++ b/lib/workers/repository/process/lookup/index.ts @@ -42,10 +42,13 @@ export async function lookupUpdates( } = config; logger.trace({ dependency: depName, currentValue }, 'lookupUpdates'); // Use the datasource's default versioning if none is configured - const versioning = allVersioning.get( - config.versioning || getDefaultVersioning(datasource) - ); - const res: UpdateResult = { updates: [], warnings: [] } as any; + config.versioning ??= getDefaultVersioning(datasource); + const versioning = allVersioning.get(config.versioning); + const res: UpdateResult = { + updates: [], + warnings: [], + versioning: config.versioning, + } as any; // istanbul ignore if if ( !isGetPkgReleasesConfig(config) || @@ -115,7 +118,7 @@ export async function lookupUpdates( versioning.matches(v.version, currentValue) ); if (rollbackPrs && !allSatisfyingVersions.length) { - const rollback = getRollbackUpdate(config, allVersions); + const rollback = getRollbackUpdate(config, allVersions, versioning); // istanbul ignore if if (!rollback) { res.warnings.push({ @@ -185,7 +188,8 @@ export async function lookupUpdates( config, filterStart, latestVersion, - allVersions + allVersions, + versioning ).filter((v) => // Leave only compatible versions versioning.isCompatible(v.version, currentValue) diff --git a/lib/workers/repository/process/lookup/rollback.ts b/lib/workers/repository/process/lookup/rollback.ts index 318cd1269951a4cef1f7dea6f2bf1ddf522d1728..847091daa8e474c1980df53c91e29476dca3706e 100644 --- a/lib/workers/repository/process/lookup/rollback.ts +++ b/lib/workers/repository/process/lookup/rollback.ts @@ -1,15 +1,15 @@ import type { Release } from '../../../../datasource/types'; import { logger } from '../../../../logger'; import type { LookupUpdate } from '../../../../manager/types'; -import * as allVersioning from '../../../../versioning'; +import type { VersioningApi } from '../../../../versioning'; import type { RollbackConfig } from './types'; export function getRollbackUpdate( config: RollbackConfig, - versions: Release[] + versions: Release[], + version: VersioningApi ): LookupUpdate { const { packageFile, versioning, depName, currentValue } = config; - const version = allVersioning.get(versioning); // istanbul ignore if if (!('isLessThanRange' in version)) { logger.debug( diff --git a/lib/workers/repository/process/lookup/types.ts b/lib/workers/repository/process/lookup/types.ts index b81c2166c8840a7be5a3b71526aeaced9c2c221f..176f8667df91d83a071f9a0c1e506f97f7b03306 100644 --- a/lib/workers/repository/process/lookup/types.ts +++ b/lib/workers/repository/process/lookup/types.ts @@ -55,4 +55,6 @@ export interface UpdateResult { fixedVersion?: string; updates: LookupUpdate[]; warnings: ValidationMessage[]; + + versioning: string; }