sinonjs / sinon

Test spies, stubs and mocks for JavaScript.
https://sinonjs.org/
Other
9.64k stars 771 forks source link

docs: overview of compatible nodejs versions #2601

Closed Rotzbua closed 3 weeks ago

Rotzbua commented 4 months ago

Is your feature request related to a problem? Please describe.

The support docs states that the current LTS nodejs is supported.

For projects that are slower to upgrade the node version, it is difficult to find the correct sinon version, as the current LTS version is newer than the old one required by the projects. Currently it is difficult to find out which sinon version supports an old node version.

Describe the solution you'd like

Simple table which states which is the minimum supported node version for every mayor sinon version.

Sinon min Node
18 18
17 18

Describe alternatives you've considered

As alternative re-add and maintain engines attribute in package.json for upcoming releases. Was removed in #1608.

Additional context nope

fatso83 commented 4 months ago

Finding historic versions for Node is indeed a good case. I guess we could try to reflect this somehow. Maybe we should have a little unit test that checks the versions running on CI are the same ones listed. Not sure how to keep it in sync otherwise.

fatso83 commented 4 months ago

Thanks for the PR. I supplied feedback on https://github.com/sinonjs/sinon/pull/2602 last week.

Rotzbua commented 4 months ago

Thanks for the feedback. I used the “supported” node versions from the Github test script. If I understand your feedback correctly, this is not the node version for which it was explicitly built. It is instead based on the query maintained node versions from browserslistrc . To find out which node version the release was built for, you need to check what the package-lock.json returns at the build time. It could even be that during a patch a mayor version of node is no longer supported. Difficult to get it formally right. Actually, you would have to adapt the build script and publish the supported versions in the release or pin the supported versions and bump them with a mayor release....

fatso83 commented 4 months ago

It's possible to automate like this in our pipeline. This is how to extract the major versions:

❯  echo "node 20.10.0" | awk '{split($2, a, "."); print a[1]} '
20

So this would be sufficient to get the Node versions supported during a build:

npx browserslist 'maintained node versions'  | awk '{split($2, a, "."); print a[1]} '
20
18

Do you want to have a stab at how this could be used to automate updating some table or similarly?