Skip to content

Commit e1910aa

Browse files
committed
feat: package-managers as default, redirects and more info
1 parent 73abd86 commit e1910aa

10 files changed

Lines changed: 82 additions & 69 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
node_modules
33
npm-debug.log
44
.npm
5-
.env.local
5+
.env.*
66

77
# Next.js Build Output
88
.next

components/Common/Badge/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const Badge: FC<PropsWithChildren<BadgeProps>> = ({
1919
<Link className={`${styles.wrapper} ${styles[kind]}`} {...args}>
2020
{badgeText && <span className={styles.badge}>{badgeText}</span>}
2121
<span className={styles.message}>{children}</span>
22-
<ArrowRightIcon className={styles.icon} />
22+
{args.href && <ArrowRightIcon className={styles.icon} />}
2323
</Link>
2424
);
2525

components/Downloads/Release/ReleaseCodeBox.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const ReleaseCodeBox: FC = () => {
2020
const t = useTranslations();
2121

2222
useEffect(() => {
23-
const updatedCode = getNodeDownloadSnippet(release, os)[platform];
23+
const updatedCode = getNodeDownloadSnippet(release)[platform];
2424
// Docker and NVM support downloading tags/versions by their full release number
2525
// but usually we should recommend users to download "major" versions
2626
// since our Downlooad Buttons get the latest minor of a major, it does make sense
@@ -43,9 +43,9 @@ const ReleaseCodeBox: FC = () => {
4343
)}
4444

4545
<span className="text-center text-xs text-neutral-800 dark:text-neutral-200">
46-
<b>{t('layouts.download.codeBox.managerInstalled')}</b>
47-
<br />
4846
{t('layouts.download.codeBox.communityWarning')}
47+
<br />
48+
<b>{t('layouts.download.codeBox.communityWarningReport')}</b>
4949
</span>
5050
</div>
5151
);

components/withDownloadCategories.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ const WithDownloadCategories: FC<PropsWithChildren> = async ({ children }) => {
2828
page: page,
2929
categories: [
3030
{
31-
category: 'download',
32-
label: t('layouts.download.categories.download'),
31+
category: 'package-manager',
32+
label: t('layouts.download.categories.package-manager'),
3333
},
3434
{
35-
category: 'prebuilt-binaries',
36-
label: t('layouts.download.categories.prebuilt-binaries'),
35+
category: 'prebuilt-installer',
36+
label: t('layouts.download.categories.prebuilt-installer'),
3737
},
3838
{
39-
category: 'package-manager',
40-
label: t('layouts.download.categories.package-manager'),
39+
category: 'prebuilt-binaries',
40+
label: t('layouts.download.categories.prebuilt-binaries'),
4141
},
4242
{
4343
category: 'source-code',

i18n/locales/en.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@
268268
"download": {
269269
"selectCategory": "Categories",
270270
"categories": {
271-
"download": "Prebuilt Installer",
271+
"prebuilt-installer": "Prebuilt Installer",
272272
"prebuilt-binaries": "Prebuilt Binaries",
273273
"package-manager": "Package Manager",
274274
"source-code": "Source Code"
@@ -284,8 +284,9 @@
284284
"platform": "Platform"
285285
},
286286
"codeBox": {
287-
"managerInstalled": "Please ensure you have the right package manager installed before running a script.",
288-
"communityWarning": "Package managers and their installation scripts are not maintained by the Node.js project."
287+
"systemManagerWarning": "is not a Node.js package manager. Please ensure you already have {packageManager} installed.",
288+
"communityWarning": "Package managers and their installation scripts are not maintained by the Node.js project.",
289+
"communityWarningReport": "If you encounter issues, please reach out to the package manager's maintainers."
289290
}
290291
}
291292
}
File renamed without changes.
File renamed without changes.

redirects.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@
271271
{
272272
"source": "/:locale/blog/weekly-updates/:path*",
273273
"destination": "/:locale/blog/weekly/:path*"
274+
},
275+
{
276+
"source": "/:locale/download",
277+
"destination": "/:locale/download/package-manager"
274278
}
275279
],
276280
"internal": []

util/downloadUtils.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,60 @@
11
import type { PackageManager } from '@/types/release';
22
import type { UserOS } from '@/types/userOS';
33

4-
// A utility enum to help convert `userOs` data type to user-readable format
5-
export enum OperatingSystem {
4+
export enum OperatingSystemLabel {
65
WIN = 'Windows',
76
MAC = 'macOS',
87
LINUX = 'Linux',
98
AIX = 'AIX',
109
OTHER = 'Other',
1110
}
1211

12+
export enum PackageManagerLabel {
13+
NVM = 'NVM',
14+
BREW = 'Brew',
15+
CHOCO = 'Chocolatey',
16+
DOCKER = 'Docker',
17+
}
18+
1319
export const operatingSystemItems = [
1420
{
15-
label: OperatingSystem.WIN,
21+
label: OperatingSystemLabel.WIN,
1622
value: 'WIN' as UserOS,
1723
},
1824
{
19-
label: OperatingSystem.MAC,
25+
label: OperatingSystemLabel.MAC,
2026
value: 'MAC' as UserOS,
2127
},
2228
{
23-
label: OperatingSystem.LINUX,
29+
label: OperatingSystemLabel.LINUX,
2430
value: 'LINUX' as UserOS,
2531
},
2632
{
27-
label: OperatingSystem.AIX,
33+
label: OperatingSystemLabel.AIX,
2834
value: 'AIX' as UserOS,
2935
},
3036
];
3137

3238
export const platformItems = [
3339
{
34-
label: 'NVM',
40+
label: PackageManagerLabel.NVM,
3541
value: 'NVM' as PackageManager,
42+
standalone: true,
3643
},
3744
{
38-
label: 'Brew',
45+
label: PackageManagerLabel.BREW,
3946
value: 'BREW' as PackageManager,
47+
standalone: false,
4048
},
4149
{
42-
label: 'Chocolatey',
50+
label: PackageManagerLabel.CHOCO,
4351
value: 'CHOCO' as PackageManager,
52+
standalone: false,
4453
},
4554
{
46-
label: 'Docker',
55+
label: PackageManagerLabel.DOCKER,
4756
value: 'DOCKER' as PackageManager,
57+
standalone: false,
4858
},
4959
];
5060

@@ -156,8 +166,5 @@ export const mapCategoriesToTabs = ({
156166
categories.map(({ category, label }) => ({
157167
key: category,
158168
label: label,
159-
link:
160-
category === 'download'
161-
? `/${[page, subCategory].filter(Boolean).join('/')}`
162-
: `/${[page, category, subCategory].filter(Boolean).join('/')}`,
169+
link: `/${[page, category, subCategory].filter(Boolean).join('/')}`,
163170
}));

util/getNodeDownloadSnippet.ts

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,67 @@ import dedent from 'dedent';
22

33
import type { NodeRelease } from '@/types';
44
import type { PackageManager } from '@/types/release';
5-
import type { UserOS } from '@/types/userOS';
65

7-
export const getNodeDownloadSnippet = (release: NodeRelease, os: UserOS) => {
6+
// @TODO: These snippets should be extracted to i18n (?)
7+
export const getNodeDownloadSnippet = (release: NodeRelease) => {
88
const snippets: Record<PackageManager, string> = {
9-
NVM: '',
10-
BREW: '',
11-
DOCKER: '',
12-
CHOCO: '',
13-
};
9+
NVM: dedent`
10+
# installs NVM (Node Version Manager)
11+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
1412
15-
switch (true) {
16-
case os === 'WIN' || os === 'MAC' || os === 'LINUX':
17-
snippets.DOCKER = dedent`
18-
# pulls the Node.js Docker image
19-
docker pull node:${release.major}-${release.major >= 4 ? 'alpine' : 'slim'}
13+
# download and install Node.js
14+
nvm install ${release.major}
2015
2116
# verifies the right Node.js version is in the environment
22-
docker run node:${release.major}-${release.major >= 4 ? 'alpine' : 'slim'} node -v # should print \`${release.versionWithPrefix}\`
17+
node -v # should print \`${release.versionWithPrefix}\`
2318
2419
# verifies the right NPM version is in the environment
25-
docker run node:${release.major}-${release.major >= 4 ? 'alpine' : 'slim'} npm -v # should print \`${release.npm}\``;
26-
// eslint-disable-next-line no-fallthrough
27-
case os === 'MAC' || os === 'LINUX':
28-
snippets.NVM = dedent`
29-
# installs NVM (Node Version Manager)
30-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
20+
npm -v # should print \`${release.npm}\``,
21+
BREW: dedent`
22+
# NOTE:
23+
# Homebrew is not a Node.js package manager. Please ensure it is already installed
24+
# on your system. Follow official instructions at https://brew.sh/
25+
# Homebrew only supports installing major Node.js versions and might not support
26+
# the latest Node.js version from the ${release.major} release line.
27+
28+
# download and install Node.js
29+
brew install node@${release.major}
3130
32-
# download and install Node.js
33-
nvm install ${release.major}
31+
# verifies the right Node.js version is in the environment
32+
node -v # should print \`${release.versionWithPrefix}\`
3433
35-
# verifies the right Node.js version is in the environment
36-
node -v # should print \`${release.versionWithPrefix}\`
34+
# verifies the right NPM version is in the environment
35+
npm -v # should print \`${release.npm}\``,
36+
DOCKER: dedent`
37+
# NOTE:
38+
# Docker is not a Node.js package manager. Please ensure it is already installed
39+
# on your system. Follow official instructions at https://docs.docker.com/desktop/
40+
# Docker images are provided officially at https://github.com/nodejs/docker-node/
3741
38-
# verifies the right NPM version is in the environment
39-
npm -v # should print \`${release.npm}\``;
42+
# pulls the Node.js Docker image
43+
docker pull node:${release.major}-${release.major >= 4 ? 'alpine' : 'slim'}
4044
41-
snippets.BREW = dedent`
42-
# download and install Node.js
43-
brew install node@${release.major}
45+
# verifies the right Node.js version is in the environment
46+
docker run node:${release.major}-${release.major >= 4 ? 'alpine' : 'slim'} node -v # should print \`${release.versionWithPrefix}\`
4447
45-
# verifies the right Node.js version is in the environment
46-
node -v # should print \`${release.versionWithPrefix}\`
48+
# verifies the right NPM version is in the environment
49+
docker run node:${release.major}-${release.major >= 4 ? 'alpine' : 'slim'} npm -v # should print \`${release.npm}\``,
50+
CHOCO: dedent`
51+
# NOTE:
52+
# Chocolatey is not a Node.js package manager. Please ensure it is already installed
53+
# on your system. Follow official instructions at https://chocolatey.org/
54+
# Chocolatey is not officially maintained by the Node.js project and might not
55+
# support the ${release.versionWithPrefix} version of Node.js
4756
48-
# verifies the right NPM version is in the environment
49-
npm -v # should print \`${release.npm}\``;
50-
// eslint-disable-next-line no-fallthrough
51-
case os === 'WIN':
52-
snippets.CHOCO = dedent`
5357
# download and install Node.js
5458
choco install nodejs${release.isLts ? '-lts' : ''} --version="${release.version}"
5559
5660
# verifies the right Node.js version is in the environment
57-
node -v # should print \`${release.versionWithPrefix}\`
61+
node -v # should print \`${release.major}\`
5862
5963
# verifies the right NPM version is in the environment
60-
npm -v # should print \`${release.npm}\``;
61-
// eslint-disable-next-line no-fallthrough
62-
default:
63-
break;
64-
}
64+
npm -v # should print \`${release.npm}\``,
65+
};
6566

6667
return snippets;
6768
};

0 commit comments

Comments
 (0)