Skip to content

Commit 2b1ce9a

Browse files
authored
feat: add asdf install method (nodejs#8916)
* feat: add asdf install method * address asdf install feedback * update asdf snippet syntax * test: cover install method icon mapping
1 parent ee114b2 commit 2b1ce9a

6 files changed

Lines changed: 37 additions & 2 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# asdf has specific installation instructions for each operating system.
2+
# Please refer to the official documentation at https://asdf-vm.com/guide/getting-started.html.
3+
# This snippet uses asdf v0.16+ command syntax.
4+
5+
# Install the Node.js plugin:
6+
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
7+
8+
# Download and install Node.js:
9+
asdf install nodejs ${props.release.version}
10+
11+
# Set Node.js as the global default:
12+
asdf set --home nodejs ${props.release.version}

apps/site/types/release.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export type InstallationMethod =
88
| 'BREW'
99
| 'DOCKER'
1010
| 'CHOCO'
11-
| 'N';
11+
| 'N'
12+
| 'ASDF';
1213
export type PackageManager = 'NPM' | 'YARN' | 'PNPM';
1314

1415
// Items with a pipe/default value mean that they are auto inferred

apps/site/util/__tests__/download.test.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,13 @@ describe('nextItem', () => {
144144
assert.equal(nextItem('valid', items), 'valid');
145145
});
146146
});
147+
148+
describe('INSTALL_METHODS', () => {
149+
it('should create icons only when an icon is configured', () => {
150+
const nvmMethod = INSTALL_METHODS.find(method => method.value === 'NVM');
151+
const asdfMethod = INSTALL_METHODS.find(method => method.value === 'ASDF');
152+
153+
assert.ok(nvmMethod?.iconImage);
154+
assert.equal(asdfMethod?.iconImage, undefined);
155+
});
156+
});

apps/site/util/download/constants.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@
187187
},
188188
"url": "https://github.com/tj/n",
189189
"info": "layouts.download.codeBox.platformInfo.n"
190+
},
191+
{
192+
"id": "ASDF",
193+
"name": "asdf",
194+
"compatibility": {
195+
"os": ["MAC", "LINUX"]
196+
},
197+
"url": "https://asdf-vm.com/guide/getting-started.html",
198+
"info": "layouts.download.codeBox.platformInfo.asdf"
190199
}
191200
],
192201
"packageManagers": [

apps/site/util/download/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ export const INSTALL_METHODS = installMethods.map(method => ({
100100
key: method.id,
101101
value: method.id as Types.InstallationMethod,
102102
label: method.name as IntlMessageKeys,
103-
iconImage: createIcon(InstallMethodIcons, method.icon),
103+
iconImage: method.icon
104+
? createIcon(InstallMethodIcons, method.icon)
105+
: undefined,
104106
recommended: method.recommended,
105107
url: method.url,
106108
info: method.info as IntlMessageKeys,

packages/i18n/src/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@
299299
"choco": "Chocolatey is a package manager for Windows.",
300300
"docker": "Docker is a containerization platform.",
301301
"n": "\"n\" is a cross-platform Node.js version manager.",
302+
"asdf": "\"asdf\" is a cross-platform version manager that supports multiple languages.",
302303
"volta": "\"Volta\" is a cross-platform Node.js version manager."
303304
}
304305
}

0 commit comments

Comments
 (0)