11import dedent from 'dedent' ;
2+ import type { TranslationValues } from 'next-intl' ;
23
34import type { NodeRelease } from '@/types' ;
45import type { PackageManager } from '@/types/release' ;
56import type { UserOS } from '@/types/userOS' ;
67
7- // @TODO : These snippets should be extracted to i18n (?)
8- export const getNodeDownloadSnippet = ( release : NodeRelease , os : UserOS ) => {
8+ export const getNodeDownloadSnippet = (
9+ release : NodeRelease ,
10+ os : UserOS ,
11+ t : ( key : string , values ?: TranslationValues ) => string
12+ ) => {
913 const snippets : Record < PackageManager , string > = {
1014 NVM : '' ,
1115 FNM : '' ,
@@ -16,94 +20,95 @@ export const getNodeDownloadSnippet = (release: NodeRelease, os: UserOS) => {
1620
1721 if ( os === 'WIN' || os === 'MAC' || os === 'LINUX' ) {
1822 snippets . DOCKER = dedent `
19- # NOTE:
20- # Docker is not a Node.js package manager. Please ensure it is already installed
21- # on your system. Follow official instructions at https://docs.docker.com/desktop/
22- # Docker images are provided officially at https://github.com/nodejs/docker-node/
23+ # ${ t ( 'layouts.download.codeBox.noteWithColon' ) }
24+ # ${ t ( 'layouts.download.codeBox.dockerIsNotNodejsPackageManager' ) }
25+ # ${ t ( 'layouts.download.codeBox.PleaseEndureAlreadyInstallOnSystem' ) }
26+ # ${ t ( 'layouts.download.codeBox.dockerInstructions' ) }
27+ # ${ t ( 'layouts.download.codeBox.dockerImagesLink' ) }
2328
24- # pulls the Node.js Docker image
29+ # ${ t ( 'layouts.download.codeBox.pullsNodejsDockerImage' ) }
2530 docker pull node:${ release . major } -${ release . major >= 4 ? 'alpine' : 'slim' }
2631
27- # verifies the right Node.js version is in the environment
28- docker run node:${ release . major } -${ release . major >= 4 ? 'alpine' : 'slim' } node -v # should print \` ${ release . versionWithPrefix } \`
32+ # ${ t ( 'layouts.download.codeBox.verifiesRightNodejsVersion' ) }
33+ docker run node:${ release . major } -${ release . major >= 4 ? 'alpine' : 'slim' } node -v # ${ t ( 'layouts.download.codeBox.shouldPrint' , { version : release . versionWithPrefix } ) }
2934
30- # verifies the right NPM version is in the environment
31- docker run node:${ release . major } -${ release . major >= 4 ? 'alpine' : 'slim' } npm -v # should print \` ${ release . npm } \` ` ;
35+ # ${ t ( 'layouts.download.codeBox.verifiesRightNpmVersion' ) }
36+ docker run node:${ release . major } -${ release . major >= 4 ? 'alpine' : 'slim' } npm -v # ${ t ( 'layouts.download.codeBox.shouldPrint' , { version : release . npm } ) } ` ;
3237 }
3338
3439 if ( os === 'MAC' || os === 'LINUX' ) {
3540 snippets . NVM = dedent `
36- # installs nvm (Node Version Manager)
41+ # ${ t ( 'layouts.download.codeBox.installsNvm' ) }
3742 curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
3843
39- # download and install Node.js (you may need to restart the terminal)
44+ # ${ t ( 'layouts. download.codeBox.downloadAndInstallNodejsRestartTerminal' ) }
4045 nvm install ${ release . major }
4146
42- # verifies the right Node.js version is in the environment
43- node -v # should print \` ${ release . versionWithPrefix } \`
47+ # ${ t ( 'layouts.download.codeBox.verifiesRightNodejsVersion' ) }
48+ node -v # ${ t ( 'layouts.download.codeBox.shouldPrint' , { version : release . versionWithPrefix } ) }
4449
45- # verifies the right NPM version is in the environment
46- npm -v # should print \` ${ release . npm } \` ` ;
50+ # ${ t ( 'layouts.download.codeBox.verifiesRightNpmVersion' ) }
51+ npm -v # ${ t ( 'layouts.download.codeBox.shouldPrint' , { version : release . npm } ) } ` ;
4752
4853 snippets . FNM = dedent `
49- # installs fnm (Fast Node Manager)
54+ # ${ t ( 'layouts.download.codeBox.installsFnm' ) }
5055 curl -fsSL https://fnm.vercel.app/install | bash
5156
52- # download and install Node.js
57+ # ${ t ( 'layouts. download.codeBox.downloadAndInstallNodejs' ) }
5358 fnm use --install-if-missing ${ release . major }
5459
55- # verifies the right Node.js version is in the environment
56- node -v # should print \` ${ release . versionWithPrefix } \`
60+ # ${ t ( 'layouts.download.codeBox.verifiesRightNodejsVersion' ) }
61+ node -v # ${ t ( 'layouts.download.codeBox.shouldPrint' , { version : release . versionWithPrefix } ) }
5762
58- # verifies the right NPM version is in the environment
59- npm -v # should print \` ${ release . npm } \` ` ;
63+ # ${ t ( 'layouts.download.codeBox.verifiesRightNpmVersion' ) }
64+ npm -v # ${ t ( 'layouts.download.codeBox.shouldPrint' , { version : release . npm } ) } ` ;
6065
6166 snippets . BREW = dedent `
62- # NOTE:
63- # Homebrew is not a Node.js package manager. Please ensure it is already installed
64- # on your system. Follow official instructions at https://brew.sh/
65- # Homebrew only supports installing major Node.js versions and might not support
66- # the latest Node.js version from the ${ release . major } release line.
67+ # ${ t ( 'layouts.download.codeBox.noteWithColon' ) }
68+ # ${ t ( 'layouts.download.codeBox.homebrewIsNotNodejsPackageManager' ) }
69+ # ${ t ( 'layouts.download.codeBox.PleaseEndureAlreadyInstallOnSystem' ) }
70+ # ${ t ( 'layouts.download.codeBox.homebrewInstructions' ) }
71+ # ${ t ( 'layouts.download.codeBox.homebrewSupportsIntallingMajorNodejsVersion' , { version : release . major } ) }
6772
68- # download and install Node.js
73+ # ${ t ( 'layouts. download.codeBox.downloadAndInstallNodejs' ) }
6974 brew install node@${ release . major }
7075
71- # verifies the right Node.js version is in the environment
72- node -v # should print \` ${ release . versionWithPrefix } \`
76+ # ${ t ( 'layouts.download.codeBox.verifiesRightNodejsVersion' ) }
77+ node -v # ${ t ( 'layouts.download.codeBox.shouldPrint' , { version : release . versionWithPrefix } ) }
7378
74- # verifies the right NPM version is in the environment
75- npm -v # should print \` ${ release . npm } \` ` ;
79+ # ${ t ( 'layouts.download.codeBox.verifiesRightNpmVersion' ) }
80+ npm -v # ${ t ( 'layouts.download.codeBox.shouldPrint' , { version : release . npm } ) } ` ;
7681 }
7782
7883 if ( os === 'WIN' ) {
7984 snippets . FNM = dedent `
80- # installs fnm (Fast Node Manager)
85+ # ${ t ( 'layouts.download.codeBox.installsFnm' ) }
8186 winget install Schniz.fnm
8287
83- # download and install Node.js
88+ # ${ t ( 'layouts. download.codeBox.downloadAndInstallNodejs' ) }
8489 fnm use --install-if-missing ${ release . major }
8590
86- # verifies the right Node.js version is in the environment
87- node -v # should print \` ${ release . versionWithPrefix } \`
91+ # ${ t ( 'layouts.download.codeBox.verifiesRightNodejsVersion' ) }
92+ node -v # ${ t ( 'layouts.download.codeBox.shouldPrint' , { version : release . versionWithPrefix } ) }
8893
89- # verifies the right NPM version is in the environment
90- npm -v # should print \` ${ release . npm } \` ` ;
94+ # ${ t ( 'layouts.download.codeBox.verifiesRightNpmVersion' ) }
95+ npm -v # ${ t ( 'layouts.download.codeBox.shouldPrint' , { version : release . npm } ) } ` ;
9196
9297 snippets . CHOCO = dedent `
93- # NOTE:
94- # Chocolatey is not a Node.js package manager. Please ensure it is already installed
95- # on your system. Follow official instructions at https://chocolatey.org/
96- # Chocolatey is not officially maintained by the Node.js project and might not
97- # support the ${ release . versionWithPrefix } version of Node.js
98+ # ${ t ( 'layouts.download.codeBox.noteWithColon' ) }
99+ # ${ t ( 'layouts.download.codeBox.chocolateyIsNotNodejsPackageManager' ) }
100+ # ${ t ( 'layouts.download.codeBox.PleaseEndureAlreadyInstallOnSystem' ) }
101+ # ${ t ( 'layouts.download.codeBox.chocolateyInstructions' ) }
102+ # ${ t ( 'layouts.download.codeBox.chocolateyNotMaintanedByNodejs' , { version : release . versionWithPrefix } ) }
98103
99- # download and install Node.js
104+ # ${ t ( 'layouts. download.codeBox.downloadAndInstallNodejs' ) }
100105 choco install nodejs${ release . isLts ? '-lts' : '' } --version="${ release . version } "
101106
102- # verifies the right Node.js version is in the environment
103- node -v # should print \` ${ release . major } \`
107+ # ${ t ( 'layouts.download.codeBox.verifiesRightNodejsVersion' ) }
108+ node -v # ${ t ( 'layouts.download.codeBox.shouldPrint' , { version : release . major } ) }
104109
105- # verifies the right NPM version is in the environment
106- npm -v # should print \` ${ release . npm } \` ` ;
110+ # ${ t ( 'layouts.download.codeBox.verifiesRightNpmVersion' ) }
111+ npm -v # ${ t ( 'layouts.download.codeBox.shouldPrint' , { version : release . npm } ) } ` ;
107112 }
108113
109114 return snippets ;
0 commit comments