From a4cdd145d2450ee3f7d225d1bf5f5f98b912d9ba Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Wed, 30 Oct 2019 07:02:07 +0100 Subject: [PATCH] feat: update date fns to v2 (#232) * chore: updates date-fns@2 * chore: updates date-fns@2 to new apis * chore: updates date-fns@2, updates format --- jest/unit/components/__mocks__/token.ts | 2 +- package.json | 2 +- src/utils/package.ts | 6 +++--- yarn.lock | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/jest/unit/components/__mocks__/token.ts b/jest/unit/components/__mocks__/token.ts index bdac6fa..bed5d39 100644 --- a/jest/unit/components/__mocks__/token.ts +++ b/jest/unit/components/__mocks__/token.ts @@ -3,7 +3,7 @@ */ import { Base64 } from 'js-base64'; -import addHours from 'date-fns/add_hours'; +import addHours from 'date-fns/addHours'; export function generateTokenWithTimeRange(limit = 0) { const payload = { diff --git a/package.json b/package.json index 0fdcd6b..3d32aee 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "concurrently": "5.0.0", "cross-env": "6.0.3", "css-loader": "3.2.0", - "date-fns": "1.30.1", + "date-fns": "2.6.0", "detect-secrets": "1.0.4", "emotion": "9.2.12", "enzyme": "3.10.0", diff --git a/src/utils/package.ts b/src/utils/package.ts index 5330b68..d8e2f3a 100644 --- a/src/utils/package.ts +++ b/src/utils/package.ts @@ -3,11 +3,11 @@ import { isObject } from 'util'; import { UpLinks } from '@verdaccio/types'; import isString from 'lodash/isString'; import format from 'date-fns/format'; -import distanceInWordsToNow from 'date-fns/distance_in_words_to_now'; +import formatDistanceToNow from 'date-fns/formatDistanceToNow'; import { Time } from '../../types/packageMeta'; -export const TIMEFORMAT = 'DD.MM.YYYY, HH:mm:ss'; +export const TIMEFORMAT = 'dd.MM.yyyy, HH:mm:ss'; /** * Formats license field for webui. @@ -56,7 +56,7 @@ export function formatDate(lastUpdate: string | number): string { } export function formatDateDistance(lastUpdate: Date | string | number): string { - return distanceInWordsToNow(new Date(lastUpdate)); + return formatDistanceToNow(new Date(lastUpdate)); } /** diff --git a/yarn.lock b/yarn.lock index 8ad73c9..a970bf3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4526,16 +4526,16 @@ data-urls@^1.0.0, data-urls@^1.1.0: whatwg-mimetype "^2.2.0" whatwg-url "^7.0.0" -date-fns@1.30.1, date-fns@^1.27.2: - version "1.30.1" - resolved "https://registry.verdaccio.org/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c" - integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw== - -date-fns@^2.0.1: +date-fns@2.6.0, date-fns@^2.0.1: version "2.6.0" resolved "https://registry.verdaccio.org/date-fns/-/date-fns-2.6.0.tgz#a5bc82e6a4c3995ae124b0ba1a71aec7b8cbd666" integrity sha512-F55YxqRdEfP/eYQmQjLN798v0AwLjmZ8nMBjdQvNwEE3N/zWVrlkkqT+9seBlPlsbkybG4JmWg3Ee3dIV9BcGQ== +date-fns@^1.27.2: + version "1.30.1" + resolved "https://registry.verdaccio.org/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c" + integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw== + date-now@^0.1.4: version "0.1.4" resolved "https://registry.verdaccio.org/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"