From 782381168d7c6b5c968b4e4574f8699c386bb33d Mon Sep 17 00:00:00 2001 From: AlexisG Date: Thu, 19 Dec 2024 14:44:48 +0100 Subject: [PATCH 1/3] chore: Run bundlemon before test in GA step Tests randomly modify the style file. This is not a problem for the final build, which uses the cached version, but BundlMon was monitoring a style file that was always different and did not represent the true state. --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c16eb3c4a..e691ecf0c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -47,10 +47,10 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/actions/setup_modules - uses: ./.github/actions/build_cache_read - - name: Tests - run: yarn test - name: BundleMon uses: lironer/bundlemon-action@v1 + - name: Tests + run: yarn test argosDesktop: needs: [prepareArgos, build] runs-on: ubuntu-latest From 69274a2f5c56b11cfbd77c977a6ee34254e0803b Mon Sep 17 00:00:00 2001 From: AlexisG Date: Thu, 19 Dec 2024 14:48:02 +0100 Subject: [PATCH 2/3] chore: Remove maximum style file size In order not to be blocked, it will be delivered very soon. --- .bundlemonrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.bundlemonrc b/.bundlemonrc index 90f5d2cdc..841beb53a 100644 --- a/.bundlemonrc +++ b/.bundlemonrc @@ -10,8 +10,7 @@ "maxPercentIncrease": 10 }, { - "path": "transpiled/react/stylesheet.css", - "maxPercentIncrease": 10 + "path": "transpiled/react/stylesheet.css" } ], "groups": [ From 9ad977c9a8078478d91d93670c9312429141b55d Mon Sep 17 00:00:00 2001 From: AlexisG Date: Thu, 19 Dec 2024 14:48:34 +0100 Subject: [PATCH 3/3] feat: Upgrade date-fns to 2.30.0 BREAKING CHANGE: The date formatting function (`f` from `useI18n`) changes, please refer to this doc. https://date-fns.org/v2.30.0/docs/format --- package.json | 2 +- react/BarContextProvider/index.spec.jsx | 2 +- react/DateMonthPicker/index.jsx | 6 ++--- react/FilePicker/FilePickerBodyItem.jsx | 2 +- react/ListItem/ListItemFile/SecondaryText.jsx | 2 +- react/providers/I18n/format.jsx | 13 ++++++----- react/providers/I18n/index.spec.jsx | 2 +- yarn.lock | 22 +++++++++++++++---- 8 files changed, 34 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 6b6c56f5f..d97ad4ee3 100644 --- a/package.json +++ b/package.json @@ -162,7 +162,7 @@ "chart.js": "3.7.1", "classnames": "^2.2.5", "cozy-interapp": "^0.5.4", - "date-fns": "^1.28.5", + "date-fns": "2.30.0", "filesize": "8.0.7", "hammerjs": "^2.0.8", "intersection-observer": "0.11.0", diff --git a/react/BarContextProvider/index.spec.jsx b/react/BarContextProvider/index.spec.jsx index b53fff9b7..823072a36 100644 --- a/react/BarContextProvider/index.spec.jsx +++ b/react/BarContextProvider/index.spec.jsx @@ -22,7 +22,7 @@ const DumbHelloWorld = translate()(({ t, f, lang }) => (
{t('helloworld')}
- {f('2020-01-06', 'DDD MMM')} + {f('2020-01-06', 'D LLL', { useAdditionalDayOfYearTokens: true })}
{lang}
diff --git a/react/DateMonthPicker/index.jsx b/react/DateMonthPicker/index.jsx index 6d612fb46..399ba39ae 100644 --- a/react/DateMonthPicker/index.jsx +++ b/react/DateMonthPicker/index.jsx @@ -26,7 +26,7 @@ const MonthButton = ({ monthNum, onClick, isSelected }) => { )} onClick={handleClick} > - {f(d, 'MMM')} + {f(d, 'LLL')} ) } @@ -50,7 +50,7 @@ const DateMonthPicker = ({ initialValue, onSelect }) => { const handleClickMonth = month => { const d = new Date(year, month, 1) - onSelect(format(d, 'YYYY-MM-DD')) + onSelect(format(d, 'yyyy-LL-dd')) } return (
@@ -93,7 +93,7 @@ const dateMonthProp = function (props, propName, componentName) { '` supplied to' + ' `' + componentName + - '`. Should be in the form YYYY-MM.' + '`. Should be in the form yyyy-LL.' ) } } diff --git a/react/FilePicker/FilePickerBodyItem.jsx b/react/FilePicker/FilePickerBodyItem.jsx index 8f913f054..b5d35c889 100644 --- a/react/FilePicker/FilePickerBodyItem.jsx +++ b/react/FilePicker/FilePickerBodyItem.jsx @@ -51,7 +51,7 @@ const FilePickerBodyItem = ({ const Input = multiple ? Checkbox : Radio const listItemSecondaryContent = isFile(item) - ? `${f(item.updated_at, 'DD MMM YYYY')} - ${filesize(item.size, { + ? `${f(item.updated_at, 'dd LLL yyyy')} - ${filesize(item.size, { base: 10 })}` : null diff --git a/react/ListItem/ListItemFile/SecondaryText.jsx b/react/ListItem/ListItemFile/SecondaryText.jsx index 1f736e881..59c918488 100644 --- a/react/ListItem/ListItemFile/SecondaryText.jsx +++ b/react/ListItem/ListItemFile/SecondaryText.jsx @@ -12,7 +12,7 @@ const SecondaryText = ({ secondary, file }) => { if (secondary) return secondary const date = file?.metadata?.datetime - ? f(file?.metadata?.datetime, 'DD/MM/YYYY') + ? f(file?.metadata?.datetime, 'dd/LL/yyyy') : null return ( diff --git a/react/providers/I18n/format.jsx b/react/providers/I18n/format.jsx index c6b3ba9a0..bb11a0f80 100644 --- a/react/providers/I18n/format.jsx +++ b/react/providers/I18n/format.jsx @@ -1,5 +1,5 @@ -import distanceInWordsToNow from 'date-fns/distance_in_words_to_now' import format from 'date-fns/format' +import formatDistanceToNow from 'date-fns/formatDistanceToNow' import { DEFAULT_LANG } from '.' @@ -29,10 +29,13 @@ export const provideDateFnsLocale = (userLang, defaultLang = DEFAULT_LANG) => { export const initFormat = (userLang, defaultLang = DEFAULT_LANG) => - (date, formatStr) => { + (date, formatStr, opts = {}) => { const locale = provideDateFnsLocale(userLang, defaultLang) - return format(date, formatStr, { locale }) + const ensureDate = date && typeof date === 'string' ? new Date(date) : date + + return format(ensureDate, formatStr, { locale, ...opts }) } -export const formatLocallyDistanceToNow = date => - distanceInWordsToNow(date, { locale: locales[lang] }) +export const formatLocallyDistanceToNow = date => { + return formatDistanceToNow(date, { locale: locales[lang] }) +} diff --git a/react/providers/I18n/index.spec.jsx b/react/providers/I18n/index.spec.jsx index f46a52e88..9f53df5ca 100644 --- a/react/providers/I18n/index.spec.jsx +++ b/react/providers/I18n/index.spec.jsx @@ -10,7 +10,7 @@ const DumbI18nHelloWorld = ({ t, f, lang }) => (
{t('helloworld')}
- {f('2020-01-06', 'DDD MMM')} + {f('2020-01-06', 'D LLL', { useAdditionalDayOfYearTokens: true })}
{lang}
diff --git a/yarn.lock b/yarn.lock index 39ca64c0c..a6b91d5e4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1403,6 +1403,13 @@ dependencies: regenerator-runtime "^0.13.4" +"@babel/runtime@^7.21.0": + version "7.26.0" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.0.tgz#8600c2f595f277c60815256418b85356a65173c1" + integrity sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw== + dependencies: + regenerator-runtime "^0.14.0" + "@babel/runtime@^7.9.2": version "7.14.6" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.14.6.tgz#535203bc0892efc7dec60bdc27b2ecf6e409062d" @@ -6548,10 +6555,12 @@ date-fns@2.29.3: resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz#27402d2fc67eb442b511b70bbdf98e6411cd68a8" integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA== -date-fns@^1.28.5: - version "1.30.1" - resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c" - integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw== +date-fns@2.30.0: + version "2.30.0" + resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.30.0.tgz#f367e644839ff57894ec6ac480de40cae4b0f4d0" + integrity sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw== + dependencies: + "@babel/runtime" "^7.21.0" date-now@^0.1.4: version "0.1.4" @@ -16623,6 +16632,11 @@ regenerator-runtime@^0.13.4: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.4.tgz#e96bf612a3362d12bb69f7e8f74ffeab25c7ac91" integrity sha512-plpwicqEzfEyTQohIKktWigcLzmNStMGwbOUbykx51/29Z3JOGYldaaNGK7ngNXV+UcoqvIMmloZ48Sr74sd+g== +regenerator-runtime@^0.14.0: + version "0.14.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f" + integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw== + regenerator-transform@^0.14.2: version "0.14.5" resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.5.tgz#c98da154683671c9c4dcb16ece736517e1b7feb4"