diff --git a/lib/config/types.ts b/lib/config/types.ts index 837468400493c718b19fe24c616e4455b00fd7d4..583069f0ec5c0211462b34d6fe8d23f0a8a81d96 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -6,6 +6,7 @@ import type { HostRule, SkipReason } from '../types'; import type { StageName } from '../types/skip-reason'; import type { GitNoVerifyOption } from '../util/git/types'; import type { MergeConfidence } from '../util/merge-confidence/types'; +import type { Timestamp } from '../util/timestamp'; export type RenovateConfigStage = | 'global' @@ -552,7 +553,7 @@ export interface PackageRuleInputConfig extends Record<string, unknown> { manager?: string; datasource?: string; packageRules?: (PackageRule & PackageRuleInputConfig)[]; - releaseTimestamp?: string | null; + releaseTimestamp?: Timestamp | null; repository?: string; currentVersionAgeInDays?: number; currentVersionTimestamp?: string; diff --git a/lib/modules/datasource/aws-machine-image/index.ts b/lib/modules/datasource/aws-machine-image/index.ts index f069ef5a52777ebee317dcb228d7da8e1aea3029..1c3dce2d985107859092e9633e57c2e015d584a3 100644 --- a/lib/modules/datasource/aws-machine-image/index.ts +++ b/lib/modules/datasource/aws-machine-image/index.ts @@ -2,6 +2,7 @@ import type { Filter, Image } from '@aws-sdk/client-ec2'; import { DescribeImagesCommand, EC2Client } from '@aws-sdk/client-ec2'; import { fromNodeProviderChain } from '@aws-sdk/credential-providers'; import { cache } from '../../../util/cache/package/decorator'; +import { asTimestamp } from '../../../util/timestamp'; import * as amazonMachineImageVersioning from '../../versioning/aws-machine-image'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, ReleaseResult } from '../types'; @@ -147,7 +148,7 @@ export class AwsMachineImageDatasource extends Datasource { releases: [ { version: latestImage.ImageId, - releaseTimestamp: latestImage.CreationDate, + releaseTimestamp: asTimestamp(latestImage.CreationDate), isDeprecated: Date.parse(latestImage.DeprecationTime ?? this.now.toString()) < this.now, diff --git a/lib/modules/datasource/bitbucket-tags/index.ts b/lib/modules/datasource/bitbucket-tags/index.ts index 1ca5ddf168951316ce8ab0d002c5ce987b7d6a14..66c39743d1727b79193ade1ae51e6734bffd8bb7 100644 --- a/lib/modules/datasource/bitbucket-tags/index.ts +++ b/lib/modules/datasource/bitbucket-tags/index.ts @@ -1,6 +1,7 @@ import { cache } from '../../../util/cache/package/decorator'; import type { PackageCacheNamespace } from '../../../util/cache/package/types'; import { BitbucketHttp } from '../../../util/http/bitbucket'; +import { asTimestamp } from '../../../util/timestamp'; import { ensureTrailingSlash } from '../../../util/url'; import { RepoInfo } from '../../platform/bitbucket/schema'; import type { PagedResult } from '../../platform/bitbucket/types'; @@ -79,7 +80,7 @@ export class BitbucketTagsDatasource extends Datasource { releases: bitbucketTags.map(({ name, target }) => ({ version: name, gitRef: name, - releaseTimestamp: target?.date, + releaseTimestamp: asTimestamp(target?.date), })), }; diff --git a/lib/modules/datasource/bitrise/schema.ts b/lib/modules/datasource/bitrise/schema.ts index 064151a45de2cd80fda24711a0d7cf7a5fe12957..ac29bec00e694b3e13d7fbd21ac38e3cba75d956 100644 --- a/lib/modules/datasource/bitrise/schema.ts +++ b/lib/modules/datasource/bitrise/schema.ts @@ -1,9 +1,10 @@ import { z } from 'zod'; import { Yaml } from '../../../util/schema-utils'; +import { MaybeTimestamp } from '../../../util/timestamp'; export const BitriseStepFile = Yaml.pipe( z.object({ - published_at: z.string(), + published_at: MaybeTimestamp, source_code_url: z.string().optional(), }), ); diff --git a/lib/modules/datasource/cpan/schema.ts b/lib/modules/datasource/cpan/schema.ts index 8e997143ba3849c2e0f2912cb3601c9577a30563..e44ce810626f50815d838fda0c208997deb95fca 100644 --- a/lib/modules/datasource/cpan/schema.ts +++ b/lib/modules/datasource/cpan/schema.ts @@ -1,5 +1,6 @@ import { z } from 'zod'; import { LooseArray } from '../../../util/schema-utils'; +import { MaybeTimestamp } from '../../../util/timestamp'; import type { CpanRelease } from './types'; /** @@ -14,7 +15,7 @@ const MetaCpanApiFileSchema = z }), ), distribution: z.string(), - date: z.string(), + date: MaybeTimestamp, deprecated: z.boolean(), maturity: z.string(), status: z.union([ diff --git a/lib/modules/datasource/crate/index.spec.ts b/lib/modules/datasource/crate/index.spec.ts index 765bba4d61ecdb18bd532d9f5738bd3e8d920e30..f5138c14b37169a87f9b5ff6b74d5b63d2272289 100644 --- a/lib/modules/datasource/crate/index.spec.ts +++ b/lib/modules/datasource/crate/index.spec.ts @@ -427,7 +427,7 @@ describe('modules/datasource/crate/index', () => { expect(res).toEqual({ version: '4.5.17', - releaseTimestamp: '2024-09-04T19:16:41.355243+00:00', + releaseTimestamp: '2024-09-04T19:16:41.355Z', }); }); }); diff --git a/lib/modules/datasource/crate/schema.ts b/lib/modules/datasource/crate/schema.ts index 9d799be31b42cc452cb924a6949e43fa667446ca..af908f22a932624d20c41c9a24dd97ae876283ce 100644 --- a/lib/modules/datasource/crate/schema.ts +++ b/lib/modules/datasource/crate/schema.ts @@ -1,9 +1,10 @@ import { z } from 'zod'; +import { MaybeTimestamp } from '../../../util/timestamp'; export const ReleaseTimestampSchema = z .object({ version: z.object({ - created_at: z.string(), + created_at: MaybeTimestamp, }), }) .transform(({ version: { created_at } }) => created_at) diff --git a/lib/modules/datasource/custom/schema.ts b/lib/modules/datasource/custom/schema.ts index 50c19b7ed948b1576aa93ce32c69616d6d989f51..c45628064f4a94dff76fcc5838cae8d01fa9cad4 100644 --- a/lib/modules/datasource/custom/schema.ts +++ b/lib/modules/datasource/custom/schema.ts @@ -1,4 +1,5 @@ import { z } from 'zod'; +import { MaybeTimestamp } from '../../../util/timestamp'; export const ReleaseResultZodSchema = z.object({ releases: z.array( @@ -6,7 +7,7 @@ export const ReleaseResultZodSchema = z.object({ .object({ version: z.string(), isDeprecated: z.boolean().optional(), - releaseTimestamp: z.string().optional(), + releaseTimestamp: MaybeTimestamp, sourceUrl: z.string().optional(), sourceDirectory: z.string().optional(), changelogUrl: z.string().optional(), diff --git a/lib/modules/datasource/dart/index.ts b/lib/modules/datasource/dart/index.ts index 80ea1cf8e3a2b44aba756c4e1129b457871e58b1..5cae12d29a50df6caa5bdb02a778924124f362b6 100644 --- a/lib/modules/datasource/dart/index.ts +++ b/lib/modules/datasource/dart/index.ts @@ -1,4 +1,5 @@ import type { HttpResponse } from '../../../util/http/types'; +import { asTimestamp } from '../../../util/timestamp'; import { ensureTrailingSlash } from '../../../util/url'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, ReleaseResult } from '../types'; @@ -49,7 +50,7 @@ export class DartDatasource extends Datasource { ?.filter(({ retracted }) => !retracted) ?.map(({ version, published }) => ({ version, - releaseTimestamp: published, + releaseTimestamp: asTimestamp(published), })); if (releases && latest) { result = { releases }; diff --git a/lib/modules/datasource/deno/schema.ts b/lib/modules/datasource/deno/schema.ts index 2587874425d9d8f92145e392bfc65062e557349f..a72b7d29669d71232e2e36112761b8cdd636a343 100644 --- a/lib/modules/datasource/deno/schema.ts +++ b/lib/modules/datasource/deno/schema.ts @@ -1,6 +1,7 @@ import { z } from 'zod'; import { getSourceUrl as getGithubSourceUrl } from '../../../util/github/url'; import { LooseArray } from '../../../util/schema-utils'; +import { MaybeTimestamp } from '../../../util/timestamp'; import type { Release } from '../types'; export const DenoApiTag = z.object({ @@ -31,7 +32,7 @@ export const DenoAPIUploadOptions = z.object({ export const DenoAPIModuleVersionResponse = z .object({ upload_options: DenoAPIUploadOptions, - uploaded_at: z.string(), + uploaded_at: MaybeTimestamp, version: z.string(), }) .transform( @@ -41,6 +42,11 @@ export const DenoAPIModuleVersionResponse = z if (type === 'github') { sourceUrl = getGithubSourceUrl(repository); } - return { version, gitRef, releaseTimestamp, sourceUrl }; + return { + version, + gitRef, + releaseTimestamp, + sourceUrl, + }; }, ); diff --git a/lib/modules/datasource/devbox/schema.ts b/lib/modules/datasource/devbox/schema.ts index bc31efae879850cde7898aebf4417110ccd37e4d..d4c3fac44b6208b0bf03f71fa2bd75b735ed7e71 100644 --- a/lib/modules/datasource/devbox/schema.ts +++ b/lib/modules/datasource/devbox/schema.ts @@ -1,8 +1,9 @@ import { z } from 'zod'; +import { MaybeTimestamp } from '../../../util/timestamp'; export const DevboxRelease = z.object({ version: z.string(), - last_updated: z.string(), + last_updated: MaybeTimestamp, }); export const DevboxResponse = z diff --git a/lib/modules/datasource/docker/index.ts b/lib/modules/datasource/docker/index.ts index dec17989b8ff5b49a0a2e3635c38d92c389ce2db..87c59c23441777ec9e809a71027c50d7d3632e69 100644 --- a/lib/modules/datasource/docker/index.ts +++ b/lib/modules/datasource/docker/index.ts @@ -10,6 +10,7 @@ import { hasKey } from '../../../util/object'; import { regEx } from '../../../util/regex'; import { type AsyncResult, Result } from '../../../util/result'; import { isDockerDigest } from '../../../util/string-match'; +import { asTimestamp } from '../../../util/timestamp'; import { ensurePathPrefix, joinUrlParts, @@ -1001,13 +1002,10 @@ export class DockerDatasource extends Datasource { const items = cache.getItems(); return items.map( - ({ - name: version, - tag_last_pushed: releaseTimestamp, - digest: newDigest, - }) => { + ({ name: version, tag_last_pushed, digest: newDigest }) => { const release: Release = { version }; + const releaseTimestamp = asTimestamp(tag_last_pushed); if (releaseTimestamp) { release.releaseTimestamp = releaseTimestamp; } diff --git a/lib/modules/datasource/dotnet-version/schema.ts b/lib/modules/datasource/dotnet-version/schema.ts index ce940ac245319a75f6a54f43cd3a31486172e158..8660a322b5f067952a995c1534b98d819535d265 100644 --- a/lib/modules/datasource/dotnet-version/schema.ts +++ b/lib/modules/datasource/dotnet-version/schema.ts @@ -1,5 +1,6 @@ import { z } from 'zod'; import { LooseArray } from '../../../util/schema-utils'; +import { MaybeTimestamp } from '../../../util/timestamp'; import type { Release } from '../types'; export const ReleasesIndex = z @@ -15,7 +16,7 @@ export const ReleasesIndex = z .transform(({ 'releases-index': releasesIndex }) => releasesIndex); const ReleaseBase = z.object({ - 'release-date': z.string(), + 'release-date': MaybeTimestamp, 'release-notes': z.string(), }); const ReleaseDetails = z.object({ diff --git a/lib/modules/datasource/endoflife-date/schema.ts b/lib/modules/datasource/endoflife-date/schema.ts index 4f184a86fc9d72409b091bb601d458bc4b8bf077..aa4e83cd0040358a65597a98f64bedb38164d30f 100644 --- a/lib/modules/datasource/endoflife-date/schema.ts +++ b/lib/modules/datasource/endoflife-date/schema.ts @@ -1,6 +1,7 @@ import { DateTime } from 'luxon'; import { z } from 'zod'; import { UtcDate } from '../../../util/schema-utils'; +import { MaybeTimestamp } from '../../../util/timestamp'; import type { Release } from '../types'; const ExpireableField = z.union([ @@ -15,7 +16,7 @@ export const EndoflifeDateVersions = z .object({ cycle: z.string(), latest: z.optional(z.string()), - releaseDate: z.optional(z.string()), + releaseDate: MaybeTimestamp, eol: z.optional(ExpireableField), discontinued: z.optional(ExpireableField), }) diff --git a/lib/modules/datasource/flutter-version/index.ts b/lib/modules/datasource/flutter-version/index.ts index 5069f9779ecc8536da61f004a6238be5454939f7..8fd364877c8d22f3929f56529191c58dd4426f7c 100644 --- a/lib/modules/datasource/flutter-version/index.ts +++ b/lib/modules/datasource/flutter-version/index.ts @@ -1,4 +1,5 @@ import { regEx } from '../../../util/regex'; +import { asTimestamp } from '../../../util/timestamp'; import { id as semverId } from '../../versioning/semver'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, ReleaseResult } from '../types'; @@ -58,7 +59,7 @@ export class FlutterVersionDatasource extends Datasource { }) .map(({ version, release_date, channel }) => ({ version, - releaseTimestamp: release_date, + releaseTimestamp: asTimestamp(release_date), isStable: channel === 'stable', })); return result.releases.length ? result : null; diff --git a/lib/modules/datasource/galaxy-collection/schema.ts b/lib/modules/datasource/galaxy-collection/schema.ts index 06be4898c52e998dd351572081e532ee8296f715..0842fc9ccbec59734422eb1197d4b0fb36dca515 100644 --- a/lib/modules/datasource/galaxy-collection/schema.ts +++ b/lib/modules/datasource/galaxy-collection/schema.ts @@ -1,4 +1,5 @@ import { z } from 'zod'; +import { MaybeTimestamp } from '../../../util/timestamp'; export type GalaxyV3 = z.infer<typeof GalaxyV3>; export const GalaxyV3 = z.object({ @@ -14,7 +15,7 @@ export const GalaxyV3Versions = z data: z.array( z.object({ version: z.string(), - created_at: z.string().datetime(), + created_at: MaybeTimestamp, }), ), }) diff --git a/lib/modules/datasource/galaxy/index.ts b/lib/modules/datasource/galaxy/index.ts index cae51402213a80f29c5033933c56eb961806078c..075653dddf5bebcbb05fab2fd628dc55f889cde6 100644 --- a/lib/modules/datasource/galaxy/index.ts +++ b/lib/modules/datasource/galaxy/index.ts @@ -82,18 +82,13 @@ export class GalaxyDatasource extends Datasource { result.sourceUrl = `https://github.com/${user}/${repo}`; } - result.releases = versions.map( - (version: { name: string; created?: string }) => { - const release: Release = { - version: version.name, - }; - - if (is.nonEmptyString(version.created)) { - release.releaseTimestamp = version.created; - } - return release; - }, - ); + result.releases = versions.map(({ version, releaseTimestamp }) => { + const release: Release = { version }; + if (releaseTimestamp) { + release.releaseTimestamp = releaseTimestamp; + } + return release; + }); return result; } diff --git a/lib/modules/datasource/galaxy/schema.ts b/lib/modules/datasource/galaxy/schema.ts index 7fb519004908e35e91a485b64044155f41b0a823..2366ffa67b1c95e328b2061427c6e09b07dad22c 100644 --- a/lib/modules/datasource/galaxy/schema.ts +++ b/lib/modules/datasource/galaxy/schema.ts @@ -1,4 +1,5 @@ import { z } from 'zod'; +import { MaybeTimestamp } from '../../../util/timestamp'; export type GalaxyV1 = z.infer<typeof GalaxyV1>; export const GalaxyV1 = z.object({ @@ -6,10 +7,15 @@ export const GalaxyV1 = z.object({ z.object({ summary_fields: z.object({ versions: z.array( - z.object({ - name: z.string(), - created: z.string().optional(), - }), + z + .object({ + name: z.string(), + created: MaybeTimestamp, + }) + .transform(({ name, created }) => ({ + version: name, + releaseTimestamp: created, + })), ), }), github_user: z.string().optional(), diff --git a/lib/modules/datasource/gitea-releases/schema.ts b/lib/modules/datasource/gitea-releases/schema.ts index fe57281c672d579e96b2769c2c57d68d4edb50b0..b1482c99701e636075d24c848b9ccc54c59fe14c 100644 --- a/lib/modules/datasource/gitea-releases/schema.ts +++ b/lib/modules/datasource/gitea-releases/schema.ts @@ -1,11 +1,12 @@ import { z } from 'zod'; +import { MaybeTimestamp } from '../../../util/timestamp'; export const ReleaseSchema = z.object({ name: z.string(), tag_name: z.string(), body: z.string(), prerelease: z.boolean(), - published_at: z.string().datetime({ offset: true }), + published_at: MaybeTimestamp, }); export const ReleasesSchema = z.array(ReleaseSchema); diff --git a/lib/modules/datasource/gitea-tags/schema.ts b/lib/modules/datasource/gitea-tags/schema.ts index 603730de8f1dbfa2cf4e7d7e89e488b3505ce098..3ba004a0bb1062ac8ec6b87b07557318eea49ff8 100644 --- a/lib/modules/datasource/gitea-tags/schema.ts +++ b/lib/modules/datasource/gitea-tags/schema.ts @@ -1,4 +1,5 @@ import { z } from 'zod'; +import { MaybeTimestamp } from '../../../util/timestamp'; export const CommitSchema = z.object({ sha: z.string(), @@ -8,7 +9,7 @@ export const CommitsSchema = z.array(CommitSchema); const TagCommitSchema = z.object({ sha: z.string(), - created: z.string().datetime({ offset: true }), + created: MaybeTimestamp, }); export const TagSchema = z.object({ diff --git a/lib/modules/datasource/github-release-attachments/index.spec.ts b/lib/modules/datasource/github-release-attachments/index.spec.ts index f1c17ad42c9102617f02fbea065438c94f363776..02872612d4d86dff410483b555cd26b983bf32be 100644 --- a/lib/modules/datasource/github-release-attachments/index.spec.ts +++ b/lib/modules/datasource/github-release-attachments/index.spec.ts @@ -3,6 +3,7 @@ import { getDigest, getPkgReleases } from '..'; import { mocked } from '../../../../test/util'; import * as githubGraphql from '../../../util/github/graphql'; import * as _hostRules from '../../../util/host-rules'; +import type { Timestamp } from '../../../util/timestamp'; import { GitHubReleaseAttachmentMocker } from './test'; import { GithubReleaseAttachmentsDatasource } from '.'; @@ -28,7 +29,7 @@ describe('modules/datasource/github-release-attachments/index', () => { name: 'some/dep2', description: 'some description', version: 'a', - releaseTimestamp: '2020-03-09T13:00:00Z', + releaseTimestamp: '2020-03-09T13:00:00Z' as Timestamp, }, { id: 2, @@ -36,7 +37,7 @@ describe('modules/datasource/github-release-attachments/index', () => { name: 'some/dep2', description: 'some description', version: 'v', - releaseTimestamp: '2020-03-09T12:00:00Z', + releaseTimestamp: '2020-03-09T12:00:00Z' as Timestamp, }, { id: 3, @@ -44,7 +45,7 @@ describe('modules/datasource/github-release-attachments/index', () => { name: 'some/dep2', description: 'some description', version: '1.0.0', - releaseTimestamp: '2020-03-09T11:00:00Z', + releaseTimestamp: '2020-03-09T11:00:00Z' as Timestamp, }, { id: 4, @@ -52,7 +53,7 @@ describe('modules/datasource/github-release-attachments/index', () => { name: 'some/dep2', description: 'some description', version: 'v1.1.0', - releaseTimestamp: '2020-03-09T10:00:00Z', + releaseTimestamp: '2020-03-09T10:00:00Z' as Timestamp, }, { id: 5, @@ -60,7 +61,7 @@ describe('modules/datasource/github-release-attachments/index', () => { name: 'some/dep2', description: 'some description', version: '2.0.0', - releaseTimestamp: '2020-04-09T10:00:00Z', + releaseTimestamp: '2020-04-09T10:00:00Z' as Timestamp, isStable: false, }, ]); diff --git a/lib/modules/datasource/github-releases/index.spec.ts b/lib/modules/datasource/github-releases/index.spec.ts index e6f93f07803bcdc4b282810b88b0a05e23dd8729..fbd1f962a94958b07638443ac6887f8c44a72cbd 100644 --- a/lib/modules/datasource/github-releases/index.spec.ts +++ b/lib/modules/datasource/github-releases/index.spec.ts @@ -3,6 +3,7 @@ import { getDigest, getPkgReleases } from '..'; import { mocked } from '../../../../test/util'; import * as githubGraphql from '../../../util/github/graphql'; import * as _hostRules from '../../../util/host-rules'; +import type { Timestamp } from '../../../util/timestamp'; import { GithubReleasesDatasource } from '.'; jest.mock('../../../util/host-rules', () => mockDeep()); @@ -25,7 +26,7 @@ describe('modules/datasource/github-releases/index', () => { name: 'some/dep2', description: 'some description', version: 'a', - releaseTimestamp: '2020-03-09T13:00:00Z', + releaseTimestamp: '2020-03-09T13:00:00Z' as Timestamp, }, { id: 2, @@ -33,7 +34,7 @@ describe('modules/datasource/github-releases/index', () => { name: 'some/dep2', description: 'some description', version: 'v', - releaseTimestamp: '2020-03-09T12:00:00Z', + releaseTimestamp: '2020-03-09T12:00:00Z' as Timestamp, }, { id: 3, @@ -41,7 +42,7 @@ describe('modules/datasource/github-releases/index', () => { name: 'some/dep2', description: 'some description', version: '1.0.0', - releaseTimestamp: '2020-03-09T11:00:00Z', + releaseTimestamp: '2020-03-09T11:00:00Z' as Timestamp, }, { id: 4, @@ -49,7 +50,7 @@ describe('modules/datasource/github-releases/index', () => { name: 'some/dep2', description: 'some description', version: 'v1.1.0', - releaseTimestamp: '2020-03-09T10:00:00Z', + releaseTimestamp: '2020-03-09T10:00:00Z' as Timestamp, }, { id: 5, @@ -57,7 +58,7 @@ describe('modules/datasource/github-releases/index', () => { name: 'some/dep2', description: 'some description', version: '2.0.0', - releaseTimestamp: '2020-04-09T10:00:00Z', + releaseTimestamp: '2020-04-09T10:00:00Z' as Timestamp, isStable: false, }, ]); @@ -70,11 +71,17 @@ describe('modules/datasource/github-releases/index', () => { expect(res).toMatchObject({ registryUrl: 'https://github.com', releases: [ - { releaseTimestamp: '2020-03-09T11:00:00.000Z', version: '1.0.0' }, - { version: 'v1.1.0', releaseTimestamp: '2020-03-09T10:00:00.000Z' }, + { + releaseTimestamp: '2020-03-09T11:00:00.000Z' as Timestamp, + version: '1.0.0', + }, + { + version: 'v1.1.0', + releaseTimestamp: '2020-03-09T10:00:00.000Z' as Timestamp, + }, { version: '2.0.0', - releaseTimestamp: '2020-04-09T10:00:00.000Z', + releaseTimestamp: '2020-04-09T10:00:00.000Z' as Timestamp, isStable: false, }, ], @@ -95,13 +102,13 @@ describe('modules/datasource/github-releases/index', () => { { version: 'v1.0.0', gitRef: 'v1.0.0', - releaseTimestamp: '2021-01-01', + releaseTimestamp: '2021-01-01' as Timestamp, hash: 'sha-of-v1', }, { version: 'v15.0.0', gitRef: 'v15.0.0', - releaseTimestamp: '2022-10-01', + releaseTimestamp: '2022-10-01' as Timestamp, hash: 'sha-of-v15', }, ]); diff --git a/lib/modules/datasource/github-tags/index.spec.ts b/lib/modules/datasource/github-tags/index.spec.ts index 8bde1f8d3fec43fe1a6fa1424c5cd881b1492ef6..02b2d0b9dcda44260ffbfda401e9c1b3222daa47 100644 --- a/lib/modules/datasource/github-tags/index.spec.ts +++ b/lib/modules/datasource/github-tags/index.spec.ts @@ -4,6 +4,7 @@ import { partial } from '../../../../test/util'; import * as githubGraphql from '../../../util/github/graphql'; import type { GithubTagItem } from '../../../util/github/graphql/types'; import * as hostRules from '../../../util/host-rules'; +import type { Timestamp } from '../../../util/timestamp'; import { GithubTagsDatasource } from '.'; const githubApiHost = 'https://api.github.com'; @@ -55,13 +56,13 @@ describe('modules/datasource/github-tags/index', () => { { version: 'v1.0.0', gitRef: 'v1.0.0', - releaseTimestamp: '2021-01-01', + releaseTimestamp: '2021-01-01' as Timestamp, hash: '123', }, { version: 'v2.0.0', gitRef: 'v2.0.0', - releaseTimestamp: '2022-01-01', + releaseTimestamp: '2022-01-01' as Timestamp, hash: 'abc', }, ]); @@ -74,13 +75,13 @@ describe('modules/datasource/github-tags/index', () => { { version: 'v1.0.0', gitRef: 'v1.0.0', - releaseTimestamp: '2021-01-01', + releaseTimestamp: '2021-01-01' as Timestamp, hash: '123', }, partial<GithubTagItem>({ version: 'v2.0.0', gitRef: 'v2.0.0', - releaseTimestamp: '2022-01-01', + releaseTimestamp: '2022-01-01' as Timestamp, }), ]); const res = await github.getDigest({ packageName }, 'v2.0.0'); @@ -92,13 +93,13 @@ describe('modules/datasource/github-tags/index', () => { { version: 'v1.0.0', gitRef: 'v1.0.0', - releaseTimestamp: '2021-01-01', + releaseTimestamp: '2021-01-01' as Timestamp, hash: '123', }, { version: 'v2.0.0', gitRef: 'v2.0.0', - releaseTimestamp: '2022-01-01', + releaseTimestamp: '2022-01-01' as Timestamp, hash: 'abc', }, ]); @@ -121,13 +122,13 @@ describe('modules/datasource/github-tags/index', () => { { version: 'v1.0.0', gitRef: 'v1.0.0', - releaseTimestamp: '2021-01-01', + releaseTimestamp: '2021-01-01' as Timestamp, hash: '123', }, { version: 'v2.0.0', gitRef: 'v2.0.0', - releaseTimestamp: '2022-01-01', + releaseTimestamp: '2022-01-01' as Timestamp, hash: 'abc', }, ]); @@ -135,7 +136,7 @@ describe('modules/datasource/github-tags/index', () => { { id: 1, version: 'v1.0.0', - releaseTimestamp: '2021-01-01', + releaseTimestamp: '2021-01-01' as Timestamp, isStable: true, url: 'https://example.com', name: 'some/dep2', @@ -144,7 +145,7 @@ describe('modules/datasource/github-tags/index', () => { { id: 2, version: 'v2.0.0', - releaseTimestamp: '2022-01-01', + releaseTimestamp: '2022-01-01' as Timestamp, isStable: false, url: 'https://example.com', name: 'some/dep2', diff --git a/lib/modules/datasource/gitlab-packages/index.ts b/lib/modules/datasource/gitlab-packages/index.ts index 651fb6d0141f167189d87734382be0cc30688d4d..fa2bfa27fdcee1cdffca5ca58ebaea04e941a5ce 100644 --- a/lib/modules/datasource/gitlab-packages/index.ts +++ b/lib/modules/datasource/gitlab-packages/index.ts @@ -1,5 +1,6 @@ import { cache } from '../../../util/cache/package/decorator'; import { GitlabHttp } from '../../../util/http/gitlab'; +import { asTimestamp } from '../../../util/timestamp'; import { joinUrlParts } from '../../../util/url'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, ReleaseResult } from '../types'; @@ -85,7 +86,7 @@ export class GitlabPackagesDatasource extends Datasource { .filter((r) => r.name === packagePart) .map(({ version, created_at }) => ({ version, - releaseTimestamp: created_at, + releaseTimestamp: asTimestamp(created_at), })); } catch (err) { this.handleGenericErrors(err); diff --git a/lib/modules/datasource/gitlab-releases/index.ts b/lib/modules/datasource/gitlab-releases/index.ts index f82a5eb68bb50f7c8de87f32f6176ea5875b0bcd..547cd5e5b7b599d2f531c8482aa8065cb959a9a6 100644 --- a/lib/modules/datasource/gitlab-releases/index.ts +++ b/lib/modules/datasource/gitlab-releases/index.ts @@ -1,5 +1,6 @@ import { cache } from '../../../util/cache/package/decorator'; import { GitlabHttp } from '../../../util/http/gitlab'; +import { asTimestamp } from '../../../util/timestamp'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, Release, ReleaseResult } from '../types'; import type { GitlabRelease } from './types'; @@ -53,7 +54,7 @@ export class GitlabReleasesDatasource extends Datasource { registryUrl, gitRef: tag_name, version: tag_name, - releaseTimestamp: released_at, + releaseTimestamp: asTimestamp(released_at), }; return release; }), diff --git a/lib/modules/datasource/gitlab-tags/index.ts b/lib/modules/datasource/gitlab-tags/index.ts index 77690fcce599420adada71bd901acf7aaf4aaaed..a4a23fadec508b0440b3df2173568c4ab9be2bdf 100644 --- a/lib/modules/datasource/gitlab-tags/index.ts +++ b/lib/modules/datasource/gitlab-tags/index.ts @@ -1,6 +1,7 @@ import { logger } from '../../../logger'; import { cache } from '../../../util/cache/package/decorator'; import { GitlabHttp } from '../../../util/http/gitlab'; +import { asTimestamp } from '../../../util/timestamp'; import { joinUrlParts } from '../../../util/url'; import { Datasource } from '../datasource'; import type { DigestConfig, GetReleasesConfig, ReleaseResult } from '../types'; @@ -60,7 +61,7 @@ export class GitlabTagsDatasource extends Datasource { dependency.releases = gitlabTags.map(({ name, commit }) => ({ version: name, gitRef: name, - releaseTimestamp: commit?.created_at, + releaseTimestamp: asTimestamp(commit?.created_at), })); return dependency; diff --git a/lib/modules/datasource/go/__snapshots__/releases-direct.spec.ts.snap b/lib/modules/datasource/go/__snapshots__/releases-direct.spec.ts.snap index 4e65ba27707cd45f89caf33bed03cab0c796feb8..d70e507a08ad467169051fd1e3a4e4f3106b5225 100644 --- a/lib/modules/datasource/go/__snapshots__/releases-direct.spec.ts.snap +++ b/lib/modules/datasource/go/__snapshots__/releases-direct.spec.ts.snap @@ -6,12 +6,12 @@ exports[`modules/datasource/go/releases-direct getReleases support bitbucket tag "releases": [ { "gitRef": "v1.0.0", - "releaseTimestamp": undefined, + "releaseTimestamp": null, "version": "v1.0.0", }, { "gitRef": "v2.0.0", - "releaseTimestamp": undefined, + "releaseTimestamp": null, "version": "v2.0.0", }, ], @@ -40,12 +40,12 @@ exports[`modules/datasource/go/releases-direct getReleases support gitlab 1`] = "releases": [ { "gitRef": "v1.0.0", - "releaseTimestamp": undefined, + "releaseTimestamp": null, "version": "v1.0.0", }, { "gitRef": "v2.0.0", - "releaseTimestamp": undefined, + "releaseTimestamp": null, "version": "v2.0.0", }, ], @@ -58,12 +58,12 @@ exports[`modules/datasource/go/releases-direct getReleases support gitlab subgro "releases": [ { "gitRef": "v1.0.0", - "releaseTimestamp": undefined, + "releaseTimestamp": null, "version": "v1.0.0", }, { "gitRef": "v2.0.0", - "releaseTimestamp": undefined, + "releaseTimestamp": null, "version": "v2.0.0", }, ], @@ -76,12 +76,12 @@ exports[`modules/datasource/go/releases-direct getReleases support self hosted g "releases": [ { "gitRef": "v1.0.0", - "releaseTimestamp": undefined, + "releaseTimestamp": null, "version": "v1.0.0", }, { "gitRef": "v2.0.0", - "releaseTimestamp": undefined, + "releaseTimestamp": null, "version": "v2.0.0", }, ], diff --git a/lib/modules/datasource/go/releases-direct.spec.ts b/lib/modules/datasource/go/releases-direct.spec.ts index 19da04761d3c4a39760f534c229686479d3f6cf3..c63003fa541a2bc06c6d32bbf1d2777bc55a5890 100644 --- a/lib/modules/datasource/go/releases-direct.spec.ts +++ b/lib/modules/datasource/go/releases-direct.spec.ts @@ -129,19 +129,19 @@ describe('modules/datasource/go/releases-direct', () => { { gitRef: 'v0.1.0', newDigest: 'd73d815ec22c421e7192a414594ac798c73c89e5', - releaseTimestamp: '2022-05-15T16:29:42Z', + releaseTimestamp: '2022-05-15T16:29:42.000Z', version: 'v0.1.0', }, { gitRef: 'v0.2.0', newDigest: '3976707232cb68751ff2ddf42547ff95c6878a97', - releaseTimestamp: '2022-05-15T17:23:28Z', + releaseTimestamp: '2022-05-15T17:23:28.000Z', version: 'v0.2.0', }, { gitRef: 'v0.2.1', newDigest: '2963b104773ead7ed28c00181c03318885d909dc', - releaseTimestamp: '2024-09-06T23:44:34Z', + releaseTimestamp: '2024-09-06T23:44:34.000Z', version: 'v0.2.1', }, ], diff --git a/lib/modules/datasource/go/releases-goproxy.spec.ts b/lib/modules/datasource/go/releases-goproxy.spec.ts index 2d6950d057f79e378faeefdce5b833e93379afea..70c5287f7b6f60bbd82d7af768aa0542d438d3bb 100644 --- a/lib/modules/datasource/go/releases-goproxy.spec.ts +++ b/lib/modules/datasource/go/releases-goproxy.spec.ts @@ -64,7 +64,7 @@ describe('modules/datasource/go/releases-goproxy', () => { expect(release).toEqual({ version: 'v0.5.0', - releaseTimestamp: '2017-06-08T17:28:36Z', + releaseTimestamp: '2017-06-08T17:28:36.000Z', }); }); }); @@ -155,15 +155,15 @@ describe('modules/datasource/go/releases-goproxy', () => { releases: [ { version: 'v1.0.0', - releaseTimestamp: '2018-08-13T15:31:12Z', + releaseTimestamp: '2018-08-13T15:31:12.000Z', }, { version: 'v1.0.1', - releaseTimestamp: '2019-10-16T16:15:28Z', + releaseTimestamp: '2019-10-16T16:15:28.000Z', }, { version: 'v1.28.1-20230721020619-4464c06fa399.4', - releaseTimestamp: '2023-07-21T02:06:19Z', + releaseTimestamp: '2023-07-21T02:06:19.000Z', newDigest: '4464c06fa399', }, ], @@ -245,8 +245,8 @@ describe('modules/datasource/go/releases-goproxy', () => { expect(res).toEqual({ releases: [ - { releaseTimestamp: '2018-08-13T15:31:12Z', version: 'v1.0.0' }, - { releaseTimestamp: '2019-10-16T16:15:28Z', version: 'v1.0.1' }, + { releaseTimestamp: '2018-08-13T15:31:12.000Z', version: 'v1.0.0' }, + { releaseTimestamp: '2019-10-16T16:15:28.000Z', version: 'v1.0.1' }, ], sourceUrl: 'https://github.com/google/btree', tags: { latest: 'v1.0.1' }, @@ -296,8 +296,8 @@ describe('modules/datasource/go/releases-goproxy', () => { expect(res).toEqual({ releases: [ - { releaseTimestamp: '2018-08-13T15:31:12Z', version: 'v1.0.0' }, - { releaseTimestamp: '2019-10-16T16:15:28Z', version: 'v1.0.1' }, + { releaseTimestamp: '2018-08-13T15:31:12.000Z', version: 'v1.0.0' }, + { releaseTimestamp: '2019-10-16T16:15:28.000Z', version: 'v1.0.1' }, ], sourceUrl: 'https://github.com/google/btree', tags: { latest: 'v1.0.1' }, @@ -399,7 +399,7 @@ describe('modules/datasource/go/releases-goproxy', () => { httpMock .scope(`${baseUrl}/custom.com/lib/btree`) .get('/@v/list') - .reply(200, ['v1.0.0 2018-08-13T15:31:12Z', 'v1.0.1'].join('\n')) + .reply(200, ['v1.0.0 2018-08-13T15:31:12.000Z', 'v1.0.1'].join('\n')) .get('/@v/v1.0.1.info') .reply(200, { Version: 'v1.0.1', Time: '2019-10-16T16:15:28Z' }) .get('/@latest') @@ -417,8 +417,8 @@ describe('modules/datasource/go/releases-goproxy', () => { expect(res).toEqual({ releases: [ - { releaseTimestamp: '2018-08-13T15:31:12Z', version: 'v1.0.0' }, - { releaseTimestamp: '2019-10-16T16:15:28Z', version: 'v1.0.1' }, + { releaseTimestamp: '2018-08-13T15:31:12.000Z', version: 'v1.0.0' }, + { releaseTimestamp: '2019-10-16T16:15:28.000Z', version: 'v1.0.1' }, ], tags: { latest: 'v1.0.1' }, }); @@ -470,9 +470,9 @@ describe('modules/datasource/go/releases-goproxy', () => { expect(res).toEqual({ releases: [ - { releaseTimestamp: '2018-08-13T15:31:12Z', version: 'v1.0.0' }, - { releaseTimestamp: '2019-10-16T16:15:28Z', version: 'v1.0.1' }, - { releaseTimestamp: '2020-10-16T16:15:28Z', version: 'v2.0.0' }, + { releaseTimestamp: '2018-08-13T15:31:12.000Z', version: 'v1.0.0' }, + { releaseTimestamp: '2019-10-16T16:15:28.000Z', version: 'v1.0.1' }, + { releaseTimestamp: '2020-10-16T16:15:28.000Z', version: 'v2.0.0' }, ], sourceUrl: 'https://github.com/google/btree', tags: { latest: 'v2.0.0' }, @@ -513,10 +513,10 @@ describe('modules/datasource/go/releases-goproxy', () => { expect(res).toEqual({ releases: [ - { releaseTimestamp: '2020-05-06T23:08:38Z', version: 'v2.3.0' }, - { releaseTimestamp: '2020-11-17T15:46:20Z', version: 'v2.4.0' }, - { releaseTimestamp: '2022-05-21T10:33:21Z', version: 'v3.0.0' }, - { releaseTimestamp: '2022-05-27T08:35:30Z', version: 'v3.0.1' }, + { releaseTimestamp: '2020-05-06T23:08:38.000Z', version: 'v2.3.0' }, + { releaseTimestamp: '2020-11-17T15:46:20.000Z', version: 'v2.4.0' }, + { releaseTimestamp: '2022-05-21T10:33:21.000Z', version: 'v3.0.0' }, + { releaseTimestamp: '2022-05-27T08:35:30.000Z', version: 'v3.0.1' }, ], sourceUrl: 'https://github.com/go-yaml/yaml', tags: { latest: 'v3.0.1' }, @@ -551,9 +551,9 @@ describe('modules/datasource/go/releases-goproxy', () => { expect(res).toEqual({ releases: [ - { releaseTimestamp: '2017-01-01T00:00:00Z', version: 'v0.1.0' }, - { releaseTimestamp: '2017-02-01T00:00:00Z', version: 'v0.2.0' }, - { releaseTimestamp: '2018-01-01T00:00:00Z', version: 'v1.0.0' }, + { releaseTimestamp: '2017-01-01T00:00:00.000Z', version: 'v0.1.0' }, + { releaseTimestamp: '2017-02-01T00:00:00.000Z', version: 'v0.2.0' }, + { releaseTimestamp: '2018-01-01T00:00:00.000Z', version: 'v1.0.0' }, ], sourceUrl: 'https://github.com/go-foo/foo', tags: { latest: 'v1.0.0' }, @@ -588,9 +588,9 @@ describe('modules/datasource/go/releases-goproxy', () => { expect(res).toEqual({ releases: [ - { releaseTimestamp: '2017-01-01T00:00:00Z', version: 'v0.1.0' }, - { releaseTimestamp: '2017-02-01T00:00:00Z', version: 'v0.2.0' }, - { releaseTimestamp: '2018-01-01T00:00:00Z', version: 'v1.0.0' }, + { releaseTimestamp: '2017-01-01T00:00:00.000Z', version: 'v0.1.0' }, + { releaseTimestamp: '2017-02-01T00:00:00.000Z', version: 'v0.2.0' }, + { releaseTimestamp: '2018-01-01T00:00:00.000Z', version: 'v1.0.0' }, ], sourceUrl: 'https://github.com/go-foo/foo', tags: { latest: 'v1.0.0' }, @@ -632,7 +632,7 @@ describe('modules/datasource/go/releases-goproxy', () => { releases: [ { newDigest: '921286631fa9', - releaseTimestamp: '2023-09-05T20:02:55Z', + releaseTimestamp: '2023-09-05T20:02:55.000Z', version: 'v0.0.0-20230905200255-921286631fa9', }, ], diff --git a/lib/modules/datasource/go/releases-goproxy.ts b/lib/modules/datasource/go/releases-goproxy.ts index 4464a2e33b6a57998df969d75cf1ada43e01e9a4..e3f87682a3478f280d976b80fce71970b7cbb40f 100644 --- a/lib/modules/datasource/go/releases-goproxy.ts +++ b/lib/modules/datasource/go/releases-goproxy.ts @@ -1,5 +1,4 @@ import is from '@sindresorhus/is'; -import { DateTime } from 'luxon'; import { logger } from '../../../logger'; import { ExternalHostError } from '../../../types/errors/external-host-error'; import { cache } from '../../../util/cache/package/decorator'; @@ -7,6 +6,7 @@ import { filterMap } from '../../../util/filter-map'; import { HttpError } from '../../../util/http'; import * as p from '../../../util/promises'; import { newlineRegex, regEx } from '../../../util/regex'; +import { asTimestamp } from '../../../util/timestamp'; import { joinUrlParts } from '../../../util/url'; import goVersioning from '../../versioning/go-mod-directive'; import { Datasource } from '../datasource'; @@ -33,9 +33,7 @@ export function pseudoVersionToRelease(pseudoVersion: string): Release | null { } const { digest: newDigest, timestamp } = match; - const releaseTimestamp = DateTime.fromFormat(timestamp, 'yyyyMMddHHmmss', { - zone: 'UTC', - }).toISO({ suppressMilliseconds: true }); + const releaseTimestamp = asTimestamp(timestamp); return { version: pseudoVersion, @@ -142,9 +140,10 @@ export class GoProxyDatasource extends Datasource { return null; } - const [version, releaseTimestamp] = str.trim().split(regEx(/\s+/)); + const [version, timestamp] = str.trim().split(regEx(/\s+/)); const release: Release = pseudoVersionToRelease(version) ?? { version }; + const releaseTimestamp = asTimestamp(timestamp); if (releaseTimestamp) { release.releaseTimestamp = releaseTimestamp; } @@ -170,8 +169,9 @@ export class GoProxyDatasource extends Datasource { version: res.body.Version, }; - if (res.body.Time) { - result.releaseTimestamp = res.body.Time; + const releaseTimestamp = asTimestamp(res.body.Time); + if (releaseTimestamp) { + result.releaseTimestamp = releaseTimestamp; } return result; diff --git a/lib/modules/datasource/golang-version/index.ts b/lib/modules/datasource/golang-version/index.ts index 65e7d9b87b37c3e0428d2aeb9a63c5a499c4f5dc..6d355a60aeb4bc94a87e2bc0b4fbfc05136b8aad 100644 --- a/lib/modules/datasource/golang-version/index.ts +++ b/lib/modules/datasource/golang-version/index.ts @@ -1,6 +1,7 @@ import { ExternalHostError } from '../../../types/errors/external-host-error'; import { cache } from '../../../util/cache/package/decorator'; import { regEx } from '../../../util/regex'; +import { asTimestamp } from '../../../util/timestamp'; import { joinUrlParts } from '../../../util/url'; import { isVersion, id as semverVersioningId } from '../../versioning/semver'; import { Datasource } from '../datasource'; @@ -111,7 +112,9 @@ export class GolangVersionDatasource extends Datasource { const year = releaseDateMatch.groups.year.padStart(4, '0'); const month = releaseDateMatch.groups.month.padStart(2, '0'); const day = releaseDateMatch.groups.day.padStart(2, '0'); - release.releaseTimestamp = `${year}-${month}-${day}T00:00:00.000Z`; + release.releaseTimestamp = asTimestamp( + `${year}-${month}-${day}T00:00:00.000Z`, + ); } const releaseVersionMatch = releaseVersionRegex.exec(line); if (releaseVersionMatch?.groups) { diff --git a/lib/modules/datasource/gradle-version/index.ts b/lib/modules/datasource/gradle-version/index.ts index 4667b6891955ca34c542e04d019287d35def92c1..d733216953e9cca650880e49b193b5dd85222547 100644 --- a/lib/modules/datasource/gradle-version/index.ts +++ b/lib/modules/datasource/gradle-version/index.ts @@ -1,5 +1,5 @@ import { cache } from '../../../util/cache/package/decorator'; -import { regEx } from '../../../util/regex'; +import { asTimestamp } from '../../../util/timestamp'; import * as gradleVersioning from '../../versioning/gradle'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, Release, ReleaseResult } from '../types'; @@ -27,10 +27,6 @@ export class GradleVersionDatasource extends Datasource { override readonly sourceUrlNote = 'We use the URL: https://github.com/gradle/gradle.'; - private static readonly buildTimeRegex = regEx( - '^(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\+\\d\\d\\d\\d)$', - ); - @cache({ namespace: `datasource-${GradleVersionDatasource.id}`, // TODO: types (#22198) @@ -55,8 +51,7 @@ export class GradleVersionDatasource extends Datasource { const gitRef = GradleVersionDatasource.getGitRef(release.version); - const releaseTimestamp = - GradleVersionDatasource.formatBuildTime(buildTime); + const releaseTimestamp = asTimestamp(buildTime); const result: Release = { version, gitRef, releaseTimestamp }; @@ -81,19 +76,6 @@ export class GradleVersionDatasource extends Datasource { return null; } - private static formatBuildTime(timeStr: string): string | null { - if (!timeStr) { - return null; - } - if (GradleVersionDatasource.buildTimeRegex.test(timeStr)) { - return timeStr.replace( - GradleVersionDatasource.buildTimeRegex, - '$1-$2-$3T$4:$5:$6$7', - ); - } - return null; - } - /** * Calculate `gitTag` based on `version`: * - `8.1.2` -> `v8.1.2` diff --git a/lib/modules/datasource/helm/schema.ts b/lib/modules/datasource/helm/schema.ts index d10d90120b86ab4e03bb01ec897cb1e697f2fd31..64465295c67d86d3550fe0a94ba0d2fee58a1bdd 100644 --- a/lib/modules/datasource/helm/schema.ts +++ b/lib/modules/datasource/helm/schema.ts @@ -3,11 +3,12 @@ import { detectPlatform } from '../../../util/common'; import { parseGitUrl } from '../../../util/git/url'; import { regEx } from '../../../util/regex'; import { LooseRecord } from '../../../util/schema-utils'; +import { MaybeTimestamp } from '../../../util/timestamp'; import type { Release } from '../types'; const HelmReleaseSchema = z.object({ version: z.string(), - created: z.string().nullable().catch(null), + created: MaybeTimestamp, digest: z.string().optional().catch(undefined), home: z.string().optional().catch(undefined), sources: z.array(z.string()).catch([]), diff --git a/lib/modules/datasource/hex/schema.ts b/lib/modules/datasource/hex/schema.ts index a04aa81a49f39980a24b66884e318f2394ffbd65..be37b11f93c575eee646d2cf653bc295f92f056c 100644 --- a/lib/modules/datasource/hex/schema.ts +++ b/lib/modules/datasource/hex/schema.ts @@ -1,6 +1,7 @@ import is from '@sindresorhus/is'; import { z } from 'zod'; import { LooseArray } from '../../../util/schema-utils'; +import { MaybeTimestamp } from '../../../util/timestamp'; import type { Release, ReleaseResult } from '../types'; export const HexRelease = z @@ -29,7 +30,7 @@ export const HexRelease = z releases: LooseArray( z.object({ version: z.string(), - inserted_at: z.string().optional(), + inserted_at: MaybeTimestamp, }), ).refine((releases) => releases.length > 0, 'No releases found'), retirements: z diff --git a/lib/modules/datasource/hexpm-bob/index.ts b/lib/modules/datasource/hexpm-bob/index.ts index c841f26e9a38d46dc2e8f7c289016fa73a206bd6..817df0a53aebcbef9bbcb5376c8635a72f1d875c 100644 --- a/lib/modules/datasource/hexpm-bob/index.ts +++ b/lib/modules/datasource/hexpm-bob/index.ts @@ -3,6 +3,7 @@ import { logger } from '../../../logger'; import { ExternalHostError } from '../../../types/errors/external-host-error'; import { cache } from '../../../util/cache/package/decorator'; import { HttpError } from '../../../util/http'; +import { asTimestamp } from '../../../util/timestamp'; import { id as semverId } from '../../versioning/semver'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, ReleaseResult } from '../types'; @@ -69,7 +70,7 @@ export class HexpmBobDatasource extends Datasource { return { gitRef, isStable: HexpmBobDatasource.isStable(version, packageType), - releaseTimestamp: buildDate, + releaseTimestamp: asTimestamp(buildDate), version: HexpmBobDatasource.cleanVersion(version, packageType), }; }); diff --git a/lib/modules/datasource/jenkins-plugins/index.spec.ts b/lib/modules/datasource/jenkins-plugins/index.spec.ts index 65cb05070d7e9443fc139f6d84b6091e1020cb00..d8bee66fb89b6b619bcb6679d5e638c26a5f39fb 100644 --- a/lib/modules/datasource/jenkins-plugins/index.spec.ts +++ b/lib/modules/datasource/jenkins-plugins/index.spec.ts @@ -1,5 +1,6 @@ import { getPkgReleases } from '..'; import * as httpMock from '../../../../test/http-mock'; +import type { Timestamp } from '../../../util/timestamp'; import * as versioning from '../../versioning/docker'; import type { JenkinsPluginsInfoResponse, @@ -31,7 +32,7 @@ const jenkinsPluginsVersions: JenkinsPluginsVersionsResponse = { '3.0.0': { version: '3.0.0', url: 'https://download.example.com', - releaseTimestamp: '2020-05-13T00:11:40.00Z', + releaseTimestamp: '2020-05-13T00:11:40.00Z' as Timestamp, requiredCore: '2.164.3', }, }, @@ -87,12 +88,12 @@ describe('modules/datasource/jenkins-plugins/index', () => { }, { downloadUrl: 'https://download.example.com', - releaseTimestamp: '2020-01-02T00:00:00.000Z', + releaseTimestamp: '2020-01-02T00:00:00.000Z' as Timestamp, version: '2.0.0', }, { downloadUrl: 'https://download.example.com', - releaseTimestamp: '2020-05-13T00:11:40.000Z', + releaseTimestamp: '2020-05-13T00:11:40.000Z' as Timestamp, version: '3.0.0', }, ], @@ -155,12 +156,12 @@ describe('modules/datasource/jenkins-plugins/index', () => { }, { downloadUrl: 'https://download.example.com', - releaseTimestamp: '2020-01-02T00:00:00.000Z', + releaseTimestamp: '2020-01-02T00:00:00.000Z' as Timestamp, version: '2.0.0', }, { downloadUrl: 'https://download.example.com', - releaseTimestamp: '2020-05-13T00:11:40.000Z', + releaseTimestamp: '2020-05-13T00:11:40.000Z' as Timestamp, version: '3.0.0', }, ], diff --git a/lib/modules/datasource/jenkins-plugins/index.ts b/lib/modules/datasource/jenkins-plugins/index.ts index 1f846c1c240e0222def0ac820f95f4e7215ed420..02fa74fdf602544fa453b22501d46518aff1da06 100644 --- a/lib/modules/datasource/jenkins-plugins/index.ts +++ b/lib/modules/datasource/jenkins-plugins/index.ts @@ -1,6 +1,7 @@ import { logger } from '../../../logger'; import { cache } from '../../../util/cache/package/decorator'; import { clone } from '../../../util/clone'; +import { asTimestamp } from '../../../util/timestamp'; import { ensureTrailingSlash } from '../../../util/url'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, Release, ReleaseResult } from '../types'; @@ -96,8 +97,7 @@ export class JenkinsPluginsDatasource extends Datasource { const downloadUrl = plugins[name][version]?.url; const buildDate = plugins[name][version]?.buildDate; const releaseTimestamp = - plugins[name][version]?.releaseTimestamp ?? - (buildDate ? new Date(`${buildDate} UTC`).toISOString() : null); + plugins[name][version]?.releaseTimestamp ?? asTimestamp(buildDate); const jenkins = plugins[name][version]?.requiredCore; const constraints = jenkins ? { jenkins: [`>=${jenkins}`] } : undefined; return { diff --git a/lib/modules/datasource/jenkins-plugins/types.ts b/lib/modules/datasource/jenkins-plugins/types.ts index 5224ff1072240dc1e1dc542303fa1cd9828e7aac..b8e350bebc59272d279f117eefa21f80a02d8504 100644 --- a/lib/modules/datasource/jenkins-plugins/types.ts +++ b/lib/modules/datasource/jenkins-plugins/types.ts @@ -1,3 +1,5 @@ +import type { Timestamp } from '../../../util/timestamp'; + export interface JenkinsPluginInfo { name: string; scm?: string; @@ -9,7 +11,7 @@ export interface JenkinsPluginVersion { url?: string; requiredCore?: string; - releaseTimestamp?: string; + releaseTimestamp?: Timestamp; } export interface JenkinsPluginsInfoResponse { diff --git a/lib/modules/datasource/maven/index.ts b/lib/modules/datasource/maven/index.ts index b35bc6996a59bb666affdeea9b20578e9e468285..32ac272918fe578909e6214172b99ddbb256fe7c 100644 --- a/lib/modules/datasource/maven/index.ts +++ b/lib/modules/datasource/maven/index.ts @@ -4,6 +4,7 @@ import { GlobalConfig } from '../../../config/global'; import { logger } from '../../../logger'; import * as packageCache from '../../../util/cache/package'; import { cache } from '../../../util/cache/package/decorator'; +import { asTimestamp } from '../../../util/timestamp'; import { ensureTrailingSlash } from '../../../util/url'; import mavenVersion from '../../versioning/maven'; import * as mavenVersioning from '../../versioning/maven'; @@ -198,7 +199,7 @@ export class MavenDatasource extends Datasource { } if (is.date(res)) { - release.releaseTimestamp = res.toISOString(); + release.releaseTimestamp = asTimestamp(res.toISOString()); } return release; diff --git a/lib/modules/datasource/metadata.spec.ts b/lib/modules/datasource/metadata.spec.ts index 645d270f98ae1bf2b58ce6a29a9334bbe7760632..87a73eb8c65adab6c3a761cd694244f5b7e5e800 100644 --- a/lib/modules/datasource/metadata.spec.ts +++ b/lib/modules/datasource/metadata.spec.ts @@ -1,4 +1,5 @@ import { partial } from '../../../test/util'; +import type { Timestamp } from '../../util/timestamp'; import { HelmDatasource } from './helm'; import { MavenDatasource } from './maven'; import { @@ -15,13 +16,22 @@ describe('modules/datasource/metadata', () => { it('Should handle manualChangelogUrls', () => { const dep: ReleaseResult = { releases: [ - { version: '2.0.0', releaseTimestamp: '2018-07-13T10:14:17.000Z' }, + { + version: '2.0.0', + releaseTimestamp: '2018-07-13T10:14:17.000Z' as Timestamp, + }, { version: '2.0.0.dev1', - releaseTimestamp: '2017-10-24T10:09:16.000Z', + releaseTimestamp: '2017-10-24T10:09:16.000Z' as Timestamp, + }, + { + version: '2.1.0', + releaseTimestamp: '2019-01-20T19:59:28.000Z' as Timestamp, + }, + { + version: '2.2.0', + releaseTimestamp: '2019-07-16T18:29:00.000Z' as Timestamp, }, - { version: '2.1.0', releaseTimestamp: '2019-01-20T19:59:28.000Z' }, - { version: '2.2.0', releaseTimestamp: '2019-07-16T18:29:00.000Z' }, ], }; @@ -38,13 +48,22 @@ describe('modules/datasource/metadata', () => { it('Should handle manualSourceUrls', () => { const dep: ReleaseResult = { releases: [ - { version: '2.0.0', releaseTimestamp: '2018-07-13T10:14:17.000Z' }, + { + version: '2.0.0', + releaseTimestamp: '2018-07-13T10:14:17.000Z' as Timestamp, + }, { version: '2.0.0.dev1', - releaseTimestamp: '2017-10-24T10:09:16.000Z', + releaseTimestamp: '2017-10-24T10:09:16.000Z' as Timestamp, + }, + { + version: '2.1.0', + releaseTimestamp: '2019-01-20T19:59:28.000Z' as Timestamp, + }, + { + version: '2.2.0', + releaseTimestamp: '2019-07-16T18:29:00.000Z' as Timestamp, }, - { version: '2.1.0', releaseTimestamp: '2019-01-20T19:59:28.000Z' }, - { version: '2.2.0', releaseTimestamp: '2019-07-16T18:29:00.000Z' }, ], }; @@ -61,13 +80,22 @@ describe('modules/datasource/metadata', () => { const dep: ReleaseResult = { sourceUrl: 'https://github.com/carltongibson/django-filter/tree/master', releases: [ - { version: '2.0.0', releaseTimestamp: '2018-07-13T10:14:17.000Z' }, + { + version: '2.0.0', + releaseTimestamp: '2018-07-13T10:14:17.000Z' as Timestamp, + }, { version: '2.0.0.dev1', - releaseTimestamp: '2017-10-24T10:09:16.000Z', + releaseTimestamp: '2017-10-24T10:09:16.000Z' as Timestamp, + }, + { + version: '2.1.0', + releaseTimestamp: '2019-01-20T19:59:28.000Z' as Timestamp, + }, + { + version: '2.2.0', + releaseTimestamp: '2019-07-16T18:29:00.000Z' as Timestamp, }, - { version: '2.1.0', releaseTimestamp: '2019-01-20T19:59:28.000Z' }, - { version: '2.2.0', releaseTimestamp: '2019-07-16T18:29:00.000Z' }, ], }; const datasource = PypiDatasource.id; @@ -142,13 +170,22 @@ describe('modules/datasource/metadata', () => { const dep: ReleaseResult = { sourceUrl: 'https://some.github.com/repo', releases: [ - { version: '2.0.0', releaseTimestamp: '2018-07-13T10:14:17.000Z' }, + { + version: '2.0.0', + releaseTimestamp: '2018-07-13T10:14:17.000Z' as Timestamp, + }, { version: '2.0.0.dev1', - releaseTimestamp: '2017-10-24T10:09:16.000Z', + releaseTimestamp: '2017-10-24T10:09:16.000Z' as Timestamp, + }, + { + version: '2.1.0', + releaseTimestamp: '2019-01-20T19:59:28.000Z' as Timestamp, + }, + { + version: '2.2.0', + releaseTimestamp: '2019-07-16T18:29:00.000Z' as Timestamp, }, - { version: '2.1.0', releaseTimestamp: '2019-01-20T19:59:28.000Z' }, - { version: '2.2.0', releaseTimestamp: '2019-07-16T18:29:00.000Z' }, ], }; const datasource = PypiDatasource.id; @@ -164,10 +201,13 @@ describe('modules/datasource/metadata', () => { const dep: ReleaseResult = { sourceUrl: 'https://gitlab.com/meno/dropzone/tree/master', releases: [ - { version: '5.7.0', releaseTimestamp: '2020-02-14T13:12:00.000Z' }, + { + version: '5.7.0', + releaseTimestamp: '2020-02-14T13:12:00.000Z' as Timestamp, + }, { version: '5.6.1', - releaseTimestamp: '2020-02-14T10:04:00.000Z', + releaseTimestamp: '2020-02-14T10:04:00.000Z' as Timestamp, }, ], }; @@ -184,10 +224,13 @@ describe('modules/datasource/metadata', () => { const dep = { sourceUrl: 'https://gitlab-nope', releases: [ - { version: '5.7.0', releaseTimestamp: '2020-02-14T13:12:00.000Z' }, + { + version: '5.7.0', + releaseTimestamp: '2020-02-14T13:12:00.000Z' as Timestamp, + }, { version: '5.6.1', - releaseTimestamp: '2020-02-14T10:04:00.000Z', + releaseTimestamp: '2020-02-14T10:04:00.000Z' as Timestamp, }, ], }; @@ -204,10 +247,13 @@ describe('modules/datasource/metadata', () => { const dep = { sourceUrl: 'https://nope-nope-nope', releases: [ - { version: '5.7.0', releaseTimestamp: '2020-02-14T13:12:00.000Z' }, + { + version: '5.7.0', + releaseTimestamp: '2020-02-14T13:12:00.000Z' as Timestamp, + }, { version: '5.6.1', - releaseTimestamp: '2020-02-14T10:04:00.000Z', + releaseTimestamp: '2020-02-14T10:04:00.000Z' as Timestamp, }, ], }; @@ -224,10 +270,13 @@ describe('modules/datasource/metadata', () => { const dep = { sourceUrl: 'not-a-url', releases: [ - { version: '5.7.0', releaseTimestamp: '2020-02-14T13:12:00.000Z' }, + { + version: '5.7.0', + releaseTimestamp: '2020-02-14T13:12:00.000Z' as Timestamp, + }, { version: '5.6.1', - releaseTimestamp: '2020-02-14T10:04:00.000Z', + releaseTimestamp: '2020-02-14T10:04:00.000Z' as Timestamp, }, ], }; @@ -280,10 +329,19 @@ describe('modules/datasource/metadata', () => { it('Should normalize releaseTimestamp', () => { const dep = { releases: [ - { version: '1.0.1', releaseTimestamp: '2000-01-01T12:34:56' }, - { version: '1.0.2', releaseTimestamp: '2000-01-02T12:34:56.000Z' }, - { version: '1.0.3', releaseTimestamp: '2000-01-03T14:34:56.000+02:00' }, - { version: '1.0.4', releaseTimestamp: '20000103150210' }, + { + version: '1.0.1', + releaseTimestamp: '2000-01-01T12:34:56' as Timestamp, + }, + { + version: '1.0.2', + releaseTimestamp: '2000-01-02T12:34:56.000Z' as Timestamp, + }, + { + version: '1.0.3', + releaseTimestamp: '2000-01-03T14:34:56.000+02:00' as Timestamp, + }, + { version: '1.0.4', releaseTimestamp: '20000103150210' as Timestamp }, ], }; addMetaData(dep, MavenDatasource.id, 'foobar'); @@ -374,9 +432,18 @@ describe('modules/datasource/metadata', () => { homepage: 'https://github.com/foo/bar', sourceUrl: 'https://github.com/foo/bar', releases: [ - { version: '1.0.1', releaseTimestamp: '2000-01-01T12:34:56' }, - { version: '1.0.2', releaseTimestamp: '2000-01-02T12:34:56.000Z' }, - { version: '1.0.3', releaseTimestamp: '2000-01-03T14:34:56.000+02:00' }, + { + version: '1.0.1', + releaseTimestamp: '2000-01-01T12:34:56' as Timestamp, + }, + { + version: '1.0.2', + releaseTimestamp: '2000-01-02T12:34:56.000Z' as Timestamp, + }, + { + version: '1.0.3', + releaseTimestamp: '2000-01-03T14:34:56.000+02:00' as Timestamp, + }, ], }; addMetaData(dep, MavenDatasource.id, 'foobar'); @@ -404,9 +471,18 @@ describe('modules/datasource/metadata', () => { sourceUrl: 'https://gitlab.com/meno/repo', homepage: 'https://gitlab.com/meno/repo', releases: [ - { version: '1.0.1', releaseTimestamp: '2000-01-01T12:34:56' }, - { version: '1.0.2', releaseTimestamp: '2000-01-02T12:34:56.000Z' }, - { version: '1.0.3', releaseTimestamp: '2000-01-03T14:34:56.000+02:00' }, + { + version: '1.0.1', + releaseTimestamp: '2000-01-01T12:34:56' as Timestamp, + }, + { + version: '1.0.2', + releaseTimestamp: '2000-01-02T12:34:56.000Z' as Timestamp, + }, + { + version: '1.0.3', + releaseTimestamp: '2000-01-03T14:34:56.000+02:00' as Timestamp, + }, ], }; addMetaData(dep, MavenDatasource.id, 'foobar'); @@ -433,9 +509,18 @@ describe('modules/datasource/metadata', () => { const dep = { sourceUrl: 'https://gitlab.com/meno/repo', releases: [ - { version: '1.0.1', releaseTimestamp: '2000-01-01T12:34:56' }, - { version: '1.0.2', releaseTimestamp: '2000-01-02T12:34:56.000Z' }, - { version: '1.0.3', releaseTimestamp: '2000-01-03T14:34:56.000+02:00' }, + { + version: '1.0.1', + releaseTimestamp: '2000-01-01T12:34:56' as Timestamp, + }, + { + version: '1.0.2', + releaseTimestamp: '2000-01-02T12:34:56.000Z' as Timestamp, + }, + { + version: '1.0.3', + releaseTimestamp: '2000-01-03T14:34:56.000+02:00' as Timestamp, + }, ], }; addMetaData(dep, MavenDatasource.id, 'foobar'); @@ -462,9 +547,18 @@ describe('modules/datasource/metadata', () => { const dep = { homepage: 'https://somesource.com/', releases: [ - { version: '1.0.1', releaseTimestamp: '2000-01-01T12:34:56' }, - { version: '1.0.2', releaseTimestamp: '2000-01-02T12:34:56.000Z' }, - { version: '1.0.3', releaseTimestamp: '2000-01-03T14:34:56.000+02:00' }, + { + version: '1.0.1', + releaseTimestamp: '2000-01-01T12:34:56' as Timestamp, + }, + { + version: '1.0.2', + releaseTimestamp: '2000-01-02T12:34:56.000Z' as Timestamp, + }, + { + version: '1.0.3', + releaseTimestamp: '2000-01-03T14:34:56.000+02:00' as Timestamp, + }, ], }; addMetaData(dep, MavenDatasource.id, 'foobar'); diff --git a/lib/modules/datasource/node-version/index.ts b/lib/modules/datasource/node-version/index.ts index aba6bd7da83e63b974db114ddacad702bc85fe27..c5caf6d8ed4898d077b38168362f62f970be0bbc 100644 --- a/lib/modules/datasource/node-version/index.ts +++ b/lib/modules/datasource/node-version/index.ts @@ -1,4 +1,5 @@ import { cache } from '../../../util/cache/package/decorator'; +import { asTimestamp } from '../../../util/timestamp'; import { joinUrlParts } from '../../../util/url'; import { id as versioning } from '../../versioning/node'; import { Datasource } from '../datasource'; @@ -53,7 +54,7 @@ export class NodeVersionDatasource extends Datasource { result.releases.push( ...resp.map(({ version, date, lts }) => ({ version, - releaseTimestamp: date, + releaseTimestamp: asTimestamp(date), isStable: lts !== false, })), ); diff --git a/lib/modules/datasource/npm/get.ts b/lib/modules/datasource/npm/get.ts index ec6cc4e5576055e280698aed40b234bf48580c83..4bee6946abd0dcb6ac427c9256be3145446d8219 100644 --- a/lib/modules/datasource/npm/get.ts +++ b/lib/modules/datasource/npm/get.ts @@ -12,6 +12,7 @@ import type { Http } from '../../../util/http'; import type { HttpOptions } from '../../../util/http/types'; import { regEx } from '../../../util/regex'; import { HttpCacheStats } from '../../../util/stats'; +import { asTimestamp } from '../../../util/timestamp'; import { joinUrlParts } from '../../../util/url'; import type { Release, ReleaseResult } from '../types'; import type { CachedReleaseResult, NpmResponse } from './types'; @@ -199,8 +200,9 @@ export async function getDependency( dependencies: res.versions?.[version].dependencies, devDependencies: res.versions?.[version].devDependencies, }; - if (res.time?.[version]) { - release.releaseTimestamp = res.time[version]; + const releaseTimestamp = asTimestamp(res.time?.[version]); + if (releaseTimestamp) { + release.releaseTimestamp = releaseTimestamp; } if (res.versions?.[version].deprecated) { release.isDeprecated = true; diff --git a/lib/modules/datasource/nuget/v2.ts b/lib/modules/datasource/nuget/v2.ts index 48c89d34b4a6fd30955a62d842b693c3b3b3bb9c..b542298eadcb9354712015d23257c1bc6f534c1e 100644 --- a/lib/modules/datasource/nuget/v2.ts +++ b/lib/modules/datasource/nuget/v2.ts @@ -3,6 +3,7 @@ import { XmlDocument } from 'xmldoc'; import { logger } from '../../../logger'; import type { Http } from '../../../util/http'; import { regEx } from '../../../util/regex'; +import { asTimestamp } from '../../../util/timestamp'; import type { ReleaseResult } from '../types'; import { massageUrl, removeBuildMeta } from './common'; @@ -32,7 +33,9 @@ export class NugetV2Api { for (const pkgInfo of pkgInfoList) { const version = this.getPkgProp(pkgInfo, 'Version'); - const releaseTimestamp = this.getPkgProp(pkgInfo, 'Published'); + const releaseTimestamp = asTimestamp( + this.getPkgProp(pkgInfo, 'Published'), + ); dep.releases.push({ // TODO: types (#22198) version: removeBuildMeta(`${version}`), diff --git a/lib/modules/datasource/nuget/v3.ts b/lib/modules/datasource/nuget/v3.ts index b773b5865f7660608838b2b4e865f19d0ebe2545..2492c02d70a674de8985f5a554d1ade5a0e8eb46 100644 --- a/lib/modules/datasource/nuget/v3.ts +++ b/lib/modules/datasource/nuget/v3.ts @@ -13,6 +13,7 @@ import type { Http } from '../../../util/http'; import { HttpError } from '../../../util/http'; import * as p from '../../../util/promises'; import { regEx } from '../../../util/regex'; +import { asTimestamp } from '../../../util/timestamp'; import { ensureTrailingSlash } from '../../../util/url'; import { api as versioning } from '../../versioning/nuget'; import type { Release, ReleaseResult } from '../types'; @@ -161,14 +162,9 @@ export class NugetV3Api { let latestStable: string | null = null; let nupkgUrl: string | null = null; const releases = catalogEntries.map( - ({ - version, - published: releaseTimestamp, - projectUrl, - listed, - packageContent, - }) => { + ({ version, published, projectUrl, listed, packageContent }) => { const release: Release = { version: removeBuildMeta(version) }; + const releaseTimestamp = asTimestamp(published); if (releaseTimestamp) { release.releaseTimestamp = releaseTimestamp; } diff --git a/lib/modules/datasource/orb/index.ts b/lib/modules/datasource/orb/index.ts index 80fa61e4e93204335a720f52a6f960da1035e916..0de66700aee4fc928fd94dd1ea014e690512a858 100644 --- a/lib/modules/datasource/orb/index.ts +++ b/lib/modules/datasource/orb/index.ts @@ -1,5 +1,6 @@ import { logger } from '../../../logger'; import { cache } from '../../../util/cache/package/decorator'; +import { asTimestamp } from '../../../util/timestamp'; import { joinUrlParts } from '../../../util/url'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, ReleaseResult } from '../types'; @@ -71,7 +72,7 @@ export class OrbDatasource extends Datasource { : `https://circleci.com/developer/orbs/orb/${packageName}`; const releases = orb.versions.map(({ version, createdAt }) => ({ version, - releaseTimestamp: createdAt ?? null, + releaseTimestamp: asTimestamp(createdAt), })); const dep = { homepage, isPrivate: !!orb.isPrivate, releases }; diff --git a/lib/modules/datasource/packagist/schema.spec.ts b/lib/modules/datasource/packagist/schema.spec.ts index a83918d124f34e6f1143833e1f3862cc79b83c72..6f8b759ded16708b287bf947041d7855179ffbdb 100644 --- a/lib/modules/datasource/packagist/schema.spec.ts +++ b/lib/modules/datasource/packagist/schema.spec.ts @@ -1,3 +1,4 @@ +import type { Timestamp } from '../../../util/timestamp'; import type { ReleaseResult } from '../types'; import { ComposerRelease, @@ -144,10 +145,13 @@ describe('modules/datasource/packagist/schema', () => { }); expect( - ComposerRelease.parse({ version: '1.2.3', time: '12345' }), + ComposerRelease.parse({ + version: '1.2.3', + time: '2025-01-16T12:00:00.000Z', + }), ).toEqual({ version: '1.2.3', - time: '12345', + time: '2025-01-16T12:00:00.000Z', homepage: null, source: null, require: null, @@ -312,7 +316,7 @@ describe('modules/datasource/packagist/schema', () => { 'foo/bar': [ { version: 'v1.1.1', - time: '111', + time: '2025-01-16T12:00:00+00:00' as Timestamp, homepage: 'https://example.com/1', source: { url: 'git@example.com:foo/bar-1' }, require: { php: '^8.0' }, @@ -321,7 +325,7 @@ describe('modules/datasource/packagist/schema', () => { 'baz/qux': [ { version: 'v2.2.2', - time: '222', + time: '2025-01-16T12:00:00+00:00' as Timestamp, homepage: 'https://example.com/2', source: { url: 'git@example.com:baz/qux-2' }, require: null, @@ -334,7 +338,7 @@ describe('modules/datasource/packagist/schema', () => { 'foo/bar': [ { version: 'v3.3.3', - time: '333', + time: '2025-01-16T12:00:00+00:00' as Timestamp, homepage: 'https://example.com/3', source: { url: 'git@example.com:foo/bar-3' }, require: { php: '^7.0' }, @@ -343,7 +347,7 @@ describe('modules/datasource/packagist/schema', () => { 'baz/qux': [ { version: 'v4.4.4', - time: '444', + time: '2025-01-16T12:00:00+00:00' as Timestamp, homepage: 'https://example.com/4', source: { url: 'git@example.com:baz/qux-3' }, require: null, @@ -359,13 +363,13 @@ describe('modules/datasource/packagist/schema', () => { { version: '1.1.1', gitRef: 'v1.1.1', - releaseTimestamp: '111', + releaseTimestamp: '2025-01-16T12:00:00.000Z' as Timestamp, constraints: { php: ['^8.0'] }, }, { version: '3.3.3', gitRef: 'v3.3.3', - releaseTimestamp: '333', + releaseTimestamp: '2025-01-16T12:00:00.000Z' as Timestamp, constraints: { php: ['^7.0'] }, }, ], diff --git a/lib/modules/datasource/packagist/schema.ts b/lib/modules/datasource/packagist/schema.ts index 2d95b2ad95d6115fc7e73c4dedbe314a2b8aa849..29af76574d5b3c87d683da6827712afb73b699bd 100644 --- a/lib/modules/datasource/packagist/schema.ts +++ b/lib/modules/datasource/packagist/schema.ts @@ -2,6 +2,7 @@ import is from '@sindresorhus/is'; import { z } from 'zod'; import { logger } from '../../../logger'; import { LooseArray, LooseRecord } from '../../../util/schema-utils'; +import { MaybeTimestamp } from '../../../util/timestamp'; import type { Release, ReleaseResult } from '../types'; export const MinifiedArray = z.array(z.record(z.unknown())).transform((xs) => { @@ -44,7 +45,7 @@ export const ComposerRelease = z.object({ version: z.string(), homepage: z.string().nullable().catch(null), source: z.object({ url: z.string() }).nullable().catch(null), - time: z.string().nullable().catch(null), + time: MaybeTimestamp, require: z.object({ php: z.string() }).nullable().catch(null), }); export type ComposerRelease = z.infer<typeof ComposerRelease>; diff --git a/lib/modules/datasource/postprocess-release.spec.ts b/lib/modules/datasource/postprocess-release.spec.ts index 3ec6de9abd8e99781d08d2cd935ba0b53294bacf..9efbbbc3a8ebcf52e834ea5436b84909f19bfe9d 100644 --- a/lib/modules/datasource/postprocess-release.spec.ts +++ b/lib/modules/datasource/postprocess-release.spec.ts @@ -1,4 +1,5 @@ import { mocked } from '../../../test/util'; +import type { Timestamp } from '../../util/timestamp'; import * as _datasourceCommon from './common'; import { Datasource } from './datasource'; import { postprocessRelease } from './postprocess-release'; @@ -86,7 +87,7 @@ describe('modules/datasource/postprocess-release', () => { _config: PostprocessReleaseConfig, release: Release, ): Promise<PostprocessReleaseResult> { - release.releaseTimestamp = '2024-09-05'; + release.releaseTimestamp = '2024-09-05' as Timestamp; return Promise.resolve(release); } } diff --git a/lib/modules/datasource/puppet-forge/index.ts b/lib/modules/datasource/puppet-forge/index.ts index 9bed72a5444d844a1d294ba024a48e8639b1b140..41b45a6a5b998ccf34ca385e96c1803489dd4199 100644 --- a/lib/modules/datasource/puppet-forge/index.ts +++ b/lib/modules/datasource/puppet-forge/index.ts @@ -1,3 +1,4 @@ +import { asTimestamp } from '../../../util/timestamp'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, Release, ReleaseResult } from '../types'; import { PUPPET_FORGE } from './common'; @@ -37,7 +38,7 @@ export class PuppetForgeDatasource extends Datasource { const releases: Release[] = module?.releases?.map((release) => ({ version: release.version, downloadUrl: release.file_uri, - releaseTimestamp: release.created_at, + releaseTimestamp: asTimestamp(release.created_at), registryUrl, })); diff --git a/lib/modules/datasource/pypi/index.ts b/lib/modules/datasource/pypi/index.ts index 16bcb1bcc9fc77a8877ce22bdf0b71b1b079573d..48fda7604991f10ebe8345d1b153176351108bb7 100644 --- a/lib/modules/datasource/pypi/index.ts +++ b/lib/modules/datasource/pypi/index.ts @@ -6,6 +6,7 @@ import { coerceArray } from '../../../util/array'; import { parse } from '../../../util/html'; import type { OutgoingHttpHeaders } from '../../../util/http/types'; import { regEx } from '../../../util/regex'; +import { asTimestamp } from '../../../util/timestamp'; import { ensureTrailingSlash, parseUrl } from '../../../util/url'; import * as pep440 from '../../versioning/pep440'; import { Datasource } from '../datasource'; @@ -173,7 +174,7 @@ export class PypiDatasource extends Datasource { const isDeprecated = releases.some(({ yanked }) => yanked); const result: Release = { version, - releaseTimestamp, + releaseTimestamp: asTimestamp(releaseTimestamp), }; if (isDeprecated) { result.isDeprecated = isDeprecated; diff --git a/lib/modules/datasource/python-version/index.spec.ts b/lib/modules/datasource/python-version/index.spec.ts index 4333bfe0cec3447d5673c914fa99ec1f5008b82d..dea8e2d3510601516e842e72fd040bc86afb19a0 100644 --- a/lib/modules/datasource/python-version/index.spec.ts +++ b/lib/modules/datasource/python-version/index.spec.ts @@ -4,6 +4,7 @@ import { Fixtures } from '../../../../test/fixtures'; import * as httpMock from '../../../../test/http-mock'; import { EXTERNAL_HOST_ERROR } from '../../../constants/error-messages'; import * as githubGraphql from '../../../util/github/graphql'; +import type { Timestamp } from '../../../util/timestamp'; import { registryUrl as eolRegistryUrl } from '../endoflife-date/common'; import { datasource, defaultRegistryUrl } from './common'; import { PythonVersionDatasource } from '.'; @@ -38,7 +39,7 @@ describe('modules/datasource/python-version/index', () => { name: 'containerbase/python-prebuild', description: 'some description', version: '3.12.1', - releaseTimestamp: '2020-03-09T13:00:00Z', + releaseTimestamp: '2020-03-09T13:00:00Z' as Timestamp, }, { id: 2, @@ -46,7 +47,7 @@ describe('modules/datasource/python-version/index', () => { name: 'containerbase/python-prebuild', description: 'some description', version: '3.12.0', - releaseTimestamp: '2020-03-09T13:00:00Z', + releaseTimestamp: '2020-03-09T13:00:00Z' as Timestamp, }, { id: 3, @@ -54,7 +55,7 @@ describe('modules/datasource/python-version/index', () => { name: 'containerbase/python-prebuild', description: 'some description', version: '3.7.8', - releaseTimestamp: '2020-03-09T13:00:00Z', + releaseTimestamp: '2020-03-09T13:00:00Z' as Timestamp, }, ]); }); @@ -105,7 +106,7 @@ describe('modules/datasource/python-version/index', () => { expect(res?.releases[0]).toEqual({ isDeprecated: true, isStable: true, - releaseTimestamp: '2020-06-27T12:55:01.000Z', + releaseTimestamp: '2020-06-27T12:55:01.000Z' as Timestamp, version: '3.7.8', }); }); diff --git a/lib/modules/datasource/python-version/schema.ts b/lib/modules/datasource/python-version/schema.ts index 2f804ef8a42f4ddf3bb6fd947bbf99debafe186f..4aa2f7f61b697bb95330b003faef6e20bb36765d 100644 --- a/lib/modules/datasource/python-version/schema.ts +++ b/lib/modules/datasource/python-version/schema.ts @@ -1,4 +1,5 @@ import { z } from 'zod'; +import { MaybeTimestamp } from '../../../util/timestamp'; import type { Release } from '../types'; export const PythonRelease = z @@ -12,7 +13,7 @@ export const PythonRelease = z /** is latest major version, true for Python 2.7.18 and latest Python 3 */ is_latest: z.boolean(), is_published: z.boolean(), - release_date: z.string(), + release_date: MaybeTimestamp, pre_release: z.boolean(), release_page: z.string().nullable(), show_on_download_page: z.boolean(), diff --git a/lib/modules/datasource/ruby-version/index.ts b/lib/modules/datasource/ruby-version/index.ts index 7f2a2613c1d6f8ae5b7c38dcd7934a64ab1a5f9e..edf3f52c46d6d47dbd9517d8123c432cf69b03b7 100644 --- a/lib/modules/datasource/ruby-version/index.ts +++ b/lib/modules/datasource/ruby-version/index.ts @@ -3,6 +3,7 @@ import { ExternalHostError } from '../../../types/errors/external-host-error'; import { cache } from '../../../util/cache/package/decorator'; import { parse } from '../../../util/html'; import type { HttpError } from '../../../util/http'; +import { asTimestamp } from '../../../util/timestamp'; import { isVersion, id as rubyVersioningId } from '../../versioning/ruby'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, ReleaseResult } from '../types'; @@ -51,7 +52,7 @@ export class RubyVersionDatasource extends Datasource { if (columns.length) { const version = columns[0].replace('Ruby ', ''); if (isVersion(version)) { - const releaseTimestamp = columns[1]; + const releaseTimestamp = asTimestamp(columns[1]); const changelogUrl = columns[2] .replace('<a href="', 'https://www.ruby-lang.org') .replace('">more...</a>', ''); diff --git a/lib/modules/datasource/rubygems/metadata-cache.spec.ts b/lib/modules/datasource/rubygems/metadata-cache.spec.ts index d1d611ac3c588279d2e58eeea0727578272daff7..2ebafc33dc489f9adc6224878155acbca3fc4cca 100644 --- a/lib/modules/datasource/rubygems/metadata-cache.spec.ts +++ b/lib/modules/datasource/rubygems/metadata-cache.spec.ts @@ -78,19 +78,19 @@ describe('modules/datasource/rubygems/metadata-cache', () => { releases: [ { version: '1.0.0', - releaseTimestamp: '2021-01-01', + releaseTimestamp: '2021-01-01T00:00:00.000Z', changelogUrl: 'https://v1.example.com/changelog', sourceUrl: 'https://v1.example.com/source', }, { version: '2.0.0', - releaseTimestamp: '2022-01-01', + releaseTimestamp: '2022-01-01T00:00:00.000Z', changelogUrl: 'https://v2.example.com/changelog', sourceUrl: 'https://v2.example.com/source', }, { version: '3.0.0', - releaseTimestamp: '2023-01-01', + releaseTimestamp: '2023-01-01T00:00:00.000Z', changelogUrl: 'https://v3.example.com/changelog', sourceUrl: 'https://v3.example.com/source', }, diff --git a/lib/modules/datasource/rubygems/schema.spec.ts b/lib/modules/datasource/rubygems/schema.spec.ts index 5ece346c68d547bb7c735c3bfdbe7e7b85db618f..ebe3fb212af071d45e716e1299cfa7c8722c0afb 100644 --- a/lib/modules/datasource/rubygems/schema.spec.ts +++ b/lib/modules/datasource/rubygems/schema.spec.ts @@ -97,7 +97,7 @@ describe('modules/datasource/rubygems/schema', () => { releases: [ { version: '1.0.0', - releaseTimestamp: '2021-01-01', + releaseTimestamp: '2021-01-01T00:00:00.000Z', changelogUrl: 'https://example.com', sourceUrl: 'https://example.com', constraints: { @@ -108,7 +108,7 @@ describe('modules/datasource/rubygems/schema', () => { }, { version: '2.0.0', - releaseTimestamp: '2022-01-01', + releaseTimestamp: '2022-01-01T00:00:00.000Z', changelogUrl: 'https://example.com', sourceUrl: 'https://example.com', constraints: { @@ -119,7 +119,7 @@ describe('modules/datasource/rubygems/schema', () => { }, { version: '3.0.0', - releaseTimestamp: '2023-01-01', + releaseTimestamp: '2023-01-01T00:00:00.000Z', changelogUrl: 'https://example.com', sourceUrl: 'https://example.com', constraints: { diff --git a/lib/modules/datasource/rubygems/schema.ts b/lib/modules/datasource/rubygems/schema.ts index 86c856cfebd37698f00a1666d013ec0fea03821c..63e289f93e4cb18fd036bc0af90ea24722d52eb7 100644 --- a/lib/modules/datasource/rubygems/schema.ts +++ b/lib/modules/datasource/rubygems/schema.ts @@ -3,6 +3,7 @@ import { z } from 'zod'; import { filterMap } from '../../../util/filter-map'; import { newlineRegex } from '../../../util/regex'; import { LooseArray } from '../../../util/schema-utils'; +import { MaybeTimestamp } from '../../../util/timestamp'; import type { Release } from '../types'; export const MarshalledVersionInfo = LooseArray( @@ -36,7 +37,7 @@ export const GemVersions = LooseArray( z .object({ number: z.string(), - created_at: z.string(), + created_at: MaybeTimestamp, platform: z.string().optional().catch(undefined), ruby_version: z.string().optional().catch(undefined), rubygems_version: z.string().optional().catch(undefined), diff --git a/lib/modules/datasource/sbt-package/index.ts b/lib/modules/datasource/sbt-package/index.ts index c956922097486c153eae502fc1e9682412a08a24..43697efde462452462b2a1eb01f3a17c0580e67d 100644 --- a/lib/modules/datasource/sbt-package/index.ts +++ b/lib/modules/datasource/sbt-package/index.ts @@ -5,6 +5,8 @@ import * as packageCache from '../../../util/cache/package'; import { cache } from '../../../util/cache/package/decorator'; import { Http } from '../../../util/http'; import { regEx } from '../../../util/regex'; +import type { Timestamp } from '../../../util/timestamp'; +import { asTimestamp } from '../../../util/timestamp'; import { ensureTrailingSlash, trimTrailingSlash } from '../../../util/url'; import * as ivyVersioning from '../../versioning/ivy'; import { compare } from '../../versioning/maven/compare'; @@ -30,7 +32,7 @@ interface ScalaDepCoordinate { interface PomInfo { homepage?: string; sourceUrl?: string; - releaseTimestamp?: string; + releaseTimestamp?: Timestamp; } export class SbtPackageDatasource extends MavenDatasource { @@ -285,7 +287,7 @@ export class SbtPackageDatasource extends MavenDatasource { const result: PomInfo = {}; - const releaseTimestamp = val.lastModified; + const releaseTimestamp = asTimestamp(val.lastModified); if (releaseTimestamp) { result.releaseTimestamp = releaseTimestamp; } diff --git a/lib/modules/datasource/terraform-module/index.ts b/lib/modules/datasource/terraform-module/index.ts index 05ff6d5e972141ae5488aab6cd63e6954180a905..c035536d51673038ee7f743f2e262d0d63a011f9 100644 --- a/lib/modules/datasource/terraform-module/index.ts +++ b/lib/modules/datasource/terraform-module/index.ts @@ -2,6 +2,7 @@ import { logger } from '../../../logger'; import { cache } from '../../../util/cache/package/decorator'; import { regEx } from '../../../util/regex'; import { coerceString } from '../../../util/string'; +import { asTimestamp } from '../../../util/timestamp'; import { isHttpUrl } from '../../../util/url'; import * as hashicorpVersioning from '../../versioning/hashicorp'; import type { GetReleasesConfig, ReleaseResult } from '../types'; @@ -128,7 +129,7 @@ export class TerraformModuleDatasource extends TerraformDatasource { (release) => res.version === release.version, ); if (latestVersion) { - latestVersion.releaseTimestamp = res.published_at; + latestVersion.releaseTimestamp = asTimestamp(res.published_at); } return dep; } diff --git a/lib/modules/datasource/terraform-provider/index.ts b/lib/modules/datasource/terraform-provider/index.ts index 81f7de33cf51a236e02932fc31164c3d29acb029..0f3e72dcacab757796dcc96730d35af9caf303f4 100644 --- a/lib/modules/datasource/terraform-provider/index.ts +++ b/lib/modules/datasource/terraform-provider/index.ts @@ -5,6 +5,7 @@ import { ExternalHostError } from '../../../types/errors/external-host-error'; import { cache } from '../../../util/cache/package/decorator'; import * as p from '../../../util/promises'; import { regEx } from '../../../util/regex'; +import { asTimestamp } from '../../../util/timestamp'; import { joinUrlParts } from '../../../util/url'; import * as hashicorpVersioning from '../../versioning/hashicorp'; import { TerraformDatasource } from '../terraform-module/base'; @@ -130,7 +131,7 @@ export class TerraformProviderDatasource extends TerraformDatasource { ); // istanbul ignore else if (latestVersion) { - latestVersion.releaseTimestamp = res.published_at; + latestVersion.releaseTimestamp = asTimestamp(res.published_at); } dep.homepage = `${registryUrl}/providers/${repository}`; return dep; diff --git a/lib/modules/datasource/types.ts b/lib/modules/datasource/types.ts index aea32290d9fbce9bfa72c79f9c4125c18622accb..9e8e8300819467ff5915fd1e12d43265932f92bc 100644 --- a/lib/modules/datasource/types.ts +++ b/lib/modules/datasource/types.ts @@ -3,6 +3,7 @@ import type { CustomDatasourceConfig, } from '../../config/types'; import type { ModuleApi } from '../../types'; +import type { Timestamp } from '../../util/timestamp'; export interface GetDigestInputConfig { datasource: string; @@ -59,7 +60,7 @@ export interface Release { gitRef?: string; isDeprecated?: boolean; isStable?: boolean; - releaseTimestamp?: string | null; + releaseTimestamp?: Timestamp | null; version: string; /** The original value to which `extractVersion` was applied */ versionOrig?: string; diff --git a/lib/modules/datasource/unity3d/index.ts b/lib/modules/datasource/unity3d/index.ts index a54bbb03e61085ad4ee0c096f990f4974efd69b0..e134d9aba3a667cb3dd25b7b0c0e50e142632150 100644 --- a/lib/modules/datasource/unity3d/index.ts +++ b/lib/modules/datasource/unity3d/index.ts @@ -2,6 +2,7 @@ import type { XmlElement } from 'xmldoc'; import { XmlDocument } from 'xmldoc'; import { logger } from '../../../logger'; import { cache } from '../../../util/cache/package/decorator'; +import { asTimestamp } from '../../../util/timestamp'; import * as Unity3dVersioning from '../../versioning/unity3d'; import { Datasource } from '../datasource'; import type { GetReleasesConfig, Release, ReleaseResult } from '../types'; @@ -64,7 +65,7 @@ export class Unity3dDatasource extends Datasource { const versionWithoutHash = itemNode.childNamed('title')?.val; const release: Release = { version: withHash ? versionWithHash : versionWithoutHash!, - releaseTimestamp: itemNode.childNamed('pubDate')?.val, + releaseTimestamp: asTimestamp(itemNode.childNamed('pubDate')?.val), changelogUrl: itemNode.childNamed('link')?.val, isStable: registryUrl !== Unity3dDatasource.streams.beta, registryUrl, diff --git a/lib/modules/manager/types.ts b/lib/modules/manager/types.ts index 6c93b44a19556af7a349e970a74ff00049a883a8..0937191789a0b640711f78a480c3d1e8c7bfe0dd 100644 --- a/lib/modules/manager/types.ts +++ b/lib/modules/manager/types.ts @@ -14,6 +14,7 @@ import type { } from '../../types'; import type { FileChange } from '../../util/git/types'; import type { MergeConfidence } from '../../util/merge-confidence/types'; +import type { Timestamp } from '../../util/timestamp'; import type { CustomExtractConfig } from './custom/types'; export type MaybePromise<T> = T | Promise<T>; @@ -103,7 +104,7 @@ export interface LookupUpdate { userStrings?: Record<string, string>; checksumUrl?: string; downloadUrl?: string; - releaseTimestamp?: any; + releaseTimestamp?: Timestamp; newVersionAgeInDays?: number; registryUrl?: string; libYears?: number; diff --git a/lib/util/github/graphql/cache-strategies/memory-cache-strategy.spec.ts b/lib/util/github/graphql/cache-strategies/memory-cache-strategy.spec.ts index ac1abbb09b38fa144613589a22cbed6945d46633..8fb5f1849ae9ac332b06a92624b8a810a6b5108b 100644 --- a/lib/util/github/graphql/cache-strategies/memory-cache-strategy.spec.ts +++ b/lib/util/github/graphql/cache-strategies/memory-cache-strategy.spec.ts @@ -1,6 +1,7 @@ import { DateTime, Settings } from 'luxon'; import * as memCache from '../../../cache/memory'; import { clone } from '../../../clone'; +import type { Timestamp } from '../../../timestamp'; import type { GithubDatasourceItem, GithubGraphqlCacheRecord } from '../types'; import { GithubGraphqlMemoryCacheStrategy } from './memory-cache-strategy'; @@ -21,7 +22,7 @@ const isoTs = (t: string) => { } else { throw new Error('Unrecognized date-time string. ' + t); } - return iso; + return iso as Timestamp; }; const mockTime = (input: string): void => { diff --git a/lib/util/github/graphql/cache-strategies/package-cache-strategy.spec.ts b/lib/util/github/graphql/cache-strategies/package-cache-strategy.spec.ts index eb386ca9e6f21da4507042d925fc15089b2d9834..4208ff1bb5ac1f53e8941fff042b855bd85405ee 100644 --- a/lib/util/github/graphql/cache-strategies/package-cache-strategy.spec.ts +++ b/lib/util/github/graphql/cache-strategies/package-cache-strategy.spec.ts @@ -1,10 +1,11 @@ import { DateTime, Settings } from 'luxon'; +import type { Timestamp } from '../../../../util/timestamp'; import * as packageCache from '../../../cache/package'; import { clone } from '../../../clone'; import type { GithubDatasourceItem, GithubGraphqlCacheRecord } from '../types'; import { GithubGraphqlPackageCacheStrategy } from './package-cache-strategy'; -const isoTs = (t: string) => t.replace(' ', 'T') + ':00.000Z'; +const isoTs = (t: string) => (t.replace(' ', 'T') + ':00.000Z') as Timestamp; const mockTime = (input: string): void => { const now = DateTime.fromISO(isoTs(input)).valueOf(); diff --git a/lib/util/github/graphql/datasource-fetcher.spec.ts b/lib/util/github/graphql/datasource-fetcher.spec.ts index ba139bf80a4c330a972a3c83a83281916bccdbf3..7046905135fbef282589d15682912d26daa1b17a 100644 --- a/lib/util/github/graphql/datasource-fetcher.spec.ts +++ b/lib/util/github/graphql/datasource-fetcher.spec.ts @@ -2,6 +2,7 @@ import AggregateError from 'aggregate-error'; import * as httpMock from '../../../../test/http-mock'; import { mocked, partial } from '../../../../test/util'; import * as _packageCache from '../../../util/cache/package'; +import type { Timestamp } from '../../../util/timestamp'; import type { GithubGraphqlResponse } from '../../http/github'; import { GithubHttp } from '../../http/github'; import { range } from '../../range'; @@ -54,7 +55,7 @@ const adapter: GithubGraphqlDatasourceAdapter< version && releaseTimestamp && foo ? { version, - releaseTimestamp, + releaseTimestamp: releaseTimestamp as Timestamp, bar: foo, } : null, diff --git a/lib/util/github/graphql/index.spec.ts b/lib/util/github/graphql/index.spec.ts index a234bac6dd19c0654b09875bb72f736d67b60c82..0a01cfebd03c4cd759edd85315c6fce37e9654d1 100644 --- a/lib/util/github/graphql/index.spec.ts +++ b/lib/util/github/graphql/index.spec.ts @@ -72,7 +72,7 @@ describe('util/github/graphql/index', () => { expect(res).toEqual([ { version: '1.2.3', - releaseTimestamp: '2024-09-24', + releaseTimestamp: '2024-09-24T00:00:00.000Z', url: 'https://example.com', id: 123, name: 'name', diff --git a/lib/util/github/graphql/query-adapters/releases-query-adapter.spec.ts b/lib/util/github/graphql/query-adapters/releases-query-adapter.spec.ts index 7e874c311eff3007c587cab2625fff70bb340f8a..bd1620fe2cc5e5f86c9fddf2bfa0d2a8aeff31fe 100644 --- a/lib/util/github/graphql/query-adapters/releases-query-adapter.spec.ts +++ b/lib/util/github/graphql/query-adapters/releases-query-adapter.spec.ts @@ -1,9 +1,10 @@ +import type { Timestamp } from '../../../../util/timestamp'; import { adapter } from './releases-query-adapter'; import type { GithubGraphqlRelease } from './releases-query-adapter'; const item: GithubGraphqlRelease = { version: '1.2.3', - releaseTimestamp: '2024-09-24', + releaseTimestamp: '2024-09-24' as Timestamp, isDraft: false, isPrerelease: false, url: 'https://example.com', @@ -18,7 +19,7 @@ describe('util/github/graphql/query-adapters/releases-query-adapter', () => { description: 'description', id: 123, name: 'name', - releaseTimestamp: '2024-09-24', + releaseTimestamp: '2024-09-24T00:00:00.000Z' as Timestamp, url: 'https://example.com', version: '1.2.3', }); diff --git a/lib/util/github/graphql/query-adapters/releases-query-adapter.ts b/lib/util/github/graphql/query-adapters/releases-query-adapter.ts index 65cf0cfb10a2d567f24adb543efd559a3f144372..7fe39e8bf908e1e22b72992b0c20a7efbbf3353f 100644 --- a/lib/util/github/graphql/query-adapters/releases-query-adapter.ts +++ b/lib/util/github/graphql/query-adapters/releases-query-adapter.ts @@ -1,4 +1,5 @@ import { z } from 'zod'; +import { Timestamp } from '../../../timestamp'; import type { GithubGraphqlDatasourceAdapter, GithubReleaseItem, @@ -32,7 +33,7 @@ const query = prepareQuery(` const GithubGraphqlRelease = z.object({ version: z.string(), - releaseTimestamp: z.string(), + releaseTimestamp: Timestamp, isDraft: z.boolean(), isPrerelease: z.boolean(), url: z.string(), diff --git a/lib/util/github/graphql/query-adapters/tags-query-adapter.spec.ts b/lib/util/github/graphql/query-adapters/tags-query-adapter.spec.ts index 07a83d1536feb3b5603d2aab1c121f276290f584..ac6f68968f325386029e84e41fc21814859a4b12 100644 --- a/lib/util/github/graphql/query-adapters/tags-query-adapter.spec.ts +++ b/lib/util/github/graphql/query-adapters/tags-query-adapter.spec.ts @@ -1,3 +1,4 @@ +import type { Timestamp } from '../../../../util/timestamp'; import { adapter } from './tags-query-adapter'; describe('util/github/graphql/query-adapters/tags-query-adapter', () => { @@ -8,14 +9,14 @@ describe('util/github/graphql/query-adapters/tags-query-adapter', () => { target: { type: 'Commit', oid: 'abc123', - releaseTimestamp: '2022-09-24', + releaseTimestamp: '2022-09-24' as Timestamp, }, }), ).toEqual({ version: '1.2.3', gitRef: '1.2.3', hash: 'abc123', - releaseTimestamp: '2022-09-24', + releaseTimestamp: '2022-09-24' as Timestamp, }); }); @@ -26,14 +27,14 @@ describe('util/github/graphql/query-adapters/tags-query-adapter', () => { target: { type: 'Tag', target: { oid: 'abc123' }, - tagger: { releaseTimestamp: '2022-09-24' }, + tagger: { releaseTimestamp: '2022-09-24' as Timestamp }, }, }), ).toEqual({ version: '1.2.3', gitRef: '1.2.3', hash: 'abc123', - releaseTimestamp: '2022-09-24', + releaseTimestamp: '2022-09-24' as Timestamp, }); }); diff --git a/lib/util/github/graphql/query-adapters/tags-query-adapter.ts b/lib/util/github/graphql/query-adapters/tags-query-adapter.ts index 0fbb2cf7728ccc0afc4daec3b1db60f858669915..bdc847b55d92c6069a9a747b46d2b4fba1317cba 100644 --- a/lib/util/github/graphql/query-adapters/tags-query-adapter.ts +++ b/lib/util/github/graphql/query-adapters/tags-query-adapter.ts @@ -1,4 +1,5 @@ import { z } from 'zod'; +import { Timestamp } from '../../../timestamp'; import type { GithubGraphqlDatasourceAdapter, GithubTagItem } from '../types'; import { prepareQuery } from '../util'; @@ -10,7 +11,7 @@ const GithubGraphqlTag = z.object({ z.object({ type: z.literal('Commit'), oid: z.string(), - releaseTimestamp: z.string(), + releaseTimestamp: Timestamp, }), z.object({ type: z.literal('Tag'), @@ -18,7 +19,7 @@ const GithubGraphqlTag = z.object({ oid: z.string(), }), tagger: z.object({ - releaseTimestamp: z.string(), + releaseTimestamp: Timestamp, }), }), ]), diff --git a/lib/util/github/graphql/types.ts b/lib/util/github/graphql/types.ts index 61c8f864300786edcf1913a6d506ca27e74fd371..ed0f8bd51fd36eb7e12eb73da629105cd0edfaf2 100644 --- a/lib/util/github/graphql/types.ts +++ b/lib/util/github/graphql/types.ts @@ -1,8 +1,9 @@ import type { PackageCacheNamespace } from '../../cache/package/types'; +import type { Timestamp } from '../../timestamp'; export interface GithubDatasourceItem { version: string; - releaseTimestamp: string; + releaseTimestamp: Timestamp; } /** diff --git a/lib/util/github/tags.spec.ts b/lib/util/github/tags.spec.ts index 5eb4a304404ed10d73054ccf9fb1e66f07922e77..ff811d09eaea7f27676d7dd2c2c678f7e8d85a97 100644 --- a/lib/util/github/tags.spec.ts +++ b/lib/util/github/tags.spec.ts @@ -1,3 +1,4 @@ +import type { Timestamp } from '../../util/timestamp'; import { GithubHttp } from '../http/github'; import * as githubGraphql from './graphql'; import { findCommitOfTag } from './tags'; @@ -12,13 +13,13 @@ describe('util/github/tags', () => { { version: 'v1.0.0', gitRef: 'v1.0.0', - releaseTimestamp: '2021-01-01', + releaseTimestamp: '2021-01-01' as Timestamp, hash: '123', }, { version: 'v2.0.0', gitRef: 'v2.0.0', - releaseTimestamp: '2022-01-01', + releaseTimestamp: '2022-01-01' as Timestamp, hash: 'abc', }, ]); diff --git a/lib/util/timestamp.spec.ts b/lib/util/timestamp.spec.ts index 1926ea478aed719313280d6600c2db93ec601e45..9b7efe3732c2a8105c338b5ba6ad0c4b5ee2254b 100644 --- a/lib/util/timestamp.spec.ts +++ b/lib/util/timestamp.spec.ts @@ -1,4 +1,4 @@ -import { TimestampSchema, asTimestamp } from './timestamp'; +import { MaybeTimestamp, asTimestamp } from './timestamp'; describe('util/timestamp', () => { describe('asTimestamp', () => { @@ -33,9 +33,7 @@ describe('util/timestamp', () => { ${'202x0101000000'} | ${null} `('$input -> $expected', ({ input, expected }) => { expect(asTimestamp(input)).toBe(expected); - expect(TimestampSchema.nullable().catch(null).parse(input)).toBe( - expected, - ); + expect(MaybeTimestamp.parse(input)).toBe(expected); }); }); }); diff --git a/lib/util/timestamp.ts b/lib/util/timestamp.ts index 5c0e3d32b9c9c15d86772c35a9b3570e9a738f4f..adf44b1c346ca268d9915db09c71c6c18ea1a68f 100644 --- a/lib/util/timestamp.ts +++ b/lib/util/timestamp.ts @@ -87,7 +87,7 @@ export function asTimestamp(input: unknown): Timestamp | null { return null; } -export const TimestampSchema = z.unknown().transform((input, ctx) => { +export const Timestamp = z.unknown().transform((input, ctx) => { const timestamp = asTimestamp(input); if (!timestamp) { ctx.addIssue({ @@ -99,3 +99,4 @@ export const TimestampSchema = z.unknown().transform((input, ctx) => { return timestamp; }); +export const MaybeTimestamp = Timestamp.nullable().catch(null); diff --git a/lib/workers/repository/process/libyear.spec.ts b/lib/workers/repository/process/libyear.spec.ts index e4a1f1fe24ff43b2a7d7f9295be7e1fd35afa714..c8e32d80bb8e111c53e02e2d531ade8e3952d3cc 100644 --- a/lib/workers/repository/process/libyear.spec.ts +++ b/lib/workers/repository/process/libyear.spec.ts @@ -1,5 +1,6 @@ import { logger } from '../../../../test/util'; import type { PackageFile } from '../../../modules/manager/types'; +import type { Timestamp } from '../../../util/timestamp'; import { calculateLibYears } from './libyear'; describe('workers/repository/process/libyear', () => { @@ -30,15 +31,15 @@ describe('workers/repository/process/libyear', () => { { depName: 'dep1', currentVersion: '0.1.0', - currentVersionTimestamp: '2019-07-01T00:00:00Z', + currentVersionTimestamp: '2019-07-01T00:00:00Z' as Timestamp, updates: [ { newVersion: '1.0.0', - releaseTimestamp: '2020-01-01T00:00:00Z', + releaseTimestamp: '2020-01-01T00:00:00Z' as Timestamp, }, { newVersion: '2.0.0', - releaseTimestamp: '2020-07-01T00:00:00Z', + releaseTimestamp: '2020-07-01T00:00:00Z' as Timestamp, }, { newVersion: '3.0.0', @@ -55,11 +56,11 @@ describe('workers/repository/process/libyear', () => { { depName: 'dep2', currentVersion: '1.0.0', - currentVersionTimestamp: '2019-07-01T00:00:00Z', + currentVersionTimestamp: '2019-07-01T00:00:00Z' as Timestamp, updates: [ { newVersion: '2.0.0', - releaseTimestamp: '2020-01-01T00:00:00Z', + releaseTimestamp: '2020-01-01T00:00:00Z' as Timestamp, }, ], }, @@ -69,7 +70,7 @@ describe('workers/repository/process/libyear', () => { updates: [ { newVersion: '2.0.0', - releaseTimestamp: '2020-01-01T00:00:00Z', + releaseTimestamp: '2020-01-01T00:00:00Z' as Timestamp, }, ], }, diff --git a/lib/workers/repository/process/lookup/filter-checks.spec.ts b/lib/workers/repository/process/lookup/filter-checks.spec.ts index aa1f3d63fed6b686597707f0154376e23fe91ad9..37c0a56d6646502fb767ec77791ab2e992f720c7 100644 --- a/lib/workers/repository/process/lookup/filter-checks.spec.ts +++ b/lib/workers/repository/process/lookup/filter-checks.spec.ts @@ -13,6 +13,7 @@ import { clone } from '../../../../util/clone'; import * as _dateUtil from '../../../../util/date'; import * as _mergeConfidence from '../../../../util/merge-confidence'; import { toMs } from '../../../../util/pretty-time'; +import type { Timestamp } from '../../../../util/timestamp'; import { filterInternalChecks } from './filter-checks'; import type { LookupUpdateConfig, UpdateResult } from './types'; @@ -42,19 +43,19 @@ const versioning = allVersioning.get('semver'); const releases: Release[] = [ { version: '1.0.1', - releaseTimestamp: '2021-01-01T00:00:01.000Z', + releaseTimestamp: '2021-01-01T00:00:01.000Z' as Timestamp, }, { version: '1.0.2', - releaseTimestamp: '2021-01-03T00:00:00.000Z', + releaseTimestamp: '2021-01-03T00:00:00.000Z' as Timestamp, }, { version: '1.0.3', - releaseTimestamp: '2021-01-05T00:00:00.000Z', + releaseTimestamp: '2021-01-05T00:00:00.000Z' as Timestamp, }, { version: '1.0.4', - releaseTimestamp: '2021-01-07T00:00:00.000Z', + releaseTimestamp: '2021-01-07T00:00:00.000Z' as Timestamp, }, ]; diff --git a/lib/workers/repository/process/lookup/filter.spec.ts b/lib/workers/repository/process/lookup/filter.spec.ts index e445a9b0fdffdb3aa4f7a72d33a578691713a284..5cdf6f78b895e9d652b85e9425d9b472fe2b7c08 100644 --- a/lib/workers/repository/process/lookup/filter.spec.ts +++ b/lib/workers/repository/process/lookup/filter.spec.ts @@ -1,6 +1,7 @@ import { partial } from '../../../../../test/util'; import type { Release } from '../../../../modules/datasource/types'; import * as allVersioning from '../../../../modules/versioning'; +import type { Timestamp } from '../../../../util/timestamp'; import { filterVersions } from './filter'; import type { FilterConfig } from './types'; @@ -12,24 +13,24 @@ describe('workers/repository/process/lookup/filter', () => { const releases = [ { version: '1.0.1', - releaseTimestamp: '2021-01-01T00:00:01.000Z', + releaseTimestamp: '2021-01-01T00:00:01.000Z' as Timestamp, }, { version: '1.2.0', - releaseTimestamp: '2021-01-03T00:00:00.000Z', + releaseTimestamp: '2021-01-03T00:00:00.000Z' as Timestamp, }, { version: '2.0.0', - releaseTimestamp: '2021-01-05T00:00:00.000Z', + releaseTimestamp: '2021-01-05T00:00:00.000Z' as Timestamp, }, { version: '2.1.0', - releaseTimestamp: '2021-01-07T00:00:00.000Z', + releaseTimestamp: '2021-01-07T00:00:00.000Z' as Timestamp, }, // for coverage { version: 'invalid.version', - releaseTimestamp: '2021-01-07T00:00:00.000Z', + releaseTimestamp: '2021-01-07T00:00:00.000Z' as Timestamp, }, ] satisfies Release[]; diff --git a/lib/workers/repository/process/lookup/index.spec.ts b/lib/workers/repository/process/lookup/index.spec.ts index 26e13ba8e456734d504c2abb913b135875a97537..31fe79439242b7c88ef7e781e4bdf325c3a36f19 100644 --- a/lib/workers/repository/process/lookup/index.spec.ts +++ b/lib/workers/repository/process/lookup/index.spec.ts @@ -31,6 +31,7 @@ import * as memCache from '../../../../util/cache/memory'; import { initConfig, resetConfig } from '../../../../util/merge-confidence'; import * as McApi from '../../../../util/merge-confidence'; import { Result } from '../../../../util/result'; +import type { Timestamp } from '../../../../util/timestamp'; import type { LookupUpdateConfig } from './types'; import * as lookup from '.'; @@ -162,7 +163,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '1.4.1', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -219,7 +220,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^0.9.0', newVersion: '0.9.7', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2013-09-04T17:07:22.948Z', + releaseTimestamp: '2013-09-04T17:07:22.948Z' as Timestamp, updateType: 'minor', }, { @@ -231,7 +232,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^1.0.0', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -261,7 +262,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^0.4.0', newVersion: '0.4.4', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2011-06-10T17:20:04.719Z', + releaseTimestamp: '2011-06-10T17:20:04.719Z' as Timestamp, updateType: 'patch', }, { @@ -273,7 +274,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^0.9.0', newVersion: '0.9.7', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2013-09-04T17:07:22.948Z', + releaseTimestamp: '2013-09-04T17:07:22.948Z' as Timestamp, updateType: 'minor', }, { @@ -285,7 +286,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^1.0.0', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -436,7 +437,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^0.9.0', newVersion: '0.9.7', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2013-09-04T17:07:22.948Z', + releaseTimestamp: '2013-09-04T17:07:22.948Z' as Timestamp, updateType: 'minor', }, { @@ -448,7 +449,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^1.0.0', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -500,7 +501,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '0.9.7', newVersion: '0.9.7', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2013-09-04T17:07:22.948Z', + releaseTimestamp: '2013-09-04T17:07:22.948Z' as Timestamp, updateType: 'minor', }, ]); @@ -526,7 +527,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '0.9.7', newVersion: '0.9.7', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2013-09-04T17:07:22.948Z', + releaseTimestamp: '2013-09-04T17:07:22.948Z' as Timestamp, updateType: 'minor', }, ]); @@ -553,7 +554,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '0.9.7', newVersion: '0.9.7', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2013-09-04T17:07:22.948Z', + releaseTimestamp: '2013-09-04T17:07:22.948Z' as Timestamp, updateType: 'minor', }, ]); @@ -580,7 +581,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '0.9.4', newVersion: '0.9.4', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2013-05-22T20:26:50.888Z', + releaseTimestamp: '2013-05-22T20:26:50.888Z' as Timestamp, updateType: 'minor', }, ]); @@ -699,7 +700,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '0.9.7', newVersion: '0.9.7', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2013-09-04T17:07:22.948Z', + releaseTimestamp: '2013-09-04T17:07:22.948Z' as Timestamp, updateType: 'patch', }, { @@ -710,7 +711,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '1.4.1', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -794,7 +795,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^1.0.0', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -821,7 +822,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '1.4.1', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -1059,7 +1060,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~0.9.0', newVersion: '0.9.7', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2013-09-04T17:07:22.948Z', + releaseTimestamp: '2013-09-04T17:07:22.948Z' as Timestamp, updateType: 'minor', }, { @@ -1071,7 +1072,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~1.4.0', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -1216,7 +1217,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~1.4.0', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -1250,7 +1251,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~1.4.0', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -1391,7 +1392,7 @@ describe('workers/repository/process/lookup/index', () => { newPatch: 0, newValue: undefined, newVersion: '1.3.0', - releaseTimestamp: '2015-04-26T16:42:11.311Z', + releaseTimestamp: '2015-04-26T16:42:11.311Z' as Timestamp, updateType: 'minor', }, ]); @@ -1420,7 +1421,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~1.3.0 || ~1.4.0', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -1447,7 +1448,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~1.4.0', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -1477,7 +1478,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^2.0.0 || ^3.0.0', newVersion: '3.8.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2017-10-17T15:22:36.646Z', + releaseTimestamp: '2017-10-17T15:22:36.646Z' as Timestamp, updateType: 'major', }, ]); @@ -1507,7 +1508,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^3.0.0', newVersion: '3.8.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2017-10-17T15:22:36.646Z', + releaseTimestamp: '2017-10-17T15:22:36.646Z' as Timestamp, updateType: 'major', }, ]); @@ -1615,7 +1616,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~1.4.0', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -1649,7 +1650,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '1.4.x', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -1676,7 +1677,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~1.4.0', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -1703,7 +1704,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '1.x', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -1730,7 +1731,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '1.4.x', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -1757,7 +1758,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '1.2.x - 1.4.x', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -1784,7 +1785,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '1', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -1811,7 +1812,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '1.4', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -1838,7 +1839,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~0.9.0', newVersion: '0.9.7', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2013-09-04T17:07:22.948Z', + releaseTimestamp: '2013-09-04T17:07:22.948Z' as Timestamp, updateType: 'minor', }, { @@ -1850,7 +1851,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~1.4.0', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -1877,7 +1878,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^0.9.0', newVersion: '0.9.7', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2013-09-04T17:07:22.948Z', + releaseTimestamp: '2013-09-04T17:07:22.948Z' as Timestamp, updateType: 'minor', }, { @@ -1889,7 +1890,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^1.0.0', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -1958,7 +1959,7 @@ describe('workers/repository/process/lookup/index', () => { 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', + releaseTimestamp: '2017-10-17T15:22:36.646Z' as Timestamp, updateType: 'major', }, ]); @@ -1988,7 +1989,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '1.x - 3.x', newVersion: '3.8.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2017-10-17T15:22:36.646Z', + releaseTimestamp: '2017-10-17T15:22:36.646Z' as Timestamp, updateType: 'major', }, ]); @@ -2018,7 +2019,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '1.x || 2.x || 3.x', newVersion: '3.8.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2017-10-17T15:22:36.646Z', + releaseTimestamp: '2017-10-17T15:22:36.646Z' as Timestamp, updateType: 'major', }, ]); @@ -2048,7 +2049,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '1 || 2 || 3', newVersion: '3.8.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2017-10-17T15:22:36.646Z', + releaseTimestamp: '2017-10-17T15:22:36.646Z' as Timestamp, updateType: 'major', }, ]); @@ -2075,7 +2076,7 @@ describe('workers/repository/process/lookup/index', () => { 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', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -2116,7 +2117,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '<= 0.9.7', newVersion: '0.9.7', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2013-09-04T17:07:22.948Z', + releaseTimestamp: '2013-09-04T17:07:22.948Z' as Timestamp, updateType: 'minor', }, { @@ -2128,7 +2129,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '<= 1.4.1', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -2155,7 +2156,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '< 0.9.8', newVersion: '0.9.7', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2013-09-04T17:07:22.948Z', + releaseTimestamp: '2013-09-04T17:07:22.948Z' as Timestamp, updateType: 'minor', }, { @@ -2167,7 +2168,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '< 1.4.2', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -2194,7 +2195,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '< 2', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -2221,7 +2222,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '<= 1.4', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -2248,7 +2249,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '=1.4.1', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -2276,7 +2277,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '<= 2', newVersion: '2.0.3', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-01-31T08:11:47.852Z', + releaseTimestamp: '2015-01-31T08:11:47.852Z' as Timestamp, updateType: 'major', }, ]); @@ -2475,7 +2476,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '2.0.3', newVersion: '2.0.3', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-01-31T08:11:47.852Z', + releaseTimestamp: '2015-01-31T08:11:47.852Z' as Timestamp, updateType: 'major', }, ]); @@ -2571,11 +2572,11 @@ describe('workers/repository/process/lookup/index', () => { { version: '1.4.4' }, { version: '1.4.5', - releaseTimestamp: lastWeek.toISOString(), + releaseTimestamp: lastWeek.toISOString() as Timestamp, }, { version: '1.4.6', - releaseTimestamp: yesterday.toISOString(), + releaseTimestamp: yesterday.toISOString() as Timestamp, }, ], }); @@ -2615,11 +2616,11 @@ describe('workers/repository/process/lookup/index', () => { { version: '1.4.4' }, { version: '1.4.5', - releaseTimestamp: lastWeek.toISOString(), + releaseTimestamp: lastWeek.toISOString() as Timestamp, }, { version: '1.4.6', - releaseTimestamp: yesterday.toISOString(), + releaseTimestamp: yesterday.toISOString() as Timestamp, }, ], }); @@ -2916,7 +2917,7 @@ describe('workers/repository/process/lookup/index', () => { { version: 'v2.0.0', gitRef: 'v2.0.0', - releaseTimestamp: '2022-01-01', + releaseTimestamp: '2022-01-01' as Timestamp, }, ], }); @@ -2951,7 +2952,7 @@ describe('workers/repository/process/lookup/index', () => { { version: 'v2.0.0', gitRef: 'v2.0.0', - releaseTimestamp: '2022-01-01', + releaseTimestamp: '2022-01-01' as Timestamp, }, ], }); @@ -2984,7 +2985,7 @@ describe('workers/repository/process/lookup/index', () => { { version: 'v1.0.0', gitRef: 'v1.0.0', - releaseTimestamp: '2022-01-01', + releaseTimestamp: '2022-01-01' as Timestamp, }, ], }); @@ -3051,7 +3052,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^0.0.35', newVersion: '0.0.35', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2017-04-27T16:59:06.479Z', + releaseTimestamp: '2017-04-27T16:59:06.479Z' as Timestamp, updateType: 'patch', }, ]); @@ -3227,7 +3228,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '^1.4.1', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -3256,7 +3257,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~1.0.1', newVersion: '1.0.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2014-03-11T18:47:17.560Z', + releaseTimestamp: '2014-03-11T18:47:17.560Z' as Timestamp, updateType: 'patch', }, { @@ -3268,7 +3269,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~1.4.1', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -3297,7 +3298,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~1.0.1', newVersion: '1.0.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2014-03-11T18:47:17.560Z', + releaseTimestamp: '2014-03-11T18:47:17.560Z' as Timestamp, updateType: 'patch', }, { @@ -3309,7 +3310,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~1.4.1', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -3337,7 +3338,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '>=1.4.1', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -3366,7 +3367,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '>=1.4.1', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -3435,7 +3436,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '1.4.1', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'minor', }, ]); @@ -3537,7 +3538,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '~=1.4', newVersion: '1.4.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2015-05-17T04:25:07.299Z', + releaseTimestamp: '2015-05-17T04:25:07.299Z' as Timestamp, updateType: 'major', }, ]); @@ -3555,7 +3556,7 @@ describe('workers/repository/process/lookup/index', () => { expect(res).toMatchObject({ currentVersion: '1.3.0', - currentVersionTimestamp: '2015-04-26T16:42:11.311Z', + currentVersionTimestamp: '2015-04-26T16:42:11.311Z' as Timestamp, fixedVersion: '1.3.0', isSingleVersion: true, registryUrl: 'https://registry.npmjs.org', @@ -3598,7 +3599,7 @@ describe('workers/repository/process/lookup/index', () => { ).unwrapOrThrow(); expect(res).toMatchObject({ currentVersion: '1.3.0', - currentVersionTimestamp: '2015-04-26T16:42:11.311Z', + currentVersionTimestamp: '2015-04-26T16:42:11.311Z' as Timestamp, fixedVersion: '1.3.0', isSingleVersion: true, registryUrl: 'https://registry.npmjs.org', @@ -3655,7 +3656,7 @@ describe('workers/repository/process/lookup/index', () => { expect(res).toMatchObject({ currentVersion: '1.3.0', - currentVersionTimestamp: '2015-04-26T16:42:11.311Z', + currentVersionTimestamp: '2015-04-26T16:42:11.311Z' as Timestamp, deprecationMessage: codeBlock` On registry \`https://registry.npmjs.org\`, the "latest" version of dependency \`q3\` has the following deprecation notice: @@ -4424,7 +4425,7 @@ describe('workers/repository/process/lookup/index', () => { // a day old release releaseTimestamp: new Date( Date.now() - 25 * 60 * 60 * 1000, - ).toISOString(), + ).toISOString() as Timestamp, }, { version: '18.0.0', @@ -4466,7 +4467,7 @@ describe('workers/repository/process/lookup/index', () => { ]; const releaseTimestamp = new Date( Date.now() - 25 * 60 * 60 * 1000, - ).toISOString(); + ).toISOString() as Timestamp; getDockerReleases.mockResolvedValueOnce({ releases: [ { @@ -4683,10 +4684,8 @@ describe('workers/repository/process/lookup/index', () => { config.packageName = 'openjdk'; config.currentDigest = 'sha256:fedcba0987654321'; config.currentValue = '17.0.0'; - //config.pinDigests = true; config.datasource = DockerDatasource.id; config.versioning = dockerVersioningId; - // This config is normally set when packageRules are applied config.replacementName = 'eclipse-temurin'; config.replacementVersion = '19.0.0'; getDockerReleases.mockResolvedValueOnce({ @@ -4785,7 +4784,6 @@ describe('workers/repository/process/lookup/index', () => { it('handles replacements - name and version', async () => { config.currentValue = '1.4.1'; config.packageName = 'q'; - // This config is normally set when packageRules are applied config.replacementName = 'r'; config.replacementVersion = '2.0.0'; config.datasource = NpmDatasource.id; @@ -5056,7 +5054,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '3.8.1', newVersion: '3.8.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2017-10-17T15:22:36.646Z', + releaseTimestamp: '2017-10-17T15:22:36.646Z' as Timestamp, updateType: 'minor', }, ]); @@ -5085,7 +5083,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: '3.8.1', newVersion: '3.8.1', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2017-10-17T15:22:36.646Z', + releaseTimestamp: '2017-10-17T15:22:36.646Z' as Timestamp, updateType: 'minor', }, ]); @@ -5145,7 +5143,7 @@ describe('workers/repository/process/lookup/index', () => { newValue: 'v0.0.0-20240509183442-62759503f434', newVersion: 'v0.0.0-20240509183442-62759503f434', newVersionAgeInDays: expect.any(Number), - releaseTimestamp: '2024-05-09T18:34:42.000Z', + releaseTimestamp: '2024-05-09T18:34:42.000Z' as Timestamp, updateType: 'digest', }, ]); diff --git a/lib/workers/repository/update/branch/index.spec.ts b/lib/workers/repository/update/branch/index.spec.ts index ba8aba7d85a76f7153fe14a8bffb88b36cab779e..174679d01823e929f244d3868e8ec75ea1cd57e0 100644 --- a/lib/workers/repository/update/branch/index.spec.ts +++ b/lib/workers/repository/update/branch/index.spec.ts @@ -36,6 +36,7 @@ import type { } from '../../../../util/git/types'; import * as _mergeConfidence from '../../../../util/merge-confidence'; import * as _sanitize from '../../../../util/sanitize'; +import type { Timestamp } from '../../../../util/timestamp'; import * as _limits from '../../../global/limits'; import type { BranchConfig, BranchUpgradeConfig } from '../../../types'; import type { ResultWithPr } from '../pr'; @@ -183,11 +184,13 @@ describe('workers/repository/update/branch/index', () => { config.prCreation = 'not-pending'; (config.upgrades as Partial<BranchUpgradeConfig>[]) = [ { - releaseTimestamp: new Date('2019-01-01').getTime().toString(), + releaseTimestamp: new Date('2019-01-01') + .getTime() + .toString() as Timestamp, minimumReleaseAge: '1 day', }, { - releaseTimestamp: new Date().toString(), + releaseTimestamp: new Date().toString() as Timestamp, minimumReleaseAge: '1 day', }, ]; @@ -206,7 +209,7 @@ describe('workers/repository/update/branch/index', () => { config.prCreation = 'not-pending'; config.upgrades = partial<BranchUpgradeConfig>([ { - releaseTimestamp: '2099-12-31', + releaseTimestamp: '2099-12-31' as Timestamp, minimumReleaseAge: '1 day', }, ]); @@ -1092,7 +1095,7 @@ describe('workers/repository/update/branch/index', () => { pr: partial<Pr>(), }); prAutomerge.checkAutoMerge.mockResolvedValueOnce({ automerged: true }); - config.releaseTimestamp = '2018-04-26T05:15:51.877Z'; + config.releaseTimestamp = '2018-04-26T05:15:51.877Z' as Timestamp; commit.commitFilesToBranch.mockResolvedValueOnce(null); await branchWorker.processBranch(config); expect(platform.ensureComment).toHaveBeenCalledTimes(1); @@ -1117,7 +1120,7 @@ describe('workers/repository/update/branch/index', () => { pr: partial<Pr>(), }); prAutomerge.checkAutoMerge.mockResolvedValueOnce({ automerged: true }); - config.releaseTimestamp = new Date().toISOString(); + config.releaseTimestamp = new Date().toISOString() as Timestamp; commit.commitFilesToBranch.mockResolvedValueOnce(null); await branchWorker.processBranch(config); expect(platform.ensureComment).toHaveBeenCalledTimes(1); @@ -1142,7 +1145,7 @@ describe('workers/repository/update/branch/index', () => { pr: partial<Pr>(), }); prAutomerge.checkAutoMerge.mockResolvedValueOnce({ automerged: true }); - config.releaseTimestamp = new Date().toISOString(); + config.releaseTimestamp = new Date().toISOString() as Timestamp; await expect(branchWorker.processBranch(config)).rejects.toThrow( Error(MANAGER_LOCKFILE_ERROR), ); diff --git a/lib/workers/repository/update/pr/changelog/gitea/index.spec.ts b/lib/workers/repository/update/pr/changelog/gitea/index.spec.ts index 8bf9593052931def7d6faed21ca41ed7bdce0552..b00012eccfe0e13b64db7d8a47a8caa29d7dda02 100644 --- a/lib/workers/repository/update/pr/changelog/gitea/index.spec.ts +++ b/lib/workers/repository/update/pr/changelog/gitea/index.spec.ts @@ -4,6 +4,7 @@ import { partial } from '../../../../../../../test/util'; import * as semverVersioning from '../../../../../../modules/versioning/semver'; import * as hostRules from '../../../../../../util/host-rules'; import { toBase64 } from '../../../../../../util/string'; +import type { Timestamp } from '../../../../../../util/timestamp'; import type { BranchUpgradeConfig } from '../../../../../types'; import { GiteaChangeLogSource } from '../gitea/source'; import { getReleaseNotesMd } from '.'; @@ -22,10 +23,13 @@ const upgrade = partial<BranchUpgradeConfig>({ { version: '5.2.0' }, { version: '5.4.0', - releaseTimestamp: '2018-08-24T14:23:00.000Z', + releaseTimestamp: '2018-08-24T14:23:00.000Z' as Timestamp, }, { version: '5.5.0', gitRef: 'eba303e91c930292198b2fc57040145682162a1b' }, - { version: '5.6.0', releaseTimestamp: '2020-02-13T15:37:00.000Z' }, + { + version: '5.6.0', + releaseTimestamp: '2020-02-13T15:37:00.000Z' as Timestamp, + }, { version: '5.6.1' }, ], }); diff --git a/lib/workers/repository/update/pr/changelog/github/index.spec.ts b/lib/workers/repository/update/pr/changelog/github/index.spec.ts index 4e85b2a379b4afb34090c846bc720eb3b2ef37c2..b5a3523ca1098e8cb380080d7362e3adea0d1a17 100644 --- a/lib/workers/repository/update/pr/changelog/github/index.spec.ts +++ b/lib/workers/repository/update/pr/changelog/github/index.spec.ts @@ -6,6 +6,7 @@ import * as semverVersioning from '../../../../../../modules/versioning/semver'; import * as githubGraphql from '../../../../../../util/github/graphql'; import type { GithubTagItem } from '../../../../../../util/github/graphql/types'; import * as hostRules from '../../../../../../util/host-rules'; +import type { Timestamp } from '../../../../../../util/timestamp'; import type { BranchUpgradeConfig } from '../../../../../types'; jest.mock('../../../../../../modules/datasource/npm'); @@ -25,10 +26,13 @@ const upgrade = partial<BranchUpgradeConfig>({ { version: '2.3.0', gitRef: 'npm_2.3.0', - releaseTimestamp: '2017-10-24T03:20:46.238Z', + releaseTimestamp: '2017-10-24T03:20:46.238Z' as Timestamp, }, { version: '2.2.2', gitRef: 'npm_2.2.2' }, - { version: '2.4.2', releaseTimestamp: '2017-12-24T03:20:46.238Z' }, + { + version: '2.4.2', + releaseTimestamp: '2017-12-24T03:20:46.238Z' as Timestamp, + }, { version: '2.5.2' }, ], }); diff --git a/lib/workers/repository/update/pr/changelog/gitlab/index.spec.ts b/lib/workers/repository/update/pr/changelog/gitlab/index.spec.ts index f55e0e197cfc39d02e3c625ecd472733744d46ea..8986b7dbbb081becd3b16883ea550a628aa9bbcc 100644 --- a/lib/workers/repository/update/pr/changelog/gitlab/index.spec.ts +++ b/lib/workers/repository/update/pr/changelog/gitlab/index.spec.ts @@ -3,6 +3,7 @@ import * as httpMock from '../../../../../../../test/http-mock'; import { partial } from '../../../../../../../test/util'; import * as semverVersioning from '../../../../../../modules/versioning/semver'; import * as hostRules from '../../../../../../util/host-rules'; +import type { Timestamp } from '../../../../../../util/timestamp'; import type { BranchUpgradeConfig } from '../../../../../types'; import { GitLabChangeLogSource } from './source'; @@ -20,10 +21,13 @@ const upgrade = partial<BranchUpgradeConfig>({ { version: '5.2.0' }, { version: '5.4.0', - releaseTimestamp: '2018-08-24T14:23:00.000Z', + releaseTimestamp: '2018-08-24T14:23:00.000Z' as Timestamp, }, { version: '5.5.0', gitRef: 'eba303e91c930292198b2fc57040145682162a1b' }, - { version: '5.6.0', releaseTimestamp: '2020-02-13T15:37:00.000Z' }, + { + version: '5.6.0', + releaseTimestamp: '2020-02-13T15:37:00.000Z' as Timestamp, + }, { version: '5.6.1' }, ], }); diff --git a/lib/workers/repository/update/pr/changelog/index.spec.ts b/lib/workers/repository/update/pr/changelog/index.spec.ts index 5dcfa186fcc60c1b8e94ad8ff07f2781dacd5550..f74d1cbc1a9f0a97b199c88d4af452cb21569c69 100644 --- a/lib/workers/repository/update/pr/changelog/index.spec.ts +++ b/lib/workers/repository/update/pr/changelog/index.spec.ts @@ -4,6 +4,7 @@ import { GlobalConfig } from '../../../../../config/global'; import * as semverVersioning from '../../../../../modules/versioning/semver'; import * as githubGraphql from '../../../../../util/github/graphql'; import * as hostRules from '../../../../../util/host-rules'; +import type { Timestamp } from '../../../../../util/timestamp'; import type { BranchConfig } from '../../../../types'; import * as releases from './releases'; import { getChangeLogJSON } from '.'; @@ -29,10 +30,13 @@ const upgrade = partial<BranchConfig>({ { version: '2.3.0', gitRef: 'npm_2.3.0', - releaseTimestamp: '2017-10-24T03:20:46.238Z', + releaseTimestamp: '2017-10-24T03:20:46.238Z' as Timestamp, }, { version: '2.2.2', gitRef: 'npm_2.2.2' }, - { version: '2.4.2', releaseTimestamp: '2017-12-24T03:20:46.238Z' }, + { + version: '2.4.2', + releaseTimestamp: '2017-12-24T03:20:46.238Z' as Timestamp, + }, { version: '2.5.2' }, ], }); diff --git a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts index 7bb3bd2ebb0c77770bd3781f711a8a6be606d03a..42534bb5bc1e082593b94b0b5b5e888d962dcc82 100644 --- a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts +++ b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts @@ -8,6 +8,7 @@ import * as githubGraphql from '../../../../../util/github/graphql'; import type { GithubReleaseItem } from '../../../../../util/github/graphql/types'; import * as _hostRules from '../../../../../util/host-rules'; import { toBase64 } from '../../../../../util/string'; +import type { Timestamp } from '../../../../../util/timestamp'; import type { BranchUpgradeConfig } from '../../../../types'; import { addReleaseNotes, @@ -251,7 +252,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { githubReleasesMock.mockResolvedValueOnce([ { version: `v1.0.0`, - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 1, url: 'https://example.com', name: 'some/dep', @@ -259,7 +260,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { }, { version: `v1.0.1`, - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 1, url: 'https://example.com', name: 'some/dep', @@ -370,7 +371,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { githubReleasesMock.mockResolvedValueOnce([ { version: '1.0.0', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 1, url: 'https://github.com/some/other-repository/releases/1.0.0', name: '', @@ -378,7 +379,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { }, { version: '1.0.1', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 2, url: 'https://github.com/some/other-repository/releases/1.0.1', name: '', @@ -404,7 +405,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { githubReleasesMock.mockResolvedValueOnce([ { version: '1.0.0', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 1, url: 'https://github.com/some/other-repository/releases/1.0.0', name: 'some/dep', @@ -412,7 +413,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { }, { version: '1.0.1', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 2, url: 'https://github.com/some/other-repository/releases/1.0.1', name: 'some/dep', @@ -447,7 +448,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { githubReleasesMock.mockResolvedValueOnce([ { version: '1.0.0', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 1, url: 'https://github.com/some/other-repository/releases/1.0.0', name: 'some/dep', @@ -455,7 +456,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { }, { version: '1.0.1', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 2, url: 'https://github.com/some/other-repository/releases/1.0.1', name: 'some release name', @@ -489,7 +490,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { githubReleasesMock.mockResolvedValueOnce([ { version: '1.0.0', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 1, url: 'https://github.com/some/other-repository/releases/1.0.0', name: 'Release v1.0.0', @@ -497,7 +498,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { }, { version: '1.0.1', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 2, url: 'https://github.com/some/other-repository/releases/1.0.1', name: '1.0.1', @@ -531,7 +532,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { githubReleasesMock.mockResolvedValueOnce([ { version: '1.0.0', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 1, url: 'https://github.com/some/other-repository/releases/1.0.1', name: 'some/dep', @@ -539,7 +540,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { }, { version: '1.0.1', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 2, url: 'https://github.com/some/other-repository/releases/1.0.1', name: 'v1.0.1 some release', @@ -573,7 +574,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { githubReleasesMock.mockResolvedValueOnce([ { version: '1.0.0', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 1, url: 'correct/url/tag.com', name: 'some/dep', @@ -581,7 +582,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { }, { version: '1.0.1', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 2, url: 'correct/url/tag.com', name: '1.0.1', @@ -607,7 +608,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { githubReleasesMock.mockResolvedValueOnce([ { version: 'v1.0.0', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 1, url: 'https://github.com/some/other-repository/releases/v1.0.0', name: 'some/dep', @@ -615,7 +616,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { }, { version: 'v1.0.1', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 2, url: 'https://github.com/some/other-repository/releases/v1.0.1', name: 'some/dep', @@ -650,7 +651,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { githubReleasesMock.mockResolvedValueOnce([ { version: 'other-1.0.0', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 1, url: 'https://github.com/some/other-repository/releases/other-1.0.0', name: 'some/dep', @@ -658,7 +659,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { }, { version: 'other-1.0.1', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 2, url: 'https://github.com/some/other-repository/releases/other-1.0.1', name: 'some/dep', @@ -694,7 +695,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { githubReleasesMock.mockResolvedValueOnce([ { version: 'other-1.0.0', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 1, url: 'https://github.com/some/other-repository/releases/other-1.0.0', name: 'some/dep', @@ -702,7 +703,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { }, { version: 'other-1.0.1', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 2, url: 'https://github.com/some/other-repository/releases/other-1.0.1', name: 'some/dep', @@ -739,7 +740,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { githubReleasesMock.mockResolvedValueOnce([ { version: 'other_v1.0.0', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 1, url: 'https://github.com/some/other-repository/releases/other_v1.0.0', name: 'some/dep', @@ -747,7 +748,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { }, { version: 'other_v1.0.1', - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, id: 2, url: 'https://github.com/some/other-repository/releases/other_v1.0.1', name: 'some/dep', @@ -784,7 +785,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { version: 'other@1.0.0', id: 1, - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, url: 'https://github.com/some/other-repository/releases/other@1.0.0', name: 'some/dep', description: 'some body', @@ -794,7 +795,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { description: 'some body #123, [#124](https://github.com/some/yet-other-repository/issues/124)', id: 2, - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, url: 'https://github.com/some/other-repository/releases/other@1.0.1', name: 'some/dep', }, @@ -956,7 +957,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { id: 1, version: `${packageName}@1.0.0`, - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, url: 'correct/url/tag.com', name: 'some/dep', description: 'some body', @@ -964,7 +965,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { id: 2, version: `someOtherRelease1/exampleDep_1.0.0`, - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, url: 'correct/url/tag.com', name: 'some/dep', description: 'some body', @@ -972,7 +973,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { id: 3, version: `someOtherRelease2/exampleDep-1.0.0`, - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, url: 'correct/url/tag.com', name: 'some/dep', description: 'some body', @@ -1006,7 +1007,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { id: 123, version: `app-1.0.0`, - releaseTimestamp: '2020-01-01', + releaseTimestamp: '2020-01-01' as Timestamp, url: 'correct/url/tag.com', description: 'some body', name: 'some/dep', diff --git a/lib/workers/repository/updates/generate.spec.ts b/lib/workers/repository/updates/generate.spec.ts index 6769da86bb68035e0a92732f79c966c5ef31e21d..ad7bfe4f8628012ff457f97894a07317a8e454f4 100644 --- a/lib/workers/repository/updates/generate.spec.ts +++ b/lib/workers/repository/updates/generate.spec.ts @@ -2,6 +2,7 @@ import { codeBlock } from 'common-tags'; import { getConfig } from '../../../config/defaults'; import type { UpdateType } from '../../../config/types'; import { NpmDatasource } from '../../../modules/datasource/npm'; +import type { Timestamp } from '../../../util/timestamp'; import type { BranchUpgradeConfig } from '../../types'; import { generateBranchConfig } from './generate'; @@ -34,7 +35,7 @@ describe('workers/repository/updates/generate', () => { depName: 'some-dep', groupName: 'some-group', prTitle: 'some-title', - releaseTimestamp: '2017-02-07T20:01:41+00:00', + releaseTimestamp: '2017-02-07T20:01:41+00:00' as Timestamp, foo: 1, group: { foo: 2, @@ -161,7 +162,7 @@ describe('workers/repository/updates/generate', () => { group: { foo: 2, }, - releaseTimestamp: '2017-02-07T20:01:41+00:00', + releaseTimestamp: '2017-02-07T20:01:41+00:00' as Timestamp, automerge: true, constraints: { foo: '1.0.0', @@ -181,7 +182,7 @@ describe('workers/repository/updates/generate', () => { group: { foo: 2, }, - releaseTimestamp: '2017-02-06T20:01:41+00:00', + releaseTimestamp: '2017-02-06T20:01:41+00:00' as Timestamp, automerge: false, constraints: { foo: '1.0.0', @@ -202,7 +203,7 @@ describe('workers/repository/updates/generate', () => { group: { foo: 2, }, - releaseTimestamp: '2017-02-06T20:01:41+00:00', + releaseTimestamp: '2017-02-06T20:01:41+00:00' as Timestamp, automerge: false, }, ]; @@ -400,7 +401,7 @@ describe('workers/repository/updates/generate', () => { group: { foo: 2, }, - releaseTimestamp: '2017-02-07T20:01:41+00:00', + releaseTimestamp: '2017-02-07T20:01:41+00:00' as Timestamp, updateType: 'minor', separateMinorPatch: true, prTitleStrict: true, @@ -420,7 +421,7 @@ describe('workers/repository/updates/generate', () => { group: { foo: 2, }, - releaseTimestamp: '2017-02-08T20:01:41+00:00', + releaseTimestamp: '2017-02-08T20:01:41+00:00' as Timestamp, updateType: 'minor', separateMinorPatch: true, prTitleStrict: true, @@ -455,7 +456,7 @@ describe('workers/repository/updates/generate', () => { group: { foo: 2, }, - releaseTimestamp: '2017-02-07T20:01:41+00:00', + releaseTimestamp: '2017-02-07T20:01:41+00:00' as Timestamp, updateType: 'minor', separateMinorPatch: true, }, @@ -474,7 +475,7 @@ describe('workers/repository/updates/generate', () => { group: { foo: 2, }, - releaseTimestamp: '2017-02-08T20:01:41+00:00', + releaseTimestamp: '2017-02-08T20:01:41+00:00' as Timestamp, updateType: 'minor', separateMinorPatch: true, }, @@ -507,7 +508,7 @@ describe('workers/repository/updates/generate', () => { group: { foo: 2, }, - releaseTimestamp: '2017-02-07T20:01:41+00:00', + releaseTimestamp: '2017-02-07T20:01:41+00:00' as Timestamp, }, { manager: 'some-manager', @@ -523,7 +524,7 @@ describe('workers/repository/updates/generate', () => { group: { foo: 2, }, - releaseTimestamp: '2017-02-08T20:01:41+00:00', + releaseTimestamp: '2017-02-08T20:01:41+00:00' as Timestamp, }, ] satisfies BranchUpgradeConfig[]; const res = generateBranchConfig(branch); @@ -550,7 +551,7 @@ describe('workers/repository/updates/generate', () => { group: { foo: 2, }, - releaseTimestamp: '2017-02-07T20:01:41+00:00', + releaseTimestamp: '2017-02-07T20:01:41+00:00' as Timestamp, }, { manager: 'some-manager', @@ -566,7 +567,7 @@ describe('workers/repository/updates/generate', () => { group: { foo: 2, }, - releaseTimestamp: '2017-02-08T20:01:41+00:00', + releaseTimestamp: '2017-02-08T20:01:41+00:00' as Timestamp, }, ] satisfies BranchUpgradeConfig[]; const res = generateBranchConfig(branch); @@ -651,7 +652,7 @@ describe('workers/repository/updates/generate', () => { group: { foo: 2, }, - releaseTimestamp: '2017-02-07T20:01:41+00:00', + releaseTimestamp: '2017-02-07T20:01:41+00:00' as Timestamp, }, { manager: 'some-manager', @@ -667,7 +668,7 @@ describe('workers/repository/updates/generate', () => { group: { foo: 2, }, - releaseTimestamp: '2017-02-08T20:01:41+00:00', + releaseTimestamp: '2017-02-08T20:01:41+00:00' as Timestamp, }, ] satisfies BranchUpgradeConfig[]; const res = generateBranchConfig(branch); diff --git a/lib/workers/repository/updates/generate.ts b/lib/workers/repository/updates/generate.ts index f2637f2fb95a665ac2dfd9c57cee09daa36a5c5b..c2db51f46b565610af6b0361eaa90d53ec6d1728 100644 --- a/lib/workers/repository/updates/generate.ts +++ b/lib/workers/repository/updates/generate.ts @@ -9,6 +9,7 @@ import { newlineRegex, regEx } from '../../../util/regex'; import { sanitize } from '../../../util/sanitize'; import { safeStringify } from '../../../util/stringify'; import * as template from '../../../util/template'; +import type { Timestamp } from '../../../util/timestamp'; import { uniq } from '../../../util/uniq'; import type { BranchConfig, BranchUpgradeConfig } from '../../types'; import { CommitMessage } from '../model/commit-message'; @@ -245,7 +246,7 @@ export function generateBranchConfig( logger.trace(`groupEligible: ${groupEligible}`); const useGroupSettings = hasGroupName && groupEligible; logger.trace(`useGroupSettings: ${useGroupSettings}`); - let releaseTimestamp: string; + let releaseTimestamp: Timestamp; if (depTypes.size) { config.depTypes = Array.from(depTypes).sort(); diff --git a/lib/workers/types.ts b/lib/workers/types.ts index e4c6477b45f6627b3fa0e1e0b8b1240a63f5a77f..3b5727320bbe08f5eb8b35b9a3a48a31b19d27e8 100644 --- a/lib/workers/types.ts +++ b/lib/workers/types.ts @@ -19,6 +19,7 @@ import type { import type { PlatformPrOptions } from '../modules/platform/types'; import type { FileChange } from '../util/git/types'; import type { MergeConfidence } from '../util/merge-confidence/types'; +import type { Timestamp } from '../util/timestamp'; import type { ChangeLogRelease, ChangeLogResult, @@ -65,7 +66,7 @@ export interface BranchUpgradeConfig prettyNewMajor?: string; prettyNewVersion?: string; releases?: ReleaseWithNotes[]; - releaseTimestamp?: string; + releaseTimestamp?: Timestamp; repoName?: string; minimumConfidence?: MergeConfidence | undefined; sourceDirectory?: string; @@ -122,7 +123,7 @@ export interface BranchConfig errors?: ValidationMessage[]; hasTypes?: boolean; dependencyDashboardChecks?: Record<string, string>; - releaseTimestamp?: string; + releaseTimestamp?: Timestamp; forceCommit?: boolean; rebaseRequested?: boolean; result?: BranchResult;