pkgxdev / pkgx

run anything
https://pkgx.sh
Apache License 2.0
8.97k stars 1.36k forks source link

`pkgx pin node@18` #666

Open felipecrs opened 1 year ago

felipecrs commented 1 year ago

I am a big fan of Volta, and I believe it was quite revolutionary when it first appeared. I switched from NVM to it, and I never looked back. I always wished there were tools like Volta but for other things like Python and Java. To my happy surprise, tea is becoming it.

Maybe some other day I'll elaborate more on why I think tea is very similar to Volta.

There is a handy tool in Volta which is: volta pin node@18 npm@9, which calculates the full sharp version of node and npm matching the version constraint and writes it to the volta key in the package.json.

Writing the full version as opposed to writing just @18 to the package.json has advantages, like bringing reproducibility to CI/CD builds and colleagues environments. We can't deny things breaks sometimes even for packages adopting semantic versioning.

Nevertheless, it would be quite painful having to search the web for the latest node@18 and npm@9 every time I want to upgrade to latest patch or minor.

Maybe some command like tea pin node@18 could:

  1. Fetch the latest version of node@18
  2. Find where node's version was fetched from. Example:
    $ cat .node-version
    18.14.2
  3. Make the replacement automatically, i.e. change .node-version from 18.14.2 to 18.17.0.
  4. If no file or source of the version was found, tea could create a .tea.yml automatically to perform the pinning process on the current folder.
mxcl commented 1 year ago

all files tea supports are considered before defining the pkgenv so we could just default to tea.yaml or some other file like tea.lock.yaml.

This is a good op for adding a new pkg to tea that “provides” tea-pin since tea automatically installs anything that is requested and understands how to install commands on itself. Could be a separate project if you have interest.

we would then roll the feature into tea proper once it has matured

Otherwise I do not currently have good understanding on how pinning would work so it's not in my immediate attention.

However I agree that such a feature has definite value.