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(download): add fnm to package managers for all platforms #6667

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

MattIPv4
Copy link
Member

@MattIPv4 MattIPv4 commented Apr 21, 2024

Description

Draft pending a vector logo for fnm (Schniz/fnm#798 (comment))

This adds fnm to the package managers download page dropdown, with support for macOS + Linux + Windows.

Of note:

  1. As part of this, I've added fnm as first in the list and changed the default to fnm. I feel this is appropriate as fnm is the only cross-platform option (and it in theory faster than NVM).

  2. I updated the logic in the snippet generator, replacing the switch with a set of if statements. I am unsure why the switch had linting disabled for the lack of break statements, but this was causing switch blocks to be evaluated when their OS condition did not match, which broke adding FNM.

Validation

fnm appears in the package manager dropdown, with the correct snippet showing for Windows, and macOS/Linux.

All other OS/manager combinations generate the correct snippets as on the production site.

Related Issues

Resolves #6490

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run npx turbo format to ensure the code follows the style guide.
  • I have run npx turbo test to check if all tests are passing.
  • I have run npx turbo build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

Copy link

vercel bot commented Apr 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview Apr 26, 2024 11:43am

@MattIPv4 MattIPv4 changed the title feat(download): add FNM to package mangers for all platforms feat(download): add FNM to package managers for all platforms Apr 21, 2024
@MattIPv4 MattIPv4 changed the title feat(download): add FNM to package managers for all platforms feat(download): add fnm to package managers for all platforms Apr 21, 2024
@ovflowd
Copy link
Member

ovflowd commented Apr 22, 2024

@MattIPv4 do you mind adding it after NVM? So that NVM is still the default (first one) for macOS/Linux?

All fine by me if it is the first one for Windows, since both on macOS/Linux Homebrew is also the 2nd one.

@MattIPv4
Copy link
Member Author

MattIPv4 commented Apr 22, 2024

@ovflowd sure, I can revert that, I kept it as a separate commit for that reason.

That being said, what is the reasoning for wanting to keep NVM as the default?

I outlined my justification for the change to fnm in the PR (it provides a faster (better) UX, and supports all platforms, so as the default folks get a consistent CLI no matter what platform they're on).

@ovflowd
Copy link
Member

ovflowd commented Apr 24, 2024

That being said, what is the reasoning for wanting to keep NVM as the default?

Based on overall popularity and download stats... and my own discretion/personal bias (ie, maintainers of NVM are close-knitted to Node.js, which means we can better support/communicate with each other)

But in the end, I'd say popularity is the primary reason.

We don't have guidelines about the order of the package managers / or even which ones should be added, so meanwhile I'm just using my own discretion. We can come up with a document in the future, as suggested by @ljharb

Copy link

github-actions bot commented Apr 24, 2024

Lighthouse Results

URL Performance Accessibility Best Practices SEO Report
/en 🟢 94 🟢 100 🟢 100 🟢 91 🔗
/en/about 🟢 99 🟢 100 🟢 100 🟢 91 🔗
/en/about/previous-releases 🟢 96 🟢 98 🟢 100 🟢 92 🔗
/en/download 🟢 97 🟢 100 🟢 100 🟢 91 🔗
/en/blog 🟢 98 🟢 100 🟢 100 🟢 92 🔗

Copy link

Unit Test Coverage Report

Lines Statements Branches Functions
Coverage: 91%
90% (585/650) 76.08% (175/230) 92.18% (118/128)

Unit Test Report

Tests Skipped Failures Errors Time
128 0 💤 0 ❌ 0 🔥 5.428s ⏱️

@MattIPv4
Copy link
Member Author

MattIPv4 commented Apr 24, 2024

But in the end, I'd say popularity is the primary reason.

I feel I should point out that this seems like a bit of a self-fulfilling prophecy if that is the main directive for what is listed first. If the most popular item is always listed first, it is never really going to give a chance to anything else to become the most popular, as its not what we're recommending by default (most users are probably just going to pick whatever we default to recommending).

That being said, reverted the swap.

@ovflowd
Copy link
Member

ovflowd commented Apr 26, 2024

But in the end, I'd say popularity is the primary reason.

I feel I should point out that this seems like a bit of a self-fulfilling prophecy if that is the main directive for what is listed first. If the most popular item is always listed first, it is never really going to give a chance to anything else to become the most popular, as its not what we're recommending by default (most users are probably just going to pick whatever we default to recommending).

That being said, reverted the swap.

@ljharb asked me to send this:

image

Copy link
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Awesome work put here :)

Can you double check edge scenarios are working as expected? And don't forget to rebase the code.

I saw that you changed from the (intentional) switch statement back to the if statements. Any reason? 🤔

@MattIPv4
Copy link
Member Author

@ljharb asked me to send this:

Yeh, I don't dispute that currently NVM is the most popular irrespective of what is default on the site for now. I just wish to note that the policy being that the most popular is set as the default seems like a good way to reinforce that the most popular remains the choice most folks will pick as it's the default.

@MattIPv4
Copy link
Member Author

I saw that you changed from the (intentional) switch statement back to the if statements. Any reason? 🤔

The switch statement was completely broken as far as I could tell -- it had no break statements, so if you were in an OS that matched the first condition, all the other conditions would get executed too. This made it impossible to use for fnm, as if the macOS/Linux condition matched, the Windows condition would get executed too, and so the wrong snippet was returned.

@ovflowd
Copy link
Member

ovflowd commented Apr 26, 2024

is set as the default seems like a good way to reinforce that the most popular remains the choice most folks will pick as it's the default.

Wouldn't doing the opposite also create the same effect?

@ovflowd
Copy link
Member

ovflowd commented Apr 26, 2024

The switch statement was completely broken as far as I could tell -- it had no break statements, so if you were in an OS that matched the first condition, all the other conditions would get executed too. This made it impossible to use for fnm, as if the macOS/Linux condition matched, the Windows condition would get executed too, and so the wrong snippet was returned.

That was intentional. It was not broken. The lack of break statement simply keeps the switch statement looking for next matches.

Please, revert the logic. Otherwise how do you think that currently nodejs.org is working fine? 😅

@MattIPv4
Copy link
Member Author

It seems to be working just fine on this preview? If I revert, how do you propose I add fnm support, as it cannot be present in the switch twice?

I'd consider a switch without break statements, and needing the linter to be disabled, to be a giant anti-pattern. And if statement is far clearer in intention, and I'm pretty sure it still functions correctly...

@MattIPv4
Copy link
Member Author

MattIPv4 commented Apr 26, 2024

When a switch statement lacks breaks, it does NOT look for the next match, it runs every block after the one that matched, irrespective of the condition on the subsequent blocks.

@ovflowd
Copy link
Member

ovflowd commented Apr 26, 2024

When a switch statement lacks breaks, it does NOT look for the next match, it runs every block after the one that matched, irrespective of the condition on the subsequent blocks.

You are right, that seems a huge oversight from my side. I'm used with break/continue statement logic in other sort of loops, and forgot this doesn't apply to switch statements

@MattIPv4
Copy link
Member Author

Wouldn't doing the opposite also create the same effect?

That is true, though I'd argue that giving the spotlight to tools that aren't the most popular is far less of a self-fulfilling prophecy than keeping it on the already established most popular option forever.

@MattIPv4
Copy link
Member Author

Given the approvals, did you want to merge this as-is with the raster icon and the todo, and follow-up when a vector is available, or would you rather hold this as a draft for now?

@ovflowd
Copy link
Member

ovflowd commented Apr 26, 2024

Wouldn't doing the opposite also create the same effect?

That is true, though I'd argue that giving the spotlight to tools that aren't the most popular is far less of a self-fulfilling prophecy than keeping it on the already established most popular option forever.

I understand your statement, but I want to keep biases off here. At this moment, the change of making fnm the first option should not be part of a PR adding fnm to the list. It's implicit/explicit bias, and I'm more than happy if you open a discussion thread to argument about that, although I believe these are highly personal arguments at best.

@ovflowd
Copy link
Member

ovflowd commented Apr 26, 2024

Given the approvals, did you want to merge this as-is with the raster icon and the todo, and follow-up when a vector is available, or would you rather hold this as a draft for now?

We can wait for a vector image to be done :)

@ovflowd
Copy link
Member

ovflowd commented Apr 30, 2024

@MattIPv4 are you waiting for someone specifically to make the SVG=

@MattIPv4
Copy link
Member Author

I had pinged @Schniz in Schniz/fnm#798 (comment), but given the lack of response, I'll see if I can find some time myself to manually recreate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Offer fnm as an installation option on all platforms
3 participants