From be1d066984ad423611b9c79a3818bd34dbb6b1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Quiroz?= Date: Mon, 12 Dec 2022 13:11:15 -0300 Subject: [PATCH 1/7] chore: wip --- src/components/UI/DataTable.tsx | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/components/UI/DataTable.tsx b/src/components/UI/DataTable.tsx index 55df07c493..60c702055b 100644 --- a/src/components/UI/DataTable.tsx +++ b/src/components/UI/DataTable.tsx @@ -71,11 +71,72 @@ export const DataTable: FC = ({ columnHeaders, data }) => { {dataType === 'Releases' && data.map((r: ReleaseData, idx: number) => { + const url = r?.release?.url; + const os = url?.includes('darwin') + ? 'darwin' + : url?.includes('linux') + ? 'linux' + : url?.includes('windows') + ? 'windows' + : url?.includes('android') + ? 'android' + : 'ios'; + + // const isLatestStableLinuxRelease = + // os === 'linux' && + // data + // .filter( + // (e: ReleaseData) => e.arch === '64-bit' && !e.release.url.includes('unstable') + // ) + // .every((elem: ReleaseData) => { + // console.log('release:', r); + // console.log('elem:', elem); + + // return new Date(r.published) >= new Date(elem.published); + // }); + + const x = data.filter((e: ReleaseData, _: any, array: any) => { + const maxDate = array + .map((e: ReleaseData) => new Date(e.published)) + .filter((f: Date, _: any, array: any) => + array.every((f: Date) => f <= new Date(e.published)) + ); + + return ( + e.arch === '64-bit' && + !e.release.url.includes('unstable') && + new Date(e.published) === new Date(maxDate) + ); + }); + + console.log(x); + + const latestDarwinRelease = os === 'darwin' && r.arch === '64-bit'; + const latestWindowsRelease = os === 'darwin' && r.kind === 'Installer'; + const latestAndroidRelease = os === 'android' && r.arch === 'all'; + const latestiOSRelease = os === 'ios' && r.arch === 'all'; + + // const latest = data.filter( + // (rel: ReleaseData) => + // os === 'linux' && rel.arch === '64-bit' && !rel.release.url.includes('unstable') + // ); + // .every((otherRelease: ReleaseData) => r.published > otherRelease.published); + + // console.log({ latest }); + + const isPrimaryRelease = + 'isLatestStableLinuxRelease' || + latestDarwinRelease || + latestWindowsRelease || + latestAndroidRelease || + latestiOSRelease; + return ( {Object.entries(r).map((item, idx) => { const objectItems = ['release', 'commit', 'signature']; From e6c2d7f2595a2590f8d8cb92170e27724075c261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Quiroz?= Date: Mon, 12 Dec 2022 14:01:52 -0300 Subject: [PATCH 2/7] chore: update wip --- src/components/UI/DataTable.tsx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/UI/DataTable.tsx b/src/components/UI/DataTable.tsx index 60c702055b..3798a4b08d 100644 --- a/src/components/UI/DataTable.tsx +++ b/src/components/UI/DataTable.tsx @@ -82,18 +82,18 @@ export const DataTable: FC = ({ columnHeaders, data }) => { ? 'android' : 'ios'; - // const isLatestStableLinuxRelease = - // os === 'linux' && - // data - // .filter( - // (e: ReleaseData) => e.arch === '64-bit' && !e.release.url.includes('unstable') - // ) - // .every((elem: ReleaseData) => { - // console.log('release:', r); - // console.log('elem:', elem); + const isLatestStableLinuxRelease = + os === 'linux' && + data + .filter( + (e: ReleaseData) => e.arch === '64-bit' && !e.release.url.includes('unstable') + ) + .every((elem: ReleaseData) => { + console.log('release:', r); + console.log('elem:', elem); - // return new Date(r.published) >= new Date(elem.published); - // }); + return new Date(r.published) >= new Date(elem.published); + }); const x = data.filter((e: ReleaseData, _: any, array: any) => { const maxDate = array @@ -125,7 +125,7 @@ export const DataTable: FC = ({ columnHeaders, data }) => { // console.log({ latest }); const isPrimaryRelease = - 'isLatestStableLinuxRelease' || + isLatestStableLinuxRelease || latestDarwinRelease || latestWindowsRelease || latestAndroidRelease || @@ -136,7 +136,7 @@ export const DataTable: FC = ({ columnHeaders, data }) => { key={idx} transition={'all 0.5s'} _hover={{ background: 'button-bg', transition: 'all 0.5s' }} - fontWeight={false ? 700 : 400} + fontWeight={isLatestStableLinuxRelease ? 700 : 400} > {Object.entries(r).map((item, idx) => { const objectItems = ['release', 'commit', 'signature']; From e66168660aa5e0a6f48621dd1e339d3a93c56a0b Mon Sep 17 00:00:00 2001 From: Corwin Smith Date: Mon, 12 Dec 2022 13:46:11 -0700 Subject: [PATCH 3/7] linux stables build --- src/components/UI/DataTable.tsx | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/components/UI/DataTable.tsx b/src/components/UI/DataTable.tsx index 3798a4b08d..bc0452b96b 100644 --- a/src/components/UI/DataTable.tsx +++ b/src/components/UI/DataTable.tsx @@ -85,15 +85,10 @@ export const DataTable: FC = ({ columnHeaders, data }) => { const isLatestStableLinuxRelease = os === 'linux' && data + .slice(0, 12) // get latest build to filter on .filter( (e: ReleaseData) => e.arch === '64-bit' && !e.release.url.includes('unstable') - ) - .every((elem: ReleaseData) => { - console.log('release:', r); - console.log('elem:', elem); - - return new Date(r.published) >= new Date(elem.published); - }); + ).includes(r) const x = data.filter((e: ReleaseData, _: any, array: any) => { const maxDate = array From 776616f45db1be98a94f9e786679fd253d26cb65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Quiroz?= Date: Mon, 12 Dec 2022 19:44:42 -0300 Subject: [PATCH 4/7] chore: update utils --- src/utils/getOS.ts | 11 +++++++++++ src/utils/index.ts | 5 +++++ src/utils/isDarwinPrimaryRelease.ts | 8 ++++++++ src/utils/isLinuxPrimaryRelease.ts | 8 ++++++++ src/utils/isMobilePrimaryRelease.ts | 8 ++++++++ src/utils/isWindowsPrimaryRelease.ts | 8 ++++++++ 6 files changed, 48 insertions(+) create mode 100644 src/utils/getOS.ts create mode 100644 src/utils/isDarwinPrimaryRelease.ts create mode 100644 src/utils/isLinuxPrimaryRelease.ts create mode 100644 src/utils/isMobilePrimaryRelease.ts create mode 100644 src/utils/isWindowsPrimaryRelease.ts diff --git a/src/utils/getOS.ts b/src/utils/getOS.ts new file mode 100644 index 0000000000..b2a3c61a1d --- /dev/null +++ b/src/utils/getOS.ts @@ -0,0 +1,11 @@ +import { OS } from '../types'; + +// slice to get the last part of the url that includes the os +export const getOS = (url: string): OS => + url?.slice(46).includes('darwin') + ? 'darwin' + : url?.slice(46).includes('linux') + ? 'linux' + : url?.slice(46).includes('windows') + ? 'windows' + : 'mobile'; diff --git a/src/utils/index.ts b/src/utils/index.ts index 206b319fe8..f950ec7d46 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -5,6 +5,7 @@ export { fetchXMLData } from './fetchXMLData'; export { getChecksum } from './getChecksum'; export { getKebabCaseFromName } from './getKebabCaseFromName'; export { getLatestBinaryURL } from './getLatestBinaryURL'; +export { getOS } from './getOS'; export { getParsedDate } from './getParsedDate'; export { getProgrammingLanguageName } from './getProgrammingLanguageName'; export { getReleaseArch } from './getReleaseArch'; @@ -16,4 +17,8 @@ export { getReleaseSize } from './getReleaseSize'; export { getReleaseURL } from './getReleaseURL'; export { getSignatureURL } from './getSignatureURL'; export { getSortedReleases } from './getSortedReleases'; +export { isDarwinPrimaryRelease } from './isDarwinPrimaryRelease'; +export { isLinuxPrimaryRelease } from './isLinuxPrimaryRelease'; +export { isMobilePrimaryRelease } from './isMobilePrimaryRelease'; +export { isWindowsPrimaryRelease } from './isWindowsPrimaryRelease'; export { mapReleasesData } from './mapReleasesData'; diff --git a/src/utils/isDarwinPrimaryRelease.ts b/src/utils/isDarwinPrimaryRelease.ts new file mode 100644 index 0000000000..1b4f0327e3 --- /dev/null +++ b/src/utils/isDarwinPrimaryRelease.ts @@ -0,0 +1,8 @@ +import { OS, ReleaseData } from '../types'; + +export const isDarwinPrimaryRelease = (r: ReleaseData, os: OS, data: ReleaseData[]) => + os === 'darwin' && + data + .slice(0, 2) // get latest build to filter on + .filter((e: ReleaseData) => e.arch === '64-bit') + .includes(r); diff --git a/src/utils/isLinuxPrimaryRelease.ts b/src/utils/isLinuxPrimaryRelease.ts new file mode 100644 index 0000000000..e2c9437e11 --- /dev/null +++ b/src/utils/isLinuxPrimaryRelease.ts @@ -0,0 +1,8 @@ +import { OS, ReleaseData } from '../types'; + +export const isLinuxPrimaryRelease = (r: ReleaseData, os: OS, data: ReleaseData[]) => + os === 'linux' && + data + .slice(0, 12) // get latest build to filter on + .filter((e: ReleaseData) => e.arch === '64-bit') + .includes(r); diff --git a/src/utils/isMobilePrimaryRelease.ts b/src/utils/isMobilePrimaryRelease.ts new file mode 100644 index 0000000000..fcbdcdc7dc --- /dev/null +++ b/src/utils/isMobilePrimaryRelease.ts @@ -0,0 +1,8 @@ +import { OS, ReleaseData } from '../types'; + +export const isMobilePrimaryRelease = (r: ReleaseData, os: OS, data: ReleaseData[]) => + os === 'mobile' && + data + .filter((e: ReleaseData) => e.arch === 'all') + .slice(0, 1) // get latest build + .includes(r); diff --git a/src/utils/isWindowsPrimaryRelease.ts b/src/utils/isWindowsPrimaryRelease.ts new file mode 100644 index 0000000000..d197232838 --- /dev/null +++ b/src/utils/isWindowsPrimaryRelease.ts @@ -0,0 +1,8 @@ +import { OS, ReleaseData } from '../types'; + +export const isWindowsPrimaryRelease = (r: ReleaseData, os: OS, data: ReleaseData[]) => + os === 'windows' && + data + .slice(0, 6) // get latest build to filter on + .filter((e: ReleaseData) => e.kind === 'Installer' && e.arch === '64-bit') + .includes(r); From 8566e5bb1f8958c4a4c7e40c589688eaa59b28c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Quiroz?= Date: Mon, 12 Dec 2022 19:44:52 -0300 Subject: [PATCH 5/7] chore: update types --- src/types.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types.ts b/src/types.ts index 5104fe71fd..4a93eed9aa 100644 --- a/src/types.ts +++ b/src/types.ts @@ -50,3 +50,5 @@ export interface OpenPGPSignaturesData { }; fingerprint: string; } + +export type OS = 'linux' | 'darwin' | 'windows' | 'mobile'; From dfdf95639ed966c3ec5cc6a8aeb39cd2643d2af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Quiroz?= Date: Mon, 12 Dec 2022 19:45:26 -0300 Subject: [PATCH 6/7] feat: check if it's primary release --- src/components/UI/DataTable.tsx | 71 +++++++++------------------------ 1 file changed, 19 insertions(+), 52 deletions(-) diff --git a/src/components/UI/DataTable.tsx b/src/components/UI/DataTable.tsx index bc0452b96b..9d51e45178 100644 --- a/src/components/UI/DataTable.tsx +++ b/src/components/UI/DataTable.tsx @@ -11,8 +11,16 @@ import { Stack } from '@chakra-ui/react'; import { FC } from 'react'; + +import { + getOS, + getParsedDate, + isDarwinPrimaryRelease, + isLinuxPrimaryRelease, + isMobilePrimaryRelease, + isWindowsPrimaryRelease +} from '../../utils'; import { OpenPGPSignaturesData, ReleaseData } from '../../types'; -import { getParsedDate } from '../../utils'; interface Props { columnHeaders: string[]; @@ -72,66 +80,25 @@ export const DataTable: FC = ({ columnHeaders, data }) => { {dataType === 'Releases' && data.map((r: ReleaseData, idx: number) => { const url = r?.release?.url; - const os = url?.includes('darwin') - ? 'darwin' - : url?.includes('linux') - ? 'linux' - : url?.includes('windows') - ? 'windows' - : url?.includes('android') - ? 'android' - : 'ios'; + const os = getOS(url); - const isLatestStableLinuxRelease = - os === 'linux' && - data - .slice(0, 12) // get latest build to filter on - .filter( - (e: ReleaseData) => e.arch === '64-bit' && !e.release.url.includes('unstable') - ).includes(r) - - const x = data.filter((e: ReleaseData, _: any, array: any) => { - const maxDate = array - .map((e: ReleaseData) => new Date(e.published)) - .filter((f: Date, _: any, array: any) => - array.every((f: Date) => f <= new Date(e.published)) - ); - - return ( - e.arch === '64-bit' && - !e.release.url.includes('unstable') && - new Date(e.published) === new Date(maxDate) - ); - }); - - console.log(x); - - const latestDarwinRelease = os === 'darwin' && r.arch === '64-bit'; - const latestWindowsRelease = os === 'darwin' && r.kind === 'Installer'; - const latestAndroidRelease = os === 'android' && r.arch === 'all'; - const latestiOSRelease = os === 'ios' && r.arch === 'all'; - - // const latest = data.filter( - // (rel: ReleaseData) => - // os === 'linux' && rel.arch === '64-bit' && !rel.release.url.includes('unstable') - // ); - // .every((otherRelease: ReleaseData) => r.published > otherRelease.published); - - // console.log({ latest }); + const _isLinuxPrimaryRelease = isLinuxPrimaryRelease(r, os, data); + const _isDarwinPrimaryRelease = isDarwinPrimaryRelease(r, os, data); + const _isWindowsPrimaryRelease = isWindowsPrimaryRelease(r, os, data); + const _isMobilePrimaryRelease = isMobilePrimaryRelease(r, os, data); const isPrimaryRelease = - isLatestStableLinuxRelease || - latestDarwinRelease || - latestWindowsRelease || - latestAndroidRelease || - latestiOSRelease; + _isLinuxPrimaryRelease || + _isDarwinPrimaryRelease || + _isWindowsPrimaryRelease || + _isMobilePrimaryRelease; return ( {Object.entries(r).map((item, idx) => { const objectItems = ['release', 'commit', 'signature']; From 9e3789e31f92d5151f2ba08317623623177e9ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Quiroz?= Date: Tue, 13 Dec 2022 00:07:38 -0300 Subject: [PATCH 7/7] chore: import correct font weight --- src/pages/_document.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index 9a0ff9aa9e..63b82cdf35 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -15,7 +15,7 @@ export default function Document() { {/* Inter */}