Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: package-managers as default, redirects and more info #6720

Merged
merged 4 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
node_modules
npm-debug.log
.npm
.env.local
.env.*

# Next.js Build Output
.next
Expand Down
2 changes: 1 addition & 1 deletion components/Common/Badge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Badge: FC<PropsWithChildren<BadgeProps>> = ({
<Link className={`${styles.wrapper} ${styles[kind]}`} {...args}>
{badgeText && <span className={styles.badge}>{badgeText}</span>}
<span className={styles.message}>{children}</span>
<ArrowRightIcon className={styles.icon} />
{args.href && <ArrowRightIcon className={styles.icon} />}
</Link>
);

Expand Down
4 changes: 2 additions & 2 deletions components/Downloads/Release/ReleaseCodeBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ const ReleaseCodeBox: FC = () => {
)}

<span className="text-center text-xs text-neutral-800 dark:text-neutral-200">
<b>{t('layouts.download.codeBox.managerInstalled')}</b>
<br />
{t('layouts.download.codeBox.communityWarning')}
<br />
<b>{t('layouts.download.codeBox.communityWarningReport')}</b>
</span>
</div>
);
Expand Down
12 changes: 6 additions & 6 deletions components/withDownloadCategories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ const WithDownloadCategories: FC<PropsWithChildren> = async ({ children }) => {
page: page,
categories: [
{
category: 'download',
label: t('layouts.download.categories.download'),
category: 'package-manager',
label: t('layouts.download.categories.package-manager'),
},
{
category: 'prebuilt-binaries',
label: t('layouts.download.categories.prebuilt-binaries'),
category: 'prebuilt-installer',
label: t('layouts.download.categories.prebuilt-installer'),
},
{
category: 'package-manager',
label: t('layouts.download.categories.package-manager'),
category: 'prebuilt-binaries',
label: t('layouts.download.categories.prebuilt-binaries'),
},
{
category: 'source-code',
Expand Down
7 changes: 4 additions & 3 deletions i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
"download": {
"selectCategory": "Categories",
"categories": {
"download": "Prebuilt Installer",
"prebuilt-installer": "Prebuilt Installer",
"prebuilt-binaries": "Prebuilt Binaries",
"package-manager": "Package Manager",
"source-code": "Source Code"
Expand All @@ -284,8 +284,9 @@
"platform": "Platform"
},
"codeBox": {
"managerInstalled": "Please ensure you have the right package manager installed before running a script.",
"communityWarning": "Package managers and their installation scripts are not maintained by the Node.js project."
"systemManagerWarning": "is not a Node.js package manager. Please ensure you already have {packageManager} installed.",
"communityWarning": "Package managers and their installation scripts are not maintained by the Node.js project.",
"communityWarningReport": "If you encounter issues, please reach out to the package manager's maintainers."
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@
{
"source": "/:locale/blog/weekly-updates/:path*",
"destination": "/:locale/blog/weekly/:path*"
},
{
"source": "/:locale/download",
"destination": "/:locale/download/package-manager"
},
{
"source": "/:locale/download/current",
"destination": "/:locale/download/package-manager/current"
}
],
"internal": []
Expand Down
20 changes: 14 additions & 6 deletions util/__tests__/downloadUtils.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ describe('mapCategoriesToTabs', () => {
page: 'download',
categories: [
{
category: 'download',
label: 'Download',
category: 'prebuilt-binaries',
label: 'Prebuilt Binaries',
},
{
category: 'package-manager',
Expand All @@ -115,7 +115,11 @@ describe('mapCategoriesToTabs', () => {
});

expect(result).toEqual([
{ key: 'download', label: 'Download', link: '/download/current' },
{
key: 'prebuilt-binaries',
label: 'Prebuilt Binaries',
link: '/download/prebuilt-binaries/current',
},
{
key: 'package-manager',
label: 'Package Manager',
Expand All @@ -129,8 +133,8 @@ describe('mapCategoriesToTabs', () => {
page: 'download',
categories: [
{
category: 'download',
label: 'Download',
category: 'prebuilt-binaries',
label: 'Prebuilt Binaries',
},
{
category: 'package-manager',
Expand All @@ -140,7 +144,11 @@ describe('mapCategoriesToTabs', () => {
});

expect(result).toEqual([
{ key: 'download', label: 'Download', link: '/download' },
{
key: 'prebuilt-binaries',
label: 'Prebuilt Binaries',
link: '/download/prebuilt-binaries',
},
{
key: 'package-manager',
label: 'Package Manager',
Expand Down
34 changes: 19 additions & 15 deletions util/downloadUtils.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,60 @@
import type { PackageManager } from '@/types/release';
import type { UserOS } from '@/types/userOS';

// A utility enum to help convert `userOs` data type to user-readable format
export enum OperatingSystem {
export enum OperatingSystemLabel {
WIN = 'Windows',
MAC = 'macOS',
LINUX = 'Linux',
AIX = 'AIX',
OTHER = 'Other',
}

export enum PackageManagerLabel {
NVM = 'nvm',
FNM = 'fnm',
BREW = 'Brew',
CHOCO = 'Chocolatey',
DOCKER = 'Docker',
}

export const operatingSystemItems = [
{
label: OperatingSystem.WIN,
label: OperatingSystemLabel.WIN,
value: 'WIN' as UserOS,
},
{
label: OperatingSystem.MAC,
label: OperatingSystemLabel.MAC,
value: 'MAC' as UserOS,
},
{
label: OperatingSystem.LINUX,
label: OperatingSystemLabel.LINUX,
value: 'LINUX' as UserOS,
},
{
label: OperatingSystem.AIX,
label: OperatingSystemLabel.AIX,
value: 'AIX' as UserOS,
},
];

export const platformItems = [
{
label: 'nvm',
label: PackageManagerLabel.NVM,
value: 'NVM' as PackageManager,
},
{
label: 'fnm',
label: PackageManagerLabel.FNM,
value: 'FNM' as PackageManager,
},
{
label: 'Brew',
label: PackageManagerLabel.BREW,
value: 'BREW' as PackageManager,
},
{
label: 'Chocolatey',
label: PackageManagerLabel.CHOCO,
value: 'CHOCO' as PackageManager,
},
{
label: 'Docker',
label: PackageManagerLabel.DOCKER,
value: 'DOCKER' as PackageManager,
},
];
Expand Down Expand Up @@ -160,8 +167,5 @@ export const mapCategoriesToTabs = ({
categories.map(({ category, label }) => ({
key: category,
label: label,
link:
category === 'download'
? `/${[page, subCategory].filter(Boolean).join('/')}`
: `/${[page, category, subCategory].filter(Boolean).join('/')}`,
link: `/${[page, category, subCategory].filter(Boolean).join('/')}`,
}));
20 changes: 19 additions & 1 deletion util/getNodeDownloadSnippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { NodeRelease } from '@/types';
import type { PackageManager } from '@/types/release';
import type { UserOS } from '@/types/userOS';

// @TODO: These snippets should be extracted to i18n (?)
export const getNodeDownloadSnippet = (release: NodeRelease, os: UserOS) => {
const snippets: Record<PackageManager, string> = {
NVM: '',
Expand All @@ -15,6 +16,11 @@ export const getNodeDownloadSnippet = (release: NodeRelease, os: UserOS) => {

if (os === 'WIN' || os === 'MAC' || os === 'LINUX') {
snippets.DOCKER = dedent`
# NOTE:
# Docker is not a Node.js package manager. Please ensure it is already installed
# on your system. Follow official instructions at https://docs.docker.com/desktop/
# Docker images are provided officially at https://github.com/nodejs/docker-node/

# pulls the Node.js Docker image
docker pull node:${release.major}-${release.major >= 4 ? 'alpine' : 'slim'}

Expand Down Expand Up @@ -53,6 +59,12 @@ export const getNodeDownloadSnippet = (release: NodeRelease, os: UserOS) => {
npm -v # should print \`${release.npm}\``;

snippets.BREW = dedent`
# NOTE:
# Homebrew is not a Node.js package manager. Please ensure it is already installed
# on your system. Follow official instructions at https://brew.sh/
# Homebrew only supports installing major Node.js versions and might not support
# the latest Node.js version from the ${release.major} release line.

# download and install Node.js
brew install node@${release.major}

Expand All @@ -78,11 +90,17 @@ export const getNodeDownloadSnippet = (release: NodeRelease, os: UserOS) => {
npm -v # should print \`${release.npm}\``;

snippets.CHOCO = dedent`
# NOTE:
# Chocolatey is not a Node.js package manager. Please ensure it is already installed
# on your system. Follow official instructions at https://chocolatey.org/
# Chocolatey is not officially maintained by the Node.js project and might not
# support the ${release.versionWithPrefix} version of Node.js

# download and install Node.js
choco install nodejs${release.isLts ? '-lts' : ''} --version="${release.version}"

# verifies the right Node.js version is in the environment
node -v # should print \`${release.versionWithPrefix}\`
node -v # should print \`${release.major}\`

# verifies the right NPM version is in the environment
npm -v # should print \`${release.npm}\``;
Expand Down
Loading