From 329b22b7f82d1b9e01d6532c6e62787fee4113c4 Mon Sep 17 00:00:00 2001 From: Jefferson Date: Wed, 20 Mar 2024 20:50:17 -0400 Subject: [PATCH] feat(download): Add APT and YUM package manager Signed-off-by: Jefferson feat(download): Add APT and YUM package manager --- .../Downloads/Release/PlatformDropdown.tsx | 8 +- components/Icons/Platform/Apt.tsx | 101 ++++++++++++++++++ components/Icons/Platform/Yum.tsx | 24 +++++ types/release.ts | 8 +- util/downloadUtils.ts | 8 ++ util/getNodeDownloadSnippet.ts | 28 +++++ 6 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 components/Icons/Platform/Apt.tsx create mode 100644 components/Icons/Platform/Yum.tsx diff --git a/components/Downloads/Release/PlatformDropdown.tsx b/components/Downloads/Release/PlatformDropdown.tsx index 9513d08cde7e0..78e8c83db55d9 100644 --- a/components/Downloads/Release/PlatformDropdown.tsx +++ b/components/Downloads/Release/PlatformDropdown.tsx @@ -5,10 +5,12 @@ import { useContext, useEffect, useMemo } from 'react'; import type { FC } from 'react'; import Select from '@/components/Common/Select'; +import Apt from '@/components/Icons/Platform/Apt'; import Choco from '@/components/Icons/Platform/Choco'; import Docker from '@/components/Icons/Platform/Docker'; import Homebrew from '@/components/Icons/Platform/Homebrew'; import NVM from '@/components/Icons/Platform/NVM'; +import Yum from '@/components/Icons/Platform/Yum'; import { ReleaseContext } from '@/providers/releaseProvider'; import type { PackageManager } from '@/types/release'; import { formatDropdownItems, platformItems } from '@/util/downloadUtils'; @@ -27,7 +29,7 @@ const PlatformDropdown: FC = () => { const disabledItems = []; if (os === 'WIN') { - disabledItems.push('BREW', 'NVM'); + disabledItems.push('BREW', 'NVM', 'APT', 'YUM'); } if (os === 'LINUX') { @@ -35,7 +37,7 @@ const PlatformDropdown: FC = () => { } if (os === 'MAC') { - disabledItems.push('CHOCO'); + disabledItems.push('CHOCO', 'APT', 'YUM'); } const releaseSupportsHomebrew = supportedHomebrewVersions.includes( @@ -77,6 +79,8 @@ const PlatformDropdown: FC = () => { BREW: , DOCKER: , CHOCO: , + APT: , + YUM: , }, disabledItems, })} diff --git a/components/Icons/Platform/Apt.tsx b/components/Icons/Platform/Apt.tsx new file mode 100644 index 0000000000000..8a834b6290886 --- /dev/null +++ b/components/Icons/Platform/Apt.tsx @@ -0,0 +1,101 @@ +import type { FC, SVGProps } from 'react'; + +const Apt: FC> = props => ( + + + + + + + + + + + + + + + + +); + +export default Apt; diff --git a/components/Icons/Platform/Yum.tsx b/components/Icons/Platform/Yum.tsx new file mode 100644 index 0000000000000..88eb2fd483d96 --- /dev/null +++ b/components/Icons/Platform/Yum.tsx @@ -0,0 +1,24 @@ +import type { FC, SVGProps } from 'react'; + +const Yum: FC> = props => ( + + + + + + +); + +export default Yum; diff --git a/types/release.ts b/types/release.ts index 4cbe96bc8fd04..b5824d9761f7b 100644 --- a/types/release.ts +++ b/types/release.ts @@ -3,7 +3,13 @@ import type { ReactNode } from 'react'; import type { NodeRelease } from '@/types/releases'; import type { UserOS } from '@/types/userOS'; -export type PackageManager = 'NVM' | 'BREW' | 'DOCKER' | 'CHOCO'; +export type PackageManager = + | 'NVM' + | 'BREW' + | 'DOCKER' + | 'CHOCO' + | 'APT' + | 'YUM'; export interface ReleaseState { os: UserOS; diff --git a/util/downloadUtils.ts b/util/downloadUtils.ts index 338be8aadcaa6..b16f6b2e9c67a 100644 --- a/util/downloadUtils.ts +++ b/util/downloadUtils.ts @@ -41,6 +41,14 @@ export const platformItems = [ label: 'Docker', value: 'DOCKER' as PackageManager, }, + { + label: 'apt', + value: 'APT' as PackageManager, + }, + { + label: 'yum', + value: 'YUM' as PackageManager, + }, ]; export const bitnessItems = { diff --git a/util/getNodeDownloadSnippet.ts b/util/getNodeDownloadSnippet.ts index 619b3aefa9a20..31ee8fdcb2163 100644 --- a/util/getNodeDownloadSnippet.ts +++ b/util/getNodeDownloadSnippet.ts @@ -10,6 +10,8 @@ export const getNodeDownloadSnippet = (release: NodeRelease, os: UserOS) => { BREW: '', DOCKER: '', CHOCO: '', + APT: '', + YUM: '', }; if (os === 'LINUX' || os === 'MAC') { @@ -36,6 +38,32 @@ export const getNodeDownloadSnippet = (release: NodeRelease, os: UserOS) => { # verifies the right Node.js version is in the environment node -v # should print \`${release.versionWithPrefix}\` + # verifies the right NPM version is in the environment + npm -v # should print \`${release.npm}\``; + + snippets.APT = dedent` + # configure Node.js repository from NodeSource + curl -fsSL https://deb.nodesource.com/setup_${release.major}.x | bash - + + # Install Node.js, replace yum with dnf if needed + apt-get install nodejs -y + + # verifies the right Node.js version is in the environment + node -v # should print \`${release.versionWithPrefix}\` + + # verifies the right NPM version is in the environment + npm -v # should print \`${release.npm}\``; + + snippets.YUM = dedent` + # configure Node.js repository from NodeSource + curl -fsSL https://rpm.nodesource.com/setup_${release.major}.x | bash - + + # Install Node.js, replace yum with dnf if needed + yum install nodejs -y + + # verifies the right Node.js version is in the environment + node -v # should print \`${release.versionWithPrefix}\` + # verifies the right NPM version is in the environment npm -v # should print \`${release.npm}\``; }