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

[ls-remote] only list active and/or maintained versions #3250

Open
ryenus opened this issue Dec 19, 2023 · 16 comments · May be fixed by #3277
Open

[ls-remote] only list active and/or maintained versions #3250

ryenus opened this issue Dec 19, 2023 · 16 comments · May be fixed by #3277
Labels
feature requests I want a new feature in nvm!

Comments

@ryenus
Copy link
Contributor

ryenus commented Dec 19, 2023

What happened?

Currently nvm ls-remote --lts literally list all the LTS versions, including the ones are no longer in active and/or maintenance status.

What did you expect to happen?

The most common usage of nvm ls-remote is to check for new versions, which is only relevant for currently supported versions, namely the ones in active and/or maintenance phases.

Therefore it would make sense to allow one to only list the currently supported versions, or to exclude the no longer supported versions.

If the default behavior cannot be changed, it would make sense to introduce certain command line options, such as --supported or --no-supported.

And we can use awk to parse the nodejs release schedule json to find supported versions, with end date later than the current date, for example:

$ curl -sL https://raw.githubusercontent.com/nodejs/Release/main/schedule.json |\
  awk -vT=$(date +%F) '{if($1~/v[0-9]+/){v=$1;gsub(/[":]/,"",v);while($1!~/end/)getline;
  e=$2;gsub(/[",]/,"",e);if(e>=T)print v,e}}'
v18 2025-04-30
v20 2026-04-30
v21 2024-06-01
v22 2027-04-30
v23 2025-06-01
v24 2028-04-30
@ljharb
Copy link
Member

ljharb commented Dec 19, 2023

No, because that's a function of time, and that's not something I want nvm's output to depend on.

@ljharb ljharb added the feature requests I want a new feature in nvm! label Dec 19, 2023
@ryenus
Copy link
Contributor Author

ryenus commented Dec 19, 2023

Hmm, even if the content of https://nodejs.org/dist/index.tab is also somehow a function of time?

@ljharb
Copy link
Member

ljharb commented Dec 19, 2023

It's not in the sense that nvm doesn't need to know the current date/time.

@ryenus ryenus changed the title [ls-morete] possible to only list active and/or maintained versions? [ls-remote] possible to only list active and/or maintained versions? Dec 19, 2023
@ryenus
Copy link
Contributor Author

ryenus commented Dec 19, 2023

TBH I don't see why we cannot put it behind a flag such as --supported, meanwhile maintain the existing behaviour as default?

@ljharb
Copy link
Member

ljharb commented Dec 19, 2023

Of course we could. However, I don't think it would be a good idea to have anything depend on "the current date", and, if there were any way for a project's preferred node version to change based on the passage of time, then it would be possible for nvm use inside a project to work one day, and stop working the next, which would be both unacceptable and violate semver.

@ryenus
Copy link
Contributor Author

ryenus commented Dec 19, 2023

for a project's preferred node version to change based on the passage of time

Hmm, here the request is only about nvm ls-remote, with no involvement with nvm use at all.

@ljharb
Copy link
Member

ljharb commented Dec 19, 2023

That affects nvm install as well, though.

@ryenus
Copy link
Contributor Author

ryenus commented Dec 19, 2023

That affects nvm install as well, though.

Maybe not if it's an option only for nvm ls-remote?

I guess this request would be more appealing back when nvm_print_versions was quite slow before it was reimplemented using awk.

Nowadays it's pretty fast. But in the context of using nvm ls-remote to check for newer versions, the no longer supported versions are NOT going to get new versions at all, that's where this option can be useful, by making the output less cluttered.

@ljharb
Copy link
Member

ljharb commented Dec 19, 2023

Is your motivation to hasten/shorten the response of nvm ls-remote? That's very different from the OP :-)

@ryenus
Copy link
Contributor Author

ryenus commented Dec 19, 2023

Is your motivation to hasten/shorten the response of nvm ls-remote?

Well yes, that's it.

BTW, and which OP? I guess I'm a bit confused.

@ljharb
Copy link
Member

ljharb commented Dec 19, 2023

I meant your original post.

@ryenus
Copy link
Contributor Author

ryenus commented Dec 19, 2023

Ahh, I was actually thinking the same, maybe my OP should have been more concise :-)

@ljharb
Copy link
Member

ljharb commented Dec 19, 2023

Would a --min=18, for example, suffice here? basically it'd all work the same except it would omit displaying anything before v18 (and i'd optimize to skip contacting iojs.org entirely when the version was >= 4, etc)

@ryenus
Copy link
Contributor Author

ryenus commented Dec 20, 2023

Would a --min=18, for example, suffice here?

Yes, that also works! And it has the advantage of being more flexible.

Maybe we can even have it as the default? So that in the most common use case we save several keystrokes for all the users :-) Meanwhile those who want the old behavior can use --min=0.

@ljharb
Copy link
Member

ljharb commented Dec 20, 2023

I'm not quite comfortable with that level of a breaking change just yet; but perhaps I could also add an env var that sets that value, so it's easy to set your own default?

@ryenus
Copy link
Contributor Author

ryenus commented Dec 20, 2023

add an env var that sets that value, so it's easy to set your own default?

That would be really great! Much appreciated 👍

@ryenus ryenus changed the title [ls-remote] possible to only list active and/or maintained versions? [ls-remote] only list active and/or maintained versions Dec 22, 2023
@ryenus ryenus linked a pull request Jan 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature requests I want a new feature in nvm!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@ljharb @ryenus and others