@@ -2,66 +2,67 @@ import dedent from 'dedent';
22
33import type { NodeRelease } from '@/types' ;
44import 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