0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-03-16 00:54:53 +00:00

feat: currentVersionAgeInDays, newVersionAgeInDays ()

This commit is contained in:
Rhys Arkins 2024-10-10 15:17:31 +02:00 committed by GitHub
parent b7e5adb0b0
commit a021e9fe6d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 173 additions and 30 deletions
docs/usage
lib
config
modules/manager
util
workers/repository/process/lookup

View file

@ -2869,6 +2869,7 @@ Here are some example `matchJsonata` strings for inspiration:
$exists(deprecationMessage)
$exists(vulnerabilityFixVersion)
manager = 'dockerfile' and depType = 'final'
updateType = 'major' and newVersionAgeInDays < 7
```
`matchJsonata` accepts an array of strings, and will return `true` if any of those JSONata expressions evaluate to `true`.

View file

@ -548,6 +548,7 @@ export interface PackageRuleInputConfig extends Record<string, unknown> {
packageRules?: (PackageRule & PackageRuleInputConfig)[];
releaseTimestamp?: string | null;
repository?: string;
currentVersionAgeInDays?: number;
currentVersionTimestamp?: string;
enabled?: boolean;
skipReason?: SkipReason;

View file

@ -99,6 +99,7 @@ export interface LookupUpdate {
checksumUrl?: string;
downloadUrl?: string;
releaseTimestamp?: any;
newVersionAgeInDays?: number;
registryUrl?: string;
}

View file

@ -22,6 +22,11 @@ describe('util/date', () => {
const t = t0.minus({ days: 42 });
expect(getElapsedDays(t.toISO()!)).toBe(42);
});
it('rounds down', () => {
const t = t0.minus({ days: 42, hours: 12 });
expect(getElapsedDays(t.toISO()!)).toBe(42);
});
});
describe('getElapsedMinutes', () => {

View file

@ -1,12 +1,13 @@
import { DateTime } from 'luxon';
const ONE_MINUTE_MS = 60 * 1000;
const ONE_DAY_MS = 24 * 60 * ONE_MINUTE_MS;
export function getElapsedDays(timestamp: string): number {
return Math.floor(
(new Date().getTime() - new Date(timestamp).getTime()) / ONE_DAY_MS,
);
const currentVersionTimestampDate = DateTime.fromISO(timestamp);
const now = DateTime.now();
const diffInDays = now.diff(currentVersionTimestampDate, 'days').as('days');
const ageInDays = Math.floor(diffInDays);
return ageInDays;
}
export function getElapsedMinutes(date: Date): number {

View file

@ -156,6 +156,7 @@ export const allowedFields = {
currentValue: 'The extracted current value of the dependency being updated',
currentVersion:
'The version that would be currently installed. For example, if currentValue is ^3.0.0 then currentVersion might be 3.1.0.',
currentVersionAgeInDays: 'The age of the current version in days',
currentVersionTimestamp: 'The timestamp of the current version',
currentDigest: 'The extracted current digest of the dependency being updated',
currentDigestShort:
@ -203,6 +204,7 @@ export const allowedFields = {
newValue:
'The new value in the upgrade. Can be a range or version e.g. "^3.0.0" or "3.1.0"',
newVersion: 'The new version in the upgrade, e.g. "3.1.0"',
newVersionAgeInDays: 'The age of the new version in days',
packageFile: 'The filename that the dependency was found in',
packageFileDir:
'The directory with full path where the packageFile was found',

View file

@ -4,6 +4,7 @@ import type { Release } from '../../../../modules/datasource';
import type { LookupUpdate } from '../../../../modules/manager/types';
import type { VersioningApi } from '../../../../modules/versioning';
import type { RangeStrategy } from '../../../../types';
import { getElapsedDays } from '../../../../util/date';
import { getMergeConfidenceLevel } from '../../../../util/merge-confidence';
import type { LookupUpdateConfig } from './types';
import { getUpdateType } from './update-type';
@ -37,8 +38,9 @@ export async function generateUpdate(
update.newDigest = release.newDigest;
}
// istanbul ignore if
if (release.releaseTimestamp !== undefined) {
if (release.releaseTimestamp) {
update.releaseTimestamp = release.releaseTimestamp;
update.newVersionAgeInDays = getElapsedDays(release.releaseTimestamp);
}
// istanbul ignore if
if (release.registryUrl !== undefined) {

View file

@ -161,6 +161,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -217,6 +218,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '^0.9.0',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2013-09-04T17:07:22.948Z',
updateType: 'minor',
},
@ -228,6 +230,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '^1.0.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -257,6 +260,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 4,
newValue: '^0.4.0',
newVersion: '0.4.4',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2011-06-10T17:20:04.719Z',
updateType: 'patch',
},
@ -268,6 +272,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '^0.9.0',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2013-09-04T17:07:22.948Z',
updateType: 'minor',
},
@ -279,6 +284,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '^1.0.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -305,6 +311,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '0.9.7',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -315,6 +322,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -342,6 +350,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 4,
newValue: '0.4.4',
newVersion: '0.4.4',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -352,6 +361,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '0.9.7',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -362,6 +372,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -389,6 +400,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -423,6 +435,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '^0.9.0',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2013-09-04T17:07:22.948Z',
updateType: 'minor',
},
@ -434,6 +447,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '^1.0.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -459,6 +473,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '0.9.7',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -484,6 +499,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '0.9.7',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2013-09-04T17:07:22.948Z',
updateType: 'minor',
},
@ -509,6 +525,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '0.9.7',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2013-09-04T17:07:22.948Z',
updateType: 'minor',
},
@ -535,6 +552,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '0.9.7',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2013-09-04T17:07:22.948Z',
updateType: 'minor',
},
@ -561,6 +579,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 4,
newValue: '0.9.4',
newVersion: '0.9.4',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2013-05-22T20:26:50.888Z',
updateType: 'minor',
},
@ -598,6 +617,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '0.9.7',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -608,6 +628,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -639,6 +660,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '0.9.7',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -649,6 +671,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -675,6 +698,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '0.9.7',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2013-09-04T17:07:22.948Z',
updateType: 'patch',
},
@ -685,6 +709,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -711,6 +736,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 12,
newValue: '0.8.12',
newVersion: '0.8.12',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -721,6 +747,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '0.9.7',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -731,6 +758,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -765,6 +793,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '^1.0.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -791,6 +820,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -816,6 +846,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.0.1',
newVersion: '1.0.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -842,6 +873,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -868,6 +900,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 0,
newValue: '1.1.0',
newVersion: '1.1.0',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -894,6 +927,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 0,
newValue: '1.1.0',
newVersion: '1.1.0',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -920,6 +954,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 0,
newValue: '1.1.0',
newVersion: '1.1.0',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -947,6 +982,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -973,6 +1009,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.0.1',
newVersion: '1.0.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -1021,6 +1058,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '~0.9.0',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2013-09-04T17:07:22.948Z',
updateType: 'minor',
},
@ -1032,6 +1070,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.4.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -1176,6 +1215,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.4.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -1209,6 +1249,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.4.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -1237,6 +1278,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '^1.2.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -1265,6 +1307,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '^1.2.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -1293,6 +1336,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.2.0',
newVersion: '1.2.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -1320,6 +1364,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: undefined,
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -1336,22 +1381,20 @@ describe('workers/repository/process/lookup/index', () => {
const { updates } = await Result.wrap(
lookup.lookupUpdates(config),
).unwrapOrThrow();
expect(updates).toMatchInlineSnapshot(`
[
{
"bucket": "non-major",
"isLockfileUpdate": true,
"isRange": true,
"newMajor": 1,
"newMinor": 3,
"newPatch": 0,
"newValue": undefined,
"newVersion": "1.3.0",
"releaseTimestamp": "2015-04-26T16:42:11.311Z",
"updateType": "minor",
},
]
`);
expect(updates).toMatchObject([
{
bucket: 'non-major',
isLockfileUpdate: true,
isRange: true,
newMajor: 1,
newMinor: 3,
newPatch: 0,
newValue: undefined,
newVersion: '1.3.0',
releaseTimestamp: '2015-04-26T16:42:11.311Z',
updateType: 'minor',
},
]);
expect(updates[0].newValue).toBeUndefined();
expect(updates[0].updateType).toBe('minor');
});
@ -1376,6 +1419,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.3.0 || ~1.4.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -1402,6 +1446,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.4.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -1431,6 +1476,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '^2.0.0 || ^3.0.0',
newVersion: '3.8.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2017-10-17T15:22:36.646Z',
updateType: 'major',
},
@ -1460,6 +1506,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '^3.0.0',
newVersion: '3.8.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2017-10-17T15:22:36.646Z',
updateType: 'major',
},
@ -1567,6 +1614,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.4.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -1600,6 +1648,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.x',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -1626,6 +1675,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.4.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -1652,6 +1702,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.x',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -1678,6 +1729,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.x',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -1704,6 +1756,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.2.x - 1.4.x',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -1730,6 +1783,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -1756,6 +1810,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -1782,6 +1837,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '~0.9.0',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2013-09-04T17:07:22.948Z',
updateType: 'minor',
},
@ -1793,6 +1849,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.4.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -1819,6 +1876,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '^0.9.0',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2013-09-04T17:07:22.948Z',
updateType: 'minor',
},
@ -1830,6 +1888,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '^1.0.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -1856,6 +1915,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '^0.7.0 || ^0.8.0 || ^0.9.0',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -1867,6 +1927,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '^0.7.0 || ^0.8.0 || ^1.0.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -1896,6 +1957,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '^1.0.0 || ^2.0.0 || ^3.0.0',
newVersion: '3.8.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2017-10-17T15:22:36.646Z',
updateType: 'major',
},
@ -1925,6 +1987,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.x - 3.x',
newVersion: '3.8.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2017-10-17T15:22:36.646Z',
updateType: 'major',
},
@ -1954,6 +2017,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.x || 2.x || 3.x',
newVersion: '3.8.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2017-10-17T15:22:36.646Z',
updateType: 'major',
},
@ -1983,6 +2047,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1 || 2 || 3',
newVersion: '3.8.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2017-10-17T15:22:36.646Z',
updateType: 'major',
},
@ -2009,6 +2074,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.2.0 || ~1.3.0 || ~1.4.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -2049,6 +2115,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '<= 0.9.7',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2013-09-04T17:07:22.948Z',
updateType: 'minor',
},
@ -2060,6 +2127,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '<= 1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -2086,6 +2154,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '< 0.9.8',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2013-09-04T17:07:22.948Z',
updateType: 'minor',
},
@ -2097,6 +2166,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '< 1.4.2',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -2123,6 +2193,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '< 2',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -2149,6 +2220,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '<= 1.4',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -2175,6 +2247,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '=1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -2202,6 +2275,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 3,
newValue: '<= 2',
newVersion: '2.0.3',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-01-31T08:11:47.852Z',
updateType: 'major',
},
@ -2228,6 +2302,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '<= 1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -2254,6 +2329,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '< 2.0.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -2280,6 +2356,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '>= 0.5.0 < 2.0.0',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -2306,6 +2383,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '>= 0.5.0 <0.10',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -2317,6 +2395,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '>= 0.5.0 <1.5',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -2343,6 +2422,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 7,
newValue: '>= 0.5.0 <= 0.9.7',
newVersion: '0.9.7',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -2354,6 +2434,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '>= 0.5.0 <= 1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -2393,6 +2474,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 3,
newValue: '2.0.3',
newVersion: '2.0.3',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-01-31T08:11:47.852Z',
updateType: 'major',
},
@ -2487,8 +2569,14 @@ describe('workers/repository/process/lookup/index', () => {
getGithubReleases.mockResolvedValueOnce({
releases: [
{ version: '1.4.4' },
{ version: '1.4.5', releaseTimestamp: lastWeek.toISOString() },
{ version: '1.4.6', releaseTimestamp: yesterday.toISOString() },
{
version: '1.4.5',
releaseTimestamp: lastWeek.toISOString(),
},
{
version: '1.4.6',
releaseTimestamp: yesterday.toISOString(),
},
],
});
@ -2505,6 +2593,7 @@ describe('workers/repository/process/lookup/index', () => {
newValue: '1.4.6',
newVersion: '1.4.6',
pendingChecks: true,
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -2524,8 +2613,14 @@ describe('workers/repository/process/lookup/index', () => {
getGithubReleases.mockResolvedValueOnce({
releases: [
{ version: '1.4.4' },
{ version: '1.4.5', releaseTimestamp: lastWeek.toISOString() },
{ version: '1.4.6', releaseTimestamp: yesterday.toISOString() },
{
version: '1.4.5',
releaseTimestamp: lastWeek.toISOString(),
},
{
version: '1.4.6',
releaseTimestamp: yesterday.toISOString(),
},
],
});
@ -2542,6 +2637,7 @@ describe('workers/repository/process/lookup/index', () => {
newValue: '1.4.5',
newVersion: '1.4.5',
pendingVersions: ['1.4.6'],
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -2571,6 +2667,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 17,
newValue: '2.5.17-beta.0',
newVersion: '2.5.17-beta.0',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -2598,6 +2695,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 0,
newValue: '3.1.0-dev.20180813',
newVersion: '3.1.0-dev.20180813',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -2625,6 +2723,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '3.0.1',
newVersion: '3.0.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -2653,6 +2752,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 35,
newValue: '0.0.35',
newVersion: '0.0.35',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -2698,6 +2798,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '3.0.1-insiders.20180726',
newVersion: '3.0.1-insiders.20180726',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -2753,6 +2854,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '3.0.1-insiders.20180726',
newVersion: '3.0.1-insiders.20180726',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'patch',
},
@ -2948,6 +3050,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 35,
newValue: '^0.0.35',
newVersion: '0.0.35',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2017-04-27T16:59:06.479Z',
updateType: 'patch',
},
@ -3001,6 +3104,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 0,
newValue: '1.15.0',
newVersion: '1.15.0',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -3011,6 +3115,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '3.8.1',
newVersion: '3.8.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -3039,6 +3144,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 0,
newValue: '1.15.0',
newVersion: '1.15.0',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -3049,6 +3155,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 0,
newValue: '2.7.0',
newVersion: '2.7.0',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -3059,6 +3166,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '3.8.1',
newVersion: '3.8.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -3118,6 +3226,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '^1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -3146,6 +3255,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.0.1',
newVersion: '1.0.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2014-03-11T18:47:17.560Z',
updateType: 'patch',
},
@ -3157,6 +3267,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -3185,6 +3296,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.0.1',
newVersion: '1.0.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2014-03-11T18:47:17.560Z',
updateType: 'patch',
},
@ -3196,6 +3308,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -3223,6 +3336,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '>=1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -3251,6 +3365,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '>=1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -3319,6 +3434,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'minor',
},
@ -3420,6 +3536,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '~=1.4',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2015-05-17T04:25:07.299Z',
updateType: 'major',
},
@ -3436,7 +3553,7 @@ describe('workers/repository/process/lookup/index', () => {
lookup.lookupUpdates(config),
).unwrapOrThrow();
expect(res).toEqual({
expect(res).toMatchObject({
currentVersion: '1.3.0',
currentVersionTimestamp: '2015-04-26T16:42:11.311Z',
fixedVersion: '1.3.0',
@ -3451,6 +3568,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -3478,7 +3596,7 @@ describe('workers/repository/process/lookup/index', () => {
const res = await Result.wrap(
lookup.lookupUpdates(config),
).unwrapOrThrow();
expect(res).toEqual({
expect(res).toMatchObject({
currentVersion: '1.3.0',
currentVersionTimestamp: '2015-04-26T16:42:11.311Z',
fixedVersion: '1.3.0',
@ -3493,6 +3611,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 0,
newValue: '1.4.0',
newVersion: '1.4.0',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -3503,6 +3622,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 3,
newValue: '2.0.3',
newVersion: '2.0.3',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -3533,7 +3653,7 @@ describe('workers/repository/process/lookup/index', () => {
lookup.lookupUpdates(config),
).unwrapOrThrow();
expect(res).toEqual({
expect(res).toMatchObject({
currentVersion: '1.3.0',
currentVersionTimestamp: '2015-04-26T16:42:11.311Z',
deprecationMessage: codeBlock`
@ -3556,6 +3676,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '1.4.1',
newVersion: '1.4.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'minor',
},
@ -4274,6 +4395,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 0,
newValue: '1.3.0',
newVersion: '1.3.0',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: expect.any(String),
updateType: 'major',
},
@ -4367,6 +4489,7 @@ describe('workers/repository/process/lookup/index', () => {
expect(res).toEqual({
currentVersion: '17.0.0',
currentVersionAgeInDays: 1,
currentVersionTimestamp: releaseTimestamp,
fixedVersion: '17.0.0',
isSingleVersion: true,
@ -4909,6 +5032,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '3.8.1',
newVersion: '3.8.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2017-10-17T15:22:36.646Z',
updateType: 'minor',
},
@ -4937,6 +5061,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 1,
newValue: '3.8.1',
newVersion: '3.8.1',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2017-10-17T15:22:36.646Z',
updateType: 'minor',
},
@ -4996,6 +5121,7 @@ describe('workers/repository/process/lookup/index', () => {
newPatch: 0,
newValue: 'v0.0.0-20240509183442-62759503f434',
newVersion: 'v0.0.0-20240509183442-62759503f434',
newVersionAgeInDays: expect.any(Number),
releaseTimestamp: '2024-05-09T18:34:42.000Z',
updateType: 'digest',
},

View file

@ -24,6 +24,7 @@ import * as allVersioning from '../../../../modules/versioning';
import { id as dockerVersioningId } from '../../../../modules/versioning/docker';
import { ExternalHostError } from '../../../../types/errors/external-host-error';
import { assignKeys } from '../../../../util/assign-keys';
import { getElapsedDays } from '../../../../util/date';
import { applyPackageRules } from '../../../../util/package-rules';
import { regEx } from '../../../../util/regex';
import { Result } from '../../../../util/result';
@ -314,9 +315,11 @@ export async function lookupUpdates(
if (is.nonEmptyString(currentVersionTimestamp)) {
res.currentVersionTimestamp = currentVersionTimestamp;
res.currentVersionAgeInDays = getElapsedDays(currentVersionTimestamp);
if (
config.packageRules?.some((rules) =>
is.nonEmptyString(rules.matchCurrentAge),
config.packageRules?.some((rule) =>
is.nonEmptyString(rule.matchCurrentAge),
)
) {
// Reapply package rules to check matches for matchCurrentAge

View file

@ -69,6 +69,7 @@ export interface UpdateResult {
updates: LookupUpdate[];
warnings: ValidationMessage[];
versioning?: string;
currentVersionAgeInDays?: number;
currentVersionTimestamp?: string;
vulnerabilityFixVersion?: string;
vulnerabilityFixStrategy?: string;