From b0537c7f0d047faef7229ea4b88ca1da9be65920 Mon Sep 17 00:00:00 2001 From: Sergio Zharinov <zharinov@users.noreply.github.com> Date: Mon, 9 Mar 2020 21:53:00 +0400 Subject: [PATCH] feat(hex): Support for `releaseTimestamp` field (#5677) --- lib/datasource/hex/__fixtures__/certifi.json | 41 ++++++++++++++--- .../hex/__snapshots__/index.spec.ts.snap | 46 +++++++++++++++++++ lib/datasource/hex/index.ts | 14 +++++- 3 files changed, 92 insertions(+), 9 deletions(-) diff --git a/lib/datasource/hex/__fixtures__/certifi.json b/lib/datasource/hex/__fixtures__/certifi.json index e4292e6050..d72dace37f 100644 --- a/lib/datasource/hex/__fixtures__/certifi.json +++ b/lib/datasource/hex/__fixtures__/certifi.json @@ -1,20 +1,22 @@ { "docs_html_url": null, "downloads": { - "all": 7801231, - "day": 4550, - "recent": 1186862, - "week": 107546 + "all": 20861717, + "day": 5846, + "recent": 3725020, + "week": 438801 }, "html_url": "https://hex.pm/packages/certifi", "inserted_at": "2015-09-10T13:58:43.376194Z", "meta": { "description": "CA bundle adapted from Mozilla by https://certifi.io", - "licenses": ["BSD"], + "licenses": [ + "BSD" + ], "links": { "Github": "https://github.com/certifi/erlang-certifi" }, - "maintainers": ["Benoit Chesneau"] + "maintainers": [] }, "name": "certifi", "owners": [ @@ -27,102 +29,127 @@ "releases": [ { "has_docs": false, + "inserted_at": "2020-03-04T14:54:16.283323Z", + "url": "https://hex.pm/api/packages/certifi/releases/2.5.2", + "version": "2.5.2" + }, + { + "has_docs": false, + "inserted_at": "2019-01-24T15:14:25.991190Z", "url": "https://hex.pm/api/packages/certifi/releases/2.5.1", "version": "2.5.1" }, { "has_docs": false, + "inserted_at": "2018-08-30T08:21:29.349366Z", "url": "https://hex.pm/api/packages/certifi/releases/2.4.2", "version": "2.4.2" }, { "has_docs": false, + "inserted_at": "2018-08-23T08:18:39.658169Z", "url": "https://hex.pm/api/packages/certifi/releases/2.4.1", "version": "2.4.1" }, { "has_docs": false, + "inserted_at": "2018-03-01T12:09:47.479620Z", "url": "https://hex.pm/api/packages/certifi/releases/2.3.1", "version": "2.3.1" }, { "has_docs": false, + "inserted_at": "2018-02-27T21:20:24.804583Z", "url": "https://hex.pm/api/packages/certifi/releases/2.3.0", "version": "2.3.0" }, { "has_docs": false, + "inserted_at": "2018-02-15T14:40:54.249660Z", "url": "https://hex.pm/api/packages/certifi/releases/2.2.0", "version": "2.2.0" }, { "has_docs": false, + "inserted_at": "2018-02-15T14:24:33.990296Z", "url": "https://hex.pm/api/packages/certifi/releases/2.1.0", "version": "2.1.0" }, { "has_docs": false, + "inserted_at": "2017-07-29T10:26:25.887395Z", "url": "https://hex.pm/api/packages/certifi/releases/2.0.0", "version": "2.0.0" }, { "has_docs": false, + "inserted_at": "2017-05-22T10:05:04.091548Z", "url": "https://hex.pm/api/packages/certifi/releases/1.2.1", "version": "1.2.1" }, { "has_docs": false, + "inserted_at": "2017-05-20T17:36:20.704236Z", "url": "https://hex.pm/api/packages/certifi/releases/1.2.0", "version": "1.2.0" }, { "has_docs": false, + "inserted_at": "2017-04-20T03:47:25.151946Z", "url": "https://hex.pm/api/packages/certifi/releases/1.1.0", "version": "1.1.0" }, { "has_docs": false, + "inserted_at": "2017-01-24T11:14:00.415180Z", "url": "https://hex.pm/api/packages/certifi/releases/1.0.0", "version": "1.0.0" }, { "has_docs": false, + "inserted_at": "2016-10-02T23:16:44.504184Z", "url": "https://hex.pm/api/packages/certifi/releases/0.7.0", "version": "0.7.0" }, { "has_docs": false, + "inserted_at": "2016-09-12T10:05:24.327928Z", "url": "https://hex.pm/api/packages/certifi/releases/0.6.0", "version": "0.6.0" }, { "has_docs": false, + "inserted_at": "2016-08-25T14:22:42.043018Z", "url": "https://hex.pm/api/packages/certifi/releases/0.5.0", "version": "0.5.0" }, { "has_docs": false, + "inserted_at": "2016-03-02T20:37:38.856702Z", "url": "https://hex.pm/api/packages/certifi/releases/0.4.0", "version": "0.4.0" }, { "has_docs": false, + "inserted_at": "2015-11-20T14:41:07.485022Z", "url": "https://hex.pm/api/packages/certifi/releases/0.3.0", "version": "0.3.0" }, { "has_docs": false, + "inserted_at": "2015-11-19T11:25:06.024607Z", "url": "https://hex.pm/api/packages/certifi/releases/0.2.0", "version": "0.2.0" }, { "has_docs": false, + "inserted_at": "2015-09-10T13:58:55.620634Z", "url": "https://hex.pm/api/packages/certifi/releases/0.1.1", "version": "0.1.1" } ], "repository": "hexpm", "retirements": {}, - "updated_at": "2019-01-28T20:35:23.869888Z", + "updated_at": "2020-03-04T14:54:16.279054Z", "url": "https://hex.pm/api/packages/certifi" } diff --git a/lib/datasource/hex/__snapshots__/index.spec.ts.snap b/lib/datasource/hex/__snapshots__/index.spec.ts.snap index 328b014728..032b3ccffc 100644 --- a/lib/datasource/hex/__snapshots__/index.spec.ts.snap +++ b/lib/datasource/hex/__snapshots__/index.spec.ts.snap @@ -5,60 +5,83 @@ Object { "homepage": "https://hex.pm/packages/certifi", "releases": Array [ Object { + "releaseTimestamp": "2020-03-04T14:54:16.283323Z", + "version": "2.5.2", + }, + Object { + "releaseTimestamp": "2019-01-24T15:14:25.991190Z", "version": "2.5.1", }, Object { + "releaseTimestamp": "2018-08-30T08:21:29.349366Z", "version": "2.4.2", }, Object { + "releaseTimestamp": "2018-08-23T08:18:39.658169Z", "version": "2.4.1", }, Object { + "releaseTimestamp": "2018-03-01T12:09:47.479620Z", "version": "2.3.1", }, Object { + "releaseTimestamp": "2018-02-27T21:20:24.804583Z", "version": "2.3.0", }, Object { + "releaseTimestamp": "2018-02-15T14:40:54.249660Z", "version": "2.2.0", }, Object { + "releaseTimestamp": "2018-02-15T14:24:33.990296Z", "version": "2.1.0", }, Object { + "releaseTimestamp": "2017-07-29T10:26:25.887395Z", "version": "2.0.0", }, Object { + "releaseTimestamp": "2017-05-22T10:05:04.091548Z", "version": "1.2.1", }, Object { + "releaseTimestamp": "2017-05-20T17:36:20.704236Z", "version": "1.2.0", }, Object { + "releaseTimestamp": "2017-04-20T03:47:25.151946Z", "version": "1.1.0", }, Object { + "releaseTimestamp": "2017-01-24T11:14:00.415180Z", "version": "1.0.0", }, Object { + "releaseTimestamp": "2016-10-02T23:16:44.504184Z", "version": "0.7.0", }, Object { + "releaseTimestamp": "2016-09-12T10:05:24.327928Z", "version": "0.6.0", }, Object { + "releaseTimestamp": "2016-08-25T14:22:42.043018Z", "version": "0.5.0", }, Object { + "releaseTimestamp": "2016-03-02T20:37:38.856702Z", "version": "0.4.0", }, Object { + "releaseTimestamp": "2015-11-20T14:41:07.485022Z", "version": "0.3.0", }, Object { + "releaseTimestamp": "2015-11-19T11:25:06.024607Z", "version": "0.2.0", }, Object { + "releaseTimestamp": "2015-09-10T13:58:55.620634Z", "version": "0.1.1", }, ], @@ -71,60 +94,83 @@ Object { "homepage": "https://hex.pm/packages/certifi", "releases": Array [ Object { + "releaseTimestamp": "2020-03-04T14:54:16.283323Z", + "version": "2.5.2", + }, + Object { + "releaseTimestamp": "2019-01-24T15:14:25.991190Z", "version": "2.5.1", }, Object { + "releaseTimestamp": "2018-08-30T08:21:29.349366Z", "version": "2.4.2", }, Object { + "releaseTimestamp": "2018-08-23T08:18:39.658169Z", "version": "2.4.1", }, Object { + "releaseTimestamp": "2018-03-01T12:09:47.479620Z", "version": "2.3.1", }, Object { + "releaseTimestamp": "2018-02-27T21:20:24.804583Z", "version": "2.3.0", }, Object { + "releaseTimestamp": "2018-02-15T14:40:54.249660Z", "version": "2.2.0", }, Object { + "releaseTimestamp": "2018-02-15T14:24:33.990296Z", "version": "2.1.0", }, Object { + "releaseTimestamp": "2017-07-29T10:26:25.887395Z", "version": "2.0.0", }, Object { + "releaseTimestamp": "2017-05-22T10:05:04.091548Z", "version": "1.2.1", }, Object { + "releaseTimestamp": "2017-05-20T17:36:20.704236Z", "version": "1.2.0", }, Object { + "releaseTimestamp": "2017-04-20T03:47:25.151946Z", "version": "1.1.0", }, Object { + "releaseTimestamp": "2017-01-24T11:14:00.415180Z", "version": "1.0.0", }, Object { + "releaseTimestamp": "2016-10-02T23:16:44.504184Z", "version": "0.7.0", }, Object { + "releaseTimestamp": "2016-09-12T10:05:24.327928Z", "version": "0.6.0", }, Object { + "releaseTimestamp": "2016-08-25T14:22:42.043018Z", "version": "0.5.0", }, Object { + "releaseTimestamp": "2016-03-02T20:37:38.856702Z", "version": "0.4.0", }, Object { + "releaseTimestamp": "2015-11-20T14:41:07.485022Z", "version": "0.3.0", }, Object { + "releaseTimestamp": "2015-11-19T11:25:06.024607Z", "version": "0.2.0", }, Object { + "releaseTimestamp": "2015-09-10T13:58:55.620634Z", "version": "0.1.1", }, ], diff --git a/lib/datasource/hex/index.ts b/lib/datasource/hex/index.ts index a001e717f0..a8ee3f866f 100644 --- a/lib/datasource/hex/index.ts +++ b/lib/datasource/hex/index.ts @@ -7,7 +7,10 @@ export const id = 'hex'; interface HexRelease { html_url: string; meta?: { links?: Record<string, string> }; - releases?: { version: string }[]; + releases?: { + version: string; + inserted_at?: string; + }[]; } export async function getPkgReleases({ @@ -41,7 +44,14 @@ export async function getPkgReleases({ } const result: ReleaseResult = { - releases: releases.map(({ version }) => ({ version })), + releases: releases.map(({ version, inserted_at }) => + inserted_at + ? { + version, + releaseTimestamp: inserted_at, + } + : { version } + ), }; if (homepage) { -- GitLab